summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2021-09-23 11:02:21 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-10-19 03:30:16 -0400
commit51281e81601fb0b288c921728ea3b3f568f77af7 (patch)
tree8c85ab881c93971263bdcd311e6caaa2277c7446 /testsuite
parent1bc77a859110e46b13ad6bf10ad75ae463e75666 (diff)
downloadhaskell-51281e81601fb0b288c921728ea3b3f568f77af7.tar.gz
Add test for implicit dynamic too
This test checks that we check for missing dynamic objects if dynamic-too is enabled implicitly by the driver.
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/tests/driver/implicit-dyn-too/Makefile12
-rw-r--r--testsuite/tests/driver/implicit-dyn-too/QuasiExpr.hs35
-rw-r--r--testsuite/tests/driver/implicit-dyn-too/QuasiQuote.hs10
-rw-r--r--testsuite/tests/driver/implicit-dyn-too/all.T1
-rw-r--r--testsuite/tests/driver/implicit-dyn-too/implicit-dyn-too.stdout3
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]