mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-19 13:49:17 +02:00
better fix for #618
This commit is contained in:
parent
d511b8e31d
commit
23f93cceb4
2 changed files with 62 additions and 57 deletions
|
@ -66,10 +66,7 @@
|
||||||
(set! count (+ count 1))))
|
(set! count (+ count 1))))
|
||||||
(cont x index)))))
|
(cont x index)))))
|
||||||
(let wr ((x x))
|
(let wr ((x x))
|
||||||
(check-shared
|
(define (wr-one x shared?)
|
||||||
x
|
|
||||||
""
|
|
||||||
(lambda (x shared?)
|
|
||||||
(cond
|
(cond
|
||||||
((pair? x)
|
((pair? x)
|
||||||
(display "(" out)
|
(display "(" out)
|
||||||
|
@ -95,7 +92,7 @@
|
||||||
(wr (car ls))
|
(wr (car ls))
|
||||||
(lp (cdr ls)))))
|
(lp (cdr ls)))))
|
||||||
(shared? ;; shared dotted tail
|
(shared? ;; shared dotted tail
|
||||||
(write ls out))
|
(wr-one ls #f))
|
||||||
(else
|
(else
|
||||||
(display " . " out)
|
(display " . " out)
|
||||||
(wr ls))))))
|
(wr ls))))))
|
||||||
|
@ -121,7 +118,8 @@
|
||||||
((eq? x #f) (display "#f" out))
|
((eq? x #f) (display "#f" out))
|
||||||
(else
|
(else
|
||||||
;; (display "#<unknown>" out)
|
;; (display "#<unknown>" out)
|
||||||
(write x out))))))))
|
(write x out))))
|
||||||
|
(check-shared x "" wr-one))))
|
||||||
|
|
||||||
(define write/ss write-with-shared-structure)
|
(define write/ss write-with-shared-structure)
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
(define-syntax test-cyclic-io
|
(define-syntax test-cyclic-io
|
||||||
(syntax-rules ()
|
(syntax-rules ()
|
||||||
((test-io str-expr expr)
|
((test-cyclic-io str-expr expr)
|
||||||
(let ((str str-expr)
|
(let ((str str-expr)
|
||||||
(value expr))
|
(value expr))
|
||||||
(test str (write-to-string value #t))
|
(test str (write-to-string value #t))
|
||||||
|
@ -48,6 +48,13 @@
|
||||||
(test-io "(#0=(1 . 2) #1=(1 . 2) #2=(3 . 4) #0# #1# #2#)"
|
(test-io "(#0=(1 . 2) #1=(1 . 2) #2=(3 . 4) #0# #1# #2#)"
|
||||||
(let ((a (cons 1 2)) (b (cons 1 2)) (c (cons 3 4)))
|
(let ((a (cons 1 2)) (b (cons 1 2)) (c (cons 3 4)))
|
||||||
(list a b c a b c)))
|
(list a b c a b c)))
|
||||||
|
(test-io "((1 . #0=#(2)) #0#)"
|
||||||
|
(let ((vec (vector 2)))
|
||||||
|
(list (cons 1 vec) vec)))
|
||||||
|
(test-io "((1 . #0=#(2 #0#)) #0#)"
|
||||||
|
(let ((vec (vector 2 #f)))
|
||||||
|
(vector-set! vec 1 vec)
|
||||||
|
(list (cons 1 vec) vec)))
|
||||||
(test-cyclic-io "((1 . 2) (1 . 2) (3 . 4) (1 . 2) (1 . 2) (3 . 4))"
|
(test-cyclic-io "((1 . 2) (1 . 2) (3 . 4) (1 . 2) (1 . 2) (3 . 4))"
|
||||||
(let ((a (cons 1 2)) (b (cons 1 2)) (c (cons 3 4)))
|
(let ((a (cons 1 2)) (b (cons 1 2)) (c (cons 3 4)))
|
||||||
(list a b c a b c)))
|
(list a b c a b c)))
|
||||||
|
|
Loading…
Add table
Reference in a new issue