IR: port more tests
This commit is contained in:
@@ -31,6 +31,50 @@ fn staticWhileLoop2() -> i32 {
|
||||
}
|
||||
}
|
||||
|
||||
fn continueAndBreak() {
|
||||
@setFnTest(this);
|
||||
|
||||
runContinueAndBreakTest();
|
||||
assert(continue_and_break_counter == 8);
|
||||
}
|
||||
var continue_and_break_counter: i32 = 0;
|
||||
fn runContinueAndBreakTest() {
|
||||
var i : i32 = 0;
|
||||
while (true) {
|
||||
continue_and_break_counter += 2;
|
||||
i += 1;
|
||||
if (i < 4) {
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
assert(i == 4);
|
||||
}
|
||||
|
||||
fn returnWithImplicitCastFromWhileLoop() {
|
||||
@setFnTest(this);
|
||||
|
||||
%%returnWithImplicitCastFromWhileLoopTest();
|
||||
}
|
||||
fn returnWithImplicitCastFromWhileLoopTest() -> %void {
|
||||
while (true) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
fn whileWithContinueExpr() {
|
||||
@setFnTest(this);
|
||||
|
||||
var sum: i32 = 0;
|
||||
{var i: i32 = 0; while (i < 10; i += 1) {
|
||||
if (i == 5) continue;
|
||||
sum += i;
|
||||
}}
|
||||
assert(sum == 40);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// TODO const assert = @import("std").debug.assert;
|
||||
fn assert(ok: bool) {
|
||||
if (!ok)
|
||||
|
||||
Reference in New Issue
Block a user