From 158b202ba113914a8aa1fc7a8a410d98bfb18f5b Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Mon, 26 Sep 2022 11:15:48 +0300 Subject: Improve tests --- test/TestUtils.hs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'test/TestUtils.hs') 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 -- cgit v1.3