6 if (! $Config{'useithreads'}) {
7 print("1..0 # SKIP Perl not compiled with 'useithreads'\n");
12 use ExtUtils::testlib;
15 my ($id, $ok, $name) = @_;
17 # You have to do it this way or VMS will get confused.
19 print("ok $id - $name\n");
21 print("not ok $id - $name\n");
22 printf("# Failed test at line %d\n", (caller)[2]);
30 print("1..11\n"); ### Number of tests that will be run ###
37 ### Start of Testing ###
41 ok(2,$test eq "bar","Test magic share fetch");
43 ok(3,$test eq "foo","Test magic share assign");
44 my $c = threads::shared::_refcnt($test);
47 ok(4, $test eq "foo","Test magic share fetch after thread");
49 ok(5,threads::shared::_refcnt($test) > $c, "Check that threadcount is correct");
51 ok(6,$test eq "baz","Test that value has changed in another thread");
52 ok(7,threads::shared::_refcnt($test) == $c,"Check thrcnt is down properly");
54 ok(8, length($test) == 6, "Check length code");
55 threads->create(sub { $test = "barbarbar" })->join;
56 ok(9, length($test) == 9, "Check length code after different thread modified it");
57 threads->create(sub { undef($test)})->join();
58 ok(10, !defined($test), "Check undef value");
60 ok(11, is_shared($test), "Check for sharing");