File: 09unzip_by.t

package info (click to toggle)
liblist-utilsby-perl 0.12-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 184 kB
  • sloc: perl: 479; makefile: 2
file content (20 lines) | stat: -rw-r--r-- 613 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
#!/usr/bin/perl

use strict;
use warnings;

use Test::More;

use List::UtilsBy qw( unzip_by );

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

is_deeply( [ unzip_by { $_ } "a", "b", "c" ], [ [ "a", "b", "c" ] ], 'identity function' );

is_deeply( [ unzip_by { $_, $_ } "a", "b", "c" ], [ [ "a", "b", "c" ], [ "a", "b", "c" ] ], 'clone function' );

is_deeply( [ unzip_by { m/(.)/g } "a1", "b2", "c3" ], [ [ "a", "b", "c" ], [ 1, 2, 3 ] ], 'regexp match function' );

is_deeply( [ unzip_by { m/(.)/g } "a", "b2", "c" ], [ [ "a", "b", "c" ], [ undef, 2, undef ] ], 'non-rectangular adds undef' );

done_testing;