simplify code and test for print-pair-curly-braces
After the change that makes printing of struct ignore print-pair-curly-braces it is possible to simplify the code in io/print and the associated tests.
This commit is contained in:
parent
bdb578606e
commit
daba5db44a
|
@ -472,14 +472,7 @@
|
|||
(test-print/all (list (cons x x))
|
||||
"{{#0=#(struct:s) . #0#}}" "{{#0=#(struct:s) . #0#}}" "{{#0=#(struct:s) . #0#}}" "(list (cons #0=(s) #0#))" "{{#0=#(struct:s) . #0#}}")
|
||||
(test-print/all (list x x)
|
||||
"{#0=#(struct:s) #0#}" "{#0=#(struct:s) #0#}" "{#0=#(struct:s) #0#}" "(list #0=(s) #0#)" "{#0=#(struct:s) #0#}")
|
||||
(test-print/all (b 1 2)
|
||||
"#(struct:b 1 2)" "#(struct:b 1 2)" "#(struct:b 1 2)" "(b 1 2)" "#(struct:b 1 2)")
|
||||
(test-print/all (c 1 2)
|
||||
"#s(c 1 2)" "#s(c 1 2)" "#s(c 1 2)" "'#s(c 1 2)" "#s(c 1 2)")
|
||||
(test-print/all (c x x)
|
||||
"#s(c #0=#(struct:s) #0#)" "#s(c #0=#(struct:s) #0#)" "#s(c #0=#(struct:s) #0#)" "(c #0=(s) #0#)" "#s(c #0=#(struct:s) #0#)"))
|
||||
|
||||
"{#0=#(struct:s) #0#}" "{#0=#(struct:s) #0#}" "{#0=#(struct:s) #0#}" "(list #0=(s) #0#)" "{#0=#(struct:s) #0#}"))
|
||||
(parameterize ([print-pair-curly-braces #f])
|
||||
(test-print/all (cons 1 2)
|
||||
"(1 . 2)" "(1 . 2)" "(1 . 2)" "'(1 . 2)" "(1 . 2)")
|
||||
|
@ -496,16 +489,16 @@
|
|||
(test-print/all (list (cons x x))
|
||||
"((#0=#(struct:s) . #0#))" "((#0=#(struct:s) . #0#))" "((#0=#(struct:s) . #0#))" "(list (cons #0=(s) #0#))" "((#0=#(struct:s) . #0#))")
|
||||
(test-print/all (list x x)
|
||||
"(#0=#(struct:s) #0#)" "(#0=#(struct:s) #0#)" "(#0=#(struct:s) #0#)" "(list #0=(s) #0#)" "(#0=#(struct:s) #0#)")
|
||||
(test-print/all (b 1 2)
|
||||
"#(struct:b 1 2)" "#(struct:b 1 2)" "#(struct:b 1 2)" "(b 1 2)" "#(struct:b 1 2)")
|
||||
(test-print/all (c 1 2)
|
||||
"#s(c 1 2)" "#s(c 1 2)" "#s(c 1 2)" "'#s(c 1 2)" "#s(c 1 2)")
|
||||
(test-print/all (c x x)
|
||||
"#s(c #0=#(struct:s) #0#)" "#s(c #0=#(struct:s) #0#)" "#s(c #0=#(struct:s) #0#)" "(c #0=(s) #0#)" "#s(c #0=#(struct:s) #0#)"))
|
||||
"(#0=#(struct:s) #0#)" "(#0=#(struct:s) #0#)" "(#0=#(struct:s) #0#)" "(list #0=(s) #0#)" "(#0=#(struct:s) #0#)"))
|
||||
|
||||
(test-print/all (a 1 2)
|
||||
"#<a>" "#<a>" "#<a>" "#<a>" "#<a>")
|
||||
|
||||
(test-print/all (b 1 2)
|
||||
"#(struct:b 1 2)" "#(struct:b 1 2)" "#(struct:b 1 2)" "(b 1 2)" "#(struct:b 1 2)")
|
||||
(test-print/all (c 1 2)
|
||||
"#s(c 1 2)" "#s(c 1 2)" "#s(c 1 2)" "'#s(c 1 2)" "#s(c 1 2)")
|
||||
(test-print/all (c x x)
|
||||
"#s(c #0=#(struct:s) #0#)" "#s(c #0=#(struct:s) #0#)" "#s(c #0=#(struct:s) #0#)" "(c #0=(s) #0#)" "#s(c #0=#(struct:s) #0#)")
|
||||
(void))))
|
||||
|
||||
;; ----------------------------------------
|
||||
|
|
|
@ -13,15 +13,9 @@
|
|||
(and (eq? mode PRINT-MODE/UNQUOTED)
|
||||
(not alt-list-constructor)
|
||||
(not (uninterrupted-list? v graph))))
|
||||
(define curly? (cond
|
||||
[(eq? mode PRINT-MODE/UNQUOTED)
|
||||
(and (not unquoted-pairs?)
|
||||
alt-list-constructor
|
||||
(eq? (string-ref alt-list-constructor 0) #\{))]
|
||||
[alt-list-prefix
|
||||
(eq? (string-ref alt-list-prefix 0) #\{)]
|
||||
[else
|
||||
(config-get config print-pair-curly-braces)]))
|
||||
(define curly? (and (not (eq? mode PRINT-MODE/UNQUOTED))
|
||||
(not alt-list-prefix)
|
||||
(config-get config print-pair-curly-braces)))
|
||||
(define (abbreviation v)
|
||||
(and (eq? mode PRINT-MODE/QUOTED)
|
||||
(pair? v)
|
||||
|
|
Loading…
Reference in New Issue
Block a user