summaryrefslogtreecommitdiff
path: root/gnu/usr.bin/perl/cpan/Memoize/t/flush.t
blob: 33eceac887994bef5000898f35727a40d3cf8bbb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use strict; use warnings;
use Memoize qw(flush_cache memoize);
use Test::More tests => 9;

my $V = 100;
sub VAL { $V }

ok eval { memoize('VAL'); 1 }, 'memozing the test function';

is VAL(), 100, '... with the expected return value';
$V = 200;
is VAL(), 100, '... which is expectedly sticky';

ok eval { flush_cache('VAL'); 1 }, 'flusing the cache by name works';

is VAL(), 200, '... with the expected new return value';
$V = 300;
is VAL(), 200, '... which is expectedly sticky';

ok eval { flush_cache(\&VAL); 1 }, 'flusing the cache by name works';

is VAL(), 300, '... with the expected new return value';
$V = 400;
is VAL(), 300, '... which is expectedly sticky';