Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add tests for "is_cached"
  • Loading branch information
lizmat committed Apr 13, 2014
1 parent 2cde4fb commit 840d421
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions S02-names/is_cached.t
@@ -0,0 +1,22 @@
use v6;
use Test;

plan 6;

#?pugs skip "is cached NYI"
#?niecza skip "is cached NYI"
{
my @seen;
sub fib(Int $x) is cached {
@seen.push: $x;
$x <= 1 ?? 1 !! fib($x - 1) + fib($x - 2);
}
is fib(9), 55, 'does fib(9) work';
is @seen, (9,8,7,6,5,4,3,2,1,0), 'did we call them all (1)';
is fib(10), 89, 'does fib(10) work';
is @seen, (9,8,7,6,5,4,3,2,1,0,10), 'did we call them all (2)';
is fib(10), 89, 'does fib(10) work';
is @seen, (9,8,7,6,5,4,3,2,1,0,10), 'did we call them all (3)';
} #6

# vim: ft=perl6

0 comments on commit 840d421

Please sign in to comment.