]> gitweb.factorcode.org Git - factor.git/commitdiff
prettyprint.backend: leave nesting-limit unset when prettyprinting hashtables without...
authorJoe Groff <arcata@gmail.com>
Mon, 28 Jun 2010 16:10:16 +0000 (09:10 -0700)
committerJoe Groff <arcata@gmail.com>
Mon, 28 Jun 2010 16:10:16 +0000 (09:10 -0700)
basis/prettyprint/backend/backend.factor
basis/prettyprint/prettyprint-tests.factor

index 201a1c28d23650f36530152143ca22817d67e4f3..9352673a61a3ac9e287e142c4b2426d0a5b05aac 100644 (file)
@@ -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 ;
index ec0e20a393c727bbd6a4ae6b0b83aceef2bf8ee4..42a73220378d7f29f93953bbe49ea67bace1b51c 100644 (file)
@@ -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
+