mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-04-27 19:09:47 +03:00
categorize behavior/bugs/<issueno>.zig tests
This commit is contained in:
committed by
Andrew Kelley
parent
282ff8d3bd
commit
804cee3b93
@@ -367,3 +367,37 @@ test "while loop with comptime true condition needs no else block to return valu
|
||||
};
|
||||
try expect(x == 69);
|
||||
}
|
||||
|
||||
test "int returned from switch in while" {
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
|
||||
var x: u32 = 3;
|
||||
const val: usize = while (true) switch (x) {
|
||||
1 => break 2,
|
||||
else => x -= 1,
|
||||
};
|
||||
try std.testing.expect(val == 2);
|
||||
}
|
||||
|
||||
test "breaking from a loop in an if statement" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
|
||||
const S = struct {
|
||||
fn retOpt() ?u32 {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
var cond = true;
|
||||
_ = &cond;
|
||||
const opt = while (cond) {
|
||||
if (S.retOpt()) |opt| {
|
||||
break opt;
|
||||
}
|
||||
break 1;
|
||||
} else 2;
|
||||
_ = opt;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user