[project @ 2000-12-19 10:50:51 by simonpj]
authorsimonpj <unknown>
Tue, 19 Dec 2000 10:50:51 +0000 (10:50 +0000)
committersimonpj <unknown>
Tue, 19 Dec 2000 10:50:51 +0000 (10:50 +0000)
Add two tests

ghc/tests/typecheck/should_fail/Makefile
ghc/tests/typecheck/should_fail/tcfail089.hs [new file with mode: 0644]
ghc/tests/typecheck/should_fail/tcfail089.stderr [new file with mode: 0644]
ghc/tests/typecheck/should_run/tcrun008.hs [new file with mode: 0644]
ghc/tests/typecheck/should_run/tcrun008.stdout [new file with mode: 0644]

index f3483b4..861ca1f 100644 (file)
@@ -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 (file)
index 0000000..78e2825
--- /dev/null
@@ -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 (file)
index 0000000..296dc16
--- /dev/null
@@ -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 (file)
index 0000000..2f4061a
--- /dev/null
@@ -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 (file)
index 0000000..f494982
--- /dev/null
@@ -0,0 +1,2 @@
+[3,3,3]
+[True,False]