authorgravatar for xtex@astrafall.orgxtex <xtex@astrafall.org> 2026-09-08 21:01:31+08:00
committergravatar for xtex@astrafall.orgxtex <xtex@astrafall.org> 2026-10-03 15:21:28+08:00
logadba66435502f0ac7f9cafe610f82960a53997da
tree6867fa8c6abeb493871cbe4a94787022fb80ef83
parentd81bdd8ab9092b844c974d0ab6dfe150cbf18f8d
signature Signed by SSH key SHA256:IEYEjkZlkUTr5U9GiDAmZU/4eZus2t2RsxusyhQqwao

test: add regression test for #36732


1 files changed, 13 insertions(+), 0 deletions(-)

test/behavior/switch.zig+13
...@@ -1568,3 +1568,16 @@ test "union field pointer capture preserves alignment in inline prong" {...@@ -1568,3 +1568,16 @@ test "union field pointer capture preserves alignment in inline prong" {
1568 try comptime U.doTheTest(&.{ .a = 123 });1568 try comptime U.doTheTest(&.{ .a = 123 });
1569 try comptime U.doTheTest(&.{ .b = 123 });1569 try comptime U.doTheTest(&.{ .b = 123 });
1570}1570}
1571
1572test "switch on expression" {
1573 var a: []const []const u8 = &.{ "b", "b", "A", "A", "b" };
1574 _ = &a;
1575 var c: isize = 0;
1576 for (a[1..]) |b| {
1577 switch (b[0] % 2) {
1578 0 => c += 1,
1579 else => c -= 1,
1580 }
1581 }
1582 try expect(c == 0);
1583}