Debian Codegraph @

cpan/Scalar-List-Utils/t/mesh.t

raw
1 #!./perl
2
3 use strict;
4 use warnings;
5
6 use Test::More tests => 7;
7 use List::Util qw(mesh mesh_longest mesh_shortest);
8
9 is_deeply( [mesh ()], [],
10 'mesh empty returns empty');
11
12 is_deeply( [mesh ['a'..'c']], [ 'a', 'b', 'c' ],
13 'mesh of one list returns the list' );
14
15 is_deeply( [mesh ['one', 'two'], [1, 2]], [ one => 1, two => 2 ],
16 'mesh of two lists returns a list of two pairs' );
17
18 # Unequal length arrays
19
20 is_deeply( [mesh_longest ['x', 'y', 'z'], ['X', 'Y']], [ 'x', 'X', 'y', 'Y', 'z', undef ],
21 'mesh_longest extends short lists with undef' );
22
23 is_deeply( [mesh_shortest ['x', 'y', 'z'], ['X', 'Y']], [ 'x', 'X', 'y', 'Y' ],
24 'mesh_shortest stops after shortest list' );
25
26 # Non arrayref arguments throw exception
27 ok( !defined eval { mesh 1, 2, 3 },
28 'non-reference argument throws exception' );
29
30 ok( !defined eval { mesh +{ one => 1 } },
31 'reference to non array throws exception' );