1use Test::More; 2use strict; use warnings FATAL => 'all'; 3 4use List::Objects::WithUtils 'array'; 5 6my $arr = array(qw/ a ba bb c /); 7my $firstidx = $arr->firstidx(sub { /^b/ }); 8ok $firstidx == 1, 'firstidx ok'; 9ok $arr->first_index(sub { /^b/ }) == $firstidx, 10 'first_index alias ok'; 11 12ok $arr->first_index(sub { /c/ }) == 3, 13 'firstidx ok'; 14 15ok $arr->first_index(sub { /d/ }) == -1, 16 'negative first_index ok'; 17 18ok array->first_index(sub { 1 }) == -1, 19 'first_index on empty array ok'; 20 21done_testing; 22