zig/test/behavior/bugs/1120.zig
Andrew Kelley 4307436b99 move behavior tests from test/stage1/ to test/
And fix test cases to make them pass. This is in preparation for
starting to pass behavior tests with self-hosted.
2021-04-29 15:54:04 -07:00

24 lines
421 B
Zig

const std = @import("std");
const expect = std.testing.expect;
const A = packed struct {
a: u2,
b: u6,
};
const B = packed struct {
q: u8,
a: u2,
b: u6,
};
test "bug 1120" {
var a = A{ .a = 2, .b = 2 };
var b = B{ .q = 22, .a = 3, .b = 2 };
var t: usize = 0;
const ptr = switch (t) {
0 => &a.a,
1 => &b.a,
else => unreachable,
};
expect(ptr.* == 2);
}