File: bisect.t

package info (click to toggle)
liblist-objects-withutils-perl 2.028003-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,292 kB
  • sloc: perl: 1,957; makefile: 17; sh: 1
file content (23 lines) | stat: -rw-r--r-- 577 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use Test::More;
use strict; use warnings FATAL => 'all';

use Lowu;

my $arr = [ 1 .. 10 ];

my $pair = $arr->bisect(sub { $_ >= 5 });

isa_ok $pair, 'List::Objects::WithUtils::Array',
  'boxed bisect returned array obj';

ok $pair->count == 2, 'boxed bisect() returned two items';
isa_ok $pair->get(0), 'List::Objects::WithUtils::Array';
isa_ok $pair->get(1), 'List::Objects::WithUtils::Array';

is_deeply [ $pair->get(0)->all ], [ 5 .. 10 ];
is_deeply [ $pair->get(1)->all ], [ 1 .. 4 ];

ok []->bisect(sub {})->count == 2,
  'boxed bisect on empty array ok';

done_testing;