Skip to content

Commit 3bc46be

Browse files
authored
Merge pull request #95 from haskellari/ediffGolden1
Add ediffGolden1
2 parents 5efb53e + b95f6ad commit 3bc46be

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

ChangeLog.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.3.2
2+
3+
- Add 'ediffGolden1', a variant of 'ediffGolden' with an additional argument.
4+
15
## 0.3.1
26

37
- Support GHC-8.6.5...9.10.1

src/Data/TreeDiff/Golden.hs

+17-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
-- | "Golden tests" using 'ediff' comparison.
22
module Data.TreeDiff.Golden (
33
ediffGolden,
4+
ediffGolden1,
45
) where
56

67
import Data.TreeDiff
@@ -41,9 +42,23 @@ ediffGolden
4142
-> FilePath -- ^ path to "golden file"
4243
-> IO a -- ^ result value
4344
-> testTree
44-
ediffGolden impl testName fp x = impl testName expect actual cmp wrt
45+
ediffGolden impl testName fp x = ediffGolden1 impl' testName fp (\() -> x) where
46+
impl' n expect actual = impl n expect (actual ())
47+
48+
-- | Like 'ediffGolden1' but with an additional argument for generation of actual value.
49+
--
50+
-- @since 0.3.2
51+
--
52+
ediffGolden1
53+
:: (Eq a, ToExpr a)
54+
=> (testName -> IO Expr -> (arg -> IO Expr) -> (Expr -> Expr -> IO (Maybe String)) -> (Expr -> IO ()) -> testTree) -- ^ 'goldenTest'
55+
-> testName -- ^ test name
56+
-> FilePath -- ^ path to "golden file"
57+
-> (arg -> IO a) -- ^ result value
58+
-> testTree
59+
ediffGolden1 impl testName fp x = impl testName expect actual cmp wrt
4560
where
46-
actual = fmap toExpr x
61+
actual arg = fmap toExpr (x arg)
4762
expect = do
4863
contents <- BS.readFile fp
4964
case parse (exprParser <* eof) fp $ TE.decodeUtf8 contents of

tree-diff.cabal

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
cabal-version: 2.2
22
name: tree-diff
3-
version: 0.3.1
4-
x-revision: 1
3+
version: 0.3.2
54
synopsis: Diffing of (expression) trees.
65
category: Data, Testing
76
description:

0 commit comments

Comments
 (0)