]> gitweb.factorcode.org Git - factor.git/commitdiff
math.rectangles: add infinite recursion check in case somebody does something stupid
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Fri, 17 Sep 2010 04:25:22 +0000 (21:25 -0700)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Fri, 17 Sep 2010 04:27:18 +0000 (21:27 -0700)
basis/math/rectangles/prettyprint/prettyprint.factor
basis/math/rectangles/rectangles-tests.factor

index c23be500299d0233bf4df89f086e16052958c214..b1fe1789f788d3d0615a4256999c62eb762f8887 100644 (file)
@@ -1,7 +1,11 @@
-! Copyright (C) 2009 Slava Pestov.
+! Copyright (C) 2009, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors math.rectangles kernel prettyprint.custom prettyprint.backend ;
 IN: math.rectangles.prettyprint
 
 M: rect pprint*
-    \ RECT: [ [ loc>> ] [ dim>> ] bi [ pprint* ] bi@ ] pprint-prefix ;
+    [
+        \ RECT: [
+            [ loc>> ] [ dim>> ] bi [ pprint* ] bi@
+        ] pprint-prefix
+    ] check-recursion ;
index 7959d98f929d5dd09f9e2140611a33b9147b5681..0e1c32778b616db0f5bee4433555588c5ec25cd8 100644 (file)
@@ -1,4 +1,5 @@
-USING: tools.test math.rectangles ;
+USING: tools.test math.rectangles prettyprint io.streams.string
+kernel accessors ;
 IN: math.rectangles.tests
 
 [ RECT: { 10 10 } { 20 20 } ]
@@ -40,3 +41,6 @@ IN: math.rectangles.tests
         { 30 30 }
     } rect-containing
 ] unit-test
+
+! Prettyprint for RECT: didn't do nesting check properly
+[ ] [ [ RECT: f f dup >>dim . ] with-string-writer drop ] unit-test