1use strict; use warnings; 2use Memoize qw(flush_cache memoize); 3use Test::More tests => 9; 4 5my $V = 100; 6sub VAL { $V } 7 8ok eval { memoize('VAL'); 1 }, 'memozing the test function'; 9 10is VAL(), 100, '... with the expected return value'; 11$V = 200; 12is VAL(), 100, '... which is expectedly sticky'; 13 14ok eval { flush_cache('VAL'); 1 }, 'flusing the cache by name works'; 15 16is VAL(), 200, '... with the expected new return value'; 17$V = 300; 18is VAL(), 200, '... which is expectedly sticky'; 19 20ok eval { flush_cache(\&VAL); 1 }, 'flusing the cache by name works'; 21 22is VAL(), 300, '... with the expected new return value'; 23$V = 400; 24is VAL(), 300, '... which is expectedly sticky'; 25