summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorDavid Terei <davidterei@gmail.com>2011-12-20 15:53:57 -0800
committerDavid Terei <davidterei@gmail.com>2011-12-22 21:29:08 -0800
commite08432d8436659e1a95da33f0d526638e3372c81 (patch)
treea4196580088bf942e9aaea33e4d2cd84924686f7 /testsuite
parente5ed689683156146457ee16cce5fe4ec6f197772 (diff)
downloadhaskell-e08432d8436659e1a95da33f0d526638e3372c81.tar.gz
More Safe Haskell tests
Diffstat (limited to 'testsuite')
-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
16 files changed, 131 insertions, 0 deletions
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