]> gitweb.factorcode.org Git - factor.git/commitdiff
stack-checker: maybe add a test that tests what the todo said.
authorJohn Benediktsson <mrjbq7@gmail.com>
Thu, 28 Mar 2013 01:44:32 +0000 (18:44 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Thu, 28 Mar 2013 01:44:32 +0000 (18:44 -0700)
basis/stack-checker/stack-checker-tests.factor

index 974b322d1f9e533396ae6c39fcb95b41e2768236..4f2aedf899650bac4c1b1b9d46b63bbf443948f8 100644 (file)
@@ -450,7 +450,13 @@ DEFER: eee'
 [ [ [ append ] strict-each ] infer ] [ unbalanced-branches-error? ] must-fail-with
 [ [ [ 1 + ] strict-2map ] infer ] [ unbalanced-branches-error? ] must-fail-with
 
-! TODO: ensure that polymorphic checking works on recursive combinators
+! ensure that polymorphic checking works on recursive combinators
+: recursive-reduce ( identity i seq quot: ( prev elt -- next ) -- x )
+    2over bounds-check? [
+        [ [ nth-unsafe ] dip call ] 3keep [ 1 + ] 2dip recursive-reduce
+    ] [ 3drop ] if ; inline recursive
+{ 24995000 } [ 0 0 10000 iota [ dup even? [ + ] [ drop ] if ] recursive-reduce ] unit-test
+{ 4 1 } [ [ member? [ 1 + ] when ] curry recursive-reduce ] must-infer-as
 
 [ [ [ write write ] each      ] infer ] [ unbalanced-branches-error? ] must-fail-with