ouroboros-network-testing
Safe HaskellNone
LanguageHaskell2010

Ouroboros.Network.Testing.Utils

Synopsis

Arbitrary Delays

newtype Delay Source #

Constructors

Delay 

Fields

Instances

Instances details
Arbitrary Delay Source #

This needs to be small, as we are using real time limits in block-fetch examples.

Instance details

Defined in Ouroboros.Network.Testing.Utils

Methods

arbitrary :: Gen Delay #

shrink :: Delay -> [Delay] #

Num Delay Source # 
Instance details

Defined in Ouroboros.Network.Testing.Utils

Show Delay Source # 
Instance details

Defined in Ouroboros.Network.Testing.Utils

Methods

showsPrec :: Int -> Delay -> ShowS #

show :: Delay -> String #

showList :: [Delay] -> ShowS #

Eq Delay Source # 
Instance details

Defined in Ouroboros.Network.Testing.Utils

Methods

(==) :: Delay -> Delay -> Bool #

(/=) :: Delay -> Delay -> Bool #

Ord Delay Source # 
Instance details

Defined in Ouroboros.Network.Testing.Utils

Methods

compare :: Delay -> Delay -> Ordering #

(<) :: Delay -> Delay -> Bool #

(<=) :: Delay -> Delay -> Bool #

(>) :: Delay -> Delay -> Bool #

(>=) :: Delay -> Delay -> Bool #

max :: Delay -> Delay -> Delay #

min :: Delay -> Delay -> Delay #

Set properties

isSubsetProperty :: (Ord a, Show a) => String -> Set a -> Set a -> Property Source #

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.

newtype ShrinkCarefully a Source #

Constructors

ShrinkCarefully a 

Instances

Instances details
(Eq a, Arbitrary a) => Arbitrary (ShrinkCarefully a) Source # 
Instance details

Defined in Ouroboros.Network.Testing.Utils

Show a => Show (ShrinkCarefully a) Source # 
Instance details

Defined in Ouroboros.Network.Testing.Utils

Eq a => Eq (ShrinkCarefully a) Source # 
Instance details

Defined in Ouroboros.Network.Testing.Utils

prop_shrink_valid :: (Arbitrary a, Show a, Testable prop) => (a -> prop) -> ShrinkCarefully a -> Property Source #

Check that each shrink satisfies some invariant or validity condition.

Tracing Utils

data WithName name event Source #

Constructors

WithName 

Fields

Instances

Instances details
Functor (WithName name) Source # 
Instance details

Defined in Ouroboros.Network.Testing.Utils

Methods

fmap :: (a -> b) -> WithName name a -> WithName name b #

(<$) :: a -> WithName name b -> WithName name a #

(Show name, Show event) => Show (WithName name event) Source # 
Instance details

Defined in Ouroboros.Network.Testing.Utils

Methods

showsPrec :: Int -> WithName name event -> ShowS #

show :: WithName name event -> String #

showList :: [WithName name event] -> ShowS #

data WithTime event Source #

Constructors

WithTime 

Fields

Instances

Instances details
Functor WithTime Source # 
Instance details

Defined in Ouroboros.Network.Testing.Utils

Methods

fmap :: (a -> b) -> WithTime a -> WithTime b #

(<$) :: a -> WithTime b -> WithTime a #

Show event => Show (WithTime event) Source # 
Instance details

Defined in Ouroboros.Network.Testing.Utils

Methods

showsPrec :: Int -> WithTime event -> ShowS #

show :: WithTime event -> String #

showList :: [WithTime event] -> ShowS #

tracerWithName :: forall name (m :: Type -> Type) a. name -> Tracer m (WithName name a) -> Tracer m a Source #

tracerWithTime :: forall (m :: Type -> Type) a. MonadMonotonicTime m => Tracer m (WithTime a) -> Tracer m a Source #

tracerWithTimeName :: forall (m :: Type -> Type) name a. MonadMonotonicTime m => name -> Tracer m (WithTime (WithName name a)) -> Tracer m a Source #

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

debugTracer :: forall a (m :: Type -> Type). (Show a, Applicative m) => Tracer m a Source #

sayTracer :: forall a (m :: Type -> Type). (Show a, MonadSay m) => Tracer m a Source #

Tasty Utils

ignoreTest :: TestTree -> TestTree #

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.