summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authordef <dennis@felsin9.de>2015-02-02 08:06:19 +0100
committerdef <dennis@felsin9.de>2015-02-02 08:06:19 +0100
commit03db4d2930bb5265da1d966cd32d7f5faccb6056 (patch)
tree796af38b464176b8ef2917dcfc46b5be46e4d70f /tests
parent1ae4d535cd8ed6b797cf0525eaab9e0c889e0c6d (diff)
downloadNim-03db4d2930bb5265da1d966cd32d7f5faccb6056.tar.gz
Adapt the tester for permutations
Uses the bool return value now
Diffstat (limited to 'tests')
-rw-r--r--tests/stdlib/tpermutations.nim24
1 files changed, 13 insertions, 11 deletions
diff --git a/tests/stdlib/tpermutations.nim b/tests/stdlib/tpermutations.nim
index 99bc424cd..a6e07ded6 100644
--- a/tests/stdlib/tpermutations.nim
+++ b/tests/stdlib/tpermutations.nim
@@ -1,17 +1,19 @@
 discard """
-  output: '''@[0, 1, 2, 3, 4, 5, 6, 7, 9, 8]
-@[0, 1, 2, 3, 4, 5, 6, 8, 7, 9]
-@[0, 1, 2, 3, 4, 5, 6, 8, 9, 7]
-@[0, 1, 2, 3, 4, 5, 6, 8, 7, 9]
-@[0, 1, 2, 3, 4, 5, 6, 7, 9, 8]
-@[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]'''
+  output: '''@[0, 2, 1]
+@[1, 0, 2]
+@[1, 2, 0]
+@[2, 0, 1]
+@[2, 1, 0]
+@[2, 0, 1]
+@[1, 2, 0]
+@[1, 0, 2]
+@[0, 2, 1]
+@[0, 1, 2]'''
 """
 import algorithm
 
-var v = @[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
-for i in 1..3:
-  v.nextPermutation()
+var v = @[0, 1, 2]
+while v.nextPermutation():
   echo v
-for i in 1..3:
-  v.prevPermutation()
+while v.prevPermutation():
   echo v