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 ###
45 # You have to do it this way or VMS will get confused.
47 print("ok $id - $name\n");
49 print("not ok $id - $name\n");
50 printf("# Failed test at line %d\n", (caller)[2]);
57 ### Start of Testing ###
62 my $wantarray = wantarray();
65 ok($context eq 'array', 'Array context');
67 } elsif (defined($wantarray)) {
68 ok($context eq 'scalar', 'Scalar context');
71 ok($context eq 'void', 'Void context');
76 my ($thr) = threads->create('foo', 'array');
77 my ($res) = $thr->join();
78 ok($res eq 'array', 'Implicit array context');
80 $thr = threads->create('foo', 'scalar');
82 ok($res eq 'scalar', 'Implicit scalar context');
84 threads->create('foo', 'void');
85 ($thr) = threads->list();
87 ok(! defined($res), 'Implicit void context');
89 $thr = threads->create({'context' => 'array'}, 'foo', 'array');
90 ($res) = $thr->join();
91 ok($res eq 'array', 'Explicit array context');
93 ($thr) = threads->create({'scalar' => 'scalar'}, 'foo', 'scalar');
95 ok($res eq 'scalar', 'Explicit scalar context');
97 $thr = threads->create({'void' => 1}, 'foo', 'void');
99 ok(! defined($res), 'Explicit void context');