Commit | Line | Data |
7473853a |
1 | use strict; |
2 | use warnings; |
0a9af0ff |
3 | |
4 | BEGIN { |
7473853a |
5 | if ($ENV{'PERL_CORE'}){ |
6 | chdir 't'; |
7 | unshift @INC, '../lib'; |
8 | } |
0a9af0ff |
9 | } |
10 | |
0a9af0ff |
11 | use Test; |
12 | plan tests => 31; |
13 | |
14 | use threads::shared; |
15 | |
7473853a |
16 | ### Start of Testing ### |
17 | |
18 | # Make sure threads are really off |
0a9af0ff |
19 | ok( !$INC{"threads.pm"} ); |
20 | |
21 | # Check each faked function. |
22 | foreach my $func (qw(share cond_wait cond_signal cond_broadcast)) { |
23 | ok( my $func_ref = __PACKAGE__->can($func) ? 1 : 0 ); |
24 | |
25 | eval qq{$func()}; |
26 | ok( $@, qr/^Not enough arguments / ); |
27 | |
28 | my %hash = (foo => 42, bar => 23); |
29 | eval qq{$func(\%hash)}; |
30 | ok( $@, '' ); |
31 | ok( $hash{foo}, 42 ); |
32 | ok( $hash{bar}, 23 ); |
33 | } |
34 | |
35 | # These all have no return value. |
36 | foreach my $func (qw(cond_wait cond_signal cond_broadcast)) { |
37 | my @array = qw(1 2 3 4); |
38 | ok( eval qq{$func(\@array)}, undef ); |
39 | ok( "@array", "1 2 3 4" ); |
40 | } |
41 | |
42 | # share() is supposed to return back it's argument as a ref. |
43 | { |
44 | my @array = qw(1 2 3 4); |
45 | ok( share(@array), \@array ); |
46 | ok( ref &share({}), 'HASH' ); |
47 | ok( "@array", "1 2 3 4" ); |
48 | } |
49 | |
50 | # lock() should be a no-op. The return value is currently undefined. |
51 | { |
52 | my @array = qw(1 2 3 4); |
53 | lock(@array); |
54 | ok( "@array", "1 2 3 4" ); |
55 | } |
7473853a |
56 | |
6c791b15 |
57 | exit(0); |
58 | |
7473853a |
59 | # EOF |