xref: /onnv-gate/usr/src/cmd/perl/5.8.4/distrib/lib/Memoize/t/flush.t (revision 0:68f95e015346)
1*0Sstevel@tonic-gate#!/usr/bin/perl
2*0Sstevel@tonic-gate
3*0Sstevel@tonic-gateuse lib '..';
4*0Sstevel@tonic-gateuse Memoize 'flush_cache', 'memoize';
5*0Sstevel@tonic-gateprint "1..8\n";
6*0Sstevel@tonic-gateprint "ok 1\n";
7*0Sstevel@tonic-gate
8*0Sstevel@tonic-gate
9*0Sstevel@tonic-gate
10*0Sstevel@tonic-gatemy $V = 100;
11*0Sstevel@tonic-gatesub VAL { $V }
12*0Sstevel@tonic-gate
13*0Sstevel@tonic-gatememoize 'VAL';
14*0Sstevel@tonic-gateprint "ok 2\n";
15*0Sstevel@tonic-gate
16*0Sstevel@tonic-gatemy $c1 = VAL();
17*0Sstevel@tonic-gateprint (($c1 == 100) ? "ok 3\n" : "not ok 3\n");
18*0Sstevel@tonic-gate
19*0Sstevel@tonic-gate$V = 200;
20*0Sstevel@tonic-gate$c1 = VAL();
21*0Sstevel@tonic-gateprint (($c1 == 100) ? "ok 4\n" : "not ok 4\n");
22*0Sstevel@tonic-gate
23*0Sstevel@tonic-gateflush_cache('VAL');
24*0Sstevel@tonic-gate$c1 = VAL();
25*0Sstevel@tonic-gateprint (($c1 == 200) ? "ok 5\n" : "not ok 5\n");
26*0Sstevel@tonic-gate
27*0Sstevel@tonic-gate$V = 300;
28*0Sstevel@tonic-gate$c1 = VAL();
29*0Sstevel@tonic-gateprint (($c1 == 200) ? "ok 6\n" : "not ok 6\n");
30*0Sstevel@tonic-gate
31*0Sstevel@tonic-gateflush_cache(\&VAL);
32*0Sstevel@tonic-gate$c1 = VAL();
33*0Sstevel@tonic-gateprint (($c1 == 300) ? "ok 7\n" : "not ok 7\n");
34*0Sstevel@tonic-gate
35*0Sstevel@tonic-gate$V = 400;
36*0Sstevel@tonic-gate$c1 = VAL();
37*0Sstevel@tonic-gateprint (($c1 == 300) ? "ok 8\n" : "not ok 8\n");
38*0Sstevel@tonic-gate
39*0Sstevel@tonic-gate
40*0Sstevel@tonic-gate
41*0Sstevel@tonic-gate
42*0Sstevel@tonic-gate
43