aboutsummaryrefslogtreecommitdiffstats
path: root/test/TestUtils.hs
diff options
context:
space:
mode:
authorJan Tuomi <jans.tuomi@gmail.com>2022-09-26 11:15:48 +0300
committerJan Tuomi <jans.tuomi@gmail.com>2022-12-05 14:21:53 +0200
commit158b202ba113914a8aa1fc7a8a410d98bfb18f5b (patch)
treee4fda8c15395c16e2116bb33d4f9d317af1ec282 /test/TestUtils.hs
parent98d3f41cd8cebf1c1e26c29f01140d0543ee5853 (diff)
Improve tests
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