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'");
73 local $TODO = 'Need a workaround for this' if $] < 5.010001;
76 local $SIG{__WARN__} = sub { push @w, join '', @_ };
77 eval 'no indirect; use indirect::TestRequired';
79 is $@, '', 'require test didn\'t croak';
80 is_deeply \@w, [ ], 'pragma didn\'t propagate into the required file';
111 eval { my $i = new P9 };
114 eval { no indirect; my $j = new P10 };
118 new P11 do { use indirect; new P12 };
123 new P13 do { no indirect; new P14 };
128 new P15 do { use indirect; new P16 };
133 new P17 do { no indirect; new P18 };