diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2016-02-04 15:26:27 -0700 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2016-02-04 15:26:27 -0700 |
| commit | fcbeaddbb2321cd1006e0e007144b0f116de80be (patch) | |
| tree | 155c3ea33cc38157b62b131833144b87aa08f1a7 /test | |
| parent | b87d0abefeeeed4d9ce981971a5e33a6d0932529 (diff) | |
| download | zig-fcbeaddbb2321cd1006e0e007144b0f116de80be.tar.gz zig-fcbeaddbb2321cd1006e0e007144b0f116de80be.zip | |
codegen: fix switch expressions for enums with payloads
Diffstat (limited to 'test')
| -rw-r--r-- | test/self_hosted.zig | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/test/self_hosted.zig b/test/self_hosted.zig index 048b820ec9..645726c657 100644 --- a/test/self_hosted.zig +++ b/test/self_hosted.zig @@ -51,16 +51,24 @@ error SecondError; #attribute("test") fn constant_enum_with_payload() { - should_be_empty(AnEnumWithPayload.Empty); - should_be_not_empty(AnEnumWithPayload.Full(13)); + var empty = AnEnumWithPayload.Empty; + var full = AnEnumWithPayload.Full(13); + should_be_empty(empty); + should_be_not_empty(full); } fn should_be_empty(x: AnEnumWithPayload) { - if (x != AnEnumWithPayload.Empty) unreachable{} + switch (x) { + AnEnumWithPayload.Empty => {}, + else => unreachable{}, + } } fn should_be_not_empty(x: AnEnumWithPayload) { - if (x == AnEnumWithPayload.Empty) unreachable{} + switch (x) { + AnEnumWithPayload.Empty => unreachable{}, + else => {}, + } } enum AnEnumWithPayload { |
