summaryrefslogtreecommitdiff
path: root/ghc/compiler/tests/deriving
diff options
context:
space:
mode:
Diffstat (limited to 'ghc/compiler/tests/deriving')
-rw-r--r--ghc/compiler/tests/deriving/Jmakefile9
-rw-r--r--ghc/compiler/tests/deriving/drv001.hs19
-rw-r--r--ghc/compiler/tests/deriving/drv001.stderr0
-rw-r--r--ghc/compiler/tests/deriving/drv002.hs11
-rw-r--r--ghc/compiler/tests/deriving/drv002.stderr0
-rw-r--r--ghc/compiler/tests/deriving/drv003.hs15
-rw-r--r--ghc/compiler/tests/deriving/drv003.stderr0
-rw-r--r--ghc/compiler/tests/deriving/drv004.hs6
-rw-r--r--ghc/compiler/tests/deriving/drv004.stderr0
-rw-r--r--ghc/compiler/tests/deriving/drv005.hs4
-rw-r--r--ghc/compiler/tests/deriving/drv005.stderr0
-rw-r--r--ghc/compiler/tests/deriving/drv006.hs6
-rw-r--r--ghc/compiler/tests/deriving/drv006.stderr0
-rw-r--r--ghc/compiler/tests/deriving/drv007.hs3
-rw-r--r--ghc/compiler/tests/deriving/drv007.stderr0
15 files changed, 73 insertions, 0 deletions
diff --git a/ghc/compiler/tests/deriving/Jmakefile b/ghc/compiler/tests/deriving/Jmakefile
new file mode 100644
index 0000000000..e676c5c14c
--- /dev/null
+++ b/ghc/compiler/tests/deriving/Jmakefile
@@ -0,0 +1,9 @@
+TEST_FLAGS=-noC -ddump-tc -dcore-lint -hi
+
+RunStdTest(drv001,$(GHC),$(TEST_FLAGS) drv001.hs -o2 drv001.stderr)
+RunStdTest(drv002,$(GHC),$(TEST_FLAGS) drv002.hs -o2 drv002.stderr)
+RunStdTest(drv003,$(GHC),$(TEST_FLAGS) drv003.hs -o2 drv003.stderr)
+RunStdTest(drv004,$(GHC),$(TEST_FLAGS) drv004.hs -o2 drv004.stderr)
+RunStdTest(drv005,$(GHC),$(TEST_FLAGS) drv005.hs -o2 drv005.stderr)
+RunStdTest(drv006,$(GHC),$(TEST_FLAGS) drv006.hs -o2 drv006.stderr)
+RunStdTest(drv007,$(GHC),$(TEST_FLAGS) drv007.hs -o2 drv007.stderr)
diff --git a/ghc/compiler/tests/deriving/drv001.hs b/ghc/compiler/tests/deriving/drv001.hs
new file mode 100644
index 0000000000..707a05d9ba
--- /dev/null
+++ b/ghc/compiler/tests/deriving/drv001.hs
@@ -0,0 +1,19 @@
+--!!! canonical weird example for "deriving"
+
+data X a b
+ = C1 (T a)
+ | C2 (Y b)
+ | C3 (X b a)
+ deriving Text
+
+data Y b
+ = D1
+ | D2 (X Int b)
+ deriving Text
+
+data T a
+ = E1
+
+instance Eq a => Text (T a) where
+ showsPrec = error "show"
+ readsPrec = error "read"
diff --git a/ghc/compiler/tests/deriving/drv001.stderr b/ghc/compiler/tests/deriving/drv001.stderr
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/ghc/compiler/tests/deriving/drv001.stderr
diff --git a/ghc/compiler/tests/deriving/drv002.hs b/ghc/compiler/tests/deriving/drv002.hs
new file mode 100644
index 0000000000..e8855f2600
--- /dev/null
+++ b/ghc/compiler/tests/deriving/drv002.hs
@@ -0,0 +1,11 @@
+data Z a b
+ = C1 (T a)
+ | C2 (Z [a] [b])
+ deriving Text
+
+data T a
+ = E1
+
+instance Eq a => Text (T a) where
+ showsPrec = error "show"
+ readsPrec = error "read"
diff --git a/ghc/compiler/tests/deriving/drv002.stderr b/ghc/compiler/tests/deriving/drv002.stderr
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/ghc/compiler/tests/deriving/drv002.stderr
diff --git a/ghc/compiler/tests/deriving/drv003.hs b/ghc/compiler/tests/deriving/drv003.hs
new file mode 100644
index 0000000000..3da22bd9d0
--- /dev/null
+++ b/ghc/compiler/tests/deriving/drv003.hs
@@ -0,0 +1,15 @@
+--!!! This is the example given in TcDeriv
+--
+data T a b
+ = C1 (Foo a) (Bar b)
+ | C2 Int (T b a)
+ | C3 (T a a)
+ deriving Eq
+
+data Foo a = MkFoo Double a deriving ()
+instance (Eq a) => Eq (Foo a)
+
+data Bar a = MkBar Int Int deriving ()
+instance (Ping b) => Eq (Bar b)
+
+class Ping a
diff --git a/ghc/compiler/tests/deriving/drv003.stderr b/ghc/compiler/tests/deriving/drv003.stderr
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/ghc/compiler/tests/deriving/drv003.stderr
diff --git a/ghc/compiler/tests/deriving/drv004.hs b/ghc/compiler/tests/deriving/drv004.hs
new file mode 100644
index 0000000000..9863e3ae3d
--- /dev/null
+++ b/ghc/compiler/tests/deriving/drv004.hs
@@ -0,0 +1,6 @@
+--!!! simple example of deriving Ord (and, implicitly, Eq)
+--
+data Foo a b
+ = C1 a Int
+ | C2 b Double
+ deriving Ord
diff --git a/ghc/compiler/tests/deriving/drv004.stderr b/ghc/compiler/tests/deriving/drv004.stderr
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/ghc/compiler/tests/deriving/drv004.stderr
diff --git a/ghc/compiler/tests/deriving/drv005.hs b/ghc/compiler/tests/deriving/drv005.hs
new file mode 100644
index 0000000000..cef5fe6a5b
--- /dev/null
+++ b/ghc/compiler/tests/deriving/drv005.hs
@@ -0,0 +1,4 @@
+--!!! simple example of deriving Enum
+--
+data Foo = Foo1 | Foo2 | Foo3 | Foo4 | Foo5 | Foo6 | Foo7 | Foo8
+ deriving Enum
diff --git a/ghc/compiler/tests/deriving/drv005.stderr b/ghc/compiler/tests/deriving/drv005.stderr
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/ghc/compiler/tests/deriving/drv005.stderr
diff --git a/ghc/compiler/tests/deriving/drv006.hs b/ghc/compiler/tests/deriving/drv006.hs
new file mode 100644
index 0000000000..a6d6d1c645
--- /dev/null
+++ b/ghc/compiler/tests/deriving/drv006.hs
@@ -0,0 +1,6 @@
+--!!! simple examples of deriving Ix
+--
+data Foo = Foo1 | Foo2 | Foo3 | Foo4 | Foo5 | Foo6 | Foo7 | Foo8
+ deriving Ix
+
+data Bar a b = MkBar a Int b Integer a
diff --git a/ghc/compiler/tests/deriving/drv006.stderr b/ghc/compiler/tests/deriving/drv006.stderr
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/ghc/compiler/tests/deriving/drv006.stderr
diff --git a/ghc/compiler/tests/deriving/drv007.hs b/ghc/compiler/tests/deriving/drv007.hs
new file mode 100644
index 0000000000..c1bbab1bae
--- /dev/null
+++ b/ghc/compiler/tests/deriving/drv007.hs
@@ -0,0 +1,3 @@
+--!!! buggy deriving with function type, reported by Sigbjorn Finne
+
+data Foo = Foo (Int -> Int) deriving Eq
diff --git a/ghc/compiler/tests/deriving/drv007.stderr b/ghc/compiler/tests/deriving/drv007.stderr
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/ghc/compiler/tests/deriving/drv007.stderr