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