aboutsummaryrefslogtreecommitdiff
path: root/test/run_tests.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2016-01-07 05:29:11 -0700
committerAndrew Kelley <superjoe30@gmail.com>2016-01-07 05:29:11 -0700
commit9aea99a999997e223307d8559e0ff9fa613839a3 (patch)
tree241d9f8fc2b8225a4941bbf8b748170eb49411e7 /test/run_tests.cpp
parentea69d6ecda8412cf47b85853c8645d453c826427 (diff)
downloadzig-9aea99a999997e223307d8559e0ff9fa613839a3.tar.gz
zig-9aea99a999997e223307d8559e0ff9fa613839a3.zip
implement array slicing syntax
closes #52
Diffstat (limited to 'test/run_tests.cpp')
-rw-r--r--test/run_tests.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/run_tests.cpp b/test/run_tests.cpp
index 1038983d2e..71158e9327 100644
--- a/test/run_tests.cpp
+++ b/test/run_tests.cpp
@@ -907,6 +907,35 @@ pub fn main(argc: isize, argv: &&u8, env: &&u8) -> i32 {
"min i16: -32768\n"
"min i32: -2147483648\n"
"min i64: -9223372036854775808\n");
+
+
+ add_simple_case("slicing", R"SOURCE(
+use "std.zig";
+pub fn main(argc: isize, argv: &&u8, env: &&u8) -> i32 {
+ var array : [20]i32;
+
+ array[5] = 1234;
+
+ var slice = array[5...10];
+
+ if (slice.len != 5) {
+ print_str("BAD\n");
+ }
+
+ if (slice.ptr[0] != 1234) {
+ print_str("BAD\n");
+ }
+
+ var slice_rest = array[10...];
+ if (slice_rest.len != 10) {
+ print_str("BAD\n");
+ }
+
+ print_str("OK\n");
+ return 0;
+}
+ )SOURCE", "OK\n");
+
}
////////////////////////////////////////////////////////////////////////////////////