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

Safe HaskellNone




The main function



:: 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). Either is for possible errors (file not found, parse error etc.), and CPS allows closing the file handle when using lazy IO to read data.




runValueGetter :: ContT r IO a

vgReadFile :: FilePath -> ValueGetter r ByteStringSource

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