diff options
| author | Jan Tuomi <jans.tuomi@gmail.com> | 2022-12-08 17:26:43 +0200 |
|---|---|---|
| committer | Jan Tuomi <jans.tuomi@gmail.com> | 2022-12-08 17:27:57 +0200 |
| commit | 29f1d1b22b240ee9ef3cf4b867bc7a663d8d3a6a (patch) | |
| tree | 9bbf6c53a3782c48f679a02e93fbe46908f44d34 /test | |
| parent | 22a9ade3409b40f644a5b79fc6f1e5b06419c507 (diff) | |
Improve error reporting
Diffstat (limited to 'test')
| -rw-r--r-- | test/Spec.hs | 2 | ||||
| -rw-r--r-- | test/TestUtils.hs | 18 |
2 files changed, 16 insertions, 4 deletions
diff --git a/test/Spec.hs b/test/Spec.hs index a17f344..d4d5bf9 100644 --- a/test/Spec.hs +++ b/test/Spec.hs @@ -23,7 +23,7 @@ parseTests = testGroup "parse" [ assertEqual "" expected got, do got <- expectErrorL M.empty $ parse (map makeNonsenseToken ["(", "+", "1", "2"]) - let expected = "unbalanced function call" + let expected = "error: unbalanced function call" assertEqual "" expected got, do (got, _) <- expectSuccessL M.empty $ parse (map makeNonsenseToken ["\"1000\n2000\n3000\""]) diff --git a/test/TestUtils.hs b/test/TestUtils.hs index 1f0d386..f023bb7 100644 --- a/test/TestUtils.hs +++ b/test/TestUtils.hs @@ -27,29 +27,41 @@ 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 + Left ex -> error $ "unexpected error: " ++ (foldStackMessage ex) Right val -> return val expectErrorL :: Show a => Env -> LContext a -> IO String expectErrorL env lc = do res <- testRunL env lc case res of - Left (LException _ err) -> return err + Left ex -> return $ foldStackMessage ex Right (val, _) -> error $ "unexpected success: " ++ show val makeEnv :: [(String, AST)] -> Env makeEnv = M.fromList . map (B.second Regular) ast :: ASTNode -> AST -ast node = AST { an = node } +ast node = makeNonsenseAST node +astInteger :: Integer -> AST astInteger a = ast $ ASTInteger a +astDouble :: Double -> AST astDouble a = ast $ ASTDouble a +astSymbol :: String -> AST astSymbol a = ast $ ASTSymbol a +astBoolean :: Bool -> AST astBoolean a = ast $ ASTBoolean a +astString :: String -> AST astString a = ast $ ASTString a +astTag :: String -> AST +astTag a = ast $ ASTTag (computeTagN a) a +astVector :: [AST] -> AST astVector a = ast $ ASTVector a +astFunctionCall :: [AST] -> AST astFunctionCall a = ast $ ASTFunctionCall a +astHashMap :: M.Map AST AST -> AST astHashMap a = ast $ ASTHashMap a +astUnit :: AST astUnit = ast $ ASTUnit +astHole :: AST astHole = ast $ ASTHole |
