cs: fix byte-ready? on the result of make-input-port

When an evt is returned by the byte-peeking function, the evt needs to
be polled.

Relevant to racket/datalog#13
This commit is contained in:
Matthew Flatt 2021-02-26 11:31:47 -07:00
parent 0841af7992
commit 999c300f7f
3 changed files with 32 additions and 2 deletions

View File

@ -164,6 +164,30 @@
exn:fail?)
(err/rt-test (port-commit-peeked 100 never-evt always-evt /dev/null-in))
;; A port that produces a stream of 1s, but always
;; though an evt:
(let ()
(define stubborn-infinite-ones
(make-input-port
'ones
(lambda (s)
(wrap-evt always-evt
(lambda (ae)
(bytes-set! s 0 (char->integer #\1))
1)))
(lambda (s skip-n progress-evt)
(wrap-evt always-evt
(lambda (ae)
(bytes-set! s 0 (char->integer #\1))
1)))
void))
(test "11111" read-string 5 stubborn-infinite-ones)
(test "11111" peek-string 5 0 stubborn-infinite-ones)
(test #t byte-ready? stubborn-infinite-ones)
(test #t char-ready? stubborn-infinite-ones)
(test "11111" read-string 5 stubborn-infinite-ones)
(test stubborn-infinite-ones sync/timeout 0 stubborn-infinite-ones))
;; A port that produces a stream of 1s:
(define infinite-ones
(make-input-port

View File

@ -28732,7 +28732,12 @@
(|#%app| byte-ready_0 in_1 void)))
(begin
(unsafe-end-atomic)
(eq? #t r_0)))))))))))))
(let ((or-part_0 (eq? #t r_0)))
(if or-part_0
or-part_0
(if r_0
(if (sync/timeout 0 r_0) #t #f)
#f)))))))))))))))
(loop_0
(->core-input-port.1 unsafe-undefined in_0 #f))))))))))
(|#%name|

View File

@ -26,7 +26,8 @@
(check-not-closed who in)
(define r (byte-ready in void))
(end-atomic)
(eq? #t r)])))
(or (eq? #t r)
(and r (sync/timeout 0 r) #t))])))
(define/who (char-ready? [in (current-input-port)])
(check who input-port? in)