summaryrefslogtreecommitdiff
path: root/testsuite/tests
diff options
context:
space:
mode:
authorKrzysztof Gogolewski <krz.gogolewski@gmail.com>2013-03-11 13:32:58 +0100
committerSimon Peyton Jones <simonpj@microsoft.com>2013-03-13 21:11:01 +0000
commitf3da8ce8a034f1c0e3dc9aa30faf721fea2ec70b (patch)
tree1fa84bceb1d6bdeb422171cc869c182d860bc465 /testsuite/tests
parent5039959790d35994bdc2f89049a63a38fd69871d (diff)
downloadhaskell-f3da8ce8a034f1c0e3dc9aa30faf721fea2ec70b.tar.gz
Tests for nullary type classes (#7642)
Diffstat (limited to 'testsuite/tests')
-rw-r--r--testsuite/tests/driver/T4437.hs3
-rw-r--r--testsuite/tests/typecheck/should_fail/TcNoNullaryTC.hs4
-rw-r--r--testsuite/tests/typecheck/should_fail/TcNoNullaryTC.stderr5
-rw-r--r--testsuite/tests/typecheck/should_fail/TcNullaryTCFail.hs6
-rw-r--r--testsuite/tests/typecheck/should_fail/TcNullaryTCFail.stderr5
-rw-r--r--testsuite/tests/typecheck/should_fail/all.T2
-rw-r--r--testsuite/tests/typecheck/should_run/TcNullaryTC.hs13
-rw-r--r--testsuite/tests/typecheck/should_run/TcNullaryTC.stdout1
-rwxr-xr-xtestsuite/tests/typecheck/should_run/all.T1
9 files changed, 39 insertions, 1 deletions
diff --git a/testsuite/tests/driver/T4437.hs b/testsuite/tests/driver/T4437.hs
index 617484c6cd..cb1d5f80a2 100644
--- a/testsuite/tests/driver/T4437.hs
+++ b/testsuite/tests/driver/T4437.hs
@@ -39,7 +39,8 @@ expectedGhcOnlyExtensions = [
"TypeHoles",
"OverloadedLists",
"EmptyCase",
- "AutoDeriveTypeable"]
+ "AutoDeriveTypeable",
+ "NullaryTypeClasses"]
expectedCabalOnlyExtensions :: [String]
expectedCabalOnlyExtensions = ["Generics",
diff --git a/testsuite/tests/typecheck/should_fail/TcNoNullaryTC.hs b/testsuite/tests/typecheck/should_fail/TcNoNullaryTC.hs
new file mode 100644
index 0000000000..de5e4436f7
--- /dev/null
+++ b/testsuite/tests/typecheck/should_fail/TcNoNullaryTC.hs
@@ -0,0 +1,4 @@
+module NoNullaryTC where
+
+class A where
+ f :: a -> a
diff --git a/testsuite/tests/typecheck/should_fail/TcNoNullaryTC.stderr b/testsuite/tests/typecheck/should_fail/TcNoNullaryTC.stderr
new file mode 100644
index 0000000000..9619004988
--- /dev/null
+++ b/testsuite/tests/typecheck/should_fail/TcNoNullaryTC.stderr
@@ -0,0 +1,5 @@
+
+TcNoNullaryTC.hs:3:1:
+ No parameters for class ‛A’
+ (Use -XNullaryTypeClasses to allow no-parameter classes)
+ In the class declaration for ‛A’
diff --git a/testsuite/tests/typecheck/should_fail/TcNullaryTCFail.hs b/testsuite/tests/typecheck/should_fail/TcNullaryTCFail.hs
new file mode 100644
index 0000000000..b127300b75
--- /dev/null
+++ b/testsuite/tests/typecheck/should_fail/TcNullaryTCFail.hs
@@ -0,0 +1,6 @@
+{-# LANGUAGE NullaryTypeClasses #-}
+module TcNullaryTCFail where
+
+class A
+instance A
+instance A
diff --git a/testsuite/tests/typecheck/should_fail/TcNullaryTCFail.stderr b/testsuite/tests/typecheck/should_fail/TcNullaryTCFail.stderr
new file mode 100644
index 0000000000..1dd7ba2f74
--- /dev/null
+++ b/testsuite/tests/typecheck/should_fail/TcNullaryTCFail.stderr
@@ -0,0 +1,5 @@
+
+TcNullaryTCFail.hs:5:10:
+ Duplicate instance declarations:
+ instance A -- Defined at TcNullaryTCFail.hs:5:10
+ instance A -- Defined at TcNullaryTCFail.hs:6:10
diff --git a/testsuite/tests/typecheck/should_fail/all.T b/testsuite/tests/typecheck/should_fail/all.T
index bb4d220875..f1bc64f398 100644
--- a/testsuite/tests/typecheck/should_fail/all.T
+++ b/testsuite/tests/typecheck/should_fail/all.T
@@ -301,3 +301,5 @@ test('T7734', normal, compile_fail, [''])
test('T7697', normal, compile_fail, [''])
test('T7696', normal, compile_fail, [''])
test('T7748a', normal, compile_fail, [''])
+test('TcNoNullaryTC', when(compiler_lt('ghc', '7.7'), skip), compile_fail, [''])
+test('TcNullaryTCFail', when(compiler_lt('ghc', '7.7'), skip), compile_fail, [''])
diff --git a/testsuite/tests/typecheck/should_run/TcNullaryTC.hs b/testsuite/tests/typecheck/should_run/TcNullaryTC.hs
new file mode 100644
index 0000000000..a94d3058b0
--- /dev/null
+++ b/testsuite/tests/typecheck/should_run/TcNullaryTC.hs
@@ -0,0 +1,13 @@
+{-# LANGUAGE NullaryTypeClasses #-}
+
+module Main where
+
+class R where
+ f :: Int -> Int
+ g :: a -> a
+
+instance R where
+ f = (+1)
+ g = id
+
+main = print (g (f 0))
diff --git a/testsuite/tests/typecheck/should_run/TcNullaryTC.stdout b/testsuite/tests/typecheck/should_run/TcNullaryTC.stdout
new file mode 100644
index 0000000000..d00491fd7e
--- /dev/null
+++ b/testsuite/tests/typecheck/should_run/TcNullaryTC.stdout
@@ -0,0 +1 @@
+1
diff --git a/testsuite/tests/typecheck/should_run/all.T b/testsuite/tests/typecheck/should_run/all.T
index 0049769f39..55d88ec963 100755
--- a/testsuite/tests/typecheck/should_run/all.T
+++ b/testsuite/tests/typecheck/should_run/all.T
@@ -108,3 +108,4 @@ test('T6117', normal, compile_and_run, [''])
test('T5751', normal, compile_and_run, [''])
test('T5913', normal, compile_and_run, [''])
test('T7748', normal, compile_and_run, [''])
+test('TcNullaryTC', when(compiler_lt('ghc', '7.7'), skip), compile_and_run, [''])