From ee731a025c40926856d0ca8a410bcaa133006c7b Mon Sep 17 00:00:00 2001
From: sof <unknown>
Date: Mon, 5 Jul 1999 17:02:42 +0000
Subject: [PATCH] [project @ 1999-07-05 17:02:42 by sof] Two new Dark Corner
 regression tests:

- testing the derived Show&Read instances for constructors with
  a field label that is a varsym rather than a varid.
- check that the default fixity & assoc of an operator is 'infixl 9'.
---
 ghc/tests/deriving/should_run/Makefile        |  2 ++
 ghc/tests/deriving/should_run/drvrun004.hs    | 10 +++++++++
 .../deriving/should_run/drvrun004.stdout      |  2 ++
 ghc/tests/deriving/should_run/drvrun005.hs    | 22 +++++++++++++++++++
 .../deriving/should_run/drvrun005.stderr      |  2 ++
 5 files changed, 38 insertions(+)
 create mode 100644 ghc/tests/deriving/should_run/drvrun004.hs
 create mode 100644 ghc/tests/deriving/should_run/drvrun004.stdout
 create mode 100644 ghc/tests/deriving/should_run/drvrun005.hs
 create mode 100644 ghc/tests/deriving/should_run/drvrun005.stderr

diff --git a/ghc/tests/deriving/should_run/Makefile b/ghc/tests/deriving/should_run/Makefile
index 91428646c86a..d39565dce6b2 100644
--- a/ghc/tests/deriving/should_run/Makefile
+++ b/ghc/tests/deriving/should_run/Makefile
@@ -4,4 +4,6 @@ include $(TOP)/mk/should_run.mk
 
 SRC_HC_OPTS += -dcore-lint
 
+drvrun005_RUNTEST_OPTS += -fail
+
 include $(TOP)/mk/target.mk
diff --git a/ghc/tests/deriving/should_run/drvrun004.hs b/ghc/tests/deriving/should_run/drvrun004.hs
new file mode 100644
index 000000000000..f530803835d7
--- /dev/null
+++ b/ghc/tests/deriving/should_run/drvrun004.hs
@@ -0,0 +1,10 @@
+module Main where
+
+data Hash = Hash{ (#) :: Int }
+ deriving (Show, Read)
+
+main =
+  do print s
+     print (read s :: Hash)
+ where
+  s = show (Hash 3)
diff --git a/ghc/tests/deriving/should_run/drvrun004.stdout b/ghc/tests/deriving/should_run/drvrun004.stdout
new file mode 100644
index 000000000000..c9f6f36275e1
--- /dev/null
+++ b/ghc/tests/deriving/should_run/drvrun004.stdout
@@ -0,0 +1,2 @@
+"Hash{(#)=3}"
+Hash{(#)=3}
diff --git a/ghc/tests/deriving/should_run/drvrun005.hs b/ghc/tests/deriving/should_run/drvrun005.hs
new file mode 100644
index 000000000000..0d21690b2fa0
--- /dev/null
+++ b/ghc/tests/deriving/should_run/drvrun005.hs
@@ -0,0 +1,22 @@
+module Main where
+
+{-
+  If a fixity declaration hasn't been supplied for
+  an operator, it is defaulted to being "infixl 9".
+
+  The derived Read instances for data types containing
+  left-assoc constructors produces code that causes
+  non-termination if you use 'read' to evaluate them
+  ( (head (reads x)) is cool tho.)
+
+  ==> The inferred assoc for :++ below left & the derived
+  Read instance should fail to terminate (with ghc-4.xx,
+  this is exemplified by having the stack overflow.)
+-}
+-- infixl 9 :++
+data T = T1 |  T :++ T  deriving (Eq,Show, Read)
+
+t :: T
+t = read "T1"
+
+main = print t
diff --git a/ghc/tests/deriving/should_run/drvrun005.stderr b/ghc/tests/deriving/should_run/drvrun005.stderr
new file mode 100644
index 000000000000..68c824b709a2
--- /dev/null
+++ b/ghc/tests/deriving/should_run/drvrun005.stderr
@@ -0,0 +1,2 @@
+Stack space overflow: current size 1048576 bytes.
+Use `+RTS -Ksize' to increase it.
-- 
GitLab