diff options
Diffstat (limited to 'testsuite/tests/lib/IO/hGetChar001.hs')
-rw-r--r-- | testsuite/tests/lib/IO/hGetChar001.hs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/testsuite/tests/lib/IO/hGetChar001.hs b/testsuite/tests/lib/IO/hGetChar001.hs new file mode 100644 index 0000000000..f5ca666828 --- /dev/null +++ b/testsuite/tests/lib/IO/hGetChar001.hs @@ -0,0 +1,18 @@ +import System.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) |