Eviscerate README.macos to match the state of the world
[p5sagit/p5-mst-13.2.git] / dist / threads-shared / t / 0nothread.t
1 use strict;
2 use warnings;
3
4 use Test::More (tests => 53);
5
6 ### Start of Testing ###
7
8 my @array;
9 my %hash;
10
11 sub hash
12 {
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");
36 }
37
38 sub array
39 {
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");
57 }
58
59 ok((require threads::shared),"Require module");
60
61 if ($threads::shared::VERSION && ! $ENV{'PERL_CORE'}) {
62     diag('Testing threads::shared ' . $threads::shared::VERSION);
63 }
64
65 array(24, [], 'Thing');
66 hash(24, [], 'Thing');
67
68 threads::shared->import();
69
70 share(\@array);
71 array(24, 42, 'Thing');
72
73 share(\%hash);
74 hash(24, 42, 'Thing');
75
76 exit(0);
77
78 # EOF