File: get_splice_parms.t

package info (click to toggle)
libarray-intspan-perl 2.004-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 216 kB
  • sloc: perl: 521; makefile: 2
file content (55 lines) | stat: -rw-r--r-- 2,150 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55

use warnings FATAL => qw(all);
use ExtUtils::testlib;
use Test::More tests => 30 ;
use Data::Dumper ;

use Array::IntSpan;

my $trace = shift || 0 ;

my @expect= ([1,3,'ab'],[6,9,'cd']) ;
my $r = Array::IntSpan->new(@expect) ;

diag(Dumper $r) if $trace ;

ok ( defined($r) , 'Array::IntSpan new() works') ;
is_deeply( $r , \@expect, 'new content ok') ;

my $spawn = sub { 'sp:'.$_[2] ;} ;

foreach my $a ( 
               [[0, 0,'bc'],[0,0,[0, 0,'bc']]],
               [[0, 1,'bc'],[0,1,[0, 1,'bc'],[2,3,'ab']]],
               [[0, 3,'bc'],[0,1,[0, 3,'bc']]],
               [[0, 4,'bc'],[0,1,[0, 4,'bc']]],
               [[0, 5,'bc'],[0,1,[0, 5,'bc']]],
               [[0, 6,'bc'],[0,2,[0, 6,'bc'],[7,9,'cd']]],
               [[0, 9,'bc'],[0,2,[0, 9,'bc']]],
               [[0,10,'bc'],[0,2,[0,10,'bc']]],
               [[1, 3,'bc'],[0,1,[1, 3,'bc']]],
               [[1, 2,'bc'],[0,1,[1, 2,'bc'],[3, 3,'ab']]],
               [[2, 2,'bc'],[0,1,[1, 1,'ab'],[2, 2,'bc'],[3,3,'ab']]],
               [[2, 3,'bc'],[0,1,[1, 1,'ab'],[2, 3,'bc']]],
               [[2, 5,'bc'],[0,1,[1, 1,'ab'],[2, 5,'bc']]],
               [[2, 8,'bc'],[0,2,[1, 1,'ab'],[2, 8,'bc'],[9,9,'cd']]],
               [[2, 9,'bc'],[0,2,[1, 1,'ab'],[2, 9,'bc']]],
               [[2,10,'bc'],[0,2,[1, 1,'ab'],[2,10,'bc']]],
               [[4, 4,'bc'],[1,0,[4, 4,'bc']]],
               [[5, 6,'bc'],[1,1,[5, 6,'bc'],[7,9,'cd']]],
               [[5, 9,'bc'],[1,1,[5, 9,'bc']]],
               [[5,11,'bc'],[1,1,[5,11,'bc']]],
               [[6, 6,'bc'],[1,1,[6, 6,'bc'],[7,9,'cd']]],
               [[6, 9,'bc'],[1,1,[6, 9,'bc']]],
               [[7, 9,'bc'],[1,1,[6, 6,'cd'],[7,9,'bc']]],
               [[9,11,'bc'],[1,1,[6, 8,'cd'],[9,11,'bc']]],
               [[10,11,'bc'],[2,0,[10,11,'bc']]],
               [[10,11,'bc', $spawn],[2,0,[10,11,'bc']]],
               [[9,11,'bc', $spawn],[1,1,[6, 8,'sp:cd'],[9,11,'bc']]],
               [[2, 2,'bc', $spawn],[0,1,[1, 1,'sp:ab'],[2, 2,'bc'],[3,3,'sp:ab']]],
              )
  {
    my @r = $r->get_splice_parms(@{$a->[0]}) ;
    is_deeply(\@r, $a->[1], "get_splice_parms @{$a->[0]}") || diag(Dumper \@r);
  }