Algorithm-Combinatorics
view release on metacpan or search on metacpan
t/04_variations_with_repetition.t view on Meta::CPAN
use strict;
use warnings;
use FindBin qw($Bin);
use lib $Bin;
use Test::More qw(no_plan);
use Algorithm::Combinatorics qw(variations_with_repetition);
use Tester;
my $tester = Tester->__new(\&variations_with_repetition);
my (@result, @expected);
# ---------------------------------------------------------------------
eval { variations_with_repetition() };
ok($@, '');
eval { variations_with_repetition([1]) };
ok($@, '');
eval { variations_with_repetition(0, 0) };
ok($@, '');
# ---------------------------------------------------------------------
@expected = ([]);
$tester->__test(\@expected, [], 0);
@expected = ([]);
$tester->__test(\@expected, [1, 2], 0);
# ---------------------------------------------------------------------
@expected = (["foo"]);
$tester->__test(\@expected, ["foo"], 1);
# ---------------------------------------------------------------------
@expected = (["foo"], ["bar"]);
$tester->__test(\@expected, ["foo", "bar"], 1);
# ---------------------------------------------------------------------
@expected = (
["foo", "foo"],
["foo", "bar"],
["bar", "foo"],
["bar", "bar"],
);
$tester->__test(\@expected, ["foo", "bar"], 2);
# ---------------------------------------------------------------------
@expected = (
["foo", "foo", "foo"],
["foo", "foo", "bar"],
["foo", "bar", "foo"],
["foo", "bar", "bar"],
["bar", "foo", "foo"],
["bar", "foo", "bar"],
["bar", "bar", "foo"],
["bar", "bar", "bar"],
( run in 0.896 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )