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 # first, last -- show first or last item
15 # show -- write entire array to stdout, space separated on one line
19 return int(rand($lim));
22 $lines = shift || 100;
23 $max = 0; # Estimate of size of array
28 my $op = (qw(push pop shift unshift))[$what % 4];
29 if ($op eq "push" || $op eq "unshift") {
37 } elsif ($what < 10) {
39 my $op = (qw(insert append))[$what % 2];
40 push(@n, $serial++) while random(4) < 3;
41 print "$op ", join(" ", @n), "\n";
43 } elsif ($what < 12) {
44 if ($max < 10000) { next; }
46 my $op = (qw(delete reduce))[$what % 2];
47 $n++ while random(4) < 3;
53 } elsif ($what < 16) {
55 $i++ while random(4) < 2;
65 } elsif ($what < 20) {
66 my $op = (qw(first last))[$what % 2];
67 print "$op\n" if $max;
68 } elsif (random(10) == 0) {