Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Defines reusable abstractions for testing RoundTrip properties of plain encoders/decoders
Synopsis
- roundTripSpec ∷ ∀ t. (Show t, Eq t, Typeable t, Arbitrary t) ⇒ Trip t t → Spec
- roundTripFailureExpectation ∷ ∀ a. (Eq a, ToCBOR a, FromCBOR a) ⇒ a → Expectation
- roundTripExpectation ∷ (Show t, Eq t, Typeable t, HasCallStack) ⇒ Trip t t → t → Expectation
- roundTripCborExpectation ∷ ∀ t. (Show t, Eq t, FromCBOR t, ToCBOR t, HasCallStack) ⇒ t → Expectation
- embedTripSpec ∷ ∀ a b. (Eq b, Show a, Typeable a, Typeable b, Arbitrary a, HasCallStack) ⇒ Trip a b → (b → a → Expectation) → Spec
- embedTripExpectation ∷ ∀ a b. (Typeable b, Eq b, HasCallStack) ⇒ Trip a b → (b → a → Expectation) → a → Expectation
- data RoundTripFailure = RoundTripFailure {}
- showMaybeDecoderError ∷ Buildable b ⇒ String → Maybe b → String
- showFailedTermsWithReSerialization ∷ ByteString → Maybe ByteString → [String]
- data Trip a b = Trip {
- tripEncoder ∷ a → Encoding
- tripDecoder ∷ ∀ s. Decoder s b
- mkTrip ∷ ∀ a b. (a → Encoding) → (∀ s. Decoder s b) → Trip a b
- cborTrip ∷ ∀ a b. (ToCBOR a, FromCBOR b) ⇒ Trip a b
- roundTrip ∷ ∀ t. (Eq t, Typeable t) ⇒ Trip t t → t → Either RoundTripFailure t
- embedTrip ∷ ∀ a b. (Eq b, Typeable b) ⇒ Trip a b → a → Either RoundTripFailure b
- embedTripLabel ∷ ∀ a b. Eq b ⇒ Text → Trip a b → a → Either RoundTripFailure b
Documentation
roundTripSpec ∷ ∀ t. (Show t, Eq t, Typeable t, Arbitrary t) ⇒ Trip t t → Spec Source #
Tests the roundtrip property using QuickCheck generators for all possible versions
starting with shelleyProtVer
.
roundTripFailureExpectation ∷ ∀ a. (Eq a, ToCBOR a, FromCBOR a) ⇒ a → Expectation Source #
roundTripExpectation ∷ (Show t, Eq t, Typeable t, HasCallStack) ⇒ Trip t t → t → Expectation Source #
Verify that round triping through the binary form holds
roundTripCborExpectation ∷ ∀ t. (Show t, Eq t, FromCBOR t, ToCBOR t, HasCallStack) ⇒ t → Expectation Source #
embedTripSpec ∷ ∀ a b. (Eq b, Show a, Typeable a, Typeable b, Arbitrary a, HasCallStack) ⇒ Trip a b → (b → a → Expectation) → Spec Source #
Tests the embedtrip property using QuickCheck generators
embedTripExpectation ∷ ∀ a b. (Typeable b, Eq b, HasCallStack) ⇒ Trip a b → (b → a → Expectation) → a → Expectation Source #
data RoundTripFailure Source #
RoundTripFailure | |
|
Instances
A definition of a CBOR trip through binary representation of one type to another. In this module this is called an embed. When a source and target type is the exact same one then it would be a dual and is expected to round trip.
Trip | |
|
mkTrip ∷ ∀ a b. (a → Encoding) → (∀ s. Decoder s b) → Trip a b Source #
Construct a Trip
using encoder and decoder, with dropper set to the decoder which
drops the value
embedTrip ∷ ∀ a b. (Eq b, Typeable b) ⇒ Trip a b → a → Either RoundTripFailure b Source #
Can we serialise a type, and then deserialise it as something else?
embedTripLabel ∷ ∀ a b. Eq b ⇒ Text → Trip a b → a → Either RoundTripFailure b Source #