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) = @_;
21 # You have to do it this way or VMS will get confused.
23 print("ok $id - $name\n");
25 print("not ok $id - $name\n");
26 printf("# Failed test at line %d\n", (caller)[2]);
34 print("1..14\n"); ### Number of tests that will be run ###
41 ### Start of Testing ###
51 ok(2, $av[0] eq "hi", 'Array holds value');
54 ok(3, $av[1] eq 'foo', 'Array holds 2nd value');
56 my $av = threads->create(sub {
62 push(@$av, "bar", \@av);
66 ok(4,$av->[0] eq "bar", 'Thread added to array');
67 ok(5,$av->[1]->[0] eq 'hi', 'Shared in shared');
69 threads->create(sub { $av[0] = "hihi" })->join();
70 ok(6,$av->[1]->[0] eq 'hihi', 'Replaced shared in shared');
71 ok(7, pop(@{$av->[1]}) eq "foo", 'Pop shared array');
72 ok(8, scalar(@{$av->[1]}) == 1, 'Array size');
74 threads->create(sub { @$av = () })->join();
75 threads->create(sub { ok(9, scalar @$av == 0, 'Array cleared in thread'); })->join();
78 unshift(@$av, threads->create(sub {
85 ok(10, ref($av->[0]) eq 'ARRAY', 'Array in array');
87 threads->create(sub { push @{$av->[0]}, \@av })->join();
88 threads->create(sub { $av[0] = 'testtest'})->join();
89 threads->create(sub { ok(11, $av->[0]->[0]->[0] eq 'testtest', 'Nested'); })->join();
91 ok(12, is_shared($sv), "Check for sharing");
92 ok(13, is_shared(@av), "Check for sharing");
95 ok(14, is_shared($x), "Check for sharing");