threads::shared 1.22
[p5sagit/p5-mst-13.2.git] / ext / threads / shared / t / disabled.t
1 use strict;
2 use warnings;
3
4 BEGIN {
5     if ($ENV{'PERL_CORE'}){
6         chdir 't';
7         unshift @INC, '../lib';
8     }
9 }
10
11 use Test;
12 plan tests => 31;
13
14 use threads::shared;
15
16 ### Start of Testing ###
17
18 # Make sure threads are really off
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 }
56
57 exit(0);
58
59 # EOF