| ... | @@ -1801,19 +1801,21 @@ test "zig fmt: array literal with hint" { | ... | @@ -1801,19 +1801,21 @@ test "zig fmt: array literal with hint" { |
| 1801 | ); | 1801 | ); |
| 1802 | } | 1802 | } |
| 1803 | | 1803 | |
| 1804 | test "zig fmt: array literal veritical column alignment" { | 1804 | test "zig fmt: array literal vertical column alignment" { |
| 1805 | try testTransform( | 1805 | try testTransform( |
| 1806 | \\const a = []u8{ | 1806 | \\const a = []u8{ |
| 1807 | \\ 1000, 200, | 1807 | \\ 1000, 200, |
| 1808 | \\ 30, 4, | 1808 | \\ 30, 4, |
| 1809 | \\ 50000, 60 | 1809 | \\ 50000, 60, |
| 1810 | \\}; | 1810 | \\}; |
| 1811 | \\const a = []u8{0, 1, 2, 3, 40, | 1811 | \\const a = []u8{0, 1, 2, 3, 40, |
| 1812 | \\ 4,5,600,7, | 1812 | \\ 4,5,600,7, |
| 1813 | \\ 80, | 1813 | \\ 80, |
| 1814 | \\ 9, 10, 11, 0, 13, 14, 15}; | 1814 | \\ 9, 10, 11, 0, 13, 14, 15,}; |
| 1815 | \\const a = [12]u8{ | 1815 | \\const a = [12]u8{ |
| 1816 | \\ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; | 1816 | \\ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; |
| | 1817 | \\const a = [12]u8{ |
| | 1818 | \\ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, }; |
| 1817 | \\ | 1819 | \\ |
| 1818 | , | 1820 | , |
| 1819 | \\const a = []u8{ | 1821 | \\const a = []u8{ |
| ... | @@ -1827,8 +1829,20 @@ test "zig fmt: array literal veritical column alignment" { | ... | @@ -1827,8 +1829,20 @@ test "zig fmt: array literal veritical column alignment" { |
| 1827 | \\ 9, 10, 11, 0, 13, | 1829 | \\ 9, 10, 11, 0, 13, |
| 1828 | \\ 14, 15, | 1830 | \\ 14, 15, |
| 1829 | \\}; | 1831 | \\}; |
| | 1832 | \\const a = [12]u8{ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; |
| 1830 | \\const a = [12]u8{ | 1833 | \\const a = [12]u8{ |
| 1831 | \\ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, | 1834 | \\ 31, |
| | 1835 | \\ 28, |
| | 1836 | \\ 31, |
| | 1837 | \\ 30, |
| | 1838 | \\ 31, |
| | 1839 | \\ 30, |
| | 1840 | \\ 31, |
| | 1841 | \\ 31, |
| | 1842 | \\ 30, |
| | 1843 | \\ 31, |
| | 1844 | \\ 30, |
| | 1845 | \\ 31, |
| 1832 | \\}; | 1846 | \\}; |
| 1833 | \\ | 1847 | \\ |
| 1834 | ); | 1848 | ); |
| ... | @@ -2031,10 +2045,7 @@ test "zig fmt: add trailing comma to array literal" { | ... | @@ -2031,10 +2045,7 @@ test "zig fmt: add trailing comma to array literal" { |
| 2031 | \\ return []u16{ | 2045 | \\ return []u16{ |
| 2032 | \\ 'm', 's', 'y', 's', '-', // hi | 2046 | \\ 'm', 's', 'y', 's', '-', // hi |
| 2033 | \\ }; | 2047 | \\ }; |
| 2034 | \\ return []u16{ | 2048 | \\ return []u16{ 'm', 's', 'y', 's', '-' }; |
| 2035 | \\ 'm', 's', 'y', 's', | | |
| 2036 | \\ '-', | | |
| 2037 | \\ }; | | |
| 2038 | \\ return []u16{ 'm', 's', 'y', 's', '-' }; | 2049 | \\ return []u16{ 'm', 's', 'y', 's', '-' }; |
| 2039 | \\} | 2050 | \\} |
| 2040 | \\ | 2051 | \\ |
| ... | @@ -4666,6 +4677,53 @@ test "zig fmt: insert trailing comma if there are comments between switch values | ... | @@ -4666,6 +4677,53 @@ test "zig fmt: insert trailing comma if there are comments between switch values |
| 4666 | ); | 4677 | ); |
| 4667 | } | 4678 | } |
| 4668 | | 4679 | |
| | 4680 | test "zig fmt: make single-line if no trailing comma" { |
| | 4681 | try testTransform( |
| | 4682 | \\test "function call no trailing comma" { |
| | 4683 | \\ foo( |
| | 4684 | \\ 1, |
| | 4685 | \\ 2 |
| | 4686 | \\ ); |
| | 4687 | \\} |
| | 4688 | \\ |
| | 4689 | , |
| | 4690 | \\test "function call no trailing comma" { |
| | 4691 | \\ foo(1, 2); |
| | 4692 | \\} |
| | 4693 | \\ |
| | 4694 | ); |
| | 4695 | |
| | 4696 | try testTransform( |
| | 4697 | \\test "struct no trailing comma" { |
| | 4698 | \\ const a = .{ |
| | 4699 | \\ .foo = 1, |
| | 4700 | \\ .bar = 2 |
| | 4701 | \\ }; |
| | 4702 | \\} |
| | 4703 | \\ |
| | 4704 | , |
| | 4705 | \\test "struct no trailing comma" { |
| | 4706 | \\ const a = .{ .foo = 1, .bar = 2 }; |
| | 4707 | \\} |
| | 4708 | \\ |
| | 4709 | ); |
| | 4710 | |
| | 4711 | try testTransform( |
| | 4712 | \\test "array no trailing comma" { |
| | 4713 | \\ var stream = multiOutStream(.{ |
| | 4714 | \\ fbs1.outStream(), |
| | 4715 | \\ fbs2.outStream() |
| | 4716 | \\ }); |
| | 4717 | \\} |
| | 4718 | \\ |
| | 4719 | , |
| | 4720 | \\test "array no trailing comma" { |
| | 4721 | \\ var stream = multiOutStream(.{ fbs1.outStream(), fbs2.outStream() }); |
| | 4722 | \\} |
| | 4723 | \\ |
| | 4724 | ); |
| | 4725 | } |
| | 4726 | |
| 4669 | test "zig fmt: error for invalid bit range" { | 4727 | test "zig fmt: error for invalid bit range" { |
| 4670 | try testError( | 4728 | try testError( |
| 4671 | \\var x: []align(0:0:0)u8 = bar; | 4729 | \\var x: []align(0:0:0)u8 = bar; |