Commit | Line | Data |
a0cb3900 |
1 | #!/usr/bin/perl |
2 | |
3 | use lib '..'; |
4 | use Memoize; |
5 | use Config; |
6 | |
7 | print "1..11\n"; |
8 | |
9 | eval { memoize({}) }; |
10 | print $@ ? "ok 1\n" : "not ok 1 # $@\n"; |
11 | |
12 | eval { memoize([]) }; |
13 | print $@ ? "ok 2\n" : "not ok 2 # $@\n"; |
14 | |
15 | eval { my $x; memoize(\$x) }; |
16 | print $@ ? "ok 3\n" : "not ok 3 # $@\n"; |
17 | |
18 | # 4--8 |
19 | $n = 4; |
899dc88a |
20 | my $dummyfile = './dummydb'; |
21 | use Fcntl; |
22 | my %args = ( DB_File => [], |
23 | GDBM_File => [$dummyfile, 2, 0666], |
24 | ODBM_File => [$dummyfile, O_RDWR|O_CREAT, 0666], |
25 | NDBM_File => [$dummyfile, O_RDWR|O_CREAT, 0666], |
26 | SDBM_File => [$dummyfile, O_RDWR|O_CREAT, 0666], |
27 | ); |
a0cb3900 |
28 | for $mod (qw(DB_File GDBM_File SDBM_File ODBM_File NDBM_File)) { |
899dc88a |
29 | eval { |
30 | require "$mod.pm"; |
31 | tie my %cache => $mod, @{$args{$mod}}; |
32 | memoize(sub {}, LIST_CACHE => [HASH => \%cache ]); |
33 | }; |
34 | print $@ =~ /can only store scalars/ |
35 | || $@ =~ /Can't locate.*in \@INC/ ? "ok $n\n" : "not ok $n # $@\n"; |
36 | 1 while unlink $dummyfile; |
a0cb3900 |
37 | $n++; |
38 | } |
39 | |
40 | # 9 |
899dc88a |
41 | eval { local $^W = 0; |
42 | memoize(sub {}, LIST_CACHE => ['TIE', 'WuggaWugga']) |
43 | }; |
a0cb3900 |
44 | print $@ ? "ok 9\n" : "not ok 9 # $@\n"; |
45 | |
46 | # 10 |
47 | eval { memoize(sub {}, LIST_CACHE => 'YOB GORGLE') }; |
48 | print $@ ? "ok 10\n" : "not ok 10 # $@\n"; |
49 | |
50 | # 11 |
51 | eval { memoize(sub {}, SCALAR_CACHE => ['YOB GORGLE']) }; |
52 | print $@ ? "ok 11\n" : "not ok 11 # $@\n"; |
53 | |