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