json: Clean up json smoke test
This commit is contained in:
parent
4fb5707b25
commit
5a47d5548c
1 changed files with 16 additions and 20 deletions
|
@ -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
|
||||
```
|
||||
|
|
Loading…
Add table
Reference in a new issue