1*b39c5158Smillertuse strict; 2*b39c5158Smillertuse warnings; 3*b39c5158Smillert 4*b39c5158Smillertuse Test::More (tests => 53); 5*b39c5158Smillert 6*b39c5158Smillert### Start of Testing ### 7*b39c5158Smillert 8*b39c5158Smillertmy @array; 9*b39c5158Smillertmy %hash; 10*b39c5158Smillert 11*b39c5158Smillertsub hash 12*b39c5158Smillert{ 13*b39c5158Smillert my @val = @_; 14*b39c5158Smillert is(keys %hash, 0, "hash empty"); 15*b39c5158Smillert $hash{0} = $val[0]; 16*b39c5158Smillert is(keys %hash,1, "Assign grows hash"); 17*b39c5158Smillert is($hash{0},$val[0],"Value correct"); 18*b39c5158Smillert $hash{2} = $val[2]; 19*b39c5158Smillert is(keys %hash,2, "Assign grows hash"); 20*b39c5158Smillert is($hash{0},$val[0],"Value correct"); 21*b39c5158Smillert is($hash{2},$val[2],"Value correct"); 22*b39c5158Smillert $hash{1} = $val[1]; 23*b39c5158Smillert is(keys %hash,3,"Size correct"); 24*b39c5158Smillert my @keys = keys %hash; 25*b39c5158Smillert is(join(',',sort @keys),'0,1,2',"Keys correct"); 26*b39c5158Smillert my @hval = @hash{0,1,2}; 27*b39c5158Smillert is(join(',',@hval),join(',',@val),"Values correct"); 28*b39c5158Smillert my $val = delete $hash{1}; 29*b39c5158Smillert is($val,$val[1],"Delete value correct"); 30*b39c5158Smillert is(keys %hash,2,"Size correct"); 31*b39c5158Smillert while (my ($k,$v) = each %hash) { 32*b39c5158Smillert is($v,$val[$k],"each works"); 33*b39c5158Smillert } 34*b39c5158Smillert %hash = (); 35*b39c5158Smillert is(keys %hash,0,"Clear hash"); 36*b39c5158Smillert} 37*b39c5158Smillert 38*b39c5158Smillertsub array 39*b39c5158Smillert{ 40*b39c5158Smillert my @val = @_; 41*b39c5158Smillert is(@array, 0, "array empty"); 42*b39c5158Smillert $array[0] = $val[0]; 43*b39c5158Smillert is(@array,1, "Assign grows array"); 44*b39c5158Smillert is($array[0],$val[0],"Value correct"); 45*b39c5158Smillert unshift(@array,$val[2]); 46*b39c5158Smillert is($array[0],$val[2],"Unshift worked"); 47*b39c5158Smillert is($array[-1],$val[0],"-ve index"); 48*b39c5158Smillert push(@array,$val[1]); 49*b39c5158Smillert is($array[-1],$val[1],"Push worked"); 50*b39c5158Smillert is(@array,3,"Size correct"); 51*b39c5158Smillert is(shift(@array),$val[2],"Shift worked"); 52*b39c5158Smillert is(@array,2,"Size correct"); 53*b39c5158Smillert is(pop(@array),$val[1],"Pop worked"); 54*b39c5158Smillert is(@array,1,"Size correct"); 55*b39c5158Smillert @array = (); 56*b39c5158Smillert is(@array,0,"Clear array"); 57*b39c5158Smillert} 58*b39c5158Smillert 59*b39c5158Smillertok((require threads::shared),"Require module"); 60*b39c5158Smillert 61*b39c5158Smillertif ($threads::shared::VERSION && ! $ENV{'PERL_CORE'}) { 62*b39c5158Smillert diag('Testing threads::shared ' . $threads::shared::VERSION); 63*b39c5158Smillert} 64*b39c5158Smillert 65*b39c5158Smillertarray(24, [], 'Thing'); 66*b39c5158Smillerthash(24, [], 'Thing'); 67*b39c5158Smillert 68*b39c5158Smillertthreads::shared->import(); 69*b39c5158Smillert 70*b39c5158Smillertshare(\@array); 71*b39c5158Smillertarray(24, 42, 'Thing'); 72*b39c5158Smillert 73*b39c5158Smillertshare(\%hash); 74*b39c5158Smillerthash(24, 42, 'Thing'); 75*b39c5158Smillert 76*b39c5158Smillertexit(0); 77*b39c5158Smillert 78*b39c5158Smillert# EOF 79