File: 02.t

package info (click to toggle)
libmath-combinatorics-perl 0.08-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 84 kB
  • ctags: 27
  • sloc: perl: 346; makefile: 35
file content (50 lines) | stat: -rw-r--r-- 1,022 bytes parent folder | download | duplicates (7)
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
BEGIN {
  use lib 'lib';
  use strict;
  use Test::More;

  plan tests => 5;

  use_ok('Data::Dumper');
  use_ok('Math::Combinatorics');
}

my $c;
my $f = 0;
my @r;
my @data;

@data = ( 'a', [], 'b', [] );
$c = Math::Combinatorics->new(
                              data => \@data,
                              count => 2,
                             );
$f = 0;
while(my(@combo) = $c->next_combination){
  #warn "combo $f is: ".join " ", @combo;
  $f++;
}
ok($f == 6, ">>> $f == 6 <<<");

@data = ([],[],[],[]);
$c = Math::Combinatorics->new(
                              data => \@data,
                              count => 2,
                             );
$f = 0;
while(my(@combo) = $c->next_combination){
  $f++;
}
ok($f == 6, ">>> $f == 6 <<<");

@data = (1..10);
$c = Math::Combinatorics->new(
                              data => \@data,
                              count => 2,
                             );
$f = 0;
while(my(@combo) = $c->next_combination){
  $f++;
}
ok($f == 45, ">>> $f == 45 <<<");