Commit | Line | Data |
899dc88a |
1 | #!/usr/bin/perl |
2 | |
5317c87c |
3 | BEGIN { |
4 | chdir 't' if -d 't'; |
5 | @INC = '../lib'; |
6 | } |
899dc88a |
7 | use Memoize 'memoize', 'unmemoize'; |
8 | |
9 | sub reff { |
10 | return [1,2,3]; |
11 | |
12 | } |
13 | |
14 | sub listf { |
15 | return (1,2,3); |
16 | } |
17 | |
18 | print "1..6\n"; |
19 | |
20 | memoize 'reff', LIST_CACHE => 'MERGE'; |
21 | print "ok 1\n"; |
22 | memoize 'listf'; |
23 | print "ok 2\n"; |
24 | |
25 | $s = reff(); |
26 | @a = reff(); |
27 | print @a == 1 ? "ok 3\n" : "not ok 3\n"; |
28 | |
29 | $s = listf(); |
30 | @a = listf(); |
31 | print @a == 3 ? "ok 4\n" : "not ok 4\n"; |
32 | |
33 | unmemoize 'reff'; |
34 | memoize 'reff', LIST_CACHE => 'MERGE'; |
35 | unmemoize 'listf'; |
36 | memoize 'listf'; |
37 | |
38 | @a = reff(); |
39 | $s = reff(); |
40 | print @a == 1 ? "ok 5\n" : "not ok 5\n"; |
41 | |
42 | @a = listf(); |
43 | $s = listf(); |
44 | print @a == 3 ? "ok 6\n" : "not ok 6\n"; |
45 | |
46 | |