aboutsummaryrefslogtreecommitdiff
path: root/test/run_tests.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/run_tests.cpp')
-rw-r--r--test/run_tests.cpp28
1 files changed, 27 insertions, 1 deletions
diff --git a/test/run_tests.cpp b/test/run_tests.cpp
index f416beb311..f7bb20038e 100644
--- a/test/run_tests.cpp
+++ b/test/run_tests.cpp
@@ -1136,6 +1136,32 @@ pub fn main(args: [][]u8) i32 => {
return 0;
}
)SOURCE", "hello\nthis\nis\nmy\nthing\n");
+
+ add_simple_case("for loops", R"SOURCE(
+import "std.zig";
+
+pub fn main(args: [][]u8) i32 => {
+ const array = []u8 {9, 8, 7, 6};
+ for (item, array) {
+ print_u64(item);
+ print_str("\n");
+ }
+ for (item, array, index) {
+ print_u64(index);
+ print_str("\n");
+ }
+ const unknown_size: []u8 = array;
+ for (item, unknown_size) {
+ print_u64(item);
+ print_str("\n");
+ }
+ for (item, unknown_size, index) {
+ print_u64(index);
+ print_str("\n");
+ }
+ return 0;
+}
+ )SOURCE", "9\n8\n7\n6\n0\n1\n2\n3\n9\n8\n7\n6\n0\n1\n2\n3\n");
}
@@ -1226,7 +1252,7 @@ fn b() => {}
add_compile_fail_case("parameter redeclaration", R"SOURCE(
fn f(a : i32, a : i32) => {
}
- )SOURCE", 1, ".tmp_source.zig:2:1: error: redeclaration of parameter 'a'");
+ )SOURCE", 1, ".tmp_source.zig:2:15: error: redeclaration of variable 'a'");
add_compile_fail_case("local variable redeclaration", R"SOURCE(
fn f() => {