Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
lisp
lingo
Commits
f155092c
Commit
f155092c
authored
Jun 26, 2017
by
Juergen Nickelsen
Browse files
enable printing cyclic data structures; closes #11
As the last piece, tests in 072.
parent
2787829c
Changes
1
Hide whitespace changes
Inline
Side-by-side
regtests/072-cycles.lisp
0 → 100644
View file @
f155092c
;;; 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
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment