Additional tests

Additional tests for both parsing and evaluation. 100% passing as of
commit.
This commit is contained in:
James Eversole 2024-12-19 20:21:59 -06:00
parent d13b2f52e7
commit 51f3f8f21d

View File

@ -80,6 +80,23 @@ parserTests = testGroup "Parser Tests"
let input = "t (t t (t t))"
let expected = TStem (TFork TLeaf (TStem TLeaf))
parseSapling input @?= expected
, testCase "Parse empty list" $ do
let input = "[]"
let expected = SList []
parseSapling input @?= expected
, testCase "Parse multiple nested lists" $ do
let input = "[[t t] [t (t t)]]"
let expected = SList [SList [TLeaf, TLeaf], SList [TLeaf, TStem TLeaf]]
parseSapling input @?= expected
, testCase "Parse whitespace variance" $ do
let input1 = "[t t]"
let input2 = "[ t t ]"
let expected = SList [TLeaf, TLeaf]
parseSapling input1 @?= expected
parseSapling input2 @?= expected
]
integrationTests :: TestTree
@ -149,6 +166,20 @@ evaluationTests = testGroup "Evaluation Tests"
let ast = parseSapling input
(result $ evalSapling Map.empty ast) @?= toList [Leaf, Stem Leaf]
, testCase "Evaluate empty list" $ do
let input = "[]"
let ast = parseSapling input
(result $ evalSapling Map.empty ast) @?= toList []
, testCase "Evaluate variable dependency chain" $ do
let input = "x = t\ny = t x\nz = t y\nz"
let env = evalMulti Map.empty (parseMulti input)
(result env) @?= (Stem (Stem Leaf))
, testCase "Evaluate redefinition of variables" $ do
let input = "x = t t\nx = t\nx"
let env = evalMulti Map.empty (parseMulti input)
(result env) @?= Leaf
]
propertyTests :: TestTree