diff options
| author | Veikka Tuominen <git@vexu.eu> | 2024-01-02 17:33:41 +0200 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2024-01-06 16:49:41 -0800 |
| commit | 804cee3b93cb7084c16ee61d3bcb57f7d3c9f0bc (patch) | |
| tree | 3d8c534b1adc352b248255ef2906ef2bdf11dffc /test/behavior/switch.zig | |
| parent | 282ff8d3bd4a0d870a98f145aa87039e0409b745 (diff) | |
| download | zig-804cee3b93cb7084c16ee61d3bcb57f7d3c9f0bc.tar.gz zig-804cee3b93cb7084c16ee61d3bcb57f7d3c9f0bc.zip | |
categorize `behavior/bugs/<issueno>.zig` tests
Diffstat (limited to 'test/behavior/switch.zig')
| -rw-r--r-- | test/behavior/switch.zig | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/behavior/switch.zig b/test/behavior/switch.zig index ae4923609f..353146e50e 100644 --- a/test/behavior/switch.zig +++ b/test/behavior/switch.zig @@ -831,3 +831,22 @@ test "peer type resolution on switch captures ignores unused payload bits" { try expect(x == 123); } + +test "switch prong captures range" { + if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO + if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO + + const S = struct { + fn a(b: []u3, c: u3) void { + switch (c) { + 0...1 => b[c] = c, + 2...3 => b[c] = c, + 4...7 => |d| b[d] = c, + } + } + }; + + var arr: [8]u3 = undefined; + S.a(&arr, 5); + try expect(arr[5] == 5); +} |
