summaryrefslogtreecommitdiff
path: root/testsuite/tests/annotations
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/tests/annotations')
-rw-r--r--testsuite/tests/annotations/Makefile3
-rw-r--r--testsuite/tests/annotations/should_compile/Makefile3
-rw-r--r--testsuite/tests/annotations/should_compile/all.T25
-rw-r--r--testsuite/tests/annotations/should_compile/ann01.hs38
-rw-r--r--testsuite/tests/annotations/should_compile/ann01.stderr0
-rw-r--r--testsuite/tests/annotations/should_fail/Annfail04_Help.hs4
-rw-r--r--testsuite/tests/annotations/should_fail/Annfail05_Help.hs3
-rw-r--r--testsuite/tests/annotations/should_fail/Annfail06_Help.hs3
-rw-r--r--testsuite/tests/annotations/should_fail/Makefile3
-rw-r--r--testsuite/tests/annotations/should_fail/all.T34
-rw-r--r--testsuite/tests/annotations/should_fail/annfail01.hs5
-rw-r--r--testsuite/tests/annotations/should_fail/annfail01.stderr4
-rw-r--r--testsuite/tests/annotations/should_fail/annfail02.hs7
-rw-r--r--testsuite/tests/annotations/should_fail/annfail02.stderr4
-rw-r--r--testsuite/tests/annotations/should_fail/annfail03.hs18
-rw-r--r--testsuite/tests/annotations/should_fail/annfail03.stderr7
-rw-r--r--testsuite/tests/annotations/should_fail/annfail04.hs15
-rw-r--r--testsuite/tests/annotations/should_fail/annfail04.stderr7
-rw-r--r--testsuite/tests/annotations/should_fail/annfail05.hs12
-rw-r--r--testsuite/tests/annotations/should_fail/annfail05.stderr8
-rw-r--r--testsuite/tests/annotations/should_fail/annfail06.hs22
-rw-r--r--testsuite/tests/annotations/should_fail/annfail06.stderr7
-rw-r--r--testsuite/tests/annotations/should_fail/annfail07.hs10
-rw-r--r--testsuite/tests/annotations/should_fail/annfail07.stderr6
-rw-r--r--testsuite/tests/annotations/should_fail/annfail08.hs10
-rw-r--r--testsuite/tests/annotations/should_fail/annfail08.stderr16
-rw-r--r--testsuite/tests/annotations/should_fail/annfail09.hs12
-rw-r--r--testsuite/tests/annotations/should_fail/annfail09.stderr7
-rw-r--r--testsuite/tests/annotations/should_fail/annfail10.hs10
-rw-r--r--testsuite/tests/annotations/should_fail/annfail10.stderr9
-rw-r--r--testsuite/tests/annotations/should_fail/annfail11.hs4
-rw-r--r--testsuite/tests/annotations/should_fail/annfail11.stderr4
-rw-r--r--testsuite/tests/annotations/should_fail/annfail12.hs6
-rw-r--r--testsuite/tests/annotations/should_fail/annfail12.stderr8
-rw-r--r--testsuite/tests/annotations/should_fail/annfail13.hs6
-rw-r--r--testsuite/tests/annotations/should_fail/annfail13.stderr2
-rw-r--r--testsuite/tests/annotations/should_run/Annrun01_Help.hs27
-rw-r--r--testsuite/tests/annotations/should_run/Makefile12
-rw-r--r--testsuite/tests/annotations/should_run/all.T31
-rw-r--r--testsuite/tests/annotations/should_run/annrun01.hs49
-rw-r--r--testsuite/tests/annotations/should_run/annrun01.stdout13
41 files changed, 474 insertions, 0 deletions
diff --git a/testsuite/tests/annotations/Makefile b/testsuite/tests/annotations/Makefile
new file mode 100644
index 0000000000..9a36a1c5fe
--- /dev/null
+++ b/testsuite/tests/annotations/Makefile
@@ -0,0 +1,3 @@
+TOP=../..
+include $(TOP)/mk/boilerplate.mk
+include $(TOP)/mk/test.mk
diff --git a/testsuite/tests/annotations/should_compile/Makefile b/testsuite/tests/annotations/should_compile/Makefile
new file mode 100644
index 0000000000..9101fbd40a
--- /dev/null
+++ b/testsuite/tests/annotations/should_compile/Makefile
@@ -0,0 +1,3 @@
+TOP=../../..
+include $(TOP)/mk/boilerplate.mk
+include $(TOP)/mk/test.mk
diff --git a/testsuite/tests/annotations/should_compile/all.T b/testsuite/tests/annotations/should_compile/all.T
new file mode 100644
index 0000000000..e13c24e72b
--- /dev/null
+++ b/testsuite/tests/annotations/should_compile/all.T
@@ -0,0 +1,25 @@
+
+setTestOpts(if_compiler_profiled(skip))
+
+# Annotations, like Template Haskell, require runtime evaluation. In
+# order for this to work with profiling, we would have to build the
+# program twice and use -osuf p_o (see the TH_splitE5_prof test). For
+# now, just disable the profiling ways.
+test('ann01',
+ [req_interp, omit_ways(['profasm','profthreaded'])],
+ compile,
+ ['-v0'])
+
+""""
+Helpful things to C+P:
+
+test('', normal, compile_fail, [''])
+
+test('', normal, compile, [''])
+
+test('', extra_clean(['.hi', '.o']),
+ multimod_compile_fail, ['', '-v0'])
+
+test('', extra_clean(['.hi', '.o']),
+ multimod_compile, ['', '-v0'])
+"""
diff --git a/testsuite/tests/annotations/should_compile/ann01.hs b/testsuite/tests/annotations/should_compile/ann01.hs
new file mode 100644
index 0000000000..134930787f
--- /dev/null
+++ b/testsuite/tests/annotations/should_compile/ann01.hs
@@ -0,0 +1,38 @@
+{-# LANGUAGE TemplateHaskell #-}
+
+module Ann01 where
+
+{-# ANN module (1 :: Int) #-}
+{-# ANN module (1 :: Integer) #-}
+{-# ANN module (1 :: Double) #-}
+{-# ANN module $([| 1 :: Int |]) #-}
+{-# ANN module "Hello" #-}
+{-# ANN module (Just (1 :: Int)) #-}
+{-# ANN module [1 :: Int, 2, 3] #-}
+{-# ANN module ([1..10] :: [Integer]) #-}
+{-# ANN module ''Foo #-}
+{-# ANN module (-1 :: Int) #-}
+
+{-# ANN type Foo (1 :: Int) #-}
+{-# ANN type Foo (1 :: Integer) #-}
+{-# ANN type Foo (1 :: Double) #-}
+{-# ANN type Foo $([| 1 :: Int |]) #-}
+{-# ANN type Foo "Hello" #-}
+{-# ANN type Foo (Just (1 :: Int)) #-}
+{-# ANN type Foo [1 :: Int, 2, 3] #-}
+{-# ANN type Foo ([1..10] :: [Integer]) #-}
+{-# ANN type Foo ''Foo #-}
+{-# ANN type Foo (-1 :: Int) #-}
+data Foo = Bar Int
+
+{-# ANN f (1 :: Int) #-}
+{-# ANN f (1 :: Integer) #-}
+{-# ANN f (1 :: Double) #-}
+{-# ANN f $([| 1 :: Int |]) #-}
+{-# ANN f "Hello" #-}
+{-# ANN f (Just (1 :: Int)) #-}
+{-# ANN f [1 :: Int, 2, 3] #-}
+{-# ANN f ([1..10] :: [Integer]) #-}
+{-# ANN f 'f #-}
+{-# ANN f (-1 :: Int) #-}
+f x = x
diff --git a/testsuite/tests/annotations/should_compile/ann01.stderr b/testsuite/tests/annotations/should_compile/ann01.stderr
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/testsuite/tests/annotations/should_compile/ann01.stderr
diff --git a/testsuite/tests/annotations/should_fail/Annfail04_Help.hs b/testsuite/tests/annotations/should_fail/Annfail04_Help.hs
new file mode 100644
index 0000000000..55cbe99884
--- /dev/null
+++ b/testsuite/tests/annotations/should_fail/Annfail04_Help.hs
@@ -0,0 +1,4 @@
+module Annfail04_Help where
+
+class Thing a where
+ thing :: a \ No newline at end of file
diff --git a/testsuite/tests/annotations/should_fail/Annfail05_Help.hs b/testsuite/tests/annotations/should_fail/Annfail05_Help.hs
new file mode 100644
index 0000000000..1300c091ca
--- /dev/null
+++ b/testsuite/tests/annotations/should_fail/Annfail05_Help.hs
@@ -0,0 +1,3 @@
+module Annfail05_Help where
+
+data NoInstances = NoInstances \ No newline at end of file
diff --git a/testsuite/tests/annotations/should_fail/Annfail06_Help.hs b/testsuite/tests/annotations/should_fail/Annfail06_Help.hs
new file mode 100644
index 0000000000..224181f261
--- /dev/null
+++ b/testsuite/tests/annotations/should_fail/Annfail06_Help.hs
@@ -0,0 +1,3 @@
+module Annfail06_Help where
+
+data InstancesInWrongModule = InstancesInWrongModule \ No newline at end of file
diff --git a/testsuite/tests/annotations/should_fail/Makefile b/testsuite/tests/annotations/should_fail/Makefile
new file mode 100644
index 0000000000..9101fbd40a
--- /dev/null
+++ b/testsuite/tests/annotations/should_fail/Makefile
@@ -0,0 +1,3 @@
+TOP=../../..
+include $(TOP)/mk/boilerplate.mk
+include $(TOP)/mk/test.mk
diff --git a/testsuite/tests/annotations/should_fail/all.T b/testsuite/tests/annotations/should_fail/all.T
new file mode 100644
index 0000000000..21eaa765c3
--- /dev/null
+++ b/testsuite/tests/annotations/should_fail/all.T
@@ -0,0 +1,34 @@
+
+test('annfail01', normal, compile_fail, [''])
+test('annfail02', normal, compile_fail, [''])
+test('annfail03', req_interp, compile_fail, [''])
+test('annfail04',
+ [req_interp, extra_clean(['Annfail04_Help.hi', 'Annfail04_Help.o'])],
+ multimod_compile_fail, ['annfail04', '-v0'])
+test('annfail05',
+ [req_interp, extra_clean(['Annfail05_Help.hi', 'Annfail05_Help.o'])],
+ multimod_compile_fail, ['annfail05', '-v0'])
+test('annfail06',
+ [req_interp, extra_clean(['Annfail06_Help.hi', 'Annfail06_Help.o'])],
+ multimod_compile_fail, ['annfail06', '-v0'])
+test('annfail07', req_interp, compile_fail, [''])
+test('annfail08', req_interp, compile_fail, [''])
+test('annfail09', req_interp, compile_fail, [''])
+test('annfail10', req_interp, compile_fail, [''])
+test('annfail11', normal, compile_fail, [''])
+test('annfail12', req_interp, compile_fail, ['-v0'])
+test('annfail13', normal, compile_fail, [''])
+
+""""
+Helpful things to C+P:
+
+test('', normal, compile_fail, [''])
+
+test('', normal, compile, [''])
+
+test('', extra_clean(['.hi', '.o']),
+ multimod_compile_fail, ['', '-v0'])
+
+test('', extra_clean(['.hi', '.o']),
+ multimod_compile, ['', '-v0'])
+"""
diff --git a/testsuite/tests/annotations/should_fail/annfail01.hs b/testsuite/tests/annotations/should_fail/annfail01.hs
new file mode 100644
index 0000000000..c5a8c29e5b
--- /dev/null
+++ b/testsuite/tests/annotations/should_fail/annfail01.hs
@@ -0,0 +1,5 @@
+module Annfail01 where
+-- Testing annotating things that don't exist
+
+{-# ANN type Foo (1 :: Int) #-}
+{-# ANN f (1 :: Int) #-} \ No newline at end of file
diff --git a/testsuite/tests/annotations/should_fail/annfail01.stderr b/testsuite/tests/annotations/should_fail/annfail01.stderr
new file mode 100644
index 0000000000..70553f983f
--- /dev/null
+++ b/testsuite/tests/annotations/should_fail/annfail01.stderr
@@ -0,0 +1,4 @@
+
+annfail01.hs:4:1: Not in scope: type constructor or class `Foo'
+
+annfail01.hs:5:1: Not in scope: `f'
diff --git a/testsuite/tests/annotations/should_fail/annfail02.hs b/testsuite/tests/annotations/should_fail/annfail02.hs
new file mode 100644
index 0000000000..50154e752c
--- /dev/null
+++ b/testsuite/tests/annotations/should_fail/annfail02.hs
@@ -0,0 +1,7 @@
+module Annfail02 where
+-- Testing annotating things that don't exist in the right namespace
+
+data Foo = Bar
+
+{-# ANN Foo (1 :: Int) #-}
+{-# ANN type Bar (2 :: Int) #-} \ No newline at end of file
diff --git a/testsuite/tests/annotations/should_fail/annfail02.stderr b/testsuite/tests/annotations/should_fail/annfail02.stderr
new file mode 100644
index 0000000000..83d54f9840
--- /dev/null
+++ b/testsuite/tests/annotations/should_fail/annfail02.stderr
@@ -0,0 +1,4 @@
+
+annfail02.hs:6:1: Not in scope: data constructor `Foo'
+
+annfail02.hs:7:1: Not in scope: type constructor or class `Bar'
diff --git a/testsuite/tests/annotations/should_fail/annfail03.hs b/testsuite/tests/annotations/should_fail/annfail03.hs
new file mode 100644
index 0000000000..c3e2a82323
--- /dev/null
+++ b/testsuite/tests/annotations/should_fail/annfail03.hs
@@ -0,0 +1,18 @@
+{-# LANGUAGE DeriveDataTypeable #-}
+
+module Annfail03 where
+-- Testing annotating something with a value defined + Typeabled / Dataed in same module
+
+import Data.Data
+import Data.Typeable
+
+data InModule = InModule
+ deriving (Typeable, Data)
+
+{-# ANN module InModule #-}
+
+{-# ANN type Foo InModule #-}
+data Foo = Bar
+
+{-# ANN f InModule #-}
+f x = x \ No newline at end of file
diff --git a/testsuite/tests/annotations/should_fail/annfail03.stderr b/testsuite/tests/annotations/should_fail/annfail03.stderr
new file mode 100644
index 0000000000..a7be7feb93
--- /dev/null
+++ b/testsuite/tests/annotations/should_fail/annfail03.stderr
@@ -0,0 +1,7 @@
+
+annfail03.hs:17:1:
+ GHC stage restriction: instance for `Data InModule'
+ is used in a top-level splice or annotation,
+ and must be imported, not defined locally
+ In the expression: InModule
+ In the annotation: {-# ANN f InModule #-}
diff --git a/testsuite/tests/annotations/should_fail/annfail04.hs b/testsuite/tests/annotations/should_fail/annfail04.hs
new file mode 100644
index 0000000000..352850e07d
--- /dev/null
+++ b/testsuite/tests/annotations/should_fail/annfail04.hs
@@ -0,0 +1,15 @@
+module Annfail04 where
+
+import Annfail04_Help
+-- Testing that we detect the use of instances defined in the same module
+
+instance Thing Int where
+ thing = 1
+
+{-# ANN module (thing :: Int) #-}
+
+{-# ANN type Foo (thing :: Int) #-}
+data Foo = Bar
+
+{-# ANN f (thing :: Int) #-}
+f x = x \ No newline at end of file
diff --git a/testsuite/tests/annotations/should_fail/annfail04.stderr b/testsuite/tests/annotations/should_fail/annfail04.stderr
new file mode 100644
index 0000000000..dcbe0e7945
--- /dev/null
+++ b/testsuite/tests/annotations/should_fail/annfail04.stderr
@@ -0,0 +1,7 @@
+
+annfail04.hs:14:12:
+ GHC stage restriction: instance for `Thing Int'
+ is used in a top-level splice or annotation,
+ and must be imported, not defined locally
+ In the expression: (thing :: Int)
+ In the annotation: {-# ANN f (thing :: Int) #-}
diff --git a/testsuite/tests/annotations/should_fail/annfail05.hs b/testsuite/tests/annotations/should_fail/annfail05.hs
new file mode 100644
index 0000000000..8657fd4ab6
--- /dev/null
+++ b/testsuite/tests/annotations/should_fail/annfail05.hs
@@ -0,0 +1,12 @@
+module Annfail05 where
+
+import Annfail05_Help
+-- Testing annotating with a value that is not Typeable or Data-able
+
+{-# ANN module NoInstances #-}
+
+{-# ANN type Foo NoInstances #-}
+data Foo = Bar
+
+{-# ANN f NoInstances #-}
+f x = x \ No newline at end of file
diff --git a/testsuite/tests/annotations/should_fail/annfail05.stderr b/testsuite/tests/annotations/should_fail/annfail05.stderr
new file mode 100644
index 0000000000..4e861c6b97
--- /dev/null
+++ b/testsuite/tests/annotations/should_fail/annfail05.stderr
@@ -0,0 +1,8 @@
+
+annfail05.hs:11:1:
+ No instance for (Data.Data.Data NoInstances)
+ arising from an annotation
+ Possible fix:
+ add an instance declaration for (Data.Data.Data NoInstances)
+ In the expression: NoInstances
+ In the annotation: {-# ANN f NoInstances #-}
diff --git a/testsuite/tests/annotations/should_fail/annfail06.hs b/testsuite/tests/annotations/should_fail/annfail06.hs
new file mode 100644
index 0000000000..51c922098a
--- /dev/null
+++ b/testsuite/tests/annotations/should_fail/annfail06.hs
@@ -0,0 +1,22 @@
+module Annfail06 where
+-- Testing that we don't accept Typeable or Data instances defined in the same module
+
+import Annfail06_Help
+
+import Data.Data
+import Data.Typeable
+
+instance Typeable InstancesInWrongModule where
+ typeOf _ = undefined
+
+instance Data InstancesInWrongModule where
+ gfoldl = undefined
+ gunfold = undefined
+
+{-# ANN module InstancesInWrongModule #-}
+
+{-# ANN type Foo InstancesInWrongModule #-}
+data Foo = Bar
+
+{-# ANN f InstancesInWrongModule #-}
+f x = x \ No newline at end of file
diff --git a/testsuite/tests/annotations/should_fail/annfail06.stderr b/testsuite/tests/annotations/should_fail/annfail06.stderr
new file mode 100644
index 0000000000..c5082c386e
--- /dev/null
+++ b/testsuite/tests/annotations/should_fail/annfail06.stderr
@@ -0,0 +1,7 @@
+
+annfail06.hs:21:1:
+ GHC stage restriction: instance for `Data InstancesInWrongModule'
+ is used in a top-level splice or annotation,
+ and must be imported, not defined locally
+ In the expression: InstancesInWrongModule
+ In the annotation: {-# ANN f InstancesInWrongModule #-}
diff --git a/testsuite/tests/annotations/should_fail/annfail07.hs b/testsuite/tests/annotations/should_fail/annfail07.hs
new file mode 100644
index 0000000000..732a66a3e4
--- /dev/null
+++ b/testsuite/tests/annotations/should_fail/annfail07.hs
@@ -0,0 +1,10 @@
+module Annfail07 where
+-- Testing normal type errors in annotations
+
+{-# ANN module (head True) #-}
+
+{-# ANN type Foo (head True) #-}
+data Foo = Bar
+
+{-# ANN f (head True) #-}
+f x = x \ No newline at end of file
diff --git a/testsuite/tests/annotations/should_fail/annfail07.stderr b/testsuite/tests/annotations/should_fail/annfail07.stderr
new file mode 100644
index 0000000000..01f4b62c45
--- /dev/null
+++ b/testsuite/tests/annotations/should_fail/annfail07.stderr
@@ -0,0 +1,6 @@
+
+annfail07.hs:9:17:
+ Couldn't match expected type `[a0]' with actual type `Bool'
+ In the first argument of `head', namely `True'
+ In the expression: (head True)
+ In the annotation: {-# ANN f (head True) #-}
diff --git a/testsuite/tests/annotations/should_fail/annfail08.hs b/testsuite/tests/annotations/should_fail/annfail08.hs
new file mode 100644
index 0000000000..c2b3a1ae19
--- /dev/null
+++ b/testsuite/tests/annotations/should_fail/annfail08.hs
@@ -0,0 +1,10 @@
+module Annfail08 where
+-- Testing instance type errors in annotations
+
+{-# ANN module (id + 1) #-}
+
+{-# ANN type Foo (id + 1) #-}
+data Foo = Bar
+
+{-# ANN f (id + 1) #-}
+f x = x \ No newline at end of file
diff --git a/testsuite/tests/annotations/should_fail/annfail08.stderr b/testsuite/tests/annotations/should_fail/annfail08.stderr
new file mode 100644
index 0000000000..e8b14d1f8a
--- /dev/null
+++ b/testsuite/tests/annotations/should_fail/annfail08.stderr
@@ -0,0 +1,16 @@
+
+annfail08.hs:9:1:
+ No instance for (Data.Data.Data (a0 -> a0))
+ arising from an annotation
+ Possible fix:
+ add an instance declaration for (Data.Data.Data (a0 -> a0))
+ In the expression: (id + 1)
+ In the annotation: {-# ANN f (id + 1) #-}
+
+annfail08.hs:9:17:
+ No instance for (Num (a0 -> a0))
+ arising from the literal `1'
+ Possible fix: add an instance declaration for (Num (a0 -> a0))
+ In the second argument of `(+)', namely `1'
+ In the expression: (id + 1)
+ In the annotation: {-# ANN f (id + 1) #-}
diff --git a/testsuite/tests/annotations/should_fail/annfail09.hs b/testsuite/tests/annotations/should_fail/annfail09.hs
new file mode 100644
index 0000000000..871dd11895
--- /dev/null
+++ b/testsuite/tests/annotations/should_fail/annfail09.hs
@@ -0,0 +1,12 @@
+module Annfail09 where
+-- Testing that we detect references to ids defined in module being compiled in annotations
+
+g = 10
+
+{-# ANN module g #-}
+
+{-# ANN type Foo g #-}
+data Foo = Bar
+
+{-# ANN f g #-}
+f x = x \ No newline at end of file
diff --git a/testsuite/tests/annotations/should_fail/annfail09.stderr b/testsuite/tests/annotations/should_fail/annfail09.stderr
new file mode 100644
index 0000000000..5eae63a012
--- /dev/null
+++ b/testsuite/tests/annotations/should_fail/annfail09.stderr
@@ -0,0 +1,7 @@
+
+annfail09.hs:11:11:
+ GHC stage restriction: `g'
+ is used in a top-level splice or annotation,
+ and must be imported, not defined locally
+ In the expression: g
+ In the annotation: {-# ANN f g #-}
diff --git a/testsuite/tests/annotations/should_fail/annfail10.hs b/testsuite/tests/annotations/should_fail/annfail10.hs
new file mode 100644
index 0000000000..d03b6a73fb
--- /dev/null
+++ b/testsuite/tests/annotations/should_fail/annfail10.hs
@@ -0,0 +1,10 @@
+module Annfail10 where
+-- Testing ambiguity in annotations
+
+{-# ANN module 1 #-}
+
+{-# ANN type Foo 1 #-}
+data Foo = Bar
+
+{-# ANN f 1 #-}
+f x = x \ No newline at end of file
diff --git a/testsuite/tests/annotations/should_fail/annfail10.stderr b/testsuite/tests/annotations/should_fail/annfail10.stderr
new file mode 100644
index 0000000000..eac3002efa
--- /dev/null
+++ b/testsuite/tests/annotations/should_fail/annfail10.stderr
@@ -0,0 +1,9 @@
+
+annfail10.hs:9:1:
+ Ambiguous type variable `a0' in the constraints:
+ (Data.Data.Data a0) arising from an annotation
+ at annfail10.hs:9:1-15
+ (Num a0) arising from the literal `1' at annfail10.hs:9:11
+ Probable fix: add a type signature that fixes these type variable(s)
+ In the expression: 1
+ In the annotation: {-# ANN f 1 #-}
diff --git a/testsuite/tests/annotations/should_fail/annfail11.hs b/testsuite/tests/annotations/should_fail/annfail11.hs
new file mode 100644
index 0000000000..2eebcb6b63
--- /dev/null
+++ b/testsuite/tests/annotations/should_fail/annfail11.hs
@@ -0,0 +1,4 @@
+module Annfail11 where
+
+{-# ANN length "Cannot annotate other modules yet" #-}
+{-# ANN type Integer "Cannot annotate other modules yet" #-} \ No newline at end of file
diff --git a/testsuite/tests/annotations/should_fail/annfail11.stderr b/testsuite/tests/annotations/should_fail/annfail11.stderr
new file mode 100644
index 0000000000..18769f7466
--- /dev/null
+++ b/testsuite/tests/annotations/should_fail/annfail11.stderr
@@ -0,0 +1,4 @@
+
+annfail11.hs:3:1: Not in scope: `length'
+
+annfail11.hs:4:1: Not in scope: type constructor or class `Integer'
diff --git a/testsuite/tests/annotations/should_fail/annfail12.hs b/testsuite/tests/annotations/should_fail/annfail12.hs
new file mode 100644
index 0000000000..7fe23073d1
--- /dev/null
+++ b/testsuite/tests/annotations/should_fail/annfail12.hs
@@ -0,0 +1,6 @@
+module Annfail12 where
+
+-- Testing errors hidden in annotations
+
+{-# ANN f (error "You were meant to see this error!" :: Int) #-}
+f x = x \ No newline at end of file
diff --git a/testsuite/tests/annotations/should_fail/annfail12.stderr b/testsuite/tests/annotations/should_fail/annfail12.stderr
new file mode 100644
index 0000000000..6b08c0a814
--- /dev/null
+++ b/testsuite/tests/annotations/should_fail/annfail12.stderr
@@ -0,0 +1,8 @@
+
+annfail12.hs:5:1:
+ Exception when trying to run compile-time code:
+ You were meant to see this error!
+ In the expression:
+ (error "You were meant to see this error!" :: Int)
+ In the annotation:
+ {-# ANN f (error "You were meant to see this error!" :: Int) #-}
diff --git a/testsuite/tests/annotations/should_fail/annfail13.hs b/testsuite/tests/annotations/should_fail/annfail13.hs
new file mode 100644
index 0000000000..0de17ce5c0
--- /dev/null
+++ b/testsuite/tests/annotations/should_fail/annfail13.hs
@@ -0,0 +1,6 @@
+module Annfail13 where
+-- Testing that brackets are mandatory in the ANN syntax
+
+{-# ANN f id 1 #-}
+{-# ANN f 1 :: Int #-}
+f x = x \ No newline at end of file
diff --git a/testsuite/tests/annotations/should_fail/annfail13.stderr b/testsuite/tests/annotations/should_fail/annfail13.stderr
new file mode 100644
index 0000000000..fb30c66f73
--- /dev/null
+++ b/testsuite/tests/annotations/should_fail/annfail13.stderr
@@ -0,0 +1,2 @@
+
+annfail13.hs:4:14: parse error on input `1'
diff --git a/testsuite/tests/annotations/should_run/Annrun01_Help.hs b/testsuite/tests/annotations/should_run/Annrun01_Help.hs
new file mode 100644
index 0000000000..c27f85fef6
--- /dev/null
+++ b/testsuite/tests/annotations/should_run/Annrun01_Help.hs
@@ -0,0 +1,27 @@
+{-# LANGUAGE TemplateHaskell #-}
+
+module Annrun01_Help where
+
+{-# ANN module "Module" #-}
+{-# ANN module "Annotations" #-}
+{-# ANN module (10 :: Int) #-}
+{-# ANN module "Rock!!!!" #-}
+
+
+{-# ANN foo "Hello" #-}
+{-# ANN foo "World!" #-}
+{-# ANN bar 'foo #-}
+foo = "Never seen"
+
+{-# ANN bar "Hello World Again!" #-}
+{-# ANN bar (1 :: Int) #-}
+{-# ANN bar 'bar #-}
+bar = "Also never seen"
+
+baz = "Especially never seen"
+
+
+{-# ANN type Baz "Type Annotation" #-}
+{-# ANN type Baz (Just True) #-}
+{-# ANN type Baz ''Baz #-}
+data Baz = Spqr \ No newline at end of file
diff --git a/testsuite/tests/annotations/should_run/Makefile b/testsuite/tests/annotations/should_run/Makefile
new file mode 100644
index 0000000000..71e065f76b
--- /dev/null
+++ b/testsuite/tests/annotations/should_run/Makefile
@@ -0,0 +1,12 @@
+TOP=../../..
+include $(TOP)/mk/boilerplate.mk
+include $(TOP)/mk/test.mk
+
+CONFIG_HS=Config.hs
+
+config :
+ rm -f $(CONFIG_HS)
+ @echo "Creating $(CONFIG_HS) ... "
+ echo "module Config where" >>$(CONFIG_HS)
+ echo "cTop :: String" >> $(CONFIG_HS)
+ echo 'cTop = "$(subst \,\\,$(shell '$(TEST_HC)' --print-libdir))"' >> $(CONFIG_HS)
diff --git a/testsuite/tests/annotations/should_run/all.T b/testsuite/tests/annotations/should_run/all.T
new file mode 100644
index 0000000000..22256b2f85
--- /dev/null
+++ b/testsuite/tests/annotations/should_run/all.T
@@ -0,0 +1,31 @@
+setTestOpts(if_compiler_profiled(skip))
+# These tests are very slow due to their use of package GHC
+setTestOpts(skip_if_fast)
+
+# Annotations, like Template Haskell, require runtime evaluation. In
+# order for this to work with profiling, we would have to build the
+# program twice and use -osuf p_o (see the TH_splitE5_prof test). For
+# now, just disable the profiling and dynamic ways.
+test('annrun01',
+ [extra_clean(['Annrun01_Help.hi', 'Annrun01_Help.o',
+ 'annrun01.hi', 'annrun01.o',
+ 'Config.hs', 'Config.hi', 'Config.o']),
+ pre_cmd('$MAKE -s config'),
+ omit_ways(['profasm','profthreaded', 'dyn'])],
+ multimod_compile_and_run,
+ ['annrun01', '-package ghc']
+ )
+
+""""
+Helpful things to C+P:
+
+test('', normal, compile_fail, [''])
+
+test('', normal, compile, [''])
+
+test('', extra_clean(['.hi', '.o']),
+ multimod_compile_fail, ['', '-v0'])
+
+test('', extra_clean(['.hi', '.o']),
+ multimod_compile, ['', '-v0'])
+"""
diff --git a/testsuite/tests/annotations/should_run/annrun01.hs b/testsuite/tests/annotations/should_run/annrun01.hs
new file mode 100644
index 0000000000..e626dadebc
--- /dev/null
+++ b/testsuite/tests/annotations/should_run/annrun01.hs
@@ -0,0 +1,49 @@
+{-# LANGUAGE ScopedTypeVariables #-}
+
+module Main where
+
+import GHC
+import MonadUtils ( liftIO )
+import DynFlags ( defaultLogAction )
+import Annotations ( AnnTarget(..), CoreAnnTarget )
+import Serialized ( deserializeWithData )
+import Panic
+
+import Config
+import Annrun01_Help
+
+import qualified Language.Haskell.TH as TH
+import Data.List
+import Data.Function
+
+main = defaultErrorHandler defaultLogAction
+ $ runGhc (Just cTop) $ do
+ liftIO $ putStrLn "Initializing Package Database"
+ dflags <- getSessionDynFlags
+ let dflags' = dflags
+ setSessionDynFlags dflags'
+
+ let mod_nm = mkModuleName "Annrun01_Help"
+
+ liftIO $ putStrLn "Setting Target"
+ setTargets [Target (TargetModule mod_nm) True Nothing]
+ liftIO $ putStrLn "Loading Targets"
+ load LoadAllTargets
+
+ liftIO $ putStrLn "Finding Module"
+ mod <- findModule mod_nm Nothing
+ liftIO $ putStrLn "Getting Module Info"
+ Just mod_info <- getModuleInfo mod
+
+ liftIO $ putStrLn "Showing Details For Module"
+ showTargetAnns (ModuleTarget mod)
+ liftIO $ putStrLn "Showing Details For Exports"
+ mapM (showTargetAnns . NamedTarget) $ sortBy (compare `on` getOccName) $ modInfoExports mod_info
+
+showTargetAnns :: CoreAnnTarget -> Ghc ()
+showTargetAnns target = do
+ (int_anns :: [Int]) <- findGlobalAnns deserializeWithData target
+ (mb_bool_anns :: [Maybe Bool]) <- findGlobalAnns deserializeWithData target
+ (string_anns :: [String]) <- findGlobalAnns deserializeWithData target
+ (name_anns :: [TH.Name]) <- findGlobalAnns deserializeWithData target
+ liftIO $ print (int_anns, mb_bool_anns, string_anns, name_anns)
diff --git a/testsuite/tests/annotations/should_run/annrun01.stdout b/testsuite/tests/annotations/should_run/annrun01.stdout
new file mode 100644
index 0000000000..b57394b563
--- /dev/null
+++ b/testsuite/tests/annotations/should_run/annrun01.stdout
@@ -0,0 +1,13 @@
+Initializing Package Database
+Setting Target
+Loading Targets
+Finding Module
+Getting Module Info
+Showing Details For Module
+([10],[],["Rock!!!!","Annotations","Module"],[])
+Showing Details For Exports
+([],[Just True],["Type Annotation"],[Annrun01_Help.Baz])
+([],[],[],[])
+([1],[],["Hello World Again!"],[Annrun01_Help.bar,Annrun01_Help.foo])
+([],[],[],[])
+([],[],["World!","Hello"],[])