diff options
| author | Jan Tuomi <jans.tuomi@gmail.com> | 2022-10-05 14:28:00 +0300 |
|---|---|---|
| committer | Jan Tuomi <jans.tuomi@gmail.com> | 2022-12-05 14:21:53 +0200 |
| commit | 78fac664f39dc52818fb99264c258b822df7d5b9 (patch) | |
| tree | 9b7187e15c4b2690df89e7558c610f20c99e9efd /test/TestUtils.hs | |
| parent | 77968899b90cd9afe2ed2668b290b66cb553ced2 (diff) | |
Refactor Env into LContext
Diffstat (limited to 'test/TestUtils.hs')
| -rw-r--r-- | test/TestUtils.hs | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/test/TestUtils.hs b/test/TestUtils.hs index e497ece..e505de2 100644 --- a/test/TestUtils.hs +++ b/test/TestUtils.hs @@ -9,25 +9,26 @@ testConfig = Config { configVerboseMode = False, configShowHelp = False, configPrintEvaled = False, - configPrintCallStack = False + configPrintCallStack = False, + configUseREPL = False } -testRunL :: LContext a -> IO (Either LException a) -testRunL = runL testConfig +testRunL :: Env -> LContext a -> IO (Either LException (a, LState)) +testRunL env = runL LState { stateConfig = testConfig, stateEnv = env } -expectSuccessL :: LContext a -> IO a -expectSuccessL lc = - do res <- testRunL lc +expectSuccessL :: Env -> LContext a -> IO (a, LState) +expectSuccessL env lc = + do res <- testRunL env 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 +expectErrorL :: Show a => Env -> LContext a -> IO String +expectErrorL env lc = + do res <- testRunL env lc case res of Left (LException _ err) -> return err - Right val -> error $ "unexpected success: " ++ show val + Right (val, _) -> error $ "unexpected success: " ++ show val ast :: ASTNode -> AST ast node = AST { astNode = node } |
