1#!./perl
2
3use strict;
4use warnings;
5
6use Test::More tests => 7;
7
8use List::Util qw(shuffle);
9
10my @r;
11
12@r = shuffle();
13ok( !@r, 'no args');
14
15@r = shuffle(9);
16is( 0+@r, 1, '1 in 1 out');
17is( $r[0], 9, 'one arg');
18
19my @in = 1..100;
20@r = shuffle(@in);
21is( 0+@r, 0+@in, 'arg count');
22
23isnt( "@r", "@in", 'result different to args');
24
25my @s = sort { $a <=> $b } @r;
26is( "@in", "@s", 'values');
27
28{
29  local $List::Util::RAND = sub { 4/10 }; # chosen by a fair die
30
31  @r = shuffle(1..10);
32  is_deeply(
33    [ shuffle(1..10) ],
34    [ shuffle(1..10) ],
35    'rigged rand() yields predictable output'
36  );
37}
38