3 -- Note: anything which prints an Integer automatically tests
6 egs1 = [-5..5] :: [Integer]
7 egs2 = filter (/=0) egs1 -- avoid division by zero
9 t0 = (1::Integer) == (1::Integer)
11 t1 = shw $ table (+) egs1 egs1
12 t2 = shw $ table (-) egs1 egs1
13 t3 = shw $ table (*) egs1 egs1
15 t4 = shw $ table div egs1 egs2
16 t5 = shw $ table mod egs1 egs2
17 t6 = shw $ table quot egs1 egs2
18 t7 = shw $ table rem egs1 egs2
20 u1 = shw $ table (==) egs1 egs1
21 u2 = shw $ table (/=) egs1 egs1
22 u3 = shw $ table (<=) egs1 egs1
23 u4 = shw $ table (<) egs1 egs1
24 u5 = shw $ table (>) egs1 egs1
25 u6 = shw $ table (>=) egs1 egs1
28 -- The implementation is based on 4 digit chunks - so let's test
29 -- the results when we use values near those boundaries.
31 egs3 = [9999,10000,10001,99999999,100000000,100000001] :: [Integer]
32 egs4 = filter (/=0) egs3 -- avoid division by zero
34 v1 = shw $ table (+) egs3 egs3
35 v2 = shw $ table (-) egs3 egs3
36 v3 = shw $ table (*) egs3 egs3
38 v4 = shw $ table div egs3 egs4
39 v5 = shw $ table mod egs3 egs4
40 v6 = shw $ table quot egs3 egs4
41 v7 = shw $ table rem egs3 egs4
43 w1 = shw $ table (==) egs3 egs3
44 w2 = shw $ table (/=) egs3 egs3
45 w3 = shw $ table (<=) egs3 egs3
46 w4 = shw $ table (<) egs3 egs3
47 w5 = shw $ table (>) egs3 egs3
48 w6 = shw $ table (>=) egs3 egs3
50 -- Some utilities for generating neat tables of test results
51 table :: (a -> a -> b) -> [a] -> [a] -> [[b]]
52 table f xs ys = [ [ x `f` y | x <- xs ] | y <- ys ]
54 shw :: Show a => [[a]] -> IO ()
55 shw = putStr . unlines . map (unwords . map show)