aboutsummaryrefslogtreecommitdiff
path: root/test/run_tests.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2016-01-02 19:47:36 -0700
committerAndrew Kelley <superjoe30@gmail.com>2016-01-02 19:47:36 -0700
commit187d00ca835d2c923cbc0a3ab9e861e82888d403 (patch)
tree923b224c44e801b3d6bb9e8a2432d216c1f7e6d6 /test/run_tests.cpp
parent968b85ad77892da945d478799d4e775222248f1f (diff)
downloadzig-187d00ca835d2c923cbc0a3ab9e861e82888d403.tar.gz
zig-187d00ca835d2c923cbc0a3ab9e861e82888d403.zip
ability to access pointers with array indexing syntax
closes #40
Diffstat (limited to 'test/run_tests.cpp')
-rw-r--r--test/run_tests.cpp34
1 files changed, 12 insertions, 22 deletions
diff --git a/test/run_tests.cpp b/test/run_tests.cpp
index 973c158705..839109a1ab 100644
--- a/test/run_tests.cpp
+++ b/test/run_tests.cpp
@@ -319,31 +319,21 @@ done:
use "std.zig";
pub fn main(argc: isize, argv: &&u8, env: &&u8) -> i32 {
- var array : [i32; 5];
+ var array : [u32; 5];
- var i : i32 = 0;
-loop_start:
- if (i == 5) {
- goto loop_end;
+ var i : u32 = 0;
+ while (i < 5) {
+ array[i] = i + 1;
+ i = array[i];
}
- array[i] = i + 1;
- i = array[i];
- goto loop_start;
-
-loop_end:
i = 0;
- var accumulator = 0 as i32;
-loop_2_start:
- if (i == 5) {
- goto loop_2_end;
- }
+ var accumulator = 0 as u32;
+ while (i < 5) {
+ accumulator += array[i];
- accumulator = accumulator + array[i];
-
- i = i + 1;
- goto loop_2_start;
-loop_2_end:
+ i += 1;
+ }
if (accumulator == 15) {
print_str("OK\n");
@@ -871,9 +861,9 @@ fn f() {
".tmp_source.zig:4:12: error: use of undeclared identifier 'i'",
".tmp_source.zig:4:14: error: use of undeclared identifier 'i'",
".tmp_source.zig:5:8: error: array access of non-array",
- ".tmp_source.zig:5:8: error: array subscripts must be integers",
+ ".tmp_source.zig:5:9: error: expected type 'usize', got 'bool'",
".tmp_source.zig:5:19: error: array access of non-array",
- ".tmp_source.zig:5:19: error: array subscripts must be integers");
+ ".tmp_source.zig:5:20: error: expected type 'usize', got 'bool'");
add_compile_fail_case("variadic functions only allowed in extern", R"SOURCE(
fn f(...) {}