summaryrefslogtreecommitdiff
path: root/testsuite/tests/mdo
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2012-06-12 08:38:48 +0100
committerSimon Peyton Jones <simonpj@microsoft.com>2012-06-12 08:38:48 +0100
commiteaef9e3294451936c2d79456473cbded85dea609 (patch)
treeb4e3eb1107808c571ccf545bc27d9b0777ff1400 /testsuite/tests/mdo
parentc5c9026dbf56002130a957f79ebded34e3ae8f29 (diff)
downloadhaskell-eaef9e3294451936c2d79456473cbded85dea609.tar.gz
New tests for Trac #4148
Diffstat (limited to 'testsuite/tests/mdo')
-rw-r--r--testsuite/tests/mdo/should_fail/mdofail006.hs12
-rw-r--r--testsuite/tests/mdo/should_fail/mdofail006.stderr1
-rw-r--r--testsuite/tests/mdo/should_run/mdorun004.hs10
-rw-r--r--testsuite/tests/mdo/should_run/mdorun004.stdout2
-rw-r--r--testsuite/tests/mdo/should_run/mdorun005.hs11
-rw-r--r--testsuite/tests/mdo/should_run/mdorun005.stdout2
6 files changed, 38 insertions, 0 deletions
diff --git a/testsuite/tests/mdo/should_fail/mdofail006.hs b/testsuite/tests/mdo/should_fail/mdofail006.hs
new file mode 100644
index 0000000000..c904c2c6b2
--- /dev/null
+++ b/testsuite/tests/mdo/should_fail/mdofail006.hs
@@ -0,0 +1,12 @@
+{-# LANGUAGE DoRec #-}
+
+-- check that do-rec does not perform segmentation
+t :: IO [Int]
+t = do rec xs <- return (1:xs)
+ print (length (take 10 xs)) -- would diverge without segmentation
+ return (take 10 xs)
+
+-- should diverge when run
+-- currently it exhibits itself via a blocked MVar operation
+main :: IO ()
+main = t >>= print
diff --git a/testsuite/tests/mdo/should_fail/mdofail006.stderr b/testsuite/tests/mdo/should_fail/mdofail006.stderr
new file mode 100644
index 0000000000..ea186c0076
--- /dev/null
+++ b/testsuite/tests/mdo/should_fail/mdofail006.stderr
@@ -0,0 +1 @@
+mdofail006: thread blocked indefinitely in an MVar operation
diff --git a/testsuite/tests/mdo/should_run/mdorun004.hs b/testsuite/tests/mdo/should_run/mdorun004.hs
new file mode 100644
index 0000000000..eee0be98ea
--- /dev/null
+++ b/testsuite/tests/mdo/should_run/mdorun004.hs
@@ -0,0 +1,10 @@
+{-# LANGUAGE RecursiveDo #-}
+
+-- check that mdo does perform segmentation
+t :: IO [Int]
+t = mdo xs <- return (1:xs)
+ print (length (take 10 xs)) -- would diverge without segmentation
+ return (take 10 xs)
+
+main :: IO ()
+main = t >>= print
diff --git a/testsuite/tests/mdo/should_run/mdorun004.stdout b/testsuite/tests/mdo/should_run/mdorun004.stdout
new file mode 100644
index 0000000000..73a3d9274a
--- /dev/null
+++ b/testsuite/tests/mdo/should_run/mdorun004.stdout
@@ -0,0 +1,2 @@
+10
+[1,1,1,1,1,1,1,1,1,1]
diff --git a/testsuite/tests/mdo/should_run/mdorun005.hs b/testsuite/tests/mdo/should_run/mdorun005.hs
new file mode 100644
index 0000000000..f9e2de23f2
--- /dev/null
+++ b/testsuite/tests/mdo/should_run/mdorun005.hs
@@ -0,0 +1,11 @@
+{-# LANGUAGE DoRec #-}
+
+-- check that do-rec does not perform segmentation
+-- compare with ../should_fail/mdofail006.hs
+t :: IO [Int]
+t = do rec xs <- return (1:xs)
+ print (length (take 10 xs)) -- would work since out of the segment
+ return (take 10 xs)
+
+main :: IO ()
+main = t >>= print
diff --git a/testsuite/tests/mdo/should_run/mdorun005.stdout b/testsuite/tests/mdo/should_run/mdorun005.stdout
new file mode 100644
index 0000000000..73a3d9274a
--- /dev/null
+++ b/testsuite/tests/mdo/should_run/mdorun005.stdout
@@ -0,0 +1,2 @@
+10
+[1,1,1,1,1,1,1,1,1,1]