summary refs log tree commit diff stats
path: root/tests/titer.nim
diff options
context:
space:
mode:
authorAndreas Rumpf <andreas@andi>2008-06-22 16:14:11 +0200
committerAndreas Rumpf <andreas@andi>2008-06-22 16:14:11 +0200
commit405b86068e6a3d39970b9129ceec0a9108464b28 (patch)
treec0449946f54baae6ea88baf453157ddd7faa8f86 /tests/titer.nim
downloadNim-405b86068e6a3d39970b9129ceec0a9108464b28.tar.gz
Initial import
Diffstat (limited to 'tests/titer.nim')
-rwxr-xr-xtests/titer.nim39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/titer.nim b/tests/titer.nim
new file mode 100755
index 000000000..736ba3155
--- /dev/null
+++ b/tests/titer.nim
@@ -0,0 +1,39 @@
+# Test the new iterators

+

+import

+  io

+

+iterator xrange(fromm, to: int, step = 1): (a: int) =

+  a = fromm

+  while a <= to:

+    yield a

+    inc(a, step)

+

+iterator interval[T](a, b: T): (x: T)

+

+iterator interval[T](a, b: T): (x: T) =

+  x = a

+  while x <= b:

+    yield x

+    inc(x)

+

+#

+#iterator lines(filename: string): (line: string) =

+#  var

+#    f: tTextfile

+#    shouldClose = open(f, filename)

+#  if shouldClose:

+#    setSpace(line, 256)

+#    while readTextLine(f, line):

+#      yield line

+#  finally:

+#    if shouldClose: close(f)

+#

+

+for i in xrange(0, 5):

+  for k in xrange(1, 7):

+    write(stdout, "test")

+

+for j in interval(45, 45):

+  write(stdout, "test2!")

+  write(stdout, "test3?")