Commit 7ae888d5 authored by batterseapower's avatar batterseapower
Browse files

Test annotations

parent e6166f13
TOP=../../..
include $(TOP)/mk/boilerplate.mk
include $(TOP)/mk/test.mk
\ No newline at end of file
TOP=../../../..
include $(TOP)/mk/boilerplate.mk
include $(TOP)/mk/test.mk
\ No newline at end of file
# Annotations were implemented in GHC 6.9 and not supported in other compilers
setTestOpts(if_compiler_lt('ghc', '6.9', skip));
test('ann01', normal, compile, [''])
""""
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'])
"""
\ No newline at end of file
{-# 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
Loading package ghc-prim ... linking ... done.
Loading package integer ... linking ... done.
Loading package base ... linking ... done.
Loading package ffi-1.0 ... linking ... done.
Loading package syb ... linking ... done.
Loading package array-0.2.0.0 ... linking ... done.
Loading package containers-0.2.0.0 ... linking ... done.
Loading package packedstring-0.1.0.1 ... linking ... done.
Loading package pretty-1.0.1.0 ... linking ... done.
Loading package template-haskell ... linking ... done.
module Annfail04_Help where
class Thing a where
thing :: a
\ No newline at end of file
module Annfail05_Help where
data NoInstances = NoInstances
\ No newline at end of file
module Annfail06_Help where
data InstancesInWrongModule = InstancesInWrongModule
\ No newline at end of file
TOP=../../../..
include $(TOP)/mk/boilerplate.mk
include $(TOP)/mk/test.mk
\ No newline at end of file
# Annotations were implemented in GHC 6.9 and not supported in other compilers
setTestOpts(if_compiler_lt('ghc', '6.9', skip));
test('annfail01', normal, compile_fail, [''])
test('annfail02', normal, compile_fail, [''])
test('annfail03', normal, compile_fail, [''])
test('annfail04', extra_clean(['Annfail04_Help.hi', 'Annfail04_Help.o']),
multimod_compile_fail, ['annfail04', '-v0'])
test('annfail05', extra_clean(['Annfail05_Help.hi', 'Annfail05_Help.o']),
multimod_compile_fail, ['annfail05', '-v0'])
test('annfail06', extra_clean(['Annfail06_Help.hi', 'Annfail06_Help.o']),
multimod_compile_fail, ['annfail06', '-v0'])
test('annfail07', normal, compile_fail, [''])
test('annfail08', normal, compile_fail, [''])
test('annfail09', normal, compile_fail, [''])
test('annfail10', normal, compile_fail, [''])
test('annfail11', normal, compile_fail, [''])
test('annfail12', normal, compile_fail, [''])
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'])
"""
\ No newline at end of file
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
annfail01.hs:4:0: Not in scope: type constructor or class `Foo'
annfail01.hs:5:0: Not in scope: `f'
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
annfail02.hs:6:0: Not in scope: data constructor `Foo'
annfail02.hs:7:0: Not in scope: type constructor or class `Bar'
{-# 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
annfail03.hs:17:0:
GHC stage restriction: instance for `Data InModule'
is used in an annotation, and must be imported, not defined locally
In the expression: InModule
In the annotation: {-# ANN f InModule #-}
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
annfail04.hs:14:11:
GHC stage restriction: instance for `Thing Int'
is used in an annotation, and must be imported, not defined locally
In the expression: (thing :: Int)
In the annotation: {-# ANN f (thing :: Int) #-}
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
annfail05.hs:11:0:
No instance for (Data.Data.Data NoInstances)
arising from an annotation at annfail05.hs:11:0-24
Possible fix:
add an instance declaration for (Data.Data.Data NoInstances)
In the expression: NoInstances
In the annotation: {-# ANN f NoInstances #-}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment