Safe Haskell | Safe-Inferred |
---|
- goldenTest :: Show e => TestName -> ValueGetter e a -> ValueGetter e a -> (a -> a -> IO (Maybe e)) -> (a -> IO ()) -> Test
- newtype ValueGetter e a = ValueGetter {
- runValueGetter :: forall r. (Either e a -> IO r) -> IO r
- vgLiftIO :: IO a -> ValueGetter e a
- vgError :: e -> ValueGetter e a
- vgReadFile :: (IOException -> e) -> FilePath -> ValueGetter e ByteString
- newtype Lit = Lit String
- showLit :: Show a => a -> Lit
The main function
:: Show e | |
=> TestName | test name |
-> ValueGetter e a | get the golden correct value |
-> ValueGetter e a | get the tested value |
-> (a -> a -> IO (Maybe e)) | comparison function. If two values are the same, it should return The function may use |
-> (a -> IO ()) | update the golden file |
-> Test |
A very general testing function.
ValueGetter monad
newtype ValueGetter e 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.
This is essentially EitherT over Codensity over IO, but that leads to too many dependencies.
ValueGetter | |
|
Monad (ValueGetter e) | |
Functor (ValueGetter e) | |
Functor (ValueGetter e) => Applicative (ValueGetter e) |
vgLiftIO :: IO a -> ValueGetter e aSource
Lift an IO
action to ValueGetter
vgError :: e -> ValueGetter e aSource
Throw an error in the ValueGetter
monad
vgReadFile :: (IOException -> e) -> FilePath -> ValueGetter e ByteStringSource
Lazily read a file. The file handle will be closed after the
ValueGetter
action is run.