File: 07_count_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 (21 lines) | stat: -rw-r--r-- 477 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use strict;
use warnings;

use Test::More;

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

my $expected;
my %gots;
my @array;

is_deeply( { count_by { } }, {}, 'empty list' );
is_deeply( { count_by { $_ } "a" }, { a => 1 }, 'unit list' );

is_deeply( { count_by { "all" } "a", "b" }, { all => 2 }, 'constant function' );

%gots = count_by { length $_ } "a", "b", "cc", "dd", "eee";
$expected = { 1 => 2, 2 => 2, 3 => 1 };
is_deeply(\%gots, $expected, 'length function' );

done_testing;