Upgrade to threads-shared-1.03
[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     use Config;
10     if (! $Config{'useithreads'}) {
11         print("1..0 # Skip: Perl not compiled with 'useithreads'\n");
12         exit(0);
13     }
14 }
15
16 use Test;
17 plan tests => 31;
18
19 use threads::shared;
20
21 ### Start of Testing ###
22
23 # Make sure threads are really off
24 ok( !$INC{"threads.pm"} );
25
26 # Check each faked function.
27 foreach my $func (qw(share cond_wait cond_signal cond_broadcast)) {
28     ok( my $func_ref = __PACKAGE__->can($func) ? 1 : 0 );
29
30     eval qq{$func()};
31     ok( $@, qr/^Not enough arguments / );
32
33     my %hash = (foo => 42, bar => 23);
34     eval qq{$func(\%hash)};
35     ok( $@, '' );
36     ok( $hash{foo}, 42 );
37     ok( $hash{bar}, 23 );
38 }
39
40 # These all have no return value.
41 foreach my $func (qw(cond_wait cond_signal cond_broadcast)) {
42     my @array = qw(1 2 3 4);
43     ok( eval qq{$func(\@array)}, undef );
44     ok( "@array", "1 2 3 4" );
45 }
46
47 # share() is supposed to return back it's argument as a ref.
48 {
49     my @array = qw(1 2 3 4);
50     ok( share(@array), \@array );
51     ok( ref &share({}), 'HASH' );
52     ok( "@array", "1 2 3 4" );
53 }
54
55 # lock() should be a no-op.  The return value is currently undefined.
56 {
57     my @array = qw(1 2 3 4);
58     lock(@array);
59     ok( "@array", "1 2 3 4" );
60 }
61
62 # EOF