Additional test cases and bug fixes for subtle issues
This commit is contained in:
23
test/Spec.hs
23
test/Spec.hs
@ -5,6 +5,7 @@ import Lexer
|
||||
import Parser
|
||||
import Research
|
||||
|
||||
import Control.Exception (evaluate, try, SomeException)
|
||||
import qualified Data.Map as Map
|
||||
import Test.Tasty
|
||||
import Test.Tasty.HUnit
|
||||
@ -58,6 +59,27 @@ parserTests = testGroup "Parser Tests"
|
||||
let input = "t t t"
|
||||
let expected = TFork TLeaf TLeaf
|
||||
parseSapling input @?= expected
|
||||
|
||||
, testCase "Parse mixed list literals" $ do
|
||||
-- You must put non-listliterals in parentheses
|
||||
let input = "[t (\"hello\") t]"
|
||||
let expected = SList [TLeaf, SStr "hello", TLeaf]
|
||||
parseSapling input @?= expected
|
||||
|
||||
, testCase "Parse function with applications" $ do
|
||||
let input = "f x = t x"
|
||||
let expected = SFunc "f" ["x"] (SApp TLeaf [SVar "x"])
|
||||
parseSapling input @?= expected
|
||||
|
||||
, testCase "Parse nested lists" $ do
|
||||
let input = "[t [(t t)]]"
|
||||
let expected = SList [TLeaf, SList [TStem TLeaf]]
|
||||
parseSapling input @?= expected
|
||||
|
||||
, testCase "Parse complex parentheses" $ do
|
||||
let input = "t (t t (t t))"
|
||||
let expected = TStem (TFork TLeaf (TStem TLeaf))
|
||||
parseSapling input @?= expected
|
||||
]
|
||||
|
||||
integrationTests :: TestTree
|
||||
@ -138,4 +160,3 @@ propertyTests = testGroup "Property Tests"
|
||||
Left _ -> property True
|
||||
Right ast -> parseSapling input === ast
|
||||
]
|
||||
|
||||
|
Reference in New Issue
Block a user