- my $index = List::Index->new([qw(
- baa1 baa2 baa3 baaa bbc cbc daaa ea eaaa zed
- )]) or return;
- is_deeply($index->ranges({pagesize => 2, context => 0}), [
- qw(-baa. baa.-bbb bbc-daa. daaa-eaa. eaaa-)
- ], 'no context');
- is_deeply($index->ranges({pagesize => 2}), [
- qw(-a b c d e-)
- ], 'default context'); # context should be 1
- is_deeply($index->ranges({pagesize => 2, context => 2}), [
- qw(-a b-c d e-)
- ], 'overlap'); # first item equals second due to large context
- is_deeply($index->ranges({pagesize => 2, context => 0, length => 1}), [
- qw(-a b-c d e-)
- ], 'single char');
-
- #pp($index->ranges({pagesize => 2, context => 2, length => 1}));
+ my @data = qw( baa1 baa2 baa3 baaa bbc cbc daaa ea eaaa zed );
+ my $index = List::Index->new({ pagesize => 2 }) or return;
+
+ is_deeply(
+ $index->ranges(\@data, { context => 0 }),
+ [qw(-baa. baa.-bbb bbc-daa. daaa-eaa. eaaa-)],
+ 'no context'
+ );
+ is_deeply(
+ $index->ranges(\@data, { context => undef }),
+ [qw(-baa. baa.-b c d e-)],
+ 'default context' # context should be 1
+ );
+ is_deeply(
+ $index->ranges(\@data, { context => 2 }),
+ # first item equals second due to large context
+ [qw(-ba bb-b c d e-)],
+ 'overlap'
+ );
+ is_deeply(
+ $index->ranges(\@data, { context => 0, length => 1 }),
+ [qw(-a b-c d e-)],
+ 'single char'
+ );
+
+ #pp(List::Index->new({pagesize => 2, context => 2, length => 1}))->ranges(\@data);