diff options
Diffstat (limited to 'testsuite/tests/indexed-types')
18 files changed, 132 insertions, 0 deletions
diff --git a/testsuite/tests/indexed-types/should_compile/T13092b/Makefile b/testsuite/tests/indexed-types/should_compile/T13092b/Makefile new file mode 100644 index 0000000000..2b498980c4 --- /dev/null +++ b/testsuite/tests/indexed-types/should_compile/T13092b/Makefile @@ -0,0 +1,10 @@ +TOP=../../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk + +T13092b: + rm -f T13092b_[12].hi + '$(TEST_HC)' $(TEST_HC_OPTS) -c T13092b_1.hs -ddump-if-trace 2> if.out + grep 'Reading interface for .*:GHC.Generics' if.out > /dev/null + '$(TEST_HC)' $(TEST_HC_OPTS) -c T13092b_2.hs -ddump-if-trace 2> if.out + ! grep 'Reading interface for .*:GHC.Generics' if.out diff --git a/testsuite/tests/indexed-types/should_compile/T13092b/T13092b_1.hs b/testsuite/tests/indexed-types/should_compile/T13092b/T13092b_1.hs new file mode 100644 index 0000000000..4d13c1580d --- /dev/null +++ b/testsuite/tests/indexed-types/should_compile/T13092b/T13092b_1.hs @@ -0,0 +1,7 @@ +{-# LANGUAGE TypeFamilies, DeriveGeneric #-} + +module T13092b_1 where + +import GHC.Generics + +data X = X deriving (Generic) diff --git a/testsuite/tests/indexed-types/should_compile/T13092b/T13092b_2.hs b/testsuite/tests/indexed-types/should_compile/T13092b/T13092b_2.hs new file mode 100644 index 0000000000..14e1ff8dcc --- /dev/null +++ b/testsuite/tests/indexed-types/should_compile/T13092b/T13092b_2.hs @@ -0,0 +1,8 @@ +{-# LANGUAGE TypeFamilies #-} + +module T13092b_2 where + +import T13092b_1 + +x :: X +x = X diff --git a/testsuite/tests/indexed-types/should_compile/T13092b/all.T b/testsuite/tests/indexed-types/should_compile/T13092b/all.T new file mode 100644 index 0000000000..a3047a60e5 --- /dev/null +++ b/testsuite/tests/indexed-types/should_compile/T13092b/all.T @@ -0,0 +1,5 @@ +# Test that we don't load all family instance interface files +# when importing a module that defines a family instance + +test('T13092b', ignore_stdout, + run_command, ['$MAKE -s --no-print-directory T13092b']) diff --git a/testsuite/tests/indexed-types/should_fail/T13092/A.hs b/testsuite/tests/indexed-types/should_fail/T13092/A.hs new file mode 100644 index 0000000000..a7acce648b --- /dev/null +++ b/testsuite/tests/indexed-types/should_fail/T13092/A.hs @@ -0,0 +1,3 @@ +{-# LANGUAGE TypeFamilies #-} +module A where +type family A a diff --git a/testsuite/tests/indexed-types/should_fail/T13092/B.hs b/testsuite/tests/indexed-types/should_fail/T13092/B.hs new file mode 100644 index 0000000000..f04248d4a1 --- /dev/null +++ b/testsuite/tests/indexed-types/should_fail/T13092/B.hs @@ -0,0 +1,5 @@ +{-# LANGUAGE TypeFamilies #-} +module B (A, X) where +import A +data X +type instance A (X, b) = () diff --git a/testsuite/tests/indexed-types/should_fail/T13092/C.hs b/testsuite/tests/indexed-types/should_fail/T13092/C.hs new file mode 100644 index 0000000000..73beecf2e8 --- /dev/null +++ b/testsuite/tests/indexed-types/should_fail/T13092/C.hs @@ -0,0 +1,6 @@ +{-# LANGUAGE RankNTypes #-} +module C (x) where +import Data.Proxy +import B +x :: Proxy b -> (forall t. Proxy t -> Bool -> A (t, b)) -> (Bool -> ()) +x _ f = f (undefined :: Proxy X) diff --git a/testsuite/tests/indexed-types/should_fail/T13092/Main.hs b/testsuite/tests/indexed-types/should_fail/T13092/Main.hs new file mode 100644 index 0000000000..ee62cf0cbb --- /dev/null +++ b/testsuite/tests/indexed-types/should_fail/T13092/Main.hs @@ -0,0 +1,18 @@ +{-# LANGUAGE TypeFamilies #-} + +module Main where + +import Data.Proxy +import A +import C + +data Y +type instance A (a, Y) = Bool + +y :: Proxy a -> Bool -> A (a, Y) +y _ = id + +z :: Bool -> () +z = x (undefined :: Proxy Y) y + +main = print (z True) diff --git a/testsuite/tests/indexed-types/should_fail/T13092/Makefile b/testsuite/tests/indexed-types/should_fail/T13092/Makefile new file mode 100644 index 0000000000..8bd11ac3c2 --- /dev/null +++ b/testsuite/tests/indexed-types/should_fail/T13092/Makefile @@ -0,0 +1,9 @@ +TOP=../../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk + +T13092: + '$(TEST_HC)' $(TEST_HC_OPTS) -c A.hs + '$(TEST_HC)' $(TEST_HC_OPTS) -c B.hs + '$(TEST_HC)' $(TEST_HC_OPTS) -c C.hs + ! '$(TEST_HC)' $(TEST_HC_OPTS) -c Main.hs diff --git a/testsuite/tests/indexed-types/should_fail/T13092/T13092.stderr b/testsuite/tests/indexed-types/should_fail/T13092/T13092.stderr new file mode 100644 index 0000000000..9df66e7cd1 --- /dev/null +++ b/testsuite/tests/indexed-types/should_fail/T13092/T13092.stderr @@ -0,0 +1,5 @@ + +Main.hs:10:15: error: + Conflicting family instance declarations: + A (a, Y) = Bool -- Defined at Main.hs:10:15 + A (B.X, b) = () -- Defined in ‘B’ diff --git a/testsuite/tests/indexed-types/should_fail/T13092/all.T b/testsuite/tests/indexed-types/should_fail/T13092/all.T new file mode 100644 index 0000000000..090d10db96 --- /dev/null +++ b/testsuite/tests/indexed-types/should_fail/T13092/all.T @@ -0,0 +1,5 @@ +# Test that we check consistency of local type family instances +# with imported ones + +test('T13092', extra_files(['A.hs', 'B.hs', 'C.hs', 'Main.hs']), + run_command, ['$MAKE -s --no-print-directory T13092']) diff --git a/testsuite/tests/indexed-types/should_fail/T13092c/Makefile b/testsuite/tests/indexed-types/should_fail/T13092c/Makefile new file mode 100644 index 0000000000..29a3b104eb --- /dev/null +++ b/testsuite/tests/indexed-types/should_fail/T13092c/Makefile @@ -0,0 +1,12 @@ +TOP=../../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk + +T13092c: + rm -f T13092c_[1234].hi + '$(TEST_HC)' $(TEST_HC_OPTS) -c T13092c_1.hs -ddump-if-trace > /dev/null 2> if.out + ! grep 'Reading interface for .*:GHC.Generics' if.out + '$(TEST_HC)' $(TEST_HC_OPTS) -c T13092c_2.hs -ddump-if-trace > /dev/null 2> if.out + ! grep 'Reading interface for .*:GHC.Generics' if.out + '$(TEST_HC)' $(TEST_HC_OPTS) -c T13092c_3.hs + ! '$(TEST_HC)' $(TEST_HC_OPTS) -c T13092c_4.hs diff --git a/testsuite/tests/indexed-types/should_fail/T13092c/T13092c.stderr b/testsuite/tests/indexed-types/should_fail/T13092c/T13092c.stderr new file mode 100644 index 0000000000..6676684ec1 --- /dev/null +++ b/testsuite/tests/indexed-types/should_fail/T13092c/T13092c.stderr @@ -0,0 +1,5 @@ + +T13092c_4.hs:7:15: error: + Conflicting family instance declarations: + F (a, Char) = String -- Defined at T13092c_4.hs:7:15 + F (T13092c_2.X, b) = Bool -- Defined in ‘T13092c_2’ diff --git a/testsuite/tests/indexed-types/should_fail/T13092c/T13092c_1.hs b/testsuite/tests/indexed-types/should_fail/T13092c/T13092c_1.hs new file mode 100644 index 0000000000..dbab1da195 --- /dev/null +++ b/testsuite/tests/indexed-types/should_fail/T13092c/T13092c_1.hs @@ -0,0 +1,6 @@ +{-# LANGUAGE TypeFamilies #-} + +module T13092c_1 where + +type family F a +type instance F Int = () diff --git a/testsuite/tests/indexed-types/should_fail/T13092c/T13092c_2.hs b/testsuite/tests/indexed-types/should_fail/T13092c/T13092c_2.hs new file mode 100644 index 0000000000..0bbf97efdd --- /dev/null +++ b/testsuite/tests/indexed-types/should_fail/T13092c/T13092c_2.hs @@ -0,0 +1,8 @@ +{-# LANGUAGE TypeFamilies #-} + +module T13092c_2 (F) where + +import T13092c_1 + +data X +type instance F (X, b) = Bool diff --git a/testsuite/tests/indexed-types/should_fail/T13092c/T13092c_3.hs b/testsuite/tests/indexed-types/should_fail/T13092c/T13092c_3.hs new file mode 100644 index 0000000000..08bda736e5 --- /dev/null +++ b/testsuite/tests/indexed-types/should_fail/T13092c/T13092c_3.hs @@ -0,0 +1,5 @@ +{-# LANGUAGE TypeFamilies #-} + +module T13092c_3 (F) where + +import T13092c_2 diff --git a/testsuite/tests/indexed-types/should_fail/T13092c/T13092c_4.hs b/testsuite/tests/indexed-types/should_fail/T13092c/T13092c_4.hs new file mode 100644 index 0000000000..a3273f9bfe --- /dev/null +++ b/testsuite/tests/indexed-types/should_fail/T13092c/T13092c_4.hs @@ -0,0 +1,7 @@ +{-# LANGUAGE TypeFamilies #-} + +module T13092c_4 where + +import T13092c_3 + +type instance F (a, Char) = String diff --git a/testsuite/tests/indexed-types/should_fail/T13092c/all.T b/testsuite/tests/indexed-types/should_fail/T13092c/all.T new file mode 100644 index 0000000000..c4e38be054 --- /dev/null +++ b/testsuite/tests/indexed-types/should_fail/T13092c/all.T @@ -0,0 +1,8 @@ +# Test that we don't load family instance instance files from +# external packages when defining an instance for a type family +# defined in the home package, but do read instance files from +# the home package. (Instance in T13092c_2 overlaps with the one +# defined in T13092c_4, and would not be read otherwise.) + +test('T13092c', ignore_stdout, + run_command, ['$MAKE -s --no-print-directory T13092c']) |