This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
warning in sv.c: double format, NV arg
[perl5.git] / lib / Memoize / t / errors.t
CommitLineData
a0cb3900
JH
1#!/usr/bin/perl
2
3use lib '..';
4use Memoize;
5use Config;
6
7print "1..11\n";
8
9eval { memoize({}) };
10print $@ ? "ok 1\n" : "not ok 1 # $@\n";
11
12eval { memoize([]) };
13print $@ ? "ok 2\n" : "not ok 2 # $@\n";
14
15eval { my $x; memoize(\$x) };
16print $@ ? "ok 3\n" : "not ok 3 # $@\n";
17
18# 4--8
19$n = 4;
899dc88a
JH
20my $dummyfile = './dummydb';
21use Fcntl;
22my %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 28for $mod (qw(DB_File GDBM_File SDBM_File ODBM_File NDBM_File)) {
899dc88a
JH
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
JH
37 $n++;
38}
39
40# 9
899dc88a
JH
41eval { local $^W = 0;
42 memoize(sub {}, LIST_CACHE => ['TIE', 'WuggaWugga'])
43 };
a0cb3900
JH
44print $@ ? "ok 9\n" : "not ok 9 # $@\n";
45
46# 10
47eval { memoize(sub {}, LIST_CACHE => 'YOB GORGLE') };
48print $@ ? "ok 10\n" : "not ok 10 # $@\n";
49
50# 11
51eval { memoize(sub {}, SCALAR_CACHE => ['YOB GORGLE']) };
52print $@ ? "ok 11\n" : "not ok 11 # $@\n";
53