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;
22 require threads::shared;
23 import threads::shared;
25 if ($@ || ! $threads::shared::threads_shared) {
26 print("1..0 # Skip: threads::shared not available\n");
31 print("1..13\n"); ### Number of tests that will be run ###
48 # You have to do it this way or VMS will get confused.
50 print("ok $id - $name\n");
52 print("not ok $id - $name\n");
53 printf("# Failed test at line %d\n", (caller)[2]);
60 ### Start of Testing ###
65 my $wantarray = wantarray();
68 ok($context eq 'array', 'Array context');
70 } elsif (defined($wantarray)) {
71 ok($context eq 'scalar', 'Scalar context');
74 ok($context eq 'void', 'Void context');
79 my ($thr) = threads->create('foo', 'array');
80 my ($res) = $thr->join();
81 ok($res eq 'array', 'Implicit array context');
83 $thr = threads->create('foo', 'scalar');
85 ok($res eq 'scalar', 'Implicit scalar context');
87 threads->create('foo', 'void');
88 ($thr) = threads->list();
90 ok(! defined($res), 'Implicit void context');
92 $thr = threads->create({'context' => 'array'}, 'foo', 'array');
93 ($res) = $thr->join();
94 ok($res eq 'array', 'Explicit array context');
96 ($thr) = threads->create({'scalar' => 'scalar'}, 'foo', 'scalar');
98 ok($res eq 'scalar', 'Explicit scalar context');
100 $thr = threads->create({'void' => 1}, 'foo', 'void');
102 ok(! defined($res), 'Explicit void context');