recurse.t revision 1
1N/A# test recursive functions. 1N/A chdir 't' if -d 't'; 1N/A return gcd($_[0] - $_[1], $_[1]) if ($_[0] > $_[1]); 1N/A return gcd($_[0], $_[1] - $_[0]) if ($_[0] < $_[1]); 1N/A# Highly recursive, highly aggressive. 1N/A# Kids, don't try this at home. 1N/A# For example ackermann(4,1) will take quite a long time. 1N/A# It will simply eat away your memory. Trust me. 1N/A return $_[1] + 1 if ($_[0] == 0); 1N/A# Highly recursive, highly boring. 1N/Ais(gcd(1147, 1271), 31, "gcd(1147, 1271) == 31");
1N/Ais(gcd(1908, 2016), 36, "gcd(1908, 2016) == 36");
1N/Amy @
ack =
qw(1 2 3 4 2 3 4 5 3 5 7 9 5 13 29 61);
1N/A is($a, shift(@ack), "ackermann($x, $y) == $a"); 1N/Amy ($x, $y, $z) =
(18, 12, 6);
1N/Ais(takeuchi($x, $y, $z), $z + 1, "takeuchi($x, $y, $z) == $z + 1");
1N/A ok($x, "premature FREETMPS (change 5699)"); 1N/A ok($x, "premature FREETMPS (change 5699)"); 1N/A local $^W = 0; # We do not need recursion depth warning. 1N/A# check ok for recursion depth > 65536 1N/A prog => q{$d=0; $e=1; sub c { ++$d; if ($d > 66000) { $e=0 } else { c(); c() unless $d % 32768 } --$d } c(); exit $e}); 1N/A is($r, '', "64K deep recursion - no output expected"); 1N/A ok(1, "$^O: \$? is unreliable"); 1N/A is($?, 0, "64K deep recursion - no coredump expected");