Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
"Golden tests" using ediff
comparison.
Synopsis
- ediffGolden :: ToExpr a => (testName -> IO Expr -> IO Expr -> (Expr -> Expr -> IO (Maybe String)) -> (Expr -> IO ()) -> testTree) -> testName -> FilePath -> IO a -> testTree
- ediffGolden1 :: forall a arg testName testTree. ToExpr a => (testName -> IO Expr -> (arg -> IO Expr) -> (Expr -> Expr -> IO (Maybe String)) -> (Expr -> IO ()) -> testTree) -> testName -> FilePath -> (arg -> IO a) -> testTree
Documentation
:: ToExpr a | |
=> (testName -> IO Expr -> IO Expr -> (Expr -> Expr -> IO (Maybe String)) -> (Expr -> IO ()) -> testTree) |
|
-> testName | test name |
-> FilePath | path to "golden file" |
-> IO a | result value |
-> 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.
:: forall a arg testName testTree. ToExpr a | |
=> (testName -> IO Expr -> (arg -> IO Expr) -> (Expr -> Expr -> IO (Maybe String)) -> (Expr -> IO ()) -> testTree) |
|
-> testName | test name |
-> FilePath | path to "golden file" |
-> (arg -> IO a) | result value |
-> testTree |
Like ediffGolden1
but with an additional argument for generation of actual value.
Since: 0.3.2