fix for ext/threads/t/problems.t failures
[p5sagit/p5-mst-13.2.git] / ext / threads / t / end.t
CommitLineData
4e00007d 1
c3939953 2# test that END blocks are run in the thread that created them and
3# not in any child threads
4
4e00007d 5BEGIN {
6 chdir 't' if -d 't';
974ec8aa 7 push @INC, '../lib';
4e00007d 8 require Config; import Config;
9 unless ($Config{'useithreads'}) {
10 print "1..0 # Skip: no useithreads\n";
11 exit 0;
12 }
13}
14
15use ExtUtils::testlib;
16use strict;
17BEGIN { print "1..6\n" };
18use threads;
19use threads::shared;
20
21my $test_id = 1;
22share($test_id);
23use Devel::Peek qw(Dump);
24
25sub ok {
26 my ($ok, $name) = @_;
27
28 # You have to do it this way or VMS will get confused.
29 print $ok ? "ok $test_id - $name\n" : "not ok $test_id - $name\n";
30
31 printf "# Failed test at line %d\n", (caller)[2] unless $ok;
32 $test_id++;
33 return $ok;
34}
a31a65c0 35ok(1,'');
4e00007d 36END { ok(1,"End block run once") }
37threads->create(sub { eval "END { ok(1,'') }"})->join();
38threads->create(sub { eval "END { ok(1,'') }"})->join();
39threads->create(\&thread)->join();
40
41sub thread {
42 eval "END { ok(1,'') }";
43 threads->create(sub { eval "END { ok(1,'') }"})->join();
44}