summary refs log tree commit diff stats
path: root/tests/accept/run
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2010-12-13 07:58:35 +0100
committerAraq <rumpf_a@web.de>2010-12-13 07:58:35 +0100
commit63ac32e6de018b5e175efb6f61675bfe36394973 (patch)
tree5e95795798ccdadecdbfaa8340d7382eae8ee9be /tests/accept/run
parente7fe8edab39884f59d685d2608f8bd944cad27e6 (diff)
downloadNim-63ac32e6de018b5e175efb6f61675bfe36394973.tar.gz
bugfix: multiple yield statements and loop body vars
Diffstat (limited to 'tests/accept/run')
-rwxr-xr-xtests/accept/run/spec.csv1
-rw-r--r--tests/accept/run/titer6.nim31
2 files changed, 32 insertions, 0 deletions
diff --git a/tests/accept/run/spec.csv b/tests/accept/run/spec.csv
index 68954cf48..c57463770 100755
--- a/tests/accept/run/spec.csv
+++ b/tests/accept/run/spec.csv
@@ -34,6 +34,7 @@ tisopr.nim;falsetrue
 titer2.nim;123
 titer3.nim;1231
 titer5.nim;abcxyz
+titer6.nim;000
 tlenopenarray.nim;1
 tlowhigh.nim;10
 tmatrix.nim;111
diff --git a/tests/accept/run/titer6.nim b/tests/accept/run/titer6.nim
new file mode 100644
index 000000000..8a1d9cf1b
--- /dev/null
+++ b/tests/accept/run/titer6.nim
@@ -0,0 +1,31 @@
+# Test iterator with more than 1 yield statement
+
+import strutils
+
+iterator tokenize2(s: string, seps: set[char] = Whitespace): tuple[

+  token: string, isSep: bool] =

+  var i = 0

+  while i < s.len:

+    var j = i

+    if s[j] in seps:

+      while j < s.len and s[j] in seps: inc(j)
+      if j > i:

+        yield (copy(s, i, j-1), true)

+    else:
+      while j < s.len and s[j] notin seps: inc(j)
+      if j > i:

+        yield (copy(s, i, j-1), false)

+    i = j
+
+for word, isSep in tokenize2("ta da", whiteSpace):
+  var titer2TestVar = 0 
+  stdout.write(titer2TestVar)

+
+proc wordWrap2(s: string, maxLineWidth = 80, 

+               splitLongWords = true,

+               seps: set[char] = whitespace,

+               newLine = "\n"): string  = 

+  result = ""

+  for word, isSep in tokenize2(s, seps):
+    var w = 0 

+