mirror of
https://github.com/ziglang/zig.git
synced 2024-11-15 16:45:27 +00:00
5619ce2406
Conflicts: * doc/langref.html.in * lib/std/enums.zig * lib/std/fmt.zig * lib/std/hash/auto_hash.zig * lib/std/math.zig * lib/std/mem.zig * lib/std/meta.zig * test/behavior/alignof.zig * test/behavior/bitcast.zig * test/behavior/bugs/1421.zig * test/behavior/cast.zig * test/behavior/ptrcast.zig * test/behavior/type_info.zig * test/behavior/vector.zig Master branch added `try` to a bunch of testing function calls, and some lines also had changed how to refer to the native architecture and other `@import("builtin")` stuff.
32 lines
718 B
Zig
32 lines
718 B
Zig
const expect = @import("std").testing.expect;
|
|
|
|
const PrefixOp = union(enum) {
|
|
Return,
|
|
AddrOf: Value,
|
|
};
|
|
|
|
const Value = struct {
|
|
align_expr: ?u32,
|
|
};
|
|
|
|
test "optional if after an if in a switch prong of a switch with 2 prongs in an else" {
|
|
try foo(false, true);
|
|
}
|
|
|
|
fn foo(a: bool, b: bool) !void {
|
|
var prefix_op = PrefixOp{
|
|
.AddrOf = Value{ .align_expr = 1234 },
|
|
};
|
|
if (a) {} else {
|
|
switch (prefix_op) {
|
|
PrefixOp.AddrOf => |addr_of_info| {
|
|
if (b) {}
|
|
if (addr_of_info.align_expr) |align_expr| {
|
|
try expect(align_expr == 1234);
|
|
}
|
|
},
|
|
PrefixOp.Return => {},
|
|
}
|
|
}
|
|
}
|