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