1#!./perl 2 3use strict; 4use warnings; 5 6use Test::More tests => 7; 7use List::Util qw(mesh mesh_longest mesh_shortest); 8 9is_deeply( [mesh ()], [], 10 'mesh empty returns empty'); 11 12is_deeply( [mesh ['a'..'c']], [ 'a', 'b', 'c' ], 13 'mesh of one list returns the list' ); 14 15is_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 20is_deeply( [mesh_longest ['x', 'y', 'z'], ['X', 'Y']], [ 'x', 'X', 'y', 'Y', 'z', undef ], 21 'mesh_longest extends short lists with undef' ); 22 23is_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 27ok( !defined eval { mesh 1, 2, 3 }, 28 'non-reference argument throws exception' ); 29 30ok( !defined eval { mesh +{ one => 1 } }, 31 'reference to non array throws exception' ); 32