authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-11-11 11:14:45-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-11-11 13:12:21-05:00
logb4ad3e71af77b2be4467d67b64c721adfe86ac17
treea3d49f817decc14cc7d87c926bfd9e12800b79ff
parent5b279434986b18d07ceec217c5c402a589ccc0b4
signaturelock-open Commit is signed but in an unrecognized format.

add behavior test case for anon union literal


1 files changed, 18 insertions(+), 0 deletions(-)

test/stage1/behavior/union.zig+18
......@@ -549,3 +549,21 @@ test "initialize global array of union" {
549549 expect(glbl_array[0].U0 == 1);
550550 expect(glbl_array[1].U1 == 2);
551551}
552
553test "anonymous union literal syntax" {
554 const S = struct {
555 const Number = union {
556 int: i32,
557 float: f64,
558 };
559
560 fn doTheTest() void {
561 var i: Number = .{.int = 42};
562 var f: Number = .{.float = 12.34};
563 expect(i.int == 42);
564 expect(f.float == 12.34);
565 }
566 };
567 S.doTheTest();
568 comptime S.doTheTest();
569}