File: 05_uniq_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 (24 lines) | stat: -rw-r--r-- 549 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
22
23
24
use strict;
use warnings;

use Test::More;
use List::UtilsBy::XS qw( uniq_by );

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

is_deeply( [ uniq_by { } ], [], 'empty list' );

is_deeply( [ uniq_by { $_ } "a" ], [ "a" ], 'unit list' );

@gots = uniq_by { $_ } "a", "b";
is_deeply(\@gots, [ "a", "b" ],'identity function no-op');

@gots = uniq_by { $_ } "b", "a";
is_deeply(\@gots, [ "b", "a" ], 'identity function on $_' );

@gots = uniq_by { length $_ } "a", "b", "cc", "dd", "eee";
is_deeply(\@gots, [ "a", "cc", "eee" ], 'length function' );

done_testing;