Test Trac #8639
authorSimon Peyton Jones <simonpj@microsoft.com>
Thu, 2 Jan 2014 15:18:10 +0000 (15:18 +0000)
committerSimon Peyton Jones <simonpj@microsoft.com>
Thu, 2 Jan 2014 15:18:58 +0000 (15:18 +0000)
testsuite/tests/ghc-api/Makefile
testsuite/tests/ghc-api/T8639_api.hs [new file with mode: 0644]
testsuite/tests/ghc-api/T8639_api.stdout [new file with mode: 0644]
testsuite/tests/ghc-api/T8639_api_a.hs [new file with mode: 0644]
testsuite/tests/ghc-api/all.T

index 57ba15c..808990c 100644 (file)
@@ -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 (file)
index 0000000..4232aa0
--- /dev/null
@@ -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 (file)
index 0000000..3d957c1
--- /dev/null
@@ -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 (file)
index 0000000..ed0d96d
--- /dev/null
@@ -0,0 +1,3 @@
+module T8639_api_a where
+
+it = True
index ee58181..998bcd7 100644 (file)
@@ -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'])