diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2018-05-03 23:02:33 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-05-03 23:02:33 -0400 |
| commit | b9e320dd521751663db7b040e65c8ff5420c824a (patch) | |
| tree | 2c4161ebf8d1997ea45926af86301d64a960484c /test/cases/union.zig | |
| parent | aa2586de182e5587c924740e80468c4c4d509500 (diff) | |
| parent | 849ea61fa11460b1a6df2529063a6b0cabc6e5e4 (diff) | |
| download | zig-b9e320dd521751663db7b040e65c8ff5420c824a.tar.gz zig-b9e320dd521751663db7b040e65c8ff5420c824a.zip | |
Merge pull request #951 from alexnask/reflect_reify
Metaprogramming - @typeInfo [DONE]
Diffstat (limited to 'test/cases/union.zig')
| -rw-r--r-- | test/cases/union.zig | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/test/cases/union.zig b/test/cases/union.zig index dc2a7c3414..e7d9c23d77 100644 --- a/test/cases/union.zig +++ b/test/cases/union.zig @@ -45,6 +45,16 @@ test "basic unions" { assert(foo.float == 12.34); } +test "comptime union field access" { + comptime { + var foo = Foo { .int = 0 }; + assert(foo.int == 0); + + foo = Foo { .float = 42.42 }; + assert(foo.float == 42.42); + } +} + test "init union with runtime value" { var foo: Foo = undefined; |
