6 BEGIN { require indirect; }
9 use VPIT::TestHelpers (
10 threads => [ 'indirect' => indirect::I_THREADSAFE ],
17 qr/^Indirect call of method "new" on object "$pkg" at \(eval \d+\) line \d+/;
24 my $tid = threads->tid();
28 my $class = "Coconut$tid";
31 local $SIG{__WARN__} = sub { push @warns, @_ };
32 eval 'die "the code compiled but it shouldn\'t have\n";
33 no indirect ":fatal"; my $x = new ' . $class . ' 1, 2;';
35 like $@ || '', expect($class),
36 "\"no indirect\" in eval in thread $tid died as expected";
37 is_deeply \@warns, [ ],
38 "\"no indirect\" in eval in thread $tid didn't warn";
43 skip 'Hints aren\'t propagated into eval STRING below perl 5.10' => 3
45 my $class = "Pineapple$tid";
48 local $SIG{__WARN__} = sub { push @warns, @_ };
49 eval 'return; my $y = new ' . $class . ' 1, 2;';
52 "\"no indirect\" propagated into eval in thread $tid didn't croak";
53 my $first = shift @warns;
54 like $first || '', expect($class),
55 "\"no indirect\" propagated into eval in thread $tid warned once";
56 is_deeply \@warns, [ ],
57 "\"no indirect\" propagated into eval in thread $tid warned just once";
63 my @threads = map spawn(\&try), 1 .. 10;
65 $_->join for @threads;
69 done_testing(scalar(@threads) * 2 * (2 + 3) + 1);