From 45b9331b49181144c88d4325277bd443314cd345 Mon Sep 17 00:00:00 2001 From: Tenshi Date: Fri, 8 Dec 2023 13:47:16 +0100 Subject: [PATCH] Add compute tests --- test/Spec.hs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/test/Spec.hs b/test/Spec.hs index d7ca972..c9add35 100644 --- a/test/Spec.hs +++ b/test/Spec.hs @@ -8,7 +8,7 @@ main :: IO () main = defaultMainWithIngredients (htmlRunner : defaultIngredients) tests tests :: TestTree -tests = testGroup "Tests" [unitTests] +tests = testGroup "Tests" [unitTests, computeTests] unitTests :: TestTree unitTests = testGroup "Unit tests" @@ -19,3 +19,13 @@ unitTests = testGroup "Unit tests" , testCase "Basic AST creation 2" $ assertEqual "42" (Leaf (Number 42)) (Leaf (Number 42)) ] + +computeTests :: TestTree +computeTests = testGroup "Compute tests" + [ testCase "Basic compute 0" $ + assertEqual "define x 42" (Atom 42) (computeAst (Node "define" [Leaf (Symbol "x"), Leaf (Number 42)])) + , testCase "Basic compute 1" $ + assertEqual "define x 42 and do x + x" (Leaf (Number 42)) (compute (Node "define" [Leaf (Symbol "x"), Leaf (Number 42)])) + , testCase "Basic compute 2" $ + assertEqual "42 + 42" (Atom 84) (computeAst (Node "+" [Leaf (Number 42), Leaf (Number 42)])) + ]