File: bisect.t

package info (click to toggle)
liblist-objects-withutils-perl 2.028003-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,296 kB
  • sloc: perl: 1,957; makefile: 17; sh: 1
file content (22 lines) | stat: -rw-r--r-- 603 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
use Test::More;
use strict; use warnings FATAL => 'all';

use List::Objects::WithUtils 'array';

my $arr = array( 1 .. 10 );

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

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

ok $pair->count == 2, '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 array()->bisect(sub {})->count == 2, 'bisect always returns two arrays';

done_testing;