summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Terei <davidterei@gmail.com>2011-10-19 12:15:17 -0700
committerDavid Terei <davidterei@gmail.com>2011-10-25 14:47:31 -0700
commited0bb9bef3338d143bf27945123e3fe4cf7d0047 (patch)
tree8a59b3eb5e71031d330adf512c01a4eb0d98d809
parenta4a8a28f57dbcc4fac9cb2a5a6f326af65964366 (diff)
downloadhaskell-ed0bb9bef3338d143bf27945123e3fe4cf7d0047.tar.gz
Modify and add a bunch of new tests for Safe Haskell changes
-rw-r--r--testsuite/tests/safeHaskell/check/Check01.hs3
-rw-r--r--testsuite/tests/safeHaskell/check/Check02.hs2
-rw-r--r--testsuite/tests/safeHaskell/check/Check04.hs2
-rw-r--r--testsuite/tests/safeHaskell/check/Check04_1.hs2
-rw-r--r--testsuite/tests/safeHaskell/check/all.T8
-rw-r--r--testsuite/tests/safeHaskell/flags/SafeFlags03.stderr2
-rw-r--r--testsuite/tests/safeHaskell/flags/SafeFlags05.hs2
-rw-r--r--testsuite/tests/safeHaskell/flags/SafeFlags06.hs2
-rw-r--r--testsuite/tests/safeHaskell/flags/SafeFlags07.hs2
-rw-r--r--testsuite/tests/safeHaskell/flags/SafeFlags12.hs7
-rw-r--r--testsuite/tests/safeHaskell/flags/SafeFlags13.hs8
-rw-r--r--testsuite/tests/safeHaskell/flags/SafeFlags14.hs8
-rw-r--r--testsuite/tests/safeHaskell/flags/SafeFlags15.hs8
-rw-r--r--testsuite/tests/safeHaskell/flags/SafeFlags16.hs8
-rw-r--r--testsuite/tests/safeHaskell/flags/SafeFlags17.hs8
-rw-r--r--testsuite/tests/safeHaskell/flags/SafeFlags18.hs7
-rw-r--r--testsuite/tests/safeHaskell/flags/SafeFlags19.hs9
-rw-r--r--testsuite/tests/safeHaskell/flags/all.T27
-rw-r--r--testsuite/tests/safeHaskell/safeInfered/Makefile3
-rw-r--r--testsuite/tests/safeHaskell/safeInfered/Mixed01.hs8
-rw-r--r--testsuite/tests/safeHaskell/safeInfered/Mixed02.hs10
-rw-r--r--testsuite/tests/safeHaskell/safeInfered/SafeInfered01.hs8
-rw-r--r--testsuite/tests/safeHaskell/safeInfered/SafeInfered01_A.hs6
-rw-r--r--testsuite/tests/safeHaskell/safeInfered/SafeInfered02.hs8
-rw-r--r--testsuite/tests/safeHaskell/safeInfered/SafeInfered02_A.hs10
-rw-r--r--testsuite/tests/safeHaskell/safeInfered/SafeInfered03.hs8
-rw-r--r--testsuite/tests/safeHaskell/safeInfered/SafeInfered03_A.hs6
-rw-r--r--testsuite/tests/safeHaskell/safeInfered/UnsafeInfered01.hs8
-rw-r--r--testsuite/tests/safeHaskell/safeInfered/UnsafeInfered01_A.hs8
-rw-r--r--testsuite/tests/safeHaskell/safeInfered/UnsafeInfered02.hs8
-rw-r--r--testsuite/tests/safeHaskell/safeInfered/UnsafeInfered02_A.hs7
-rw-r--r--testsuite/tests/safeHaskell/safeInfered/UnsafeInfered03.hs8
-rw-r--r--testsuite/tests/safeHaskell/safeInfered/UnsafeInfered03_A.hs7
-rw-r--r--testsuite/tests/safeHaskell/safeInfered/UnsafeInfered04.hs8
-rw-r--r--testsuite/tests/safeHaskell/safeInfered/UnsafeInfered04_A.hs9
-rw-r--r--testsuite/tests/safeHaskell/safeInfered/UnsafeInfered05.hs8
-rw-r--r--testsuite/tests/safeHaskell/safeInfered/UnsafeInfered05_A.hs10
-rw-r--r--testsuite/tests/safeHaskell/safeInfered/UnsafeInfered06.hs5
-rw-r--r--testsuite/tests/safeHaskell/safeInfered/UnsafeInfered06_A.hs6
-rw-r--r--testsuite/tests/safeHaskell/safeInfered/UnsafeInfered07.hs5
-rw-r--r--testsuite/tests/safeHaskell/safeInfered/UnsafeInfered07_A.hs10
-rw-r--r--testsuite/tests/safeHaskell/safeInfered/UnsafeInfered08.hs8
-rw-r--r--testsuite/tests/safeHaskell/safeInfered/UnsafeInfered08_A.hs9
-rw-r--r--testsuite/tests/safeHaskell/safeInfered/UnsafeInfered09.hs8
-rw-r--r--testsuite/tests/safeHaskell/safeInfered/UnsafeInfered09_A.hs8
-rw-r--r--testsuite/tests/safeHaskell/safeInfered/UnsafeInfered09_B.hs6
-rw-r--r--testsuite/tests/safeHaskell/safeInfered/all.T29
-rw-r--r--testsuite/tests/safeHaskell/safeLanguage/SafeLang09_A.hs1
-rw-r--r--testsuite/tests/safeHaskell/safeLanguage/SafeLang09_B.hs1
-rw-r--r--testsuite/tests/safeHaskell/safeLanguage/SafeLang10.hs3
-rw-r--r--testsuite/tests/safeHaskell/safeLanguage/SafeLang12.hs2
-rw-r--r--testsuite/tests/safeHaskell/safeLanguage/SafeLang12_B.hs1
-rw-r--r--testsuite/tests/safeHaskell/safeLanguage/all.T21
-rw-r--r--testsuite/tests/safeHaskell/unsafeLibs/BadImport01.hs1
-rw-r--r--testsuite/tests/safeHaskell/unsafeLibs/BadImport04.hs12
-rw-r--r--testsuite/tests/safeHaskell/unsafeLibs/BadImport05.hs12
-rw-r--r--testsuite/tests/safeHaskell/unsafeLibs/BadImport06.hs12
-rw-r--r--testsuite/tests/safeHaskell/unsafeLibs/BadImport07.hs12
-rw-r--r--testsuite/tests/safeHaskell/unsafeLibs/BadImport08.hs12
-rw-r--r--testsuite/tests/safeHaskell/unsafeLibs/Dep05.hs1
-rw-r--r--testsuite/tests/safeHaskell/unsafeLibs/Dep06.hs1
-rw-r--r--testsuite/tests/safeHaskell/unsafeLibs/Dep07.hs1
-rw-r--r--testsuite/tests/safeHaskell/unsafeLibs/Dep08.hs1
-rw-r--r--testsuite/tests/safeHaskell/unsafeLibs/Dep09.hs1
-rw-r--r--testsuite/tests/safeHaskell/unsafeLibs/Dep10.hs1
-rw-r--r--testsuite/tests/safeHaskell/unsafeLibs/GoodImport01.hs14
-rw-r--r--testsuite/tests/safeHaskell/unsafeLibs/GoodImport02.hs15
-rw-r--r--testsuite/tests/safeHaskell/unsafeLibs/GoodImport03.hs121
-rw-r--r--testsuite/tests/safeHaskell/unsafeLibs/all.T26
69 files changed, 588 insertions, 41 deletions
diff --git a/testsuite/tests/safeHaskell/check/Check01.hs b/testsuite/tests/safeHaskell/check/Check01.hs
index bd018acb50..f11d87db15 100644
--- a/testsuite/tests/safeHaskell/check/Check01.hs
+++ b/testsuite/tests/safeHaskell/check/Check01.hs
@@ -1,4 +1,5 @@
-{-# LANGUAGE SafeImports #-}
+{-# GHC_OPTIONS -fpackage-trust #-}
+{-# LANGUAGE Unsafe #-}
module Check01 ( main' ) where
import safe Check01_B
diff --git a/testsuite/tests/safeHaskell/check/Check02.hs b/testsuite/tests/safeHaskell/check/Check02.hs
index 3f15cb4ba9..50e64b79e8 100644
--- a/testsuite/tests/safeHaskell/check/Check02.hs
+++ b/testsuite/tests/safeHaskell/check/Check02.hs
@@ -1,4 +1,4 @@
-{-# LANGUAGE SafeImports #-}
+{-# LANGUAGE Unsafe #-}
module Check02 ( main' ) where
import safe Check02_B
diff --git a/testsuite/tests/safeHaskell/check/Check04.hs b/testsuite/tests/safeHaskell/check/Check04.hs
index 9891de36ee..2f6e94b3d5 100644
--- a/testsuite/tests/safeHaskell/check/Check04.hs
+++ b/testsuite/tests/safeHaskell/check/Check04.hs
@@ -1,4 +1,4 @@
-{-# LANGUAGE SafeImports #-}
+{-# LANGUAGE Unsafe #-}
module Main ( main ) where
import Check04_1
diff --git a/testsuite/tests/safeHaskell/check/Check04_1.hs b/testsuite/tests/safeHaskell/check/Check04_1.hs
index e823c889d6..106540ae29 100644
--- a/testsuite/tests/safeHaskell/check/Check04_1.hs
+++ b/testsuite/tests/safeHaskell/check/Check04_1.hs
@@ -1,4 +1,4 @@
-{-# LANGUAGE SafeImports #-}
+{-# LANGUAGE Unsafe #-}
module Check04_1 ( main' ) where
import safe Check04_B
diff --git a/testsuite/tests/safeHaskell/check/all.T b/testsuite/tests/safeHaskell/check/all.T
index 9e7868de48..d665c655c4 100644
--- a/testsuite/tests/safeHaskell/check/all.T
+++ b/testsuite/tests/safeHaskell/check/all.T
@@ -16,20 +16,20 @@ test('CheckB',
test('Check01', normal, multi_compile_fail, ['Check01 -distrust base', [
('Check01_A.hs', ''),
('Check01_B.hs', '-trust base')
- ], ''])
+ ], '-fpackage-trust'])
# suceed this time since we trust base when we compile AND use CheckB
test('Check02', normal, multi_compile, ['Check02', [
('Check02_A.hs', ''),
('Check02_B.hs', '')
- ], '-trust base'])
+ ], '-trust base -fpackage-trust'])
# suceed as while like Check01_fail we don't import CheckB as a safe
# import this time, so don't require base trusted when used.
test('Check03', normal, multi_compile, ['Check03', [
('Check03_A.hs', ''),
('Check03_B.hs', '-trust base')
- ], ''])
+ ], '-fpackage-trust'])
# Check a slightly larger transitive program. Check01 isn't imported
# safely by Check03 so we don't require base trused at end.
@@ -37,5 +37,5 @@ test('Check04', normal, multi_compile, ['Check04', [
('Check04_A.hs', ''),
('Check04_B.hs', '-trust base'),
('Check04_1.hs', '-trust base')
- ], ''])
+ ], '-fpackage-trust'])
diff --git a/testsuite/tests/safeHaskell/flags/SafeFlags03.stderr b/testsuite/tests/safeHaskell/flags/SafeFlags03.stderr
new file mode 100644
index 0000000000..7e38ffded2
--- /dev/null
+++ b/testsuite/tests/safeHaskell/flags/SafeFlags03.stderr
@@ -0,0 +1,2 @@
+
+SafeFlags04.hs:1:14: Unsupported extension: SafeImport
diff --git a/testsuite/tests/safeHaskell/flags/SafeFlags05.hs b/testsuite/tests/safeHaskell/flags/SafeFlags05.hs
index 0f316d475b..1f27a2fa53 100644
--- a/testsuite/tests/safeHaskell/flags/SafeFlags05.hs
+++ b/testsuite/tests/safeHaskell/flags/SafeFlags05.hs
@@ -1,4 +1,4 @@
-{-# LANGUAGE Safe, SafeImports #-}
+{-# LANGUAGE Safe, Unsafe #-}
-- | Basic test to see if Safe flags compiles
module SafeFlags05 where
diff --git a/testsuite/tests/safeHaskell/flags/SafeFlags06.hs b/testsuite/tests/safeHaskell/flags/SafeFlags06.hs
index 81fd3257ae..50c2f4b620 100644
--- a/testsuite/tests/safeHaskell/flags/SafeFlags06.hs
+++ b/testsuite/tests/safeHaskell/flags/SafeFlags06.hs
@@ -1,4 +1,4 @@
-{-# LANGUAGE Trustworthy, SafeImports #-}
+{-# LANGUAGE Trustworthy, Unsafe #-}
-- | Basic test to see if Safe flags compiles
module SafeFlags06 where
diff --git a/testsuite/tests/safeHaskell/flags/SafeFlags07.hs b/testsuite/tests/safeHaskell/flags/SafeFlags07.hs
index 0339fe362f..348966f270 100644
--- a/testsuite/tests/safeHaskell/flags/SafeFlags07.hs
+++ b/testsuite/tests/safeHaskell/flags/SafeFlags07.hs
@@ -1,4 +1,4 @@
-{-# LANGUAGE SafeLanguage, SafeImports #-}
+{-# LANGUAGE SafeLanguage, Unsafe #-}
-- | Basic test to see if Safe flags compiles
module SafeFlags07 where
diff --git a/testsuite/tests/safeHaskell/flags/SafeFlags12.hs b/testsuite/tests/safeHaskell/flags/SafeFlags12.hs
new file mode 100644
index 0000000000..37ddddbc77
--- /dev/null
+++ b/testsuite/tests/safeHaskell/flags/SafeFlags12.hs
@@ -0,0 +1,7 @@
+{-# LANGUAGE Unsafe #-}
+-- | Basic test to see if Safe flags compiles
+module SafeFlags12 where
+
+f :: Int
+f = 1
+
diff --git a/testsuite/tests/safeHaskell/flags/SafeFlags13.hs b/testsuite/tests/safeHaskell/flags/SafeFlags13.hs
new file mode 100644
index 0000000000..ab3b63df93
--- /dev/null
+++ b/testsuite/tests/safeHaskell/flags/SafeFlags13.hs
@@ -0,0 +1,8 @@
+{-# LANGUAGE Trustworthy #-}
+{-# LANGUAGE Unsafe #-}
+-- | Basic test to see if Safe flags compiles
+module SafeFlags13 where
+
+f :: Int
+f = 1
+
diff --git a/testsuite/tests/safeHaskell/flags/SafeFlags14.hs b/testsuite/tests/safeHaskell/flags/SafeFlags14.hs
new file mode 100644
index 0000000000..c5be74477b
--- /dev/null
+++ b/testsuite/tests/safeHaskell/flags/SafeFlags14.hs
@@ -0,0 +1,8 @@
+{-# LANGUAGE Safe #-}
+{-# LANGUAGE Unsafe #-}
+-- | Basic test to see if Safe flags compiles
+module SafeFlags14 where
+
+f :: Int
+f = 1
+
diff --git a/testsuite/tests/safeHaskell/flags/SafeFlags15.hs b/testsuite/tests/safeHaskell/flags/SafeFlags15.hs
new file mode 100644
index 0000000000..3e3bbfd774
--- /dev/null
+++ b/testsuite/tests/safeHaskell/flags/SafeFlags15.hs
@@ -0,0 +1,8 @@
+{-# LANGUAGE Unsafe #-}
+{-# OPTIONS_GHC -fpackage-trust #-}
+-- | Basic test to see if Safe flags compiles
+module SafeFlags15 where
+
+f :: Int
+f = 1
+
diff --git a/testsuite/tests/safeHaskell/flags/SafeFlags16.hs b/testsuite/tests/safeHaskell/flags/SafeFlags16.hs
new file mode 100644
index 0000000000..6259edc313
--- /dev/null
+++ b/testsuite/tests/safeHaskell/flags/SafeFlags16.hs
@@ -0,0 +1,8 @@
+{-# LANGUAGE Trustworthy #-}
+{-# OPTIONS_GHC -fpackage-trust #-}
+-- | Basic test to see if Safe flags compiles
+module SafeFlags15 where
+
+f :: Int
+f = 1
+
diff --git a/testsuite/tests/safeHaskell/flags/SafeFlags17.hs b/testsuite/tests/safeHaskell/flags/SafeFlags17.hs
new file mode 100644
index 0000000000..3f4651b2f4
--- /dev/null
+++ b/testsuite/tests/safeHaskell/flags/SafeFlags17.hs
@@ -0,0 +1,8 @@
+{-# LANGUAGE Safe #-}
+{-# OPTIONS_GHC -fpackage-trust #-}
+-- | Basic test to see if Safe flags compiles
+module SafeFlags15 where
+
+f :: Int
+f = 1
+
diff --git a/testsuite/tests/safeHaskell/flags/SafeFlags18.hs b/testsuite/tests/safeHaskell/flags/SafeFlags18.hs
new file mode 100644
index 0000000000..f8286918f9
--- /dev/null
+++ b/testsuite/tests/safeHaskell/flags/SafeFlags18.hs
@@ -0,0 +1,7 @@
+{-# OPTIONS_GHC -fpackage-trust #-}
+-- | Basic test to see if Safe flags compiles
+module SafeFlags15 where
+
+f :: Int
+f = 1
+
diff --git a/testsuite/tests/safeHaskell/flags/SafeFlags19.hs b/testsuite/tests/safeHaskell/flags/SafeFlags19.hs
new file mode 100644
index 0000000000..957a906846
--- /dev/null
+++ b/testsuite/tests/safeHaskell/flags/SafeFlags19.hs
@@ -0,0 +1,9 @@
+{-# OPTIONS_GHC -fno-package-trust #-}
+-- | Basic test to see if Safe flags compiles
+-- test should fail as there shouldn't be a no-package-trust flag, only a
+-- package-trust flag!
+module SafeFlags15 where
+
+f :: Int
+f = 1
+
diff --git a/testsuite/tests/safeHaskell/flags/all.T b/testsuite/tests/safeHaskell/flags/all.T
index 85b4443752..66d07b9c07 100644
--- a/testsuite/tests/safeHaskell/flags/all.T
+++ b/testsuite/tests/safeHaskell/flags/all.T
@@ -9,25 +9,36 @@ def f( opts ):
setTestOpts(f)
-test('SafeFlags01', normal, compile, ['-trust base'])
+test('SafeFlags01', normal, compile, [''])
test('SafeFlags02', normal, compile, [''])
-test('SafeFlags03', normal, compile, [''])
+# no longer support a SafeImport flag, so expect fail for them.
+test('SafeFlags03', normal, compile_fail, [''])
# no longer support a SafeLanguage flag, so expect fail for them.
-test('SafeFlags04', normal, compile_fail, ['-trust base'])
+test('SafeFlags04', normal, compile_fail, [''])
-test('SafeFlags05', normal, compile, ['-trust base'])
-test('SafeFlags06', normal, compile, [''])
+test('SafeFlags05', normal, compile_fail, [''])
+test('SafeFlags06', normal, compile_fail, [''])
# no longer support a SafeLanguage flag, so expect fail for them.
-test('SafeFlags07', normal, compile_fail, ['-trust base'])
+test('SafeFlags07', normal, compile_fail, [''])
# no longer support a SafeLanguage flag, so expect fail for them.
-test('SafeFlags08', normal, compile_fail, ['-trust base'])
+test('SafeFlags08', normal, compile_fail, [''])
test('SafeFlags09', normal, compile_fail, [''])
test('SafeFlags10', normal, compile_fail, [''])
-test('SafeFlags11', normal, compile, ['-trust base'])
+test('SafeFlags11', normal, compile, [''])
+
+test('SafeFlags12', normal, compile, [''])
+test('SafeFlags13', normal, compile_fail, [''])
+test('SafeFlags14', normal, compile_fail, [''])
+
+test('SafeFlags15', normal, compile, [''])
+test('SafeFlags16', normal, compile, [''])
+test('SafeFlags17', normal, compile, [''])
+test('SafeFlags18', normal, compile, [''])
+test('SafeFlags19', normal, compile_fail, [''])
test('Flags01', normal, compile, [''])
test('Flags02', normal, compile, [''])
diff --git a/testsuite/tests/safeHaskell/safeInfered/Makefile b/testsuite/tests/safeHaskell/safeInfered/Makefile
new file mode 100644
index 0000000000..9101fbd40a
--- /dev/null
+++ b/testsuite/tests/safeHaskell/safeInfered/Makefile
@@ -0,0 +1,3 @@
+TOP=../../..
+include $(TOP)/mk/boilerplate.mk
+include $(TOP)/mk/test.mk
diff --git a/testsuite/tests/safeHaskell/safeInfered/Mixed01.hs b/testsuite/tests/safeHaskell/safeInfered/Mixed01.hs
new file mode 100644
index 0000000000..cb895fe634
--- /dev/null
+++ b/testsuite/tests/safeHaskell/safeInfered/Mixed01.hs
@@ -0,0 +1,8 @@
+-- | Should fail compilation because safe imports aren't enabled
+module Mixed01 where
+
+import safe Data.Word
+
+f :: Int
+f = 1
+
diff --git a/testsuite/tests/safeHaskell/safeInfered/Mixed02.hs b/testsuite/tests/safeHaskell/safeInfered/Mixed02.hs
new file mode 100644
index 0000000000..062c2db64d
--- /dev/null
+++ b/testsuite/tests/safeHaskell/safeInfered/Mixed02.hs
@@ -0,0 +1,10 @@
+{-# LANGUAGE Unsafe #-}
+-- | Should fail compilation because we import Data.Word as safe and unsafe
+module Mixed02 where
+
+import safe qualified Data.Word as DW
+import Data.Word
+
+f :: Int
+f = 1
+
diff --git a/testsuite/tests/safeHaskell/safeInfered/SafeInfered01.hs b/testsuite/tests/safeHaskell/safeInfered/SafeInfered01.hs
new file mode 100644
index 0000000000..1562a18592
--- /dev/null
+++ b/testsuite/tests/safeHaskell/safeInfered/SafeInfered01.hs
@@ -0,0 +1,8 @@
+{-# LANGUAGE Safe #-}
+module SafeInfered01 where
+
+import safe SafeInfered01_A.hs
+
+g :: Int
+g = f
+
diff --git a/testsuite/tests/safeHaskell/safeInfered/SafeInfered01_A.hs b/testsuite/tests/safeHaskell/safeInfered/SafeInfered01_A.hs
new file mode 100644
index 0000000000..f66ac43d78
--- /dev/null
+++ b/testsuite/tests/safeHaskell/safeInfered/SafeInfered01_A.hs
@@ -0,0 +1,6 @@
+-- | Trivial Safe Module
+module SafeInfered01_A where
+
+f :: Int
+f = 1
+
diff --git a/testsuite/tests/safeHaskell/safeInfered/SafeInfered02.hs b/testsuite/tests/safeHaskell/safeInfered/SafeInfered02.hs
new file mode 100644
index 0000000000..6656c5acf7
--- /dev/null
+++ b/testsuite/tests/safeHaskell/safeInfered/SafeInfered02.hs
@@ -0,0 +1,8 @@
+{-# LANGUAGE Safe #-}
+module SafeInfered02 where
+
+import safe SafeInfered02_A
+
+g :: Int
+g = f
+
diff --git a/testsuite/tests/safeHaskell/safeInfered/SafeInfered02_A.hs b/testsuite/tests/safeHaskell/safeInfered/SafeInfered02_A.hs
new file mode 100644
index 0000000000..fff3286de5
--- /dev/null
+++ b/testsuite/tests/safeHaskell/safeInfered/SafeInfered02_A.hs
@@ -0,0 +1,10 @@
+-- | Only uses deriving of Typeable so should be considered safe
+module SafeInfered02_A where
+
+import Data.Typeable
+
+data G = G Int deriving (Typeable)
+
+f :: Int
+f = 1
+
diff --git a/testsuite/tests/safeHaskell/safeInfered/SafeInfered03.hs b/testsuite/tests/safeHaskell/safeInfered/SafeInfered03.hs
new file mode 100644
index 0000000000..9c7af12231
--- /dev/null
+++ b/testsuite/tests/safeHaskell/safeInfered/SafeInfered03.hs
@@ -0,0 +1,8 @@
+{-# LANGUAGE Safe #-}
+module SafeInfered03 where
+
+import safe SafeInfered03_A
+
+g :: Int
+g = 1
+
diff --git a/testsuite/tests/safeHaskell/safeInfered/SafeInfered03_A.hs b/testsuite/tests/safeHaskell/safeInfered/SafeInfered03_A.hs
new file mode 100644
index 0000000000..01c2839cfc
--- /dev/null
+++ b/testsuite/tests/safeHaskell/safeInfered/SafeInfered03_A.hs
@@ -0,0 +1,6 @@
+{-# LANGUAGE ForeignFunctionInterface #-}
+-- | FFI but in IO monad so safe
+module SafeInfered03_A where
+
+foreign import ccall "math.h" sin :: CDouble -> IO CDouble
+
diff --git a/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered01.hs b/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered01.hs
new file mode 100644
index 0000000000..b1db9ea578
--- /dev/null
+++ b/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered01.hs
@@ -0,0 +1,8 @@
+{-# LANGUAGE Safe #-}
+module UnsafeInfered01 where
+
+import safe UnsafeInfered01_A
+
+g :: IO a -> a
+g = f
+
diff --git a/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered01_A.hs b/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered01_A.hs
new file mode 100644
index 0000000000..0fe65b9536
--- /dev/null
+++ b/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered01_A.hs
@@ -0,0 +1,8 @@
+-- | Trivial Unsafe Module
+module UnsafeInfered01_A where
+
+import System.IO.Unsafe
+
+f :: IO a -> a
+f = unsafePerformIO
+
diff --git a/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered02.hs b/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered02.hs
new file mode 100644
index 0000000000..67105965d8
--- /dev/null
+++ b/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered02.hs
@@ -0,0 +1,8 @@
+{-# LANGUAGE Safe #-}
+module UnsafeInfered02 where
+
+import safe UnsafeInfered02_A
+
+g :: Int
+g = f
+
diff --git a/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered02_A.hs b/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered02_A.hs
new file mode 100644
index 0000000000..5a9a0db7f0
--- /dev/null
+++ b/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered02_A.hs
@@ -0,0 +1,7 @@
+{-# LANGUAGE TemplateHaskell #-}
+-- | Unsafe as uses TH
+module UnsafeInfered02_A where
+
+f :: Int
+f = 1
+
diff --git a/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered03.hs b/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered03.hs
new file mode 100644
index 0000000000..67220ac4d0
--- /dev/null
+++ b/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered03.hs
@@ -0,0 +1,8 @@
+{-# LANGUAGE Safe #-}
+module UnsafeInfered03 where
+
+import safe UnsafeInfered03_A
+
+g :: Int
+g = f
+
diff --git a/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered03_A.hs b/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered03_A.hs
new file mode 100644
index 0000000000..ea3202ed5d
--- /dev/null
+++ b/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered03_A.hs
@@ -0,0 +1,7 @@
+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
+-- | Unsafe as uses GND
+module UnsafeInfered03_A where
+
+f :: Int
+f = 1
+
diff --git a/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered04.hs b/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered04.hs
new file mode 100644
index 0000000000..85b7121bc3
--- /dev/null
+++ b/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered04.hs
@@ -0,0 +1,8 @@
+{-# LANGUAGE Safe #-}
+module UnsafeInfered04 where
+
+import safe UnsafeInfered04_A
+
+g :: Int
+g = f
+
diff --git a/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered04_A.hs b/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered04_A.hs
new file mode 100644
index 0000000000..244c3be1be
--- /dev/null
+++ b/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered04_A.hs
@@ -0,0 +1,9 @@
+{-# LANGUAGE RULES #-}
+-- | Unsafe as uses RULES
+-- Although only turns on the flag doesn't define? So mark safe
+-- maybe?
+module UnsafeInfered04_A where
+
+f :: Int
+f = 1
+
diff --git a/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered05.hs b/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered05.hs
new file mode 100644
index 0000000000..712d02a350
--- /dev/null
+++ b/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered05.hs
@@ -0,0 +1,8 @@
+{-# LANGUAGE Safe #-}
+module UnsafeInfered05 where
+
+import safe UnsafeInfered05_A
+
+g :: Int
+g = f
+
diff --git a/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered05_A.hs b/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered05_A.hs
new file mode 100644
index 0000000000..4d147716f5
--- /dev/null
+++ b/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered05_A.hs
@@ -0,0 +1,10 @@
+{-# OPTIONS_GHC -fenable-rewrite-rules #-}
+-- | Unsafe as uses RULES
+-- Although only turns on the flag doesn't define? So mark safe
+-- maybe?
+module UnsafeInfered05_A where
+
+{-# RULES "f" f = undefined #-}
+f :: Int
+f = 1
+
diff --git a/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered06.hs b/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered06.hs
new file mode 100644
index 0000000000..a5bb127202
--- /dev/null
+++ b/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered06.hs
@@ -0,0 +1,5 @@
+{-# LANGUAGE Safe #-}
+module UnsafeInfered06 where
+
+import safe UnsafeInfered06_A
+
diff --git a/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered06_A.hs b/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered06_A.hs
new file mode 100644
index 0000000000..f865193a69
--- /dev/null
+++ b/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered06_A.hs
@@ -0,0 +1,6 @@
+{-# LANGUAGE ForeignFunctionInterface #-}
+-- | Unsafe as uses FFI with a pure function
+module UnsafeInfered06_A where
+
+foreign import ccall "math.h" sin :: CDouble -> CDouble
+
diff --git a/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered07.hs b/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered07.hs
new file mode 100644
index 0000000000..dd6a830239
--- /dev/null
+++ b/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered07.hs
@@ -0,0 +1,5 @@
+{-# LANGUAGE Safe #-}
+module UnsafeInfered07 where
+
+import safe UnsafeInfered07_A
+
diff --git a/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered07_A.hs b/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered07_A.hs
new file mode 100644
index 0000000000..98e9249876
--- /dev/null
+++ b/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered07_A.hs
@@ -0,0 +1,10 @@
+-- | Unsafe as hand crafts a typeable instance
+module UnsafeInfered07_A where
+
+import Data.Typeable
+
+data G = G Int
+
+instance Typeable G where
+ typeof _ = typeof (undefined::Int)
+
diff --git a/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered08.hs b/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered08.hs
new file mode 100644
index 0000000000..394d7e6999
--- /dev/null
+++ b/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered08.hs
@@ -0,0 +1,8 @@
+{-# LANGUAGE Safe #-}
+module UnsafeInfered08 where
+
+import safe UnsafeInfered08_A
+
+f :: Int
+f = g
+
diff --git a/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered08_A.hs b/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered08_A.hs
new file mode 100644
index 0000000000..13f22ce3d7
--- /dev/null
+++ b/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered08_A.hs
@@ -0,0 +1,9 @@
+{-# LANGUAGE OverlappingInstances #-}
+-- | Unsafe as uses overlapping instances
+-- Although it isn't defining any so can we mark safe
+-- still?
+module UnsafeInfered08_A where
+
+g :: Int
+g = 1
+
diff --git a/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered09.hs b/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered09.hs
new file mode 100644
index 0000000000..1c1e61d3c5
--- /dev/null
+++ b/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered09.hs
@@ -0,0 +1,8 @@
+{-# LANGUAGE Safe #-}
+module UnsafeInfered09 where
+
+import safe UnsafeInfered09_A
+
+h :: Int
+h = g
+
diff --git a/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered09_A.hs b/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered09_A.hs
new file mode 100644
index 0000000000..d2e0893f75
--- /dev/null
+++ b/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered09_A.hs
@@ -0,0 +1,8 @@
+-- | Unsafe as we explicitly marked UnsafeInfered09_B as unsafe
+module UnsafeInfered09_A where
+
+import UnsafeInfered09_B
+
+g :: Int
+g = f
+
diff --git a/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered09_B.hs b/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered09_B.hs
new file mode 100644
index 0000000000..8ba8720b03
--- /dev/null
+++ b/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered09_B.hs
@@ -0,0 +1,6 @@
+{-# LANGUAGE Unsafe #-}
+module UnsafeInfered09_B where
+
+f :: Int
+f = 1
+
diff --git a/testsuite/tests/safeHaskell/safeInfered/all.T b/testsuite/tests/safeHaskell/safeInfered/all.T
new file mode 100644
index 0000000000..19a788b792
--- /dev/null
+++ b/testsuite/tests/safeHaskell/safeInfered/all.T
@@ -0,0 +1,29 @@
+# safeInfered tests are for testing that the Safe Haskell
+# mode safe inference works correctly.
+
+# Just do the normal way, SafeHaskell is all in the frontend
+def f( opts ):
+ opts.only_ways = ['normal']
+
+setTestOpts(f)
+
+# Tests that should compile fine as they should be infered safe
+test('SafeInfered01', normal, multimod_compile, ['SafeInfered01', ''])
+test('SafeInfered02', normal, multimod_compile, ['SafeInfered02', ''])
+test('SafeInfered03', normal, multimod_compile, ['SafeInfered03', ''])
+
+# Tests that should fail to compile as they should be infered unsafe
+test('UnsafeInfered01', normal, multimod_compile_fail, ['UnsafeInfered01', ''])
+test('UnsafeInfered02', normal, multimod_compile_fail, ['UnsafeInfered02', ''])
+test('UnsafeInfered03', normal, multimod_compile_fail, ['UnsafeInfered03', ''])
+test('UnsafeInfered04', normal, multimod_compile_fail, ['UnsafeInfered04', ''])
+test('UnsafeInfered05', normal, multimod_compile_fail, ['UnsafeInfered05', ''])
+test('UnsafeInfered06', normal, multimod_compile_fail, ['UnsafeInfered06', ''])
+test('UnsafeInfered07', normal, multimod_compile_fail, ['UnsafeInfered07', ''])
+test('UnsafeInfered08', normal, multimod_compile_fail, ['UnsafeInfered08', ''])
+test('UnsafeInfered09', normal, multimod_compile_fail, ['UnsafeInfered09', ''])
+
+# Mixed tests
+test('Mixed01', normal, compile_fail, [''])
+test('Mixed02', normal, compile_fail, [''])
+
diff --git a/testsuite/tests/safeHaskell/safeLanguage/SafeLang09_A.hs b/testsuite/tests/safeHaskell/safeLanguage/SafeLang09_A.hs
index 129c2c4b56..ff89183f93 100644
--- a/testsuite/tests/safeHaskell/safeLanguage/SafeLang09_A.hs
+++ b/testsuite/tests/safeHaskell/safeLanguage/SafeLang09_A.hs
@@ -12,4 +12,3 @@ class Pos a where
instance Pos [a] where
res _ = True
-
diff --git a/testsuite/tests/safeHaskell/safeLanguage/SafeLang09_B.hs b/testsuite/tests/safeHaskell/safeLanguage/SafeLang09_B.hs
index 76e0fe5a1c..d03a6296ca 100644
--- a/testsuite/tests/safeHaskell/safeLanguage/SafeLang09_B.hs
+++ b/testsuite/tests/safeHaskell/safeLanguage/SafeLang09_B.hs
@@ -16,4 +16,3 @@ instance Pos [Int] where
function :: Int
function = 3
-
diff --git a/testsuite/tests/safeHaskell/safeLanguage/SafeLang10.hs b/testsuite/tests/safeHaskell/safeLanguage/SafeLang10.hs
index ff5c168cff..5c88d3916d 100644
--- a/testsuite/tests/safeHaskell/safeLanguage/SafeLang10.hs
+++ b/testsuite/tests/safeHaskell/safeLanguage/SafeLang10.hs
@@ -1,4 +1,4 @@
-{-# LANGUAGE SafeImports #-}
+{-# LANGUAGE Trustworthy #-}
module Main where
import safe SafeLang10_A -- trusted lib
@@ -9,4 +9,3 @@ main = do
putStrLn $ "Result: " ++ show r
putStrLn $ "Result: " ++ show function
-
diff --git a/testsuite/tests/safeHaskell/safeLanguage/SafeLang12.hs b/testsuite/tests/safeHaskell/safeLanguage/SafeLang12.hs
index 5f1e51c956..f6fce3b73f 100644
--- a/testsuite/tests/safeHaskell/safeLanguage/SafeLang12.hs
+++ b/testsuite/tests/safeHaskell/safeLanguage/SafeLang12.hs
@@ -1,5 +1,5 @@
-{-# LANGUAGE Safe #-}
{-# LANGUAGE TemplateHaskell #-}
+{-# LANGUAGE Safe #-}
module Main where
import SafeLang12_A
diff --git a/testsuite/tests/safeHaskell/safeLanguage/SafeLang12_B.hs b/testsuite/tests/safeHaskell/safeLanguage/SafeLang12_B.hs
index e8269c129d..1e5b2252cb 100644
--- a/testsuite/tests/safeHaskell/safeLanguage/SafeLang12_B.hs
+++ b/testsuite/tests/safeHaskell/safeLanguage/SafeLang12_B.hs
@@ -15,4 +15,3 @@ mkSimpleClass name = do
return [InstanceD [] (AppT (ConT cname) (ConT dname)) [FunD mname
[Clause [] (NormalB (ConE conname)) []]]]
-
diff --git a/testsuite/tests/safeHaskell/safeLanguage/all.T b/testsuite/tests/safeHaskell/safeLanguage/all.T
index cd31bf570c..75ebad8e90 100644
--- a/testsuite/tests/safeHaskell/safeLanguage/all.T
+++ b/testsuite/tests/safeHaskell/safeLanguage/all.T
@@ -9,11 +9,11 @@ def f( opts ):
setTestOpts(f)
-test('SafeLang01', normal, compile, ['-trust base'])
-test('SafeLang02', normal, compile, ['-trust base'])
-test('SafeLang03', normal, compile, ['-trust base'])
+test('SafeLang01', normal, compile, [''])
+test('SafeLang02', normal, compile, [''])
+test('SafeLang03', normal, compile, [''])
test('SafeLang04', normal, compile_and_run, [''])
-test('SafeLang05', normal, compile_and_run, ['-trust base'])
+test('SafeLang05', normal, compile_and_run, [''])
test('SafeLang06',
extra_clean(['SafeLang06_A.o', 'SafeLang06_A.hi']),
compile_and_run,
@@ -30,25 +30,26 @@ test('SafeLang10',
extra_clean(['SafeLang10_A.o', 'SafeLang10_A.hi',
'SafeLang10_B.o', 'SafeLang10_B.hi']),
multimod_compile_fail,
- ['SafeLang10', '-trust base'])
+ ['SafeLang10', ''])
test('SafeLang11',
[req_interp,
extra_clean(['SafeLang11_A.o', 'SafeLang11_A.hi',
'SafeLang11_B.o', 'SafeLang11_B.hi'])],
multimod_compile_and_run,
- ['SafeLang11', '-trust base'])
-test('SafeLang12', normal, multimod_compile_fail, ['SafeLang12', '-trust base'])
+ ['SafeLang11', ''])
+test('SafeLang12', normal, multimod_compile_fail, ['SafeLang12', ''])
test('SafeLang13',
extra_clean(['SafeLang13_A.o', 'SafeLang13_A.hi']),
multimod_compile_and_run,
- ['SafeLang13', '-trust base'])
+ ['SafeLang13', ''])
test('SafeLang14',
extra_clean(['SafeLang14_A.o', 'SafeLang14_A.hi']),
multimod_compile_fail,
- ['SafeLang14', '-trust base -XSafe'])
+ ['SafeLang14', '-XSafe'])
test('SafeLang15',
[exit_code(1),
extra_clean(['SafeLang15_A.o', 'SafeLang15_A.hi'])],
multimod_compile_and_run,
- ['SafeLang15', '-trust base -XSafe'])
+ ['SafeLang15', '-XSafe'])
test('SafeLang16', normal, compile, [''])
+
diff --git a/testsuite/tests/safeHaskell/unsafeLibs/BadImport01.hs b/testsuite/tests/safeHaskell/unsafeLibs/BadImport01.hs
index ae72dd6cd3..175365c17c 100644
--- a/testsuite/tests/safeHaskell/unsafeLibs/BadImport01.hs
+++ b/testsuite/tests/safeHaskell/unsafeLibs/BadImport01.hs
@@ -1,4 +1,5 @@
{-# LANGUAGE Safe #-}
+-- | Import unsafe module System.IO.Unsafe to make sure it fails
module Main where
import System.IO.Unsafe
diff --git a/testsuite/tests/safeHaskell/unsafeLibs/BadImport04.hs b/testsuite/tests/safeHaskell/unsafeLibs/BadImport04.hs
new file mode 100644
index 0000000000..c22b0362f7
--- /dev/null
+++ b/testsuite/tests/safeHaskell/unsafeLibs/BadImport04.hs
@@ -0,0 +1,12 @@
+{-# LANGUAGE Safe #-}
+-- | Import unsafe module Foreign to make sure it fails
+module Main where
+
+import Foreign (unsafePerformIO)
+
+f :: Int
+f = unsafePerformIO $ putStrLn "What kind of swallow?" >> return 2
+
+main :: IO ()
+main = putStrLn $ "X is: " ++ show f
+
diff --git a/testsuite/tests/safeHaskell/unsafeLibs/BadImport05.hs b/testsuite/tests/safeHaskell/unsafeLibs/BadImport05.hs
new file mode 100644
index 0000000000..137f3b5f31
--- /dev/null
+++ b/testsuite/tests/safeHaskell/unsafeLibs/BadImport05.hs
@@ -0,0 +1,12 @@
+{-# LANGUAGE Safe #-}
+-- | Import unsafe module Foreign.Unsafe to make sure it fails
+module Main where
+
+import Foreign.Unsafe (unsafePerformIO)
+
+f :: Int
+f = unsafePerformIO $ putStrLn "What kind of swallow?" >> return 2
+
+main :: IO ()
+main = putStrLn $ "X is: " ++ show f
+
diff --git a/testsuite/tests/safeHaskell/unsafeLibs/BadImport06.hs b/testsuite/tests/safeHaskell/unsafeLibs/BadImport06.hs
new file mode 100644
index 0000000000..e64a7ea09b
--- /dev/null
+++ b/testsuite/tests/safeHaskell/unsafeLibs/BadImport06.hs
@@ -0,0 +1,12 @@
+{-# LANGUAGE Safe #-}
+-- | Import unsafe module Debug.Trace to make sure it fails
+module Main where
+
+import Debug.Trace
+
+f :: Int
+f = trace "What kind of swallow?" 2
+
+main :: IO ()
+main = putStrLn $ "X is: " ++ show f
+
diff --git a/testsuite/tests/safeHaskell/unsafeLibs/BadImport07.hs b/testsuite/tests/safeHaskell/unsafeLibs/BadImport07.hs
new file mode 100644
index 0000000000..ea2b6402d3
--- /dev/null
+++ b/testsuite/tests/safeHaskell/unsafeLibs/BadImport07.hs
@@ -0,0 +1,12 @@
+{-# LANGUAGE Safe #-}
+-- | Import unsafe module Unsafe.Coerce to make sure it fails
+module Main where
+
+import Unsafe.Coerce
+
+f :: Int
+f = trace "What kind of swallow?" 2
+
+main :: IO ()
+main = putStrLn $ "X is: " ++ show f
+
diff --git a/testsuite/tests/safeHaskell/unsafeLibs/BadImport08.hs b/testsuite/tests/safeHaskell/unsafeLibs/BadImport08.hs
new file mode 100644
index 0000000000..0df948ecd6
--- /dev/null
+++ b/testsuite/tests/safeHaskell/unsafeLibs/BadImport08.hs
@@ -0,0 +1,12 @@
+{-# LANGUAGE Safe #-}
+-- | Import unsafe module Control.ST to make sure it fails
+module Main where
+
+import Control.ST
+
+f :: Int
+f = trace "What kind of swallow?" 2
+
+main :: IO ()
+main = putStrLn $ "X is: " ++ show f
+
diff --git a/testsuite/tests/safeHaskell/unsafeLibs/Dep05.hs b/testsuite/tests/safeHaskell/unsafeLibs/Dep05.hs
index da25c1a52a..a5c13bb5aa 100644
--- a/testsuite/tests/safeHaskell/unsafeLibs/Dep05.hs
+++ b/testsuite/tests/safeHaskell/unsafeLibs/Dep05.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE Safe #-}
{-# LANGUAGE NoMonomorphismRestriction #-}
module Dep05 where
diff --git a/testsuite/tests/safeHaskell/unsafeLibs/Dep06.hs b/testsuite/tests/safeHaskell/unsafeLibs/Dep06.hs
index 0a5811d02b..2dbb15e197 100644
--- a/testsuite/tests/safeHaskell/unsafeLibs/Dep06.hs
+++ b/testsuite/tests/safeHaskell/unsafeLibs/Dep06.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE Safe #-}
module Dep06 where
import GHC.Conc
diff --git a/testsuite/tests/safeHaskell/unsafeLibs/Dep07.hs b/testsuite/tests/safeHaskell/unsafeLibs/Dep07.hs
index 6f0df7af11..662b6a4754 100644
--- a/testsuite/tests/safeHaskell/unsafeLibs/Dep07.hs
+++ b/testsuite/tests/safeHaskell/unsafeLibs/Dep07.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE Safe #-}
module Dep07 where
import GHC.ForeignPtr
diff --git a/testsuite/tests/safeHaskell/unsafeLibs/Dep08.hs b/testsuite/tests/safeHaskell/unsafeLibs/Dep08.hs
index a3fbc7be61..76a0dde570 100644
--- a/testsuite/tests/safeHaskell/unsafeLibs/Dep08.hs
+++ b/testsuite/tests/safeHaskell/unsafeLibs/Dep08.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE Safe #-}
{-# LANGUAGE NoMonomorphismRestriction #-}
module Dep08 where
diff --git a/testsuite/tests/safeHaskell/unsafeLibs/Dep09.hs b/testsuite/tests/safeHaskell/unsafeLibs/Dep09.hs
index beeb7ffe95..a92f739b50 100644
--- a/testsuite/tests/safeHaskell/unsafeLibs/Dep09.hs
+++ b/testsuite/tests/safeHaskell/unsafeLibs/Dep09.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE Safe #-}
module Dep09 where
import GHC.Ptr
diff --git a/testsuite/tests/safeHaskell/unsafeLibs/Dep10.hs b/testsuite/tests/safeHaskell/unsafeLibs/Dep10.hs
index 70d660ed1c..84a7adcff7 100644
--- a/testsuite/tests/safeHaskell/unsafeLibs/Dep10.hs
+++ b/testsuite/tests/safeHaskell/unsafeLibs/Dep10.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE Safe #-}
module Dep10 where
import GHC.ST
diff --git a/testsuite/tests/safeHaskell/unsafeLibs/GoodImport01.hs b/testsuite/tests/safeHaskell/unsafeLibs/GoodImport01.hs
new file mode 100644
index 0000000000..7834de52bc
--- /dev/null
+++ b/testsuite/tests/safeHaskell/unsafeLibs/GoodImport01.hs
@@ -0,0 +1,14 @@
+{-# LANGUAGE Safe #-}
+-- | Import SYB stuff that should be safe
+module Main where
+
+import Data.Typeable
+import Data.Dynamic
+import Data.Data
+
+f :: Int
+f = 2
+
+main :: IO ()
+main = putStrLn $ "X is: " ++ show f
+
diff --git a/testsuite/tests/safeHaskell/unsafeLibs/GoodImport02.hs b/testsuite/tests/safeHaskell/unsafeLibs/GoodImport02.hs
new file mode 100644
index 0000000000..85a781f982
--- /dev/null
+++ b/testsuite/tests/safeHaskell/unsafeLibs/GoodImport02.hs
@@ -0,0 +1,15 @@
+{-# LANGUAGE Safe #-}
+-- | Import safe versions of unsafe modules from prelude
+module Main where
+
+import Control.Monad.ST.Safe
+import Control.Monad.ST.Lazy.Safe
+import Foreign.ForeignPtr.Safe
+import Foreign.Safe
+
+f :: Int
+f = 2
+
+main :: IO ()
+main = putStrLn $ "X is: " ++ show f
+
diff --git a/testsuite/tests/safeHaskell/unsafeLibs/GoodImport03.hs b/testsuite/tests/safeHaskell/unsafeLibs/GoodImport03.hs
new file mode 100644
index 0000000000..5ad44026a8
--- /dev/null
+++ b/testsuite/tests/safeHaskell/unsafeLibs/GoodImport03.hs
@@ -0,0 +1,121 @@
+{-# LANGUAGE Safe #-}
+-- | Import all modules from prelude that should be safe
+module Main where
+
+import Numeric
+import Prelude
+-- import Foreign
+
+import Control.Applicative
+import Control.Arrow
+import Control.Category
+
+-- import Control.ST
+-- import Control.ST.Lazy
+-- import Control.ST.Strict
+
+import Control.Concurrent
+import Control.Concurrent.Chan
+import Control.Concurrent.MVar
+import Control.Concurrent.QSem
+import Control.Concurrent.QSemN
+import Control.Concurrent.SampleVar
+
+import Control.Exception
+import Control.OldException
+import Control.Exception.Base
+
+import Control.Monad
+import Control.Monad.Fix
+import Control.Monad.Group
+import Control.Monad.Instances
+import Control.Monad.Zip
+
+import Data.Bits
+import Data.Bool
+import Data.Char
+import Data.Complex
+import Data.Either
+import Data.Eq
+import Data.Fixed
+import Data.Foldable
+import Data.Function
+import Data.Functor
+import Data.HashTable
+import Data.IORef
+import Data.Int
+import Data.Ix
+import Data.List
+import Data.Maybe
+import Data.Monoid
+import Data.Ord
+import Data.Ratio
+import Data.String
+import Data.Traversable
+import Data.Tuple
+import Data.Typeable
+import Data.Unique
+import Data.Version
+import Data.Word
+
+import Data.STRef
+import Data.STRef.Lazy
+import Data.STRef.Strict
+
+-- import Debug.Trace
+
+import Foreign.Concurrent
+-- import Foreign.ForeignPtr
+import Foreign.Ptr
+import Foreign.StablePtr
+import Foreign.Storable
+
+import Foreign.C
+import Foreign.C.Error
+import Foreign.C.String
+import Foreign.C.Types
+
+import Foreign.Marshal
+import Foreign.Marshal.Alloc
+import Foreign.Marshal.Array
+import Foreign.Marshal.Error
+import Foreign.Marshal.Pool
+import Foreign.Marshal.Utils
+
+import System.CPUTime
+import System.Environment
+import System.Exit
+import System.Info
+import System.Mem
+import System.Timeout
+
+import System.Console.GetOpt
+
+import System.IO
+import System.IO.Error
+
+import System.Mem.StableName
+import System.Mem.Weak
+
+import System.Posix.Internals
+import System.Posix.Types
+
+import Text.Printf
+
+import Text.Read
+import Text.Read.Lex
+
+import Text.Show
+import Text.Show.Functions
+
+import Text.ParserCombinators.ReadP
+import Text.ParserCombinators.ReadPrec
+
+-- import Unsafe.Coerce
+
+f :: Int
+f = 2
+
+main :: IO ()
+main = putStrLn $ "X is: " ++ show f
+
diff --git a/testsuite/tests/safeHaskell/unsafeLibs/all.T b/testsuite/tests/safeHaskell/unsafeLibs/all.T
index c43fe0d191..949511579d 100644
--- a/testsuite/tests/safeHaskell/unsafeLibs/all.T
+++ b/testsuite/tests/safeHaskell/unsafeLibs/all.T
@@ -1,6 +1,7 @@
# unsafeLib tests are all about testing that the correct
# standard library modules have been marked as unsafe.
# e.g no importing unsafePerformIO
+# Checking base package is properly safe basically
# Just do the normal way, SafeHaskell is all in the frontend
def f( opts ):
@@ -8,17 +9,19 @@ def f( opts ):
setTestOpts(f)
+# Check correct methods are deprecated
test('Dep01', normal, compile, [''])
test('Dep02', normal, compile, [''])
test('Dep03', normal, compile, [''])
test('Dep04', normal, compile, [''])
-test('Dep05', normal, compile, [''])
-test('Dep06', normal, compile, [''])
-test('Dep07', normal, compile, [''])
-test('Dep08', normal, compile, [''])
-test('Dep09', normal, compile, [''])
-test('Dep10', normal, compile, [''])
+test('Dep05', normal, compile_fail, [''])
+test('Dep06', normal, compile_fail, [''])
+test('Dep07', normal, compile_fail, [''])
+test('Dep08', normal, compile_fail, [''])
+test('Dep09', normal, compile_fail, [''])
+test('Dep10', normal, compile_fail, [''])
+# check unsafe modules are marked unsafe
test('BadImport01', normal, compile_fail, [''])
test('BadImport02',
extra_clean(['BadImport02_A.o', 'BadImport02_A.hi']),
@@ -28,3 +31,14 @@ test('BadImport03',
extra_clean(['BadImport03_A.o', 'BadImport03_A.hi']),
multimod_compile_fail,
['BadImport03', ''])
+test('BadImport04', normal, compile_fail, [''])
+test('BadImport05', normal, compile_fail, [''])
+test('BadImport06', normal, compile_fail, [''])
+test('BadImport07', normal, compile_fail, [''])
+test('BadImport08', normal, compile_fail, [''])
+
+# check safe modules are marked safe
+test('GoodImport01', normal, compile, [''])
+test('GoodImport02', normal, compile, [''])
+test('GoodImport03', normal, compile, [''])
+