6 use Test::More tests => 10;
11 wantarray ? (1, 2) : 1;
14 my $sn = Sub::Nary->new();
16 my $r = { 1 => 0.5, 2 => 0.5 };
18 is_deeply($sn->nary(\&wat), $r, 'first run, without cache');
19 isnt(keys %{$sn->{cache}}, 0, 'cache isn\'t empty');
20 is_deeply($sn->nary(\&wat), $r, 'second run, cached');
21 isnt(keys %{$sn->{cache}}, 0, 'cache isn\'t empty');
23 my $sn2 = $sn->flush();
24 is_deeply( [ defined $sn2, $sn2->isa('Sub::Nary') ], [ 1, 1 ], 'flush ');
25 is(keys %{$sn->{cache}}, 0, 'cache is empty');
27 is_deeply($sn->nary(\&wat), $r, 'third run, without cache');
28 isnt(keys %{$sn->{cache}}, 0, 'cache isn\'t empty');
29 is_deeply($sn->nary(\&wat), $r, 'fourth run, cached');
30 isnt(keys %{$sn->{cache}}, 0, 'cache isn\'t empty');