zig/test/behavior/bugs/1120.zig
Andrew Kelley f27d3409bd behavior tests: disable failing stage1 test
My previous commit added a new behavior test that passes for stage2 but
I forgot to check whether it passes for stage1. Since it does not, it
has to be disabled.

Additionally, this commit organizes behavior tests; there is no longer a
section of tests only passing for stage1. Instead, tests are disabled on
an individual basis. There is an except for the file which has global
assembly in it.
2022-03-23 14:06:07 -07:00

26 lines
511 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" {
if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO
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,
};
try expect(ptr.* == 2);
}