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