Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Internal utilities for unit testing.
Synopsis
- data EPMismatch = EPMismatch {
- epmmExtra :: EPList
- epmmMissing :: EPList
- epmmTypeMismatch :: [(EpName, MismatchError Ty)]
- type EPList = [(EpName, Ty)]
- pattern EPComparisonResultOK :: EPMismatch
- ignoreExtraEntrypoints :: EPMismatch -> EPMismatch
- compareEntrypoints :: ("expected" :! Map EpName Ty) -> ("actual" :! Map EpName Ty) -> EPMismatch
- contractMatchesEntrypoints :: Contract -> Map EpName Ty -> Either TcTypeError EPMismatch
- contractCoversEntrypoints :: Contract -> Map EpName Ty -> Either TcTypeError EPMismatch
- assertEPComparisonSuccessful :: Either TcTypeError EPMismatch -> Assertion
- testContractEntrypoints :: (EPMismatch -> EPMismatch) -> TestName -> Contract -> Map EpName Ty -> TestTree
- michelsonRoundtripContract :: HasCallStack => Contract -> Contract
- michelineRoundtripContract :: HasCallStack => Contract -> Contract
Documentation
data EPMismatch Source #
Entrypoint comparison mismatch report
EPMismatch | |
|
Instances
Buildable EPMismatch Source # | |
Defined in Test.Cleveland.Michelson.Internal.Entrypoints build :: EPMismatch -> Doc buildList :: [EPMismatch] -> Doc |
type EPList = [(EpName, Ty)] Source #
Convenience type synonym for a list of pairs of entrypoint names and types
pattern EPComparisonResultOK :: EPMismatch Source #
A pattern syononym for no mismatches
ignoreExtraEntrypoints :: EPMismatch -> EPMismatch Source #
Ignore extraneous entrypoint names in EPMismatch
. Essentially sets
epmmExtra
to []
.
compareEntrypoints :: ("expected" :! Map EpName Ty) -> ("actual" :! Map EpName Ty) -> EPMismatch Source #
Compare two sets of entrypoints. Accepts ordered Map
s to enforce sorting order.
contractMatchesEntrypoints :: Contract -> Map EpName Ty -> Either TcTypeError EPMismatch Source #
Check if the contract exactly matches the given entrypoints. Will report both missing and extraneous entrypoint names, and type mismatches.
contractCoversEntrypoints :: Contract -> Map EpName Ty -> Either TcTypeError EPMismatch Source #
Check if the contract contains the entrypoints given in spec (with matching types). Ignores any additional entrypoints present in the contract.
assertEPComparisonSuccessful :: Either TcTypeError EPMismatch -> Assertion Source #
Turn Either
TcTypeError
EPMismatch
into an Assertion
testContractEntrypoints :: (EPMismatch -> EPMismatch) -> TestName -> Contract -> Map EpName Ty -> TestTree Source #
Expect the contract to match with the entrypoints given in spec (with matching types).
Comparison is defined by the first argument; use ignoreExtraEntrypoints
for cover test,
id
for match test.
Also tests if the same holds after Michelson and Micheline roundtrips of the contract.
michelsonRoundtripContract :: HasCallStack => Contract -> Contract Source #
Round-trip the contract through Michelson text representation.
This is useful if you're intending to use the contract with Michelson text output and want to check if that output satisfies tests (which should be the same for internal representation and output, but bugs happen)
michelineRoundtripContract :: HasCallStack => Contract -> Contract Source #
Round-trip the contract through Micheline JSON representation.
This is useful if you're intending to use the contract with Micheline JSON output and want to check if that output satisfies tests (which should be the same for internal representation and output, but bugs happen)