module Main where

import Control.Exception

--good: main = assert False (let f x = f x in f 1)

-- bad: main = assert False undefined

-- bad: main = assert False (error "assert is doomed")

-- bad: main = assert False (throw Overflow)

--good: main = let e1 = (1, throw Overflow)
--             in assert False (snd e1)

assertError str predicate v
 | predicate = v
 | otherwise = throw (AssertionFailed str)

--good:
--main = assertError "assert rulez!" False (throw Overflow)

-- bad:
main = let e1 i = throw Overflow
       in assert False (e1 5)

--good: ghc --make -O0 -fno-ignore-asserts test.hs

--good: ghc --make -O0 -fignore-asserts -fno-ignore-asserts test.hs

-- bad: ghc --make -O1 -fno-ignore-asserts test.hs

-- bad: ghc --make -O2 -fno-ignore-asserts test.hs
