9 use Test::More tests => 1 + $tests + 1 + 2;
11 my %wrong = map { $_ => 1 } 2, 3, 5, 7, 9, 10;
15 return qr/^warn:Indirect\s+call\s+of\s+method\s+"new"\s+on\s+object\s+"$pkg"/;
19 my $code = do { local $/; <DATA> };
22 local $SIG{__WARN__} = sub {
23 my $w = join '', 'warn:', @_;
24 if ($w =~ /"P(\d+)"/ and not exists $res{$1}) {
30 eval "die qq{ok\\n}; $code";
31 is($@, "ok\n", 'DATA compiled fine');
36 like($w, expect("P$_"), "$_ should warn");
38 is($w, undef, "$_ shouldn't warn");
41 is(@left, 0, 'nothing left');
42 diag "Extraneous warnings:\n", @left if @left;
47 local $SIG{__WARN__} = sub {
48 $w = 'more than 2 warnings' if $w;
49 $w = join '', 'warn:', @_
52 eval 'no indirect; my $x = new Foo';
53 like($w, expect('Foo'), "eval 'no indirect; my \$x = new Foo'");
59 eval 'my $x = new Bar';
62 is($w, '', "eval 'no indirect; my \$x = new Bar'");
64 like($w, expect('Bar'), "no indirect; eval 'my \$x = new Bar'");
97 eval { my $i = new P9 };
100 eval { no indirect; my $j = new P10 };