Permalink
Browse files

test List.combinations a bit.

  • Loading branch information...
1 parent 3531185 commit 25ccede15032ccaa87c1f3fa4b05665ce160e71f @timo timo committed Nov 12, 2013
Showing with 15 additions and 0 deletions.
  1. +15 −0 S32-list/combinations.t
View
@@ -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.