summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2011-12-23 17:57:53 +0000
committerSimon Peyton Jones <simonpj@microsoft.com>2011-12-23 17:57:53 +0000
commit4976d0e03cadcd7faf19a21e759dc3088604e63f (patch)
tree08081ecae966ca820bb82a0b2bcf28e80e71e2e2 /testsuite
parentd3c9c1dbc4cd65cf4626d311633e6d260eb075e6 (diff)
parente08432d8436659e1a95da33f0d526638e3372c81 (diff)
downloadhaskell-4976d0e03cadcd7faf19a21e759dc3088604e63f.tar.gz
Merge branch 'master' of http://darcs.haskell.org/testsuite
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/tests/indexed-types/should_fail/T3330c.stderr35
-rw-r--r--testsuite/tests/safeHaskell/check/Check06.hs13
-rw-r--r--testsuite/tests/safeHaskell/check/Check06.stderr5
-rw-r--r--testsuite/tests/safeHaskell/check/Check06_A.hs6
-rw-r--r--testsuite/tests/safeHaskell/check/Check07.hs14
-rw-r--r--testsuite/tests/safeHaskell/check/Check07.stderr3
-rw-r--r--testsuite/tests/safeHaskell/check/Check07_A.hs8
-rw-r--r--testsuite/tests/safeHaskell/check/Check07_B.hs8
-rw-r--r--testsuite/tests/safeHaskell/check/Check08.hs14
-rw-r--r--testsuite/tests/safeHaskell/check/Check08.stderr6
-rw-r--r--testsuite/tests/safeHaskell/check/Check08_A.hs8
-rw-r--r--testsuite/tests/safeHaskell/check/Check08_B.hs8
-rw-r--r--testsuite/tests/safeHaskell/check/all.T15
-rw-r--r--testsuite/tests/safeHaskell/check/pkg01/M_SafePkg5.hs14
-rw-r--r--testsuite/tests/safeHaskell/check/pkg01/Makefile3
-rw-r--r--testsuite/tests/safeHaskell/check/pkg01/p.cabal1
-rw-r--r--testsuite/tests/safeHaskell/check/pkg01/safePkg01.stdout5
17 files changed, 148 insertions, 18 deletions
diff --git a/testsuite/tests/indexed-types/should_fail/T3330c.stderr b/testsuite/tests/indexed-types/should_fail/T3330c.stderr
index 506f91e47e..b35db0dcdb 100644
--- a/testsuite/tests/indexed-types/should_fail/T3330c.stderr
+++ b/testsuite/tests/indexed-types/should_fail/T3330c.stderr
@@ -1,18 +1,17 @@
-
-T3330c.hs:23:43:
- Couldn't match type `Der ((->) x)' with `R'
- In the first argument of `plug', namely `rf'
- In the first argument of `Inl', namely `(plug rf df x)'
- In the expression: Inl (plug rf df x)
-
-T3330c.hs:23:43:
- Couldn't match type `f1' with `f1 x'
- `f1' is a rigid type variable bound by
- a pattern with constructor
- RSum :: forall (f :: * -> *) (g :: * -> *).
- R f -> R g -> R (f :+: g),
- in an equation for plug'
- at T3330c.hs:23:8
- In the first argument of `plug', namely `rf'
- In the first argument of `Inl', namely `(plug rf df x)'
- In the expression: Inl (plug rf df x)
+
+T3330c.hs:23:33:
+ Kind incompatibility when matching types:
+ f0 :: * -> *
+ f0 x :: *
+ In the return type of a call of `Inl'
+ In the expression: Inl (plug rf df x)
+ In an equation for plug':
+ plug' (RSum rf rg) (Inl df) x = Inl (plug rf df x)
+
+T3330c.hs:23:43:
+ Couldn't match kind `*' with `* -> *'
+ Kind incompatibility when matching types:
+ Der ((->) x) :: * -> *
+ R :: (* -> *) -> *
+ In the first argument of `plug', namely `rf'
+ In the first argument of `Inl', namely `(plug rf df x)'
diff --git a/testsuite/tests/safeHaskell/check/Check06.hs b/testsuite/tests/safeHaskell/check/Check06.hs
new file mode 100644
index 0000000000..a4debfc2cb
--- /dev/null
+++ b/testsuite/tests/safeHaskell/check/Check06.hs
@@ -0,0 +1,13 @@
+{-# LANGUAGE Trustworthy, NoImplicitPrelude #-}
+{-# OPTIONS_GHC -fpackage-trust #-}
+
+-- make sure importing a safe-infered module brings in the
+-- pkg trust requirements correctly.
+module Check06 ( main' ) where
+
+import safe Check06_A
+
+main' =
+ let n = mainM 1
+ in n
+
diff --git a/testsuite/tests/safeHaskell/check/Check06.stderr b/testsuite/tests/safeHaskell/check/Check06.stderr
new file mode 100644
index 0000000000..07a49374d0
--- /dev/null
+++ b/testsuite/tests/safeHaskell/check/Check06.stderr
@@ -0,0 +1,5 @@
+[1 of 2] Compiling Check06_A ( Check06_A.hs, Check06_A.o )
+[2 of 2] Compiling Check06 ( Check06.hs, Check06.o )
+
+<no location info>:
+ The package (base) is required to be trusted but it isn't!
diff --git a/testsuite/tests/safeHaskell/check/Check06_A.hs b/testsuite/tests/safeHaskell/check/Check06_A.hs
new file mode 100644
index 0000000000..9c9d92ba24
--- /dev/null
+++ b/testsuite/tests/safeHaskell/check/Check06_A.hs
@@ -0,0 +1,6 @@
+-- safe infered, with requirement base is trusted
+module Check06_A where
+
+mainM :: Int -> Int
+mainM n = n + 1
+
diff --git a/testsuite/tests/safeHaskell/check/Check07.hs b/testsuite/tests/safeHaskell/check/Check07.hs
new file mode 100644
index 0000000000..aa10c37891
--- /dev/null
+++ b/testsuite/tests/safeHaskell/check/Check07.hs
@@ -0,0 +1,14 @@
+{-# LANGUAGE Trustworthy, NoImplicitPrelude #-}
+{-# OPTIONS_GHC -fpackage-trust #-}
+
+-- make sure selective safe imports brings in pkg trust requirements correctly.
+-- (e.g only for the imports that are safe ones)
+module Check07 ( main' ) where
+
+import safe Check07_A -- no pkg trust reqs
+import Check07_B -- base pkg trust req
+
+main' =
+ let n = a (b 1)
+ in n
+
diff --git a/testsuite/tests/safeHaskell/check/Check07.stderr b/testsuite/tests/safeHaskell/check/Check07.stderr
new file mode 100644
index 0000000000..dafdad6cba
--- /dev/null
+++ b/testsuite/tests/safeHaskell/check/Check07.stderr
@@ -0,0 +1,3 @@
+[1 of 3] Compiling Check07_B ( Check07_B.hs, Check07_B.o )
+[2 of 3] Compiling Check07_A ( Check07_A.hs, Check07_A.o )
+[3 of 3] Compiling Check07 ( Check07.hs, Check07.o )
diff --git a/testsuite/tests/safeHaskell/check/Check07_A.hs b/testsuite/tests/safeHaskell/check/Check07_A.hs
new file mode 100644
index 0000000000..5b38c6a07b
--- /dev/null
+++ b/testsuite/tests/safeHaskell/check/Check07_A.hs
@@ -0,0 +1,8 @@
+{-# LANGUAGE NoImplicitPrelude #-}
+
+-- safe infered, with no pkg trust reqs
+module Check07_A where
+
+a :: a -> a
+a n = n
+
diff --git a/testsuite/tests/safeHaskell/check/Check07_B.hs b/testsuite/tests/safeHaskell/check/Check07_B.hs
new file mode 100644
index 0000000000..4a2003f9a9
--- /dev/null
+++ b/testsuite/tests/safeHaskell/check/Check07_B.hs
@@ -0,0 +1,8 @@
+-- safe infered, with requirement base is trusted
+module Check07_B where
+
+import Prelude
+
+b :: Int -> Int
+b n = n + 1
+
diff --git a/testsuite/tests/safeHaskell/check/Check08.hs b/testsuite/tests/safeHaskell/check/Check08.hs
new file mode 100644
index 0000000000..dde6908f30
--- /dev/null
+++ b/testsuite/tests/safeHaskell/check/Check08.hs
@@ -0,0 +1,14 @@
+{-# LANGUAGE Trustworthy, NoImplicitPrelude #-}
+{-# OPTIONS_GHC -fpackage-trust #-}
+
+-- make sure selective safe imports brings in pkg trust requirements correctly.
+-- (e.g only for the imports that are safe ones)
+module Check08 ( main' ) where
+
+import safe Check08_A -- no pkg trust reqs
+import safe Check08_B -- base pkg trust req
+
+main' =
+ let n = a (b 1)
+ in n
+
diff --git a/testsuite/tests/safeHaskell/check/Check08.stderr b/testsuite/tests/safeHaskell/check/Check08.stderr
new file mode 100644
index 0000000000..7a27852b55
--- /dev/null
+++ b/testsuite/tests/safeHaskell/check/Check08.stderr
@@ -0,0 +1,6 @@
+[1 of 3] Compiling Check08_B ( Check08_B.hs, Check08_B.o )
+[2 of 3] Compiling Check08_A ( Check08_A.hs, Check08_A.o )
+[3 of 3] Compiling Check08 ( Check08.hs, Check08.o )
+
+<no location info>:
+ The package (base) is required to be trusted but it isn't!
diff --git a/testsuite/tests/safeHaskell/check/Check08_A.hs b/testsuite/tests/safeHaskell/check/Check08_A.hs
new file mode 100644
index 0000000000..c888a59b71
--- /dev/null
+++ b/testsuite/tests/safeHaskell/check/Check08_A.hs
@@ -0,0 +1,8 @@
+{-# LANGUAGE NoImplicitPrelude #-}
+
+-- safe infered, with no pkg trust reqs
+module Check08_A where
+
+a :: a -> a
+a n = n
+
diff --git a/testsuite/tests/safeHaskell/check/Check08_B.hs b/testsuite/tests/safeHaskell/check/Check08_B.hs
new file mode 100644
index 0000000000..41feab5eae
--- /dev/null
+++ b/testsuite/tests/safeHaskell/check/Check08_B.hs
@@ -0,0 +1,8 @@
+-- safe infered, with requirement base is trusted
+module Check08_B where
+
+import Prelude
+
+b :: Int -> Int
+b n = n + 1
+
diff --git a/testsuite/tests/safeHaskell/check/all.T b/testsuite/tests/safeHaskell/check/all.T
index d8b2f379fa..41d8edf1a8 100644
--- a/testsuite/tests/safeHaskell/check/all.T
+++ b/testsuite/tests/safeHaskell/check/all.T
@@ -42,3 +42,18 @@ test('Check04', normal, multi_compile, ['Check04', [
# Check -fpackage-trust with no safe haskell flag is an error
test('Check05', normal, compile, [''])
+# Check safe-infered modules have correct pkg trust requirements
+test('Check06',
+ extra_clean(['Check06_A.hi', 'Check06_A.o']),
+ multimod_compile_fail, ['Check06', ''])
+
+# Check selective safe imports bring in correct pkg trust requirements
+test('Check07',
+ extra_clean(['Check07_A.hi', 'Check07_A.o', 'Check07_B.hi', 'Check07_B.o']),
+ multimod_compile, ['Check07', ''])
+
+# Check selective safe imports bring in correct pkg trust requirements
+test('Check08',
+ extra_clean(['Check08_A.hi', 'Check08_A.o', 'Check08_B.hi', 'Check08_B.o']),
+ multimod_compile_fail, ['Check08', ''])
+
diff --git a/testsuite/tests/safeHaskell/check/pkg01/M_SafePkg5.hs b/testsuite/tests/safeHaskell/check/pkg01/M_SafePkg5.hs
new file mode 100644
index 0000000000..a4b7390352
--- /dev/null
+++ b/testsuite/tests/safeHaskell/check/pkg01/M_SafePkg5.hs
@@ -0,0 +1,14 @@
+-- safe inference
+-- same module as M_SafePkg4 which compiles with -XSafe.
+-- Want to make sure compiles fine and is infered safe and
+-- also picks up corrected pkg trust requirements.
+module M_SafePkg5 where
+
+import qualified M_SafePkg3 as M3
+import Data.Word
+
+bigInt :: Int
+bigInt = M3.bigInt
+
+type MyWord = Word
+
diff --git a/testsuite/tests/safeHaskell/check/pkg01/Makefile b/testsuite/tests/safeHaskell/check/pkg01/Makefile
index 1c34906a03..3f3dea6cea 100644
--- a/testsuite/tests/safeHaskell/check/pkg01/Makefile
+++ b/testsuite/tests/safeHaskell/check/pkg01/Makefile
@@ -44,6 +44,9 @@ safePkg01:
echo 'M_SafePkg4'
'$(TEST_HC)' --show-iface dist/build/M_SafePkg4.hi | grep -E '^package dependencies:|^trusted:|^require own pkg trusted:'
echo
+ echo 'M_SafePkg5'
+ '$(TEST_HC)' --show-iface dist/build/M_SafePkg5.hi | grep -E '^package dependencies:|^trusted:|^require own pkg trusted:'
+ echo
echo 'Testing setting trust'
$(LGHC_PKG) trust safePkg01-1.0
$(LGHC_PKG) field safePkg01-1.0 trusted
diff --git a/testsuite/tests/safeHaskell/check/pkg01/p.cabal b/testsuite/tests/safeHaskell/check/pkg01/p.cabal
index f6d84b5f8a..7ddffff027 100644
--- a/testsuite/tests/safeHaskell/check/pkg01/p.cabal
+++ b/testsuite/tests/safeHaskell/check/pkg01/p.cabal
@@ -11,5 +11,6 @@ Library {
M_SafePkg2
M_SafePkg3
M_SafePkg4
+ M_SafePkg5
}
diff --git a/testsuite/tests/safeHaskell/check/pkg01/safePkg01.stdout b/testsuite/tests/safeHaskell/check/pkg01/safePkg01.stdout
index 9a98bacd8c..83906042d8 100644
--- a/testsuite/tests/safeHaskell/check/pkg01/safePkg01.stdout
+++ b/testsuite/tests/safeHaskell/check/pkg01/safePkg01.stdout
@@ -23,6 +23,11 @@ package dependencies: base* ghc-prim integer-gmp
trusted: safe
require own pkg trusted: True
+M_SafePkg5
+package dependencies: base* ghc-prim integer-gmp
+trusted: safe-infered
+require own pkg trusted: True
+
Testing setting trust
trusted: True
trusted: False