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 return qr/^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+/;
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 'die "ok\n"; my $y = new ' . $class . ' 1, 2;';
67 my $first = shift @warns;
68 like $first || '', expect($class),
69 "\"no indirect\" propagated into eval in thread $tid warned once";
70 is_deeply \@warns, [ ],
71 "\"no indirect\" propagated into eval in thread $tid warned just once";
77 my @t = map threads->create(\&try), 1 .. 10;