Skip to content
Snippets Groups Projects
Commit d004e3d4 authored by ik1g19's avatar ik1g19
Browse files

starting writing tests for 5 and 6

parent cb345a87
No related branches found
No related tags found
No related merge requests found
......@@ -51,6 +51,18 @@ ex4'6Ans = Nothing
ex4'7Ans = Just (LamDef [ ( "F",LamAbs 1 (LamApp (LamVar 1) (LamVar 1)) ), ( "G",LamAbs 2 (LamVar 2) ) ] (LamApp (LamMacro "F") (LamMacro "G")))
exId = (LamAbs 1 (LamVar 1))
ex5'1 = LamDef [] (LamApp (LamVar 1) (LamVar 2))
ex5'2 = (LamDef [ ("F", exId) ] (LamVar 2) )
ex5'3 = (LamDef [ ("F", exId) ] (LamMacro "F") )
ex5'4 = (LamDef [ ("F", exId) ] (LamApp (LamMacro "F") (LamMacro "F"))
ex5'1Ans = LJust (LamDef [] (LamAbs 3 (LamApp (LamAbs 6 (LamApp (LamVar 6) (LamVar 1))) (LamAbs 4 (LamApp (LamAbs 7 (LamApp (LamVar 7) (LamVar 2))) (LamAbs 5 (LamApp (LamApp (LamVar 4) (LamVar 5)) (LamVar 3))))))))
ex5'2Ans = (LamDef [ ("F", exId) ] (LamVar 2) )
ex5'3Ans = (LamDef [ ("F", exId) ] (LamMacro "F") )
ex5'4Ans = (LamDef [ ("F", exId) ] (LamApp (LamMacro "F") (LamMacro "F")))
------------------------------Printing Functions--------------------------------
......@@ -214,4 +226,32 @@ challenge4Test = do putStrLn "========================================="
assert4 ex4'7 ex4'7Ans (parseLamMacro ex4'7)
putStrLn "========================================="
putStrLn "Challenge 4 End Test"
putStrLn "=========================================\n"
-----------------------------Challenge 5 Testing--------------------------------
assert5 :: LamMacroExpr -> LamMacroExpr -> LamMacroExpr -> IO ()
assert5 macro expected result = do putStrLn "CPS Translating:"
putStrLn $ prettyPrint macro ++ "\n"
putStrLn "(Actual Internal Value):"
putStrLn $ show macro ++ "\n"
putStrLn "Expected Result:"
putStrLn $ show expected ++ "\n"
if expected == result then
putStrLn "Passed! Result:"
else
putStrLn "Failed! Result:"
putStrLn $ show result
challenge5Test :: IO ()
challenge5Test = do putStrLn "========================================="
putStrLn "Challenge 5 Start Test"
putStrLn "========================================="
assert5 ex5'1 ex5'1Ans (parseLamMacro ex4'1)
putStrLn "\n- - - - - - - - - - - - - - - - - -\n"
putStrLn "========================================="
putStrLn "Challenge 5 End Test"
putStrLn "=========================================\n"
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment