Better test coverage for module reexports in signatures.
authorEdward Z. Yang <ezyang@cs.stanford.edu>
Tue, 28 Mar 2017 17:21:15 +0000 (10:21 -0700)
committerEdward Z. Yang <ezyang@cs.stanford.edu>
Sun, 2 Apr 2017 23:43:47 +0000 (16:43 -0700)
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
testsuite/tests/backpack/should_compile/all.T
testsuite/tests/backpack/should_compile/bkp54.bkp [new file with mode: 0644]
testsuite/tests/backpack/should_compile/bkp54.stderr [new file with mode: 0644]
testsuite/tests/backpack/should_compile/bkp55.bkp [new file with mode: 0644]
testsuite/tests/backpack/should_compile/bkp55.stderr [new file with mode: 0644]
testsuite/tests/backpack/should_fail/all.T
testsuite/tests/backpack/should_fail/bkpfail48.bkp [new file with mode: 0644]
testsuite/tests/backpack/should_fail/bkpfail48.stderr [new file with mode: 0644]
testsuite/tests/backpack/should_fail/bkpfail49.bkp [new file with mode: 0644]
testsuite/tests/backpack/should_fail/bkpfail49.stderr [new file with mode: 0644]

index 477c0fe..da6ea5f 100644 (file)
@@ -45,6 +45,8 @@ test('bkp50', normal, backpack_compile, [''])
 test('bkp51', normal, backpack_compile, [''])
 test('bkp52', normal, backpack_compile, [''])
 test('bkp53', normal, backpack_compile, [''])
+test('bkp54', normal, backpack_compile, [''])
+test('bkp55', normal, backpack_compile, [''])
 
 test('T13140', normal, backpack_compile, [''])
 test('T13149', expect_broken(13149), backpack_compile, [''])
diff --git a/testsuite/tests/backpack/should_compile/bkp54.bkp b/testsuite/tests/backpack/should_compile/bkp54.bkp
new file mode 100644 (file)
index 0000000..6cf1270
--- /dev/null
@@ -0,0 +1,11 @@
+unit q where
+    signature A (module N) where
+        import qualified Data.Bool as N
+unit p where
+    dependency signature q[A=<A>]
+    signature A (module A, module Data.Word) where
+        import Data.Word
+    module M where
+        import qualified A
+        x = A.otherwise
+        type T = A.Word
diff --git a/testsuite/tests/backpack/should_compile/bkp54.stderr b/testsuite/tests/backpack/should_compile/bkp54.stderr
new file mode 100644 (file)
index 0000000..f3aafc1
--- /dev/null
@@ -0,0 +1,5 @@
+[1 of 2] Processing q
+  [1 of 1] Compiling A[sig]           ( q/A.hsig, nothing )
+[2 of 2] Processing p
+  [1 of 2] Compiling A[sig]           ( p/A.hsig, nothing )
+  [2 of 2] Compiling M                ( p/M.hs, nothing )
diff --git a/testsuite/tests/backpack/should_compile/bkp55.bkp b/testsuite/tests/backpack/should_compile/bkp55.bkp
new file mode 100644 (file)
index 0000000..d9c7370
--- /dev/null
@@ -0,0 +1,11 @@
+unit p where
+    signature A where
+        p :: Int
+
+unit q where
+    dependency signature p[A=<B>]
+    signature B (module B) where
+        q :: Int
+    module M where
+        import B
+        f = p + q
diff --git a/testsuite/tests/backpack/should_compile/bkp55.stderr b/testsuite/tests/backpack/should_compile/bkp55.stderr
new file mode 100644 (file)
index 0000000..9213c9c
--- /dev/null
@@ -0,0 +1,5 @@
+[1 of 2] Processing p
+  [1 of 1] Compiling A[sig]           ( p/A.hsig, nothing )
+[2 of 2] Processing q
+  [1 of 2] Compiling B[sig]           ( q/B.hsig, nothing )
+  [2 of 2] Compiling M                ( q/M.hs, nothing )
index e1416fc..856733e 100644 (file)
@@ -43,3 +43,5 @@ test('bkpfail44', normal, backpack_compile_fail, [''])
 test('bkpfail45', normal, backpack_compile_fail, [''])
 test('bkpfail46', normal, backpack_compile_fail, [''])
 test('bkpfail47', normal, backpack_compile_fail, [''])
+test('bkpfail48', normal, backpack_compile_fail, [''])
+test('bkpfail49', normal, backpack_compile_fail, [''])
diff --git a/testsuite/tests/backpack/should_fail/bkpfail48.bkp b/testsuite/tests/backpack/should_fail/bkpfail48.bkp
new file mode 100644 (file)
index 0000000..e66100d
--- /dev/null
@@ -0,0 +1,7 @@
+unit q where
+    signature A (module Data.Bool) where
+        import Data.Bool
+unit p where
+    dependency signature q[A=<A>]
+    signature A (module Data.Bool) where
+        -- This should not work: module is mandatory
diff --git a/testsuite/tests/backpack/should_fail/bkpfail48.stderr b/testsuite/tests/backpack/should_fail/bkpfail48.stderr
new file mode 100644 (file)
index 0000000..9c991d6
--- /dev/null
@@ -0,0 +1,10 @@
+[1 of 2] Processing q
+  [1 of 1] Compiling A[sig]           ( q/A.hsig, nothing )
+[2 of 2] Processing p
+  [1 of 1] Compiling A[sig]           ( p/A.hsig, nothing )
+
+bkpfail48.bkp:6:18: error:
+    • The export item `module Data.Bool' is not imported
+    • while merging the signatures from:
+        • q[A=<A>]:A
+        • ...and the local signature for A
diff --git a/testsuite/tests/backpack/should_fail/bkpfail49.bkp b/testsuite/tests/backpack/should_fail/bkpfail49.bkp
new file mode 100644 (file)
index 0000000..a30a1f8
--- /dev/null
@@ -0,0 +1,11 @@
+unit p where
+    signature A (module Data.Bool) where
+        import Data.Bool
+
+unit q where
+    dependency signature p[A=<A>]
+    signature A (module Data.Bool) where
+        import Data.Bool ()
+    module M where
+        import qualified A
+        x = A.True -- should not exist!
diff --git a/testsuite/tests/backpack/should_fail/bkpfail49.stderr b/testsuite/tests/backpack/should_fail/bkpfail49.stderr
new file mode 100644 (file)
index 0000000..c2236e5
--- /dev/null
@@ -0,0 +1,9 @@
+[1 of 2] Processing p
+  [1 of 1] Compiling A[sig]           ( p/A.hsig, nothing )
+[2 of 2] Processing q
+  [1 of 2] Compiling A[sig]           ( q/A.hsig, nothing )
+  [2 of 2] Compiling M                ( q/M.hs, nothing )
+
+bkpfail49.bkp:11:13: error:
+    Not in scope: data constructor ‘A.True’
+    Module ‘A’ does not export ‘True’.