morley-1.4.0: Developer tools for the Michelson Language
Safe HaskellNone
LanguageHaskell2010

Michelson.Test.Util

Description

Testing utility functions used by testing framework itself or intended to be used by test writers.

Synopsis

Documentation

failedTest :: (HasCallStack, MonadTest m) => Text -> m () Source #

A Property that always fails with given message.

succeededTest :: MonadTest m => m () Source #

A Property that always succeeds.

eitherIsLeft :: (Show b, MonadTest m, HasCallStack) => Either a b -> m () Source #

The Property holds on `Left a`.

eitherIsRight :: (Show a, MonadTest m, HasCallStack) => Either a b -> m () Source #

The Property holds on `Right b`.

total :: (MonadTest m, NFData a, HasCallStack) => a -> m a Source #

Checks that a value is total, i.e., doesn't crash when evaluated, by reducing it to its normal form.

Equivalent to QuickCheck's total.

meanTimeUpperBoundProp :: (KnownDivRat unit Second, KnownUnitName unit, HasCallStack) => Time unit -> (a -> b) -> a -> Property Source #

Benchmarks the given function and checks that the mean time to evaluate to weak head normal form is under the given amount of time.

This test fails if the benchmark takes longer than 30 seconds to run.

meanTimeUpperBoundPropNF :: (KnownDivRat unit Second, KnownUnitName unit, HasCallStack, NFData b) => Time unit -> (a -> b) -> a -> Property Source #

Benchmarks the given function and checks that the mean time to evaluate to normal form is under the given amount of time.

This test aborts and fails if the benchmark takes longer than 120 seconds to run.

genEither :: MonadGen m => m a -> m b -> m (Either a b) Source #

Randomly selects one of the two generators.

genTuple2 :: MonadGen m => m a -> m b -> m (a, b) Source #

Generates an a and a b and wraps them in a tuple.

runGen :: HasCallStack => Size -> Word64 -> Gen a -> a Source #

Run the given generator deterministically, by fixing its size and seed.

roundtripTree :: forall x y err. (Show x, Show y, Show err, Typeable x, Eq x, Eq err) => Gen x -> (x -> y) -> (y -> Either err x) -> TestTree Source #

This TestTree contains a property based test for conversion from some x to some y and back to x (it should successfully return the initial x).

Re-exports

These functions from Time are re-exported here to make it convenient to call meanTimeUpperBoundProp and meanTimeUpperBoundPropNF.

mcs :: RatioNat -> Time Microsecond #

Creates Microsecond from given Natural.

>>> mcs 42
42mcs

ms :: RatioNat -> Time Millisecond #

Creates Millisecond from given Natural.

>>> ms 42
42ms

sec :: RatioNat -> Time Second #

Creates Second from given Natural.

>>> sec 42
42s

minute :: RatioNat -> Time Minute #

Creates Minute from given Natural.

>>> minute 42
42m

Deprecated

failedProp :: Text -> Property Source #

Deprecated: Use failedtest instead.

A Property that always fails with given message.

succeededProp :: Property Source #

Deprecated: Use succeededTest instead.

A Property that always succeeds.

qcIsLeft :: Show b => Either a b -> Property Source #

Deprecated: Use eitherIsLeft instead.

The Property holds on `Left a`.

qcIsRight :: Show a => Either a b -> Property Source #

Deprecated: Use eitherIsRight instead.

The Property holds on `Right b`.

roundtripTest :: forall x y err. (Show x, Show err, Typeable x, Arbitrary x, Eq x, Eq err) => (x -> y) -> (y -> Either err x) -> TestTree Source #

Deprecated: Use roundtripTree instead.

This TestTree contains a property based test for conversion from some x to some y and back to x (it should successfully return the initial x).