d0c698b35bb98196a020465cbdbeee0269614301
[ghc-hetmet.git] / ghc / tests / io / should_run / io024.hs
1 -- !!! Testing IO.hFileSize
2 module Main(main) where
3
4 import IO
5 import Directory ( removeFile )
6
7 main = do
8   sz <- hFileSize stdin `catch` (\ _ -> return (-1))
9   print sz
10   let fn = "io025.out" 
11   hdl <- openFile fn WriteMode
12   removeFile fn
13   hPutStrLn hdl "file_size"
14    -- with default buffering
15   sz <- hFileSize hdl
16   print sz
17
18   hSetBuffering hdl NoBuffering
19   hPutStrLn hdl "file_size"
20    -- with no buffering
21   sz <- hFileSize hdl
22   print sz
23   hSetBuffering hdl LineBuffering
24   hPutStrLn hdl "file_size"
25    -- with line buffering
26   sz <- hFileSize hdl
27   print sz
28   hSetBuffering hdl (BlockBuffering (Just 4))
29    -- with block buffering
30   hPutStrLn hdl "file_size"
31   sz <- hFileSize hdl
32   print sz
33   hClose hdl