aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/Spec.hs2
-rw-r--r--test/TestUtils.hs18
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