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