| ... | @@ -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 | } |
| 4741 | | 4741 | |
| | 4742 | test "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 | |
| 4742 | test "zig fmt: insert trailing comma if there are comments between switch values" { | 4762 | test "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) { |