[project @ 2000-04-25 11:27:35 by rrt]
authorrrt <unknown>
Tue, 25 Apr 2000 11:27:35 +0000 (11:27 +0000)
committerrrt <unknown>
Tue, 25 Apr 2000 11:27:35 +0000 (11:27 +0000)
Numerous tweaks to remove out-of-date constructs and make tests Windows-
friendly.

20 files changed:
ghc/tests/io/should_run/Makefile
ghc/tests/io/should_run/io005.hs
ghc/tests/io/should_run/io006.hs
ghc/tests/io/should_run/io007.hs
ghc/tests/io/should_run/io007.stdout
ghc/tests/io/should_run/io008.hs
ghc/tests/io/should_run/io011.hs
ghc/tests/io/should_run/io012.hs
ghc/tests/io/should_run/io012.stdout
ghc/tests/io/should_run/io013.hs
ghc/tests/io/should_run/io014.hs
ghc/tests/io/should_run/io015.hs
ghc/tests/io/should_run/io016.hs
ghc/tests/io/should_run/io017.hs
ghc/tests/io/should_run/io018.hs
ghc/tests/io/should_run/io021.hs
ghc/tests/io/should_run/io024.hs
ghc/tests/io/should_run/io024.stdout
ghc/tests/io/should_run/io029.hs
ghc/tests/io/should_run/io031.hs

index 6cc9f8c..dcdd7e6 100644 (file)
@@ -1,11 +1,19 @@
 TOP = ../..
+
 include $(TOP)/mk/boilerplate.mk
+
+ifeq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
+OMITTED_RUNTESTS = io005.run io033.run
+endif
+
 include $(TOP)/mk/should_run.mk
 
 HC_OPTS += -dcore-lint
 io022_HC_OPTS += -fglasgow-exts
 io010_HC_OPTS += -fglasgow-exts
 io011_HC_OPTS += -fglasgow-exts
+io018_HC_OPTS += -fglasgow-exts
+io030_HC_OPTS += -fglasgow-exts
 io032_HC_OPTS += -fglasgow-exts
 
 io004_RUNTEST_OPTS += -x 42
index 0fd1f86..ac12847 100644 (file)
@@ -1,3 +1,5 @@
+-- Not run on mingw, because of /dev/null use
+
 import System (system, ExitCode(..), exitWith)
 
 main = 
index 27fc005..fe237d3 100644 (file)
@@ -1,4 +1,4 @@
-import IO -- 1.3
+import IO
 
 main = do
   hClose stderr
index 596a781..0cd2f7e 100644 (file)
@@ -1,4 +1,4 @@
-import IO -- 1.3
+import IO
 
 main =
     openFile "io007.hs" ReadMode >>= \ hIn ->
index 596a781..0cd2f7e 100644 (file)
@@ -1,4 +1,4 @@
-import IO -- 1.3
+import IO
 
 main =
     openFile "io007.hs" ReadMode >>= \ hIn ->
index 059e889..5a3e337 100644 (file)
@@ -1,15 +1,17 @@
+-- !!! Test file positioning
+
 module Main(main) where
 
-import IO -- 1.3
---import IOBase -- tryIO 1.3
---import GHCio
+import IO
+import Monad
 
-import Directory (removeFile)
+import Directory (removeFile, doesFileExist)
 
 main = do
-  hIn   <- openFile "io008.in" ReadMode
-  hOut  <- openFile "io008.out" ReadWriteMode
-  removeFile "io008.out"
+  hIn <- openFile "io008.in" ReadMode
+  f <- doesFileExist "io008.out"
+  when f (removeFile "io008.out")
+  hOut <- openFile "io008.out" ReadWriteMode
   bof <- hGetPosn hIn
   copy hIn hOut
   hSetPosn bof
@@ -23,4 +25,3 @@ copy hIn hOut =
     try (hGetChar hIn) >>=
     either (\ err -> if isEOFError err then return () else error "copy")
           ( \ x -> hPutChar hOut x >> copy hIn hOut)
-
index 62750f7..0df9e00 100644 (file)
@@ -1,4 +1,4 @@
-import IO -- 1.3
+import IO
 
 import Directory
 import IOExts (trace)
index 5b7fe9e..06114c6 100644 (file)
@@ -1,10 +1,11 @@
-import IO -- 1.3
+-- !!! Test getCPUTime
+
+import IO
 
 import CPUTime
 
 main = do
-    h <- openFile "/dev/null" WriteMode
-    hPrint h (nfib 30)
+    print (nfib 30)
     t <- getCPUTime
     print (length (show t)) -- printing the CPU time itself is un-cool if you want to diff the output..
 
index a59921e..de37140 100644 (file)
@@ -1,8 +1,6 @@
--- If you're testing on a Win32 box, be aware that
--- line termination conventions differ (and that
--- io013 uses /dev/null, which is also unix centric.)
+-- !!! Test seeking
 
-import IO -- 1.3
+import IO
 
 main = do
     h  <- openFile "io013.in" ReadMode
@@ -14,9 +12,6 @@ main = do
     hSeek h RelativeSeek (-2)
     w <- hGetChar h
     putStr (w:"\n")
-    ~True <- hIsSeekable h
-    hClose h
-    h <- openFile "/dev/null" ReadMode
-    ~False <- hIsSeekable h
+    True <- hIsSeekable h
     hClose h
 
index 5249fbc..9b956b0 100644 (file)
@@ -1,4 +1,4 @@
-import IO -- 1.3
+import IO
 
 main = 
     sequence (map hIsOpen [stdin, stdout, stderr]) >>= \ opens ->
@@ -16,7 +16,6 @@ main =
     sequence (map hIsNotBuffered [stdin, stdout, stderr]) >>= \ buffereds ->
     print buffereds
   where
-    -- these didn't make it into 1.3
     hIsBlockBuffered h = hGetBuffering h >>= \ b -> return $ case b of { BlockBuffering _ -> True; _ -> False }
     hIsLineBuffered  h = hGetBuffering h >>= \ b -> return $ case b of { LineBuffering -> True; _ -> False }
     hIsNotBuffered   h = hGetBuffering h >>= \ b -> return $ case b of { NoBuffering -> True; _ -> False }
index 37f0cc1..440493f 100644 (file)
@@ -1,4 +1,4 @@
-import IO -- 1.3
+import IO
 
 main =
     isEOF >>= \ eof ->
index a8b6eec..fc48cb5 100644 (file)
@@ -1,13 +1,14 @@
-import IO -- 1.3
+import IO
 
 import System (getArgs)
 import Char   (toUpper)
-import Directory (removeFile)
+import Directory (removeFile, doesFileExist)
 
 main   =  getArgs                           >>=        \ [f1,f2] ->
           openFile f1 ReadMode              >>=        \ h1      ->
+          doesFileExist f2                  >>=        \ f       ->
+          if f then removeFile f2 else return () >>
           openFile f2 WriteMode             >>=        \ h2      ->
-         removeFile f2                     >>
           copyFile h1 h2                    >>
           hClose h1                         >>
           hClose h2
index 2be7254..cba9fbd 100644 (file)
@@ -1,4 +1,4 @@
-import IO -- 1.3
+import IO
 
 main =
       hSetBuffering stdout NoBuffering                  >>
index 02b24bb..e465b5b 100644 (file)
@@ -1,17 +1,20 @@
 -- !!! Testing RW handles 
 module Main(main) where
 
-
 import IO
-import Directory (removeFile)
+import IOExts
+import Directory (removeFile, doesFileExist)
+import Monad
 
 -- This test is weird, full marks to whoever dreamt it up!
 
 main :: IO ()
 main = do
    let username = "io018.inout"
+   f <- doesFileExist username
+   when f (removeFile username)
    cd <- openFile username ReadWriteMode
-   removeFile username
+   hSetBinaryMode cd True
    hSetBuffering stdin NoBuffering
    hSetBuffering stdout NoBuffering
    hSetBuffering cd NoBuffering
@@ -28,14 +31,9 @@ main = do
 speakString = "Someone wants to speak with you\n"
 
 speak cd = do
-     (do
-        ready <- hReady cd
-        if ready then 
-          hGetChar cd >>= putChar
-        else
-          return ()
-        ready <- hReady stdin
-        if ready then (do { ch <- getChar; hPutChar cd ch})
-         else return ())
+     ready <- hReady cd
+     if ready then hGetChar cd >>= putChar else return ()
+     ready <- hReady stdin
+     if ready then (do { ch <- getChar; hPutChar cd ch}) else return ()
      speak cd
 
index c45a40b..396d435 100644 (file)
@@ -1,4 +1,4 @@
-import IO -- 1.3
+import IO
 
 main = 
     hSetBuffering stdin NoBuffering    >>
index d0c698b..ade7de7 100644 (file)
@@ -2,32 +2,34 @@
 module Main(main) where
 
 import IO
-import Directory ( removeFile )
+import Directory ( removeFile, doesFileExist )
+import Monad
 
 main = do
   sz <- hFileSize stdin `catch` (\ _ -> return (-1))
   print sz
-  let fn = "io025.out" 
+  let fn = "io025.out"
+  f <- doesFileExist fn
+  when f (removeFile fn)
   hdl <- openFile fn WriteMode
-  removeFile fn
-  hPutStrLn hdl "file_size"
+  hPutStr hdl "file_size"
    -- with default buffering
   sz <- hFileSize hdl
   print sz
 
   hSetBuffering hdl NoBuffering
-  hPutStrLn hdl "file_size"
+  hPutStr hdl "file_size"
    -- with no buffering
   sz <- hFileSize hdl
   print sz
   hSetBuffering hdl LineBuffering
-  hPutStrLn hdl "file_size"
+  hPutStr hdl "file_size"
    -- with line buffering
   sz <- hFileSize hdl
   print sz
   hSetBuffering hdl (BlockBuffering (Just 4))
    -- with block buffering
-  hPutStrLn hdl "file_size"
+  hPutStr hdl "file_size"
   sz <- hFileSize hdl
   print sz
   hClose hdl
index 8af2846..4eb722d 100644 (file)
@@ -2,7 +2,8 @@
 module Main(main) where
 
 import IO
-import Directory ( removeFile )
+import Directory ( removeFile, doesFileExist )
+import Monad
 
 main = do
   hFlush stdin `catch` \ _ -> putStrLn "No can do - flushing read-only handles isn't legal"
@@ -13,15 +14,18 @@ main = do
   hdl <- openFile "io029.hs" ReadMode
   hFlush hdl `catch` \ _ -> putStrLn "No can do - flushing read-only handles isn't legal"
   hClose hdl
+  remove
   hdl <- openFile "io029.out" WriteMode
-  removeFile "io029.out"
   hFlush hdl
   hClose hdl
+  remove
   hdl <- openFile "io029.out" AppendMode
-  removeFile "io029.out"
   hFlush hdl
   hClose hdl
+  remove
   hdl <- openFile "io029.out" ReadWriteMode
-  removeFile "io029.out"
   hFlush hdl
   hClose hdl
+ where remove = do
+         f <- doesFileExist "io029.out"
+         when f (removeFile "io029.out")
index 798c154..7cae451 100644 (file)
@@ -2,11 +2,13 @@
 module Main(main) where
 
 import IO
-import Directory ( removeFile )
+import Directory ( removeFile, doesFileExist )
+import Monad
 
-main = do 
+main = do
+  f <- doesFileExist "io031.inout" 
+  when f (removeFile "io031.inout")
   hdl <- openFile "io031.inout" ReadWriteMode
-  removeFile "io031.inout"
   hSetBuffering hdl LineBuffering
   hPutStr hdl "as"
   hSeek hdl AbsoluteSeek 0