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

20 lines
411 B
Zig

const std = @import("std");
const B = union(enum) {
c: C,
None,
};
const A = struct {
b: B,
};
const C = struct {};
test "tagged union with all void fields but a meaningful tag" {
var a: A = A{ .b = B{ .c = C{} } };
std.testing.expect(@as(std.meta.Tag(B), a.b) == std.meta.Tag(B).c);
a = A{ .b = B.None };
std.testing.expect(@as(std.meta.Tag(B), a.b) == std.meta.Tag(B).None);
}