test-framework-golden-1.1.3.3: Golden tests support for test-framework

Safe HaskellNone
LanguageHaskell98

Test.Golden.Advanced

Contents

Synopsis

The main function

goldenTest Source

Arguments

:: 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 Nothing. If they are different, it should return an error that will be printed to the user. First argument is the golden value.

The function may use IO, for example, to launch an external diff command.

-> (a -> IO ())

update the golden file

-> Test 

A very general testing function.

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.

Constructors

ValueGetter 

Fields

runValueGetter :: ContT r IO a
 

vgReadFile :: FilePath -> ValueGetter r ByteString Source

Lazily read a file. The file handle will be closed after the ValueGetter action is run.