6 use Config qw/%Config/;
9 if (!$Config{useithreads}) {
12 plan(skip_all => 'This perl wasn\'t built to support threads');
21 delete $ENV{PERL_INDIRECT_PM_DISABLE};
23 if (indirect::I_THREADSAFE()) {
24 plan tests => 10 * 2 * (2 + 3);
25 defined and diag "Using threads $_" for $threads::VERSION;
27 plan skip_all => 'This indirect isn\'t thread safe';
33 qr/^Indirect call of method "new" on object "$pkg" at \(eval \d+\) line \d+/;
40 my $tid = threads->tid();
44 my $class = "Coconut$tid";
47 local $SIG{__WARN__} = sub { push @warns, @_ };
48 eval 'die "the code compiled but it shouldn\'t have\n";
49 no indirect ":fatal"; my $x = new ' . $class . ' 1, 2;';
51 like $@ || '', expect($class),
52 "\"no indirect\" in eval in thread $tid died as expected";
53 is_deeply \@warns, [ ],
54 "\"no indirect\" in eval in thread $tid didn't warn";
59 skip 'Hints aren\'t propagated into eval STRING below perl 5.10' => 3
61 my $class = "Pineapple$tid";
64 local $SIG{__WARN__} = sub { push @warns, @_ };
65 eval 'return; my $y = new ' . $class . ' 1, 2;';
68 "\"no indirect\" propagated into eval in thread $tid didn't croak";
69 my $first = shift @warns;
70 like $first || '', expect($class),
71 "\"no indirect\" propagated into eval in thread $tid warned once";
72 is_deeply \@warns, [ ],
73 "\"no indirect\" propagated into eval in thread $tid warned just once";
79 my @t = map threads->create(\&try), 1 .. 10;