Test Trac #8628
authorSimon Peyton Jones <simonpj@microsoft.com>
Fri, 3 Jan 2014 16:33:59 +0000 (16:33 +0000)
committerSimon Peyton Jones <simonpj@microsoft.com>
Fri, 3 Jan 2014 16:33:59 +0000 (16:33 +0000)
testsuite/tests/ghc-api/Makefile
testsuite/tests/ghc-api/T8628.hs [new file with mode: 0644]
testsuite/tests/ghc-api/T8628.stdout [new file with mode: 0644]
testsuite/tests/ghc-api/all.T

index 808990c..855b774 100644 (file)
@@ -13,6 +13,10 @@ 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'`"
 
+T8628: clean
+       '$(TEST_HC)' $(TEST_HC_OPTS) --make -v0 -package ghc T8628
+       ./T8628 "`'$(TEST_HC)' $(TEST_HC_OPTS) --print-libdir | tr -d '\r'`"
+
 .PHONY: clean T6145
 
 
diff --git a/testsuite/tests/ghc-api/T8628.hs b/testsuite/tests/ghc-api/T8628.hs
new file mode 100644 (file)
index 0000000..203d328
--- /dev/null
@@ -0,0 +1,33 @@
+module Main where
+
+import System.IO
+import DynFlags
+import GHC
+import Exception
+import Module
+import FastString
+import MonadUtils
+import Outputable
+import Bag (filterBag,isEmptyBag)
+import System.Directory (removeFile)
+import System.Environment( getArgs )
+import PrelNames
+
+main :: IO()
+main
+  = do  [libdir] <- getArgs
+        ok <- runGhc (Just libdir) $ do
+          dflags <- getSessionDynFlags
+          setSessionDynFlags dflags
+          liftIO (setUnsafeGlobalDynFlags dflags)
+
+          setContext [ IIDecl (simpleImportDecl pRELUDE_NAME)
+                     , IIDecl (simpleImportDecl (mkModuleNameFS (fsLit "System.IO")))]
+          runDecls "data X = Y ()"
+          runStmt "print True" RunToCompletion
+          gtry $ runStmt "print (Y ())" RunToCompletion :: GhcMonad m => m (Either SomeException RunResult)
+          runDecls "data X = Y () deriving Show"
+          _ <- dynCompileExpr "'x'"
+          runStmt "print (Y ())" RunToCompletion
+          runStmt "System.IO.hFlush System.IO.stdout" RunToCompletion
+        print "done"
diff --git a/testsuite/tests/ghc-api/T8628.stdout b/testsuite/tests/ghc-api/T8628.stdout
new file mode 100644 (file)
index 0000000..d18820e
--- /dev/null
@@ -0,0 +1,3 @@
+True
+Y ()
+"done"
index 998bcd7..1f83dcd 100644 (file)
@@ -5,3 +5,6 @@ test('T6145', when(fast(), skip),
 test('T8639_api', when(fast(), skip),
               run_command,
               ['$MAKE -s --no-print-directory T8639_api'])
+test('T8628', when(fast(), skip),
+              run_command,
+              ['$MAKE -s --no-print-directory T8628'])