New tests for Trac #4148
authorSimon Peyton Jones <simonpj@microsoft.com>
Tue, 12 Jun 2012 07:38:48 +0000 (08:38 +0100)
committerSimon Peyton Jones <simonpj@microsoft.com>
Tue, 12 Jun 2012 07:38:48 +0000 (08:38 +0100)
testsuite/tests/mdo/should_fail/mdofail006.hs [new file with mode: 0644]
testsuite/tests/mdo/should_fail/mdofail006.stderr [new file with mode: 0644]
testsuite/tests/mdo/should_run/mdorun004.hs [new file with mode: 0644]
testsuite/tests/mdo/should_run/mdorun004.stdout [new file with mode: 0644]
testsuite/tests/mdo/should_run/mdorun005.hs [new file with mode: 0644]
testsuite/tests/mdo/should_run/mdorun005.stdout [new file with mode: 0644]

diff --git a/testsuite/tests/mdo/should_fail/mdofail006.hs b/testsuite/tests/mdo/should_fail/mdofail006.hs
new file mode 100644 (file)
index 0000000..c904c2c
--- /dev/null
@@ -0,0 +1,12 @@
+{-# LANGUAGE DoRec #-}\r
+\r
+-- check that do-rec does not perform segmentation\r
+t :: IO [Int]\r
+t = do rec xs <- return (1:xs)\r
+           print (length (take 10 xs))     -- would diverge without segmentation\r
+       return (take 10 xs)\r
+\r
+-- should diverge when run\r
+-- currently it exhibits itself via a blocked MVar operation\r
+main :: IO ()\r
+main = t >>= print\r
diff --git a/testsuite/tests/mdo/should_fail/mdofail006.stderr b/testsuite/tests/mdo/should_fail/mdofail006.stderr
new file mode 100644 (file)
index 0000000..ea186c0
--- /dev/null
@@ -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 (file)
index 0000000..eee0be9
--- /dev/null
@@ -0,0 +1,10 @@
+{-# LANGUAGE RecursiveDo #-}\r
+\r
+-- check that mdo does perform segmentation\r
+t :: IO [Int]\r
+t = mdo xs <- return (1:xs)\r
+        print (length (take 10 xs))     -- would diverge without segmentation\r
+        return (take 10 xs)\r
+\r
+main :: IO ()\r
+main = t >>= print\r
diff --git a/testsuite/tests/mdo/should_run/mdorun004.stdout b/testsuite/tests/mdo/should_run/mdorun004.stdout
new file mode 100644 (file)
index 0000000..73a3d92
--- /dev/null
@@ -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 (file)
index 0000000..f9e2de2
--- /dev/null
@@ -0,0 +1,11 @@
+{-# LANGUAGE DoRec #-}\r
+\r
+-- check that do-rec does not perform segmentation\r
+-- compare with ../should_fail/mdofail006.hs\r
+t :: IO [Int]\r
+t = do rec xs <- return (1:xs)\r
+       print (length (take 10 xs))     -- would work since out of the segment\r
+       return (take 10 xs)\r
+\r
+main :: IO ()\r
+main = t >>= print\r
diff --git a/testsuite/tests/mdo/should_run/mdorun005.stdout b/testsuite/tests/mdo/should_run/mdorun005.stdout
new file mode 100644 (file)
index 0000000..73a3d92
--- /dev/null
@@ -0,0 +1,2 @@
+10
+[1,1,1,1,1,1,1,1,1,1]