summary refs log tree commit diff stats
path: root/tests/accept/run
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2011-04-23 17:11:24 +0200
committerAraq <rumpf_a@web.de>2011-04-23 17:11:24 +0200
commit4ba4999bb7b172b683cf7b8d574adbf04afa7527 (patch)
treef1216df68dba7abb0e9324afa11464db885800dd /tests/accept/run
parent05fee773ec48b5b45cdb7469a6c8410b59fcb542 (diff)
downloadNim-4ba4999bb7b172b683cf7b8d574adbf04afa7527.tar.gz
slice support in system.nim; syntactic sugar for tables; cleanup of grammar/parser
Diffstat (limited to 'tests/accept/run')
-rw-r--r--tests/accept/run/tslices.nim43
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/accept/run/tslices.nim b/tests/accept/run/tslices.nim
new file mode 100644
index 000000000..1061b4245
--- /dev/null
+++ b/tests/accept/run/tslices.nim
@@ -0,0 +1,43 @@
+discard """
+  file: "tslices.nim"
+  output: '''456456
+456456
+456456
+Zugr5nd
+'''
+"""
+
+# Test the new slices.
+
+import strutils
+
+var mystr = "Abgrund"
+mystr[..1] = "Zu"
+
+mystr[4..4] = "5"
+
+type
+  TEnum = enum e1, e2, e3, e4, e5, e6
+
+var myarr: array[TEnum, int] = [1, 2, 3, 4, 5, 6]
+myarr[e1..e3] = myarr[e4..e6]
+myarr[..e3] = myarr[e4..e6]
+
+for x in items(myarr): stdout.write(x)
+echo()
+
+var myarr2: array[0..5, int] = [1, 2, 3, 4, 5, 6]
+myarr2[0..2] = myarr2[3..5]
+
+for x in items(myarr2): stdout.write(x)
+echo()
+
+
+var myseq = @[1, 2, 3, 4, 5, 6]
+myseq[0..2] = myseq[-3.. -1]
+
+for x in items(myseq): stdout.write(x)
+echo()
+
+echo mystr
+