aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/gleam/list_test.gleam23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/gleam/list_test.gleam b/test/gleam/list_test.gleam
index ff94c3b..d9a4285 100644
--- a/test/gleam/list_test.gleam
+++ b/test/gleam/list_test.gleam
@@ -481,3 +481,26 @@ pub fn partition_test() {
|> list.partition(int.is_odd)
|> should.equal(tuple([1, 3, 5, 7], [2, 4, 6]))
}
+
+pub fn permutations_test() {
+ [1, 2]
+ |> list.permutations
+ |> should.equal([[1, 2], [2, 1]])
+
+ let expected = [
+ [1, 2, 3],
+ [1, 3, 2],
+ [2, 1, 3],
+ [2, 3, 1],
+ [3, 1, 2],
+ [3, 2, 1],
+ ]
+
+ [1, 2, 3]
+ |> list.permutations
+ |> should.equal(expected)
+
+ ["a", "b"]
+ |> list.permutations
+ |> should.equal([["a", "b"], ["b", "a"]])
+}