Commit a7160faa authored by thomie's avatar thomie

Testsuite: tabs -> spaces [skip ci]

parent 5b03dc69
......@@ -14,16 +14,16 @@ main = do
-- test should run quickly, but arrange to kill it if it hangs for any reason:
main_t <- myThreadId
forkIO $ do
threadDelay 10000000
throwTo main_t (ErrorCall "killed")
threadDelay 10000000
throwTo main_t (ErrorCall "killed")
zipWithM_ ($)
[ f rbuf wbuf
| f <- [hGetBufTest, hGetBufNBTest, hGetBufSomeTest],
rbuf <- [buf1,buf2,buf3],
wbuf <- [buf1,buf2,buf3]
]
[1..]
zipWithM_ ($)
[ f rbuf wbuf
| f <- [hGetBufTest, hGetBufNBTest, hGetBufSomeTest],
rbuf <- [buf1,buf2,buf3],
wbuf <- [buf1,buf2,buf3]
]
[1..]
msg = "hello!"
msg_length = length msg
......@@ -66,13 +66,13 @@ readProc m1 m2 finished h = do
let
loop 0 = return ()
loop n = do putMVar m2 (); takeMVar m1
r <- hGetBuf h buf msg_length
if (r /= msg_length)
then do hPutStr stderr ("error: " ++ show r)
exitFailure
else do s <- peekCStringLen (buf,r)
hPutStr stdout (show n ++ " ")
loop (n-1)
r <- hGetBuf h buf msg_length
if (r /= msg_length)
then do hPutStr stderr ("error: " ++ show r)
exitFailure
else do s <- peekCStringLen (buf,r)
hPutStr stdout (show n ++ " ")
loop (n-1)
loop 100
hPutStr stdout "\n"
putMVar m2 (); takeMVar m1
......@@ -90,12 +90,12 @@ writeProc m1 m2 h = do
let
loop 0 = return ()
loop n =
withCStringLen msg $ \ (s,len) -> do
takeMVar m2
hPutBuf h s len
hFlush h
putMVar m1 ()
loop (n-1)
withCStringLen msg $ \ (s,len) -> do
takeMVar m2
hPutBuf h s len
hFlush h
putMVar m1 ()
loop (n-1)
loop 100
takeMVar m2
......@@ -134,13 +134,13 @@ readProcNB m1 m2 finished h = do
let
loop 0 = return ()
loop n = do putMVar m2 (); takeMVar m1
r <- hGetBufNonBlocking h buf read_size
if (r /= msg_length)
then do hPutStr stderr ("error: " ++ show r)
exitFailure
else do s <- peekCStringLen (buf,r)
hPutStr stdout (show n ++ " ")
loop (n-1)
r <- hGetBufNonBlocking h buf read_size
if (r /= msg_length)
then do hPutStr stderr ("error: " ++ show r)
exitFailure
else do s <- peekCStringLen (buf,r)
hPutStr stdout (show n ++ " ")
loop (n-1)
loop 100
hPutStr stdout "\n"
putMVar m2 (); takeMVar m1
......@@ -158,12 +158,12 @@ writeProcNB m1 m2 h = do
let
loop 0 = return ()
loop n =
withCStringLen msg $ \ (s,len) -> do
takeMVar m2
hPutBufNonBlocking h s len
hFlush h
putMVar m1 ()
loop (n-1)
withCStringLen msg $ \ (s,len) -> do
takeMVar m2
hPutBufNonBlocking h s len
hFlush h
putMVar m1 ()
loop (n-1)
loop 100
takeMVar m2
......@@ -198,13 +198,13 @@ readProcSome m1 m2 finished h = do
let
loop 0 = return ()
loop n = do putMVar m2 (); takeMVar m1
r <- hGetBufSome h buf read_size
if (r /= msg_length)
then do hPutStr stderr ("error: " ++ show r)
exitFailure
else do s <- peekCStringLen (buf,r)
hPutStr stdout (show n ++ " ")
loop (n-1)
r <- hGetBufSome h buf read_size
if (r /= msg_length)
then do hPutStr stderr ("error: " ++ show r)
exitFailure
else do s <- peekCStringLen (buf,r)
hPutStr stdout (show n ++ " ")
loop (n-1)
loop 100
hPutStr stdout "\n"
putMVar m2 (); takeMVar m1
......
......@@ -12,7 +12,7 @@ main = do
eof <- isEOF
if eof then return [] else do
c <- getChar
if c `elem` ['\n','\r']
then return []
if c `elem` ['\n','\r']
then return []
else do cs <- readLine
return (c:cs)
......@@ -2,8 +2,8 @@ import System.IO
main = f stdin
where f h = do p <- hIsEOF h
if p then putStrLn "done"
else do l <- hGetLine h
putStrLn l
f h
if p then putStrLn "done"
else do l <- hGetLine h
putStrLn l
f h
......@@ -25,4 +25,4 @@ copy :: Handle -> Handle -> IO ()
copy hIn hOut =
tryIOError (hGetChar hIn) >>=
either (\ err -> if isEOFError err then return () else error "copy")
( \ x -> hPutChar hOut x >> copy hIn hOut)
( \ x -> hPutChar hOut x >> copy hIn hOut)
import System.IO
main =
hSetBuffering stdin NoBuffering >>
hSetBuffering stdout NoBuffering >>
main =
hSetBuffering stdin NoBuffering >>
hSetBuffering stdout NoBuffering >>
interact id
import System.IO
main =
hSetBuffering stdin NoBuffering >>
hSetBuffering stdout NoBuffering >>
main =
hSetBuffering stdin NoBuffering >>
hSetBuffering stdout NoBuffering >>
interact id
......@@ -8,6 +8,6 @@ main = do
h <- openFile "ioeGetErrorString001.hs" ReadMode
hSeek h SeekFromEnd 0
(hGetChar h >> return ()) `catchIOError`
\e -> if isEOFError e
then print (ioeGetErrorString e)
else putStrLn "failed."
\e -> if isEOFError e
then print (ioeGetErrorString e)
else putStrLn "failed."
......@@ -7,6 +7,6 @@ main = do
h <- openFile "ioeGetFileName001.hs" ReadMode
hSeek h SeekFromEnd 0
(hGetChar h >> return ()) `catchIOError`
\e -> if isEOFError e
then print (ioeGetFileName e)
else putStrLn "failed."
\e -> if isEOFError e
then print (ioeGetFileName e)
else putStrLn "failed."
......@@ -8,6 +8,6 @@ main = do
h <- openFile "ioeGetHandle001.hs" ReadMode
hSeek h SeekFromEnd 0
(hGetChar h >> return ()) `catchIOError`
\e -> if isEOFError e && fromJust (ioeGetHandle e) == h
then putStrLn "ok."
else putStrLn "failed."
\e -> if isEOFError e && fromJust (ioeGetHandle e) == h
then putStrLn "ok."
else putStrLn "failed."
......@@ -16,9 +16,9 @@ main = do
copyFile h1 h2 = do
eof <- hIsEOF h1
if eof
then return ()
else do
if eof
then return ()
else do
c <- hGetChar h1
c <- hPutChar h2 (toUpper c)
copyFile h1 h2
......@@ -6,6 +6,6 @@ import System.IO.Error
main = do
hIn <- openFile "openFile001.hs" ReadMode
hPutStr hIn "test" `catchIOError` \ err ->
if isIllegalOperation err
then putStrLn "ok."
else error "Oh dear\n"
if isIllegalOperation err
then putStrLn "ok."
else error "Oh dear\n"
......@@ -17,7 +17,7 @@ main = do
h <- openFile file ReadMode
let loop = do
b <- hIsEOF h
if b then return ()
else do c <- hGetChar h; putChar c; loop
b <- hIsEOF h
if b then return ()
else do c <- hGetChar h; putChar c; loop
loop
-- !!! Testing RW handles
-- !!! Testing RW handles
import System.IO
import System.IO.Error
......@@ -39,10 +39,10 @@ speakString = "##############################\n"
speak cd = do
(do
ready <- hReady cd
if ready then
hGetChar cd >>= putChar
else
return ()
if ready then
hGetChar cd >>= putChar
else
return ()
ready <- hReady stdin
if ready then (do { ch <- getChar; hPutChar cd ch})
else return ())
......
......@@ -36,7 +36,7 @@ main = do
putStrLn "Testing Enum (Ratio Int): "
testEnumRatioInt
{-
{-
Here's the properties that's supposed to
hold for arithmetic sequences over Int:
......@@ -44,30 +44,30 @@ main = do
- [e1,e2..] = [e1, (e1+i), (e1+2*i), ... upper]
where
i = e2 - e1
upper
| i > 0 = maxBound
| i < 0 = minBound
| i == 0 = maxBound -- this really shouldn't matter (I feel.)
i = e2 - e1
upper
| i > 0 = maxBound
| i < 0 = minBound
| i == 0 = maxBound -- this really shouldn't matter (I feel.)
- [e1..e3] = [e1, (e1+i), (e1+2*i),..e3]
where
i
| e3 >= e1 = 1
| e3 < e1 = (-1)
i
| e3 >= e1 = 1
| e3 < e1 = (-1)
- [e1,e2..e3] = res
where
i = e2 - e1
res
| i >= 0 && e3 < e1 = []
| i < 0 && e3 >= e1 = [] -- (*)
| otherwise = [e1, (e1+i), (e1 + 2*i), .. e3]
i = e2 - e1
res
| i >= 0 && e3 < e1 = []
| i < 0 && e3 >= e1 = [] -- (*)
| otherwise = [e1, (e1+i), (e1 + 2*i), .. e3]
Note:
(*) - I think this instead should be (i < 0 && e3 > e1), since, as is,
[x,(x+1) ..x] = [x]
[x,(x+1) ..x] = [x]
[x,(x-1) ..x] = []
which does not look right, symmetrically speaking.
......@@ -75,7 +75,7 @@ main = do
The same properties hold for other Prelude types that
are instances of Enum as well as being Bounded.
For non-Bounded types (e.g., Float and Double), the properties are similar,
except that the boundary tests become slightly different, i.e., when an
element becomes greater than (e3 + i/2) (or less than (e3 + i/2) for negative
......@@ -98,7 +98,7 @@ testEnumInt = do
-- pred
printTest (pred (1::Int))
printTest (pred (maxBound::Int))
mayBomb (printTest (pred (minBound::Int)))
mayBomb (printTest (pred (minBound::Int)))
-- toEnum
printTest ((map (toEnum::Int->Int) [1,minBound,maxBound]))
......@@ -109,7 +109,7 @@ testEnumInt = do
-- [x..] aka enumFrom
printTest ((take 7 [(1::Int)..]))
printTest ((take 7 [((maxBound::Int)-5)..])) -- just in case it doesn't catch the upper bound..
-- [x,y..] aka enumFromThen
printTest ((take 7 [(1::Int),2..]))
printTest ((take 7 [(1::Int),7..]))
......@@ -123,7 +123,7 @@ testEnumInt = do
let x = (maxBound::Int) - 5
printTest ((take 7 [x, (x+1) ..]))
-- Test overflow conditions
-- Test overflow conditions
printTest (([minBound::Int,1..]))
printTest (([minBound::Int,0..]))
printTest (([minBound::Int,-1..]))
......@@ -148,7 +148,7 @@ testEnumInt = do
printTest ((take 7 [(2::Int),1..1]))
printTest ((take 7 [(2::Int),3..1]))
-- Test overflow conditions
-- Test overflow conditions
printTest (([minBound, 1..maxBound::Int]))
printTest (([minBound, 0..maxBound::Int]))
printTest (([minBound,-1..maxBound::Int]))
......@@ -190,7 +190,7 @@ testEnumChar = do
do{ putStr ( " " ++ "(take 7 ['\\NUL' .. ])" ++ " = " ) ; print (take 7 ['\NUL' .. ]) }
-- printTest ((take 7 ['\250' .. ]))
do{ putStr ( " " ++ "(take 7 ['\\250' .. ])" ++ " = " ) ; print (take 7 ['\250' .. ]) }
-- [x,y..] aka enumFromThen
printTest ((take 7 ['a','b'..]))
printTest ((take 7 ['a','e'..]))
......@@ -237,7 +237,7 @@ testEnumUnit = do
mayBomb (printTest ((succ ())))
mayBomb (printTest ((succ (minBound::()))))
mayBomb (printTest ((succ (maxBound::()))))
-- pred:
mayBomb (printTest ((pred ())))
mayBomb (printTest ((pred (minBound::()))))
......@@ -268,7 +268,7 @@ testEnumOrdering = do
printTest ((succ LT))
printTest ((succ (minBound::Ordering)))
mayBomb (printTest ((succ (maxBound::Ordering))))
-- pred:
printTest ((pred GT))
printTest ((pred (maxBound::Ordering)))
......@@ -322,7 +322,7 @@ testEnumBool = do
printTest ((succ False))
printTest ((succ (minBound::Bool)))
mayBomb (printTest ((succ (maxBound::Bool))))
-- pred:
printTest ((pred True))
printTest ((pred (maxBound::Bool)))
......@@ -380,7 +380,7 @@ testEnumInteger = do
-- [x..] aka enumFrom
printTest ((take 7 [(1::Integer)..]))
printTest ((take 7 [(-5::Integer)..]))
-- [x,y..] aka enumFromThen
printTest ((take 7 [(1::Integer),2..]))
printTest ((take 7 [(1::Integer),7..]))
......@@ -422,7 +422,7 @@ testEnumRational = do
-- [x..] aka enumFrom
printTest ((take 7 [(1::Rational)..]))
printTest ((take 7 [(-5::Rational)..]))
-- [x,y..] aka enumFromThen
printTest ((take 7 [(1::Rational),2..]))
printTest ((take 7 [(1::Rational),7..]))
......@@ -465,7 +465,7 @@ testEnumRatioInt = do
printTest ((take 7 [(1::Ratio Int)..]))
printTest ((take 7 [(-5::Ratio Int)..]))
printTest ((take 7 [((toEnum ((maxBound::Int)-5))::Ratio Int)..]))
-- [x,y..] aka enumFromThen
printTest ((take 7 [(1::Ratio Int),2..]))
printTest ((take 7 [(1::Ratio Int),7..]))
......
......@@ -7,8 +7,8 @@ import Control.Exception
-- sample code in the Prelude doesn't agree, at least for
-- Float and Double).
main = do
catch (evaluate [error "" :: Int ..] >> return ()) (\(e::SomeException) -> putStrLn "ok1")
catch (evaluate [error "" :: Integer ..] >> return ()) (\(e::SomeException) -> putStrLn "ok2")
catch (evaluate [error "" :: Float ..] >> return ()) (\(e::SomeException) -> putStrLn "ok3")
catch (evaluate [error "" :: Double ..] >> return ()) (\(e::SomeException) -> putStrLn "ok4")
main = do
catch (evaluate [error "" :: Int ..] >> return ()) (\(e::SomeException) -> putStrLn "ok1")
catch (evaluate [error "" :: Integer ..] >> return ()) (\(e::SomeException) -> putStrLn "ok2")
catch (evaluate [error "" :: Float ..] >> return ()) (\(e::SomeException) -> putStrLn "ok3")
catch (evaluate [error "" :: Double ..] >> return ()) (\(e::SomeException) -> putStrLn "ok4")
......@@ -9,14 +9,14 @@ test blocking = do
let sz = 42
loop = do
b <- allocaBytes sz $ \ptr -> do
b <- allocaBytes sz $ \ptr -> do
r <- (if blocking then hGetBuf else hGetBufNonBlocking) h ptr sz
if (r == 0)
then return True
else do s <- peekCStringLen (ptr,r)
putStr s
return False
if b then return () else loop -- tail call
if (r == 0)
then return True
else do s <- peekCStringLen (ptr,r)
putStr s
return False
if b then return () else loop -- tail call
loop
......@@ -9,14 +9,14 @@ test blocking = do
let sz = 42
loop = do
b <- allocaBytes sz $ \ptr -> do
b <- allocaBytes sz $ \ptr -> do
r <- (if blocking then hGetBuf else hGetBufNonBlocking) h ptr sz
if (r == 0)
then return True
else do s <- peekCStringLen (ptr,r)
putStr s
return False
if b then return () else loop -- tail call
if (r == 0)
then return True
else do s <- peekCStringLen (ptr,r)
putStr s
return False
if b then return () else loop -- tail call
loop
......@@ -31,14 +31,14 @@ test blocking = do
let sz = 42
loop = do
b <- allocaBytes sz $ \ptr -> do
b <- allocaBytes sz $ \ptr -> do
r <- (if blocking then hGetBuf else hGetBufNonBlocking) h ptr sz
if (r == 0)
then return True
else do s <- peekCStringLen (ptr,r)
putStr s
return False
if b then return () else loop -- tail call
if (r == 0)
then return True
else do s <- peekCStringLen (ptr,r)
putStr s
return False
if b then return () else loop -- tail call
loop
......@@ -13,14 +13,14 @@ test blocking = do
-- mix ordinary char buffering with hGetBuf
eof <- hIsEOF h
when (not eof) $ hGetChar h >>= putChar
b <- allocaBytes sz $ \ptr -> do
b <- allocaBytes sz $ \ptr -> do
r <- (if blocking then hGetBuf else hGetBufNonBlocking) h ptr sz
if (r == 0)
then return True
else do s <- peekCStringLen (ptr,r)
putStr s
return False
if b then return () else loop -- tail call
if (r == 0)
then return True
else do s <- peekCStringLen (ptr,r)
putStr s
return False
if b then return () else loop -- tail call
loop
......@@ -13,14 +13,14 @@ test blocking = do
-- mix ordinary char buffering with hGetBuf
eof <- hIsEOF h
when (not eof) $ hGetChar h >>= putChar
b <- allocaBytes sz $ \ptr -> do
b <- allocaBytes sz $ \ptr -> do
r <- (if blocking then hGetBuf else hGetBufNonBlocking) h ptr sz
if (r == 0)
then return True
else do s <- peekCStringLen (ptr,r)
putStr s
return False
if b then return () else loop -- tail call
if (r == 0)
then return True
else do s <- peekCStringLen (ptr,r)
putStr s
return False
if b then return () else loop -- tail call
loop
......@@ -39,14 +39,14 @@ test blocking = do
-- mix ordinary char buffering with hGetBuf
eof <- hIsEOF h
when (not eof) $ hGetChar h >>= putChar
b <- allocaBytes sz $ \ptr -> do
b <- allocaBytes sz $ \ptr -> do
r <- (if blocking then hGetBuf else hGetBufNonBlocking) h ptr sz
if (r == 0)
then return True
else do s <- peekCStringLen (ptr,r)
putStr s
return False
if b then return () else loop -- tail call
if (r == 0)