summaryrefslogtreecommitdiff
path: root/testsuite/tests/lib/IO/hFlush001.hs
diff options
context:
space:
mode:
authorDavid Terei <davidterei@gmail.com>2011-07-20 11:09:03 -0700
committerDavid Terei <davidterei@gmail.com>2011-07-20 11:26:35 -0700
commit16514f272fb42af6e9c7674a9bd6c9dce369231f (patch)
treee4f332b45fe65e2a7a2451be5674f887b42bf199 /testsuite/tests/lib/IO/hFlush001.hs
parentebd422aed41048476aa61dd4c520d43becd78682 (diff)
downloadhaskell-16514f272fb42af6e9c7674a9bd6c9dce369231f.tar.gz
Move tests from tests/ghc-regress/* to just tests/*
Diffstat (limited to 'testsuite/tests/lib/IO/hFlush001.hs')
-rw-r--r--testsuite/tests/lib/IO/hFlush001.hs31
1 files changed, 31 insertions, 0 deletions
diff --git a/testsuite/tests/lib/IO/hFlush001.hs b/testsuite/tests/lib/IO/hFlush001.hs
new file mode 100644
index 0000000000..78c7b7eeb3
--- /dev/null
+++ b/testsuite/tests/lib/IO/hFlush001.hs
@@ -0,0 +1,31 @@
+-- !!! Flushing
+module Main(main) where
+
+import Control.Monad
+import System.Directory ( removeFile, doesFileExist )
+import System.IO
+
+main = do
+ hFlush stdin `catch` \ _ -> putStrLn "No can do - flushing read-only handles isn't legal"
+ putStr "Hello,"
+ hFlush stdout
+ putStr "Hello - "
+ hFlush stderr
+ hdl <- openFile "hFlush001.hs" ReadMode
+ hFlush hdl `catch` \ _ -> putStrLn "No can do - flushing read-only handles isn't legal"
+ hClose hdl
+ remove
+ hdl <- openFile "hFlush001.out" WriteMode
+ hFlush hdl
+ hClose hdl
+ remove
+ hdl <- openFile "hFlush001.out" AppendMode
+ hFlush hdl
+ hClose hdl
+ remove
+ hdl <- openFile "hFlush001.out" ReadWriteMode
+ hFlush hdl
+ hClose hdl
+ where remove = do
+ f <- doesFileExist "hFlush001.out"
+ when f (removeFile "hFlush001.out")