| ... | @@ -878,17 +878,17 @@ test "zig fmt: async function" { | ... | @@ -878,17 +878,17 @@ test "zig fmt: async function" { |
| 878 | ); | 878 | ); |
| 879 | } | 879 | } |
| 880 | | 880 | |
| 881 | //test "zig fmt: whitespace fixes" { | 881 | test "zig fmt: whitespace fixes" { |
| 882 | // try testTransform("test \"\" {\r\n\tconst hi = x;\r\n}\n// zig fmt: off\ntest \"\"{\r\n\tconst a = b;}\r\n", | 882 | try testTransform("test \"\" {\r\n\tconst hi = x;\r\n}\n// zig fmt: off\ntest \"\"{\r\n\tconst a = b;}\r\n", |
| 883 | // \\test "" { | 883 | \\test "" { |
| 884 | // \\ const hi = x; | 884 | \\ const hi = x; |
| 885 | // \\} | 885 | \\} |
| 886 | // \\// zig fmt: off | 886 | \\// zig fmt: off |
| 887 | // \\test ""{ | 887 | \\test ""{ |
| 888 | // \\ const a = b;} | 888 | \\ const a = b;} |
| 889 | // \\ | 889 | \\ |
| 890 | // ); | 890 | ); |
| 891 | //} | 891 | } |
| 892 | | 892 | |
| 893 | test "zig fmt: while else err prong with no block" { | 893 | test "zig fmt: while else err prong with no block" { |
| 894 | try testCanonical( | 894 | try testCanonical( |
| ... | @@ -1098,128 +1098,154 @@ test "zig fmt: aligned struct field" { | ... | @@ -1098,128 +1098,154 @@ test "zig fmt: aligned struct field" { |
| 1098 | ); | 1098 | ); |
| 1099 | } | 1099 | } |
| 1100 | | 1100 | |
| 1101 | //test "zig fmt: comment to disable/enable zig fmt first" { | 1101 | test "zig fmt: comment to disable/enable zig fmt first" { |
| 1102 | // try testCanonical( | 1102 | try testCanonical( |
| 1103 | // \\// Test trailing comma syntax | 1103 | \\// Test trailing comma syntax |
| 1104 | // \\// zig fmt: off | 1104 | \\// zig fmt: off |
| 1105 | // \\ | 1105 | \\ |
| 1106 | // \\const struct_trailing_comma = struct { x: i32, y: i32, }; | 1106 | \\const struct_trailing_comma = struct { x: i32, y: i32, }; |
| 1107 | // ); | 1107 | ); |
| 1108 | //} | 1108 | } |
| 1109 | // | 1109 | |
| 1110 | //test "zig fmt: comment to disable/enable zig fmt" { | 1110 | test "zig fmt: comment to disable/enable zig fmt" { |
| 1111 | // try testTransform( | 1111 | try testTransform( |
| 1112 | // \\const a = b; | 1112 | \\const a = b; |
| 1113 | // \\// zig fmt: off | 1113 | \\// zig fmt: off |
| 1114 | // \\const c = d; | 1114 | \\const c = d; |
| 1115 | // \\// zig fmt: on | 1115 | \\// zig fmt: on |
| 1116 | // \\const e = f; | 1116 | \\const e = f; |
| 1117 | // , | 1117 | , |
| 1118 | // \\const a = b; | 1118 | \\const a = b; |
| 1119 | // \\// zig fmt: off | 1119 | \\// zig fmt: off |
| 1120 | // \\const c = d; | 1120 | \\const c = d; |
| 1121 | // \\// zig fmt: on | 1121 | \\// zig fmt: on |
| 1122 | // \\const e = f; | 1122 | \\const e = f; |
| 1123 | // \\ | 1123 | \\ |
| 1124 | // ); | 1124 | ); |
| 1125 | //} | 1125 | } |
| 1126 | // | 1126 | |
| 1127 | //test "zig fmt: line comment following 'zig fmt: off'" { | 1127 | test "zig fmt: line comment following 'zig fmt: off'" { |
| 1128 | // try testCanonical( | 1128 | try testCanonical( |
| 1129 | // \\// zig fmt: off | 1129 | \\// zig fmt: off |
| 1130 | // \\// Test | 1130 | \\// Test |
| 1131 | // \\const e = f; | 1131 | \\const e = f; |
| 1132 | // ); | 1132 | ); |
| 1133 | //} | 1133 | } |
| 1134 | // | 1134 | |
| 1135 | //test "zig fmt: doc comment following 'zig fmt: off'" { | 1135 | test "zig fmt: doc comment following 'zig fmt: off'" { |
| 1136 | // try testCanonical( | 1136 | try testCanonical( |
| 1137 | // \\// zig fmt: off | 1137 | \\// zig fmt: off |
| 1138 | // \\/// test | 1138 | \\/// test |
| 1139 | // \\const e = f; | 1139 | \\const e = f; |
| 1140 | // ); | 1140 | ); |
| 1141 | //} | 1141 | } |
| 1142 | // | 1142 | |
| 1143 | //test "zig fmt: line and doc comment following 'zig fmt: off'" { | 1143 | test "zig fmt: line and doc comment following 'zig fmt: off'" { |
| 1144 | // try testCanonical( | 1144 | try testCanonical( |
| 1145 | // \\// zig fmt: off | 1145 | \\// zig fmt: off |
| 1146 | // \\// test 1 | 1146 | \\// test 1 |
| 1147 | // \\/// test 2 | 1147 | \\/// test 2 |
| 1148 | // \\const e = f; | 1148 | \\const e = f; |
| 1149 | // ); | 1149 | ); |
| 1150 | //} | 1150 | } |
| 1151 | // | 1151 | |
| 1152 | //test "zig fmt: doc and line comment following 'zig fmt: off'" { | 1152 | test "zig fmt: doc and line comment following 'zig fmt: off'" { |
| 1153 | // try testCanonical( | 1153 | try testCanonical( |
| 1154 | // \\// zig fmt: off | 1154 | \\// zig fmt: off |
| 1155 | // \\/// test 1 | 1155 | \\/// test 1 |
| 1156 | // \\// test 2 | 1156 | \\// test 2 |
| 1157 | // \\const e = f; | 1157 | \\const e = f; |
| 1158 | // ); | 1158 | ); |
| 1159 | //} | 1159 | } |
| 1160 | // | 1160 | |
| 1161 | //test "zig fmt: alternating 'zig fmt: off' and 'zig fmt: on'" { | 1161 | test "zig fmt: alternating 'zig fmt: off' and 'zig fmt: on'" { |
| 1162 | // try testCanonical( | 1162 | try testCanonical( |
| 1163 | // \\// zig fmt: off | 1163 | \\// zig fmt: off |
| 1164 | // \\// zig fmt: on | 1164 | \\// zig fmt: on |
| 1165 | // \\// zig fmt: off | 1165 | \\// zig fmt: off |
| 1166 | // \\const e = f; | 1166 | \\const e = f; |
| 1167 | // \\// zig fmt: off | 1167 | \\// zig fmt: off |
| 1168 | // \\// zig fmt: on | 1168 | \\// zig fmt: on |
| 1169 | // \\// zig fmt: off | 1169 | \\// zig fmt: off |
| 1170 | // \\const a = b; | 1170 | \\const a = b; |
| 1171 | // \\// zig fmt: on | 1171 | \\// zig fmt: on |
| 1172 | // \\const c = d; | 1172 | \\const c = d; |
| 1173 | // \\// zig fmt: on | 1173 | \\// zig fmt: on |
| 1174 | // \\ | 1174 | \\ |
| 1175 | // ); | 1175 | ); |
| 1176 | //} | 1176 | } |
| 1177 | // | 1177 | |
| 1178 | //test "zig fmt: line comment following 'zig fmt: on'" { | 1178 | test "zig fmt: line comment following 'zig fmt: on'" { |
| 1179 | // try testCanonical( | 1179 | try testCanonical( |
| 1180 | // \\// zig fmt: off | 1180 | \\// zig fmt: off |
| 1181 | // \\const e = f; | 1181 | \\const e = f; |
| 1182 | // \\// zig fmt: on | 1182 | \\// zig fmt: on |
| 1183 | // \\// test | 1183 | \\// test |
| 1184 | // \\const e = f; | 1184 | \\const e = f; |
| 1185 | // \\ | 1185 | \\ |
| 1186 | // ); | 1186 | ); |
| 1187 | //} | 1187 | } |
| 1188 | // | 1188 | |
| 1189 | //test "zig fmt: doc comment following 'zig fmt: on'" { | 1189 | test "zig fmt: doc comment following 'zig fmt: on'" { |
| 1190 | // try testCanonical( | 1190 | try testCanonical( |
| 1191 | // \\// zig fmt: off | 1191 | \\// zig fmt: off |
| 1192 | // \\const e = f; | 1192 | \\const e = f; |
| 1193 | // \\// zig fmt: on | 1193 | \\// zig fmt: on |
| 1194 | // \\/// test | 1194 | \\/// test |
| 1195 | // \\const e = f; | 1195 | \\const e = f; |
| 1196 | // \\ | 1196 | \\ |
| 1197 | // ); | 1197 | ); |
| 1198 | //} | 1198 | } |
| 1199 | // | 1199 | |
| 1200 | //test "zig fmt: line and doc comment following 'zig fmt: on'" { | 1200 | test "zig fmt: line and doc comment following 'zig fmt: on'" { |
| 1201 | // try testCanonical( | 1201 | try testCanonical( |
| 1202 | // \\// zig fmt: off | 1202 | \\// zig fmt: off |
| 1203 | // \\const e = f; | 1203 | \\const e = f; |
| 1204 | // \\// zig fmt: on | 1204 | \\// zig fmt: on |
| 1205 | // \\// test1 | 1205 | \\// test1 |
| 1206 | // \\/// test2 | 1206 | \\/// test2 |
| 1207 | // \\const e = f; | 1207 | \\const e = f; |
| 1208 | // \\ | 1208 | \\ |
| 1209 | // ); | 1209 | ); |
| 1210 | //} | 1210 | } |
| 1211 | // | 1211 | |
| 1212 | //test "zig fmt: doc and line comment following 'zig fmt: on'" { | 1212 | test "zig fmt: doc and line comment following 'zig fmt: on'" { |
| 1213 | // try testCanonical( | 1213 | try testCanonical( |
| 1214 | // \\// zig fmt: off | 1214 | \\// zig fmt: off |
| 1215 | // \\const e = f; | 1215 | \\const e = f; |
| 1216 | // \\// zig fmt: on | 1216 | \\// zig fmt: on |
| 1217 | // \\/// test1 | 1217 | \\/// test1 |
| 1218 | // \\// test2 | 1218 | \\// test2 |
| 1219 | // \\const e = f; | 1219 | \\const e = f; |
| 1220 | // \\ | 1220 | \\ |
| 1221 | // ); | 1221 | ); |
| 1222 | //} | 1222 | } |
| | 1223 | |
| | 1224 | test "zig fmt: 'zig fmt: (off|on)' works in the middle of code" { |
| | 1225 | try testTransform( |
| | 1226 | \\test "" { |
| | 1227 | \\ const x = 42; |
| | 1228 | \\ |
| | 1229 | \\ if (foobar) |y| { |
| | 1230 | \\ // zig fmt: off |
| | 1231 | \\ }// zig fmt: on |
| | 1232 | \\ |
| | 1233 | \\ const z = 420; |
| | 1234 | \\} |
| | 1235 | \\ |
| | 1236 | , |
| | 1237 | \\test "" { |
| | 1238 | \\ const x = 42; |
| | 1239 | \\ |
| | 1240 | \\ if (foobar) |y| { |
| | 1241 | \\ // zig fmt: off |
| | 1242 | \\ }// zig fmt: on |
| | 1243 | \\ |
| | 1244 | \\ const z = 420; |
| | 1245 | \\} |
| | 1246 | \\ |
| | 1247 | ); |
| | 1248 | } |
| 1223 | | 1249 | |
| 1224 | test "zig fmt: pointer of unknown length" { | 1250 | test "zig fmt: pointer of unknown length" { |
| 1225 | try testCanonical( | 1251 | try testCanonical( |