From 8c9c0f05d2d2b1ee638a7a0f8561cab0fa926888 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Mon, 28 Jun 2010 09:10:16 -0700 Subject: [PATCH] prettyprint.backend: leave nesting-limit unset when prettyprinting hashtables without a nesting limit, fixing the bug where it would get set to 1 and print nothing (reported by Blei) --- basis/prettyprint/backend/backend.factor | 8 ++++++-- basis/prettyprint/prettyprint-tests.factor | 13 +++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/basis/prettyprint/backend/backend.factor b/basis/prettyprint/backend/backend.factor index 201a1c28d2..9352673a61 100644 --- a/basis/prettyprint/backend/backend.factor +++ b/basis/prettyprint/backend/backend.factor @@ -226,9 +226,13 @@ M: object pprint-object ( obj -- ) M: object pprint* pprint-object ; M: vector pprint* pprint-object ; M: byte-vector pprint* pprint-object ; + +: with-extra-nesting-level ( quot -- ) + nesting-limit [ dup [ 1 + ] [ f ] if* ] change + [ nesting-limit set ] curry [ ] cleanup ; inline + M: hashtable pprint* - nesting-limit inc - [ pprint-object ] [ nesting-limit dec ] [ ] cleanup ; + [ pprint-object ] with-extra-nesting-level ; M: curry pprint* pprint-object ; M: compose pprint* pprint-object ; M: hash-set pprint* pprint-object ; diff --git a/basis/prettyprint/prettyprint-tests.factor b/basis/prettyprint/prettyprint-tests.factor index ec0e20a393..42a7322037 100644 --- a/basis/prettyprint/prettyprint-tests.factor +++ b/basis/prettyprint/prettyprint-tests.factor @@ -374,3 +374,16 @@ TUPLE: final-tuple ; final ] [ [ \ final-tuple see ] with-string-writer "\n" split ] unit-test + +[ "H{ { 1 2 } }\n" ] [ [ H{ { 1 2 } } short. ] with-string-writer ] unit-test + +[ "H{ { 1 ~array~ } }\n" ] [ [ H{ { 1 { 2 } } } short. ] with-string-writer ] unit-test + +[ "{ ~array~ }\n" ] [ [ { { 1 2 } } short. ] with-string-writer ] unit-test + +[ "H{ { 1 { 2 3 } } }\n" ] [ + f nesting-limit [ + [ H{ { 1 { 2 3 } } } . ] with-string-writer + ] with-variable +] unit-test +