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