5 if ($ENV{'PERL_CORE'}){
7 unshift @INC, '../lib';
10 if (! $Config{'useithreads'}) {
11 print("1..0 # Skip: Perl not compiled with 'useithreads'\n");
16 use ExtUtils::testlib;
24 print("1..5\n"); ### Number of tests that will be run ###
38 # You have to do it this way or VMS will get confused.
40 print("ok $id - $name\n");
42 print("not ok $id - $name\n");
43 printf("# Failed test at line %d\n", (caller)[2]);
50 ### Start of Testing ###
52 $SIG{'__WARN__'} = sub { ok(0, "Warning: $_[0]"); };
59 $SIG{'__WARN__'} = sub { ok(0, "BEGIN: $_[0]"); };
61 threads->create('foo')->join();
62 threads->create(\&foo)->join();
63 threads->create(sub {})->join();
65 threads->create('foo')->detach();
66 threads->create(\&foo)->detach();
67 threads->create(sub {})->detach();
69 $bthr = threads->create('baz');
74 threads->create('foo')->join();
75 threads->create(\&foo)->join();
76 threads->create(sub {})->join();
78 threads->create('foo')->detach();
79 threads->create(\&foo)->detach();
80 threads->create(sub {})->detach();
82 $mthr = threads->create('baz');
85 ok($mthr, 'Main thread');
86 ok($bthr, 'BEGIN thread');
88 ok($mthr->join() == 42, 'Main join');
89 ok($bthr->join() == 42, 'BEGIN join');