[patch: perl@8211]VMS: add -Duseperlio capacity to configure.com
[p5sagit/p5-mst-13.2.git] / t / op / recurse.t
index 6b21c66..dc823ed 100755 (executable)
@@ -4,7 +4,7 @@
 # test recursive functions.
 #
 
-print "1..23\n";
+print "1..25\n";
 
 sub gcd ($$) {
     return gcd($_[0] - $_[1], $_[1]) if ($_[0] > $_[1]);
@@ -22,13 +22,9 @@ sub fibonacci ($) {
 
 # Highly recursive, highly aggressive.
 # Kids, don't try this at home.
-# For example ackermann(4,0) will take quite a long time.
 #
-# In fact, the current Perl, 5.004, will complain loudly:
-# "Deep recursion on subroutine." (see perldiag) when
-# computing the ackermann(4,0) because the recursion will
-# become so deep (>100 levels) that Perl suspects the script
-# has been lost in an infinite recursion.
+# For example ackermann(4,1) will take quite a long time.
+# It will simply eat away your memory. Trust me.
 
 sub ackermann ($$) {
     return $_[1] + 1               if ($_[0] == 0);
@@ -88,3 +84,33 @@ for $x (0..3) {
 print 'not ' unless (($t = takeuchi($x, $y, $z)) == $z + 1);
 print "ok ", $i++, "\n";
 print "# takeuchi($x, $y, $z) = $t\n";
+
+{
+    sub get_first1 {
+       get_list1(@_)->[0];
+    }
+
+    sub get_list1 {
+       return [24] unless $_[0];
+       my $u = get_first1(0);
+       [$u];
+    }
+    my $x = get_first1(1);
+    print "ok $x\n";
+}
+
+{
+    sub get_first2 {
+       return get_list2(@_)->[0];
+    }
+
+    sub get_list2 {
+       return [25] unless $_[0];
+       my $u = get_first2(0);
+       return [$u];
+    }
+    my $x = get_first2(1);
+    print "ok $x\n";
+}
+
+$i = 26;