math.rectangles: add infinite recursion check in case somebody does something stupid

release
Slava Pestov 2010-09-16 21:25:22 -07:00
parent b3c5097862
commit 04be762fac
2 changed files with 11 additions and 3 deletions

View 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 ;

View 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