aboutsummaryrefslogtreecommitdiffstats
path: root/test/TestUtils.hs
diff options
context:
space:
mode:
Diffstat (limited to 'test/TestUtils.hs')
-rw-r--r--test/TestUtils.hs20
1 files changed, 15 insertions, 5 deletions
diff --git a/test/TestUtils.hs b/test/TestUtils.hs
index bcb147c..676df1d 100644
--- a/test/TestUtils.hs
+++ b/test/TestUtils.hs
@@ -12,9 +12,19 @@ initialConfig = Config {
configShowHelp = False
}
-runL :: LContext a -> IO a
-runL lc = do res <- runExceptT $ runReaderT lc initialConfig
- case res of
- Left (LException err) -> error err
- Right val -> return val
+testRunL :: LContext a -> IO (Either LException a)
+testRunL lc = runExceptT $ runReaderT lc initialConfig
+expectSuccessL :: LContext a -> IO a
+expectSuccessL lc =
+ do res <- testRunL lc
+ case res of
+ Left (LException err) -> error $ "unexpected error: " ++ err
+ Right val -> return val
+
+expectErrorL :: Show a => LContext a -> IO String
+expectErrorL lc =
+ do res <- testRunL lc
+ case res of
+ Left (LException err) -> return err
+ Right val -> error $ "unexpected success: " ++ show val