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