1#!/usr/bin/perl 2 3use lib '..'; 4use Memoize 'flush_cache', 'memoize'; 5print "1..8\n"; 6print "ok 1\n"; 7 8 9 10my $V = 100; 11sub VAL { $V } 12 13memoize 'VAL'; 14print "ok 2\n"; 15 16my $c1 = VAL(); 17print (($c1 == 100) ? "ok 3\n" : "not ok 3\n"); 18 19$V = 200; 20$c1 = VAL(); 21print (($c1 == 100) ? "ok 4\n" : "not ok 4\n"); 22 23flush_cache('VAL'); 24$c1 = VAL(); 25print (($c1 == 200) ? "ok 5\n" : "not ok 5\n"); 26 27$V = 300; 28$c1 = VAL(); 29print (($c1 == 200) ? "ok 6\n" : "not ok 6\n"); 30 31flush_cache(\&VAL); 32$c1 = VAL(); 33print (($c1 == 300) ? "ok 7\n" : "not ok 7\n"); 34 35$V = 400; 36$c1 = VAL(); 37print (($c1 == 300) ? "ok 8\n" : "not ok 8\n"); 38 39 40 41 42 43