Add test for #16197
authorÖmer Sinan Ağacan <omeragacan@gmail.com>
Thu, 17 Jan 2019 13:57:20 +0000 (16:57 +0300)
committerÖmer Sinan Ağacan <omeragacan@gmail.com>
Thu, 17 Jan 2019 13:57:20 +0000 (16:57 +0300)
testsuite/tests/stranal/should_run/Makefile
testsuite/tests/stranal/should_run/T16197.hs [new file with mode: 0644]
testsuite/tests/stranal/should_run/T16197.stdout [new file with mode: 0644]
testsuite/tests/stranal/should_run/all.T

index 9101fbd..dae01b4 100644 (file)
@@ -1,3 +1,11 @@
 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
diff --git a/testsuite/tests/stranal/should_run/T16197.hs b/testsuite/tests/stranal/should_run/T16197.hs
new file mode 100644 (file)
index 0000000..a1ab333
--- /dev/null
@@ -0,0 +1,25 @@
+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 ()
diff --git a/testsuite/tests/stranal/should_run/T16197.stdout b/testsuite/tests/stranal/should_run/T16197.stdout
new file mode 100644 (file)
index 0000000..0eb6782
--- /dev/null
@@ -0,0 +1,2 @@
+Evaluated True
+Evaluated True
index a9cc3d7..51b1e41 100644 (file)
@@ -1,4 +1,7 @@
-# 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, [''])