Skip to content

Commit

Permalink
test List.combinations a bit.
Browse files Browse the repository at this point in the history
  • Loading branch information
timo committed Nov 12, 2013
1 parent 3531185 commit 25ccede
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions S32-list/combinations.t
@@ -0,0 +1,15 @@
use Test;

plan 6;

sub canon($t) {
$t.tree.map(*.sort).tree
}

ok(((1,), (2,), (3,)).list eqv [1, 2, 3].combinations(1).&canon, "single-item combinations");
ok(all([1, 2], [2, 3], [1, 3]) eqv one([1, 2, 3].combinations(2).&canon), "two item combinations");
ok(([1, 2, 3],).list eqv [1, 2, 3].combinations(3).&canon, "three items of a three-item list");

ok(all(1, 2, 3, [1, 2], [2, 3], [1, 3]) eqv one([1, 2, 3].combinations(1..2).&canon), "1..2 items");
ok(all(1, 2, 3, [1, 2], [2, 3], [1, 3], [1, 2, 3]) eqv one([1, 2, 3].combinations(1..3).&canon), "1..3 items");
ok(all([1, 2], [2, 3], [1, 3], [1, 2, 3]) eqv one([1, 2, 3].combinations(2..3).&canon), "2..3 items");

0 comments on commit 25ccede

Please sign in to comment.