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