From 018cbff438cedc19d0ad18021619ec7ede997307 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Wed, 15 Nov 2017 22:52:47 -0500 Subject: unions have a secret field for the type See #144 --- test/cases/union.zig | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'test') diff --git a/test/cases/union.zig b/test/cases/union.zig index 74bda8db6a..377374c157 100644 --- a/test/cases/union.zig +++ b/test/cases/union.zig @@ -44,3 +44,16 @@ test "basic unions" { foo.float = 12.34; assert(foo.float == 12.34); } + + +const FooExtern = extern union { + float: f64, + int: i32, +}; + +test "basic extern unions" { + var foo = FooExtern { .int = 1 }; + assert(foo.int == 1); + foo.float = 12.34; + assert(foo.float == 12.34); +} -- cgit v1.2.3