summary refs log tree commit diff stats
path: root/tests/iter/titer9.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/iter/titer9.nim')
-rw-r--r--tests/iter/titer9.nim20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/iter/titer9.nim b/tests/iter/titer9.nim
new file mode 100644
index 000000000..99874e70a
--- /dev/null
+++ b/tests/iter/titer9.nim
@@ -0,0 +1,20 @@
+discard """
+  output: '''5
+14
+0'''
+"""
+
+iterator count[T](x: T, skip: bool): int {.closure.} =
+  if skip: return x+10
+  else: yield x+1
+
+  if skip: return x+10
+  else: yield x+2
+
+proc takeProc[T](x: iterator (x: T, skip: bool): int) =
+  echo x(4, false)
+  echo x(4, true)
+  echo x(4, false)
+
+takeProc(count[int])
+