diff options
Diffstat (limited to 'testsuite/tests')
25 files changed, 182 insertions, 2 deletions
diff --git a/testsuite/tests/cabal/sigcabal02/Main.hs b/testsuite/tests/cabal/sigcabal02/Main.hs new file mode 100644 index 0000000000..52def3d41f --- /dev/null +++ b/testsuite/tests/cabal/sigcabal02/Main.hs @@ -0,0 +1,7 @@ +import Map +import P +import Q + +main = do + x <- foo + print (mymember 5 x) diff --git a/testsuite/tests/cabal/sigcabal02/Makefile b/testsuite/tests/cabal/sigcabal02/Makefile new file mode 100644 index 0000000000..152aaeac0e --- /dev/null +++ b/testsuite/tests/cabal/sigcabal02/Makefile @@ -0,0 +1,34 @@ +TOP=../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk + +SETUP=../Setup -v0 + +# This test is for two Cabal packages exposing the same signature + +sigcabal02: + $(MAKE) clean + '$(GHC_PKG)' field containers id | sed 's/^.*: *//' > containers + '$(GHC_PKG)' init tmp.d + '$(TEST_HC)' -v0 --make Setup + cd p && $(SETUP) clean + cd p && $(SETUP) configure $(CABAL_MINIMAL_BUILD) --with-ghc='$(TEST_HC)' --ghc-options='$(TEST_HC_OPTS)' --package-db=../tmp.d --prefix='$(PWD)/inst-p' --instantiate-with="Map=Data.Map.Lazy@`cat ../containers`" --instantiate-with="Set=Data.Set@`cat ../containers`" --ghc-pkg-options="--enable-multi-instance" + cd p && $(SETUP) build + cd p && $(SETUP) copy + cd p && $(SETUP) register --print-ipid > ../p_ipid + cd q && $(SETUP) clean + cd q && $(SETUP) configure $(CABAL_MINIMAL_BUILD) --with-ghc='$(TEST_HC)' --ghc-options='$(TEST_HC_OPTS)' --package-db=../tmp.d --prefix='$(PWD)/inst-p' --instantiate-with="Map=Data.Map.Lazy@`cat ../containers`" --ghc-pkg-options="--enable-multi-instance" + cd q && $(SETUP) build + cd q && $(SETUP) copy + cd q && $(SETUP) register --print-ipid > ../q_ipid + '$(TEST_HC)' $(TEST_HC_OPTS) -package-db=tmp.d -hide-all-packages -package base -package-id "`cat p_ipid`" -package-id "`cat q_ipid`" --make Main.hs + ./Main + ! '$(TEST_HC)' $(TEST_HC_OPTS) -package-db=tmp.d -hide-all-packages -package base -package-id "`cat p_ipid`" -package-id "`cat q_ipid`" --make ShouldFail.hs +ifneq "$(CLEANUP)" "" + $(MAKE) clean +endif + +clean : + '$(GHC_PKG)' unregister --force p >/dev/null 2>&1 || true + '$(GHC_PKG)' unregister --force q >/dev/null 2>&1 || true + $(RM) -r tmp.d inst-* *.o *.hi */*.o */*.hi */Setup$(exeext) */dist Setup$(exeext) diff --git a/testsuite/tests/cabal/sigcabal02/Setup.hs b/testsuite/tests/cabal/sigcabal02/Setup.hs new file mode 100644 index 0000000000..9a994af677 --- /dev/null +++ b/testsuite/tests/cabal/sigcabal02/Setup.hs @@ -0,0 +1,2 @@ +import Distribution.Simple +main = defaultMain diff --git a/testsuite/tests/cabal/sigcabal02/ShouldFail.hs b/testsuite/tests/cabal/sigcabal02/ShouldFail.hs new file mode 100644 index 0000000000..98ec49e886 --- /dev/null +++ b/testsuite/tests/cabal/sigcabal02/ShouldFail.hs @@ -0,0 +1 @@ +import Set diff --git a/testsuite/tests/cabal/sigcabal02/all.T b/testsuite/tests/cabal/sigcabal02/all.T new file mode 100644 index 0000000000..11eb05975b --- /dev/null +++ b/testsuite/tests/cabal/sigcabal02/all.T @@ -0,0 +1,9 @@ +if default_testopts.cleanup != '': + cleanup = 'CLEANUP=1' +else: + cleanup = '' + +test('sigcabal02', + normal, + run_command, + ['$MAKE -s --no-print-directory sigcabal02 ' + cleanup]) diff --git a/testsuite/tests/cabal/sigcabal02/p/LICENSE b/testsuite/tests/cabal/sigcabal02/p/LICENSE new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/testsuite/tests/cabal/sigcabal02/p/LICENSE diff --git a/testsuite/tests/cabal/sigcabal02/p/Map.hsig b/testsuite/tests/cabal/sigcabal02/p/Map.hsig new file mode 100644 index 0000000000..359cf64ab9 --- /dev/null +++ b/testsuite/tests/cabal/sigcabal02/p/Map.hsig @@ -0,0 +1,18 @@ +{-# LANGUAGE RoleAnnotations #-} +module Map where + +import Set + +type role Map nominal representational +data Map k a + +instance (Show k, Show a) => Show (Map k a) + +size :: Map k a -> Int +lookup :: Ord k => k -> Map k a -> Maybe a +empty :: Map k a +insert :: Ord k => k -> a -> Map k a -> Map k a +delete :: Ord k => k -> Map k a -> Map k a + +keysSet :: Map k a -> Set k +fromSet :: (k -> a) -> Set k -> Map k a diff --git a/testsuite/tests/cabal/sigcabal02/p/P.hs b/testsuite/tests/cabal/sigcabal02/p/P.hs new file mode 100644 index 0000000000..dec6b41c94 --- /dev/null +++ b/testsuite/tests/cabal/sigcabal02/p/P.hs @@ -0,0 +1,12 @@ +module P where + +import qualified Map +import qualified Set + +foo = do + let x = Map.insert 0 "foo" + . Map.insert (6 :: Int) "foo" + $ Map.empty + print (Map.lookup 1 x) + print (Set.size (Map.keysSet x)) + return x diff --git a/testsuite/tests/cabal/sigcabal02/p/Set.hsig b/testsuite/tests/cabal/sigcabal02/p/Set.hsig new file mode 100644 index 0000000000..1713133365 --- /dev/null +++ b/testsuite/tests/cabal/sigcabal02/p/Set.hsig @@ -0,0 +1,13 @@ +{-# LANGUAGE RoleAnnotations #-} +module Set where + +type role Set nominal +data Set a + +instance Show a => Show (Set a) + +size :: Set a -> Int +member :: Ord a => a -> Set a -> Bool +empty :: Set a +insert :: Ord a => a -> Set a -> Set a +delete :: Ord a => a -> Set a -> Set a diff --git a/testsuite/tests/cabal/sigcabal02/p/p.cabal b/testsuite/tests/cabal/sigcabal02/p/p.cabal new file mode 100644 index 0000000000..bb3b2a4463 --- /dev/null +++ b/testsuite/tests/cabal/sigcabal02/p/p.cabal @@ -0,0 +1,14 @@ +name: p +version: 1.0 +license-file: LICENSE +author: Edward Z. Yang +maintainer: ezyang@cs.stanford.edu +build-type: Simple +cabal-version: >=1.20 + +library + exposed-modules: P + exposed-signatures: Map + required-signatures: Set + build-depends: base + default-language: Haskell2010 diff --git a/testsuite/tests/cabal/sigcabal02/q/LICENSE b/testsuite/tests/cabal/sigcabal02/q/LICENSE new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/testsuite/tests/cabal/sigcabal02/q/LICENSE diff --git a/testsuite/tests/cabal/sigcabal02/q/Map.hsig b/testsuite/tests/cabal/sigcabal02/q/Map.hsig new file mode 100644 index 0000000000..40fd0bc74c --- /dev/null +++ b/testsuite/tests/cabal/sigcabal02/q/Map.hsig @@ -0,0 +1,7 @@ +{-# LANGUAGE RoleAnnotations #-} +module Map where + +type role Map nominal representational +data Map k a + +member :: Ord k => k -> Map k a -> Bool diff --git a/testsuite/tests/cabal/sigcabal02/q/Q.hs b/testsuite/tests/cabal/sigcabal02/q/Q.hs new file mode 100644 index 0000000000..ba55fb97b7 --- /dev/null +++ b/testsuite/tests/cabal/sigcabal02/q/Q.hs @@ -0,0 +1,7 @@ +module Q where + +import qualified Map +import Map(Map) + +mymember :: Int -> Map Int a -> Bool +mymember k m = Map.member k m || Map.member (k + 1) m diff --git a/testsuite/tests/cabal/sigcabal02/q/q.cabal b/testsuite/tests/cabal/sigcabal02/q/q.cabal new file mode 100644 index 0000000000..2f99c4403c --- /dev/null +++ b/testsuite/tests/cabal/sigcabal02/q/q.cabal @@ -0,0 +1,13 @@ +name: q +version: 1.0 +license-file: LICENSE +author: Edward Z. Yang +maintainer: ezyang@cs.stanford.edu +build-type: Simple +cabal-version: >=1.20 + +library + exposed-modules: Q + exposed-signatures: Map + build-depends: base + default-language: Haskell2010 diff --git a/testsuite/tests/cabal/sigcabal02/sigcabal02.stderr b/testsuite/tests/cabal/sigcabal02/sigcabal02.stderr new file mode 100644 index 0000000000..7c1f09239f --- /dev/null +++ b/testsuite/tests/cabal/sigcabal02/sigcabal02.stderr @@ -0,0 +1,4 @@ + +ShouldFail.hs:1:8: + Could not find module ‘Set’ + Use -v to see a list of the files searched for. diff --git a/testsuite/tests/cabal/sigcabal02/sigcabal02.stdout b/testsuite/tests/cabal/sigcabal02/sigcabal02.stdout new file mode 100644 index 0000000000..48cb59e63a --- /dev/null +++ b/testsuite/tests/cabal/sigcabal02/sigcabal02.stdout @@ -0,0 +1,5 @@ +[1 of 1] Compiling Main ( Main.hs, Main.o ) +Linking Main ... +Nothing +2 +True diff --git a/testsuite/tests/driver/recomp014/Makefile b/testsuite/tests/driver/recomp014/Makefile index 8bd973594a..c9ba0e05bd 100644 --- a/testsuite/tests/driver/recomp014/Makefile +++ b/testsuite/tests/driver/recomp014/Makefile @@ -19,9 +19,11 @@ recomp014: clean '$(TEST_HC)' $(TEST_HC_OPTS_NO_RECOMP) -c A.hs '$(TEST_HC)' $(TEST_HC_OPTS_NO_RECOMP) -c A1.hs '$(TEST_HC)' $(TEST_HC_OPTS_NO_RECOMP) -c B.hsig -sig-of main:A + echo 'import B; main = print a' > C.hs + '$(TEST_HC)' $(TEST_HC_OPTS_NO_RECOMP) -c C.hs + '$(TEST_HC)' $(TEST_HC_OPTS_NO_RECOMP) -c C.hs echo 'second run' '$(TEST_HC)' $(TEST_HC_OPTS_NO_RECOMP) -c B.hsig -sig-of main:A1 - echo 'import B; main = print a' > C.hs '$(TEST_HC)' $(TEST_HC_OPTS_NO_RECOMP) -c C.hs '$(TEST_HC)' $(TEST_HC_OPTS_NO_RECOMP) A1.o C.o -o recomp014 ./recomp014 diff --git a/testsuite/tests/driver/recomp014/recomp014.stdout b/testsuite/tests/driver/recomp014/recomp014.stdout index 2f899ed73e..7d540716f0 100644 --- a/testsuite/tests/driver/recomp014/recomp014.stdout +++ b/testsuite/tests/driver/recomp014/recomp014.stdout @@ -1,3 +1,4 @@ first run +compilation IS NOT required second run False diff --git a/testsuite/tests/driver/sigof01/Makefile b/testsuite/tests/driver/sigof01/Makefile index a54a1b97e4..8e373e749e 100644 --- a/testsuite/tests/driver/sigof01/Makefile +++ b/testsuite/tests/driver/sigof01/Makefile @@ -21,3 +21,9 @@ sigof01m: mkdir tmp_sigof01m '$(TEST_HC)' $(TEST_HC_OPTS_NO_RECOMP) -outputdir tmp_sigof01m --make Main.hs -sig-of "B is main:A" -o tmp_sigof01m/Main tmp_sigof01m/Main + +sigof01i: + '$(TEST_HC)' $(TEST_HC_OPTS_NO_RECOMP) --interactive -v0 -ignore-dot-ghci Main.hs -sig-of "B is main:A" < sigof01i.script + +sigof01i2: + '$(TEST_HC)' $(TEST_HC_OPTS_NO_RECOMP) --interactive -v0 -ignore-dot-ghci -sig-of "B is main:A" < sigof01i2.script diff --git a/testsuite/tests/driver/sigof01/all.T b/testsuite/tests/driver/sigof01/all.T index d0cdc3c02c..50418b9af0 100644 --- a/testsuite/tests/driver/sigof01/all.T +++ b/testsuite/tests/driver/sigof01/all.T @@ -7,3 +7,13 @@ test('sigof01m', [ clean_cmd('rm -rf tmp_sigof01m') ], run_command, ['$MAKE -s --no-print-directory sigof01m']) + +test('sigof01i', + normal, + run_command, + ['$MAKE -s --no-print-directory sigof01i']) + +test('sigof01i2', + normal, + run_command, + ['$MAKE -s --no-print-directory sigof01i2']) diff --git a/testsuite/tests/driver/sigof01/sigof01i.script b/testsuite/tests/driver/sigof01/sigof01i.script new file mode 100644 index 0000000000..ba2906d066 --- /dev/null +++ b/testsuite/tests/driver/sigof01/sigof01i.script @@ -0,0 +1 @@ +main diff --git a/testsuite/tests/driver/sigof01/sigof01i.stdout b/testsuite/tests/driver/sigof01/sigof01i.stdout new file mode 100644 index 0000000000..bb614cd2a0 --- /dev/null +++ b/testsuite/tests/driver/sigof01/sigof01i.stdout @@ -0,0 +1,3 @@ +False +T +True diff --git a/testsuite/tests/driver/sigof01/sigof01i2.script b/testsuite/tests/driver/sigof01/sigof01i2.script new file mode 100644 index 0000000000..3a91e377a3 --- /dev/null +++ b/testsuite/tests/driver/sigof01/sigof01i2.script @@ -0,0 +1,3 @@ +:load B +:browse B +:issafe diff --git a/testsuite/tests/driver/sigof01/sigof01i2.stdout b/testsuite/tests/driver/sigof01/sigof01i2.stdout new file mode 100644 index 0000000000..ac15dcfa1e --- /dev/null +++ b/testsuite/tests/driver/sigof01/sigof01i2.stdout @@ -0,0 +1,8 @@ +class Foo a where + foo :: a -> a +data T = A.T +mkT :: T +x :: Bool +Trust type is (Module: Safe, Package: trusted) +Package Trust: Off +B is trusted! diff --git a/testsuite/tests/package/package09e.stderr b/testsuite/tests/package/package09e.stderr index 9cd00a2930..70c6f22d89 100644 --- a/testsuite/tests/package/package09e.stderr +++ b/testsuite/tests/package/package09e.stderr @@ -1,5 +1,5 @@ package09e.hs:2:1: Ambiguous interface for ‘M’: - it is bound as Data.Set by a package flag it is bound as Data.Map by a package flag + it is bound as Data.Set by a package flag |