5 if ($ENV{'PERL_CORE'}){
7 unshift @INC, '../lib';
10 unless ($Config{'useithreads'}) {
11 print "1..0 # Skip: no useithreads\n";
16 use ExtUtils::testlib;
20 BEGIN { $| = 1; print "1..15\n" };
28 #########################
30 my ($id, $ok, $name) = @_;
32 # You have to do it this way or VMS will get confused.
33 print $ok ? "ok $id - $name\n" : "not ok $id - $name\n";
35 printf "# Failed test at line %d\n", (caller)[2] unless $ok;
40 ### Start of Testing ###
42 ok(2, scalar @{[threads->list()]} == 0, 'No threads yet');
44 threads->create(sub {})->join();
45 ok(3, scalar @{[threads->list()]} == 0, 'Empty thread list after join');
47 my $thread = threads->create(sub {});
48 ok(4, scalar(threads->list()) == 1, 'Non-empty thread list');
49 ok(5, threads->list() == 1, 'Non-empty thread list');
51 ok(6, scalar @{[threads->list()]} == 0, 'Thread list empty again');
52 ok(7, threads->list() == 0, 'Thread list empty again');
54 $thread = threads->create(sub {
55 ok(8, threads->list() == 1, 'Non-empty thread list in thread');
56 ok(9, threads->self == (threads->list())[0], 'Self in thread list')
59 threads->yield; # help out non-preemptive thread implementations
62 ok(10, scalar(threads->list()) == 1, 'Thread count 1');
63 ok(11, threads->list() == 1, 'Thread count 1');
64 my $cnt = threads->list();
65 ok(12, $cnt == 1, 'Thread count 1');
66 my ($thr_x) = threads->list();
67 ok(13, $thread == $thr_x, 'Thread in list');
69 ok(14, scalar @{[threads->list()]} == 0, 'Thread list empty');
70 ok(15, threads->list() == 0, 'Thread list empty');