fix: tests
This commit is contained in:
parent
18921e06d1
commit
ca81f3b0f2
@ -10,7 +10,7 @@ import Data.Aeson
|
|||||||
import Data.Aeson.Encoding.Internal
|
import Data.Aeson.Encoding.Internal
|
||||||
import Data.Aeson.Types (parseMaybe)
|
import Data.Aeson.Types (parseMaybe)
|
||||||
import Data.Proxy
|
import Data.Proxy
|
||||||
import Unsafe.Coerce -- DON'T PANIC, it's aeson's fault
|
import Data.Coerce
|
||||||
|
|
||||||
jsonKeyLaws :: forall a. (Arbitrary a, FromJSONKey a, ToJSONKey a, Eq a, Show a, FromJSON a, ToJSON a) => Proxy a -> Laws
|
jsonKeyLaws :: forall a. (Arbitrary a, FromJSONKey a, ToJSONKey a, Eq a, Show a, FromJSON a, ToJSON a) => Proxy a -> Laws
|
||||||
jsonKeyLaws _ = Laws "ToJSONKey/FromJSONKey"
|
jsonKeyLaws _ = Laws "ToJSONKey/FromJSONKey"
|
||||||
@ -26,8 +26,8 @@ jsonKeyLaws _ = Laws "ToJSONKey/FromJSONKey"
|
|||||||
where
|
where
|
||||||
partialIsomorphism :: forall a'. (FromJSONKey a', ToJSONKey a', Eq a') => a' -> Property
|
partialIsomorphism :: forall a'. (FromJSONKey a', ToJSONKey a', Eq a') => a' -> Property
|
||||||
partialIsomorphism a = case (toJSONKey, fromJSONKey) of
|
partialIsomorphism a = case (toJSONKey, fromJSONKey) of
|
||||||
(ToJSONKeyText toVal _, FromJSONKeyCoerce _)
|
(ToJSONKeyText toVal _, FromJSONKeyCoerce)
|
||||||
-> property $ unsafeCoerce (toVal a) == a
|
-> property $ coerce (toVal a) == a
|
||||||
(ToJSONKeyText toVal _, FromJSONKeyText fromVal)
|
(ToJSONKeyText toVal _, FromJSONKeyText fromVal)
|
||||||
-> property $ fromVal (toVal a) == a
|
-> property $ fromVal (toVal a) == a
|
||||||
(ToJSONKeyText toVal _, FromJSONKeyTextParser parser)
|
(ToJSONKeyText toVal _, FromJSONKeyTextParser parser)
|
||||||
|
|||||||
Reference in New Issue
Block a user