chiark / gitweb /
Headers: Guard inclusion of mLib headers.
[mLib] / da-gtest
index 4412e498df6ded36a2dd6b633775c7df9645dca4..0348833597e8d96ad1f83b0029e5132d087814ee 100755 (executable)
--- a/da-gtest
+++ b/da-gtest
@@ -11,6 +11,7 @@
 #   reduce n -- remove n items from end
 #   set i n -- assign item at index i to be n
 #   get i -- display item at index i
+#   first, last -- show first or last item
 #   show -- write entire array to stdout, space separated on one line
 
 sub random ($) {
@@ -22,7 +23,7 @@ $lines = shift || 100;
 $max = 0; # Estimate of size of array
 $serial = 1;
 while ($lines) {
-  $what = random(17);
+  $what = random(21);
   if ($what < 8) {
     my $op = (qw(push pop shift unshift))[$what % 4];
     if ($op eq "push" || $op eq "unshift") {
@@ -61,6 +62,9 @@ while ($lines) {
     } else {
       print "get $i\n";
     }
+  } elsif ($what < 20) {
+    my $op = (qw(first last))[$what % 2];
+    print "$op\n" if $max;
   } elsif (random(10) == 0) {
     print "show\n";
   } else { next; }