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

starting test work on challenge 4

parent 89a62282
No related branches found
No related tags found
No related merge requests found
......@@ -7,7 +7,7 @@
-- DO NOT MODIFY THE FOLLOWING LINES OF CODE
module Challenges (WordSearchGrid,Placement,Posn,Orientation(..),solveWordSearch, createWordSearch,
LamMacroExpr(..),LamExpr(..),prettyPrint, parseLamMacro,
cpsTransform,innerRedn1,outerRedn1,compareInnerOuter,unique,macroName,closedParse,expr) where
cpsTransform,innerRedn1,outerRedn1,compareInnerOuter) where
-- Import standard library and parsing definitions from Hutton 2016, Chapter 13
-- We import System.Random - make sure that your installation has it installed - use stack ghci and stack ghc
......
import Challenges
import Data.List
main :: IO ()
main = challenge2Test
-------------------------------------Examples-----------------------------------
exGrid1'1 = [ "HAGNIRTSH" , "SACAGETAK", "GCSTACKEL","MGHKMILKI","EKNLETGCN","TNIRTLETE","IRAAHCLSR","MAMROSAGD","GIZKDDNRG" ]
exWords1'1 = [ "HASKELL","STRING","STACK","MAIN","METHOD"]
exAns1'1 = [("HASKELL",Just((0,0),DownForward)),("STRING",Just((7,0),Back)),("STACK",Just((2,2),Forward)),
("MAIN", Just((2,7),Up )),("METHOD",Just((4,3),Down))]
exGrid1'2 = ["ROBREUMBR","AURPEPSAN","UNLALMSEE","YGAUNPYYP","NLMNBGENA","NBLEALEOR","ALRYPBBLG","NREPBEBEP","YGAYAROMR"]
exWords1'2 = [ "BANANA", "ORANGE", "MELON", "RASPBERRY","APPLE","PLUM","GRAPE" ]
exAns1'2 = [("BANANA", Just((5,6),UpBack )),("ORANGE",Just((1,0),DownForward)),("MELON",Just((7,8),Up )),
("RASPBERRY",Just((8,0),DownBack)),("APPLE", Just((2,8),UpForward )),("PLUM", Just((5,1),DownBack)),
("GRAPE", Just((8,6),Up ))]
exGrid1'3 = ["TEST","ASBD","GDFI","FDGS"]
exWords1'3 = ["TEST"]
exAns1'3 = [("TEST",Just((0,0),Forward))]
ex3'1 = LamDef [] (LamApp (LamAbs 1 (LamVar 1)) (LamAbs 1 (LamVar 1)))
ex3'2 = LamDef [] (LamAbs 1 (LamApp (LamVar 1) (LamAbs 1 (LamVar 1))))
ex3'3 = LamDef [ ("F",LamAbs 1 (LamVar 1) ) ] (LamAbs 2 (LamApp (LamVar 2) (LamMacro "F")))
ex3'4 = LamDef [ ("F",LamAbs 1 (LamVar 1) ) ] (LamAbs 2 (LamApp (LamAbs 1 (LamVar 1)) (LamVar 2)))
ex3'5 = LamDef [ ( "F",LamAbs 1 (LamApp ((LamVar 1) (LamVar 1)) ), ( "G",LamAbs 2 (LamVar 2) ) ] ()
ex3'1Ans = "(\\x1 -> x1) \\x1 -> x1"
ex3'2Ans = "\\x1 -> x1 \\x1 -> x1"
ex3'3Ans = "def F = \\x1 -> x1 in \\x2 -> x2 F"
ex3'4Ans = "def F = \\x1 -> x1 in \\x2 -> F x2"
ex3'5Ans = "def F = \\x1 -> x1 x1 in def G = \\x2 -> x2 in F G"
------------------------------Printing Functions--------------------------------
printGrid :: WordSearchGrid -> IO ()
printGrid [] = return ()
......@@ -39,6 +52,16 @@ pPrintList cs = do putStr "["
ppl $ xs
-------------------------------------Main---------------------------------------
main :: IO ()
main = do challenge1Test
challenge2Test
-----------------------------Challenge 1 Testing--------------------------------
assert1 :: WordSearchGrid -> [ (String,Maybe Placement) ] -> [ (String,Maybe Placement) ] -> IO ()
assert1 grid result correct | result == correct = do putStrLn "Testing Grid:\n"
......@@ -60,8 +83,10 @@ challenge1Test = do putStrLn "Challenge 1 Start Test"
assert1 exGrid1'1 (solveWordSearch exWords1'1 exGrid1'1) exAns1'1
assert1 exGrid1'2 (solveWordSearch exWords1'2 exGrid1'2) exAns1'2
putStrLn "========================================="
putStrLn "Challenge 1 End Test"
putStrLn "Challenge 1 End Test\n"
-----------------------------Challenge 2 Testing--------------------------------
assert2 :: WordSearchGrid -> [ (String,Maybe Placement) ] -> IO ()
......@@ -87,3 +112,13 @@ challenge2Test = do putStrLn "Challenge 2 Start Test"
assert2 g1 sol1
putStrLn "========================================="
putStrLn "Challenge 2 End Test"
-----------------------------Challenge 3 Testing--------------------------------
assert3
-- challenge3Test
\ 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