HORIZON HASKELLDocslts/ghc-10.0.xfc4e5982026-10-11Search names, modules, packages, or :: a typeCtrl K

GHC 10.0.0.20260917 · lts/ghc-10.0.x · fc4e598 · 2026-10-11

Moduletree-diff-0.4.1Haskell2010

Data.TreeDiff.Golden

"Golden tests" using ediff comparison.

  • 2 values
  • Packagetree-diff-0.4.1
  • Exports2
  • LanguageHaskell2010
  • LicenceGPL-2.0-or-later
  • SourceGolden.hs
valueediffGolden
  1. :: ToExpr a
  2. => (testName -> IO Expr -> IO Expr -> (Expr -> Expr -> IO (Maybe String)) -> (Expr -> IO ()) -> testTree)

    goldenTest

  3. -> testName

    test name

  4. -> FilePath

    path to "golden file"

  5. -> IO a

    result value

  6. -> testTree
#

Make a golden tests.

ediffGolden is testing framework agnostic, thus the type looks intimidating.

An example using tasty-golden, goldenTest is imported from Test.Tasty.Golden.Advanced

exTest :: TestTree
exTest = ediffGolden goldenTest "golden test" "fixtures/ex.expr" $
   action constructing actual value

The ediffGolden will read an Expr from provided path to golden file, and compare it with a toExpr of a result. If values differ, the (compact) diff of two will be printed.

See https://github.com/phadej/tree-diff/blob/master/tests/Tests.hs for a proper example.