software-engineering-amsterdam / ST2018_WG_4

0 stars 0 forks source link

Lab 3 #3

Open BertLisser opened 5 years ago

BertLisser commented 5 years ago

Exercise 1 Nice solution with uncurry.

Exercise 2

parserTest :: Int -> Int -> IO ()
parserTest testsExecuted totalTests = if testsExecuted == totalTests then putStrLn ("\x1b[32m" ++ show totalTests ++ " tests passed\x1b[0m")
                else generateActualForm >>= \x -> let resultingForm = parse (show x) in if length resultingForm == 1 && equiv x (head resultingForm) then
                    do putStrLn ("pass on: " ++ show x)
                       parserTest (testsExecuted+1) totalTests
                  else error ("failed test on: " ++ show x)

equiv is not sufficient. Required is: That the forms have the same shape. So

parserTest :: Int -> Int -> IO ()
parserTest testsExecuted totalTests = if testsExecuted == totalTests then putStrLn ("\x1b[32m" ++ show totalTests ++ " tests passed\x1b[0m")
                else generateActualForm >>= \x -> let resultingForm = parse (show x) in if length resultingForm == 1 &&  x == (head resultingForm) then
                    do putStrLn ("pass on: " ++ show x)
                       parserTest (testsExecuted+1) totalTests
                  else error ("failed test on: " ++ show x)