New handling of overlapping inst in Safe Haskell
[ghc.git] / testsuite / tests / safeHaskell / safeInfered / all.T
1 # safeInfered tests are for testing that the Safe Haskell
2 # mode safe inference works correctly.
3
4 # Just do the normal way, SafeHaskell is all in the frontend
5 def f( name, opts ):
6   opts.only_ways = ['normal']
7
8 setTestOpts(f)
9
10 # Tests that should compile fine as they should be infered safe
11 test('SafeInfered01',
12      [ extra_clean(['SafeInfered01_A.hi', 'SafeInfered01_A.o']) ],
13      multimod_compile, ['SafeInfered01', ''])
14 test('SafeInfered02',
15      [ extra_clean(['SafeInfered02_A.hi', 'SafeInfered02_A.o']) ],
16      multimod_compile, ['SafeInfered02', ''])
17 test('SafeInfered03',
18      [ extra_clean(['SafeInfered03_A.hi', 'SafeInfered03_A.o']) ],
19       multimod_compile, ['SafeInfered03', ''])
20 test('SafeInfered04',
21      [ extra_clean(['SafeInfered04_A.hi', 'SafeInfered04_A.o']) ],
22      multimod_compile, ['SafeInfered04', ''])
23 test('SafeInfered05',
24      [ extra_clean(['SafeInfered05_A.hi', 'SafeInfered05_A.o']) ],
25      multimod_compile, ['SafeInfered05', ''])
26
27 # Tests that should fail to compile as they should be infered unsafe
28 test('UnsafeInfered01',
29      [ extra_clean(['UnsafeInfered01_A.hi', 'UnsafeInfered01_A.o']) ],
30      multimod_compile_fail, ['UnsafeInfered01', ''])
31 test('UnsafeInfered02',
32      [ extra_clean(['UnsafeInfered02_A.hi', 'UnsafeInfered02_A.o']) ],
33      multimod_compile_fail, ['UnsafeInfered02', ''])
34 test('UnsafeInfered03',
35      [ extra_clean(['UnsafeInfered03_A.hi', 'UnsafeInfered03_A.o']) ],
36      multimod_compile_fail, ['UnsafeInfered03', ''])
37 test('UnsafeInfered05',
38      [ extra_clean(['UnsafeInfered05_A.hi', 'UnsafeInfered05_A.o']) ],
39      multimod_compile_fail, ['UnsafeInfered05', ''])
40 test('UnsafeInfered06',
41      [ extra_clean(['UnsafeInfered06_A.hi', 'UnsafeInfered06_A.o']) ],
42      multimod_compile_fail, ['UnsafeInfered06', ''])
43 test('UnsafeInfered08',
44      [ extra_clean(['UnsafeInfered08_A.hi', 'UnsafeInfered08_A.o']) ],
45      multimod_compile, ['UnsafeInfered08', ''])
46 test('UnsafeInfered09',
47      [ extra_clean(['UnsafeInfered09_A.hi', 'UnsafeInfered09_A.o',
48                     'UnsafeInfered09_B.hi', 'UnsafeInfered09_B.o']) ],
49      multimod_compile_fail, ['UnsafeInfered09', ''])
50
51 # Test that should fail as we disable safe inference
52 test('UnsafeInfered10',
53      [ extra_clean(['UnsafeInfered10_A.hi', 'UnsafeInfered10_A.o']) ],
54      multimod_compile_fail, ['UnsafeInfered10', ''])
55 test('UnsafeInfered11',
56      [ extra_clean(['UnsafeInfered11_A.hi', 'UnsafeInfered11_A.o']) ],
57      multimod_compile_fail, ['UnsafeInfered11', ''])
58
59 # Test TH is unsafe
60 test('UnsafeInfered12', normal, compile_fail, [''])
61
62 # Test various overlapping instance flags
63 # GHC 7.10 and earlier we regarded them as unsafe, but we now take an approach
64 # based on looking only at sites of actual overlaps
65 test('UnsafeInfered13', normal, compile, [''])
66 test('UnsafeInfered14', normal, compile, [''])
67 test('UnsafeInfered15', normal, compile, [''])
68 test('UnsafeInfered16', normal, compile, [''])
69 test('UnsafeInfered17', normal, compile, [''])
70 test('UnsafeInfered18', normal, compile, [''])
71 test('UnsafeInfered19', normal, compile, [''])
72
73 # Mixed tests
74 test('Mixed01', normal, compile_fail, [''])
75 test('Mixed02', normal, compile_fail, [''])
76 test('Mixed03', normal, compile_fail, [''])
77
78 # Trustworthy Safe modules
79 test('TrustworthySafe01', normal, compile, [''])
80 test('TrustworthySafe02', normal, compile, [''])
81 test('TrustworthySafe03', normal, compile, [''])
82 test('TrustworthySafe04', normal, compile, [''])
83
84 # Check -fwarn-unsafe works
85 test('UnsafeWarn01', normal, compile, [''])
86 test('UnsafeWarn02', normal, compile, [''])
87 test('UnsafeWarn03', normal, compile, [''])
88 test('UnsafeWarn04', normal, compile, [''])
89 test('UnsafeWarn05', normal, compile, [''])
90 test('UnsafeWarn06', normal, compile, [''])
91 test('UnsafeWarn07', normal, compile, [''])
92
93 # Chck -fwa-safe works
94 test('SafeWarn01', normal, compile, [''])
95