testsuite: Add (broken) test for #17510
authorBen Gamari <ben@smart-cactus.org>
Mon, 9 Dec 2019 19:41:17 +0000 (14:41 -0500)
committerMarge Bot <ben+marge-bot@smart-cactus.org>
Wed, 11 Dec 2019 00:58:19 +0000 (19:58 -0500)
libraries/base/tests/IO/T17510.hs [new file with mode: 0644]
libraries/base/tests/IO/T17510.stdout [new file with mode: 0644]
libraries/base/tests/IO/all.T

diff --git a/libraries/base/tests/IO/T17510.hs b/libraries/base/tests/IO/T17510.hs
new file mode 100644 (file)
index 0000000..a291855
--- /dev/null
@@ -0,0 +1,15 @@
+-- | Test that a handle from 'hDuplicate' really shares the file position with
+-- its parent.
+
+import System.IO
+import GHC.IO.Handle
+
+main :: IO ()
+main = do
+    writeFile "test" "hello\nworld\ntesting\n"
+    h <- openFile "test" ReadMode
+    h2 <- hDuplicate h
+    hGetLine h  >>= putStrLn  -- should print "hello"
+    hGetLine h2 >>= putStrLn -- should print "world"
+    hGetLine h  >>= putStrLn -- should print "testing"
+
diff --git a/libraries/base/tests/IO/T17510.stdout b/libraries/base/tests/IO/T17510.stdout
new file mode 100644 (file)
index 0000000..23e6098
--- /dev/null
@@ -0,0 +1,4 @@
+hello
+world
+testing
+
index bfc6a09..189fbeb 100644 (file)
@@ -142,3 +142,4 @@ test('T17414',
       when(opsys('linux'), skip),
       high_memory_usage],
      compile_and_run, [''])
+test('T17510', expect_broken(17510), compile_and_run, [''])