vendredi 22 septembre 2017

Testing haskell functions that return errors

Hi I have a similar to the following haskell function

 test :: Int -> Bool
 test 1 = error "shouldnt have been 1"
 test 2 = error "shouldnt have been 2"
 test 11 = error "shouldnt have been 11"
 test 77 = error "shouldnt have been 77"
 test _ = True

I have a testing scheme to test bad inputs to make sure they return the correct error

 tc1 = test 1
 tc2 = test 2
 tc3 = test 11
 tc4 = test 77

 allTests = [tc1,tc2,tc3,tc4]

But the problem is that when I run allTests in ghci, I only get the first error. I would like to have a list of all the errors

How can this be done or some way I can catch the errors?

Thanks

Aucun commentaire:

Enregistrer un commentaire