mes: open-input-string: peek fix.
authorJan Nieuwenhuizen <janneke@gnu.org>
Thu, 4 Jan 2018 18:32:35 +0000 (19:32 +0100)
committerJan Nieuwenhuizen <janneke@gnu.org>
Thu, 4 Jan 2018 18:32:35 +0000 (19:32 +0100)
* module/mes/guile.mes (open-input-string): Return actual tell.
* tests/guile.test ("open-input-string peek"): Test it.

module/mes/guile.mes
tests/guile.test

index bd2f3bb47909865632a52809ada39e3df7e62649..5b5051f4d2120da1d8afed4a060c7b76e922ba79 100644 (file)
                       (set! tell 0)
                       (set! peek-char
                             (lambda () (if (= tell end) (integer->char -1)
-                                           (string-ref string (- tell 1)))))
+                                           (string-ref string tell))))
                       (set! read-char
                             (lambda () (if (= tell end) (integer->char -1)
                                            (begin
index 0af3b35e8175f2fed5e469202d4e7fecd5e9f4e0..1fa3b1142cfb07b914d7a61073a5c4cdb3242f65 100755 (executable)
@@ -117,4 +117,10 @@ exit $?
                (with-input-from-string "X"
                  (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)