Make tests public. Rewrite most tests. Add tests.
[pintos-anon] / src / tests / lib.pm
diff --git a/src/tests/lib.pm b/src/tests/lib.pm
new file mode 100644 (file)
index 0000000..bc37ae5
--- /dev/null
@@ -0,0 +1,19 @@
+use strict;
+use warnings;
+
+use tests::random;
+
+sub shuffle {
+    my ($in, $cnt, $sz) = @_;
+    $cnt * $sz == length $in or die;
+    my (@a) = 0...$cnt - 1;
+    for my $i (0...$cnt - 1) {
+       my ($j) = $i + random_ulong () % ($cnt - $i);
+       @a[$i, $j] = @a[$j, $i];
+    }
+    my ($out) = "";
+    $out .= substr ($in, $_ * $sz, $sz) foreach @a;
+    return $out;
+}
+
+1;