| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Test.Ouroboros.Network.Utils
Synopsis
- newtype Delay = Delay {}
- genDelayWithPrecision :: Integer -> Gen DiffTime
- newtype SmallDelay = SmallDelay {}
- newtype DistinctList a = DistinctList {
- fromDistinctList :: [a]
- newtype DistinctNEList a = DistinctNEList {}
- isSubsetProperty :: (Ord a, Show a) => String -> Set a -> Set a -> Property
- disjointSetsProperty :: (Ord a, Show a) => String -> Set a -> Set a -> Property
- arbitrarySubset :: Ord a => Set a -> Gen (Set a)
- shrinkVector :: (a -> [a]) -> [a] -> [[a]]
- newtype ShrinkCarefully a = ShrinkCarefully a
- prop_shrink_nonequal :: (Arbitrary a, Eq a, Show a) => ShrinkCarefully a -> Property
- prop_shrink_valid :: (Arbitrary a, Show a, Testable prop) => (a -> prop) -> ShrinkCarefully a -> Property
- data WithName name event = WithName {}
- data WithTime event = WithTime {}
- tracerWithName :: forall name (m :: Type -> Type) a. name -> Tracer m (WithName name a) -> Tracer m a
- tracerWithTime :: forall (m :: Type -> Type) a. MonadMonotonicTime m => Tracer m (WithTime a) -> Tracer m a
- tracerWithTimeName :: forall (m :: Type -> Type) name a. MonadMonotonicTime m => name -> Tracer m (WithTime (WithName name a)) -> Tracer m a
- swapTimeWithName :: WithTime (WithName name b) -> WithName name (WithTime b)
- swapNameWithTime :: WithName name (WithTime b) -> WithTime (WithName name b)
- splitWithNameTrace :: Ord name => Trace r (WithName name b) -> Trace r [WithName name b]
- debugTracer :: forall a (m :: Type -> Type). (Show a, Applicative m) => Tracer m a
- debugTracerG :: (Show a, Typeable a) => Tracer (IOSim s) a
- sayTracer :: forall a (m :: Type -> Type). (Show a, MonadSay m) => Tracer m a
- nightlyTest :: TestTree -> TestTree
- ignoreTest :: TestTree -> TestTree
- renderRanges :: Int -> Int -> String
Arbitrary Delays
Instances
| Arbitrary Delay Source # | This needs to be small, as we are using real time limits in block-fetch examples. |
| Num Delay Source # | |
| Fractional Delay Source # | |
| Real Delay Source # | |
Defined in Test.Ouroboros.Network.Utils Methods toRational :: Delay -> Rational # | |
| Show Delay Source # | |
| Eq Delay Source # | |
| Ord Delay Source # | |
newtype SmallDelay Source #
Constructors
| SmallDelay | |
Fields | |
Instances
Utilities
newtype DistinctList a Source #
Constructors
| DistinctList | |
Fields
| |
Instances
| (Eq a, Arbitrary a) => Arbitrary (DistinctList a) Source # | |
Defined in Test.Ouroboros.Network.Utils | |
| Show a => Show (DistinctList a) Source # | |
Defined in Test.Ouroboros.Network.Utils Methods showsPrec :: Int -> DistinctList a -> ShowS # show :: DistinctList a -> String # showList :: [DistinctList a] -> ShowS # | |
newtype DistinctNEList a Source #
Constructors
| DistinctNEList | |
Fields | |
Instances
| (Eq a, Arbitrary a) => Arbitrary (DistinctNEList a) Source # | |
Defined in Test.Ouroboros.Network.Utils | |
| Show a => Show (DistinctNEList a) Source # | |
Defined in Test.Ouroboros.Network.Utils Methods showsPrec :: Int -> DistinctNEList a -> ShowS # show :: DistinctNEList a -> String # showList :: [DistinctNEList a] -> ShowS # | |
Set properties
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
| (Eq a, Arbitrary a) => Arbitrary (ShrinkCarefully a) Source # | |
Defined in Test.Ouroboros.Network.Utils | |
| Show a => Show (ShrinkCarefully a) Source # | |
Defined in Test.Ouroboros.Network.Utils Methods showsPrec :: Int -> ShrinkCarefully a -> ShowS # show :: ShrinkCarefully a -> String # showList :: [ShrinkCarefully a] -> ShowS # | |
| Eq a => Eq (ShrinkCarefully a) Source # | |
Defined in Test.Ouroboros.Network.Utils Methods (==) :: ShrinkCarefully a -> ShrinkCarefully a -> Bool # (/=) :: ShrinkCarefully a -> ShrinkCarefully a -> Bool # | |
prop_shrink_nonequal :: (Arbitrary a, Eq a, Show a) => ShrinkCarefully a -> Property Source #
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
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 #
debugTracerG :: (Show a, Typeable a) => Tracer (IOSim s) a Source #
Redefine this tracer to get valuable tracing information from various components:
- connection-manager
- inbound governor
- server
Tasty Utils
nightlyTest :: TestTree -> TestTree Source #
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