summaryrefslogtreecommitdiff
path: root/testsuite/tests
diff options
context:
space:
mode:
authorBen Gamari <bgamari.foss@gmail.com>2015-12-15 23:57:46 +0100
committerBen Gamari <ben@smart-cactus.org>2015-12-15 23:59:54 +0100
commitc1e25536d67fba33ad6ddae5556115340d99000a (patch)
tree4aa98e5fd9faa46df67412f94fef33d52205181e /testsuite/tests
parent28638dfe79e915f33d75a1b22c5adce9e2b62b97 (diff)
downloadhaskell-c1e25536d67fba33ad6ddae5556115340d99000a.tar.gz
Expose enabled language extensions to TH
This exposes `template-haskell` functions for querying the language extensions which are enabled when compiling a module, - an `isExtEnabled` function to check whether an extension is enabled - an `extsEnabled` function to obtain a full list of enabled extensions To avoid code duplication this adds a `GHC.LanguageExtensions` module to `ghc-boot` and moves `DynFlags.ExtensionFlag` into it. A happy consequence of this is that the ungainly `DynFlags` lost around 500 lines. Moreover, flags corresponding to language extensions are now clearly distinguished from other flags due to the `LangExt.*` prefix. Updates haddock submodule. This fixes #10820. Test Plan: validate Reviewers: austin, spinda, hvr, goldfire, alanz Reviewed By: goldfire Subscribers: mpickering, RyanGlScott, hvr, simonpj, thomie Differential Revision: https://phabricator.haskell.org/D1200 GHC Trac Issues: #10820
Diffstat (limited to 'testsuite/tests')
-rw-r--r--testsuite/tests/ghc-api/T10508_api.hs3
-rw-r--r--testsuite/tests/th/T10820.hs16
-rw-r--r--testsuite/tests/th/T10820.stdout5
-rw-r--r--testsuite/tests/th/all.T1
4 files changed, 24 insertions, 1 deletions
diff --git a/testsuite/tests/ghc-api/T10508_api.hs b/testsuite/tests/ghc-api/T10508_api.hs
index afe8e50e73..d0b8b0a946 100644
--- a/testsuite/tests/ghc-api/T10508_api.hs
+++ b/testsuite/tests/ghc-api/T10508_api.hs
@@ -2,6 +2,7 @@ module Main where
import DynFlags
import GHC
+import qualified GHC.LanguageExtensions as LangExt
import Control.Monad (forM_)
import Control.Monad.IO.Class (liftIO)
@@ -14,7 +15,7 @@ main = do
dflags <- getSessionDynFlags
setSessionDynFlags $ dflags
`gopt_unset` Opt_ImplicitImportQualified
- `xopt_unset` Opt_ImplicitPrelude
+ `xopt_unset` LangExt.ImplicitPrelude
forM_ exprs $ \expr ->
handleSourceError printException $ do
diff --git a/testsuite/tests/th/T10820.hs b/testsuite/tests/th/T10820.hs
new file mode 100644
index 0000000000..0e53bbde72
--- /dev/null
+++ b/testsuite/tests/th/T10820.hs
@@ -0,0 +1,16 @@
+{-# LANGUAGE LiberalTypeSynonyms #-}
+{-# LANGUAGE RankNTypes #-}
+{-# LANGUAGE TemplateHaskell #-}
+{-# LANGUAGE MagicHash #-}
+
+module Main where
+
+import Language.Haskell.TH.Syntax
+import GHC.LanguageExtensions
+
+main = do
+ print $(isExtEnabled Cpp >>= lift)
+ print $(isExtEnabled LiberalTypeSynonyms >>= lift)
+ print $(isExtEnabled RankNTypes >>= lift)
+ print $(isExtEnabled TypeSynonymInstances >>= lift)
+ print $(isExtEnabled MagicHash >>= lift)
diff --git a/testsuite/tests/th/T10820.stdout b/testsuite/tests/th/T10820.stdout
new file mode 100644
index 0000000000..8a39f7a810
--- /dev/null
+++ b/testsuite/tests/th/T10820.stdout
@@ -0,0 +1,5 @@
+False
+True
+True
+False
+True \ No newline at end of file
diff --git a/testsuite/tests/th/all.T b/testsuite/tests/th/all.T
index 11b0ac21b1..af8531c8b1 100644
--- a/testsuite/tests/th/all.T
+++ b/testsuite/tests/th/all.T
@@ -369,3 +369,4 @@ test('T10819',
extra_clean(['T10819_Lib.hi', 'T10819_Lib.o']),
multimod_compile,
['T10819.hs', '-v0 ' + config.ghc_th_way_flags])
+test('T10820', normal, compile_and_run, ['-v0'])