json: Clean up json smoke test

This commit is contained in:
Nathan McCarty 2025-01-26 15:47:02 -05:00
parent 4fb5707b25
commit 5a47d5548c

View file

@ -68,6 +68,7 @@ Show (JSONValue t) where
show (VBool True) = "true"
show VNull = "null"
-- TODO: Deal with keys potentially having different orders in different objects
Eq (JSONValue t) where
(VObject xs) == (VObject ys) =
assert_total $ xs $== ys
@ -263,25 +264,20 @@ quickSmoke = do
printLn err
pure False
putStrLn "Input: \{input}\nOutput: \{show type} -> \{show parsed}"
case parsed of
VObject {types} xs => do
putStrLn "Output types: \{show types}"
case decEq types [TString, TNumber, TBool, TBool, TNull, TArray] of
No contra => pure False
Yes Refl => case xs of
[ ("string", str)
, ("number", num)
, ("true", bool_t)
, ("false", bool_f)
, ("null", nul)
, ("array", arr)
] => pure $
str == VString "string"
&& num == VNumber 5.0
&& bool_t == VBool True
&& bool_f == VBool False
&& nul == VNull
&& arr == VArray [VNumber 1.0, VNumber 2.0, VNumber 3.0]
_ => pure False
let reference_object =
VObject [
("string", VString "string")
, ("number", VNumber 5.0)
, ("true", VBool True)
, ("false", VBool False)
, ("null", VNull)
, ("array", VArray [
VNumber 1.0
, VNumber 2.0
, VNumber 3.0
])
]
case type of
TObject => pure $ parsed == reference_object
_ => pure False
```