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> };
20 my (%res, $num, @left);
22 local $SIG{__WARN__} = sub {
24 my $w = join '', 'warn:', @_;
25 if ($w =~ /"P(\d+)"/ and not exists $res{$1}) {
28 push @left, "[$num] $w";
31 eval "die qq{ok\\n}; $code";
32 is($@, "ok\n", 'DATA compiled fine');
37 like($w, expect("P$_"), "$_ should warn");
39 is($w, undef, "$_ shouldn't warn");
42 is(@left, 0, 'nothing left');
43 diag "Extraneous warnings:\n", @left if @left;
48 local $SIG{__WARN__} = sub {
49 $w = 'more than 2 warnings' if $w;
50 $w = join '', 'warn:', @_
53 eval 'no indirect; my $x = new Foo';
54 like($w, expect('Foo'), "eval 'no indirect; my \$x = new Foo'");
60 eval 'my $x = new Bar';
63 is($w, '', "eval 'no indirect; my \$x = new Bar'");
65 like($w, expect('Bar'), "no indirect; eval 'my \$x = new Bar'");
98 eval { my $i = new P9 };
101 eval { no indirect; my $j = new P10 };