| ... | ... | @@ -1655,112 +1655,110 @@ test "zig fmt: struct literal containing a multiline expression" { |
| 1655 | 1655 | ); |
| 1656 | 1656 | } |
| 1657 | 1657 | |
| 1658 | | //test "zig fmt: array literal with hint" { |
| 1659 | | // try testTransform( |
| 1660 | | // \\const a = []u8{ |
| 1661 | | // \\ 1, 2, // |
| 1662 | | // \\ 3, |
| 1663 | | // \\ 4, |
| 1664 | | // \\ 5, |
| 1665 | | // \\ 6, |
| 1666 | | // \\ 7 }; |
| 1667 | | // \\const a = []u8{ |
| 1668 | | // \\ 1, 2, // |
| 1669 | | // \\ 3, |
| 1670 | | // \\ 4, |
| 1671 | | // \\ 5, |
| 1672 | | // \\ 6, |
| 1673 | | // \\ 7, 8 }; |
| 1674 | | // \\const a = []u8{ |
| 1675 | | // \\ 1, 2, // |
| 1676 | | // \\ 3, |
| 1677 | | // \\ 4, |
| 1678 | | // \\ 5, |
| 1679 | | // \\ 6, // blah |
| 1680 | | // \\ 7, 8 }; |
| 1681 | | // \\const a = []u8{ |
| 1682 | | // \\ 1, 2, // |
| 1683 | | // \\ 3, // |
| 1684 | | // \\ 4, |
| 1685 | | // \\ 5, |
| 1686 | | // \\ 6, |
| 1687 | | // \\ 7 }; |
| 1688 | | // \\const a = []u8{ |
| 1689 | | // \\ 1, |
| 1690 | | // \\ 2, |
| 1691 | | // \\ 3, 4, // |
| 1692 | | // \\ 5, 6, // |
| 1693 | | // \\ 7, 8, // |
| 1694 | | // \\}; |
| 1695 | | // , |
| 1696 | | // \\const a = []u8{ |
| 1697 | | // \\ 1, 2, |
| 1698 | | // \\ 3, 4, |
| 1699 | | // \\ 5, 6, |
| 1700 | | // \\ 7, |
| 1701 | | // \\}; |
| 1702 | | // \\const a = []u8{ |
| 1703 | | // \\ 1, 2, |
| 1704 | | // \\ 3, 4, |
| 1705 | | // \\ 5, 6, |
| 1706 | | // \\ 7, 8, |
| 1707 | | // \\}; |
| 1708 | | // \\const a = []u8{ |
| 1709 | | // \\ 1, 2, |
| 1710 | | // \\ 3, 4, |
| 1711 | | // \\ 5, |
| 1712 | | // \\ 6, // blah |
| 1713 | | // \\ 7, |
| 1714 | | // \\ 8, |
| 1715 | | // \\}; |
| 1716 | | // \\const a = []u8{ |
| 1717 | | // \\ 1, 2, |
| 1718 | | // \\ 3, // |
| 1719 | | // \\ 4, |
| 1720 | | // \\ 5, 6, |
| 1721 | | // \\ 7, |
| 1722 | | // \\}; |
| 1723 | | // \\const a = []u8{ |
| 1724 | | // \\ 1, |
| 1725 | | // \\ 2, |
| 1726 | | // \\ 3, |
| 1727 | | // \\ 4, |
| 1728 | | // \\ 5, |
| 1729 | | // \\ 6, |
| 1730 | | // \\ 7, |
| 1731 | | // \\ 8, |
| 1732 | | // \\}; |
| 1733 | | // \\ |
| 1734 | | // ); |
| 1735 | | //} |
| 1736 | | // |
| 1737 | | //test "zig fmt: array literal veritical column alignment" { |
| 1738 | | // try testTransform( |
| 1739 | | // \\const a = []u8{ |
| 1740 | | // \\ 1000, 200, |
| 1741 | | // \\ 30, 4, |
| 1742 | | // \\ 50000, 60 |
| 1743 | | // \\}; |
| 1744 | | // \\const a = []u8{0, 1, 2, 3, 40, |
| 1745 | | // \\ 4,5,600,7, |
| 1746 | | // \\ 80, |
| 1747 | | // \\ 9, 10, 11, 0, 13, 14, 15}; |
| 1748 | | // \\ |
| 1749 | | // , |
| 1750 | | // \\const a = []u8{ |
| 1751 | | // \\ 1000, 200, |
| 1752 | | // \\ 30, 4, |
| 1753 | | // \\ 50000, 60, |
| 1754 | | // \\}; |
| 1755 | | // \\const a = []u8{ |
| 1756 | | // \\ 0, 1, 2, 3, 40, |
| 1757 | | // \\ 4, 5, 600, 7, 80, |
| 1758 | | // \\ 9, 10, 11, 0, 13, |
| 1759 | | // \\ 14, 15, |
| 1760 | | // \\}; |
| 1761 | | // \\ |
| 1762 | | // ); |
| 1763 | | //} |
| 1658 | test "zig fmt: array literal with hint" { |
| 1659 | try testTransform( |
| 1660 | \\const a = []u8{ |
| 1661 | \\ 1, 2, // |
| 1662 | \\ 3, |
| 1663 | \\ 4, |
| 1664 | \\ 5, |
| 1665 | \\ 6, |
| 1666 | \\ 7 }; |
| 1667 | \\const a = []u8{ |
| 1668 | \\ 1, 2, // |
| 1669 | \\ 3, |
| 1670 | \\ 4, |
| 1671 | \\ 5, |
| 1672 | \\ 6, |
| 1673 | \\ 7, 8 }; |
| 1674 | \\const a = []u8{ |
| 1675 | \\ 1, 2, // |
| 1676 | \\ 3, |
| 1677 | \\ 4, |
| 1678 | \\ 5, |
| 1679 | \\ 6, // blah |
| 1680 | \\ 7, 8 }; |
| 1681 | \\const a = []u8{ |
| 1682 | \\ 1, 2, // |
| 1683 | \\ 3, // |
| 1684 | \\ 4, |
| 1685 | \\ 5, |
| 1686 | \\ 6, |
| 1687 | \\ 7 }; |
| 1688 | \\const a = []u8{ |
| 1689 | \\ 1, |
| 1690 | \\ 2, |
| 1691 | \\ 3, 4, // |
| 1692 | \\ 5, 6, // |
| 1693 | \\ 7, 8, // |
| 1694 | \\}; |
| 1695 | , |
| 1696 | \\const a = []u8{ |
| 1697 | \\ 1, 2, // |
| 1698 | \\ 3, 4, |
| 1699 | \\ 5, 6, |
| 1700 | \\ 7, |
| 1701 | \\}; |
| 1702 | \\const a = []u8{ |
| 1703 | \\ 1, 2, // |
| 1704 | \\ 3, 4, |
| 1705 | \\ 5, 6, |
| 1706 | \\ 7, 8, |
| 1707 | \\}; |
| 1708 | \\const a = []u8{ |
| 1709 | \\ 1, 2, // |
| 1710 | \\ 3, 4, |
| 1711 | \\ 5, |
| 1712 | \\ 6, // blah |
| 1713 | \\ 7, |
| 1714 | \\ 8, |
| 1715 | \\}; |
| 1716 | \\const a = []u8{ |
| 1717 | \\ 1, 2, // |
| 1718 | \\ 3, // |
| 1719 | \\ 4, |
| 1720 | \\ 5, |
| 1721 | \\ 6, |
| 1722 | \\ 7, |
| 1723 | \\}; |
| 1724 | \\const a = []u8{ |
| 1725 | \\ 1, |
| 1726 | \\ 2, |
| 1727 | \\ 3, 4, // |
| 1728 | \\ 5, 6, // |
| 1729 | \\ 7, 8, // |
| 1730 | \\}; |
| 1731 | \\ |
| 1732 | ); |
| 1733 | } |
| 1734 | |
| 1735 | test "zig fmt: array literal veritical column alignment" { |
| 1736 | try testTransform( |
| 1737 | \\const a = []u8{ |
| 1738 | \\ 1000, 200, |
| 1739 | \\ 30, 4, |
| 1740 | \\ 50000, 60 |
| 1741 | \\}; |
| 1742 | \\const a = []u8{0, 1, 2, 3, 40, |
| 1743 | \\ 4,5,600,7, |
| 1744 | \\ 80, |
| 1745 | \\ 9, 10, 11, 0, 13, 14, 15}; |
| 1746 | \\ |
| 1747 | , |
| 1748 | \\const a = []u8{ |
| 1749 | \\ 1000, 200, |
| 1750 | \\ 30, 4, |
| 1751 | \\ 50000, 60, |
| 1752 | \\}; |
| 1753 | \\const a = []u8{ |
| 1754 | \\ 0, 1, 2, 3, 40, |
| 1755 | \\ 4, 5, 600, 7, 80, |
| 1756 | \\ 9, 10, 11, 0, 13, |
| 1757 | \\ 14, 15, |
| 1758 | \\}; |
| 1759 | \\ |
| 1760 | ); |
| 1761 | } |
| 1764 | 1762 | |
| 1765 | 1763 | test "zig fmt: multiline string with backslash at end of line" { |
| 1766 | 1764 | try testCanonical( |
| ... | ... | @@ -1949,29 +1947,29 @@ test "zig fmt: slice align" { |
| 1949 | 1947 | ); |
| 1950 | 1948 | } |
| 1951 | 1949 | |
| 1952 | | //test "zig fmt: add trailing comma to array literal" { |
| 1953 | | // try testTransform( |
| 1954 | | // \\comptime { |
| 1955 | | // \\ return []u16{'m', 's', 'y', 's', '-' // hi |
| 1956 | | // \\ }; |
| 1957 | | // \\ return []u16{'m', 's', 'y', 's', |
| 1958 | | // \\ '-'}; |
| 1959 | | // \\ return []u16{'m', 's', 'y', 's', '-'}; |
| 1960 | | // \\} |
| 1961 | | // , |
| 1962 | | // \\comptime { |
| 1963 | | // \\ return []u16{ |
| 1964 | | // \\ 'm', 's', 'y', 's', '-', // hi |
| 1965 | | // \\ }; |
| 1966 | | // \\ return []u16{ |
| 1967 | | // \\ 'm', 's', 'y', 's', |
| 1968 | | // \\ '-', |
| 1969 | | // \\ }; |
| 1970 | | // \\ return []u16{ 'm', 's', 'y', 's', '-' }; |
| 1971 | | // \\} |
| 1972 | | // \\ |
| 1973 | | // ); |
| 1974 | | //} |
| 1950 | test "zig fmt: add trailing comma to array literal" { |
| 1951 | try testTransform( |
| 1952 | \\comptime { |
| 1953 | \\ return []u16{'m', 's', 'y', 's', '-' // hi |
| 1954 | \\ }; |
| 1955 | \\ return []u16{'m', 's', 'y', 's', |
| 1956 | \\ '-'}; |
| 1957 | \\ return []u16{'m', 's', 'y', 's', '-'}; |
| 1958 | \\} |
| 1959 | , |
| 1960 | \\comptime { |
| 1961 | \\ return []u16{ |
| 1962 | \\ 'm', 's', 'y', 's', '-', // hi |
| 1963 | \\ }; |
| 1964 | \\ return []u16{ |
| 1965 | \\ 'm', 's', 'y', 's', |
| 1966 | \\ '-', |
| 1967 | \\ }; |
| 1968 | \\ return []u16{ 'm', 's', 'y', 's', '-' }; |
| 1969 | \\} |
| 1970 | \\ |
| 1971 | ); |
| 1972 | } |
| 1975 | 1973 | |
| 1976 | 1974 | test "zig fmt: first thing in file is line comment" { |
| 1977 | 1975 | try testCanonical( |
| ... | ... | @@ -3406,30 +3404,30 @@ test "zig fmt: comptime block in container" { |
| 3406 | 3404 | // ); |
| 3407 | 3405 | //} |
| 3408 | 3406 | |
| 3409 | | //test "zig fmt: multiline string in array" { |
| 3410 | | // try testCanonical( |
| 3411 | | // \\const Foo = [][]const u8{ |
| 3412 | | // \\ \\aaa |
| 3413 | | // \\ , |
| 3414 | | // \\ \\bbb |
| 3415 | | // \\}; |
| 3416 | | // \\ |
| 3417 | | // \\fn bar() void { |
| 3418 | | // \\ const Foo = [][]const u8{ |
| 3419 | | // \\ \\aaa |
| 3420 | | // \\ , |
| 3421 | | // \\ \\bbb |
| 3422 | | // \\ }; |
| 3423 | | // \\ const Bar = [][]const u8{ // comment here |
| 3424 | | // \\ \\aaa |
| 3425 | | // \\ \\ |
| 3426 | | // \\ , // and another comment can go here |
| 3427 | | // \\ \\bbb |
| 3428 | | // \\ }; |
| 3429 | | // \\} |
| 3430 | | // \\ |
| 3431 | | // ); |
| 3432 | | //} |
| 3407 | test "zig fmt: multiline string in array" { |
| 3408 | try testCanonical( |
| 3409 | \\const Foo = [][]const u8{ |
| 3410 | \\ \\aaa |
| 3411 | \\ , |
| 3412 | \\ \\bbb |
| 3413 | \\}; |
| 3414 | \\ |
| 3415 | \\fn bar() void { |
| 3416 | \\ const Foo = [][]const u8{ |
| 3417 | \\ \\aaa |
| 3418 | \\ , |
| 3419 | \\ \\bbb |
| 3420 | \\ }; |
| 3421 | \\ const Bar = [][]const u8{ // comment here |
| 3422 | \\ \\aaa |
| 3423 | \\ \\ |
| 3424 | \\ , // and another comment can go here |
| 3425 | \\ \\bbb |
| 3426 | \\ }; |
| 3427 | \\} |
| 3428 | \\ |
| 3429 | ); |
| 3430 | } |
| 3433 | 3431 | |
| 3434 | 3432 | test "zig fmt: if type expr" { |
| 3435 | 3433 | try testCanonical( |
| ... | ... | @@ -3449,19 +3447,21 @@ test "zig fmt: file ends with struct field" { |
| 3449 | 3447 | ); |
| 3450 | 3448 | } |
| 3451 | 3449 | |
| 3452 | | test "zig fmt: comment after empty comment" { |
| 3453 | | try testTransform( |
| 3454 | | \\const x = true; // |
| 3455 | | \\// |
| 3456 | | \\// |
| 3457 | | \\//a |
| 3458 | | \\ |
| 3459 | | , |
| 3460 | | \\const x = true; |
| 3461 | | \\//a |
| 3462 | | \\ |
| 3463 | | ); |
| 3464 | | } |
| 3450 | // TODO intentionally change the behavior of this case? |
| 3451 | // for array literals we necessarily have meaningful empty comments |
| 3452 | //test "zig fmt: comment after empty comment" { |
| 3453 | // try testTransform( |
| 3454 | // \\const x = true; // |
| 3455 | // \\// |
| 3456 | // \\// |
| 3457 | // \\//a |
| 3458 | // \\ |
| 3459 | // , |
| 3460 | // \\const x = true; |
| 3461 | // \\//a |
| 3462 | // \\ |
| 3463 | // ); |
| 3464 | //} |
| 3465 | 3465 | |
| 3466 | 3466 | //test "zig fmt: line comment in array" { |
| 3467 | 3467 | // try testTransform( |
| ... | ... | @@ -3493,7 +3493,7 @@ test "zig fmt: comment after empty comment" { |
| 3493 | 3493 | // \\ |
| 3494 | 3494 | // ); |
| 3495 | 3495 | //} |
| 3496 | | // |
| 3496 | |
| 3497 | 3497 | //test "zig fmt: comment after params" { |
| 3498 | 3498 | // try testTransform( |
| 3499 | 3499 | // \\fn a( |
| ... | ... | @@ -3518,7 +3518,7 @@ test "zig fmt: comment after empty comment" { |
| 3518 | 3518 | // \\ |
| 3519 | 3519 | // ); |
| 3520 | 3520 | //} |
| 3521 | | // |
| 3521 | |
| 3522 | 3522 | //test "zig fmt: comment in array initializer/access" { |
| 3523 | 3523 | // try testCanonical( |
| 3524 | 3524 | // \\test "a" { |
| ... | ... | @@ -3550,7 +3550,7 @@ test "zig fmt: comment after empty comment" { |
| 3550 | 3550 | // \\ |
| 3551 | 3551 | // ); |
| 3552 | 3552 | //} |
| 3553 | | // |
| 3553 | |
| 3554 | 3554 | //test "zig fmt: comments at several places in struct init" { |
| 3555 | 3555 | // try testTransform( |
| 3556 | 3556 | // \\var bar = Bar{ |
| ... | ... | @@ -3899,44 +3899,44 @@ test "zig fmt: regression test for #5722" { |
| 3899 | 3899 | ); |
| 3900 | 3900 | } |
| 3901 | 3901 | |
| 3902 | | //test "zig fmt: allow trailing line comments to do manual array formatting" { |
| 3903 | | // try testCanonical( |
| 3904 | | // \\fn foo() void { |
| 3905 | | // \\ self.code.appendSliceAssumeCapacity(&[_]u8{ |
| 3906 | | // \\ 0x55, // push rbp |
| 3907 | | // \\ 0x48, 0x89, 0xe5, // mov rbp, rsp |
| 3908 | | // \\ 0x48, 0x81, 0xec, // sub rsp, imm32 (with reloc) |
| 3909 | | // \\ }); |
| 3910 | | // \\ |
| 3911 | | // \\ di_buf.appendAssumeCapacity(&[_]u8{ |
| 3912 | | // \\ 1, DW.TAG_compile_unit, DW.CHILDREN_no, // header |
| 3913 | | // \\ DW.AT_stmt_list, DW_FORM_data4, // form value pairs |
| 3914 | | // \\ DW.AT_low_pc, DW_FORM_addr, |
| 3915 | | // \\ DW.AT_high_pc, DW_FORM_addr, |
| 3916 | | // \\ DW.AT_name, DW_FORM_strp, |
| 3917 | | // \\ DW.AT_comp_dir, DW_FORM_strp, |
| 3918 | | // \\ DW.AT_producer, DW_FORM_strp, |
| 3919 | | // \\ DW.AT_language, DW_FORM_data2, |
| 3920 | | // \\ 0, 0, // sentinel |
| 3921 | | // \\ }); |
| 3922 | | // \\ |
| 3923 | | // \\ self.code.appendSliceAssumeCapacity(&[_]u8{ |
| 3924 | | // \\ 0x55, // push rbp |
| 3925 | | // \\ 0x48, 0x89, 0xe5, // mov rbp, rsp |
| 3926 | | // \\ // How do we handle this? |
| 3927 | | // \\ //0x48, 0x81, 0xec, // sub rsp, imm32 (with reloc) |
| 3928 | | // \\ // Here's a blank line, should that be allowed? |
| 3929 | | // \\ |
| 3930 | | // \\ 0x48, 0x89, 0xe5, |
| 3931 | | // \\ 0x33, 0x45, |
| 3932 | | // \\ // Now the comment breaks a single line -- how do we handle this? |
| 3933 | | // \\ 0x88, |
| 3934 | | // \\ }); |
| 3935 | | // \\} |
| 3936 | | // \\ |
| 3937 | | // ); |
| 3938 | | //} |
| 3939 | | // |
| 3902 | test "zig fmt: allow trailing line comments to do manual array formatting" { |
| 3903 | try testCanonical( |
| 3904 | \\fn foo() void { |
| 3905 | \\ self.code.appendSliceAssumeCapacity(&[_]u8{ |
| 3906 | \\ 0x55, // push rbp |
| 3907 | \\ 0x48, 0x89, 0xe5, // mov rbp, rsp |
| 3908 | \\ 0x48, 0x81, 0xec, // sub rsp, imm32 (with reloc) |
| 3909 | \\ }); |
| 3910 | \\ |
| 3911 | \\ di_buf.appendAssumeCapacity(&[_]u8{ |
| 3912 | \\ 1, DW.TAG_compile_unit, DW.CHILDREN_no, // header |
| 3913 | \\ DW.AT_stmt_list, DW_FORM_data4, // form value pairs |
| 3914 | \\ DW.AT_low_pc, DW_FORM_addr, |
| 3915 | \\ DW.AT_high_pc, DW_FORM_addr, |
| 3916 | \\ DW.AT_name, DW_FORM_strp, |
| 3917 | \\ DW.AT_comp_dir, DW_FORM_strp, |
| 3918 | \\ DW.AT_producer, DW_FORM_strp, |
| 3919 | \\ DW.AT_language, DW_FORM_data2, |
| 3920 | \\ 0, 0, // sentinel |
| 3921 | \\ }); |
| 3922 | \\ |
| 3923 | \\ self.code.appendSliceAssumeCapacity(&[_]u8{ |
| 3924 | \\ 0x55, // push rbp |
| 3925 | \\ 0x48, 0x89, 0xe5, // mov rbp, rsp |
| 3926 | \\ // How do we handle this? |
| 3927 | \\ //0x48, 0x81, 0xec, // sub rsp, imm32 (with reloc) |
| 3928 | \\ // Here's a blank line, should that be allowed? |
| 3929 | \\ |
| 3930 | \\ 0x48, 0x89, 0xe5, |
| 3931 | \\ 0x33, 0x45, |
| 3932 | \\ // Now the comment breaks a single line -- how do we handle this? |
| 3933 | \\ 0x88, |
| 3934 | \\ }); |
| 3935 | \\} |
| 3936 | \\ |
| 3937 | ); |
| 3938 | } |
| 3939 | |
| 3940 | 3940 | //test "zig fmt: multiline string literals should play nice with array initializers" { |
| 3941 | 3941 | // try testCanonical( |
| 3942 | 3942 | // \\fn main() void { |
| ... | ... | @@ -3999,7 +3999,7 @@ test "zig fmt: regression test for #5722" { |
| 3999 | 3999 | // \\ |
| 4000 | 4000 | // ); |
| 4001 | 4001 | //} |
| 4002 | | // |
| 4002 | |
| 4003 | 4003 | //test "zig fmt: use of comments and Multiline string literals may force the parameters over multiple lines" { |
| 4004 | 4004 | // try testCanonical( |
| 4005 | 4005 | // \\pub fn makeMemUndefined(qzz: []u8) i1 { |