shithub: femtolisp

Download patch

ref: 2d5cb51afb76b68d7475b7c4033c72000f3dcca7
parent: 983c8476aaabb3ae2868371be198c9ee972dd0dc
author: Jeff Bezanson <jeff.bezanson@gmail.com>
date: Thu Jun 6 15:34:00 EDT 2019

fix part of #53, assertion failure in print_traverse

--- a/print.c
+++ b/print.c
@@ -89,6 +89,9 @@
         for(i=0; i < vector_size(v); i++)
             print_traverse(vector_elt(v,i));
     }
+    else if (iscprim(v)) {
+        // don't consider shared references to e.g. chars
+    }
     else if (isclosure(v)) {
         mark_cons(v);
         function_t *f = (function_t*)ptr(v);
--- a/tests/unittest.lsp
+++ b/tests/unittest.lsp
@@ -292,5 +292,14 @@
 
 (assert (equal? 1.0 (* 1.0 1))) ; tests that * no longer does inexact->exact
 
+(define (with-output-to-string nada thunk)
+  (let ((b (buffer)))
+    (with-output-to b (thunk))
+    (io.tostring! b)))
+
+(let ((c #\a))
+  (assert (equal? (with-output-to-string #f (lambda () (print (list c c))))
+                  "(#\\a #\\a)")))
+
 (princ "all tests pass\n")
 #t