From 53389e36dc0471b5058cf310e9709e13f41fdbc8 Mon Sep 17 00:00:00 2001 From: simonpj Date: Tue, 19 Dec 2000 10:50:51 +0000 Subject: [PATCH] [project @ 2000-12-19 10:50:51 by simonpj] Add two tests --- ghc/tests/typecheck/should_fail/Makefile | 2 ++ ghc/tests/typecheck/should_fail/tcfail089.hs | 10 ++++++++ ghc/tests/typecheck/should_fail/tcfail089.stderr | 5 ++++ ghc/tests/typecheck/should_run/tcrun008.hs | 28 ++++++++++++++++++++++ ghc/tests/typecheck/should_run/tcrun008.stdout | 2 ++ 5 files changed, 47 insertions(+) create mode 100644 ghc/tests/typecheck/should_fail/tcfail089.hs create mode 100644 ghc/tests/typecheck/should_fail/tcfail089.stderr create mode 100644 ghc/tests/typecheck/should_run/tcrun008.hs create mode 100644 ghc/tests/typecheck/should_run/tcrun008.stdout diff --git a/ghc/tests/typecheck/should_fail/Makefile b/ghc/tests/typecheck/should_fail/Makefile index f3483b4..861ca1f 100644 --- a/ghc/tests/typecheck/should_fail/Makefile +++ b/ghc/tests/typecheck/should_fail/Makefile @@ -10,6 +10,8 @@ HS_SRCS = $(wildcard *.hs) tcfail045_HC_OPTS = -fglasgow-exts -package lang tcfail068_HC_OPTS = -fglasgow-exts -package lang tcfail080_HC_OPTS = -fglasgow-exts -package lang +tcfail089_HC_OPTS = -O +# The -O can't go in {-# OPTIONS #-} because it's static Inst82_1.o : Inst82_1.hs Data82.hi $(HC) $(HC_OPTS) -c $< -o $@ diff --git a/ghc/tests/typecheck/should_fail/tcfail089.hs b/ghc/tests/typecheck/should_fail/tcfail089.hs new file mode 100644 index 0000000..78e2825 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail089.hs @@ -0,0 +1,10 @@ +{-# OPTIONS -fglasgow-exts #-} + +-- !!! Check non-constructors in patterns fail tidily +-- !!! The -O made ghc 4.08 go into a loop! +-- Unfortunately the -O has to go in the Makefile + +module ShouldFail where + +compute :: String -> String +compute ("hd" ++ _) = "_" diff --git a/ghc/tests/typecheck/should_fail/tcfail089.stderr b/ghc/tests/typecheck/should_fail/tcfail089.stderr new file mode 100644 index 0000000..296dc16 --- /dev/null +++ b/ghc/tests/typecheck/should_fail/tcfail089.stderr @@ -0,0 +1,5 @@ + +tcfail089.hs:10: + `++' is not a data constructor + In the pattern: "hd" ++ _ + In an equation for function `compute': compute ("hd" ++ _) = "_" diff --git a/ghc/tests/typecheck/should_run/tcrun008.hs b/ghc/tests/typecheck/should_run/tcrun008.hs new file mode 100644 index 0000000..2f4061a --- /dev/null +++ b/ghc/tests/typecheck/should_run/tcrun008.hs @@ -0,0 +1,28 @@ +{-# OPTIONS -fglasgow-exts #-} + +-- !!! Check that record selectors for polymorphic fields work right + +module Main where + +import IO + +class Foo a where + bar :: a -> [a] + +instance Foo Int where + bar x = replicate x x + +instance Foo Bool where + bar x = [x, not x] + +data Record = R { + blub :: Foo a => a -> [a] + } + +main = do { let r = R {blub = bar} + ; print (blub r (3::Int)) + ; print (blub r True) + } + + + diff --git a/ghc/tests/typecheck/should_run/tcrun008.stdout b/ghc/tests/typecheck/should_run/tcrun008.stdout new file mode 100644 index 0000000..f494982 --- /dev/null +++ b/ghc/tests/typecheck/should_run/tcrun008.stdout @@ -0,0 +1,2 @@ +[3,3,3] +[True,False] -- 1.7.10.4