@@ -51,17 +51,18 @@ genJson n = frequency (Tuple 1.0 genJNull) rest where
51
51
Tuple 1.0 (genJArray n),
52
52
Tuple 1.0 (genJObject n)]
53
53
54
- -- orphan, but it's just for tests
55
- instance arbitraryJson :: Arbitrary Json where
56
- arbitrary = sized genJson
54
+ newtype TestJson = TestJson Json
57
55
56
+ instance arbitraryTestJson :: Arbitrary TestJson where
57
+ arbitrary = TestJson <$> sized genJson
58
58
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) =
61
62
Right json == (decodeJson $ encodeJson $ json)
62
63
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) =
65
66
let decoded = (decodeJson json) :: Either String Json in
66
67
Right json == (decoded >>= (encodeJson >>> pure))
67
68
@@ -90,9 +91,10 @@ instance arbitraryObj :: Arbitrary Obj where
90
91
arbitrary = Obj <$> (genJObject 5 )
91
92
92
93
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)) =
95
96
let appended = assoc ~> obj
97
+ assoc = Tuple key val
96
98
in case toObject appended >>= M .lookup key of
97
99
Just val -> true
98
100
_ -> false
0 commit comments