summaryrefslogtreecommitdiff
path: root/testsuite/tests/lib/integer/plusMinusInteger.hs
blob: ec8d7e6ab410c6d8c5efa5568493995c58aa63a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
module Main (main) where


main :: IO ()
main = do
    print $ length vals

  where
    boundaries :: [Integer]
    boundaries = [fromIntegral (maxBound :: Int) - 3,
                  fromIntegral (maxBound :: Int) - 2,
                  fromIntegral (maxBound :: Int) - 1,
                  fromIntegral (maxBound :: Int),
                  fromIntegral (maxBound :: Int) + 1,
                  fromIntegral (maxBound :: Int) + 2,
                  fromIntegral (maxBound :: Int) + 3,

                  fromIntegral (minBound :: Int) - 3,
                  fromIntegral (minBound :: Int) - 2,
                  fromIntegral (minBound :: Int) - 1,
                  fromIntegral (minBound :: Int),
                  fromIntegral (minBound :: Int) + 1,
                  fromIntegral (minBound :: Int) + 2,
                  fromIntegral (minBound :: Int) + 3,

                  fromIntegral (maxBound :: Word) - 3,
                  fromIntegral (maxBound :: Word) - 2,
                  fromIntegral (maxBound :: Word) - 1,
                  fromIntegral (maxBound :: Word),
                  fromIntegral (maxBound :: Word) + 1,
                  fromIntegral (maxBound :: Word) + 2,
                  fromIntegral (maxBound :: Word) + 3,

                  -3, -2, -1, 0, 1, 2, 3]
    vals = filter (\(x, y) -> x /= y) [(x - y, x + negate y) |
                                       x <- boundaries, y <- boundaries]