Safe Haskell | None |
---|---|
Language | Haskell2010 |
- goldenTest1 :: TestName -> (forall r. ValueGetter r (Maybe a)) -> (forall r. ValueGetter r a) -> (a -> a -> GDiff) -> (a -> GShow) -> (a -> IO ()) -> TestTree
- goldenTestIO :: TestName -> (forall r. ValueGetter r (Maybe a)) -> (forall r. ValueGetter r a) -> (a -> a -> IO GDiff) -> (a -> IO GShow) -> (a -> IO ()) -> TestTree
- goldenTest :: TestName -> (forall r. ValueGetter r a) -> (forall r. ValueGetter r a) -> (a -> a -> IO (Maybe String)) -> (a -> IO ()) -> TestTree
- data GShow = ShowText Text
- data GDiff
- newtype ValueGetter r a = ValueGetter {
- runValueGetter :: ContT r IO a
- vgReadFile :: FilePath -> ValueGetter r ByteString
- vgReadFileMaybe :: FilePath -> ValueGetter r (Maybe ByteString)
The main function
:: TestName | test name |
-> (forall r. ValueGetter r (Maybe a)) | get the golden correct value |
-> (forall r. ValueGetter r a) | get the tested value |
-> (a -> a -> GDiff) | comparison function. If two values are the same, it should return |
-> (a -> GShow) | Show the golden/actual value. |
-> (a -> IO ()) | update the golden file |
-> TestTree |
A very general testing function.
:: TestName | test name |
-> (forall r. ValueGetter r (Maybe a)) | get the golden correct value |
-> (forall r. ValueGetter r a) | get the tested value |
-> (a -> a -> IO GDiff) | comparison function. If two values are the same, it should return |
-> (a -> IO GShow) | Show the golden/actual value. |
-> (a -> IO ()) | update the golden file |
-> TestTree |
A very general testing function.
The IO version of show/diff are useful when using external diff or show mechanisms. If IO is not required,
the goldenTest1
function should be used instead.
:: TestName | test name |
-> (forall r. ValueGetter r a) | get the golden correct value |
-> (forall r. ValueGetter r a) | get the tested value |
-> (a -> a -> IO (Maybe String)) | comparison function. If two values are the same, it should return The function may use |
-> (a -> IO ()) | update the golden file |
-> TestTree |
A very general testing function. Use goldenTest1
instead if you can.
The comparison/diff result.
ValueGetter monad
newtype ValueGetter r a Source
An action that yields a value (either golden or tested).
CPS allows closing the file handle when using lazy IO to read data.
ValueGetter | |
|
Monad (ValueGetter r) | |
Functor (ValueGetter r) | |
Applicative (ValueGetter r) | |
MonadIO (ValueGetter r) | |
MonadCont (ValueGetter r) |
vgReadFile :: FilePath -> ValueGetter r ByteString Source
Lazily read a file. The file handle will be closed after the
ValueGetter
action is run.
vgReadFileMaybe :: FilePath -> ValueGetter r (Maybe ByteString) Source
Lazily read a file. The file handle will be closed after the
ValueGetter
action is run.
Will return Nothing
if the file does not exist.