Upgrade to threads-1.42
[p5sagit/p5-mst-13.2.git] / ext / threads / shared / t / disabled.t
CommitLineData
0a9af0ff 1#!./perl -Tw
2
3# Tests of threads::shared's behavior when threads are disabled.
4
5BEGIN {
6 chdir 't';
7 @INC = '../lib';
a73a1357 8 require Config;
98641f60 9 if (($Config::Config{'extensions'} !~ m!\bthreads/shared\b!) ){
a73a1357 10 print "1..0 # Skip -- Perl configured without threads::shared module\n";
11 exit 0;
12 }
0a9af0ff 13}
14
15# Can't use Test::More, it turns threads on.
16use Test;
17plan tests => 31;
18
19use threads::shared;
20
21# Make sure threads are really off.
22ok( !$INC{"threads.pm"} );
23
24# Check each faked function.
25foreach my $func (qw(share cond_wait cond_signal cond_broadcast)) {
26 ok( my $func_ref = __PACKAGE__->can($func) ? 1 : 0 );
27
28 eval qq{$func()};
29 ok( $@, qr/^Not enough arguments / );
30
31 my %hash = (foo => 42, bar => 23);
32 eval qq{$func(\%hash)};
33 ok( $@, '' );
34 ok( $hash{foo}, 42 );
35 ok( $hash{bar}, 23 );
36}
37
38# These all have no return value.
39foreach my $func (qw(cond_wait cond_signal cond_broadcast)) {
40 my @array = qw(1 2 3 4);
41 ok( eval qq{$func(\@array)}, undef );
42 ok( "@array", "1 2 3 4" );
43}
44
45# share() is supposed to return back it's argument as a ref.
46{
47 my @array = qw(1 2 3 4);
48 ok( share(@array), \@array );
49 ok( ref &share({}), 'HASH' );
50 ok( "@array", "1 2 3 4" );
51}
52
53# lock() should be a no-op. The return value is currently undefined.
54{
55 my @array = qw(1 2 3 4);
56 lock(@array);
57 ok( "@array", "1 2 3 4" );
58}