@@ -72,16 +72,11 @@ modifyFailureProp orig added =
72 result :: Result ()
72 result :: Result ()
73 result = parse parser ()
73 result = parse parser ()
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.
76sameAs :: (a -> Value) -> (a -> Encoding) -> a -> Property
78sameAs :: (a -> Value) -> (a -> Encoding) -> a -> Property
77sameAs toVal toEnc v =
79sameAs toVal toEnc v =
78− toLazyByteString (encodeToBuilder (toVal v)) ===
79− toLazyByteString (fromEncoding (toEnc v))
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 =
85 eitherDecode (toLazyByteString (fromEncoding (toEnc v))) === Right (toVal v)
80 eitherDecode (toLazyByteString (fromEncoding (toEnc v))) === Right (toVal v)
87type P6 = Product6 Int Bool String (Approx Double) (Int, Approx Double) ()
82type P6 = Product6 Int Bool String (Approx Double) (Int, Approx Double) ()
@@ -202,11 +197,11 @@ tests = testGroup "properties" [
202 , testProperty "ApproxDefault" $
197 , testProperty "ApproxDefault" $
203 thApproxToJSONDefault `sameAs` thApproxToEncodingDefault
198 thApproxToJSONDefault `sameAs` thApproxToEncodingDefault
204 , testProperty "SomeType2ElemArray" $
199 , testProperty "SomeType2ElemArray" $
205− thSomeTypeToJSON2ElemArray `sameAsV` thSomeTypeToEncoding2ElemArray
200+ thSomeTypeToJSON2ElemArray `sameAs` thSomeTypeToEncoding2ElemArray
206 , testProperty "SomeTypeTaggedObject" $
201 , testProperty "SomeTypeTaggedObject" $
207− thSomeTypeToJSONTaggedObject `sameAsV` thSomeTypeToEncodingTaggedObject
202+ thSomeTypeToJSONTaggedObject `sameAs` thSomeTypeToEncodingTaggedObject
208 , testProperty "SomeTypeObjectWithSingleField" $
203 , testProperty "SomeTypeObjectWithSingleField" $
209− thSomeTypeToJSONObjectWithSingleField `sameAsV`
204+ thSomeTypeToJSONObjectWithSingleField `sameAs`
210 thSomeTypeToEncodingObjectWithSingleField
205 thSomeTypeToEncodingObjectWithSingleField