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