diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2016-12-21 21:49:05 -0500 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2016-12-21 21:49:05 -0500 |
| commit | 9b616820370c08a97d95805ca31eae5f8ca554f3 (patch) | |
| tree | 02156ccb1d8a72c747a08b4312820e5ab649cdfa /test | |
| parent | 1f6dacbb2f9a91a20309b271a31e781f11f81819 (diff) | |
| download | zig-9b616820370c08a97d95805ca31eae5f8ca554f3.tar.gz zig-9b616820370c08a97d95805ca31eae5f8ca554f3.zip | |
IR: implement runtime enum init and switch on enum with variable
Diffstat (limited to 'test')
| -rw-r--r-- | test/cases3/enum.zig | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/test/cases3/enum.zig b/test/cases3/enum.zig index e588a19091..9c89414958 100644 --- a/test/cases3/enum.zig +++ b/test/cases3/enum.zig @@ -12,6 +12,16 @@ fn enumType() { assert(@sizeOf(Foo) == expected_foo_size); assert(@sizeOf(Bar) == 1); } + +fn enumAsReturnValue () { + @setFnTest(this); + + switch (returnAnInt(13)) { + Foo.One => |value| assert(value == 13), + else => @unreachable(), + } +} + const Point = struct { x: u64, y: u64, @@ -28,6 +38,11 @@ const Bar = enum { D, }; +fn returnAnInt(x: i32) -> Foo { + Foo.One { x } +} + + fn assert(ok: bool) { if (!ok) @unreachable(); |
