Commit beedb87b authored by sewardj's avatar sewardj
Browse files

[project @ 2001-06-07 10:45:30 by sewardj]

Track current changes in the text-mode-seek-on-Windows saga.
parent f819f0f4
# -----------------------------------------------------------------------------
# $Id: Makefile,v 1.7 2001/06/01 14:33:01 sewardj Exp $
# $Id: Makefile,v 1.8 2001/06/07 10:45:30 sewardj Exp $
TOP = ../..
......@@ -7,7 +7,7 @@ include $(TOP)/mk/boilerplate.mk
include $(TOP)/mk/should_run.mk
SRC_HC_OPTS += -dcore-lint
SRC_HC_OPTS += -dcore-lint -cpp
hGetBuffering001_RUNTEST_OPTS += -i hGetBuffering001.hs
hSetBuffering002_RUNTEST_OPTS += -i hSetBuffering002.hs
......@@ -21,6 +21,8 @@ hGetLine001_RUNTEST_OPTS += -i hGetLine001.hs -o1 hGetLine001.stdout-mingw
hFileSize001_RUNTEST_OPTS += -o1 hFileSize001.stdout-mingw
hSeek004_RUNTEST_OPTS += -o1 hSeek004.stdout-mingw
hGetPosn001_RUNTEST_OPTS += -o1 hGetPosn001.stdout-mingw
openFile003_RUNTEST_OPTS += -o1 openFile003.stdout-mingw
openFile005_RUNTEST_OPTS += -o1 openFile005.stdout-mingw
.PRECIOUS: %.o %.bin
......
-- !!! testing hGetLine
import IO
#if defined(__MINGW32__)
import PrelHandle(hSetBinaryMode)
#endif
-- one version of 'cat'
main = do
......@@ -10,7 +13,10 @@ main = do
loop stdin
h <- openFile "hGetLine001.hs" ReadMode
# if defined(__MINGW32__)
hSetBinaryMode h True
# endif
hSetBuffering h NoBuffering
loop h
......
-- !!! testing hGetLine
import IO
#if defined(__MINGW32__)
import PrelHandle(hSetBinaryMode)
#endif
-- one version of 'cat'
main = do
......@@ -10,7 +13,10 @@ main = do
loop stdin
h <- openFile "hGetLine001.hs" ReadMode
# if defined(__MINGW32__)
hSetBinaryMode h True
# endif
hSetBuffering h NoBuffering
loop h
......@@ -25,6 +31,9 @@ main = do
-- !!! testing hGetLine
import IO
#if defined(__MINGW32__)
import PrelHandle(hSetBinaryMode)
#endif
-- one version of 'cat'
main = do
......@@ -34,7 +43,10 @@ main = do
loop stdin
h <- openFile "hGetLine001.hs" ReadMode
# if defined(__MINGW32__)
hSetBinaryMode h True
# endif
hSetBuffering h NoBuffering
loop h
......@@ -49,6 +61,9 @@ main = do
-- !!! testing hGetLine
import IO
#if defined(__MINGW32__)
import PrelHandle(hSetBinaryMode)
#endif
-- one version of 'cat'
main = do
......@@ -58,7 +73,10 @@ main = do
loop stdin
h <- openFile "hGetLine001.hs" ReadMode
# if defined(__MINGW32__)
hSetBinaryMode h True
# endif
hSetBuffering h NoBuffering
loop h
......@@ -73,6 +91,9 @@ main = do
-- !!! testing hGetLine
import IO
#if defined(__MINGW32__)
import PrelHandle(hSetBinaryMode)
#endif
-- one version of 'cat'
main = do
......@@ -82,7 +103,10 @@ main = do
loop stdin
h <- openFile "hGetLine001.hs" ReadMode
# if defined(__MINGW32__)
hSetBinaryMode h True
# endif
hSetBuffering h NoBuffering
loop h
......
......@@ -4,16 +4,22 @@ module Main(main) where
import IO
import Monad
import Directory (removeFile, doesFileExist)
#if defined(__MINGW32__)
import PrelHandle(hSetBinaryMode)
#endif
main = do
hIn <- openFile "hGetPosn001.in" ReadMode
# if defined(__MINGW32__)
hSetBinaryMode hIn True
# endif
f <- doesFileExist "hGetPosn001.out"
when f (removeFile "hGetPosn001.out")
hOut <- openFile "hGetPosn001.out" ReadWriteMode
# if defined(__MINGW32__)
hSetBinaryMode hOut True
# endif
bof <- hGetPosn hIn
copy hIn hOut
hSetPosn bof
......
-- !!! test hIsEOF in various buffering situations
import IO
#if defined(__MINGW32__)
import PrelHandle(hSetBinaryMode)
#endif
main = do
h <- openFile "hIsEOF002.hs" ReadMode
# if defined(__MINGW32__)
hSetBinaryMode h True
# endif
hSetBuffering h NoBuffering
hSeek h SeekFromEnd 0
hIsEOF h >>= print
......@@ -39,7 +44,9 @@ main = do
hClose h
h <- openFile "hIsEOF002.out" ReadWriteMode
# if defined(__MINGW32__)
hSetBinaryMode h True
# endif
hSetBuffering h NoBuffering
hSeek h SeekFromEnd 0
hIsEOF h >>= print
......
......@@ -4,9 +4,14 @@
-- but in GHC it returns True (known bug).
import IO
#if defined(__MINGW32__)
import PrelHandle(hSetBinaryMode)
#endif
main = do
h <- openFile "hReady001.hs" ReadMode
#if defined(__MINGW32__)
hSetBinaryMode h True
#endif
hSeek h SeekFromEnd 0
hReady h >>= print
-- !!! Test seeking
import IO
#if defined(__MINGW32__)
import PrelHandle(hSetBinaryMode)
#endif
main = do
h <- openFile "hSeek001.in" ReadMode
# if defined(__MINGW32__)
hSetBinaryMode h True
# endif
True <- hIsSeekable h
hSeek h SeekFromEnd (-1)
z <- hGetChar h
......
......@@ -3,11 +3,16 @@ module Main(main) where
import IO
import Directory ( removeFile )
#if defined(__MINGW32__)
import PrelHandle(hSetBinaryMode)
#endif
main :: IO ()
main = do
hdl <- openFile "hSeek002.hs" ReadMode
# if defined(__MINGW32__)
hSetBinaryMode hdl True
# endif
flg <- hIsEOF hdl
print flg
hSeek hdl SeekFromEnd 0
......
......@@ -3,6 +3,9 @@ module Main(main) where
import IO
import Monad ( sequence )
#if defined(__MINGW32__)
import PrelHandle(hSetBinaryMode)
#endif
testPosns :: Handle -> BufferMode -> IO ()
testPosns hdl bmo = do
......@@ -15,7 +18,9 @@ bmo_ls = [NoBuffering, LineBuffering, BlockBuffering Nothing,
main = do
hdl <- openFile "hSeek003.hs" ReadMode
# if defined(__MINGW32__)
hSetBinaryMode hdl True
# endif
sequence (zipWith testPosns (repeat hdl) bmo_ls)
hClose hdl
......
-- !!! can't seek an AppendMode handle
import IO
#if defined(__MINGW32__)
import PrelHandle(hSetBinaryMode)
#endif
main = do
h <- openFile "hSeek004.out" AppendMode
# if defined(__MINGW32__)
hSetBinaryMode h True
# endif
try (hSeek h AbsoluteSeek 0) >>= print
......@@ -2,10 +2,15 @@
import IO
import Maybe
#if defined(__MINGW32__)
import PrelHandle(hSetBinaryMode)
#endif
main = do
h <- openFile "ioeGetErrorString001.hs" ReadMode
# if defined(__MINGW32__)
hSetBinaryMode h True
# endif
hSeek h SeekFromEnd 0
(hGetChar h >> return ()) `catch`
\e -> if isEOFError e
......
-- !!! test ioeGetFileName
import IO
#if defined(__MINGW32__)
import PrelHandle(hSetBinaryMode)
#endif
main = do
h <- openFile "ioeGetFileName001.hs" ReadMode
# if defined(__MINGW32__)
hSetBinaryMode h True
# endif
hSeek h SeekFromEnd 0
(hGetChar h >> return ()) `catch`
\e -> if isEOFError e
......
......@@ -2,10 +2,15 @@
import IO
import Maybe
#if defined(__MINGW32__)
import PrelHandle(hSetBinaryMode)
#endif
main = do
h <- openFile "ioeGetHandle001.hs" ReadMode
# if defined(__MINGW32__)
hSetBinaryMode h True
# endif
hSeek h SeekFromEnd 0
(hGetChar h >> return ()) `catch`
\e -> if isEOFError e && fromJust (ioeGetHandle e) == h
......
Left permission denied
Action: openFile
Reason: Permission denied
File: .
Left permission denied
Action: openFile
Reason: Permission denied
File: .
Left permission denied
Action: openFile
Reason: Permission denied
File: .
Left permission denied
Action: openFile
Reason: Permission denied
File: .
two writes (should fail)
Right {loc=openFile005.out1,type=writable,binary=False,buffering=block (512)}
write and an append (should fail)
Right {loc=openFile005.out1,type=writable (append),binary=False,buffering=block (512)}
read/write and a write (should fail)
Right {loc=openFile005.out1,type=writable,binary=False,buffering=block (512)}
read and a read/write (should fail)
Right {loc=openFile005.out1,type=read-writable,binary=False,buffering=block (512)}
write and a read (should fail)
Right {loc=openFile005.out1,type=readable,binary=False,buffering=block (512)}
two writes, different files (silly, but should succeed)
two reads, should succeed
......@@ -4,12 +4,17 @@ module Main(main) where
import IO
import Directory ( removeFile, doesFileExist )
import Monad
#if defined(__MINGW32__)
import PrelHandle(hSetBinaryMode)
#endif
main = do
f <- doesFileExist "readwrite001.inout"
when f (removeFile "readwrite001.inout")
hdl <- openFile "readwrite001.inout" ReadWriteMode
# if defined(__MINGW32__)
hSetBinaryMode hdl True
# endif
hSetBuffering hdl LineBuffering
hPutStr hdl "as"
hSeek hdl AbsoluteSeek 0
......
......@@ -2,6 +2,9 @@
import IO
import Directory (removeFile, doesFileExist)
import Monad
#if defined(__MINGW32__)
import PrelHandle(hSetBinaryMode)
#endif
-- This test is weird, full marks to whoever dreamt it up!
......@@ -11,7 +14,9 @@ main = do
f <- doesFileExist username
when f (removeFile username)
cd <- openFile username ReadWriteMode
# if defined(__MINGW32__)
hSetBinaryMode cd True
# endif
hSetBuffering stdin NoBuffering
hSetBuffering stdout NoBuffering
hSetBuffering cd NoBuffering
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment