diff options
Diffstat (limited to 'testsuite/tests/driver')
5 files changed, 61 insertions, 0 deletions
diff --git a/testsuite/tests/driver/implicit-dyn-too/Makefile b/testsuite/tests/driver/implicit-dyn-too/Makefile new file mode 100644 index 0000000000..45af9afaff --- /dev/null +++ b/testsuite/tests/driver/implicit-dyn-too/Makefile @@ -0,0 +1,12 @@ +TOP=../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk + +clean: + rm -f *.o *.hi *.dyn_hi *.dyn_o + +implicit-dyn-too: clean + '$(TEST_HC)' $(TEST_HC_OPTS) "QuasiQuote.hs" -fno-code -fwrite-interface -v1 --make + rm "QuasiExpr.dyn_o" + '$(TEST_HC)' $(TEST_HC_OPTS) "QuasiQuote.hs" -fno-code -fwrite-interface -v1 --make + diff --git a/testsuite/tests/driver/implicit-dyn-too/QuasiExpr.hs b/testsuite/tests/driver/implicit-dyn-too/QuasiExpr.hs new file mode 100644 index 0000000000..d81fcf8b05 --- /dev/null +++ b/testsuite/tests/driver/implicit-dyn-too/QuasiExpr.hs @@ -0,0 +1,35 @@ +{-# LANGUAGE Haskell2010 #-} +{-# LANGUAGE TemplateHaskell #-} + +-- Used by QuasiQuote. Example taken from the GHC documentation. +module QuasiExpr where + +import Language.Haskell.TH +import Language.Haskell.TH.Quote + +data Expr = IntExpr Integer + | AntiIntExpr String + | BinopExpr BinOp Expr Expr + | AntiExpr String + deriving Show + +data BinOp = AddOp + | SubOp + | MulOp + | DivOp + deriving Show + +eval :: Expr -> Integer +eval (IntExpr n) = n +eval (BinopExpr op x y) = (opToFun op) (eval x) (eval y) + where + opToFun AddOp = (+) + opToFun SubOp = (-) + opToFun MulOp = (*) + opToFun DivOp = div + +expr = QuasiQuoter parseExprExp undefined undefined undefined + +-- cheating... +parseExprExp :: String -> Q Exp +parseExprExp _ = [| BinopExpr AddOp (IntExpr 1) (IntExpr 2) |] diff --git a/testsuite/tests/driver/implicit-dyn-too/QuasiQuote.hs b/testsuite/tests/driver/implicit-dyn-too/QuasiQuote.hs new file mode 100644 index 0000000000..fe900eb825 --- /dev/null +++ b/testsuite/tests/driver/implicit-dyn-too/QuasiQuote.hs @@ -0,0 +1,10 @@ +{-# LANGUAGE Haskell2010 #-} +{-# LANGUAGE TemplateHaskell, QuasiQuotes #-} + +-- example taken from the GHC documentation +module QuasiQuote where + +import QuasiExpr + +val :: Integer +val = eval [expr|1 + 2|] diff --git a/testsuite/tests/driver/implicit-dyn-too/all.T b/testsuite/tests/driver/implicit-dyn-too/all.T new file mode 100644 index 0000000000..1e0b0ed96a --- /dev/null +++ b/testsuite/tests/driver/implicit-dyn-too/all.T @@ -0,0 +1 @@ +test('implicit-dyn-too', [when(opsys('mingw32'),skip), extra_files(['QuasiExpr.hs', 'QuasiQuote.hs']) ], makefile_test, []) diff --git a/testsuite/tests/driver/implicit-dyn-too/implicit-dyn-too.stdout b/testsuite/tests/driver/implicit-dyn-too/implicit-dyn-too.stdout new file mode 100644 index 0000000000..f50bfcd98f --- /dev/null +++ b/testsuite/tests/driver/implicit-dyn-too/implicit-dyn-too.stdout @@ -0,0 +1,3 @@ +[1 of 2] Compiling QuasiExpr ( QuasiExpr.hs, QuasiExpr.o, QuasiExpr.dyn_o ) +[2 of 2] Compiling QuasiQuote ( QuasiQuote.hs, QuasiQuote.o, QuasiQuote.dyn_o ) +[1 of 2] Compiling QuasiExpr ( QuasiExpr.hs, QuasiExpr.o, QuasiExpr.dyn_o ) [Missing dynamic object file] |