From 04be762fac97486eaf16a64bfb68ee8d6cea7362 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 16 Sep 2010 21:25:22 -0700 Subject: [PATCH] math.rectangles: add infinite recursion check in case somebody does something stupid --- basis/math/rectangles/prettyprint/prettyprint.factor | 8 ++++++-- basis/math/rectangles/rectangles-tests.factor | 6 +++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/basis/math/rectangles/prettyprint/prettyprint.factor b/basis/math/rectangles/prettyprint/prettyprint.factor index c23be50029..b1fe1789f7 100644 --- a/basis/math/rectangles/prettyprint/prettyprint.factor +++ b/basis/math/rectangles/prettyprint/prettyprint.factor @@ -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 ; diff --git a/basis/math/rectangles/rectangles-tests.factor b/basis/math/rectangles/rectangles-tests.factor index 7959d98f92..0e1c32778b 100644 --- a/basis/math/rectangles/rectangles-tests.factor +++ b/basis/math/rectangles/rectangles-tests.factor @@ -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