Last active
March 19, 2018 20:51
-
-
Save richardwu/2277fc92bdb2edeaa2b59e263d8cf01a to your computer and use it in GitHub Desktop.
Testing in Haskell (CS 442)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- eval loop | |
module TestQ17 where | |
import Test.HUnit | |
import Q17 | |
testFn fn (input, expected) = | |
TestCase $ (fn input) @?= expected | |
main = | |
let | |
testCases = [("hello", "hello"), (1,1), (True, False)] | |
id = \x -> x | |
in | |
runTestTT $ TestList (map (testFn id) testCases) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- invoke this from the command line `runghs TestQ17.hs` | |
module TestQ17 where | |
import Test.HUnit | |
-- Replace this with the module you want to test | |
import Q17 | |
-- Fails | |
test0 = | |
TestCase $ "hello" @?= "Hello" | |
-- Passes | |
test1 = | |
TestCase $ 1 @?= 1 | |
-- Fails | |
test2 = | |
TestCase $ True @?= False | |
main = runTestTT $ TestList [test0, test1, test2] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment