[commit: testsuite] master: Added test cases for closed type families in .hs-boot files. (9ba44e3)

Richard Eisenberg eir at ghc.haskell.org
Mon Aug 5 18:27:10 CEST 2013


Repository : http://darcs.haskell.org/ghc.git/

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/9ba44e316d404182486dfa3be544de57e9a53235

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

commit 9ba44e316d404182486dfa3be544de57e9a53235
Author: Richard Eisenberg <eir at cis.upenn.edu>
Date:   Mon Aug 5 16:56:39 2013 +0100

    Added test cases for closed type families in .hs-boot files.

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

 tests/deriving/should_fail/Roles12.stderr          |    3 ++-
 tests/indexed-types/should_compile/ClosedFam1.hs   |    9 +++++++
 .../should_compile/ClosedFam1.hs-boot              |    7 ++++++
 tests/indexed-types/should_compile/ClosedFam2.hs   |    9 +++++++
 .../should_compile/ClosedFam2.hs-boot              |    5 ++++
 tests/indexed-types/should_compile/all.T           |    4 ++++
 tests/indexed-types/should_fail/ClosedFam3.hs      |   16 +++++++++++++
 tests/indexed-types/should_fail/ClosedFam3.hs-boot |   13 ++++++++++
 tests/indexed-types/should_fail/ClosedFam3.stderr  |   25 ++++++++++++++++++++
 tests/indexed-types/should_fail/ClosedFam4.hs      |    5 ++++
 tests/indexed-types/should_fail/ClosedFam4.stderr  |    5 ++++
 tests/indexed-types/should_fail/all.T              |    4 ++++
 12 files changed, 104 insertions(+), 1 deletion(-)

diff --git a/tests/deriving/should_fail/Roles12.stderr b/tests/deriving/should_fail/Roles12.stderr
index e7f9329..ad8c25e 100644
--- a/tests/deriving/should_fail/Roles12.stderr
+++ b/tests/deriving/should_fail/Roles12.stderr
@@ -1,6 +1,7 @@
 
 Roles12.hs:5:6:
-    Type constructor ‛T’ has conflicting definitions in the module and its hs-boot file
+    Type constructor ‛T’ has conflicting definitions in the module
+    and its hs-boot file
     Main module: data T a at P
                      No C type associated
                      RecFlag Recursive, Promotable
diff --git a/tests/indexed-types/should_compile/ClosedFam1.hs b/tests/indexed-types/should_compile/ClosedFam1.hs
new file mode 100644
index 0000000..40c56db
--- /dev/null
+++ b/tests/indexed-types/should_compile/ClosedFam1.hs
@@ -0,0 +1,9 @@
+{-# LANGUAGE TypeFamilies #-}
+
+module ClosedFam1 where
+
+import {-# SOURCE #-} ClosedFam1
+
+type family Foo a where
+  Foo Int = Bool
+  Foo [a] = Maybe a
\ No newline at end of file
diff --git a/tests/indexed-types/should_compile/ClosedFam1.hs-boot b/tests/indexed-types/should_compile/ClosedFam1.hs-boot
new file mode 100644
index 0000000..244e9d1
--- /dev/null
+++ b/tests/indexed-types/should_compile/ClosedFam1.hs-boot
@@ -0,0 +1,7 @@
+{-# LANGUAGE TypeFamilies #-}
+
+module ClosedFam1 where
+
+type family Foo b where
+  Foo Int = Bool
+  Foo [different] = Maybe different
\ No newline at end of file
diff --git a/tests/indexed-types/should_compile/ClosedFam2.hs b/tests/indexed-types/should_compile/ClosedFam2.hs
new file mode 100644
index 0000000..c07c84e
--- /dev/null
+++ b/tests/indexed-types/should_compile/ClosedFam2.hs
@@ -0,0 +1,9 @@
+{-# LANGUAGE TypeFamilies #-}
+
+module ClosedFam2 where
+
+import {-# SOURCE #-} ClosedFam2
+
+type family Foo a where
+  Foo Int = Bool
+  Foo [a] = Maybe a
\ No newline at end of file
diff --git a/tests/indexed-types/should_compile/ClosedFam2.hs-boot b/tests/indexed-types/should_compile/ClosedFam2.hs-boot
new file mode 100644
index 0000000..f13bf46
--- /dev/null
+++ b/tests/indexed-types/should_compile/ClosedFam2.hs-boot
@@ -0,0 +1,5 @@
+{-# LANGUAGE TypeFamilies #-}
+
+module ClosedFam2 where
+
+type family Foo b where ..
diff --git a/tests/indexed-types/should_compile/all.T b/tests/indexed-types/should_compile/all.T
index a64c19b..6327e6e 100644
--- a/tests/indexed-types/should_compile/all.T
+++ b/tests/indexed-types/should_compile/all.T
@@ -228,3 +228,7 @@ test('T8011',
 
 test('T8018', normal, compile, [''])
 test('T8020', normal, compile, [''])
+test('ClosedFam1', extra_clean(['ClosedFam1.o-boot', 'ClosedFam1.hi-boot']),
+     multimod_compile, ['ClosedFam1', '-v0'])
+test('ClosedFam2', extra_clean(['ClosedFam2.o-boot', 'ClosedFam2.hi-boot']),
+     multimod_compile, ['ClosedFam2', '-v0'])
\ No newline at end of file
diff --git a/tests/indexed-types/should_fail/ClosedFam3.hs b/tests/indexed-types/should_fail/ClosedFam3.hs
new file mode 100644
index 0000000..27033b9
--- /dev/null
+++ b/tests/indexed-types/should_fail/ClosedFam3.hs
@@ -0,0 +1,16 @@
+{-# LANGUAGE TypeFamilies #-}
+
+module ClosedFam3 where
+
+import {-# SOURCE #-} ClosedFam3
+
+type family Foo a where
+  Foo Int = Bool
+  Foo Double = Char
+
+type family Bar a where
+  Bar Int = Bool
+  Bar Double = Double
+
+type family Baz a where
+  Baz Int = Bool
\ No newline at end of file
diff --git a/tests/indexed-types/should_fail/ClosedFam3.hs-boot b/tests/indexed-types/should_fail/ClosedFam3.hs-boot
new file mode 100644
index 0000000..0388084
--- /dev/null
+++ b/tests/indexed-types/should_fail/ClosedFam3.hs-boot
@@ -0,0 +1,13 @@
+{-# LANGUAGE TypeFamilies, PolyKinds #-}
+
+module ClosedFam3 where
+
+type family Foo a where
+  Foo Int = Bool
+
+type family Bar a where
+  Bar Int = Bool
+  Bar Double = Char
+
+type family Baz (a :: k) where
+  Baz Int = Bool
\ No newline at end of file
diff --git a/tests/indexed-types/should_fail/ClosedFam3.stderr b/tests/indexed-types/should_fail/ClosedFam3.stderr
new file mode 100644
index 0000000..1edebd6
--- /dev/null
+++ b/tests/indexed-types/should_fail/ClosedFam3.stderr
@@ -0,0 +1,25 @@
+
+ClosedFam3.hs-boot:5:13:
+    Type constructor ‛Foo’ has conflicting definitions in the module
+    and its hs-boot file
+    Main module: closed type family Foo a at N :: * where
+                     Foo Int = Bool
+                     Foo Double = Char
+    Boot file:   closed type family Foo a at N :: * where Foo Int = Bool
+
+ClosedFam3.hs-boot:8:13:
+    Type constructor ‛Bar’ has conflicting definitions in the module
+    and its hs-boot file
+    Main module: closed type family Bar a at N :: * where
+                     Bar Int = Bool
+                     Bar Double = Double
+    Boot file:   closed type family Bar a at N :: * where
+                     Bar Int = Bool
+                     Bar Double = Char
+
+ClosedFam3.hs-boot:12:13:
+    Type constructor ‛Baz’ has conflicting definitions in the module
+    and its hs-boot file
+    Main module: closed type family Baz a at N :: * where Baz Int = Bool
+    Boot file:   closed type family Baz (k::BOX)@N (a::k)@N :: * where
+                     Baz * Int = Bool
diff --git a/tests/indexed-types/should_fail/ClosedFam4.hs b/tests/indexed-types/should_fail/ClosedFam4.hs
new file mode 100644
index 0000000..348278e
--- /dev/null
+++ b/tests/indexed-types/should_fail/ClosedFam4.hs
@@ -0,0 +1,5 @@
+{-# LANGUAGE TypeFamilies #-}
+
+module ClosedFam4 where
+
+type family Foo a where ..
\ No newline at end of file
diff --git a/tests/indexed-types/should_fail/ClosedFam4.stderr b/tests/indexed-types/should_fail/ClosedFam4.stderr
new file mode 100644
index 0000000..34f8c97
--- /dev/null
+++ b/tests/indexed-types/should_fail/ClosedFam4.stderr
@@ -0,0 +1,5 @@
+
+ClosedFam4.hs:5:1:
+    You may omit the equations in a closed type family
+    only in a .hs-boot file
+    In the family declaration for ‛Foo’
diff --git a/tests/indexed-types/should_fail/all.T b/tests/indexed-types/should_fail/all.T
index d14f345..04d19ab 100644
--- a/tests/indexed-types/should_fail/all.T
+++ b/tests/indexed-types/should_fail/all.T
@@ -101,3 +101,7 @@ test('NoGood', normal, compile_fail, [''])
 test('T7967', normal, compile_fail, [''])
 
 test('T7938', normal, compile_fail, [''])
+
+test('ClosedFam3', extra_clean(['ClosedFam3.o-boot', 'ClosedFam3.hi-boot']),
+     multimod_compile_fail, ['ClosedFam3', '-v0'])
+test('ClosedFam4', normal, compile_fail, [''])
\ No newline at end of file






More information about the ghc-commits mailing list