summaryrefslogtreecommitdiff
path: root/libraries/base/tests
diff options
context:
space:
mode:
authorAndreas Klebinger <klebinger.andreas@gmx.at>2020-03-10 09:58:05 +0100
committerBen Gamari <ben@smart-cactus.org>2020-07-15 16:41:02 -0400
commit29bcd9363f2712524f7720377f19cb885adf2825 (patch)
tree3ddf7f436e24802d27b03fddbd1e12af16d1710e /libraries/base/tests
parent6ec26df241d80e8e5cf39a02757c274067c8078d (diff)
downloadhaskell-29bcd9363f2712524f7720377f19cb885adf2825.tar.gz
winio: Set handle offset when opening files in Append mode.
Otherwise we would truncate the file.
Diffstat (limited to 'libraries/base/tests')
-rw-r--r--libraries/base/tests/IO/all.T1
-rw-r--r--libraries/base/tests/IO/openFile009.hs20
-rw-r--r--libraries/base/tests/IO/openFile009.stdout1
3 files changed, 22 insertions, 0 deletions
diff --git a/libraries/base/tests/IO/all.T b/libraries/base/tests/IO/all.T
index 39b7f17134..054b050276 100644
--- a/libraries/base/tests/IO/all.T
+++ b/libraries/base/tests/IO/all.T
@@ -68,6 +68,7 @@ test('openFile005', [], compile_and_run, [''])
test('openFile006', [], compile_and_run, [''])
test('openFile007', [], compile_and_run, [''])
test('openFile008', cmd_prefix('ulimit -n 2048; '), compile_and_run, [''])
+test('openFile009', [], compile_and_run, [''])
test('putStr001', normal, compile_and_run, [''])
test('readFile001', [], compile_and_run, [''])
diff --git a/libraries/base/tests/IO/openFile009.hs b/libraries/base/tests/IO/openFile009.hs
new file mode 100644
index 0000000000..00328ed0cb
--- /dev/null
+++ b/libraries/base/tests/IO/openFile009.hs
@@ -0,0 +1,20 @@
+import System.IO
+import System.Cmd
+import System.FilePath
+import Text.Printf
+import System.Directory
+import Control.Monad
+
+testfile = "openFile009_testfile"
+
+-- Make sure opening with append doesn't truncate files.
+main = do
+ h <- openFile testfile Write
+ hPutStr "Hello"
+ hClose h
+ h <- openFile testfile Append
+ hPutStr " World!"
+ hClose h
+ s <- readFile testfile
+ putStrLn s
+
diff --git a/libraries/base/tests/IO/openFile009.stdout b/libraries/base/tests/IO/openFile009.stdout
new file mode 100644
index 0000000000..980a0d5f19
--- /dev/null
+++ b/libraries/base/tests/IO/openFile009.stdout
@@ -0,0 +1 @@
+Hello World!