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