add tests for racket/port
Also, fix some doc typos.
This commit is contained in:
parent
d469265a6e
commit
608e6cc2a2
|
@ -235,9 +235,9 @@ arguments. The four arguments correspond to the location of the
|
|||
special value within the port, as described in
|
||||
@secref["customport"]. If the procedure is called more than once
|
||||
with valid arguments, the @exnraise[exn:fail:contract]. If
|
||||
@racket[read-bytes-avail] returns a special-producing procedure, then
|
||||
@racket[read-bytes-avail!] returns a special-producing procedure, then
|
||||
it does not place characters in @racket[bstr]. Similarly,
|
||||
@racket[read-bytes-avail] places only as many bytes into @racket[bstr]
|
||||
@racket[read-bytes-avail!] places only as many bytes into @racket[bstr]
|
||||
as are available before a special value in the port's stream.}
|
||||
|
||||
@defproc[(read-bytes-avail!* [bstr bytes?]
|
||||
|
@ -351,7 +351,7 @@ case that @racket[progress] becomes ready before bytes are peeked.}
|
|||
Like @racket[read-bytes-avail!*], but for @tech{peek}ing, and with
|
||||
@racket[skip-bytes-amt] and @racket[progress] arguments like
|
||||
@racket[peek-bytes-avail!]. Since this procedure never blocks, it may
|
||||
return before even @racket[skip-amt] bytes are available from the
|
||||
return before even @racket[skip-bytes-amt] bytes are available from the
|
||||
port.}
|
||||
|
||||
@defproc[(peek-bytes-avail!/enable-break [bstr (and/c bytes? (not/c immutable?))]
|
||||
|
|
|
@ -1201,4 +1201,43 @@
|
|||
|
||||
;; --------------------------------------------------
|
||||
|
||||
(let ()
|
||||
;; Check `special-filter-input-port`
|
||||
(define-values (i o) (make-pipe-with-specials))
|
||||
(define fi (special-filter-input-port
|
||||
i
|
||||
(lambda (proc bstr)
|
||||
(bytes-set! bstr 0 (char->integer #\z))
|
||||
1)))
|
||||
(write-bytes #"abc" o)
|
||||
(test #"abc" read-bytes 3 fi)
|
||||
(write-special 'hello o)
|
||||
(test #"z" read-bytes 1 fi)
|
||||
(write-bytes #"ab" o)
|
||||
(write-bytes #"c" o)
|
||||
(write-special 'ok o)
|
||||
(write-special 'bye o)
|
||||
(test #"abczz" peek-bytes 5 0 fi)
|
||||
(test #"abczz" peek-bytes 5 0 fi)
|
||||
(test #"abcz" read-bytes 4 fi)
|
||||
(define bstr (make-bytes 5))
|
||||
(test 1 peek-bytes-avail! bstr 0 #f fi)
|
||||
(test #"z" subbytes bstr 0 1))
|
||||
|
||||
(let ()
|
||||
;; Check `special-filter-input-port` with `peeking-input-port`
|
||||
(define-values (i o) (make-pipe-with-specials))
|
||||
(define fi (special-filter-input-port
|
||||
i
|
||||
(lambda (proc bstr)
|
||||
(bytes-set! bstr 0 (char->integer #\z))
|
||||
1)))
|
||||
(define pi (peeking-input-port fi))
|
||||
(write-bytes #"abc" o)
|
||||
(write-special 'hello o)
|
||||
(write-special 'again o)
|
||||
(test #"abczz" peek-bytes 5 0 pi))
|
||||
|
||||
;; --------------------------------------------------
|
||||
|
||||
(report-errs)
|
||||
|
|
Loading…
Reference in New Issue
Block a user