6ce87ed3b36fc5868b555c3b8e435d78be2dc53b
[ghc-hetmet.git] / ghc / tests / lib / IO / readFile001.hs
1 -- !!! readFile test
2
3 import IO
4
5 source   = "readFile001.hs"
6 filename = "readFile001.out"
7
8 main = do
9   s <- readFile source
10   h <- openFile filename WriteMode
11   hPutStrLn h s
12   hClose h
13   s <- readFile filename
14
15   -- This open should fail, because the readFile hasn't been forced
16   -- and the file is therefore still locked.
17   try (openFile filename WriteMode) >>= print
18
19   putStrLn s
20
21   -- should be able to open it for writing now, because we've forced the
22   -- whole file.
23   h <- openFile filename WriteMode
24
25   print h