adding all of botlist, initial add
[botlist.git] / botlistprojects / botspider / spider / tests / haskell / src / Tests / Unit / TestExample.hs
blobfde979f0861b340621614def341c62db8a866771
1 -- Example.hs -- Examples from HUnit user's guide
3 module Tests.Unit.TestExample where
5 import Test.HUnit
7 foo :: Int -> (Int, Int)
8 foo x = (1, x)
10 partA :: Int -> IO (Int, Int)
11 partA v = return (v+2, v+3)
13 partB :: Int -> IO Bool
14 partB v = return (v > 5)
16 test1 :: Test
17 test1 = TestCase (assertEqual "for (foo 3)," (1,2) (foo 3))
19 test2 :: Test
20 test2 = TestCase (do (x,y) <- partA 3
21 assertEqual "for the first result of partA," 5 x
22 b <- partB y
23 assertBool ("(partB " ++ show y ++ ") failed") b)
25 allTests :: Test
26 allTests = TestList [TestLabel "test1" test1, TestLabel "test2" test2]
28 allTests2 :: Test
29 allTests2 = test [ "test1" ~: "(foo 3)" ~: (1,2) ~=? (foo 3),
30 "test2" ~: do (x, y) <- partA 3
31 assertEqual "for the first result of partA," 5 x
32 partB y @? "(partB " ++ show y ++ ") failed" ]
34 --main :: IO Counts
35 --main = do runTestTT tests
36 -- runTestTT tests'