xref: /openbsd-src/gnu/usr.bin/perl/dist/threads-shared/t/disabled.t (revision 4c1e55dc91edd6e69ccc60ce855900fbc12cf34f)
1use strict;
2use warnings;
3
4use Test;
5plan tests => 31;
6
7use threads::shared;
8
9### Start of Testing ###
10
11# Make sure threads are really off
12ok( !$INC{"threads.pm"} );
13
14# Check each faked function.
15foreach 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.
29foreach 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}
49
50exit(0);
51
52# EOF
53