Im taking a software testing class. And we were allowed to choose what language to write our code and tests in. And I choose Haskell. I know, maybe not the best way to learn testing (= but...
The unit-testing and coding has been working great!
But I am also required to use mocking to get a higher grade.
My problem is that I dont know very much Haskell (like Monads and stuff).
I have written and tested Calculator. And now I want to test my main. My instructor used Mockito for Java to check that the program had the correct flow.
Is it possible to test that my if-statements are correct? I have tried reading up on testing IO actions through Monads, but I dont quite understand it. Maybe I should just learn more about Monads before trying to solve this?
Any help or reading suggestions are very much appreciated!
import Calculator
main :: IO ()
main = do
putStrLn("What should I calcuclate? ex 3*(2+2) | quit to exit" )
line <- getLine
if line /= "quit"
then do if correctInput line
then do putStrLn( show $ calculate line)
main
else do putStrLn( "Wrong input")
main
else putStrLn("goodbye")
Aucun commentaire:
Enregistrer un commentaire