Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Test.Tasty.Extras
Contents
Synopsis
- newtype Layer a r = Layer {}
- embed ∷ MonadFree ((,) a) m ⇒ a → m ()
- nestWith ∷ ([a] → a) → Layer a () → Layer a ()
- newtype TestNestedM r = TestNestedM {
- unTestNestedM ∷ ReaderT [FilePath] (Layer TestTree) r
- type TestNested = TestNestedM ()
- runTestNestedM ∷ [String] → TestNested → TestTree
- testNestedNamedM ∷ FilePath → String → TestNested → TestNested
- testNestedM ∷ FilePath → TestNested → TestNested
- testNestedGhcM ∷ TestNested → TestNested
- runTestNested ∷ [String] → [TestNested] → TestTree
- testNestedNamed ∷ FilePath → String → [TestNested] → TestNested
- testNested ∷ FilePath → [TestNested] → TestNested
- testNestedGhc ∷ [TestNested] → TestNested
- goldenVsText ∷ TestName → FilePath → Text → TestTree
- goldenVsTextM ∷ TestName → FilePath → IO Text → TestTree
- goldenVsDoc ∷ TestName → FilePath → Doc ann → TestTree
- goldenVsDocM ∷ TestName → FilePath → IO (Doc ann) → TestTree
- nestedGoldenVsText ∷ TestName → FilePath → Text → TestNested
- nestedGoldenVsTextPredM ∷ TestName → FilePath → IO Text → (Text → Text → Bool) → TestNested
- nestedGoldenVsTextM ∷ TestName → FilePath → IO Text → TestNested
- nestedGoldenVsDoc ∷ TestName → FilePath → Doc ann → TestNested
- nestedGoldenVsDocM ∷ TestName → FilePath → IO (Doc ann) → TestNested
- makeVersionedFilePath ∷ [FilePath] → FilePath → FilePath
- assertEqualPretty ∷ (Eq a, Show a, HasCallStack) ⇒ String → a → a → Assertion
- (%=?) ∷ (Eq a, Show a, HasCallStack) ⇒ a → a → Assertion
- (%?=) ∷ (Eq a, Show a, HasCallStack) ⇒ a → a → Assertion
Documentation
A monad allowing one to emit elements of type a
. Semantically equivalent to
Writer (DList a) r
, but:
- is faster, being based on the Church-encoded free monad
- implements
Monoid
, so that all the Data.Foldable convenience is supported - has better ergonomics as it doesn't require the user to wrap
a
values intoDList
s
This type is also semantically equivalent to Stream (Of a) Identity r
.
Useful for monadically creating tree-like structures, for example the following
import Data.Tree yield = embed . pure main = putStrLn . drawTree . Node "a" . toList $ do yield "b" nestWith (Node "c") $ do yield "d" yield "e" yield "f"
will produce
-a | +- b | +- c | | | +- d | | | `- e | `- f
Instances
Applicative (Layer a) Source # | |
Functor (Layer a) Source # | |
Monad (Layer a) Source # | |
MonadFree ((,) a) (Layer a) Source # | |
unit ~ () ⇒ Monoid (Layer a unit) Source # | |
unit ~ () ⇒ Semigroup (Layer a unit) Source # | |
unit ~ () ⇒ IsList (Layer a unit) Source # | |
type Item (Layer a unit) Source # | |
Defined in Test.Tasty.Extras |
newtype TestNestedM r Source #
Constructors
TestNestedM | |
Fields
|
Instances
type TestNested = TestNestedM () Source #
A TestTree
of tests under some name prefix.
runTestNestedM ∷ [String] → TestNested → TestTree Source #
Run a TestNested
computation to produce a TestTree
(without actually executing the tests).
Arguments
∷ FilePath | The name of the folder. |
→ String | The name of the test group to render in CLI. |
→ TestNested | |
→ TestNested |
Descend into a folder.
testNestedM ∷ FilePath → TestNested → TestNested Source #
Descend into a folder for a TestNested
computation.
testNestedGhcM ∷ TestNested → TestNested Source #
Like testNestedM
but adds a subdirectory corresponding to the GHC version being used.
runTestNested ∷ [String] → [TestNested] → TestTree Source #
Run a list of TestNested
computation to produce a TestTree
(without actually executing the
tests).
Arguments
∷ FilePath | The name of the folder. |
→ String | The name of the test group to render in CLI. |
→ [TestNested] | |
→ TestNested |
Descend into a folder for a list of tests.
testNested ∷ FilePath → [TestNested] → TestNested Source #
Descend into a folder for a list of TestNested
computations.
testNestedGhc ∷ [TestNested] → TestNested Source #
Like testNested
but adds a subdirectory corresponding to the GHC version being used.
goldenVsText ∷ TestName → FilePath → Text → TestTree Source #
Check the contents of a file against a Text
.
goldenVsTextM ∷ TestName → FilePath → IO Text → TestTree Source #
Check the contents of a file against a Text
.
goldenVsDoc ∷ TestName → FilePath → Doc ann → TestTree Source #
Check the contents of a file against a Doc
.
goldenVsDocM ∷ TestName → FilePath → IO (Doc ann) → TestTree Source #
Check the contents of a file against a Doc
.
nestedGoldenVsText ∷ TestName → FilePath → Text → TestNested Source #
Check the contents of a file under a name prefix against a Text
.
nestedGoldenVsTextPredM Source #
Arguments
∷ TestName | The name of the test |
→ FilePath | The file extension |
→ IO Text | The text-producing action to execute |
→ (Text → Text → Bool) | How to compare golden file contents with the produced text |
→ TestNested |
Compare the contents of a file under a name prefix against a Text
using a predicate.
nestedGoldenVsTextM ∷ TestName → FilePath → IO Text → TestNested Source #
Check the contents of a file under a name prefix against a Text
.
nestedGoldenVsDoc ∷ TestName → FilePath → Doc ann → TestNested Source #
Check the contents of a file under a name prefix against a Text
.
nestedGoldenVsDocM ∷ TestName → FilePath → IO (Doc ann) → TestNested Source #
Check the contents of a file under a name prefix against a Text
.
makeVersionedFilePath ∷ [FilePath] → FilePath → FilePath Source #
Given a lists of FilePaths and a filename, concatenate the members of the list together, append the GHC version number, then append the filename. We use this to create GHC-version-dependent golden files.
Prettier equality assertions
Arguments
∷ (Eq a, Show a, HasCallStack) | |
⇒ String | The message prefix |
→ a | The expected value |
→ a | The actual value |
→ Assertion |
Asserts that the specified actual value is equal to the expected value. The output message will contain the prefix, the expected value, and the actual value.
If the prefix is the empty string (i.e., ""
), then the prefix is omitted
and only the expected and actual values are output.
Arguments
∷ (Eq a, Show a, HasCallStack) | |
⇒ a | The expected value |
→ a | The actual value |
→ Assertion |
Asserts that the specified actual value is equal to the expected value (with the expected value on the left-hand side).