Commit a1e9cd6a authored by Ömer Sinan Ağacan's avatar Ömer Sinan Ağacan

Add test for #16197

parent 6aaa0655
TOP=../../..
include $(TOP)/mk/boilerplate.mk
include $(TOP)/mk/test.mk
.PHONY: T16197
T16197:
'$(TEST_HC)' -O0 -v0 T16197.hs
./T16197
rm T16197.o T16197.hi T16197
'$(TEST_HC)' -O1 -v0 T16197.hs
./T16197
import System.IO.Unsafe (unsafePerformIO)
data T = T !Bool
data Box a = Box a
f :: Int -> T -> Box Bool
f n t
| n <= 0 = case t of
T b -> Box b
| otherwise = f (n-2) t
f1 :: Int -> Bool -> Box Bool
f1 n t
| n <= 0 = f (-n) $! T t
| otherwise = f1 (n-2) t
g :: Int -> Bool
g k = if k <= 0
then unsafePerformIO (putStrLn "Evaluated True" >> return True)
else unsafePerformIO (putStrLn "Evaluated False" >> return False)
{-# NOINLINE g #-}
main :: IO ()
main = case f1 4 (g 0) of
Box _ -> return ()
# Optimised only, we're testing the strictness analyser here
# Run this always
test('T16197', normal, run_command, ['$MAKE -s --no-print-directory T16197'])
# Run the rest only in optasm way, we're testing the strictness analyser here
setTestOpts( only_ways(['optasm']) )
test('strun001', normal, compile_and_run, [''])
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment