[commit: testsuite] master: Demand Analyser testcase: Unsaturated functions (8c5f13e)

git at git.haskell.org git at git.haskell.org
Mon Dec 9 18:44:46 UTC 2013


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

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/8c5f13eb2949d0cd29efaae2882adfc3b9af212a/testsuite

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

commit 8c5f13eb2949d0cd29efaae2882adfc3b9af212a
Author: Joachim Breitner <mail at joachim-breitner.de>
Date:   Mon Dec 9 17:45:48 2013 +0000

    Demand Analyser testcase: Unsaturated functions


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

8c5f13eb2949d0cd29efaae2882adfc3b9af212a
 tests/stranal/sigs/UnsatFun.hs     |   29 +++++++++++++++++++++++++++++
 tests/stranal/sigs/UnsatFun.stderr |    9 +++++++++
 tests/stranal/sigs/all.T           |    1 +
 3 files changed, 39 insertions(+)

diff --git a/tests/stranal/sigs/UnsatFun.hs b/tests/stranal/sigs/UnsatFun.hs
new file mode 100644
index 0000000..23ba642
--- /dev/null
+++ b/tests/stranal/sigs/UnsatFun.hs
@@ -0,0 +1,29 @@
+module UnsatFun where
+
+-- Here we test how a partially applied function (f x)
+-- with a bottom result affects the strictness signature
+-- when used strictly (g) and lazily (g')
+--
+-- In both cases, the parameter x should not be absent
+
+f :: Int -> Int -> Int
+f x y = error (show x)
+{-# NOINLINE f #-}
+
+h :: (Int -> Int) -> Int
+h f = f 2
+{-# NOINLINE h #-}
+
+h2 :: Bool -> (Int -> Int) -> Int
+h2 True  _ = 0
+h2 False f = f 2
+{-# NOINLINE h2 #-}
+
+-- Should get a bottom result
+g :: Int -> Int
+g x = let f' = f x
+      in h f'
+
+g2 :: Int -> Int
+g2 x = let f' = f x
+       in h2 True f'
diff --git a/tests/stranal/sigs/UnsatFun.stderr b/tests/stranal/sigs/UnsatFun.stderr
new file mode 100644
index 0000000..3df7ac8
--- /dev/null
+++ b/tests/stranal/sigs/UnsatFun.stderr
@@ -0,0 +1,9 @@
+
+==================== Strictness signatures ====================
+UnsatFun.h: <C(S),1*C1(U(U))>
+UnsatFun.h2: <S,1*U><L,1*C1(U(U))>
+UnsatFun.f: <B,1*U(U)><B,A>b
+UnsatFun.g2: <L,U>
+UnsatFun.g: <B,1*U(U)>b
+
+
diff --git a/tests/stranal/sigs/all.T b/tests/stranal/sigs/all.T
index ca47b52..3657432 100644
--- a/tests/stranal/sigs/all.T
+++ b/tests/stranal/sigs/all.T
@@ -12,3 +12,4 @@ test('T8569', expect_broken(8569), compile, [''])
 test('HyperStrUse', normal, compile, [''])
 test('T8598', normal, compile, [''])
 test('FacState', expect_broken(1600), compile, [''])
+test('UnsatFun', normal, compile, [''])



More information about the ghc-commits mailing list