3 # Generate a random test file for dynamic array testing.
7 # push n, pop, shift, unshift n -- normal stack ops (pop and shift print)
8 # insert x y z ... -- insert items at beginning
9 # append x y z ... -- append items at end
10 # delete n -- remove n items from beginning
11 # reduce n -- remove n items from end
12 # set i n -- assign item at index i to be n
13 # get i -- display item at index i
14 # show -- write entire array to stdout, space separated on one line
18 return int(rand($lim));
21 $lines = shift || 100;
22 $max = 0; # Estimate of size of array
27 my $op = (qw(push pop shift unshift))[$what % 4];
28 if ($op eq "push" || $op eq "unshift") {
36 } elsif ($what < 10) {
38 my $op = (qw(insert append))[$what % 2];
39 push(@n, $serial++) while random(4) < 3;
40 print "$op ", join(" ", @n), "\n";
42 } elsif ($what < 12) {
43 if ($max < 10000) { next; }
45 my $op = (qw(delete reduce))[$what % 2];
46 $n++ while random(4) < 3;
52 } elsif ($what < 16) {
54 $i++ while random(4) < 2;
64 } elsif (random(10) == 0) {