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.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/test/run_tests.cpp b/test/run_tests.cpp
index 4a58f6df02..7bbe6be97b 100644
--- a/test/run_tests.cpp
+++ b/test/run_tests.cpp
@@ -355,6 +355,48 @@ done:
exit(0);
}
)SOURCE", "zero\nloop\nloop\nloop\n");
+
+ add_simple_case("arrays", R"SOURCE(
+#link("c")
+extern {
+ fn puts(s: *const u8) -> i32;
+ fn exit(code: i32) -> unreachable;
+}
+
+export fn _start() -> unreachable {
+ let mut array : [i32; 5];
+
+ let mut i = 0;
+loop_start:
+ if i == 5 {
+ goto loop_end;
+ }
+ array[i] = i + 1;
+ i = array[i];
+ goto loop_start;
+
+loop_end:
+
+ i = 0;
+ let mut accumulator = 0;
+loop_2_start:
+ if i == 5 {
+ goto loop_2_end;
+ }
+
+ accumulator = accumulator + array[i];
+
+ i = i + 1;
+ goto loop_2_start;
+loop_2_end:
+
+ if accumulator == 15 {
+ puts("OK");
+ }
+
+ exit(0);
+}
+ )SOURCE", "OK\n");
}
static void add_compile_failure_test_cases(void) {