9 use Test::More tests => 1 + $tests + 1 + 2 + 2;
13 my %wrong = map { $_ => 1 } 2, 3, 5, 7, 9, 10, 14, 15, 17, 18;
17 return qr/^warn:Indirect\s+call\s+of\s+method\s+"new"\s+on\s+object\s+"$pkg"\s+at\s+\(eval\s+\d+\)\s+line\s+\d+/;
21 my $code = do { local $/; <DATA> };
22 my (%res, $num, @left);
24 local $SIG{__WARN__} = sub {
26 my $w = join '', 'warn:', @_;
27 if ($w =~ /"P(\d+)"/ and not exists $res{$1}) {
30 push @left, "[$num] $w";
33 eval "die qq{ok\\n}; $code";
34 is($@, "ok\n", 'DATA compiled fine');
39 like($w, expect("P$_"), "$_ should warn");
41 is($w, undef, "$_ shouldn't warn");
44 is(@left, 0, 'nothing left');
45 diag "Extraneous warnings:\n", @left if @left;
50 local $SIG{__WARN__} = sub {
51 $w = 'more than 2 warnings' if $w;
52 $w = join '', 'warn:', @_
55 eval 'no indirect; my $x = new Foo';
56 like($w, expect('Foo'), "eval 'no indirect; my \$x = new Foo'");
62 eval 'my $x = new Bar';
65 is($w, '', "eval 'no indirect; my \$x = new Bar'");
67 like($w, expect('Bar'), "no indirect; eval 'my \$x = new Bar'");
75 local $SIG{__WARN__} = sub { push @w, join '', @_ };
76 eval 'no indirect; use indirect::TestRequired';
78 is $@, '', 'require test didn\'t croak';
79 is_deeply \@w, [ ], 'pragma didn\'t propagate into the required file';
110 eval { my $i = new P9 };
113 eval { no indirect; my $j = new P10 };
117 new P11 do { use indirect; new P12 };
122 new P13 do { no indirect; new P14 };
127 new P15 do { use indirect; new P16 };
132 new P17 do { no indirect; new P18 };