5 require Config; import Config;
6 unless ($Config{'useithreads'}) {
7 print "1..0 # Skip: no useithreads\n";
12 use ExtUtils::testlib;
14 BEGIN { print "1..10\n" };
20 use Devel::Peek qw(Dump);
25 # You have to do it this way or VMS will get confused.
26 print $ok ? "ok $test_id - $name\n" : "not ok $test_id - $name\n";
28 printf "# Failed test at line %d\n", (caller)[2] unless $ok;
37 my $retval = threads->create(sub { return ("hi") })->join();
38 ok($retval eq 'hi', "Check basic returnvalue");
41 my ($thread) = threads->create(sub { return (1,2,3) });
42 my @retval = $thread->join();
43 ok($retval[0] == 1 && $retval[1] == 2 && $retval[2] == 3);
46 my $retval = threads->create(sub { return [1] })->join();
47 ok($retval->[0] == 1,"Check that a array ref works");
50 my $retval = threads->create(sub { return { foo => "bar" }})->join();
51 ok($retval->{foo} eq 'bar',"Check that hash refs work");
54 my $retval = threads->create( sub {
55 open(my $fh, "+>threadtest") || die $!;
59 ok(ref($retval) eq 'GLOB', "Check that we can return FH $retval");
60 print $retval "test2\n";
62 # ok(<$retval> eq "test\n");
68 my $retval = threads->create(sub { return $_[0]}, \$test)->join();
74 my $retval = threads->create(sub { return $_[0]}, \$test)->join();
77 ok($$retval eq 'foo');
86 return $foo{bar} = \$foo;