diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2021-08-07 20:34:28 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2021-08-07 20:34:28 -0700 |
| commit | 799fedf612aa8742c446b015c12d21707a1dbec0 (patch) | |
| tree | 1d9efbc4cb3f6dda9631160784a074e58d6bd479 /test/behavior/if.zig | |
| parent | f81b2531cb4904064446f84a06f6e09e4120e28a (diff) | |
| download | zig-799fedf612aa8742c446b015c12d21707a1dbec0.tar.gz zig-799fedf612aa8742c446b015c12d21707a1dbec0.zip | |
stage2: pass some error union tests
* Value: rename `error_union` to `eu_payload` and clarify the intended
usage in the doc comments. The way error unions is represented with
Value is fixed to not have ambiguous values.
* Fix codegen for error union constants in all the backends.
* Implement the AIR instructions having to do with error unions in the
LLVM backend.
Diffstat (limited to 'test/behavior/if.zig')
| -rw-r--r-- | test/behavior/if.zig | 42 |
1 files changed, 0 insertions, 42 deletions
diff --git a/test/behavior/if.zig b/test/behavior/if.zig index e8c84f4570..191d4817df 100644 --- a/test/behavior/if.zig +++ b/test/behavior/if.zig @@ -65,45 +65,3 @@ test "labeled break inside comptime if inside runtime if" { } try expect(answer == 42); } - -test "const result loc, runtime if cond, else unreachable" { - const Num = enum { - One, - Two, - }; - - var t = true; - const x = if (t) Num.Two else unreachable; - try expect(x == .Two); -} - -test "if prongs cast to expected type instead of peer type resolution" { - const S = struct { - fn doTheTest(f: bool) !void { - var x: i32 = 0; - x = if (f) 1 else 2; - try expect(x == 2); - - var b = true; - const y: i32 = if (b) 1 else 2; - try expect(y == 1); - } - }; - try S.doTheTest(false); - comptime try S.doTheTest(false); -} - -test "while copies its payload" { - const S = struct { - fn doTheTest() !void { - var tmp: ?i32 = 10; - if (tmp) |value| { - // Modify the original variable - tmp = null; - try expectEqual(@as(i32, 10), value); - } else unreachable; - } - }; - try S.doTheTest(); - comptime try S.doTheTest(); -} |
