mes: with-input-from-string: peek fix.

* module/mes/guile.mes (with-input-from-string): Return actual tell.
* tests/guile.test ("with-input-from-string peek"): Test it.
This commit is contained in:
Jan Nieuwenhuizen 2018-01-04 18:35:26 +01:00
parent fd13741eb3
commit 28d0c259ed
2 changed files with 8 additions and 2 deletions

View file

@ -71,8 +71,9 @@
(let ((tell 0)
(end (string-length string)))
(set! peek-char
(lambda () (if (= tell end) (integer->char -1)
(string-ref string (- tell 1)))))
(lambda ()
(if (= tell end) (integer->char -1)
(string-ref string tell))))
(set! read-char
(lambda () (if (= tell end) (integer->char -1)
(begin

View file

@ -112,4 +112,9 @@ exit $?
(push-input sp)
(and (pop-input) (not (pop-input)))))
(pass-if-equal "with-input-from-string peek"
#\X
(with-input-from-string "X"
(lambda () (peek-char))))
(result 'report)