Eviscerate README.macos to match the state of the world
[p5sagit/p5-mst-13.2.git] / dist / threads-shared / t / 0nothread.t
CommitLineData
6b85e4fe 1use strict;
13c1b207 2use warnings;
7473853a 3
7473853a 4use Test::More (tests => 53);
5
6### Start of Testing ###
6b85e4fe 7
8my @array;
9my %hash;
10
11sub hash
12{
7473853a 13 my @val = @_;
14 is(keys %hash, 0, "hash empty");
15 $hash{0} = $val[0];
16 is(keys %hash,1, "Assign grows hash");
17 is($hash{0},$val[0],"Value correct");
18 $hash{2} = $val[2];
19 is(keys %hash,2, "Assign grows hash");
20 is($hash{0},$val[0],"Value correct");
21 is($hash{2},$val[2],"Value correct");
22 $hash{1} = $val[1];
23 is(keys %hash,3,"Size correct");
24 my @keys = keys %hash;
25 is(join(',',sort @keys),'0,1,2',"Keys correct");
26 my @hval = @hash{0,1,2};
27 is(join(',',@hval),join(',',@val),"Values correct");
28 my $val = delete $hash{1};
29 is($val,$val[1],"Delete value correct");
30 is(keys %hash,2,"Size correct");
31 while (my ($k,$v) = each %hash) {
32 is($v,$val[$k],"each works");
33 }
34 %hash = ();
35 is(keys %hash,0,"Clear hash");
6b85e4fe 36}
37
38sub array
39{
7473853a 40 my @val = @_;
41 is(@array, 0, "array empty");
42 $array[0] = $val[0];
43 is(@array,1, "Assign grows array");
44 is($array[0],$val[0],"Value correct");
45 unshift(@array,$val[2]);
46 is($array[0],$val[2],"Unshift worked");
47 is($array[-1],$val[0],"-ve index");
48 push(@array,$val[1]);
49 is($array[-1],$val[1],"Push worked");
50 is(@array,3,"Size correct");
51 is(shift(@array),$val[2],"Shift worked");
52 is(@array,2,"Size correct");
53 is(pop(@array),$val[1],"Pop worked");
54 is(@array,1,"Size correct");
55 @array = ();
56 is(@array,0,"Clear array");
6b85e4fe 57}
58
59ok((require threads::shared),"Require module");
60
63790022 61if ($threads::shared::VERSION && ! $ENV{'PERL_CORE'}) {
7473853a 62 diag('Testing threads::shared ' . $threads::shared::VERSION);
63}
6b85e4fe 64
7473853a 65array(24, [], 'Thing');
66hash(24, [], 'Thing');
5f64702c 67
7c8caac0 68threads::shared->import();
6b85e4fe 69
7473853a 70share(\@array);
71array(24, 42, 'Thing');
6b85e4fe 72
73share(\%hash);
7473853a 74hash(24, 42, 'Thing');
6b85e4fe 75
6c791b15 76exit(0);
77
7473853a 78# EOF