RE: VOS bleadperl test failure on 16539
[p5sagit/p5-mst-13.2.git] / ext / threads / t / list.t
CommitLineData
6794f985 1
2BEGIN {
3 chdir 't' if -d 't';
74bf223e 4 @INC = '../lib';
6794f985 5 require Config; import Config;
6 unless ($Config{'useithreads'}) {
7 print "1..0 # Skip: no useithreads\n";
8 exit 0;
9 }
10}
11
12use ExtUtils::testlib;
13
14use strict;
15
16
17BEGIN { $| = 1; print "1..8\n" };
74bf223e 18use threads;
6794f985 19
20
21
74bf223e 22print "ok 1\n";
6794f985 23
24
74bf223e 25#########################
26sub ok {
27 my ($id, $ok, $name) = @_;
6794f985 28
74bf223e 29 # You have to do it this way or VMS will get confused.
30 print $ok ? "ok $id - $name\n" : "not ok $id - $name\n";
6794f985 31
74bf223e 32 printf "# Failed test at line %d\n", (caller)[2] unless $ok;
6794f985 33
74bf223e 34 return $ok;
35}
6794f985 36
6794f985 37
74bf223e 38ok(2, threads->self == (threads->list)[0]);
6794f985 39
6794f985 40
74bf223e 41threads->create(sub {})->join();
42ok(3, scalar @{[threads->list]} == 1);
43
44my $thread = threads->create(sub {});
45ok(4, scalar @{[threads->list]} == 2);
46$thread->join();
47ok(5, scalar @{[threads->list]} == 1);
48
49$thread = threads->create(sub { ok(6, threads->self == (threads->list)[1])});
50sleep 1;
51ok(7, $thread == (threads->list)[1]);
52$thread->join();
53ok(8, scalar @{[threads->list]} == 1);