summaryrefslogtreecommitdiff
path: root/ghc/tests
diff options
context:
space:
mode:
authorsewardj <unknown>2001-06-07 10:45:30 +0000
committersewardj <unknown>2001-06-07 10:45:30 +0000
commitbeedb87b728cb50e3d67ef208f00f8dd3e8ab5fb (patch)
tree16c4b42adfc7fb7a310b3470789f2a4b87aa11f9 /ghc/tests
parentf819f0f451c1599a5cc7e954c087dac592180a51 (diff)
downloadhaskell-beedb87b728cb50e3d67ef208f00f8dd3e8ab5fb.tar.gz
[project @ 2001-06-07 10:45:30 by sewardj]
Track current changes in the text-mode-seek-on-Windows saga.
Diffstat (limited to 'ghc/tests')
-rw-r--r--ghc/tests/lib/IO/Makefile6
-rw-r--r--ghc/tests/lib/IO/hGetLine001.hs6
-rw-r--r--ghc/tests/lib/IO/hGetLine001.stdout-mingw24
-rw-r--r--ghc/tests/lib/IO/hGetPosn001.hs8
-rw-r--r--ghc/tests/lib/IO/hIsEOF002.hs7
-rw-r--r--ghc/tests/lib/IO/hReady001.hs5
-rw-r--r--ghc/tests/lib/IO/hSeek001.hs5
-rw-r--r--ghc/tests/lib/IO/hSeek002.hs5
-rw-r--r--ghc/tests/lib/IO/hSeek003.hs5
-rw-r--r--ghc/tests/lib/IO/hSeek004.hs5
-rw-r--r--ghc/tests/lib/IO/ioeGetErrorString001.hs5
-rw-r--r--ghc/tests/lib/IO/ioeGetFileName001.hs5
-rw-r--r--ghc/tests/lib/IO/ioeGetHandle001.hs5
-rw-r--r--ghc/tests/lib/IO/openFile003.stdout-mingw16
-rw-r--r--ghc/tests/lib/IO/openFile005.stdout-mingw12
-rw-r--r--ghc/tests/lib/IO/readwrite001.hs5
-rw-r--r--ghc/tests/lib/IO/readwrite002.hs5
17 files changed, 126 insertions, 3 deletions
diff --git a/ghc/tests/lib/IO/Makefile b/ghc/tests/lib/IO/Makefile
index 3504bd5c96..05bbe3b036 100644
--- a/ghc/tests/lib/IO/Makefile
+++ b/ghc/tests/lib/IO/Makefile
@@ -1,5 +1,5 @@
# -----------------------------------------------------------------------------
-# $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
diff --git a/ghc/tests/lib/IO/hGetLine001.hs b/ghc/tests/lib/IO/hGetLine001.hs
index a950ab8a6c..2f612ad0b9 100644
--- a/ghc/tests/lib/IO/hGetLine001.hs
+++ b/ghc/tests/lib/IO/hGetLine001.hs
@@ -1,6 +1,9 @@
-- !!! 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
diff --git a/ghc/tests/lib/IO/hGetLine001.stdout-mingw b/ghc/tests/lib/IO/hGetLine001.stdout-mingw
index a70b13dbf9..d3dc4efc3c 100644
--- a/ghc/tests/lib/IO/hGetLine001.stdout-mingw
+++ b/ghc/tests/lib/IO/hGetLine001.stdout-mingw
@@ -1,6 +1,9 @@
-- !!! 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
diff --git a/ghc/tests/lib/IO/hGetPosn001.hs b/ghc/tests/lib/IO/hGetPosn001.hs
index f8726b577d..c1b68363bb 100644
--- a/ghc/tests/lib/IO/hGetPosn001.hs
+++ b/ghc/tests/lib/IO/hGetPosn001.hs
@@ -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
diff --git a/ghc/tests/lib/IO/hIsEOF002.hs b/ghc/tests/lib/IO/hIsEOF002.hs
index 78a654afb6..d2c607009d 100644
--- a/ghc/tests/lib/IO/hIsEOF002.hs
+++ b/ghc/tests/lib/IO/hIsEOF002.hs
@@ -1,10 +1,15 @@
-- !!! 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
diff --git a/ghc/tests/lib/IO/hReady001.hs b/ghc/tests/lib/IO/hReady001.hs
index daae59bb14..2c2431caa2 100644
--- a/ghc/tests/lib/IO/hReady001.hs
+++ b/ghc/tests/lib/IO/hReady001.hs
@@ -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
diff --git a/ghc/tests/lib/IO/hSeek001.hs b/ghc/tests/lib/IO/hSeek001.hs
index 98b75f5883..9bfd4bacd4 100644
--- a/ghc/tests/lib/IO/hSeek001.hs
+++ b/ghc/tests/lib/IO/hSeek001.hs
@@ -1,10 +1,15 @@
-- !!! 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
diff --git a/ghc/tests/lib/IO/hSeek002.hs b/ghc/tests/lib/IO/hSeek002.hs
index d11a3df8e0..c9b795fc9a 100644
--- a/ghc/tests/lib/IO/hSeek002.hs
+++ b/ghc/tests/lib/IO/hSeek002.hs
@@ -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
diff --git a/ghc/tests/lib/IO/hSeek003.hs b/ghc/tests/lib/IO/hSeek003.hs
index d6fa8e1492..6ab3015be0 100644
--- a/ghc/tests/lib/IO/hSeek003.hs
+++ b/ghc/tests/lib/IO/hSeek003.hs
@@ -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
diff --git a/ghc/tests/lib/IO/hSeek004.hs b/ghc/tests/lib/IO/hSeek004.hs
index 5078388fe1..bce810523c 100644
--- a/ghc/tests/lib/IO/hSeek004.hs
+++ b/ghc/tests/lib/IO/hSeek004.hs
@@ -1,8 +1,13 @@
-- !!! 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
diff --git a/ghc/tests/lib/IO/ioeGetErrorString001.hs b/ghc/tests/lib/IO/ioeGetErrorString001.hs
index dc47f91513..0a34e4bfc6 100644
--- a/ghc/tests/lib/IO/ioeGetErrorString001.hs
+++ b/ghc/tests/lib/IO/ioeGetErrorString001.hs
@@ -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
diff --git a/ghc/tests/lib/IO/ioeGetFileName001.hs b/ghc/tests/lib/IO/ioeGetFileName001.hs
index ee7ec29eb0..dd60f6889e 100644
--- a/ghc/tests/lib/IO/ioeGetFileName001.hs
+++ b/ghc/tests/lib/IO/ioeGetFileName001.hs
@@ -1,10 +1,15 @@
-- !!! 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
diff --git a/ghc/tests/lib/IO/ioeGetHandle001.hs b/ghc/tests/lib/IO/ioeGetHandle001.hs
index e7e8f71409..dc3d375acc 100644
--- a/ghc/tests/lib/IO/ioeGetHandle001.hs
+++ b/ghc/tests/lib/IO/ioeGetHandle001.hs
@@ -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
diff --git a/ghc/tests/lib/IO/openFile003.stdout-mingw b/ghc/tests/lib/IO/openFile003.stdout-mingw
new file mode 100644
index 0000000000..f7d4410620
--- /dev/null
+++ b/ghc/tests/lib/IO/openFile003.stdout-mingw
@@ -0,0 +1,16 @@
+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: .
diff --git a/ghc/tests/lib/IO/openFile005.stdout-mingw b/ghc/tests/lib/IO/openFile005.stdout-mingw
new file mode 100644
index 0000000000..9c97133bc1
--- /dev/null
+++ b/ghc/tests/lib/IO/openFile005.stdout-mingw
@@ -0,0 +1,12 @@
+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
diff --git a/ghc/tests/lib/IO/readwrite001.hs b/ghc/tests/lib/IO/readwrite001.hs
index c3b542df85..ebd80cf080 100644
--- a/ghc/tests/lib/IO/readwrite001.hs
+++ b/ghc/tests/lib/IO/readwrite001.hs
@@ -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
diff --git a/ghc/tests/lib/IO/readwrite002.hs b/ghc/tests/lib/IO/readwrite002.hs
index 0743e1999a..cd6e34db1e 100644
--- a/ghc/tests/lib/IO/readwrite002.hs
+++ b/ghc/tests/lib/IO/readwrite002.hs
@@ -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