[project @ 2000-04-25 11:27:35 by rrt]
[ghc-hetmet.git] / ghc / tests / io / should_run / io029.hs
1 -- !!! Flushing
2 module Main(main) where
3
4 import IO
5 import Directory ( removeFile, doesFileExist )
6 import Monad
7
8 main = do
9   hFlush stdin `catch` \ _ -> putStrLn "No can do - flushing read-only handles isn't legal"
10   putStr "Hello,"
11   hFlush stdout
12   putStr "Hello - "
13   hFlush stderr
14   hdl <- openFile "io029.hs" ReadMode
15   hFlush hdl `catch` \ _ -> putStrLn "No can do - flushing read-only handles isn't legal"
16   hClose hdl
17   remove
18   hdl <- openFile "io029.out" WriteMode
19   hFlush hdl
20   hClose hdl
21   remove
22   hdl <- openFile "io029.out" AppendMode
23   hFlush hdl
24   hClose hdl
25   remove
26   hdl <- openFile "io029.out" ReadWriteMode
27   hFlush hdl
28   hClose hdl
29  where remove = do
30          f <- doesFileExist "io029.out"
31          when f (removeFile "io029.out")