Safe Haskell | None |
---|---|
Language | Haskell2010 |
- goldenSpecs :: (Eq a, Show a, Typeable a, Arbitrary a, ToJSON a, FromJSON a) => Int -> Proxy a -> Spec
- roundtripSpecs :: forall a. (Typeable a, Eq a, Show a, Arbitrary a, ToJSON a, FromJSON a) => Proxy a -> Spec
- roundtripAndGoldenSpecs :: forall a. (Arbitrary a, Eq a, Show a, ToJSON a, FromJSON a, Typeable a) => Int -> Proxy a -> Spec
- goldenADTSpecs :: forall a. (ToADTArbitrary a, Eq a, Show a, Arbitrary a, ToJSON a, FromJSON a) => Int -> Proxy a -> Spec
- roundtripADTSpecs :: forall a. (ToADTArbitrary a, Eq a, Show a, Arbitrary a, ToJSON a, FromJSON a) => Proxy a -> Spec
- roundtripAndGoldenADTSpecs :: forall a. (Arbitrary a, ToADTArbitrary a, Eq a, Show a, ToJSON a, FromJSON a) => Int -> Proxy a -> Spec
- shouldBeIdentity :: (Eq a, Show a, Arbitrary a) => Proxy a -> (a -> IO a) -> Property
- data Proxy k t :: forall k. k -> * = Proxy
Arbitrary testing
goldenSpecs :: (Eq a, Show a, Typeable a, Arbitrary a, ToJSON a, FromJSON a) => Int -> Proxy a -> Spec Source #
Allows to obtain tests that will try to ensure that the JSON encoding
didn't change unintentionally. To this end goldenSpecs
will
- write a file
golden.json/TYPENAME.json
in the current directory containing a number of JSON-encoded sample values, - during subsequent tests it will encode the same sample values again and compare them with the saved golden encodings,
- on failure it will create a file
golden.json/TYPENAME.faulty.json
for easy manual inspection.
You can consider putting the golden files under revision control. That way it'll be obvious when JSON encodings change.
roundtripSpecs :: forall a. (Typeable a, Eq a, Show a, Arbitrary a, ToJSON a, FromJSON a) => Proxy a -> Spec Source #
Allows to obtain a roundtrip test to check whether values of the given type can be successfully converted to JSON and back.
roundtripSpecs
will
roundtripAndGoldenSpecs :: forall a. (Arbitrary a, Eq a, Show a, ToJSON a, FromJSON a, Typeable a) => Int -> Proxy a -> Spec Source #
run roundtrip and golden test for a type. sampleSize is used only when creating the golden file. When it is compared, the sampleSize is derived from the file.
ToADTArbitrary testing
goldenADTSpecs :: forall a. (ToADTArbitrary a, Eq a, Show a, Arbitrary a, ToJSON a, FromJSON a) => Int -> Proxy a -> Spec Source #
for a type a, create a set of golden files if they do not exist, compare with golden file if it exists. Golden file encodes json format of a type
roundtripADTSpecs :: forall a. (ToADTArbitrary a, Eq a, Show a, Arbitrary a, ToJSON a, FromJSON a) => Proxy a -> Spec Source #
A roundtrip test to check whether values of the given type can be successfully converted to JSON and back to a Haskell value.
roundtripSpecs
will
roundtripAndGoldenADTSpecs :: forall a. (Arbitrary a, ToADTArbitrary a, Eq a, Show a, ToJSON a, FromJSON a) => Int -> Proxy a -> Spec Source #
run roundtrip and golden tests for all constructors of a type. sampleSize is used only when creating the golden files. When they are compared, the sampleSize is derived from the file.
shouldBeIdentity :: (Eq a, Show a, Arbitrary a) => Proxy a -> (a -> IO a) -> Property Source #
hspec style combinator to easily write tests that check the a given operation returns the same value it was given, e.g. roundtrip tests.
re-exports
data Proxy k t :: forall k. k -> * #
A concrete, poly-kinded proxy type
Monad (Proxy *) | |
Functor (Proxy *) | |
Applicative (Proxy *) | |
Foldable (Proxy *) | |
Generic1 (Proxy *) | |
Alternative (Proxy *) | |
MonadPlus (Proxy *) | |
Eq1 (Proxy *) | Since: 4.9.0.0 |
Ord1 (Proxy *) | Since: 4.9.0.0 |
Read1 (Proxy *) | Since: 4.9.0.0 |
Show1 (Proxy *) | Since: 4.9.0.0 |
Bounded (Proxy k s) | |
Enum (Proxy k s) | |
Eq (Proxy k s) | |
Ord (Proxy k s) | |
Read (Proxy k s) | |
Show (Proxy k s) | |
Ix (Proxy k s) | |
Generic (Proxy k t) | |
Semigroup (Proxy k s) | |
Monoid (Proxy k s) | |
FromJSON (Proxy k a) | |
ToJSON (Proxy k a) | |
type Rep1 (Proxy *) | |
type Rep (Proxy k t) | |