diff options
author | David Terei <davidterei@gmail.com> | 2011-07-20 11:09:03 -0700 |
---|---|---|
committer | David Terei <davidterei@gmail.com> | 2011-07-20 11:26:35 -0700 |
commit | 16514f272fb42af6e9c7674a9bd6c9dce369231f (patch) | |
tree | e4f332b45fe65e2a7a2451be5674f887b42bf199 /testsuite/tests/annotations/should_run | |
parent | ebd422aed41048476aa61dd4c520d43becd78682 (diff) | |
download | haskell-16514f272fb42af6e9c7674a9bd6c9dce369231f.tar.gz |
Move tests from tests/ghc-regress/* to just tests/*
Diffstat (limited to 'testsuite/tests/annotations/should_run')
-rw-r--r-- | testsuite/tests/annotations/should_run/Annrun01_Help.hs | 27 | ||||
-rw-r--r-- | testsuite/tests/annotations/should_run/Makefile | 12 | ||||
-rw-r--r-- | testsuite/tests/annotations/should_run/all.T | 31 | ||||
-rw-r--r-- | testsuite/tests/annotations/should_run/annrun01.hs | 49 | ||||
-rw-r--r-- | testsuite/tests/annotations/should_run/annrun01.stdout | 13 |
5 files changed, 132 insertions, 0 deletions
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"],[]) |