Add test case to make sure `read' returns mutable strings.
authorLudovic Courtès <ludo@gnu.org>
Thu, 9 Oct 2008 20:32:16 +0000 (22:32 +0200)
committerLudovic Courtès <ludo@gnu.org>
Thu, 9 Oct 2008 20:32:16 +0000 (22:32 +0200)
* test-suite/tests/reader.test ("reading")["returned strings are
  mutable"]: New test, as reported by szgyg <szgyg@ludens.elte.hu>.

test-suite/tests/reader.test

index 0b13cf1..b068c71 100644 (file)
 
   (pass-if "CR recognized as a token delimiter"
     ;; In 1.8.3, character 0x0d was not recognized as a delimiter.
-    (equal? (read-string "one\x0dtwo") 'one)))
+    (equal? (read-string "one\x0dtwo") 'one))
+
+  (pass-if "returned strings are mutable"
+    ;; Per R5RS Section 3.4, "Storage Model", `read' is supposed to return
+    ;; mutable objects.
+    (let ((str (with-input-from-string "\"hello, world\"" read)))
+      (string-set! str 0 #\H)
+      (string=? str "Hello, world"))))
 
 \f
 (pass-if-exception "radix passed to number->string can't be zero"