ouroboros-network-testing-0.1.0.1: Common modules used for testing in ouroboros-network and ouroboros-consensus
Safe Haskell None
Language Haskell2010

Ouroboros.Network.Testing.Utils

Synopsis

Arbitrary Delays

newtype SmallDelay Source #

Instances

Instances details
Eq SmallDelay Source #
Instance details

Defined in Ouroboros.Network.Testing.Utils

Num SmallDelay Source #
Instance details

Defined in Ouroboros.Network.Testing.Utils

Ord SmallDelay Source #
Instance details

Defined in Ouroboros.Network.Testing.Utils

Show SmallDelay Source #
Instance details

Defined in Ouroboros.Network.Testing.Utils

Arbitrary SmallDelay Source #
Instance details

Defined in Ouroboros.Network.Testing.Utils

QuickCheck Utils

arbitrarySubset :: Ord a => Set a -> Gen ( Set a) Source #

Pick a subset of a set, using a 50:50 chance for each set element.

shrinkVector :: (a -> [a]) -> [a] -> [[a]] Source #

Like shrinkList but only shrink the elems, don't drop elements.

Useful when you want a custom strategy for dropping elements.

prop_shrink_valid :: ( Arbitrary a, Show a) => (a -> Bool ) -> Fixed a -> Property Source #

Check that each shrink satisfies some invariant or validity condition.

prop_shrink_nonequal :: ( Arbitrary a, Eq a) => Fixed a -> Property Source #

The shrink function needs to give a valid value that is smaller than the original, otherwise the shrinking procedure is not well-founded and can cycle.

This property does not check size, as that would need significant extra infrastructure to define an appropriate measure. Instead this property simply checks each shrink is not the same as the original. This catches simple 1-cycles, but not bigger cycles. These are fortunately the most common case, so it is still a useful property in practice.

Tracing Utils

data WithName name event Source #

Constructors

WithName

Fields

splitWithNameTrace :: Ord name => Trace r ( WithName name b) -> Trace r [ WithName name b] Source #

Split Trace events into separate traces indexed by a given name.

Tracers

Tasty Utils

ignoreTest :: TestTree -> TestTree Source #

Prevents the tests from running and reports them as succeeding.

This may be be desireable as an alternative to commenting out the tests. This way, they are still typechecked (preventing bitrot), and the test report lists them, which serves as a reminder that there are ignored tests.

Note that any setup/teardown actions executed by withResource are still executed. You can bypass this manually as in the following example:

askOption $ \(MyFlag b) -> if b
                           then withResource mytest
                           else ignoreTest . mytest $ return junkvalue

Auxiliary functions

renderRanges :: Int -> Int -> String Source #

Use in tabulate to help summarise data into buckets.