summaryrefslogtreecommitdiffstats
path: root/pintos-progos/tests/lib.pm
diff options
context:
space:
mode:
authormanuel <manuel@mausz.at>2012-03-26 12:54:45 +0200
committermanuel <manuel@mausz.at>2012-03-26 12:54:45 +0200
commitb5f0874cd96ee2a62aabc645b9626c2749cb6a01 (patch)
tree1262e4bbe0634de6650be130c36e0538240f4cbf /pintos-progos/tests/lib.pm
downloadprogos-b5f0874cd96ee2a62aabc645b9626c2749cb6a01.tar.gz
progos-b5f0874cd96ee2a62aabc645b9626c2749cb6a01.tar.bz2
progos-b5f0874cd96ee2a62aabc645b9626c2749cb6a01.zip
initial pintos checkin
Diffstat (limited to 'pintos-progos/tests/lib.pm')
-rw-r--r--pintos-progos/tests/lib.pm19
1 files changed, 19 insertions, 0 deletions
diff --git a/pintos-progos/tests/lib.pm b/pintos-progos/tests/lib.pm
new file mode 100644
index 0000000..bc37ae5
--- /dev/null
+++ b/pintos-progos/tests/lib.pm
@@ -0,0 +1,19 @@
1use strict;
2use warnings;
3
4use tests::random;
5
6sub shuffle {
7 my ($in, $cnt, $sz) = @_;
8 $cnt * $sz == length $in or die;
9 my (@a) = 0...$cnt - 1;
10 for my $i (0...$cnt - 1) {
11 my ($j) = $i + random_ulong () % ($cnt - $i);
12 @a[$i, $j] = @a[$j, $i];
13 }
14 my ($out) = "";
15 $out .= substr ($in, $_ * $sz, $sz) foreach @a;
16 return $out;
17}
18
191;