Commit | Line | Data |
---|---|---|
13c1b207 DM |
1 | use warnings; |
2 | ||
dab065ea AB |
3 | BEGIN { |
4 | # chdir 't' if -d 't'; | |
5 | # push @INC ,'../lib'; | |
6 | require Config; import Config; | |
7 | unless ($Config{'useithreads'}) { | |
8 | print "1..0 # Skip: no useithreads\n"; | |
9 | exit 0; | |
10 | } | |
11 | $SIG{__WARN__} = sub { $warnmsg = shift; }; | |
12 | } | |
13 | ||
14 | ||
15 | sub ok { | |
16 | my ($id, $ok, $name) = @_; | |
17 | ||
13c1b207 | 18 | $name = '' unless defined $name; |
dab065ea AB |
19 | # You have to do it this way or VMS will get confused. |
20 | print $ok ? "ok $id - $name\n" : "not ok $id - $name\n"; | |
21 | ||
22 | printf "# Failed test at line %d\n", (caller)[2] unless $ok; | |
23 | ||
24 | return $ok; | |
25 | } | |
26 | ||
27 | our $warnmsg; | |
28 | use ExtUtils::testlib; | |
29 | use strict; | |
30 | BEGIN { print "1..5\n" }; | |
31 | use threads::shared; | |
32 | use threads; | |
33 | ok(1,1,"loaded"); | |
34 | ok(2,$warnmsg =~ /Warning, threads::shared has already been loaded/, | |
9c4972d9 | 35 | "threads has warned us"); |
dab065ea AB |
36 | my $test = "bar"; |
37 | share($test); | |
38 | ok(3,$test eq "bar","Test disabled share not interfering"); | |
39 | threads->create( | |
40 | sub { | |
41 | ok(4,$test eq "bar","Test disabled share after thread"); | |
42 | $test = "baz"; | |
43 | })->join(); | |
9c4972d9 NIS |
44 | # Value should either remain unchanged or be value set by other thread |
45 | ok(5,$test eq "bar" || $test eq 'baz',"Test that value is an expected one"); | |
46 | ||
dab065ea | 47 |