zig/test/behavior/bugs/1381.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

25 lines
516 B
Zig

const std = @import("std");
const builtin = @import("builtin");
const B = union(enum) {
D: u8,
E: u16,
};
const A = union(enum) {
B: B,
C: u8,
};
test "union that needs padding bytes inside an array" {
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
var as = [_]A{
A{ .B = B{ .D = 1 } },
A{ .B = B{ .D = 1 } },
};
const a = as[0].B;
try std.testing.expect(a.D == 1);
}