diff options
Diffstat (limited to 'ghc/tests')
| -rw-r--r-- | ghc/tests/deSugar/should_compile/ds046.hs | 9 | ||||
| -rw-r--r-- | ghc/tests/io/should_run/io001.hs | 1 | ||||
| -rw-r--r-- | ghc/tests/io/should_run/io007.hs | 11 | ||||
| -rw-r--r-- | ghc/tests/io/should_run/io007.stdout | 11 | ||||
| -rw-r--r-- | ghc/tests/io/should_run/io013.hs | 17 | ||||
| -rw-r--r-- | ghc/tests/io/should_run/io013.stdout | 3 | ||||
| -rw-r--r-- | ghc/tests/io/should_run/io015.hs | 10 | ||||
| -rw-r--r-- | ghc/tests/io/should_run/io016.hs | 24 | ||||
| -rw-r--r-- | ghc/tests/io/should_run/io016.stdout | 0 | ||||
| -rw-r--r-- | ghc/tests/io/should_run/io017.hs | 19 | ||||
| -rw-r--r-- | ghc/tests/io/should_run/io018.stdout | 46 | ||||
| -rw-r--r-- | ghc/tests/io/should_run/io023.stdout | 1 | ||||
| -rw-r--r-- | ghc/tests/io/should_run/io026.hs | 10 | ||||
| -rw-r--r-- | ghc/tests/io/should_run/io035.stdout | 10 | ||||
| -rw-r--r-- | ghc/tests/lib/CPUTime/CPUTime001.hs (renamed from ghc/tests/io/should_run/io012.hs) | 0 | ||||
| -rw-r--r-- | ghc/tests/lib/CPUTime/CPUTime001.stdout (renamed from ghc/tests/io/should_run/io012.stdout) | 0 | ||||
| -rw-r--r-- | ghc/tests/lib/Directory/currentDirectory001.hs (renamed from ghc/tests/io/should_run/io010.hs) | 0 | ||||
| -rw-r--r-- | ghc/tests/lib/Directory/currentDirectory001.stdout (renamed from ghc/tests/io/should_run/io006.stdout) | 0 | ||||
| -rw-r--r-- | ghc/tests/lib/Directory/directory001.hs (renamed from ghc/tests/io/should_run/io011.hs) | 0 | ||||
| -rw-r--r-- | ghc/tests/lib/Directory/directory001.stdout (renamed from ghc/tests/io/should_run/io010.stdout) | 0 | ||||
| -rw-r--r-- | ghc/tests/lib/Directory/getDirectoryContents001.hs (renamed from ghc/tests/io/should_run/io009.hs) | 0 | ||||
| -rw-r--r-- | ghc/tests/lib/Directory/getDirectoryContents001.stdout (renamed from ghc/tests/io/should_run/io009.stdout) | 0 | ||||
| -rw-r--r-- | ghc/tests/lib/Directory/getPermissions001.hs (renamed from ghc/tests/io/should_run/io034.hs) | 0 | ||||
| -rw-r--r-- | ghc/tests/lib/Directory/getPermissions001.stdout (renamed from ghc/tests/io/should_run/io034.stdout) | 0 | ||||
| -rw-r--r-- | ghc/tests/lib/Directory/getPermissions001.stdout-mingw (renamed from ghc/tests/io/should_run/io034.stdout-mingw) | 0 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/IOError001.hs (renamed from ghc/tests/io/should_run/io035.hs) | 0 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/IOError001.stdout | 8 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/IOError001.stdout-mingw (renamed from ghc/tests/io/should_run/io035.stdout-mingw) | 0 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/Makefile | 30 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/finalization001.hs (renamed from ghc/tests/io/should_run/io033.hs) | 2 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/finalization001.stdout (renamed from ghc/tests/io/should_run/io033.stdout) | 0 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/hClose001.hs (renamed from ghc/tests/io/should_run/io006.hs) | 0 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/hClose001.stdout (renamed from ghc/tests/io/should_run/io011.stdout) | 0 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/hFileSize001.hs | 8 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/hFileSize001.stdout | 1 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/hFileSize002.hs (renamed from ghc/tests/io/should_run/io024.hs) | 2 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/hFileSize002.stdout (renamed from ghc/tests/io/should_run/io024.stdout) | 0 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/hFlush001.hs (renamed from ghc/tests/io/should_run/io029.hs) | 12 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/hFlush001.stdout (renamed from ghc/tests/io/should_run/io029.stdout) | 0 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/hGetBuffering001.hs (renamed from ghc/tests/io/should_run/io014.hs) | 0 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/hGetBuffering001.stdout (renamed from ghc/tests/io/should_run/io014.stdout) | 0 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/hGetChar001.hs | 18 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/hGetChar001.stdin (renamed from ghc/tests/io/should_run/io017.stdin) | 0 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/hGetChar001.stdout (renamed from ghc/tests/io/should_run/io017.stdout) | 0 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/hGetLine001.hs | 22 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/hGetLine001.stdout | 88 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/hGetPosn001.hs (renamed from ghc/tests/io/should_run/io008.hs) | 8 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/hGetPosn001.in (renamed from ghc/tests/io/should_run/io008.in) | 0 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/hGetPosn001.stdout (renamed from ghc/tests/io/should_run/io008.stdout) | 0 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/hIsEOF001.hs (renamed from ghc/tests/io/should_run/io027.hs) | 1 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/hIsEOF001.stdout (renamed from ghc/tests/io/should_run/io027.stdout) | 0 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/hIsEOF002.hs | 48 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/hIsEOF002.stdout | 16 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/hReady001.hs | 11 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/hSeek001.hs | 29 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/hSeek001.in (renamed from ghc/tests/io/should_run/io013.in) | 0 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/hSeek001.stdout | 7 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/hSeek002.hs (renamed from ghc/tests/io/should_run/io025.hs) | 2 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/hSeek002.stdout (renamed from ghc/tests/io/should_run/io025.stdout) | 0 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/hSeek003.hs (renamed from ghc/tests/io/should_run/io030.hs) | 2 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/hSeek003.stdout (renamed from ghc/tests/io/should_run/io030.stdout) | 0 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/hSeek004.hs | 7 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/hSeek004.stdout | 5 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/hSetBuffering002.hs (renamed from ghc/tests/io/should_run/io021.hs) | 0 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/hSetBuffering002.stdout (renamed from ghc/tests/io/should_run/io021.stdout) | 0 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/hSetBuffering003.hs (renamed from ghc/tests/io/should_run/io028.hs) | 0 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/hSetBuffering003.stderr (renamed from ghc/tests/io/should_run/io028.stderr) | 0 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/hSetBuffering003.stdout (renamed from ghc/tests/io/should_run/io028.stdout) | 0 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/ioeGetErrorString001.hs | 12 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/ioeGetErrorString001.stdout | 1 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/ioeGetFileName001.hs | 11 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/ioeGetFileName001.stdout | 1 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/ioeGetHandle001.hs | 12 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/ioeGetHandle001.stdout | 1 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/isEOF001.hs | 3 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/isEOF001.stdout (renamed from ghc/tests/io/should_run/io020.stdout) | 0 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/misc001.hs | 24 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/misc001.stdout (renamed from ghc/tests/io/should_run/io004.stdout) | 0 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/openFile001.hs | 10 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/openFile001.stdout | 1 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/openFile002.hs | 6 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/openFile002.stderr | 6 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/openFile003.hs | 13 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/openFile003.stdout | 16 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/openFile004.hs | 23 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/openFile004.stdout | 1 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/openFile005.hs | 44 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/openFile005.stdout | 20 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/openFile006.hs | 14 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/openFile006.stdout | 2 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/putStr001.hs (renamed from ghc/tests/io/should_run/io023.hs) | 5 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/putStr001.stdout (renamed from ghc/tests/io/should_run/io001.stdout) | 0 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/readwrite001.hs (renamed from ghc/tests/io/should_run/io031.hs) | 6 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/readwrite001.stdout (renamed from ghc/tests/io/should_run/io031.stdout) | 0 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/readwrite002.hs (renamed from ghc/tests/io/should_run/io018.hs) | 9 | ||||
| -rw-r--r-- | ghc/tests/lib/IO/readwrite002.stdout | 9 | ||||
| -rw-r--r-- | ghc/tests/lib/IOExts/echo001.hs (renamed from ghc/tests/io/should_run/io022.hs) | 0 | ||||
| -rw-r--r-- | ghc/tests/lib/IOExts/echo001.stdout (renamed from ghc/tests/io/should_run/io022.stdout) | 0 | ||||
| -rw-r--r-- | ghc/tests/lib/IOExts/trace001.hs (renamed from ghc/tests/io/should_run/io032.hs) | 0 | ||||
| -rw-r--r-- | ghc/tests/lib/IOExts/trace001.stderr (renamed from ghc/tests/io/should_run/io032.stderr) | 0 | ||||
| -rw-r--r-- | ghc/tests/lib/IOExts/trace001.stdout (renamed from ghc/tests/io/should_run/io032.stdout) | 0 | ||||
| -rw-r--r-- | ghc/tests/lib/System/Makefile (renamed from ghc/tests/io/should_run/Makefile) | 0 | ||||
| -rw-r--r-- | ghc/tests/lib/System/exitWith001.hs (renamed from ghc/tests/io/should_run/io004.hs) | 0 | ||||
| -rw-r--r-- | ghc/tests/lib/System/exitWith001.stdout (renamed from ghc/tests/io/should_run/io015.stdout) | 0 | ||||
| -rw-r--r-- | ghc/tests/lib/System/getArgs001.hs (renamed from ghc/tests/io/should_run/io003.hs) | 0 | ||||
| -rw-r--r-- | ghc/tests/lib/System/getArgs001.stdout (renamed from ghc/tests/io/should_run/io003.stdout) | 0 | ||||
| -rw-r--r-- | ghc/tests/lib/System/getArgs001.stdout-mingw (renamed from ghc/tests/io/should_run/io003.stdout-mingw) | 0 | ||||
| -rw-r--r-- | ghc/tests/lib/System/getEnv001.hs (renamed from ghc/tests/io/should_run/io002.hs) | 0 | ||||
| -rw-r--r-- | ghc/tests/lib/System/getEnv001.stdout (renamed from ghc/tests/io/should_run/io002.stdout) | 0 | ||||
| -rw-r--r-- | ghc/tests/lib/System/system001.hs (renamed from ghc/tests/io/should_run/io005.hs) | 0 | ||||
| -rw-r--r-- | ghc/tests/lib/System/system001.stdout (renamed from ghc/tests/io/should_run/io005.stdout) | 0 | ||||
| -rw-r--r-- | ghc/tests/lib/Time/time001.hs (renamed from ghc/tests/lib/should_run/time001.hs) | 0 | ||||
| -rw-r--r-- | ghc/tests/lib/Time/time001.stdout (renamed from ghc/tests/lib/should_run/time001.stdout) | 0 | ||||
| -rw-r--r-- | ghc/tests/lib/Time/time002.hs (renamed from ghc/tests/lib/should_run/time002.hs) | 0 | ||||
| -rw-r--r-- | ghc/tests/lib/Time/time002.stdout (renamed from ghc/tests/lib/should_run/time002.stdout) | 0 | ||||
| -rw-r--r-- | ghc/tests/lib/Time/time003.hs (renamed from ghc/tests/io/should_run/io019.hs) | 0 | ||||
| -rw-r--r-- | ghc/tests/lib/Time/time003.stdout (renamed from ghc/tests/io/should_run/io019.stdout) | 0 | ||||
| -rw-r--r-- | ghc/tests/lib/Time/time004.hs (renamed from ghc/tests/io/should_run/io020.hs) | 0 | ||||
| -rw-r--r-- | ghc/tests/lib/Time/time004.stdout (renamed from ghc/tests/io/should_run/io026.stdout) | 0 |
119 files changed, 557 insertions, 192 deletions
diff --git a/ghc/tests/deSugar/should_compile/ds046.hs b/ghc/tests/deSugar/should_compile/ds046.hs index 5126ff3df4..7096f2bdf0 100644 --- a/ghc/tests/deSugar/should_compile/ds046.hs +++ b/ghc/tests/deSugar/should_compile/ds046.hs @@ -7,8 +7,8 @@ data T = T !Int t (T i) = i + 1 -- test 2: mutual recursion (should back off from unboxing either field) -data R = R !R -data S = S !S +data R = R !S +data S = S !R r (R s) = s @@ -34,3 +34,8 @@ data F a b = F { x :: !Int, y :: !(Float,Float), z :: !(a,b) } l F{x = a} = a m (F a b c) = a n F{z = (a,b)} = a + +-- test 7: newtypes +newtype G a b = G (F a b) +data H a b = H !Int !(G a b) !Int +o (H y (G (F{ x=x })) z) = x + z diff --git a/ghc/tests/io/should_run/io001.hs b/ghc/tests/io/should_run/io001.hs deleted file mode 100644 index 6620e3c1fe..0000000000 --- a/ghc/tests/io/should_run/io001.hs +++ /dev/null @@ -1 +0,0 @@ -main = putStr "Hello, world\n" diff --git a/ghc/tests/io/should_run/io007.hs b/ghc/tests/io/should_run/io007.hs deleted file mode 100644 index 0cd2f7e9ff..0000000000 --- a/ghc/tests/io/should_run/io007.hs +++ /dev/null @@ -1,11 +0,0 @@ -import IO - -main = - openFile "io007.hs" ReadMode >>= \ hIn -> - hPutStr hIn "test" `catch` - \ err -> - if isIllegalOperation err then - hGetContents hIn >>= \ stuff -> - hPutStr stdout stuff - else - error "Oh dear\n" diff --git a/ghc/tests/io/should_run/io007.stdout b/ghc/tests/io/should_run/io007.stdout deleted file mode 100644 index 0cd2f7e9ff..0000000000 --- a/ghc/tests/io/should_run/io007.stdout +++ /dev/null @@ -1,11 +0,0 @@ -import IO - -main = - openFile "io007.hs" ReadMode >>= \ hIn -> - hPutStr hIn "test" `catch` - \ err -> - if isIllegalOperation err then - hGetContents hIn >>= \ stuff -> - hPutStr stdout stuff - else - error "Oh dear\n" diff --git a/ghc/tests/io/should_run/io013.hs b/ghc/tests/io/should_run/io013.hs deleted file mode 100644 index de3714002f..0000000000 --- a/ghc/tests/io/should_run/io013.hs +++ /dev/null @@ -1,17 +0,0 @@ --- !!! Test seeking - -import IO - -main = do - h <- openFile "io013.in" ReadMode - sz <- hFileSize h - print sz - hSeek h SeekFromEnd (-3) - x <- hGetChar h - putStr (x:"\n") - hSeek h RelativeSeek (-2) - w <- hGetChar h - putStr (w:"\n") - True <- hIsSeekable h - hClose h - diff --git a/ghc/tests/io/should_run/io013.stdout b/ghc/tests/io/should_run/io013.stdout deleted file mode 100644 index cffb0fdf87..0000000000 --- a/ghc/tests/io/should_run/io013.stdout +++ /dev/null @@ -1,3 +0,0 @@ -26 -x -w diff --git a/ghc/tests/io/should_run/io015.hs b/ghc/tests/io/should_run/io015.hs deleted file mode 100644 index 440493fce2..0000000000 --- a/ghc/tests/io/should_run/io015.hs +++ /dev/null @@ -1,10 +0,0 @@ -import IO - -main = - isEOF >>= \ eof -> - if eof then - return () - else - getChar >>= \ c -> - putChar c >> - main diff --git a/ghc/tests/io/should_run/io016.hs b/ghc/tests/io/should_run/io016.hs deleted file mode 100644 index fc48cb5b53..0000000000 --- a/ghc/tests/io/should_run/io016.hs +++ /dev/null @@ -1,24 +0,0 @@ -import IO - -import System (getArgs) -import Char (toUpper) -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 -> - copyFile h1 h2 >> - hClose h1 >> - hClose h2 - -copyFile h1 h2 = - hIsEOF h1 >>= \ eof -> - if eof then - return () - else - hGetChar h1 >>= \ c -> - hPutChar h2 (toUpper c) >> - copyFile h1 h2 - diff --git a/ghc/tests/io/should_run/io016.stdout b/ghc/tests/io/should_run/io016.stdout deleted file mode 100644 index e69de29bb2..0000000000 --- a/ghc/tests/io/should_run/io016.stdout +++ /dev/null diff --git a/ghc/tests/io/should_run/io017.hs b/ghc/tests/io/should_run/io017.hs deleted file mode 100644 index 4f8ec1f869..0000000000 --- a/ghc/tests/io/should_run/io017.hs +++ /dev/null @@ -1,19 +0,0 @@ -import IO - -main = - hSetBuffering stdout NoBuffering >> - putStr "Enter an integer: " >> - readLine >>= \ x1 -> - putStr "Enter another integer: " >> - readLine >>= \ x2 -> - putStr ("Their sum is " ++ show (read x1 + read x2 :: Int) ++ "\n") - - where readLine = isEOF >>= \ eof -> - if eof then return [] - else getChar >>= \ c -> - if c `elem` ['\n','\r'] then - return [] - else - readLine >>= \ cs -> - return (c:cs) - diff --git a/ghc/tests/io/should_run/io018.stdout b/ghc/tests/io/should_run/io018.stdout deleted file mode 100644 index 281e7acbaa..0000000000 --- a/ghc/tests/io/should_run/io018.stdout +++ /dev/null @@ -1,46 +0,0 @@ -Smoewnst pa ihyu -Caught EOF -S-m-o e!w!n -Caught EOF -S-m-o e!w!n!s tT epsat iinhgy uR!s tT epsat iinhgy uRW handles -module Main(main) where - -import IO -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 - hSetBinaryMode cd True - hSetBuffering stdin NoBuffering - hSetBuffering stdout NoBuffering - hSetBuffering cd NoBuffering - hPutStr cd speakString - hSeek cd AbsoluteSeek 0 - speak cd `catch` \ err -> if isEOFError err then putStrLn "\nCaught EOF" else ioError err - hSeek cd AbsoluteSeek 0 - hSetBuffering cd LineBuffering - speak cd `catch` \ err -> if isEOFError err then putStrLn "\nCaught EOF" else ioError err - hSeek cd AbsoluteSeek 0 - hSetBuffering cd (BlockBuffering Nothing) - speak cd `catch` \ err -> if isEOFError err then putStrLn "\nCaught EOF" else ioError err - -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 <- ge -Caught EOF diff --git a/ghc/tests/io/should_run/io023.stdout b/ghc/tests/io/should_run/io023.stdout deleted file mode 100644 index 5ab2f8a432..0000000000 --- a/ghc/tests/io/should_run/io023.stdout +++ /dev/null @@ -1 +0,0 @@ -Hello
\ No newline at end of file diff --git a/ghc/tests/io/should_run/io026.hs b/ghc/tests/io/should_run/io026.hs deleted file mode 100644 index d89fb31589..0000000000 --- a/ghc/tests/io/should_run/io026.hs +++ /dev/null @@ -1,10 +0,0 @@ --- !!! isEOF -module Main(main) where - -import IO ( isEOF ) - -main = do - flg <- isEOF - print flg - - diff --git a/ghc/tests/io/should_run/io035.stdout b/ghc/tests/io/should_run/io035.stdout deleted file mode 100644 index 3fe2102e60..0000000000 --- a/ghc/tests/io/should_run/io035.stdout +++ /dev/null @@ -1,10 +0,0 @@ -illegal operation -Action: hGetChar -Handle: {loc=stdin,type=semi-closed,buffering=block (8192)} - -Reason: handle is closed -illegal operation -Action: hGetChar -Handle: {loc=stdin,type=semi-closed,buffering=block (8192)} - -Reason: handle is closed diff --git a/ghc/tests/io/should_run/io012.hs b/ghc/tests/lib/CPUTime/CPUTime001.hs index 807bbb7895..807bbb7895 100644 --- a/ghc/tests/io/should_run/io012.hs +++ b/ghc/tests/lib/CPUTime/CPUTime001.hs diff --git a/ghc/tests/io/should_run/io012.stdout b/ghc/tests/lib/CPUTime/CPUTime001.stdout index 032e7595f0..032e7595f0 100644 --- a/ghc/tests/io/should_run/io012.stdout +++ b/ghc/tests/lib/CPUTime/CPUTime001.stdout diff --git a/ghc/tests/io/should_run/io010.hs b/ghc/tests/lib/Directory/currentDirectory001.hs index bcf9b96ce3..bcf9b96ce3 100644 --- a/ghc/tests/io/should_run/io010.hs +++ b/ghc/tests/lib/Directory/currentDirectory001.hs diff --git a/ghc/tests/io/should_run/io006.stdout b/ghc/tests/lib/Directory/currentDirectory001.stdout index 1ddd42bbe7..1ddd42bbe7 100644 --- a/ghc/tests/io/should_run/io006.stdout +++ b/ghc/tests/lib/Directory/currentDirectory001.stdout diff --git a/ghc/tests/io/should_run/io011.hs b/ghc/tests/lib/Directory/directory001.hs index 0df9e00c90..0df9e00c90 100644 --- a/ghc/tests/io/should_run/io011.hs +++ b/ghc/tests/lib/Directory/directory001.hs diff --git a/ghc/tests/io/should_run/io010.stdout b/ghc/tests/lib/Directory/directory001.stdout index 1ddd42bbe7..1ddd42bbe7 100644 --- a/ghc/tests/io/should_run/io010.stdout +++ b/ghc/tests/lib/Directory/directory001.stdout diff --git a/ghc/tests/io/should_run/io009.hs b/ghc/tests/lib/Directory/getDirectoryContents001.hs index 829a9f9df4..829a9f9df4 100644 --- a/ghc/tests/io/should_run/io009.hs +++ b/ghc/tests/lib/Directory/getDirectoryContents001.hs diff --git a/ghc/tests/io/should_run/io009.stdout b/ghc/tests/lib/Directory/getDirectoryContents001.stdout index 55dab93156..55dab93156 100644 --- a/ghc/tests/io/should_run/io009.stdout +++ b/ghc/tests/lib/Directory/getDirectoryContents001.stdout diff --git a/ghc/tests/io/should_run/io034.hs b/ghc/tests/lib/Directory/getPermissions001.hs index 97faf05d58..97faf05d58 100644 --- a/ghc/tests/io/should_run/io034.hs +++ b/ghc/tests/lib/Directory/getPermissions001.hs diff --git a/ghc/tests/io/should_run/io034.stdout b/ghc/tests/lib/Directory/getPermissions001.stdout index b827957934..b827957934 100644 --- a/ghc/tests/io/should_run/io034.stdout +++ b/ghc/tests/lib/Directory/getPermissions001.stdout diff --git a/ghc/tests/io/should_run/io034.stdout-mingw b/ghc/tests/lib/Directory/getPermissions001.stdout-mingw index b200d03aed..b200d03aed 100644 --- a/ghc/tests/io/should_run/io034.stdout-mingw +++ b/ghc/tests/lib/Directory/getPermissions001.stdout-mingw diff --git a/ghc/tests/io/should_run/io035.hs b/ghc/tests/lib/IO/IOError001.hs index dee7f31e29..dee7f31e29 100644 --- a/ghc/tests/io/should_run/io035.hs +++ b/ghc/tests/lib/IO/IOError001.hs diff --git a/ghc/tests/lib/IO/IOError001.stdout b/ghc/tests/lib/IO/IOError001.stdout new file mode 100644 index 0000000000..4a50380db8 --- /dev/null +++ b/ghc/tests/lib/IO/IOError001.stdout @@ -0,0 +1,8 @@ +illegal operation +Action: hGetChar +Handle: {loc=<stdin>,type=semi-closed,buffering=block (8192)} +File: <stdin> +illegal operation +Action: hGetChar +Handle: {loc=<stdin>,type=semi-closed,buffering=block (8192)} +File: <stdin> diff --git a/ghc/tests/io/should_run/io035.stdout-mingw b/ghc/tests/lib/IO/IOError001.stdout-mingw index f906a77aa7..f906a77aa7 100644 --- a/ghc/tests/io/should_run/io035.stdout-mingw +++ b/ghc/tests/lib/IO/IOError001.stdout-mingw diff --git a/ghc/tests/lib/IO/Makefile b/ghc/tests/lib/IO/Makefile new file mode 100644 index 0000000000..9d3e242b3a --- /dev/null +++ b/ghc/tests/lib/IO/Makefile @@ -0,0 +1,30 @@ +# ----------------------------------------------------------------------------- +# $Id: Makefile,v 1.1 2001/05/18 16:54:08 simonmar Exp $ + +TOP = ../.. + +include $(TOP)/mk/boilerplate.mk + +ifeq "$(TARGETPLATFORM)" "i386-unknown-mingw32" +# io018 should run +OMITTED_RUNTESTS = io005.run io018.run io033.run +endif + +include $(TOP)/mk/should_run.mk + +SRC_HC_OPTS += -dcore-lint + +hSetBuffering002_RUNTEST_OPTS += -i hSetBuffering002.hs +hSetBuffering003_RUNTEST_OPTS += -i hSetBuffering003.hs +misc001_RUNTEST_OPTS += misc001.hs misc001.out +hGetChar001_RUNTEST_OPTS += -i hGetChar001.stdin +openFile002_RUNTEST_OPTS += -x 1 +IOError001_RUNTEST_OPTS += -o1 IOError001.stdout-mingw +readwrite002_RUNTEST_OPTS += -i readwrite002.hs +hGetLine001_RUNTEST_OPTS += -i hGetLine001.hs + +.PRECIOUS: %.o %.bin + +CLEAN_FILES += *.out* *.inout + +include $(TOP)/mk/target.mk diff --git a/ghc/tests/io/should_run/io033.hs b/ghc/tests/lib/IO/finalization001.hs index 0e8620ce03..a4b4b28ab2 100644 --- a/ghc/tests/io/should_run/io033.hs +++ b/ghc/tests/lib/IO/finalization001.hs @@ -9,7 +9,7 @@ import System doTest :: IO () doTest = do - sd <- openFile "io033.hs" ReadWriteMode + sd <- openFile "finalization001.hs" ReadWriteMode result <- hGetContents sd slurp result hClose sd diff --git a/ghc/tests/io/should_run/io033.stdout b/ghc/tests/lib/IO/finalization001.stdout index ec04732f97..ec04732f97 100644 --- a/ghc/tests/io/should_run/io033.stdout +++ b/ghc/tests/lib/IO/finalization001.stdout diff --git a/ghc/tests/io/should_run/io006.hs b/ghc/tests/lib/IO/hClose001.hs index fe237d33ef..fe237d33ef 100644 --- a/ghc/tests/io/should_run/io006.hs +++ b/ghc/tests/lib/IO/hClose001.hs diff --git a/ghc/tests/io/should_run/io011.stdout b/ghc/tests/lib/IO/hClose001.stdout index 1ddd42bbe7..1ddd42bbe7 100644 --- a/ghc/tests/io/should_run/io011.stdout +++ b/ghc/tests/lib/IO/hClose001.stdout diff --git a/ghc/tests/lib/IO/hFileSize001.hs b/ghc/tests/lib/IO/hFileSize001.hs new file mode 100644 index 0000000000..6326425095 --- /dev/null +++ b/ghc/tests/lib/IO/hFileSize001.hs @@ -0,0 +1,8 @@ +import IO + +-- !!! test hFileSize + +main = do + h <- openFile "hFileSize001.hs" ReadMode + sz <- hFileSize h + print sz diff --git a/ghc/tests/lib/IO/hFileSize001.stdout b/ghc/tests/lib/IO/hFileSize001.stdout new file mode 100644 index 0000000000..d136d6a714 --- /dev/null +++ b/ghc/tests/lib/IO/hFileSize001.stdout @@ -0,0 +1 @@ +125 diff --git a/ghc/tests/io/should_run/io024.hs b/ghc/tests/lib/IO/hFileSize002.hs index ade7de7de7..d2213bfc4a 100644 --- a/ghc/tests/io/should_run/io024.hs +++ b/ghc/tests/lib/IO/hFileSize002.hs @@ -8,7 +8,7 @@ import Monad main = do sz <- hFileSize stdin `catch` (\ _ -> return (-1)) print sz - let fn = "io025.out" + let fn = "hFileSize002.out" f <- doesFileExist fn when f (removeFile fn) hdl <- openFile fn WriteMode diff --git a/ghc/tests/io/should_run/io024.stdout b/ghc/tests/lib/IO/hFileSize002.stdout index 23dd734048..23dd734048 100644 --- a/ghc/tests/io/should_run/io024.stdout +++ b/ghc/tests/lib/IO/hFileSize002.stdout diff --git a/ghc/tests/io/should_run/io029.hs b/ghc/tests/lib/IO/hFlush001.hs index 4eb722d507..059b3adc1a 100644 --- a/ghc/tests/io/should_run/io029.hs +++ b/ghc/tests/lib/IO/hFlush001.hs @@ -11,21 +11,21 @@ main = do hFlush stdout putStr "Hello - " hFlush stderr - hdl <- openFile "io029.hs" ReadMode + hdl <- openFile "hFlush001.hs" ReadMode hFlush hdl `catch` \ _ -> putStrLn "No can do - flushing read-only handles isn't legal" hClose hdl remove - hdl <- openFile "io029.out" WriteMode + hdl <- openFile "hFlush001.out" WriteMode hFlush hdl hClose hdl remove - hdl <- openFile "io029.out" AppendMode + hdl <- openFile "hFlush001.out" AppendMode hFlush hdl hClose hdl remove - hdl <- openFile "io029.out" ReadWriteMode + hdl <- openFile "hFlush001.out" ReadWriteMode hFlush hdl hClose hdl where remove = do - f <- doesFileExist "io029.out" - when f (removeFile "io029.out") + f <- doesFileExist "hFlush001.out" + when f (removeFile "hFlush001.out") diff --git a/ghc/tests/io/should_run/io029.stdout b/ghc/tests/lib/IO/hFlush001.stdout index 0954a7a0b4..0954a7a0b4 100644 --- a/ghc/tests/io/should_run/io029.stdout +++ b/ghc/tests/lib/IO/hFlush001.stdout diff --git a/ghc/tests/io/should_run/io014.hs b/ghc/tests/lib/IO/hGetBuffering001.hs index 9b956b0073..9b956b0073 100644 --- a/ghc/tests/io/should_run/io014.hs +++ b/ghc/tests/lib/IO/hGetBuffering001.hs diff --git a/ghc/tests/io/should_run/io014.stdout b/ghc/tests/lib/IO/hGetBuffering001.stdout index 75b9a133d9..75b9a133d9 100644 --- a/ghc/tests/io/should_run/io014.stdout +++ b/ghc/tests/lib/IO/hGetBuffering001.stdout diff --git a/ghc/tests/lib/IO/hGetChar001.hs b/ghc/tests/lib/IO/hGetChar001.hs new file mode 100644 index 0000000000..18ba4fe40b --- /dev/null +++ b/ghc/tests/lib/IO/hGetChar001.hs @@ -0,0 +1,18 @@ +import IO + +main = do + hSetBuffering stdout NoBuffering + putStr "Enter an integer: " + x1 <- readLine + putStr "Enter another integer: " + x2 <- readLine + putStr ("Their sum is " ++ show (read x1 + read x2 :: Int) ++ "\n") + + where readLine = do + eof <- isEOF + if eof then return [] else do + c <- getChar + if c `elem` ['\n','\r'] + then return [] + else do cs <- readLine + return (c:cs) diff --git a/ghc/tests/io/should_run/io017.stdin b/ghc/tests/lib/IO/hGetChar001.stdin index 2510fcaec3..2510fcaec3 100644 --- a/ghc/tests/io/should_run/io017.stdin +++ b/ghc/tests/lib/IO/hGetChar001.stdin diff --git a/ghc/tests/io/should_run/io017.stdout b/ghc/tests/lib/IO/hGetChar001.stdout index 47d4185c64..47d4185c64 100644 --- a/ghc/tests/io/should_run/io017.stdout +++ b/ghc/tests/lib/IO/hGetChar001.stdout diff --git a/ghc/tests/lib/IO/hGetLine001.hs b/ghc/tests/lib/IO/hGetLine001.hs new file mode 100644 index 0000000000..cb60e0625b --- /dev/null +++ b/ghc/tests/lib/IO/hGetLine001.hs @@ -0,0 +1,22 @@ +-- !!! testing hGetLine + +import IO + +-- one version of 'cat' +main = do + let loop h = do b <- hIsEOF h + if b then return () + else do l <- hGetLine h; putStrLn l; loop h + loop stdin + + h <- openFile "hGetLine001.hs" ReadMode + hSetBuffering h NoBuffering + loop h + + hSeek h AbsoluteSeek 0 + hSetBuffering h LineBuffering + loop h + + hSeek h AbsoluteSeek 0 + hSetBuffering h (BlockBuffering (Just 83)) + loop h diff --git a/ghc/tests/lib/IO/hGetLine001.stdout b/ghc/tests/lib/IO/hGetLine001.stdout new file mode 100644 index 0000000000..3ace789b81 --- /dev/null +++ b/ghc/tests/lib/IO/hGetLine001.stdout @@ -0,0 +1,88 @@ +-- !!! testing hGetLine + +import IO + +-- one version of 'cat' +main = do + let loop h = do b <- hIsEOF h + if b then return () + else do l <- hGetLine h; putStrLn l; loop h + loop stdin + + h <- openFile "hGetLine001.hs" ReadMode + hSetBuffering h NoBuffering + loop h + + hSeek h AbsoluteSeek 0 + hSetBuffering h LineBuffering + loop h + + hSeek h AbsoluteSeek 0 + hSetBuffering h (BlockBuffering (Just 83)) + loop h +-- !!! testing hGetLine + +import IO + +-- one version of 'cat' +main = do + let loop h = do b <- hIsEOF h + if b then return () + else do l <- hGetLine h; putStrLn l; loop h + loop stdin + + h <- openFile "hGetLine001.hs" ReadMode + hSetBuffering h NoBuffering + loop h + + hSeek h AbsoluteSeek 0 + hSetBuffering h LineBuffering + loop h + + hSeek h AbsoluteSeek 0 + hSetBuffering h (BlockBuffering (Just 83)) + loop h +-- !!! testing hGetLine + +import IO + +-- one version of 'cat' +main = do + let loop h = do b <- hIsEOF h + if b then return () + else do l <- hGetLine h; putStrLn l; loop h + loop stdin + + h <- openFile "hGetLine001.hs" ReadMode + hSetBuffering h NoBuffering + loop h + + hSeek h AbsoluteSeek 0 + hSetBuffering h LineBuffering + loop h + + hSeek h AbsoluteSeek 0 + hSetBuffering h (BlockBuffering (Just 83)) + loop h +-- !!! testing hGetLine + +import IO + +-- one version of 'cat' +main = do + let loop h = do b <- hIsEOF h + if b then return () + else do l <- hGetLine h; putStrLn l; loop h + loop stdin + + h <- openFile "hGetLine001.hs" ReadMode + hSetBuffering h NoBuffering + loop h + + hSeek h AbsoluteSeek 0 + hSetBuffering h LineBuffering + loop h + + hSeek h AbsoluteSeek 0 + hSetBuffering h (BlockBuffering (Just 83)) + loop h diff --git a/ghc/tests/io/should_run/io008.hs b/ghc/tests/lib/IO/hGetPosn001.hs index 5a3e3373ed..b952ab87ad 100644 --- a/ghc/tests/io/should_run/io008.hs +++ b/ghc/tests/lib/IO/hGetPosn001.hs @@ -8,10 +8,10 @@ import Monad import Directory (removeFile, doesFileExist) main = do - hIn <- openFile "io008.in" ReadMode - f <- doesFileExist "io008.out" - when f (removeFile "io008.out") - hOut <- openFile "io008.out" ReadWriteMode + hIn <- openFile "hGetPosn001.in" ReadMode + f <- doesFileExist "hGetPosn001.out" + when f (removeFile "hGetPosn001.out") + hOut <- openFile "hGetPosn001.out" ReadWriteMode bof <- hGetPosn hIn copy hIn hOut hSetPosn bof diff --git a/ghc/tests/io/should_run/io008.in b/ghc/tests/lib/IO/hGetPosn001.in index 2e2537150f..2e2537150f 100644 --- a/ghc/tests/io/should_run/io008.in +++ b/ghc/tests/lib/IO/hGetPosn001.in diff --git a/ghc/tests/io/should_run/io008.stdout b/ghc/tests/lib/IO/hGetPosn001.stdout index 7ac3cc54f0..7ac3cc54f0 100644 --- a/ghc/tests/io/should_run/io008.stdout +++ b/ghc/tests/lib/IO/hGetPosn001.stdout diff --git a/ghc/tests/io/should_run/io027.hs b/ghc/tests/lib/IO/hIsEOF001.hs index 8bb3229cc6..b63c1d41db 100644 --- a/ghc/tests/io/should_run/io027.hs +++ b/ghc/tests/lib/IO/hIsEOF001.hs @@ -1,5 +1,4 @@ -- !!! hIsEOF (on stdout) -module Main(main) where import IO ( hIsEOF, stdout ) diff --git a/ghc/tests/io/should_run/io027.stdout b/ghc/tests/lib/IO/hIsEOF001.stdout index 76460ac50a..76460ac50a 100644 --- a/ghc/tests/io/should_run/io027.stdout +++ b/ghc/tests/lib/IO/hIsEOF001.stdout diff --git a/ghc/tests/lib/IO/hIsEOF002.hs b/ghc/tests/lib/IO/hIsEOF002.hs new file mode 100644 index 0000000000..a12f9b95ce --- /dev/null +++ b/ghc/tests/lib/IO/hIsEOF002.hs @@ -0,0 +1,48 @@ +-- !!! test hIsEOF in various buffering situations + +import IO + +main = do + h <- openFile "hIsEOF002.hs" ReadMode + hSetBuffering h NoBuffering + hSeek h SeekFromEnd 0 + hIsEOF h >>= print + hSeek h SeekFromEnd (-1) + hIsEOF h >>= print + hGetChar h >>= print + + hSetBuffering h LineBuffering + hSeek h SeekFromEnd 0 + hIsEOF h >>= print + hSeek h SeekFromEnd (-1) + hIsEOF h >>= print + hGetChar h >>= print + + hSetBuffering h (BlockBuffering (Just 1)) + hSeek h SeekFromEnd 0 + hIsEOF h >>= print + hSeek h SeekFromEnd (-1) + hIsEOF h >>= print + hGetChar h >>= print + + hSetBuffering h (BlockBuffering Nothing) + hSeek h SeekFromEnd 0 + hIsEOF h >>= print + hSeek h SeekFromEnd (-1) + hIsEOF h >>= print + hGetChar h >>= print + hClose h + + h <- openFile "hIsEOF002.out" WriteMode + hPutStrLn h "hello, world" + hClose h + + h <- openFile "hIsEOF002.out" ReadWriteMode + hSetBuffering h NoBuffering + hSeek h SeekFromEnd 0 + hIsEOF h >>= print + hPutChar h 'x' + hIsEOF h >>= print + hSeek h SeekFromEnd (-1) + hIsEOF h >>= print + hGetChar h >>= print diff --git a/ghc/tests/lib/IO/hIsEOF002.stdout b/ghc/tests/lib/IO/hIsEOF002.stdout new file mode 100644 index 0000000000..3aa5e1a64d --- /dev/null +++ b/ghc/tests/lib/IO/hIsEOF002.stdout @@ -0,0 +1,16 @@ +True +False +'\n' +True +False +'\n' +True +False +'\n' +True +False +'\n' +True +True +False +'x' diff --git a/ghc/tests/lib/IO/hReady001.hs b/ghc/tests/lib/IO/hReady001.hs new file mode 100644 index 0000000000..f31f69d017 --- /dev/null +++ b/ghc/tests/lib/IO/hReady001.hs @@ -0,0 +1,11 @@ +-- !!! hReady test + + -- hReady should probably return False at the end of a file, + -- but in GHC it returns True (known bug). + +import IO + +main = do + h <- openFile "hReady001.hs" ReadMode + hSeek h SeekFromEnd 0 + hReady h >>= print diff --git a/ghc/tests/lib/IO/hSeek001.hs b/ghc/tests/lib/IO/hSeek001.hs new file mode 100644 index 0000000000..a2053a143b --- /dev/null +++ b/ghc/tests/lib/IO/hSeek001.hs @@ -0,0 +1,29 @@ +-- !!! Test seeking + +import IO + +main = do + h <- openFile "hSeek001.in" ReadMode + True <- hIsSeekable h + hSeek h SeekFromEnd (-1) + z <- hGetChar h + putStr (z:"\n") + hSeek h SeekFromEnd (-3) + x <- hGetChar h + putStr (x:"\n") + hSeek h RelativeSeek (-2) + w <- hGetChar h + putStr (w:"\n") + hSeek h RelativeSeek 2 + z <- hGetChar h + putStr (z:"\n") + hSeek h AbsoluteSeek (0) + a <- hGetChar h + putStr (a:"\n") + hSeek h AbsoluteSeek (10) + k <- hGetChar h + putStr (k:"\n") + hSeek h AbsoluteSeek (25) + z <- hGetChar h + putStr (z:"\n") + hClose h diff --git a/ghc/tests/io/should_run/io013.in b/ghc/tests/lib/IO/hSeek001.in index e85d5b4528..e85d5b4528 100644 --- a/ghc/tests/io/should_run/io013.in +++ b/ghc/tests/lib/IO/hSeek001.in diff --git a/ghc/tests/lib/IO/hSeek001.stdout b/ghc/tests/lib/IO/hSeek001.stdout new file mode 100644 index 0000000000..ab6c1d751b --- /dev/null +++ b/ghc/tests/lib/IO/hSeek001.stdout @@ -0,0 +1,7 @@ +z +x +w +z +a +k +z diff --git a/ghc/tests/io/should_run/io025.hs b/ghc/tests/lib/IO/hSeek002.hs index a378b3d974..a23481f2bf 100644 --- a/ghc/tests/io/should_run/io025.hs +++ b/ghc/tests/lib/IO/hSeek002.hs @@ -6,7 +6,7 @@ import Directory ( removeFile ) main :: IO () main = do - hdl <- openFile "io025.hs" ReadMode + hdl <- openFile "hSeek002.hs" ReadMode flg <- hIsEOF hdl print flg hSeek hdl SeekFromEnd 0 diff --git a/ghc/tests/io/should_run/io025.stdout b/ghc/tests/lib/IO/hSeek002.stdout index 8069fe32b0..8069fe32b0 100644 --- a/ghc/tests/io/should_run/io025.stdout +++ b/ghc/tests/lib/IO/hSeek002.stdout diff --git a/ghc/tests/io/should_run/io030.hs b/ghc/tests/lib/IO/hSeek003.hs index 987f5629e7..d0ecf92f44 100644 --- a/ghc/tests/io/should_run/io030.hs +++ b/ghc/tests/lib/IO/hSeek003.hs @@ -14,7 +14,7 @@ bmo_ls = [NoBuffering, LineBuffering, BlockBuffering Nothing, BlockBuffering (Just 511),BlockBuffering (Just 3), BlockBuffering (Just 11)] main = do - hdl <- openFile "io030.hs" ReadMode + hdl <- openFile "hSeek003.hs" ReadMode sequence (zipWith testPosns (repeat hdl) bmo_ls) hClose hdl diff --git a/ghc/tests/io/should_run/io030.stdout b/ghc/tests/lib/IO/hSeek003.stdout index 7c765c5bc5..7c765c5bc5 100644 --- a/ghc/tests/io/should_run/io030.stdout +++ b/ghc/tests/lib/IO/hSeek003.stdout diff --git a/ghc/tests/lib/IO/hSeek004.hs b/ghc/tests/lib/IO/hSeek004.hs new file mode 100644 index 0000000000..464fa05bc3 --- /dev/null +++ b/ghc/tests/lib/IO/hSeek004.hs @@ -0,0 +1,7 @@ +-- !!! can't seek an AppendMode handle + +import IO + +main = do + h <- openFile "hSeek004.out" AppendMode + try (hSeek h AbsoluteSeek 0) >>= print diff --git a/ghc/tests/lib/IO/hSeek004.stdout b/ghc/tests/lib/IO/hSeek004.stdout new file mode 100644 index 0000000000..308399259f --- /dev/null +++ b/ghc/tests/lib/IO/hSeek004.stdout @@ -0,0 +1,5 @@ +Left illegal operation +Action: hSeek +Handle: {loc=hSeek004.out,type=writable (append),buffering=block (8192)} +Reason: handle is not seekable +File: hSeek004.out diff --git a/ghc/tests/io/should_run/io021.hs b/ghc/tests/lib/IO/hSetBuffering002.hs index 396d4353c9..396d4353c9 100644 --- a/ghc/tests/io/should_run/io021.hs +++ b/ghc/tests/lib/IO/hSetBuffering002.hs diff --git a/ghc/tests/io/should_run/io021.stdout b/ghc/tests/lib/IO/hSetBuffering002.stdout index 396d4353c9..396d4353c9 100644 --- a/ghc/tests/io/should_run/io021.stdout +++ b/ghc/tests/lib/IO/hSetBuffering002.stdout diff --git a/ghc/tests/io/should_run/io028.hs b/ghc/tests/lib/IO/hSetBuffering003.hs index 424be16465..424be16465 100644 --- a/ghc/tests/io/should_run/io028.hs +++ b/ghc/tests/lib/IO/hSetBuffering003.hs diff --git a/ghc/tests/io/should_run/io028.stderr b/ghc/tests/lib/IO/hSetBuffering003.stderr index a4cf8779b4..a4cf8779b4 100644 --- a/ghc/tests/io/should_run/io028.stderr +++ b/ghc/tests/lib/IO/hSetBuffering003.stderr diff --git a/ghc/tests/io/should_run/io028.stdout b/ghc/tests/lib/IO/hSetBuffering003.stdout index 7768773198..7768773198 100644 --- a/ghc/tests/io/should_run/io028.stdout +++ b/ghc/tests/lib/IO/hSetBuffering003.stdout diff --git a/ghc/tests/lib/IO/ioeGetErrorString001.hs b/ghc/tests/lib/IO/ioeGetErrorString001.hs new file mode 100644 index 0000000000..b2f84f6a11 --- /dev/null +++ b/ghc/tests/lib/IO/ioeGetErrorString001.hs @@ -0,0 +1,12 @@ +-- !!! test ioeGetErrorString + +import IO +import Maybe + +main = do + h <- openFile "ioeGetErrorString001.hs" ReadMode + hSeek h SeekFromEnd 0 + (hGetChar h >> return ()) `catch` + \e -> if isEOFError e + then print (ioeGetErrorString e) + else putStrLn "failed." diff --git a/ghc/tests/lib/IO/ioeGetErrorString001.stdout b/ghc/tests/lib/IO/ioeGetErrorString001.stdout new file mode 100644 index 0000000000..0b8daea55a --- /dev/null +++ b/ghc/tests/lib/IO/ioeGetErrorString001.stdout @@ -0,0 +1 @@ +"end of file" diff --git a/ghc/tests/lib/IO/ioeGetFileName001.hs b/ghc/tests/lib/IO/ioeGetFileName001.hs new file mode 100644 index 0000000000..73434bb7e4 --- /dev/null +++ b/ghc/tests/lib/IO/ioeGetFileName001.hs @@ -0,0 +1,11 @@ +-- !!! test ioeGetFileName + +import IO + +main = do + h <- openFile "ioeGetFileName001.hs" ReadMode + hSeek h SeekFromEnd 0 + (hGetChar h >> return ()) `catch` + \e -> if isEOFError e + then print (ioeGetFileName e) + else putStrLn "failed." diff --git a/ghc/tests/lib/IO/ioeGetFileName001.stdout b/ghc/tests/lib/IO/ioeGetFileName001.stdout new file mode 100644 index 0000000000..7377ad409d --- /dev/null +++ b/ghc/tests/lib/IO/ioeGetFileName001.stdout @@ -0,0 +1 @@ +Just "ioeGetFileName001.hs" diff --git a/ghc/tests/lib/IO/ioeGetHandle001.hs b/ghc/tests/lib/IO/ioeGetHandle001.hs new file mode 100644 index 0000000000..0d041e0591 --- /dev/null +++ b/ghc/tests/lib/IO/ioeGetHandle001.hs @@ -0,0 +1,12 @@ +-- !!! test ioeGetHandle + +import IO +import Maybe + +main = do + h <- openFile "ioeGetHandle001.hs" ReadMode + hSeek h SeekFromEnd 0 + (hGetChar h >> return ()) `catch` + \e -> if isEOFError e && fromJust (ioeGetHandle e) == h + then putStrLn "ok." + else putStrLn "failed." diff --git a/ghc/tests/lib/IO/ioeGetHandle001.stdout b/ghc/tests/lib/IO/ioeGetHandle001.stdout new file mode 100644 index 0000000000..90b5016eff --- /dev/null +++ b/ghc/tests/lib/IO/ioeGetHandle001.stdout @@ -0,0 +1 @@ +ok. diff --git a/ghc/tests/lib/IO/isEOF001.hs b/ghc/tests/lib/IO/isEOF001.hs new file mode 100644 index 0000000000..c5f552f6b7 --- /dev/null +++ b/ghc/tests/lib/IO/isEOF001.hs @@ -0,0 +1,3 @@ +import IO + +main = isEOF >>= print diff --git a/ghc/tests/io/should_run/io020.stdout b/ghc/tests/lib/IO/isEOF001.stdout index 0ca95142bb..0ca95142bb 100644 --- a/ghc/tests/io/should_run/io020.stdout +++ b/ghc/tests/lib/IO/isEOF001.stdout diff --git a/ghc/tests/lib/IO/misc001.hs b/ghc/tests/lib/IO/misc001.hs new file mode 100644 index 0000000000..c536f7d03a --- /dev/null +++ b/ghc/tests/lib/IO/misc001.hs @@ -0,0 +1,24 @@ +import IO + +import System (getArgs) +import Char (toUpper) +import Directory (removeFile, doesFileExist) + +main = do + [f1,f2] <- getArgs + h1 <- openFile f1 ReadMode + f <- doesFileExist f2 + if f then removeFile f2 else return () + h2 <- openFile f2 WriteMode + copyFile h1 h2 + hClose h1 + hClose h2 + +copyFile h1 h2 = do + eof <- hIsEOF h1 + if eof + then return () + else do + c <- hGetChar h1 + c <- hPutChar h2 (toUpper c) + copyFile h1 h2 diff --git a/ghc/tests/io/should_run/io004.stdout b/ghc/tests/lib/IO/misc001.stdout index e69de29bb2..e69de29bb2 100644 --- a/ghc/tests/io/should_run/io004.stdout +++ b/ghc/tests/lib/IO/misc001.stdout diff --git a/ghc/tests/lib/IO/openFile001.hs b/ghc/tests/lib/IO/openFile001.hs new file mode 100644 index 0000000000..02e14034aa --- /dev/null +++ b/ghc/tests/lib/IO/openFile001.hs @@ -0,0 +1,10 @@ +-- !!! test that a file opened in ReadMode can't be written to + +import IO + +main = do + hIn <- openFile "openFile001.hs" ReadMode + hPutStr hIn "test" `catch` \ err -> + if isIllegalOperation err + then putStrLn "ok." + else error "Oh dear\n" diff --git a/ghc/tests/lib/IO/openFile001.stdout b/ghc/tests/lib/IO/openFile001.stdout new file mode 100644 index 0000000000..90b5016eff --- /dev/null +++ b/ghc/tests/lib/IO/openFile001.stdout @@ -0,0 +1 @@ +ok. diff --git a/ghc/tests/lib/IO/openFile002.hs b/ghc/tests/lib/IO/openFile002.hs new file mode 100644 index 0000000000..70d2a7ddd6 --- /dev/null +++ b/ghc/tests/lib/IO/openFile002.hs @@ -0,0 +1,6 @@ +import Char +import IO + +-- !!! Open a non-existent file for reading (should fail) + +main = openFile "<nonexistent>" ReadMode diff --git a/ghc/tests/lib/IO/openFile002.stderr b/ghc/tests/lib/IO/openFile002.stderr new file mode 100644 index 0000000000..f40db1ed2d --- /dev/null +++ b/ghc/tests/lib/IO/openFile002.stderr @@ -0,0 +1,6 @@ + +Fail: does not exist +Action: openFile +Reason: No such file or directory +File: <nonexistent> + diff --git a/ghc/tests/lib/IO/openFile003.hs b/ghc/tests/lib/IO/openFile003.hs new file mode 100644 index 0000000000..77900f04c1 --- /dev/null +++ b/ghc/tests/lib/IO/openFile003.hs @@ -0,0 +1,13 @@ +import IO + +-- !!! Open a directory (should fail) + +main = do + r <- try (openFile "." ReadMode) + print r + r <- try (openFile "." WriteMode) + print r + r <- try (openFile "." AppendMode) + print r + r <- try (openFile "." ReadWriteMode) + print r diff --git a/ghc/tests/lib/IO/openFile003.stdout b/ghc/tests/lib/IO/openFile003.stdout new file mode 100644 index 0000000000..eb69ce3f0a --- /dev/null +++ b/ghc/tests/lib/IO/openFile003.stdout @@ -0,0 +1,16 @@ +Left inappropriate type +Action: openFile +Reason: is a directory +File: . +Left inappropriate type +Action: openFile +Reason: Is a directory +File: . +Left inappropriate type +Action: openFile +Reason: Is a directory +File: . +Left inappropriate type +Action: openFile +Reason: Is a directory +File: . diff --git a/ghc/tests/lib/IO/openFile004.hs b/ghc/tests/lib/IO/openFile004.hs new file mode 100644 index 0000000000..da6443f014 --- /dev/null +++ b/ghc/tests/lib/IO/openFile004.hs @@ -0,0 +1,23 @@ +-- !!! Open a non-existent file for writing + +import Char +import IO +import Directory +import Monad + +file = "openFile004.out" + +main = do + b <- doesFileExist file + when b (removeFile file) + + h <- openFile file WriteMode + hPutStr h "hello world\n" + hClose h + + h <- openFile file ReadMode + let loop = do + b <- hIsEOF h + if b then return () + else do c <- hGetChar h; putChar c; loop + loop diff --git a/ghc/tests/lib/IO/openFile004.stdout b/ghc/tests/lib/IO/openFile004.stdout new file mode 100644 index 0000000000..3b18e512db --- /dev/null +++ b/ghc/tests/lib/IO/openFile004.stdout @@ -0,0 +1 @@ +hello world diff --git a/ghc/tests/lib/IO/openFile005.hs b/ghc/tests/lib/IO/openFile005.hs new file mode 100644 index 0000000000..fd2dfa8c41 --- /dev/null +++ b/ghc/tests/lib/IO/openFile005.hs @@ -0,0 +1,44 @@ +-- !!! test multiple-reader single-writer locking semantics + +import IO + +file1 = "openFile005.out1" +file2 = "openFile005.out2" + +main = do + -- two writes (should fail) + h <- openFile file1 WriteMode + try (openFile file1 WriteMode) >>= print + hClose h + + -- write and an append (should fail) + h <- openFile file1 WriteMode + try (openFile file1 AppendMode) >>= print + hClose h + + -- read/write and a write (should fail) + h <- openFile file1 ReadWriteMode + try (openFile file1 WriteMode) >>= print + hClose h + + -- read and a read/write (should fail) + h <- openFile file1 ReadMode + try (openFile file1 ReadWriteMode) >>= print + hClose h + + -- write and a read (should fail) + h <- openFile file1 WriteMode + try (openFile file1 ReadMode) >>= print + hClose h + + -- two writes, different files (silly, but should succeed) + h1 <- openFile file1 WriteMode + h2 <- openFile file2 WriteMode + hClose h1 + hClose h2 + + -- two reads, should succeed + h1 <- openFile file1 ReadMode + h2 <- openFile file1 ReadMode + hClose h1 + hClose h2 diff --git a/ghc/tests/lib/IO/openFile005.stdout b/ghc/tests/lib/IO/openFile005.stdout new file mode 100644 index 0000000000..6899c848df --- /dev/null +++ b/ghc/tests/lib/IO/openFile005.stdout @@ -0,0 +1,20 @@ +Left resource busy +Action: openFile +Reason: file is locked +File: openFile005.out1 +Left resource busy +Action: openFile +Reason: file is locked +File: openFile005.out1 +Left resource busy +Action: openFile +Reason: file is locked +File: openFile005.out1 +Left resource busy +Action: openFile +Reason: file is locked +File: openFile005.out1 +Left resource busy +Action: openFile +Reason: file is locked +File: openFile005.out1 diff --git a/ghc/tests/lib/IO/openFile006.hs b/ghc/tests/lib/IO/openFile006.hs new file mode 100644 index 0000000000..9a91886053 --- /dev/null +++ b/ghc/tests/lib/IO/openFile006.hs @@ -0,0 +1,14 @@ +-- !!! opening a file in WriteMode better truncate it + +import IO + +main = do + h <- openFile "openFile006.out" AppendMode + hPutStrLn h "hello, world" + size <- hFileSize h + print size + hClose h + + h <- openFile "openFile006.out" WriteMode + size <- hFileSize h + print size diff --git a/ghc/tests/lib/IO/openFile006.stdout b/ghc/tests/lib/IO/openFile006.stdout new file mode 100644 index 0000000000..33a9dbad99 --- /dev/null +++ b/ghc/tests/lib/IO/openFile006.stdout @@ -0,0 +1,2 @@ +13 +0 diff --git a/ghc/tests/io/should_run/io023.hs b/ghc/tests/lib/IO/putStr001.hs index ec2d1857f4..48b3add3f3 100644 --- a/ghc/tests/io/should_run/io023.hs +++ b/ghc/tests/lib/IO/putStr001.hs @@ -1,7 +1,6 @@ -- !!! Testing output on stdout -module Main(main) where -- stdout is buffered, so test if its buffer -- is flushed upon program termination. -main :: IO () -main = putStr "Hello" + +main = putStr "Hello, world\n" diff --git a/ghc/tests/io/should_run/io001.stdout b/ghc/tests/lib/IO/putStr001.stdout index a5c1966771..a5c1966771 100644 --- a/ghc/tests/io/should_run/io001.stdout +++ b/ghc/tests/lib/IO/putStr001.stdout diff --git a/ghc/tests/io/should_run/io031.hs b/ghc/tests/lib/IO/readwrite001.hs index 7cae45162f..69b41ca50b 100644 --- a/ghc/tests/io/should_run/io031.hs +++ b/ghc/tests/lib/IO/readwrite001.hs @@ -6,9 +6,9 @@ import Directory ( removeFile, doesFileExist ) import Monad main = do - f <- doesFileExist "io031.inout" - when f (removeFile "io031.inout") - hdl <- openFile "io031.inout" ReadWriteMode + f <- doesFileExist "readwrite001.inout" + when f (removeFile "readwrite001.inout") + hdl <- openFile "readwrite001.inout" ReadWriteMode hSetBuffering hdl LineBuffering hPutStr hdl "as" hSeek hdl AbsoluteSeek 0 diff --git a/ghc/tests/io/should_run/io031.stdout b/ghc/tests/lib/IO/readwrite001.stdout index e33ba0613d..e33ba0613d 100644 --- a/ghc/tests/io/should_run/io031.stdout +++ b/ghc/tests/lib/IO/readwrite001.stdout diff --git a/ghc/tests/io/should_run/io018.hs b/ghc/tests/lib/IO/readwrite002.hs index 6320c975e6..3257cd6be0 100644 --- a/ghc/tests/io/should_run/io018.hs +++ b/ghc/tests/lib/IO/readwrite002.hs @@ -1,8 +1,5 @@ -- !!! Testing RW handles -module Main(main) where - import IO -import IOExts import Directory (removeFile, doesFileExist) import Monad @@ -10,11 +7,11 @@ import Monad main :: IO () main = do - let username = "io018.inout" + let username = "readwrite002.inout" f <- doesFileExist username when f (removeFile username) cd <- openFile username ReadWriteMode - hSetBinaryMode cd True +-- hSetBinaryMode cd True hSetBuffering stdin NoBuffering hSetBuffering stdout NoBuffering hSetBuffering cd NoBuffering @@ -28,7 +25,7 @@ main = do hSetBuffering cd (BlockBuffering Nothing) speak cd `catch` \ err -> if isEOFError err then putStrLn "\nCaught EOF" else ioError err -speakString = "Someone wants to speak with you\n" +speakString = "##############################\n" speak cd = do (do diff --git a/ghc/tests/lib/IO/readwrite002.stdout b/ghc/tests/lib/IO/readwrite002.stdout new file mode 100644 index 0000000000..9aed0284d7 --- /dev/null +++ b/ghc/tests/lib/IO/readwrite002.stdout @@ -0,0 +1,9 @@ +############### + +Caught EOF +############### + +Caught EOF +############### + +Caught EOF diff --git a/ghc/tests/io/should_run/io022.hs b/ghc/tests/lib/IOExts/echo001.hs index a00ca35286..a00ca35286 100644 --- a/ghc/tests/io/should_run/io022.hs +++ b/ghc/tests/lib/IOExts/echo001.hs diff --git a/ghc/tests/io/should_run/io022.stdout b/ghc/tests/lib/IOExts/echo001.stdout index 73f06fdb1c..73f06fdb1c 100644 --- a/ghc/tests/io/should_run/io022.stdout +++ b/ghc/tests/lib/IOExts/echo001.stdout diff --git a/ghc/tests/io/should_run/io032.hs b/ghc/tests/lib/IOExts/trace001.hs index 5e340e056a..5e340e056a 100644 --- a/ghc/tests/io/should_run/io032.hs +++ b/ghc/tests/lib/IOExts/trace001.hs diff --git a/ghc/tests/io/should_run/io032.stderr b/ghc/tests/lib/IOExts/trace001.stderr index 3b8ac7ae24..3b8ac7ae24 100644 --- a/ghc/tests/io/should_run/io032.stderr +++ b/ghc/tests/lib/IOExts/trace001.stderr diff --git a/ghc/tests/io/should_run/io032.stdout b/ghc/tests/lib/IOExts/trace001.stdout index 5b19477993..5b19477993 100644 --- a/ghc/tests/io/should_run/io032.stdout +++ b/ghc/tests/lib/IOExts/trace001.stdout diff --git a/ghc/tests/io/should_run/Makefile b/ghc/tests/lib/System/Makefile index 9947e9902b..9947e9902b 100644 --- a/ghc/tests/io/should_run/Makefile +++ b/ghc/tests/lib/System/Makefile diff --git a/ghc/tests/io/should_run/io004.hs b/ghc/tests/lib/System/exitWith001.hs index 69d2221743..69d2221743 100644 --- a/ghc/tests/io/should_run/io004.hs +++ b/ghc/tests/lib/System/exitWith001.hs diff --git a/ghc/tests/io/should_run/io015.stdout b/ghc/tests/lib/System/exitWith001.stdout index e69de29bb2..e69de29bb2 100644 --- a/ghc/tests/io/should_run/io015.stdout +++ b/ghc/tests/lib/System/exitWith001.stdout diff --git a/ghc/tests/io/should_run/io003.hs b/ghc/tests/lib/System/getArgs001.hs index 93fff71be5..93fff71be5 100644 --- a/ghc/tests/io/should_run/io003.hs +++ b/ghc/tests/lib/System/getArgs001.hs diff --git a/ghc/tests/io/should_run/io003.stdout b/ghc/tests/lib/System/getArgs001.stdout index 3d23060901..3d23060901 100644 --- a/ghc/tests/io/should_run/io003.stdout +++ b/ghc/tests/lib/System/getArgs001.stdout diff --git a/ghc/tests/io/should_run/io003.stdout-mingw b/ghc/tests/lib/System/getArgs001.stdout-mingw index ef48076a32..ef48076a32 100644 --- a/ghc/tests/io/should_run/io003.stdout-mingw +++ b/ghc/tests/lib/System/getArgs001.stdout-mingw diff --git a/ghc/tests/io/should_run/io002.hs b/ghc/tests/lib/System/getEnv001.hs index e06fe6c776..e06fe6c776 100644 --- a/ghc/tests/io/should_run/io002.hs +++ b/ghc/tests/lib/System/getEnv001.hs diff --git a/ghc/tests/io/should_run/io002.stdout b/ghc/tests/lib/System/getEnv001.stdout index da3acde026..da3acde026 100644 --- a/ghc/tests/io/should_run/io002.stdout +++ b/ghc/tests/lib/System/getEnv001.stdout diff --git a/ghc/tests/io/should_run/io005.hs b/ghc/tests/lib/System/system001.hs index ac12847e52..ac12847e52 100644 --- a/ghc/tests/io/should_run/io005.hs +++ b/ghc/tests/lib/System/system001.hs diff --git a/ghc/tests/io/should_run/io005.stdout b/ghc/tests/lib/System/system001.stdout index ac12847e52..ac12847e52 100644 --- a/ghc/tests/io/should_run/io005.stdout +++ b/ghc/tests/lib/System/system001.stdout diff --git a/ghc/tests/lib/should_run/time001.hs b/ghc/tests/lib/Time/time001.hs index 30c7280d37..30c7280d37 100644 --- a/ghc/tests/lib/should_run/time001.hs +++ b/ghc/tests/lib/Time/time001.hs diff --git a/ghc/tests/lib/should_run/time001.stdout b/ghc/tests/lib/Time/time001.stdout index c2e987e94e..c2e987e94e 100644 --- a/ghc/tests/lib/should_run/time001.stdout +++ b/ghc/tests/lib/Time/time001.stdout diff --git a/ghc/tests/lib/should_run/time002.hs b/ghc/tests/lib/Time/time002.hs index d3c3e42ad3..d3c3e42ad3 100644 --- a/ghc/tests/lib/should_run/time002.hs +++ b/ghc/tests/lib/Time/time002.hs diff --git a/ghc/tests/lib/should_run/time002.stdout b/ghc/tests/lib/Time/time002.stdout index 587579af91..587579af91 100644 --- a/ghc/tests/lib/should_run/time002.stdout +++ b/ghc/tests/lib/Time/time002.stdout diff --git a/ghc/tests/io/should_run/io019.hs b/ghc/tests/lib/Time/time003.hs index ac2c72dfd4..ac2c72dfd4 100644 --- a/ghc/tests/io/should_run/io019.hs +++ b/ghc/tests/lib/Time/time003.hs diff --git a/ghc/tests/io/should_run/io019.stdout b/ghc/tests/lib/Time/time003.stdout index dbde422651..dbde422651 100644 --- a/ghc/tests/io/should_run/io019.stdout +++ b/ghc/tests/lib/Time/time003.stdout diff --git a/ghc/tests/io/should_run/io020.hs b/ghc/tests/lib/Time/time004.hs index 31fd567689..31fd567689 100644 --- a/ghc/tests/io/should_run/io020.hs +++ b/ghc/tests/lib/Time/time004.hs diff --git a/ghc/tests/io/should_run/io026.stdout b/ghc/tests/lib/Time/time004.stdout index 0ca95142bb..0ca95142bb 100644 --- a/ghc/tests/io/should_run/io026.stdout +++ b/ghc/tests/lib/Time/time004.stdout |
