Expansion of testing suite to cover incl. library

Expands the testing suite to verify behavior of provided library
functions. Updates the README further for clarification on important
concepts.
This commit is contained in:
2024-12-29 10:28:32 -06:00
committed by James Eversole
parent 7a7ee6886a
commit f41c92fa9d
5 changed files with 118 additions and 46 deletions

View File

@ -30,14 +30,13 @@ library = evalTricu Map.empty $ parseTricu $ unlines
, "matchBool = (\\ot of : triage of (\\_ : ot) (\\_ _ : ot))"
, "matchList = (\\oe oc : triage oe _ oc)"
, "matchPair = (\\op : triage _ _ op)"
, "not = matchBool false true"
, "and = matchBool id (\\z : false)"
, "if = (\\cond then else : t (t else (t t then)) t cond)"
, "test = triage \"leaf\" (\\z : \"stem\") (\\a b : \"fork\")"
, "test = triage \"Leaf\" (\\z : \"Stem\") (\\a b : \"Fork\")"
, "emptyList = matchList true (\\y z : false)"
, "nonEmptyList = matchList false (\\y z : true)"
, "head = matchList t (\\hd tl : hd)"
, "tail = matchList t (\\hd tl : tl)"
, "isLeaf = (\\_ : triage true false false)"
, "listConcat = y (\\self : matchList (\\k : k) (\\h r k : pair h (self r k)))"
, "lAnd = triage (\\x : false) (\\_ x : x) (\\_ _ x : x)"
, "lOr = triage (\\x : x) (\\_ _ : true) (\\_ _ x : true)"

View File

@ -12,7 +12,7 @@ import Text.Megaparsec (runParser)
main :: IO ()
main = do
putStrLn "Welcome to the Tricu Interpreter"
putStrLn "Welcome to the tricu Interpreter"
putStrLn "You can exit at any time by typing and entering: "
putStrLn ":_exit"
repl library

View File

@ -28,7 +28,7 @@ repl env = runInputT defaultSettings (loop env)
case Map.lookup "__result" newEnv of
Just r -> do
outputStrLn $ "tricu > " ++ show r
outputStrLn $ "DECODE -: " ++ decodeResult r
outputStrLn $ "DECODE -: \"" ++ decodeResult r ++ "\""
Nothing -> return ()
loop newEnv
@ -36,7 +36,7 @@ decodeResult :: T -> String
decodeResult tc = case toNumber tc of
Right num -> show num
Left _ -> case toString tc of
Right str -> "\"" ++ str ++ "\""
Right str -> str
Left _ -> case toList tc of
Right list -> "[" ++ intercalate ", " (map decodeResult list) ++ "]"
Left _ -> ""