genvalidity-hspec-aeson-0.2.0.0: Standard spec's for aeson-related instances

Safe HaskellNone
LanguageHaskell2010

Test.Validity.Aeson

Description

Standard test Specs and raw Propertys for FromJSON and ToJSON instances.

You will need TypeApplications to use these.

Synopsis

Documentation

jsonSpecOnValid :: forall a. (Show a, Eq a, Typeable a, GenValid a, FromJSON a, ToJSON a) => Spec Source #

Standard test spec for properties of JSON-related functions for valid values

Example usage:

jsonSpecOnValid @Double

jsonSpec :: forall a. (Show a, Eq a, Typeable a, GenUnchecked a, FromJSON a, ToJSON a) => Spec Source #

Standard test spec for properties of JSON-related functions for unchecked values

Example usage:

jsonSpec @Int

jsonSpecOnArbitrary :: forall a. (Show a, Eq a, Typeable a, Arbitrary a, FromJSON a, ToJSON a) => Spec Source #

Standard test spec for properties of JSON-related functions for arbitrary values

Example usage:

jsonSpecOnArbitrary @Int

jsonSpecOnGen :: forall a. (Show a, Eq a, Typeable a, FromJSON a, ToJSON a) => Gen a -> String -> (a -> [a]) -> Spec Source #

Standard test spec for properties of JSON-related functions for a given generator (and a name for that generator).

Example usage:

jsonSpecOnGen (genListOf $ pure 'a') "sequence of 'a's"

neverFailsToEncodeOnGen :: (Show a, ToJSON a) => Gen a -> (a -> [a]) -> Property Source #

neverFailsToEncodeOnGen @Bool arbitrary shrink
neverFailsToEncodeOnGen @Bool genUnchecked shrinkUnchecked
neverFailsToEncodeOnGen @Bool genValid shrinkValid
neverFailsToEncodeOnGen @Int arbitrary shrink
neverFailsToEncodeOnGen @Int genUnchecked shrinkUnchecked
neverFailsToEncodeOnGen @Int genValid shrinkValid

encodeAndDecodeAreInversesOnGen :: (Show a, Eq a, FromJSON a, ToJSON a) => Gen a -> (a -> [a]) -> Property Source #

encodeAndDecodeAreInversesOnGen @Bool arbitrary shrink
encodeAndDecodeAreInversesOnGen @Bool genUnchecked shrinkUnchecked
encodeAndDecodeAreInversesOnGen @Bool genValid shrinkValid
encodeAndDecodeAreInversesOnGen @Int arbitrary shrink
encodeAndDecodeAreInversesOnGen @Int genUnchecked shrinkUnchecked
encodeAndDecodeAreInversesOnGen @Int genValid shrinkValid