@@ -51,17 +51,18 @@ genJson n = frequency (Tuple 1.0 genJNull) rest where
5151 Tuple 1.0 (genJArray n),
5252 Tuple 1.0 (genJObject n)]
5353
54- -- orphan, but it's just for tests
55- instance arbitraryJson :: Arbitrary Json where
56- arbitrary = sized genJson
54+ newtype TestJson = TestJson Json
5755
56+ instance arbitraryTestJson :: Arbitrary TestJson where
57+ arbitrary = TestJson <$> sized genJson
5858
59- prop_encode_then_decode :: Json -> Boolean
60- prop_encode_then_decode json =
59+
60+ prop_encode_then_decode :: TestJson -> Boolean
61+ prop_encode_then_decode (TestJson json) =
6162 Right json == (decodeJson $ encodeJson $ json)
6263
63- prop_decode_then_encode :: Json -> Boolean
64- prop_decode_then_encode json =
64+ prop_decode_then_encode :: TestJson -> Boolean
65+ prop_decode_then_encode ( TestJson json) =
6566 let decoded = (decodeJson json) :: Either String Json in
6667 Right json == (decoded >>= (encodeJson >>> pure))
6768
@@ -90,9 +91,10 @@ instance arbitraryObj :: Arbitrary Obj where
9091 arbitrary = Obj <$> (genJObject 5 )
9192
9293
93- prop_assoc_append :: (Tuple JAssoc Obj ) -> Boolean
94- prop_assoc_append (Tuple assoc@ (Tuple key val) (Obj obj)) =
94+ prop_assoc_append :: (Tuple ( Tuple String TestJson ) Obj ) -> Boolean
95+ prop_assoc_append (Tuple (Tuple key ( TestJson val) ) (Obj obj)) =
9596 let appended = assoc ~> obj
97+ assoc = Tuple key val
9698 in case toObject appended >>= M .lookup key of
9799 Just val -> true
98100 _ -> false
0 commit comments