LLM approve #1

This commit is contained in:
2026-08-28 17:24:00 -05:00
parent c6e4a43178
commit 079643e2b7
6 changed files with 219 additions and 83 deletions

View File

@@ -77,13 +77,13 @@ allTestLibsEnv = unsafePerformIO $ do
tests :: TestTree
tests = testGroup "Tricu Tests"
[ lexer
, parser
, simpleEvaluation
, lambdas
--, parser
--, simpleEvaluation
--, lambdas
, providedLibraries
, maybeTests
, fileEval
, demos
--, maybeTests
--, fileEval
--, demos
--, decoding
--, elimLambdaSingle
--, stressElimLambda
@@ -1106,6 +1106,91 @@ providedLibraries = testGroup "Library Tests"
let input = "unwords []"
env = evalTricu allTestLibsEnv (parseTricu input)
result env @?= ofString ""
, testCase "intercalate joins fields" $ do
let input = "intercalate \", \" [(\"a\") (\"b\") (\"c\")]"
env = evalTricu allTestLibsEnv (parseTricu input)
result env @?= ofString "a, b, c"
, testCase "intercalate leaves a lone field alone" $ do
let input = "intercalate \", \" [(\"a\")]"
env = evalTricu allTestLibsEnv (parseTricu input)
result env @?= ofString "a"
, testCase "intercalate empty list" $ do
let input = "intercalate \", \" []"
env = evalTricu allTestLibsEnv (parseTricu input)
result env @?= ofString ""
, testCase "joinSuffix terminates every field" $ do
let input = "joinSuffix \"-\" [(\"a\") (\"b\")]"
env = evalTricu allTestLibsEnv (parseTricu input)
result env @?= ofString "a-b-"
, testCase "splitOnByte splits on a byte" $ do
let input = "splitOnByte 58 \"a:b:c\""
env = evalTricu allTestLibsEnv (parseTricu input)
result env @?= ofList [ofString "a", ofString "b", ofString "c"]
, testCase "splitOnByte keeps empty fields" $ do
let input = "splitOnByte 58 \"a::b\""
env = evalTricu allTestLibsEnv (parseTricu input)
result env @?= ofList [ofString "a", ofString "", ofString "b"]
, testCase "splitOnByte trailing separator leaves an empty field" $ do
let input = "splitOnByte 58 \"a:\""
env = evalTricu allTestLibsEnv (parseTricu input)
result env @?= ofList [ofString "a", ofString ""]
, testCase "splitOnByte without a match" $ do
let input = "splitOnByte 58 \"abc\""
env = evalTricu allTestLibsEnv (parseTricu input)
result env @?= ofList [ofString "abc"]
, testCase "splitOnByte empty input" $ do
let input = "splitOnByte 58 \"\""
env = evalTricu allTestLibsEnv (parseTricu input)
result env @?= ofList [ofString ""]
, testCase "intercalate round trips splitOnByte" $ do
let input = "equal? (intercalate \":\" (splitOnByte 58 \"a:b:c\")) \"a:b:c\""
env = evalTricu allTestLibsEnv (parseTricu input)
result env @?= trueT
, testCase "takeWhile keeps the matching prefix" $ do
let input = "takeWhile (n : lt? n 3) [(1) (2) (3) (1)]"
env = evalTricu allTestLibsEnv (parseTricu input)
result env @?= ofList [ofNumber 1, ofNumber 2]
, testCase "takeWhile stops at the first mismatch" $ do
let input = "takeWhile (n : lt? n 3) [(3) (1)]"
env = evalTricu allTestLibsEnv (parseTricu input)
result env @?= ofList []
, testCase "dropWhile drops the matching prefix" $ do
let input = "dropWhile (n : lt? n 3) [(1) (2) (3) (1)]"
env = evalTricu allTestLibsEnv (parseTricu input)
result env @?= ofList [ofNumber 3, ofNumber 1]
, testCase "dropWhile on an all matching list" $ do
let input = "dropWhile (n : lt? n 3) [(1) (2)]"
env = evalTricu allTestLibsEnv (parseTricu input)
result env @?= ofList []
, testCase "trim strips surrounding spaces and tabs" $ do
let input = "trim \" \\ttrimmed \\t\""
env = evalTricu allTestLibsEnv (parseTricu input)
result env @?= ofString "trimmed"
, testCase "trim leaves interior bytes alone" $ do
let input = "trim \" a b \""
env = evalTricu allTestLibsEnv (parseTricu input)
result env @?= ofString "a b"
, testCase "trim all whitespace is empty" $ do
let input = "trim \" \\t \""
env = evalTricu allTestLibsEnv (parseTricu input)
result env @?= ofString ""
]
arithmeticTests :: TestTree