From 2e37f398956fc243e1d3f5d1cc83f14d228ef12c Mon Sep 17 00:00:00 2001
From: Mikhail Vorozhtsov <mikhail.vorozhtsov@gmail.com>
Date: Sat, 25 Jun 2011 21:15:16 +0700
Subject: [PATCH] Added MultiClauseLambdas tests.

---
 tests/deSugar/should_run/all.T                            |  1 +
 tests/ghc-regress/deSugar/should_run/DsMCL.hs             | 14 ++++++++++++++
 tests/ghc-regress/deSugar/should_run/DsMCL.stdout         |  1 +
 tests/ghc-regress/parser/should_compile/ParserMCL.hs      | 15 +++++++++++++++
 tests/ghc-regress/parser/should_fail/ParserMCLArity.hs    |  7 +++++++
 .../ghc-regress/parser/should_fail/ParserMCLArity.stderr  |  4 ++++
 .../ghc-regress/parser/should_fail/ParserMCLLayoutFail.hs |  7 +++++++
 .../parser/should_fail/ParserMCLLayoutFail.stderr         |  3 +++
 tests/ghc-regress/parser/should_fail/ParserNoMCL.hs       |  6 ++++++
 tests/ghc-regress/parser/should_fail/ParserNoMCL.stderr   |  2 ++
 tests/ghc-regress/parser/should_fail/ParserNoMCLHint.hs   |  5 +++++
 .../ghc-regress/parser/should_fail/ParserNoMCLHint.stderr |  3 +++
 tests/parser/should_compile/all.T                         |  1 +
 tests/parser/should_fail/all.T                            |  4 ++++
 14 files changed, 73 insertions(+)
 create mode 100644 tests/ghc-regress/deSugar/should_run/DsMCL.hs
 create mode 100644 tests/ghc-regress/deSugar/should_run/DsMCL.stdout
 create mode 100644 tests/ghc-regress/parser/should_compile/ParserMCL.hs
 create mode 100644 tests/ghc-regress/parser/should_fail/ParserMCLArity.hs
 create mode 100644 tests/ghc-regress/parser/should_fail/ParserMCLArity.stderr
 create mode 100644 tests/ghc-regress/parser/should_fail/ParserMCLLayoutFail.hs
 create mode 100644 tests/ghc-regress/parser/should_fail/ParserMCLLayoutFail.stderr
 create mode 100644 tests/ghc-regress/parser/should_fail/ParserNoMCL.hs
 create mode 100644 tests/ghc-regress/parser/should_fail/ParserNoMCL.stderr
 create mode 100644 tests/ghc-regress/parser/should_fail/ParserNoMCLHint.hs
 create mode 100644 tests/ghc-regress/parser/should_fail/ParserNoMCLHint.stderr

diff --git a/tests/deSugar/should_run/all.T b/tests/deSugar/should_run/all.T
index 31b0878..10224c8 100644
--- a/tests/deSugar/should_run/all.T
+++ b/tests/deSugar/should_run/all.T
@@ -38,3 +38,4 @@ test('mc06', normal, compile_and_run, [''])
 test('mc07', normal, compile_and_run, [''])
 test('mc08', normal, compile_and_run, [''])
 test('T5742', normal, compile_and_run, [''])
+test('DsMCL', if_compiler_lt('ghc', '7.5', skip), compile_and_run, [''])
diff --git a/tests/ghc-regress/deSugar/should_run/DsMCL.hs b/tests/ghc-regress/deSugar/should_run/DsMCL.hs
new file mode 100644
index 0000000..c623642
--- /dev/null
+++ b/tests/ghc-regress/deSugar/should_run/DsMCL.hs
@@ -0,0 +1,14 @@
+{-# LANGUAGE MultiClauseLambdas #-}
+
+module Main where
+
+f = \(Just x) (Left y)            -> Just (x, y)
+     Nothing  (Right y) | y == 99 -> Just (0, "99")
+     _        _                   -> Nothing
+
+main = putStrLn $ show [f (Just 1) (Left "Y") == Just (1, "Y"),
+                        f (Just 1) (Right 99) == Nothing,
+                        f Nothing  (Right 99) == Just (0, "99"),
+                        f Nothing  (Right 9)  == Nothing,
+                        f Nothing  (Left "Y") == Nothing]
+
diff --git a/tests/ghc-regress/deSugar/should_run/DsMCL.stdout b/tests/ghc-regress/deSugar/should_run/DsMCL.stdout
new file mode 100644
index 0000000..9adb27b
--- /dev/null
+++ b/tests/ghc-regress/deSugar/should_run/DsMCL.stdout
@@ -0,0 +1 @@
+[True,True,True,True,True]
diff --git a/tests/ghc-regress/parser/should_compile/ParserMCL.hs b/tests/ghc-regress/parser/should_compile/ParserMCL.hs
new file mode 100644
index 0000000..79875d4
--- /dev/null
+++ b/tests/ghc-regress/parser/should_compile/ParserMCL.hs
@@ -0,0 +1,15 @@
+{-# LANGUAGE MultiClauseLambdas #-}
+
+module ParserMCL where
+
+f1 x = return x >>= \y -> return y
+f2 x = return x >>=
+         \y -> return y
+f3 x = return x >>= \
+         y -> return y
+
+g1 = \"1" -> 1; "2" -> 2
+g2 = \"1" -> 1
+      "2" -> 2
+g3 = \{"1" -> 1; "2" -> 2}
+
diff --git a/tests/ghc-regress/parser/should_fail/ParserMCLArity.hs b/tests/ghc-regress/parser/should_fail/ParserMCLArity.hs
new file mode 100644
index 0000000..289e539
--- /dev/null
+++ b/tests/ghc-regress/parser/should_fail/ParserMCLArity.hs
@@ -0,0 +1,7 @@
+{-# LANGUAGE MultiClauseLambdas #-}
+
+module ParserMCLArity where
+
+f = \(Just x) y -> 1
+     Nothing -> 2
+
diff --git a/tests/ghc-regress/parser/should_fail/ParserMCLArity.stderr b/tests/ghc-regress/parser/should_fail/ParserMCLArity.stderr
new file mode 100644
index 0000000..6973bdc
--- /dev/null
+++ b/tests/ghc-regress/parser/should_fail/ParserMCLArity.stderr
@@ -0,0 +1,4 @@
+
+ParserMCLArity.hs:6:6:
+    Clause should have two patterns, but has one
+          Nothing -> 2
diff --git a/tests/ghc-regress/parser/should_fail/ParserMCLLayoutFail.hs b/tests/ghc-regress/parser/should_fail/ParserMCLLayoutFail.hs
new file mode 100644
index 0000000..bdb7e17
--- /dev/null
+++ b/tests/ghc-regress/parser/should_fail/ParserMCLLayoutFail.hs
@@ -0,0 +1,7 @@
+{-# LANGUAGE MultiClauseLambdas #-}
+
+module ParserMCLLayoutFail where
+
+f x = return x >>= \y ->
+      return y
+
diff --git a/tests/ghc-regress/parser/should_fail/ParserMCLLayoutFail.stderr b/tests/ghc-regress/parser/should_fail/ParserMCLLayoutFail.stderr
new file mode 100644
index 0000000..286c8db
--- /dev/null
+++ b/tests/ghc-regress/parser/should_fail/ParserMCLLayoutFail.stderr
@@ -0,0 +1,3 @@
+
+ParserMCLLayoutFail.hs:6:7:
+    parse error (possibly incorrect indentation)
diff --git a/tests/ghc-regress/parser/should_fail/ParserNoMCL.hs b/tests/ghc-regress/parser/should_fail/ParserNoMCL.hs
new file mode 100644
index 0000000..e7c115d
--- /dev/null
+++ b/tests/ghc-regress/parser/should_fail/ParserNoMCL.hs
@@ -0,0 +1,6 @@
+
+module ParserNoMCL where
+
+f = \"1" -> 1
+     "2" -> 2
+
diff --git a/tests/ghc-regress/parser/should_fail/ParserNoMCL.stderr b/tests/ghc-regress/parser/should_fail/ParserNoMCL.stderr
new file mode 100644
index 0000000..f5c3e11
--- /dev/null
+++ b/tests/ghc-regress/parser/should_fail/ParserNoMCL.stderr
@@ -0,0 +1,2 @@
+
+ParserNoMCL.hs:5:10: parse error on input `->'
diff --git a/tests/ghc-regress/parser/should_fail/ParserNoMCLHint.hs b/tests/ghc-regress/parser/should_fail/ParserNoMCLHint.hs
new file mode 100644
index 0000000..dc3d69d
--- /dev/null
+++ b/tests/ghc-regress/parser/should_fail/ParserNoMCLHint.hs
@@ -0,0 +1,5 @@
+
+module ParserNoMCLHint where
+
+f = \{"1" -> 1}
+
diff --git a/tests/ghc-regress/parser/should_fail/ParserNoMCLHint.stderr b/tests/ghc-regress/parser/should_fail/ParserNoMCLHint.stderr
new file mode 100644
index 0000000..fdf165d
--- /dev/null
+++ b/tests/ghc-regress/parser/should_fail/ParserNoMCLHint.stderr
@@ -0,0 +1,3 @@
+
+ParserNoMCLHint.hs:4:6:
+    Unexpected '{' after '\', maybe you need to enable -XMultiClauseLambdas
diff --git a/tests/parser/should_compile/all.T b/tests/parser/should_compile/all.T
index 0ac301e..c511d3f 100644
--- a/tests/parser/should_compile/all.T
+++ b/tests/parser/should_compile/all.T
@@ -94,3 +94,4 @@ test('EmptyDecls', normal, compile, [''])
 test('T5243', extra_clean(['T5243A.hi', 'T5243A.o']),
      multimod_compile, ['T5243',''])
 
+test('ParserMCL', if_compiler_lt('ghc', '7.5', skip), compile, [''])
diff --git a/tests/parser/should_fail/all.T b/tests/parser/should_fail/all.T
index 0e94f1a..fe0e56f 100644
--- a/tests/parser/should_fail/all.T
+++ b/tests/parser/should_fail/all.T
@@ -74,3 +74,7 @@ test('readFailTraditionalRecords2', normal, compile_fail, [''])
 test('readFailTraditionalRecords3', normal, compile_fail, [''])
 
 test('T5425', normal, compile_fail, [''])
+test('ParserNoMCL', if_compiler_lt('ghc', '7.5', skip), compile_fail, [''])
+test('ParserNoMCLHint', if_compiler_lt('ghc', '7.5', skip), compile_fail, [''])
+test('ParserMCLLayoutFail', if_compiler_lt('ghc', '7.5', skip), compile_fail, [''])
+test('ParserMCLArity', if_compiler_lt('ghc', '7.5', skip), compile_fail, [''])
-- 
1.7.11.1

