| ... | @@ -1594,50 +1594,67 @@ test "zig fmt: struct literal no trailing comma" { | ... | @@ -1594,50 +1594,67 @@ test "zig fmt: struct literal no trailing comma" { |
| 1594 | ); | 1594 | ); |
| 1595 | } | 1595 | } |
| 1596 | | 1596 | |
| 1597 | //test "zig fmt: struct literal containing a multiline expression" { | 1597 | test "zig fmt: struct literal containing a multiline expression" { |
| 1598 | // try testTransform( | 1598 | try testTransform( |
| 1599 | // \\const a = A{ .x = if (f1()) 10 else 20 }; | 1599 | \\const a = A{ .x = if (f1()) 10 else 20 }; |
| 1600 | // \\const a = A{ .x = if (f1()) 10 else 20, }; | 1600 | \\const a = A{ .x = if (f1()) 10 else 20, }; |
| 1601 | // \\const a = A{ .x = if (f1()) | 1601 | \\const a = A{ .x = if (f1()) |
| 1602 | // \\ 10 else 20 }; | 1602 | \\ 10 else 20 }; |
| 1603 | // \\const a = A{ .x = if (f1()) 10 else 20, .y = f2() + 100 }; | 1603 | \\const a = A{ .x = if (f1()) |
| 1604 | // \\const a = A{ .x = if (f1()) 10 else 20, .y = f2() + 100, }; | 1604 | \\ 10 else 20,}; |
| 1605 | // \\const a = A{ .x = if (f1()) | 1605 | \\const a = A{ .x = if (f1()) 10 else 20, .y = f2() + 100 }; |
| 1606 | // \\ 10 else 20}; | 1606 | \\const a = A{ .x = if (f1()) 10 else 20, .y = f2() + 100, }; |
| 1607 | // \\const a = A{ .x = switch(g) {0 => "ok", else => "no"} }; | 1607 | \\const a = A{ .x = if (f1()) |
| 1608 | // \\ | 1608 | \\ 10 else 20}; |
| 1609 | // , | 1609 | \\const a = A{ .x = if (f1()) |
| 1610 | // \\const a = A{ .x = if (f1()) 10 else 20 }; | 1610 | \\ 10 else 20,}; |
| 1611 | // \\const a = A{ | 1611 | \\const a = A{ .x = switch(g) {0 => "ok", else => "no"} }; |
| 1612 | // \\ .x = if (f1()) 10 else 20, | 1612 | \\const a = A{ .x = switch(g) {0 => "ok", else => "no"}, }; |
| 1613 | // \\}; | 1613 | \\ |
| 1614 | // \\const a = A{ | 1614 | , |
| 1615 | // \\ .x = if (f1()) | 1615 | \\const a = A{ .x = if (f1()) 10 else 20 }; |
| 1616 | // \\ 10 | 1616 | \\const a = A{ |
| 1617 | // \\ else | 1617 | \\ .x = if (f1()) 10 else 20, |
| 1618 | // \\ 20, | 1618 | \\}; |
| 1619 | // \\}; | 1619 | \\const a = A{ .x = if (f1()) |
| 1620 | // \\const a = A{ .x = if (f1()) 10 else 20, .y = f2() + 100 }; | 1620 | \\ 10 |
| 1621 | // \\const a = A{ | 1621 | \\else |
| 1622 | // \\ .x = if (f1()) 10 else 20, | 1622 | \\ 20 }; |
| 1623 | // \\ .y = f2() + 100, | 1623 | \\const a = A{ |
| 1624 | // \\}; | 1624 | \\ .x = if (f1()) |
| 1625 | // \\const a = A{ | 1625 | \\ 10 |
| 1626 | // \\ .x = if (f1()) | 1626 | \\ else |
| 1627 | // \\ 10 | 1627 | \\ 20, |
| 1628 | // \\ else | 1628 | \\}; |
| 1629 | // \\ 20, | 1629 | \\const a = A{ .x = if (f1()) 10 else 20, .y = f2() + 100 }; |
| 1630 | // \\}; | 1630 | \\const a = A{ |
| 1631 | // \\const a = A{ | 1631 | \\ .x = if (f1()) 10 else 20, |
| 1632 | // \\ .x = switch (g) { | 1632 | \\ .y = f2() + 100, |
| 1633 | // \\ 0 => "ok", | 1633 | \\}; |
| 1634 | // \\ else => "no", | 1634 | \\const a = A{ .x = if (f1()) |
| 1635 | // \\ }, | 1635 | \\ 10 |
| 1636 | // \\}; | 1636 | \\else |
| 1637 | // \\ | 1637 | \\ 20 }; |
| 1638 | // ); | 1638 | \\const a = A{ |
| 1639 | //} | 1639 | \\ .x = if (f1()) |
| 1640 | // | 1640 | \\ 10 |
| | 1641 | \\ else |
| | 1642 | \\ 20, |
| | 1643 | \\}; |
| | 1644 | \\const a = A{ .x = switch (g) { |
| | 1645 | \\ 0 => "ok", |
| | 1646 | \\ else => "no", |
| | 1647 | \\} }; |
| | 1648 | \\const a = A{ |
| | 1649 | \\ .x = switch (g) { |
| | 1650 | \\ 0 => "ok", |
| | 1651 | \\ else => "no", |
| | 1652 | \\ }, |
| | 1653 | \\}; |
| | 1654 | \\ |
| | 1655 | ); |
| | 1656 | } |
| | 1657 | |
| 1641 | //test "zig fmt: array literal with hint" { | 1658 | //test "zig fmt: array literal with hint" { |
| 1642 | // try testTransform( | 1659 | // try testTransform( |
| 1643 | // \\const a = []u8{ | 1660 | // \\const a = []u8{ |