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