[commit: ghc] wip/T16197: Add test for #16197 (a1e9cd6)

git at git.haskell.org git at git.haskell.org
Thu Jan 17 13:59:38 UTC 2019


Repository : ssh://git@git.haskell.org/ghc

On branch  : wip/T16197
Link       : http://ghc.haskell.org/trac/ghc/changeset/a1e9cd6af8b41fa451fd3be806f4aced0040a14c/ghc

>---------------------------------------------------------------

commit a1e9cd6af8b41fa451fd3be806f4aced0040a14c
Author: Ömer Sinan Ağacan <omeragacan at gmail.com>
Date:   Thu Jan 17 16:57:20 2019 +0300

    Add test for #16197


>---------------------------------------------------------------

a1e9cd6af8b41fa451fd3be806f4aced0040a14c
 testsuite/tests/stranal/should_run/Makefile      |  8 ++++++++
 testsuite/tests/stranal/should_run/T16197.hs     | 25 ++++++++++++++++++++++++
 testsuite/tests/stranal/should_run/T16197.stdout |  2 ++
 testsuite/tests/stranal/should_run/all.T         |  5 ++++-
 4 files changed, 39 insertions(+), 1 deletion(-)

diff --git a/testsuite/tests/stranal/should_run/Makefile b/testsuite/tests/stranal/should_run/Makefile
index 9101fbd..dae01b4 100644
--- a/testsuite/tests/stranal/should_run/Makefile
+++ b/testsuite/tests/stranal/should_run/Makefile
@@ -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
index 0000000..a1ab333
--- /dev/null
+++ b/testsuite/tests/stranal/should_run/T16197.hs
@@ -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
index 0000000..0eb6782
--- /dev/null
+++ b/testsuite/tests/stranal/should_run/T16197.stdout
@@ -0,0 +1,2 @@
+Evaluated True
+Evaluated True
diff --git a/testsuite/tests/stranal/should_run/all.T b/testsuite/tests/stranal/should_run/all.T
index a9cc3d7..51b1e41 100644
--- a/testsuite/tests/stranal/should_run/all.T
+++ b/testsuite/tests/stranal/should_run/all.T
@@ -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, [''])



More information about the ghc-commits mailing list