HORIZON HASKELLDocslts/ghc-10.0.x77a86622026-10-31Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 77a8662 · 2026-10-31

Moduletasty-th-0.1.7Haskell98

Test.Tasty.TH

This module provides TemplateHaskell functions to automatically generate tasty TestTrees from specially named functions. See the README of the package for examples.

Important: due to to the GHC staging restriction, you must put any uses of these functions at the end of the file, or you may get errors due to missing definitions.

Synopsis
  • Packagetasty-th-0.1.7
  • Exports6
  • LanguageHaskell98
  • LicenceBSD-3-Clause
  • SourceTH.hs

This function generates a TestTree from functions in the current module. The test tree is named after the current module.

The following definitions are collected by testGroupGenerator:

  • a test_something definition in the current module creates a sub-testGroup with the name "something"

  • a prop_something definition in the current module is added as a QuickCheck property named "something"

  • a case_something definition leads to a HUnit-Assertion test with the name "something"

Example usage:

prop_example :: Int -> Int -> Bool
prop_example a b = a + b == b + a

tests :: TestTree
tests = $(testGroupGenerator)
valuetestGroupGeneratorFor
  1. :: String

    The name of the test group itself

  2. -> [String]

    The names of the functions which should be included in the test group

  3. -> ExpQ

Like testGroupGenerator, but generates a test group only including the specified function names. The function names still need to follow the pattern of starting with one of prop_, case_ or test_.

valuedefaultMainGeneratorFor
  1. :: String

    The name of the top-level test group

  2. -> [String]

    The names of the functions which should be included in the test group

  3. -> ExpQ

Like defaultMainGenerator, but only includes the specific function names in the test group. The function names still need to follow the pattern of starting with one of prop_, case_ or test_.