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