summary refs log tree commit diff stats
path: root/tests/tlowhigh.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/tlowhigh.nim')
-rwxr-xr-xtests/tlowhigh.nim21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/tlowhigh.nim b/tests/tlowhigh.nim
new file mode 100755
index 000000000..6553da2b5
--- /dev/null
+++ b/tests/tlowhigh.nim
@@ -0,0 +1,21 @@
+# Test the magic low() and high() procs

+

+import

+  io

+

+type

+  myEnum = enum e1, e2, e3, e4, e5

+

+var

+  a: array [myEnum, int]

+

+for i in low(a) .. high(a):

+  a[i] = 0

+

+proc sum(a: openarray[int]): int =

+  result = 0

+  for i in low(a)..high(a):

+    inc(result, a[i])

+

+write(stdout, sum([1, 2, 3, 4]))

+#OUT 10