1use Test::More; 2use strict; use warnings FATAL => 'all'; 3 4use List::Objects::WithUtils 'array'; 5 6my $arr = array(qw/ a b c /); 7 8my $first = $arr->head; 9ok $first eq 'a', 'scalar head ok'; 10 11my ($head, $tail) = $arr->head; 12isa_ok $tail, 'List::Objects::WithUtils::Array'; 13 14ok $head eq 'a', 'list head first item ok'; 15is_deeply 16 [ $tail->all ], 17 [ qw/ b c / ], 18 'list head second item ok'; 19 20ok !defined array->head, 'empty array head undef ok'; 21($head, $tail) = array->head; 22ok !defined $head, 'empty array list head first item undef ok'; 23ok $tail->is_empty, 'empty array list head second item is_empty'; 24 25done_testing; 26