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;
19 my ($id, $ok, $name) = @_;
20 if (! defined($name)) {
24 # You have to do it this way or VMS will get confused.
26 print("ok $id - $name\n");
28 print("not ok $id - $name\n");
29 printf("# Failed test at line %d\n", (caller)[2]);
37 print("1..101\n"); ### Number of tests that will be run ###
44 ### Start of Testing ###
51 my $foo : shared = "foo";
52 ok($test_count++, $foo eq "foo");
53 threads->create(sub { $foo = "bar" })->join();
54 ok($test_count++, $foo eq "bar");
55 my @foo : shared = ("foo","bar");
56 ok($test_count++, $foo[1] eq "bar");
57 threads->create(sub { ok($test_count++, shift(@foo) eq "foo")})->join();
58 ok($test_count++, $foo[0] eq "bar");
59 my %foo : shared = ( foo => "bar" );
60 ok($test_count++, $foo{foo} eq "bar");
61 threads->create(sub { $foo{bar} = "foo" })->join();
62 ok($test_count++, $foo{bar} eq "foo");
64 threads->create(sub { $foo{array} = \@foo})->join();
65 threads->create(sub { push @{$foo{array}}, "baz"})->join();
66 ok($test_count++, $foo[-1] eq "baz");
69 my $shared :shared = &share({});
70 $$shared{'foo'} = 'bar';
75 ok($test_count++, $str1 eq $str2, 'stringify');
76 $str1 = $$shared{'foo'};
77 $str2 = $$shared{'foo'};
78 ok($test_count++, $str1 eq $str2, 'contents');