| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Test.Cleveland.Michelson.Internal.Entrypoints
Description
Internal utilities for unit testing.
Synopsis
- type EPList = [(EpName, Ty)]
- newtype EPExpected a = EPExpected a
- newtype EPActual a = EPActual a
- data EPMismatch where
- EPMismatch {
- epmmExtra :: EPList
- epmmMissing :: EPList
- epmmTypeMismatch :: [(EpName, (EPExpected Ty, EPActual Ty))]
- pattern EPComparisonResultOK :: EPMismatch
- EPMismatch {
- ignoreExtraEntrypoints :: EPMismatch -> EPMismatch
- compareEntrypoints :: EPExpected (Map EpName Ty) -> EPActual (Map EpName Ty) -> EPMismatch
- contractMatchesEntrypoints :: Contract -> Map EpName Ty -> Either TCError EPMismatch
- contractCoversEntrypoints :: Contract -> Map EpName Ty -> Either TCError EPMismatch
- testContractEntrypoints :: (EPMismatch -> EPMismatch) -> TestName -> Contract -> Map EpName Ty -> TestTree
- assertEPComparisonSuccessful :: Either TCError EPMismatch -> Assertion
- michelsonRoundtripContract :: HasCallStack => Contract -> Contract
- michelineRoundtripContract :: HasCallStack => Contract -> Contract
Documentation
type EPList = [(EpName, Ty)] Source #
Convenience type synonym for a list of pairs of entrypoint names and types
newtype EPExpected a Source #
Newtype wrapper for the expected value in entrypoint comparison
Constructors
| EPExpected a |
Instances
| Eq a => Eq (EPExpected a) Source # | |
| Show a => Show (EPExpected a) Source # | |
Defined in Test.Cleveland.Michelson.Internal.Entrypoints Methods showsPrec :: Int -> EPExpected a -> ShowS # show :: EPExpected a -> String # showList :: [EPExpected a] -> ShowS # | |
| Buildable a => Buildable (EPExpected a) Source # | |
Defined in Test.Cleveland.Michelson.Internal.Entrypoints Methods build :: EPExpected a -> Builder # | |
| Buildable (EPExpected Ty, EPActual Ty) Source # | |
Defined in Test.Cleveland.Michelson.Internal.Entrypoints Methods build :: (EPExpected Ty, EPActual Ty) -> Builder # | |
Newtype wrapper for the actual value in entrypoint comparison
Constructors
| EPActual a |
data EPMismatch Source #
Entrypoint comparison mismatch report
Constructors
| EPMismatch | |
Fields
| |
Bundled Patterns
| pattern EPComparisonResultOK :: EPMismatch | A pattern syononym for no mismatches |
Instances
| Eq EPMismatch Source # | |
| Show EPMismatch Source # | |
Defined in Test.Cleveland.Michelson.Internal.Entrypoints Methods showsPrec :: Int -> EPMismatch -> ShowS # show :: EPMismatch -> String # showList :: [EPMismatch] -> ShowS # | |
| Buildable EPMismatch Source # | |
Defined in Test.Cleveland.Michelson.Internal.Entrypoints Methods build :: EPMismatch -> Builder # | |
ignoreExtraEntrypoints :: EPMismatch -> EPMismatch Source #
Ignore extraneous entrypoint names in EPMismatch. Essentially sets
epmmExtra to [].
compareEntrypoints :: EPExpected (Map EpName Ty) -> EPActual (Map EpName Ty) -> EPMismatch Source #
Compare two sets of entrypoints. Accepts ordered Maps to enforce sorting order.
contractMatchesEntrypoints :: Contract -> Map EpName Ty -> Either TCError 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 TCError EPMismatch Source #
Check if the contract contains the entrypoints given in spec (with matching types). Ignores any additional entrypoints present in the contract.
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.
assertEPComparisonSuccessful :: Either TCError EPMismatch -> Assertion Source #
Turn Either TCError EPMismatch into an Assertion
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)