Commit f155092c authored by Juergen Nickelsen's avatar Juergen Nickelsen
Browse files

enable printing cyclic data structures; closes #11

As the last piece, tests in 072.
parent 2787829c
;;; printing (or rather string conversion) of cyclic data structures
;; Testing this with an environment is difficult, and I don't know where I
;; (test-is "cycles env" ...)
(test-is "cycles pair" (let ((a '(3 4 5 6)))
(setf (cadr a) a)
a)
"(3 [...] 5 6)")
(defstruct self-holder "can hold its liquor and itself" this that)
(test-is "cycles struct" (let ((s (make-self-holder :this 19 :that 23)))
(setf (self-holder-this s) s)
s)
"#S(self-holder this [...] that 23)")
(test-is "cycles table" (let ((tbl #:()))
(tbl tbl tbl)
(tbl tbl))
"#:(([...] . [...]))")
(test-is "cycles vector" (let ((v #(4 1 2))
(w #(4 1 1)))
(setf (aref v 1) w)
(setf (aref w 2) v)
w)
"#(4 1 #(4 [...] 2))")
(defstruct foo "each must play a part" bar ble quu)
(test-is "cycles indirect" (let* ((a #:((1 . 2) (3 . 4)))
(b (list 5 6 7 a))
(c (vector 8 9 10 b))
(f (make-foo :bar 11 :ble 12 :quu c)))
(a 3 f)
a)
"#:((1 . 2)(3 . #S(foo bar 11 ble 12 quu #(8 9 10 (5 6 7 [...])))))")
(done-testing)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment