aboutsummaryrefslogtreecommitdiff
path: root/test/cases
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2017-11-15 22:52:47 -0500
committerAndrew Kelley <superjoe30@gmail.com>2017-11-15 22:52:47 -0500
commit018cbff438cedc19d0ad18021619ec7ede997307 (patch)
treee21110319947f172100bda3b62685d2857c1fcdb /test/cases
parentf276fd0f3728bf1a43b185e3e2d33d593309cb2f (diff)
downloadzig-018cbff438cedc19d0ad18021619ec7ede997307.tar.gz
zig-018cbff438cedc19d0ad18021619ec7ede997307.zip
unions have a secret field for the type
See #144
Diffstat (limited to 'test/cases')
-rw-r--r--test/cases/union.zig13
1 files changed, 13 insertions, 0 deletions
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);
+}