summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2012-11-26 08:47:57 +0100
committerAraq <rumpf_a@web.de>2012-11-26 08:47:57 +0100
commit2591ac0ada7f022b695b91f8ce9e5cfe1e7df299 (patch)
treea7543d5861638f15c75fce9758318ce78cb9c82e /tests
parentdd9ad9e49730cec954e9113f0136053c5020aafd (diff)
downloadNim-2591ac0ada7f022b695b91f8ce9e5cfe1e7df299.tar.gz
'return' for first class iterators
Diffstat (limited to 'tests')
-rw-r--r--tests/run/titer9.nim20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/run/titer9.nim b/tests/run/titer9.nim
new file mode 100644
index 000000000..0d6c466c1
--- /dev/null
+++ b/tests/run/titer9.nim
@@ -0,0 +1,20 @@
+discard """
+  output: '''5
+14
+0'''
+"""
+
+iterator count(x: int, skip: bool): int {.closure.} =
+  if skip: return x+10
+  else: yield x+1
+
+  if skip: return x+10
+  else: yield x+2
+
+proc takeProc(x: iterator (x: int, skip: bool): int) =
+  echo x(4, false)
+  echo x(4, true)
+  echo x(4, false)
+
+takeProc(count)
+