| ... | ... | @@ -1456,17 +1456,17 @@ test "zig fmt: if condition has line break but must not wrap (no fn call comma)" |
| 1456 | 1456 | ); |
| 1457 | 1457 | } |
| 1458 | 1458 | |
| 1459 | | //test "zig fmt: function call with multiline argument" { |
| 1460 | | // try testCanonical( |
| 1461 | | // \\comptime { |
| 1462 | | // \\ self.user_input_options.put(name, UserInputOption{ |
| 1463 | | // \\ .name = name, |
| 1464 | | // \\ .used = false, |
| 1465 | | // \\ }); |
| 1466 | | // \\} |
| 1467 | | // \\ |
| 1468 | | // ); |
| 1469 | | //} |
| 1459 | test "zig fmt: function call with multiline argument" { |
| 1460 | try testCanonical( |
| 1461 | \\comptime { |
| 1462 | \\ self.user_input_options.put(name, UserInputOption{ |
| 1463 | \\ .name = name, |
| 1464 | \\ .used = false, |
| 1465 | \\ }); |
| 1466 | \\} |
| 1467 | \\ |
| 1468 | ); |
| 1469 | } |
| 1470 | 1470 | |
| 1471 | 1471 | test "zig fmt: if-else with comment before else" { |
| 1472 | 1472 | try testCanonical( |
| ... | ... | @@ -1817,14 +1817,24 @@ test "zig fmt: empty block with only comment" { |
| 1817 | 1817 | ); |
| 1818 | 1818 | } |
| 1819 | 1819 | |
| 1820 | | //test "zig fmt: no trailing comma on struct decl" { |
| 1821 | | // try testCanonical( |
| 1822 | | // \\const RoundParam = struct { |
| 1823 | | // \\ k: usize, s: u32, t: u32 |
| 1824 | | // \\}; |
| 1825 | | // \\ |
| 1826 | | // ); |
| 1827 | | //} |
| 1820 | test "zig fmt: trailing commas on struct decl" { |
| 1821 | try testTransform( |
| 1822 | \\const RoundParam = struct { |
| 1823 | \\ k: usize, s: u32, t: u32 |
| 1824 | \\}; |
| 1825 | \\const RoundParam = struct { |
| 1826 | \\ k: usize, s: u32, t: u32, |
| 1827 | \\}; |
| 1828 | , |
| 1829 | \\const RoundParam = struct { k: usize, s: u32, t: u32 }; |
| 1830 | \\const RoundParam = struct { |
| 1831 | \\ k: usize, |
| 1832 | \\ s: u32, |
| 1833 | \\ t: u32, |
| 1834 | \\}; |
| 1835 | \\ |
| 1836 | ); |
| 1837 | } |
| 1828 | 1838 | |
| 1829 | 1839 | test "zig fmt: extra newlines at the end" { |
| 1830 | 1840 | try testTransform( |
| ... | ... | @@ -2975,75 +2985,75 @@ test "zig fmt: switch" { |
| 2975 | 2985 | ); |
| 2976 | 2986 | } |
| 2977 | 2987 | |
| 2978 | | //test "zig fmt: while" { |
| 2979 | | // try testCanonical( |
| 2980 | | // \\test "while" { |
| 2981 | | // \\ while (10 < 1) unreachable; |
| 2982 | | // \\ |
| 2983 | | // \\ while (10 < 1) unreachable else unreachable; |
| 2984 | | // \\ |
| 2985 | | // \\ while (10 < 1) { |
| 2986 | | // \\ unreachable; |
| 2987 | | // \\ } |
| 2988 | | // \\ |
| 2989 | | // \\ while (10 < 1) |
| 2990 | | // \\ unreachable; |
| 2991 | | // \\ |
| 2992 | | // \\ var i: usize = 0; |
| 2993 | | // \\ while (i < 10) : (i += 1) { |
| 2994 | | // \\ continue; |
| 2995 | | // \\ } |
| 2996 | | // \\ |
| 2997 | | // \\ i = 0; |
| 2998 | | // \\ while (i < 10) : (i += 1) |
| 2999 | | // \\ continue; |
| 3000 | | // \\ |
| 3001 | | // \\ i = 0; |
| 3002 | | // \\ var j: usize = 0; |
| 3003 | | // \\ while (i < 10) : ({ |
| 3004 | | // \\ i += 1; |
| 3005 | | // \\ j += 1; |
| 3006 | | // \\ }) { |
| 3007 | | // \\ continue; |
| 3008 | | // \\ } |
| 3009 | | // \\ |
| 3010 | | // \\ var a: ?u8 = 2; |
| 3011 | | // \\ while (a) |v| : (a = null) { |
| 3012 | | // \\ continue; |
| 3013 | | // \\ } |
| 3014 | | // \\ |
| 3015 | | // \\ while (a) |v| : (a = null) |
| 3016 | | // \\ unreachable; |
| 3017 | | // \\ |
| 3018 | | // \\ label: while (10 < 0) { |
| 3019 | | // \\ unreachable; |
| 3020 | | // \\ } |
| 3021 | | // \\ |
| 3022 | | // \\ const res = while (0 < 10) { |
| 3023 | | // \\ break 7; |
| 3024 | | // \\ } else { |
| 3025 | | // \\ unreachable; |
| 3026 | | // \\ }; |
| 3027 | | // \\ |
| 3028 | | // \\ const res = while (0 < 10) |
| 3029 | | // \\ break 7 |
| 3030 | | // \\ else |
| 3031 | | // \\ unreachable; |
| 3032 | | // \\ |
| 3033 | | // \\ var a: anyerror!u8 = 0; |
| 3034 | | // \\ while (a) |v| { |
| 3035 | | // \\ a = error.Err; |
| 3036 | | // \\ } else |err| { |
| 3037 | | // \\ i = 1; |
| 3038 | | // \\ } |
| 3039 | | // \\ |
| 3040 | | // \\ comptime var k: usize = 0; |
| 3041 | | // \\ inline while (i < 10) : (i += 1) |
| 3042 | | // \\ j += 2; |
| 3043 | | // \\} |
| 3044 | | // \\ |
| 3045 | | // ); |
| 3046 | | //} |
| 2988 | test "zig fmt: while" { |
| 2989 | try testCanonical( |
| 2990 | \\test "while" { |
| 2991 | \\ while (10 < 1) unreachable; |
| 2992 | \\ |
| 2993 | \\ while (10 < 1) unreachable else unreachable; |
| 2994 | \\ |
| 2995 | \\ while (10 < 1) { |
| 2996 | \\ unreachable; |
| 2997 | \\ } |
| 2998 | \\ |
| 2999 | \\ while (10 < 1) |
| 3000 | \\ unreachable; |
| 3001 | \\ |
| 3002 | \\ var i: usize = 0; |
| 3003 | \\ while (i < 10) : (i += 1) { |
| 3004 | \\ continue; |
| 3005 | \\ } |
| 3006 | \\ |
| 3007 | \\ i = 0; |
| 3008 | \\ while (i < 10) : (i += 1) |
| 3009 | \\ continue; |
| 3010 | \\ |
| 3011 | \\ i = 0; |
| 3012 | \\ var j: usize = 0; |
| 3013 | \\ while (i < 10) : ({ |
| 3014 | \\ i += 1; |
| 3015 | \\ j += 1; |
| 3016 | \\ }) { |
| 3017 | \\ continue; |
| 3018 | \\ } |
| 3019 | \\ |
| 3020 | \\ var a: ?u8 = 2; |
| 3021 | \\ while (a) |v| : (a = null) { |
| 3022 | \\ continue; |
| 3023 | \\ } |
| 3024 | \\ |
| 3025 | \\ while (a) |v| : (a = null) |
| 3026 | \\ unreachable; |
| 3027 | \\ |
| 3028 | \\ label: while (10 < 0) { |
| 3029 | \\ unreachable; |
| 3030 | \\ } |
| 3031 | \\ |
| 3032 | \\ const res = while (0 < 10) { |
| 3033 | \\ break 7; |
| 3034 | \\ } else { |
| 3035 | \\ unreachable; |
| 3036 | \\ }; |
| 3037 | \\ |
| 3038 | \\ const res = while (0 < 10) |
| 3039 | \\ break 7 |
| 3040 | \\ else |
| 3041 | \\ unreachable; |
| 3042 | \\ |
| 3043 | \\ var a: anyerror!u8 = 0; |
| 3044 | \\ while (a) |v| { |
| 3045 | \\ a = error.Err; |
| 3046 | \\ } else |err| { |
| 3047 | \\ i = 1; |
| 3048 | \\ } |
| 3049 | \\ |
| 3050 | \\ comptime var k: usize = 0; |
| 3051 | \\ inline while (i < 10) : (i += 1) |
| 3052 | \\ j += 2; |
| 3053 | \\} |
| 3054 | \\ |
| 3055 | ); |
| 3056 | } |
| 3047 | 3057 | |
| 3048 | 3058 | test "zig fmt: for" { |
| 3049 | 3059 | try testCanonical( |