9c3f8be440dbbaa03f81de887b87ef86a2896370
[ghc-hetmet.git] / ghc / tests / lib / IO / openFile007.hs
1 -- !!! check that we don't truncate files if the open fails
2
3 import IO
4 import Monad
5
6 tmp = "openFile007.out"
7
8 main = do
9   h <- openFile tmp WriteMode
10   hPutStrLn h "hello, world"
11
12   -- second open in write mode better fail, but better not truncate the file
13   try (openFile tmp WriteMode) >>= print
14   
15   hClose h
16   s <- readFile tmp -- make sure our "hello, world" is still there
17   putStr s