@@ -72,16 +72,11 @@ modifyFailureProp orig added =
7272 result :: Result ()
7373 result = parse parser ()
7474
75−-- | Perform a bit-for-bit comparison of two encoding methods.
75+-- | Perform a structural comparison of the results of two encoding
76+-- methods. Compares decoded values to account for HashMap-driven
77+-- variation in JSON object key ordering.
7678sameAs :: (a -> Value) -> (a -> Encoding) -> a -> Property
7779sameAs toVal toEnc v =
78− toLazyByteString (encodeToBuilder (toVal v)) ===
79− toLazyByteString (fromEncoding (toEnc v))
80−
81−-- | Behaves like 'sameAs', but compares decoded values to account for
82−-- HashMap-driven variation in JSON object key ordering.
83−sameAsV :: (a -> Value) -> (a -> Encoding) -> a -> Property
84−sameAsV toVal toEnc v =
8580 eitherDecode (toLazyByteString (fromEncoding (toEnc v))) === Right (toVal v)
8681
8782type P6 = Product6 Int Bool String (Approx Double) (Int, Approx Double) ()
@@ -202,11 +197,11 @@ tests = testGroup "properties" [
202197 , testProperty "ApproxDefault" $
203198 thApproxToJSONDefault `sameAs` thApproxToEncodingDefault
204199 , testProperty "SomeType2ElemArray" $
205− thSomeTypeToJSON2ElemArray `sameAsV` thSomeTypeToEncoding2ElemArray
200+ thSomeTypeToJSON2ElemArray `sameAs` thSomeTypeToEncoding2ElemArray
206201 , testProperty "SomeTypeTaggedObject" $
207− thSomeTypeToJSONTaggedObject `sameAsV` thSomeTypeToEncodingTaggedObject
202+ thSomeTypeToJSONTaggedObject `sameAs` thSomeTypeToEncodingTaggedObject
208203 , testProperty "SomeTypeObjectWithSingleField" $
209− thSomeTypeToJSONObjectWithSingleField `sameAsV`
204+ thSomeTypeToJSONObjectWithSingleField `sameAs`
210205 thSomeTypeToEncodingObjectWithSingleField
211206 ]
212207 ]