mes: open-input-string: peek fix.

* module/mes/guile.mes (open-input-string): Return actual tell.
* tests/guile.test ("open-input-string peek"): Test it.
This commit is contained in:
Jan Nieuwenhuizen 2018-01-04 19:32:35 +01:00
parent 28d0c259ed
commit 0e06928320
2 changed files with 7 additions and 1 deletions

View file

@ -148,7 +148,7 @@
(set! tell 0) (set! tell 0)
(set! peek-char (set! peek-char
(lambda () (if (= tell end) (integer->char -1) (lambda () (if (= tell end) (integer->char -1)
(string-ref string (- tell 1))))) (string-ref string tell))))
(set! read-char (set! read-char
(lambda () (if (= tell end) (integer->char -1) (lambda () (if (= tell end) (integer->char -1)
(begin (begin

View file

@ -117,4 +117,10 @@ exit $?
(with-input-from-string "X" (with-input-from-string "X"
(lambda () (peek-char)))) (lambda () (peek-char))))
(pass-if-equal "open-input-string peek"
#\X
(let ((port (open-input-string "X")))
(set-current-input-port port)
(peek-char)))
(result 'report) (result 'report)