diff options
| -rw-r--r-- | ghc/tests/lib/IO/openFile007.hs | 17 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/openFile007.stdout | 5 |
2 files changed, 22 insertions, 0 deletions
diff --git a/ghc/tests/lib/IO/openFile007.hs b/ghc/tests/lib/IO/openFile007.hs new file mode 100644 index 0000000000..9c3f8be440 --- /dev/null +++ b/ghc/tests/lib/IO/openFile007.hs @@ -0,0 +1,17 @@ +-- !!! check that we don't truncate files if the open fails + +import IO +import Monad + +tmp = "openFile007.out" + +main = do + h <- openFile tmp WriteMode + hPutStrLn h "hello, world" + + -- second open in write mode better fail, but better not truncate the file + try (openFile tmp WriteMode) >>= print + + hClose h + s <- readFile tmp -- make sure our "hello, world" is still there + putStr s diff --git a/ghc/tests/lib/IO/openFile007.stdout b/ghc/tests/lib/IO/openFile007.stdout new file mode 100644 index 0000000000..a19d317eff --- /dev/null +++ b/ghc/tests/lib/IO/openFile007.stdout @@ -0,0 +1,5 @@ +Left resource busy +Action: openFile +Reason: file is locked +File: openFile007.out +hello, world |
