diff options
author | Richard Eisenberg <eir@seas.upenn.edu> | 2013-08-28 12:05:03 -0400 |
---|---|---|
committer | Richard Eisenberg <eir@cis.upenn.edu> | 2013-09-17 21:41:53 -0400 |
commit | 1e3ca733694f0c9c8cc1d95237eb4b09cee4206f (patch) | |
tree | 73f31ae153ac841d0f8499b5edd98075881bdec4 /testsuite/tests/roles/should_fail | |
parent | b4ab30d54540573fbda3f561377d2c5968eb215c (diff) | |
download | haskell-1e3ca733694f0c9c8cc1d95237eb4b09cee4206f.tar.gz |
Update to tests due to change in syntax for role annotations.
Diffstat (limited to 'testsuite/tests/roles/should_fail')
19 files changed, 176 insertions, 0 deletions
diff --git a/testsuite/tests/roles/should_fail/Makefile b/testsuite/tests/roles/should_fail/Makefile new file mode 100644 index 0000000000..8f80de39c3 --- /dev/null +++ b/testsuite/tests/roles/should_fail/Makefile @@ -0,0 +1,9 @@ +TOP=../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk + +.PHONY: Roles12 + +Roles12: + '$(TEST_HC)' $(TEST_HC_OPTS) -c Roles12.hs-boot + -'$(TEST_HC)' $(TEST_HC_OPTS) -c Roles12.hs diff --git a/testsuite/tests/roles/should_fail/Roles10.hs b/testsuite/tests/roles/should_fail/Roles10.hs new file mode 100644 index 0000000000..af19bfdf31 --- /dev/null +++ b/testsuite/tests/roles/should_fail/Roles10.hs @@ -0,0 +1,16 @@ +{-# LANGUAGE GeneralizedNewtypeDeriving, TypeFamilies #-} + +module Roles10 where + +type family F a +type instance F Int = Bool +type instance F Age = Char + +class C a where + meth :: a -> F a + +instance C Int where + meth = (> 0) + +newtype Age = MkAge Int + deriving C
\ No newline at end of file diff --git a/testsuite/tests/roles/should_fail/Roles10.stderr b/testsuite/tests/roles/should_fail/Roles10.stderr new file mode 100644 index 0000000000..756aaa2e00 --- /dev/null +++ b/testsuite/tests/roles/should_fail/Roles10.stderr @@ -0,0 +1,7 @@ + +Roles10.hs:16:12: + Can't make a derived instance of ‛C Age’ + (even with cunning newtype deriving): + it is not type-safe to use GeneralizedNewtypeDeriving on this class; + the last parameter of ‛C’ is at role Nominal + In the newtype declaration for ‛Age’ diff --git a/testsuite/tests/roles/should_fail/Roles11.hs b/testsuite/tests/roles/should_fail/Roles11.hs new file mode 100644 index 0000000000..bc05477da9 --- /dev/null +++ b/testsuite/tests/roles/should_fail/Roles11.hs @@ -0,0 +1,8 @@ +{-# LANGUAGE GADTs, RoleAnnotations #-} + +module Roles11 where + +type role T2 representational +data T2 a where + K2 :: T2 Int + diff --git a/testsuite/tests/roles/should_fail/Roles11.stderr b/testsuite/tests/roles/should_fail/Roles11.stderr new file mode 100644 index 0000000000..ee15f99185 --- /dev/null +++ b/testsuite/tests/roles/should_fail/Roles11.stderr @@ -0,0 +1,5 @@ + +Roles11.hs:6:1: + Role mismatch on variable a: + Annotation says representational but role nominal is required + In the data declaration for ‛T2’ diff --git a/testsuite/tests/roles/should_fail/Roles12.hs b/testsuite/tests/roles/should_fail/Roles12.hs new file mode 100644 index 0000000000..875d105b78 --- /dev/null +++ b/testsuite/tests/roles/should_fail/Roles12.hs @@ -0,0 +1,5 @@ +module Roles12 where + +import {-# SOURCE #-} Roles12 + +data T a diff --git a/testsuite/tests/roles/should_fail/Roles12.hs-boot b/testsuite/tests/roles/should_fail/Roles12.hs-boot new file mode 100644 index 0000000000..6a708d984a --- /dev/null +++ b/testsuite/tests/roles/should_fail/Roles12.hs-boot @@ -0,0 +1,3 @@ +module Roles12 where + +data T a
\ No newline at end of file diff --git a/testsuite/tests/roles/should_fail/Roles12.stderr b/testsuite/tests/roles/should_fail/Roles12.stderr new file mode 100644 index 0000000000..42d63463e0 --- /dev/null +++ b/testsuite/tests/roles/should_fail/Roles12.stderr @@ -0,0 +1,15 @@ + +Roles12.hs:5:6: + Type constructor ‛T’ has conflicting definitions in the module + and its hs-boot file + Main module: data T a + No C type associated + Roles: [phantom] + RecFlag Recursive, Promotable + = + FamilyInstance: none + Boot file: abstract(False) T a + No C type associated + Roles: [representational] + RecFlag NonRecursive, Not promotable + FamilyInstance: none diff --git a/testsuite/tests/roles/should_fail/Roles5.hs b/testsuite/tests/roles/should_fail/Roles5.hs new file mode 100644 index 0000000000..b75af75008 --- /dev/null +++ b/testsuite/tests/roles/should_fail/Roles5.hs @@ -0,0 +1,9 @@ +module Roles5 where + +data T a +class C a +type S a = Int + +type role T nominal +type role C representational +type role S phantom
\ No newline at end of file diff --git a/testsuite/tests/roles/should_fail/Roles5.stderr b/testsuite/tests/roles/should_fail/Roles5.stderr new file mode 100644 index 0000000000..c4907c89f6 --- /dev/null +++ b/testsuite/tests/roles/should_fail/Roles5.stderr @@ -0,0 +1,12 @@ + +Roles5.hs:7:1: + Illegal role annotation for T; + did you intend to use RoleAnnotations? + +Roles5.hs:8:1: + Illegal role annotation for C; + did you intend to use RoleAnnotations? + +Roles5.hs:9:1: + Illegal role annotation for S; + they are allowed only for datatypes and classes. diff --git a/testsuite/tests/roles/should_fail/Roles6.hs b/testsuite/tests/roles/should_fail/Roles6.hs new file mode 100644 index 0000000000..c0ab9fafb2 --- /dev/null +++ b/testsuite/tests/roles/should_fail/Roles6.hs @@ -0,0 +1,8 @@ +{-# LANGUAGE RoleAnnotations #-} + +module Roles6 where + +data Foo a b = MkFoo (a b) + +type role Foo nominal representational phantom + diff --git a/testsuite/tests/roles/should_fail/Roles6.stderr b/testsuite/tests/roles/should_fail/Roles6.stderr new file mode 100644 index 0000000000..3cca04d2a6 --- /dev/null +++ b/testsuite/tests/roles/should_fail/Roles6.stderr @@ -0,0 +1,15 @@ + +Roles6.hs:5:1: + Role mismatch on variable a: + Annotation says nominal but role representational is required + In the data declaration for ‛Foo’ + +Roles6.hs:5:1: + Role mismatch on variable b: + Annotation says representational but role nominal is required + In the data declaration for ‛Foo’ + +Roles6.hs:7:1: + Wrong number of roles listed in role annotation; + Expected 2, got 3: + type role Foo nominal representational phantom diff --git a/testsuite/tests/roles/should_fail/Roles7.hs b/testsuite/tests/roles/should_fail/Roles7.hs new file mode 100644 index 0000000000..221b01a1c5 --- /dev/null +++ b/testsuite/tests/roles/should_fail/Roles7.hs @@ -0,0 +1,7 @@ +{-# LANGUAGE RoleAnnotations #-} + +module Roles7 where + +class Bar a +type role Bar repesentational + -- spelling error intentional!
\ No newline at end of file diff --git a/testsuite/tests/roles/should_fail/Roles7.stderr b/testsuite/tests/roles/should_fail/Roles7.stderr new file mode 100644 index 0000000000..e4774f1aa8 --- /dev/null +++ b/testsuite/tests/roles/should_fail/Roles7.stderr @@ -0,0 +1,4 @@ + +Roles7.hs:6:15: + Illegal role name ‛repesentational’ + Perhaps you meant ‛representational’ diff --git a/testsuite/tests/roles/should_fail/Roles8.hs b/testsuite/tests/roles/should_fail/Roles8.hs new file mode 100644 index 0000000000..396431cd50 --- /dev/null +++ b/testsuite/tests/roles/should_fail/Roles8.hs @@ -0,0 +1,13 @@ +{-# LANGUAGE RoleAnnotations, GADTs #-} + +module Roles8 where + +data T1 a = K1 a + +type role T1 nominal +type role T1 nominal + +data T2 b = MkT2 + +type role T2 representational +type role T2 phantom
\ No newline at end of file diff --git a/testsuite/tests/roles/should_fail/Roles8.stderr b/testsuite/tests/roles/should_fail/Roles8.stderr new file mode 100644 index 0000000000..22f66f4667 --- /dev/null +++ b/testsuite/tests/roles/should_fail/Roles8.stderr @@ -0,0 +1,10 @@ + +Roles8.hs:7:1: + Duplicate role annotations for ‛T1’: + type role T1 nominal -- written at Roles8.hs:7:1-20 + type role T1 nominal -- written at Roles8.hs:8:1-20 + +Roles8.hs:12:1: + Duplicate role annotations for ‛T2’: + type role T2 representational -- written at Roles8.hs:12:1-29 + type role T2 phantom -- written at Roles8.hs:13:1-20 diff --git a/testsuite/tests/roles/should_fail/Roles9.hs b/testsuite/tests/roles/should_fail/Roles9.hs new file mode 100644 index 0000000000..f8e134d5a1 --- /dev/null +++ b/testsuite/tests/roles/should_fail/Roles9.hs @@ -0,0 +1,13 @@ +{-# LANGUAGE GeneralizedNewtypeDeriving, RoleAnnotations #-} + +module Roles9 where + +type role C nominal +class C a where + meth :: a -> a + +instance C Int where + meth = (+ 1) + +newtype Age = MkAge Int + deriving C diff --git a/testsuite/tests/roles/should_fail/Roles9.stderr b/testsuite/tests/roles/should_fail/Roles9.stderr new file mode 100644 index 0000000000..0cd02f9b5f --- /dev/null +++ b/testsuite/tests/roles/should_fail/Roles9.stderr @@ -0,0 +1,7 @@ + +Roles9.hs:13:12: + Can't make a derived instance of ‛C Age’ + (even with cunning newtype deriving): + it is not type-safe to use GeneralizedNewtypeDeriving on this class; + the last parameter of ‛C’ is at role Nominal + In the newtype declaration for ‛Age’ diff --git a/testsuite/tests/roles/should_fail/all.T b/testsuite/tests/roles/should_fail/all.T new file mode 100644 index 0000000000..36f2d2e1a4 --- /dev/null +++ b/testsuite/tests/roles/should_fail/all.T @@ -0,0 +1,10 @@ +test('Roles5', normal, compile_fail, ['']) +test('Roles6', normal, compile_fail, ['']) +test('Roles7', normal, compile_fail, ['']) +test('Roles8', normal, compile_fail, ['']) +test('Roles9', normal, compile_fail, ['']) +test('Roles10', normal, compile_fail, ['']) +test('Roles11', normal, compile_fail, ['']) +test('Roles12', + extra_clean(['Roles12.o-boot', 'Roles12.hi-boot']), + run_command, ['$MAKE --no-print-directory -s Roles12']) |