File: 10_weighted_shuffle_by.t

package info (click to toggle)
liblist-utilsby-xs-perl 0.06-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 212 kB
  • sloc: perl: 198; makefile: 3; sh: 1
file content (17 lines) | stat: -rw-r--r-- 489 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use strict;
use warnings;

use Test::More;

use List::UtilsBy::XS qw(weighted_shuffle_by);

is_deeply( [ weighted_shuffle_by { } ], [], 'empty list' );
is_deeply( [ weighted_shuffle_by { 1 } "a" ], [ "a" ], 'unit list' );

my @vals = weighted_shuffle_by { 1 } "a", "b", "c";
is_deeply( [ sort @vals ], [ "a", "b", "c" ], 'set of return values' );

@vals = weighted_shuffle_by { ord $_ } "a", "b", "c";
is_deeply( [ sort @vals ], [ "a", "b", "c" ], 'set of return values' );

done_testing;