aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2016-11-26 23:16:38 -0500
committerAndrew Kelley <superjoe30@gmail.com>2016-11-26 23:16:38 -0500
commita52ede6494d44865fcf05591eaf5715d8bd1dc4a (patch)
tree54d336044dce404d17283f01c4643f83afa0572f /test
parenta3db60b5d726004cbb5d7235893a3e148b493096 (diff)
downloadzig-a52ede6494d44865fcf05591eaf5715d8bd1dc4a.tar.gz
zig-a52ede6494d44865fcf05591eaf5715d8bd1dc4a.zip
IR: support goto and labels
Diffstat (limited to 'test')
-rw-r--r--test/self_hosted2.zig18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/self_hosted2.zig b/test/self_hosted2.zig
index 1f98ed686e..6b5d12ffd1 100644
--- a/test/self_hosted2.zig
+++ b/test/self_hosted2.zig
@@ -67,6 +67,23 @@ fn testNamespaceFnCall() {
assert(case_namespace_fn_call.foo() == 1234);
}
+fn gotoAndLabels() {
+ gotoLoop();
+ assert(goto_counter == 10);
+}
+fn gotoLoop() {
+ var i: i32 = 0;
+ goto cond;
+loop:
+ i += 1;
+cond:
+ if (!(i < 10)) goto end;
+ goto_counter += 1;
+ goto loop;
+end:
+}
+var goto_counter: i32 = 0;
+
fn assert(ok: bool) {
if (!ok)
@unreachable();
@@ -80,6 +97,7 @@ fn runAllTests() {
switchWithAllRanges();
testInlineSwitch();
testNamespaceFnCall();
+ gotoAndLabels();
}
export nakedcc fn _start() -> unreachable {