Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Glasgow Haskell Compiler
GHC
Commits
edf3f79d
Commit
edf3f79d
authored
Aug 28, 2001
by
simonmar
Browse files
[project @ 2001-08-28 11:12:09 by simonmar]
Add some tests for hGetBuf & hPutBuf
parent
f81e778a
Changes
7
Hide whitespace changes
Inline
Side-by-side
testsuite/tests/ghc-regress/lib/IOExts/all.T
View file @
edf3f79d
...
...
@@ -11,3 +11,6 @@ test "hTell001" { myvtr("","","") }
test
"
hTell002
"
{
myvtr
("","","")
}
test
"
performGC001
"
{
myvtr
("","","")
}
test
"
trace001
"
{
myvtr
("","","")
}
test
"
hGetBuf001
"
{
myvtr
("","","")
}
test
"
hPutBuf001
"
{
myvtr
("","","")
}
test
"
hPutBuf002
"
{
myvtr
("","","")
}
testsuite/tests/ghc-regress/lib/IOExts/hGetBuf001.hs
0 → 100644
View file @
edf3f79d
import
IO
import
IOExts
import
Foreign
import
CForeign
main
=
do
h
<-
openFile
"hGetBuf001.hs"
ReadMode
let
sz
=
42
loop
=
do
b
<-
allocaBytes
sz
$
\
ptr
->
do
r
<-
hGetBuf
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
loop
testsuite/tests/ghc-regress/lib/IOExts/hGetBuf001.stdout
0 → 100644
View file @
edf3f79d
import IO
import IOExts
import Foreign
import CForeign
main = do
h <- openFile "hGetBuf001.hs" ReadMode
let sz = 42
loop = do
b <- allocaBytes sz $ \ptr -> do
r <- hGetBuf 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
loop
testsuite/tests/ghc-regress/lib/IOExts/hPutBuf001.hs
0 → 100644
View file @
edf3f79d
import
IO
import
IOExts
import
Foreign
import
CForeign
main
=
withCStringLen
"hello world
\n
"
$
\
(
ptr
,
len
)
->
hPutBuf
stdout
ptr
len
testsuite/tests/ghc-regress/lib/IOExts/hPutBuf001.stdout
0 → 100644
View file @
edf3f79d
hello world
testsuite/tests/ghc-regress/lib/IOExts/hPutBuf002.hs
0 → 100644
View file @
edf3f79d
import
IO
import
IOExts
import
Foreign
import
CForeign
-- !!! this test failed to write anything in GHC 5.00.2
main
=
do
h
<-
openFile
"hPutBuf002.out"
ReadWriteMode
withCStringLen
"hello world
\n
"
$
\
(
ptr
,
len
)
->
hPutBuf
h
ptr
len
hFileSize
h
>>=
print
testsuite/tests/ghc-regress/lib/IOExts/hPutBuf002.stdout
0 → 100644
View file @
edf3f79d
12
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment