1use Test::More;
2use strict; use warnings FATAL => 'all';
3
4use List::Objects::WithUtils 'array';
5
6my $arr = array(1 .. 3);
7
8ok $arr->exists(0),     'array exists ok';
9ok $arr->exists(1),     'array exists(1) ok';
10ok $arr->exists(2),     'array exists(2) ok';
11ok !$arr->exists(3),    '!array exists(3) ok';
12ok !$arr->exists(4),    '!array exists(4) ok';
13
14ok $arr->exists(-1),    'array exists(-1) ok';
15ok $arr->exists(-2),    'array exists(-2) ok';
16ok $arr->exists(-3),    'array exists(-3) ok';
17ok !$arr->exists(-4),   'array !exists(-4) ok';
18
19ok !array->exists(0),   'empty array !exists(0) ok';
20ok !array->exists(1),   'empty array !exists(1) ok';
21ok !array->exists(-1),  'empty array !exists(-1) ok';
22
23ok array(1)->exists(0),   'single-element array exists(0) ok';
24ok !array(1)->exists(1),  'single-element array !exists(1) ok';
25ok !array(1)->exists(2),  'single-element array !exists(2) ok';
26ok array(1)->exists(-1),  'single-element array exists(-1) ok';
27ok !array(1)->exists(-2), 'single-element array exists(-2) ok';
28
29done_testing
30