X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=tests%2Fstream.pure.lisp;h=b059537673d928ab95973c4b21e7b4ec78b79979;hb=c43e3ee7e99bf8116402c2e6a90320b2e92b391b;hp=b9e2a9ba2e5a8dc6d3b31db4963dc79097e5ff28;hpb=4898ef32c639b1c7f4ee13a5ba566ce6debd03e6;p=sbcl.git diff --git a/tests/stream.pure.lisp b/tests/stream.pure.lisp index b9e2a9b..b059537 100644 --- a/tests/stream.pure.lisp +++ b/tests/stream.pure.lisp @@ -261,7 +261,7 @@ (frob 'base-char) (frob 'nil)) -(with-open-file (s "/dev/null" :element-type '(signed-byte 48)) +(with-open-file (s #-win32 "/dev/null" #+win32 "nul" :element-type '(signed-byte 48)) (assert (eq :eof (read-byte s nil :eof)))) (let* ((is (make-string-input-stream "foo")) @@ -292,4 +292,43 @@ (assert (string= (get-output-stream-string os) "foo"))) (with-standard-io-syntax - (open "/dev/null")) + (open #-win32 "/dev/null" #+win32 "nul" )) + +;;; PEEK-CHAR T uses whitespace[2] +(let ((*readtable* (copy-readtable))) + (assert (char= (peek-char t (make-string-input-stream " a")) #\a)) + (set-syntax-from-char #\Space #\a) + (assert (char= (peek-char t (make-string-input-stream " a")) #\Space))) + +;;; It is actually easier to run into the problem exercised by this +;;; test with sockets, due to their delays between availabilities of +;;; data. However edgy the case may be for normal files, however, +;;; there is still a case to be found in which CL:LISTEN answers +;;; improperly. +;;; +;;; This test assumes that buffering is still done until a buffer of +;;; SB-IMPL::BYTES-PER-BUFFER bytes is filled up, that the buffer may +;;; immediately be completely filled for normal files, and that the +;;; buffer-fill routine is responsible for figuring out when we've +;;; reached EOF. +(with-test (:name (stream listen-vs-select)) + (let ((listen-testfile-name "stream.impure.lisp.testqfile") + ;; If non-NIL, size (in bytes) of the file that will exercise + ;; the LISTEN problem. + (bytes-per-buffer-sometime + (and (boundp 'sb-impl::bytes-per-buffer) + (symbol-value 'sb-impl::bytes-per-buffer)))) + (when bytes-per-buffer-sometime + (unwind-protect + (progn + (with-open-file (stream listen-testfile-name + :direction :output :if-exists :error + :element-type '(unsigned-byte 8)) + (dotimes (n bytes-per-buffer-sometime) + (write-byte 113 stream))) + (with-open-file (stream listen-testfile-name + :direction :input :element-type '(unsigned-byte 8)) + (dotimes (n bytes-per-buffer-sometime) + (read-byte stream)) + (assert (not (listen stream))))) + (ignore-errors (delete-file listen-testfile-name))))))