diff options
author | Paolo Capriotti <p.capriotti@gmail.com> | 2012-03-09 11:42:24 +0000 |
---|---|---|
committer | Paolo Capriotti <p.capriotti@gmail.com> | 2012-03-09 13:04:46 +0000 |
commit | 7e84795cdd797cc3718dfce730e8a7c6a2a31b63 (patch) | |
tree | 4035924f4671336aa57028a42b4e3abca7673235 /libraries/base/tests/hTell002.hs | |
parent | ba85754a049791ee795ba887e698523f1885d3f3 (diff) | |
download | haskell-7e84795cdd797cc3718dfce730e8a7c6a2a31b63.tar.gz |
Copy tests from GHC testsuite; part of #1161.
Diffstat (limited to 'libraries/base/tests/hTell002.hs')
-rw-r--r-- | libraries/base/tests/hTell002.hs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/libraries/base/tests/hTell002.hs b/libraries/base/tests/hTell002.hs new file mode 100644 index 0000000000..b790db8fe8 --- /dev/null +++ b/libraries/base/tests/hTell002.hs @@ -0,0 +1,33 @@ +-- !!! Testing hSeek +module Main(main) where + +import System.Directory +import System.IO + +main :: IO () +main = do + h <- openFile "tst-seek" WriteMode + hSetEncoding h utf8 -- hSeek/hTell work with Unicode streams + hPutStr h "test string1" + -- seek to EOF should be cool.. + hSeek h SeekFromEnd 0 + hPutStr h "test string2" + -- seek past EOF should now also be cool.. + hSeek h SeekFromEnd 3 + hPutStr h "test string3" + hSeek h AbsoluteSeek 13 + hPutStr h "test string4" + x <- hTell h + print x + hSeek h AbsoluteSeek 30 + x1 <- hTell h + hPutStr h "人間虫" -- we should be able to output Unicode too + x2 <- hTell h + print (x2 - x1) + hPutStr h "filler" + hClose h + h <- openFile "tst-seek" ReadMode + hSetEncoding h utf8 + str <- hGetContents h + putStrLn str + removeFile "tst-seek" |