zig/test/behavior/bugs/656.zig
Luuk de Gram 0682c9ac33
wasm: Implement genTypedValue for enums
This makes all union test cases succeed.
`rem` was also implemented as all we had to do is enable the instruction.
Loading and storing values based on ABI-size was simplified to a direct abiSize() call.

We also enabled all the newly passing test cases and disable them for all non-passing backends.
All of those test cases were verified to see if they perhaps already pass for the c-backend.
2022-01-25 19:29:40 +01:00

35 lines
897 B
Zig

const expect = @import("std").testing.expect;
const builtin = @import("builtin");
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" {
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
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 => {},
}
}
}