authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-09-28 16:55:42-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-09-28 17:04:19-07:00
log6cb7906394281370173cd1c1fc79ad93562005a0
tree8cc94d31e21e3ada1f62b6c85f85b99e93e178bd
parent51673bcb315d837ee0fe80dc50571c2c07d80a2c

add missing zig fmt test for saturating arithmetic


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

lib/std/zig/parser_test.zig+20
...@@ -4739,6 +4739,26 @@ test "zig fmt: assignment with inline for and inline while" {...@@ -4739,6 +4739,26 @@ test "zig fmt: assignment with inline for and inline while" {
4739 );4739 );
4740}4740}
47414741
4742test "zig fmt: saturating arithmetic" {
4743 try testCanonical(
4744 \\test {
4745 \\ const actual = switch (op) {
4746 \\ .add => a +| b,
4747 \\ .sub => a -| b,
4748 \\ .mul => a *| b,
4749 \\ .shl => a <<| b,
4750 \\ };
4751 \\ switch (op) {
4752 \\ .add => actual +|= b,
4753 \\ .sub => actual -|= b,
4754 \\ .mul => actual *|= b,
4755 \\ .shl => actual <<|= b,
4756 \\ }
4757 \\}
4758 \\
4759 );
4760}
4761
4742test "zig fmt: insert trailing comma if there are comments between switch values" {4762test "zig fmt: insert trailing comma if there are comments between switch values" {
4743 try testTransform(4763 try testTransform(
4744 \\const a = switch (b) {4764 \\const a = switch (b) {