servant-aeson-specs-0.4.1: generic tests for aeson serialization in servant

Safe HaskellNone
LanguageHaskell2010

Test.Aeson.Internal.RoundtripSpecs

Description

Internal module, use at your own risk.

Synopsis

Documentation

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

  • create random values (using Arbitrary),
  • convert them into JSON (using ToJSON),
  • read them back into Haskell (using FromJSON) and
  • make sure that the result is the same as the value it started with (using Eq).

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.