Additional test cases and bug fixes for subtle issues

This commit is contained in:
2024-12-19 19:53:32 -06:00
committed by James Eversole
parent b14d7b8b2c
commit e7d47ffc3c
2 changed files with 30 additions and 2 deletions

View File

@ -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
]