Skip to content
This repository has been archived by the owner on Dec 19, 2023. It is now read-only.

Commit

Permalink
Interpreter v.0: Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaumeAbel committed Dec 5, 2023
1 parent b5f5af2 commit 1e84747
Showing 1 changed file with 28 additions and 5 deletions.
33 changes: 28 additions & 5 deletions test/Spec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ unitTestsASTParse = testGroup "AST Parse Tests"
(textToAST "foo")
, testCase "(foo)" $
assertEqual "(foo)"
(Just $ Node "foo" Nothing Nothing)
(Just $ Leaf (Symbol "foo"))
(textToAST "(foo)")
, testCase "(foo def)" $
assertEqual "(foo def)"
(Just $ Node "foo"
(Just $ Leaf (Symbol "def"))
Nothing
(Just $ Empty)
)
(textToAST "(foo def)")
, testCase "(foo def #t)" $
Expand Down Expand Up @@ -135,18 +135,41 @@ unitTestsASTParse = testGroup "AST Parse Tests"
)
)
(textToAST "(fst 1 (scd 2 3 4))")
, testCase "(fst 1 (scd 2 3 4) 12)" $
assertEqual "(fst 1 (scd 2 3 4) 12)"
(Just $ Node "fst"
(Just $ Leaf (Number 1))
(Just $ Variadic
(Just $ Node "scd"
(Just $ Leaf (Number 2))
(Just $ Variadic
(Just $ Leaf (Number 3))
(Just $ Leaf (Number 4))
)
)
(Just $ Leaf (Number 12))
)
)
(textToAST "(fst 1 (scd 2 3 4) 12)")
, testCase "(foo 42 )" $
assertEqual "(foo 42 )"
(Just $ Node "foo"
(Just $ Leaf (Number 42))
Nothing
(Just $ Empty)
)
(textToAST "(foo 42 )")
, testCase "(foo def )" $
assertEqual "(foo 42 )"
assertEqual "(foo def )"
(Just $ Node "foo"
(Just $ Leaf (Symbol "def"))
Nothing
(Just $ Empty)
)
(textToAST "(foo def )")
, testCase "(foo ((def)) #t)" $
assertEqual "(foo ((def)) #t)"
(Just $ Node "foo"
(Just $ Leaf (Symbol "(def"))
(Just $ Leaf (Boolean True))
)
(textToAST "(foo ((def)) #t)")
]

0 comments on commit 1e84747

Please sign in to comment.