summaryrefslogtreecommitdiff
path: root/testsuite/tests/ghc-api
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2014-01-02 15:18:10 +0000
committerSimon Peyton Jones <simonpj@microsoft.com>2014-01-02 15:18:58 +0000
commit40db99a7c485aa58f9fc3a209fced8720cf5c3e5 (patch)
tree5a19163e3253219d3b6bf62ec1a9c15a85aa444e /testsuite/tests/ghc-api
parentf54fc09bb17226c71deb766306cb2e293c33dc83 (diff)
downloadhaskell-40db99a7c485aa58f9fc3a209fced8720cf5c3e5.tar.gz
Test Trac #8639
Diffstat (limited to 'testsuite/tests/ghc-api')
-rw-r--r--testsuite/tests/ghc-api/Makefile4
-rw-r--r--testsuite/tests/ghc-api/T8639_api.hs26
-rw-r--r--testsuite/tests/ghc-api/T8639_api.stdout1
-rw-r--r--testsuite/tests/ghc-api/T8639_api_a.hs3
-rw-r--r--testsuite/tests/ghc-api/all.T5
5 files changed, 38 insertions, 1 deletions
diff --git a/testsuite/tests/ghc-api/Makefile b/testsuite/tests/ghc-api/Makefile
index 57ba15cd42..808990c909 100644
--- a/testsuite/tests/ghc-api/Makefile
+++ b/testsuite/tests/ghc-api/Makefile
@@ -9,6 +9,10 @@ T6145: clean
'$(TEST_HC)' $(TEST_HC_OPTS) --make -v0 -package ghc T6145
./T6145 "`'$(TEST_HC)' $(TEST_HC_OPTS) --print-libdir | tr -d '\r'`"
+T8639_api: clean
+ '$(TEST_HC)' $(TEST_HC_OPTS) --make -v0 -package ghc T8639_api
+ ./T8639_api "`'$(TEST_HC)' $(TEST_HC_OPTS) --print-libdir | tr -d '\r'`"
+
.PHONY: clean T6145
diff --git a/testsuite/tests/ghc-api/T8639_api.hs b/testsuite/tests/ghc-api/T8639_api.hs
new file mode 100644
index 0000000000..4232aa00b9
--- /dev/null
+++ b/testsuite/tests/ghc-api/T8639_api.hs
@@ -0,0 +1,26 @@
+module Main where
+
+import GHC
+import GhcMonad
+import Outputable
+import System.IO
+import System.Environment( getArgs )
+
+main
+ = do { [libdir] <- getArgs
+ ; runGhc (Just libdir) $ do
+ flags <- getSessionDynFlags
+ setSessionDynFlags (flags{ hscTarget = HscInterpreted, ghcLink = LinkInMemory})
+ target <- guessTarget "T8639_api_a.hs" Nothing
+ setTargets [target]
+ load LoadAllTargets
+ imps <- mapM parseImportDecl ["import Prelude", "import T8639_api_a"]
+ setContext (map IIDecl imps)
+
+ -- With the next line, you get an "Not in scope" exception.
+ -- If you comment out this runStmt, it runs without error and prints the type.
+ runStmt "putStrLn (show 3)" RunToCompletion
+
+ ty <- exprType "T8639_api_a.it"
+ liftIO (putStrLn (showPpr flags ty))
+ ; hFlush stdout }
diff --git a/testsuite/tests/ghc-api/T8639_api.stdout b/testsuite/tests/ghc-api/T8639_api.stdout
new file mode 100644
index 0000000000..3d957c18e3
--- /dev/null
+++ b/testsuite/tests/ghc-api/T8639_api.stdout
@@ -0,0 +1 @@
+GHC.Types.Bool
diff --git a/testsuite/tests/ghc-api/T8639_api_a.hs b/testsuite/tests/ghc-api/T8639_api_a.hs
new file mode 100644
index 0000000000..ed0d96db71
--- /dev/null
+++ b/testsuite/tests/ghc-api/T8639_api_a.hs
@@ -0,0 +1,3 @@
+module T8639_api_a where
+
+it = True
diff --git a/testsuite/tests/ghc-api/all.T b/testsuite/tests/ghc-api/all.T
index ee5818110c..998bcd711e 100644
--- a/testsuite/tests/ghc-api/all.T
+++ b/testsuite/tests/ghc-api/all.T
@@ -1,4 +1,7 @@
+test('ghcApi', normal, compile_and_run, ['-package ghc'])
test('T6145', when(fast(), skip),
run_command,
['$MAKE -s --no-print-directory T6145'])
-test('ghcApi', normal, compile_and_run, ['-package ghc'])
+test('T8639_api', when(fast(), skip),
+ run_command,
+ ['$MAKE -s --no-print-directory T8639_api'])