polysemy-test-0.4.0.1: Polysemy Effects for Testing
Safe HaskellSafe-Inferred
LanguageHaskell2010

Polysemy.Test.Hedgehog

Description

Hedgehog interpreters, internal

Synopsis

Documentation

interpretHedgehog :: Member (Embed (TestT m)) r => InterpreterFor (Hedgehog m) r Source #

Interpret Hedgehog into TestT IO by simple embedding of the native combinators.

rewriteHedgehog :: Members [Error Failure, Writer Journal, Embed m] r => InterpreterFor (Hedgehog m) r Source #

Interpret Hedgehog in terms of Error Failure and Writer Journal, which correspond to the monad stack wrapped by TestT.

assert :: forall m r. Monad m => HasCallStack => Member (Hedgehog m) r => Bool -> Sem r () Source #

Embeds assert.

(===) :: forall a m r. Monad m => Eq a => Show a => HasCallStack => Member (Hedgehog m) r => a -> a -> Sem r () infix 4 Source #

Embeds ===.

>>> 5 === 6
5 === 6
^^^^^^^
│ ━━━ Failed (- lhs) (+ rhs) ━━━
│ - 5
│ + 6

assertEq :: forall a m r. Monad m => Eq a => Show a => HasCallStack => Member (Hedgehog m) r => a -> a -> Sem r () Source #

Prefix variant of (===).

(/==) :: forall a m r. Monad m => Eq a => Show a => HasCallStack => Member (Hedgehog m) r => a -> a -> Sem r () infix 4 Source #

Embeds /==.

>>> 5 /== 5
5 /== 5
^^^^^^^
│ ━━━ Failed (no differences) ━━━
│ 5

assertNeq :: forall a m r. Monad m => Eq a => Show a => HasCallStack => Member (Hedgehog m) r => a -> a -> Sem r () Source #

Prefix variant of (/==).

evalEither :: forall a m e r. Show e => Monad m => HasCallStack => Member (Hedgehog m) r => Either e a -> Sem r a Source #

Embeds evalEither.

assertRight :: forall a m e r. Eq a => Show e => Show a => Monad m => HasCallStack => Member (Hedgehog m) r => a -> Either e a -> Sem r () Source #

Given a reference value, unpacks an Either with evalEither and applies === to the result in the Right case, and produces a test failure in the Left case.

assertRight2 :: forall a m e1 e2 r. Eq a => Show e1 => Show e2 => Show a => Monad m => HasCallStack => Member (Hedgehog m) r => a -> Either e1 (Either e2 a) -> Sem r () Source #

Like assertRight, but for two nested Eithers.

assertRight3 :: forall a m e1 e2 e3 r. Eq a => Show e1 => Show e2 => Show e3 => Show a => Monad m => HasCallStack => Member (Hedgehog m) r => a -> Either e1 (Either e2 (Either e3 a)) -> Sem r () Source #

Like assertRight, but for three nested Eithers.

evalLeft :: forall a m e r. Show a => Monad m => HasCallStack => Member (Hedgehog m) r => Either e a -> Sem r e Source #

Like evalEither, but for Left.

assertLeft :: forall a m e r. Eq e => Show e => Show a => Monad m => HasCallStack => Member (Hedgehog m) r => e -> Either e a -> Sem r () Source #

Like assertRight, but for Left.

evalMaybe :: forall a m r. Monad m => HasCallStack => Member (Hedgehog m) r => Maybe a -> Sem r a Source #

Like evalEither, but for Maybe.

assertJust :: forall a m r. Eq a => Show a => Monad m => HasCallStack => Member (Hedgehog m) r => a -> Maybe a -> Sem r () Source #

Given a reference value, asserts that the scrutinee is Just and its contained value matches the target.

evalError :: forall e a m r. Show e => Monad m => HasCallStack => Member (Hedgehog m) r => Sem (Error e ': r) a -> Sem r a Source #

Run a Polysemy Error effect and assert its result.

assertCloseBy :: forall a m r. Num a => Ord a => Monad m => HasCallStack => Member (Hedgehog m) r => a -> a -> a -> Sem r () Source #

Assert that two numeric values are closer to each other than the specified delta.

assertClose :: forall a m r. Ord a => Fractional a => Monad m => HasCallStack => Member (Hedgehog m) r => a -> a -> Sem r () Source #

Assert that two fractional values are closer to each other than 0.001.