File: shuffle.t

package info (click to toggle)
libautobox-list-util-perl 20090629-1
  • links: PTS
  • area: main
  • in suites: squeeze, wheezy
  • size: 96 kB
  • ctags: 12
  • sloc: perl: 59; makefile: 2
file content (41 lines) | stat: -rwxr-xr-x 760 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
use blib;
use strict;
use autobox::List::Util;
use Test::More tests => 13;

my @r;

@r = []->shuffle;
ok( !@r,	'no args');

@r = [9]->shuffle;
is( 0+@r,	1,	'1 in 1 out');
is( $r[0],	9,	'one arg');

my @in = 1..100;
@r = @in->shuffle;
is( 0+@r,	0+@in,	'arg count');

isnt( "@r",	"@in",	'result different to args');

my @s = sort { $a <=> $b } @r;
is( "@in",	"@s",	'values');

my $r;

$r = []->shuffle;
ok( !@$r,	'no args (ref)');

$r = [9]->shuffle;
is( 0+@$r,	1,	'1 in 1 out (ref)');
is( $r->[0],	9,	'one arg (ref)');

$r = @in->shuffle;
is( 0+@$r,	0+@in,	'arg count (ref)');

isnt( "@$r",	"@in",	'result different to args (ref)');

@s = sort { $a <=> $b } @$r;
is( "@in",	"@s",	'values (ref)');

is @in->shuffle->first(sub { $_ == 5 }), 5, "can chain calls";