[project @ 2000-04-25 11:27:35 by rrt]
[ghc-hetmet.git] / ghc / tests / io / should_run / io024.hs
index d0c698b..ade7de7 100644 (file)
@@ -2,32 +2,34 @@
 module Main(main) where
 
 import IO
-import Directory ( removeFile )
+import Directory ( removeFile, doesFileExist )
+import Monad
 
 main = do
   sz <- hFileSize stdin `catch` (\ _ -> return (-1))
   print sz
-  let fn = "io025.out" 
+  let fn = "io025.out"
+  f <- doesFileExist fn
+  when f (removeFile fn)
   hdl <- openFile fn WriteMode
-  removeFile fn
-  hPutStrLn hdl "file_size"
+  hPutStr hdl "file_size"
    -- with default buffering
   sz <- hFileSize hdl
   print sz
 
   hSetBuffering hdl NoBuffering
-  hPutStrLn hdl "file_size"
+  hPutStr hdl "file_size"
    -- with no buffering
   sz <- hFileSize hdl
   print sz
   hSetBuffering hdl LineBuffering
-  hPutStrLn hdl "file_size"
+  hPutStr hdl "file_size"
    -- with line buffering
   sz <- hFileSize hdl
   print sz
   hSetBuffering hdl (BlockBuffering (Just 4))
    -- with block buffering
-  hPutStrLn hdl "file_size"
+  hPutStr hdl "file_size"
   sz <- hFileSize hdl
   print sz
   hClose hdl