6 require Config; import Config;
7 unless ($Config{'useithreads'}) {
8 print "1..0 # Skip: no useithreads\n";
15 my ($id, $ok, $name) = @_;
17 $name = '' unless defined $name;
18 # You have to do it this way or VMS will get confused.
19 print $ok ? "ok $id - $name\n" : "not ok $id - $name\n";
21 printf "# Failed test at line %d\n", (caller)[2] unless $ok;
27 use ExtUtils::testlib;
29 BEGIN { print "1..81\n" };
39 my $foo : shared = "foo";
40 ok($test_count++, $foo eq "foo");
41 threads->create(sub { $foo = "bar" })->join();
42 ok($test_count++, $foo eq "bar");
43 my @foo : shared = ("foo","bar");
44 ok($test_count++, $foo[1] eq "bar");
45 threads->create(sub { ok($test_count++, shift(@foo) eq "foo")})->join();
46 ok($test_count++, $foo[0] eq "bar");
47 my %foo : shared = ( foo => "bar" );
48 ok($test_count++, $foo{foo} eq "bar");
49 threads->create(sub { $foo{bar} = "foo" })->join();
50 ok($test_count++, $foo{bar} eq "foo");
52 threads->create(sub { $foo{array} = \@foo})->join();
53 threads->create(sub { push @{$foo{array}}, "baz"})->join();
54 ok($test_count++, $foo[-1] eq "baz");