Ticket #5561: test.hs

File test.hs, 777 bytes (added by MikolajKonarski, 4 years ago)
Line 
1module Main where
2
3import Control.Exception
4
5--good: main = assert False (let f x = f x in f 1)
6
7-- bad: main = assert False undefined
8
9-- bad: main = assert False (error "assert is doomed")
10
11-- bad: main = assert False (throw Overflow)
12
13--good: main = let e1 = (1, throw Overflow)
14--             in assert False (snd e1)
15
16assertError str predicate v
17 | predicate = v
18 | otherwise = throw (AssertionFailed str)
19
20--good:
21--main = assertError "assert rulez!" False (throw Overflow)
22
23-- bad:
24main = let e1 i = throw Overflow
25       in assert False (e1 5)
26
27--good: ghc --make -O0 -fno-ignore-asserts test.hs
28
29--good: ghc --make -O0 -fignore-asserts -fno-ignore-asserts test.hs
30
31-- bad: ghc --make -O1 -fno-ignore-asserts test.hs
32
33-- bad: ghc --make -O2 -fno-ignore-asserts test.hs