X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fop%2Frecurse.t;h=10830e622137e42c025c3d7d0213b7ab54b1af04;hb=1c509eb921569425706e6fe39ea7cb2f11e99d1b;hp=a86744e4aff3115fe3f10b6e8cd463a1229e0422;hpb=4fc932073df150c47d1c1a91564ea6bfacbc9a85;p=p5sagit%2Fp5-mst-13.2.git diff --git a/t/op/recurse.t b/t/op/recurse.t index a86744e..10830e6 100755 --- a/t/op/recurse.t +++ b/t/op/recurse.t @@ -8,7 +8,7 @@ BEGIN { chdir 't' if -d 't'; @INC = qw(. ../lib); require "test.pl"; - plan(tests => 26); + plan(tests => 28); } use strict; @@ -49,24 +49,24 @@ sub takeuchi { : $_[2]; } -is(gcd(1147, 1271), 31, "gcd(1147, 1271)"); +is(gcd(1147, 1271), 31, "gcd(1147, 1271) == 31"); -is(gcd(1908, 2016), 36, "gcd(1908, 2016)"); +is(gcd(1908, 2016), 36, "gcd(1908, 2016) == 36"); -is(factorial(10), 3628800, "factorial(10)"); +is(factorial(10), 3628800, "factorial(10) == 3628800"); -is(factorial(factorial(3)), 720, "factorial(factorial(3))"); +is(factorial(factorial(3)), 720, "factorial(factorial(3)) == 720"); -is(fibonacci(10), 89, "fibonacci(10)"); +is(fibonacci(10), 89, "fibonacci(10) == 89"); -is(fibonacci(fibonacci(7)), 17711, "fibonacci(fibonacci(7))"); +is(fibonacci(fibonacci(7)), 17711, "fibonacci(fibonacci(7)) == 17711"); my @ack = qw(1 2 3 4 2 3 4 5 3 5 7 9 5 13 29 61); for my $x (0..3) { for my $y (0..3) { my $a = ackermann($x, $y); - is($a, shift(@ack), "ackermann($x, y)"); + is($a, shift(@ack), "ackermann($x, $y) == $a"); } } @@ -112,6 +112,26 @@ is(takeuchi($x, $y, $z), $z + 1, "takeuchi($x, $y, $z) == $z + 1"); is(sillysum(1000), 1000*1001/2, "recursive sum of 1..1000"); } - - +# 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: { + skip("Out of memory -- increase your data/heap?", 2) + if $r =~ /Out of memory/i; + is($r, '', "64K deep recursion - no output expected"); + + if ($^O eq 'MacOS') { + ok(1, "$^O: \$? is unreliable"); + } else { + is($?, 0, "64K deep recursion - no coredump expected"); + } + + } +}