tree-diff-0.0.1: Diffing of (expression) trees.

Safe HaskellNone
LanguageHaskell2010

Data.TreeDiff.Golden

Description

"Golden tests" using ediff comparison.

Synopsis

Documentation

ediffGolden Source #

Arguments

:: (Eq a, ToExpr a) 
=> (testName -> IO Expr -> IO Expr -> (Expr -> Expr -> IO (Maybe String)) -> (Expr -> IO ()) -> testTree)

goldenTest

-> testName

test name

-> FilePath

path to "golden file"

-> IO a

result value

-> testTree 

Make a golden tests.

ediffGolden is testing framework agnostic, thus the test framework looks intimdating.

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 diff of two will be printed.

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