1use Test::More; 2use strict; use warnings FATAL => 'all'; 3 4use List::Objects::WithUtils 'array'; 5 6ok !array->indexes(sub { 1 })->has_any, 'empty indexes ok'; 7 8my $arr = array(qw/foo bar baz/); 9 10my $idx = $arr->indexes(sub { $_ eq 'bar' }); 11 12is_deeply [ $idx->all ], [ 1 ], 13 'indexes (single) ok'; 14 15is_deeply [ $idx->all ], [ $arr->indices(sub { $_ eq 'bar' })->all ], 16 'indices alias ok'; 17 18$arr = array( 1 .. 10 ); 19$idx = $arr->indexes(sub { $_ % 2 == 0 }); 20 21is_deeply [ $idx->all ], [ 1, 3, 5, 7, 9 ], 22 'indexes (multiple) ok'; 23 24$idx = $arr->indexes; 25is_deeply [ $idx->all ], [ 0 .. 9 ], 26 'indexes (no arguments) ok'; 27 28done_testing 29