zig/test/behavior/underscore.zig

31 lines
600 B
Zig
Raw Normal View History

const std = @import("std");
const expect = std.testing.expect;
test "ignore lval with underscore" {
_ = false;
}
test "ignore lval with underscore (for loop)" {
for ([_]void{}) |_, i| {
2021-06-20 02:10:22 +01:00
_ = i;
for ([_]void{}) |_, j| {
2021-06-20 02:10:22 +01:00
_ = j;
break;
}
break;
}
}
test "ignore lval with underscore (while loop)" {
while (optionalReturnError()) |_| {
while (optionalReturnError()) |_| {
break;
} else |_| {}
break;
} else |_| {}
}
fn optionalReturnError() !?u32 {
return error.optionalReturnError;
}