recurse.t revision 7c478bd95313f5f23a4c958a745db2134aa03244
#!./perl
#
# test recursive functions.
#
BEGIN {
chdir 't' if -d 't';
}
use strict;
sub gcd {
$_[0];
}
sub factorial {
}
sub fibonacci {
}
# Highly recursive, highly aggressive.
# Kids, don't try this at home.
#
# 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);
}
# Highly recursive, highly boring.
sub takeuchi {
$_[1] < $_[0] ?
: $_[2];
}
for my $x (0..3) {
for my $y (0..3) {
}
}
my ($x, $y, $z) = (18, 12, 6);
{
sub get_first1 {
}
sub get_list1 {
[$u];
}
}
{
sub get_first2 {
}
sub get_list2 {
return [$u];
}
}
{
local $^W = 0; # We do not need recursion depth warning.
sub sillysum {
}
}
# check ok for recursion depth > 65536
{
my $r;
eval {
$r = runperl(
nolib => 1,
stderr => 1,
prog => q{$d=0; $e=1; sub c { ++$d; if ($d > 66000) { $e=0 } else { c(); c() unless $d % 32768 } --$d } c(); exit $e});
};
SKIP: {
} else {
}
}
}