summaryrefslogtreecommitdiff
path: root/testsuite/tests/stranal/should_run
diff options
context:
space:
mode:
authorDavid Terei <davidterei@gmail.com>2011-07-20 11:09:03 -0700
committerDavid Terei <davidterei@gmail.com>2011-07-20 11:26:35 -0700
commit16514f272fb42af6e9c7674a9bd6c9dce369231f (patch)
treee4f332b45fe65e2a7a2451be5674f887b42bf199 /testsuite/tests/stranal/should_run
parentebd422aed41048476aa61dd4c520d43becd78682 (diff)
downloadhaskell-16514f272fb42af6e9c7674a9bd6c9dce369231f.tar.gz
Move tests from tests/ghc-regress/* to just tests/*
Diffstat (limited to 'testsuite/tests/stranal/should_run')
-rw-r--r--testsuite/tests/stranal/should_run/Makefile3
-rw-r--r--testsuite/tests/stranal/should_run/T2756b.hs15
-rw-r--r--testsuite/tests/stranal/should_run/all.T9
-rw-r--r--testsuite/tests/stranal/should_run/strun001.hs15
-rw-r--r--testsuite/tests/stranal/should_run/strun001.stdout1
-rw-r--r--testsuite/tests/stranal/should_run/strun002.hs12
-rw-r--r--testsuite/tests/stranal/should_run/strun002.stderr1
-rw-r--r--testsuite/tests/stranal/should_run/strun003.hs23
-rw-r--r--testsuite/tests/stranal/should_run/strun003.stdout1
-rw-r--r--testsuite/tests/stranal/should_run/strun004.hs10
-rw-r--r--testsuite/tests/stranal/should_run/strun004.stdout1
11 files changed, 91 insertions, 0 deletions
diff --git a/testsuite/tests/stranal/should_run/Makefile b/testsuite/tests/stranal/should_run/Makefile
new file mode 100644
index 0000000000..9101fbd40a
--- /dev/null
+++ b/testsuite/tests/stranal/should_run/Makefile
@@ -0,0 +1,3 @@
+TOP=../../..
+include $(TOP)/mk/boilerplate.mk
+include $(TOP)/mk/test.mk
diff --git a/testsuite/tests/stranal/should_run/T2756b.hs b/testsuite/tests/stranal/should_run/T2756b.hs
new file mode 100644
index 0000000000..cb59d50c9b
--- /dev/null
+++ b/testsuite/tests/stranal/should_run/T2756b.hs
@@ -0,0 +1,15 @@
+module Main where
+
+data X = X ()
+
+{-# NOINLINE newX #-}
+newX :: () -> IO X
+newX n = do
+ let {-# NOINLINE value #-}
+ value = n
+ return (X value)
+
+main = do
+ x <- newX (error "Why?")
+ case x of
+ X _ -> return ()
diff --git a/testsuite/tests/stranal/should_run/all.T b/testsuite/tests/stranal/should_run/all.T
new file mode 100644
index 0000000000..d94a7c492d
--- /dev/null
+++ b/testsuite/tests/stranal/should_run/all.T
@@ -0,0 +1,9 @@
+# Optimised only, we're testing the strictness analyser here
+setTestOpts( only_ways(['optasm']) )
+
+test('strun001', normal, compile_and_run, [''])
+test('strun002', exit_code(1), compile_and_run, [''])
+test('strun003', normal, compile_and_run, [''])
+test('strun004', normal, compile_and_run, [''])
+test('T2756b', normal, compile_and_run, [''])
+
diff --git a/testsuite/tests/stranal/should_run/strun001.hs b/testsuite/tests/stranal/should_run/strun001.hs
new file mode 100644
index 0000000000..43820f3028
--- /dev/null
+++ b/testsuite/tests/stranal/should_run/strun001.hs
@@ -0,0 +1,15 @@
+-- Made the new demand analyser enter an absent arg
+-- Reason: it thought 'a' was unused in g.
+
+module Main where
+
+-- Strictness: SS(AL) -> T
+f True p@(x,y) = (p,y)
+f False p@(x,y) = f y p
+
+-- Easy to get the wrong strictness,
+-- by thinking 'a' is absent
+g True a b = f False (a,b)
+g False a b = g b a b
+
+main = print (g True 'a' True)
diff --git a/testsuite/tests/stranal/should_run/strun001.stdout b/testsuite/tests/stranal/should_run/strun001.stdout
new file mode 100644
index 0000000000..9cba23c739
--- /dev/null
+++ b/testsuite/tests/stranal/should_run/strun001.stdout
@@ -0,0 +1 @@
+(('a',True),True)
diff --git a/testsuite/tests/stranal/should_run/strun002.hs b/testsuite/tests/stranal/should_run/strun002.hs
new file mode 100644
index 0000000000..145166964d
--- /dev/null
+++ b/testsuite/tests/stranal/should_run/strun002.hs
@@ -0,0 +1,12 @@
+-- This showed up an "entered-absent-arg" error in 5.02.1
+
+module Main where
+
+is_volatile :: [Int] -> (String,Int) -> Int
+is_volatile [] (destVarName, destPtr)
+ = error ("Variable not found: " ++ "(" ++ (show destPtr) ++ ") " ++ destVarName)
+is_volatile (a:allWrites) (destVarName, destPtr)
+ | a == destPtr = a
+ | otherwise = is_volatile allWrites (destVarName, destPtr)
+
+main = print (is_volatile [] ("hello",2))
diff --git a/testsuite/tests/stranal/should_run/strun002.stderr b/testsuite/tests/stranal/should_run/strun002.stderr
new file mode 100644
index 0000000000..ac89b7f80b
--- /dev/null
+++ b/testsuite/tests/stranal/should_run/strun002.stderr
@@ -0,0 +1 @@
+strun002: Variable not found: (2) hello
diff --git a/testsuite/tests/stranal/should_run/strun003.hs b/testsuite/tests/stranal/should_run/strun003.hs
new file mode 100644
index 0000000000..eaedd59e8c
--- /dev/null
+++ b/testsuite/tests/stranal/should_run/strun003.hs
@@ -0,0 +1,23 @@
+-- This module should run fine with an empty argument list
+-- But it won't if the strictness analyser thinks that 'len' is use
+-- strictly, which was the case in GHC 6.0
+
+-- See the io_hack_reqd in DmdAnal.lhs
+
+module Main where
+
+import System.Environment
+import System.Exit
+
+main = do
+ args <- getArgs
+ let len = read (head args) :: Int
+
+ (if null args && useLazily len
+ then putStrLn "ok" >> exitWith ExitSuccess
+ else return () )
+
+ print len
+
+useLazily :: Int -> Bool
+useLazily len = ([len,3,4] !! 1) == 3
diff --git a/testsuite/tests/stranal/should_run/strun003.stdout b/testsuite/tests/stranal/should_run/strun003.stdout
new file mode 100644
index 0000000000..9766475a41
--- /dev/null
+++ b/testsuite/tests/stranal/should_run/strun003.stdout
@@ -0,0 +1 @@
+ok
diff --git a/testsuite/tests/stranal/should_run/strun004.hs b/testsuite/tests/stranal/should_run/strun004.hs
new file mode 100644
index 0000000000..ff58f72ce5
--- /dev/null
+++ b/testsuite/tests/stranal/should_run/strun004.hs
@@ -0,0 +1,10 @@
+module Main where
+
+f 0 = 0
+f x = x + g (x-1)
+
+g 0 = 0
+g x = x - f (x-1)
+
+main = print (f 300)
+
diff --git a/testsuite/tests/stranal/should_run/strun004.stdout b/testsuite/tests/stranal/should_run/strun004.stdout
new file mode 100644
index 0000000000..697cb3a26d
--- /dev/null
+++ b/testsuite/tests/stranal/should_run/strun004.stdout
@@ -0,0 +1 @@
+300