Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(337)

Side by Side Diff: pkg/front_end/test/src/incremental/file_state_test.dart

Issue 2975253002: Format analyzer, analysis_server, analyzer_plugin, front_end and kernel with the latest dartfmt. (Closed)
Patch Set: Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import 'dart:async'; 5 import 'dart:async';
6 6
7 import 'package:front_end/memory_file_system.dart'; 7 import 'package:front_end/memory_file_system.dart';
8 import 'package:front_end/src/fasta/uri_translator_impl.dart'; 8 import 'package:front_end/src/fasta/uri_translator_impl.dart';
9 import 'package:front_end/src/incremental/byte_store.dart'; 9 import 'package:front_end/src/incremental/byte_store.dart';
10 import 'package:front_end/src/incremental/file_state.dart'; 10 import 'package:front_end/src/incremental/file_state.dart';
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 } 142 }
143 baz() => 44; 143 baz() => 44;
144 '''); 144 ''');
145 } 145 }
146 146
147 test_gc() async { 147 test_gc() async {
148 var a = writeFile('/a.dart', ''); 148 var a = writeFile('/a.dart', '');
149 var b = writeFile('/b.dart', ''); 149 var b = writeFile('/b.dart', '');
150 var c = writeFile('/c.dart', 'import "a.dart";'); 150 var c = writeFile('/c.dart', 'import "a.dart";');
151 var d = writeFile('/d.dart', 'import "b.dart";'); 151 var d = writeFile('/d.dart', 'import "b.dart";');
152 var e = writeFile( 152 var e = writeFile('/e.dart', r'''
153 '/e.dart',
154 r'''
155 import "c.dart"; 153 import "c.dart";
156 import "d.dart"; 154 import "d.dart";
157 '''); 155 ''');
158 156
159 var eFile = await fsState.getFile(e); 157 var eFile = await fsState.getFile(e);
160 158
161 // The root and four files. 159 // The root and four files.
162 expect(fsState.fileUris, contains(e)); 160 expect(fsState.fileUris, contains(e));
163 expect(fsState.fileUris, contains(a)); 161 expect(fsState.fileUris, contains(a));
164 expect(fsState.fileUris, contains(b)); 162 expect(fsState.fileUris, contains(b));
165 expect(fsState.fileUris, contains(c)); 163 expect(fsState.fileUris, contains(c));
166 expect(fsState.fileUris, contains(d)); 164 expect(fsState.fileUris, contains(d));
167 165
168 // No changes after GC. 166 // No changes after GC.
169 expect(fsState.gc(e), isEmpty); 167 expect(fsState.gc(e), isEmpty);
170 expect(fsState.fileUris, contains(e)); 168 expect(fsState.fileUris, contains(e));
171 expect(fsState.fileUris, contains(a)); 169 expect(fsState.fileUris, contains(a));
172 expect(fsState.fileUris, contains(b)); 170 expect(fsState.fileUris, contains(b));
173 expect(fsState.fileUris, contains(c)); 171 expect(fsState.fileUris, contains(c));
174 expect(fsState.fileUris, contains(d)); 172 expect(fsState.fileUris, contains(d));
175 173
176 // Update e.dart so that it does not reference c.dart anymore. 174 // Update e.dart so that it does not reference c.dart anymore.
177 // Then GC removes both c.dart and a.dart it references. 175 // Then GC removes both c.dart and a.dart it references.
178 writeFile( 176 writeFile('/e.dart', r'''
179 '/e.dart',
180 r'''
181 import "d.dart"; 177 import "d.dart";
182 '''); 178 ''');
183 await eFile.refresh(); 179 await eFile.refresh();
184 { 180 {
185 var gcFiles = fsState.gc(e); 181 var gcFiles = fsState.gc(e);
186 expect(gcFiles.map((file) => file.uri), unorderedEquals([a, c])); 182 expect(gcFiles.map((file) => file.uri), unorderedEquals([a, c]));
187 } 183 }
188 expect(fsState.fileUris, contains(e)); 184 expect(fsState.fileUris, contains(e));
189 expect(fsState.fileUris, isNot(contains(a))); 185 expect(fsState.fileUris, isNot(contains(a)));
190 expect(fsState.fileUris, contains(b)); 186 expect(fsState.fileUris, contains(b));
191 expect(fsState.fileUris, isNot(contains(c))); 187 expect(fsState.fileUris, isNot(contains(c)));
192 expect(fsState.fileUris, contains(d)); 188 expect(fsState.fileUris, contains(d));
193 } 189 }
194 190
195 test_getFile() async { 191 test_getFile() async {
196 var a = writeFile('/a.dart', ''); 192 var a = writeFile('/a.dart', '');
197 var b = writeFile('/b.dart', ''); 193 var b = writeFile('/b.dart', '');
198 var c = writeFile('/c.dart', ''); 194 var c = writeFile('/c.dart', '');
199 var d = writeFile( 195 var d = writeFile('/d.dart', r'''
200 '/d.dart',
201 r'''
202 import "a.dart"; 196 import "a.dart";
203 export "b.dart"; 197 export "b.dart";
204 part "c.dart"; 198 part "c.dart";
205 '''); 199 ''');
206 200
207 FileState aFile = await fsState.getFile(a); 201 FileState aFile = await fsState.getFile(a);
208 FileState bFile = await fsState.getFile(b); 202 FileState bFile = await fsState.getFile(b);
209 FileState cFile = await fsState.getFile(c); 203 FileState cFile = await fsState.getFile(c);
210 FileState dFile = await fsState.getFile(d); 204 FileState dFile = await fsState.getFile(d);
211 205
(...skipping 14 matching lines...) Expand all
226 expect(bFile.exists, isTrue); 220 expect(bFile.exists, isTrue);
227 _assertImportedUris(bFile, [_coreUri]); 221 _assertImportedUris(bFile, [_coreUri]);
228 expect(bFile.exportedLibraries, isEmpty); 222 expect(bFile.exportedLibraries, isEmpty);
229 expect(bFile.partFiles, isEmpty); 223 expect(bFile.partFiles, isEmpty);
230 } 224 }
231 225
232 test_getFile_exports() async { 226 test_getFile_exports() async {
233 var a = writeFile('/a.dart', ''); 227 var a = writeFile('/a.dart', '');
234 var b = writeFile('/b.dart', ''); 228 var b = writeFile('/b.dart', '');
235 var c = writeFile('/c.dart', ''); 229 var c = writeFile('/c.dart', '');
236 var d = writeFile( 230 var d = writeFile('/d.dart', r'''
237 '/d.dart',
238 r'''
239 export "a.dart" show A, B; 231 export "a.dart" show A, B;
240 export "b.dart" hide C, D; 232 export "b.dart" hide C, D;
241 export "c.dart" show A, B, C, D hide C show A, D; 233 export "c.dart" show A, B, C, D hide C show A, D;
242 '''); 234 ''');
243 235
244 FileState aFile = await fsState.getFile(a); 236 FileState aFile = await fsState.getFile(a);
245 FileState bFile = await fsState.getFile(b); 237 FileState bFile = await fsState.getFile(b);
246 FileState cFile = await fsState.getFile(c); 238 FileState cFile = await fsState.getFile(c);
247 FileState dFile = await fsState.getFile(d); 239 FileState dFile = await fsState.getFile(d);
248 240
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 expect(export_.combinators[2].isShow, isTrue); 273 expect(export_.combinators[2].isShow, isTrue);
282 expect(export_.combinators[2].names, unorderedEquals(['A', 'D'])); 274 expect(export_.combinators[2].names, unorderedEquals(['A', 'D']));
283 expect(export_.isExposed('A'), isTrue); 275 expect(export_.isExposed('A'), isTrue);
284 expect(export_.isExposed('B'), isFalse); 276 expect(export_.isExposed('B'), isFalse);
285 expect(export_.isExposed('C'), isFalse); 277 expect(export_.isExposed('C'), isFalse);
286 expect(export_.isExposed('D'), isTrue); 278 expect(export_.isExposed('D'), isTrue);
287 } 279 }
288 } 280 }
289 281
290 test_hasMixinApplication_false() async { 282 test_hasMixinApplication_false() async {
291 writeFile( 283 writeFile('/a.dart', r'''
292 '/a.dart',
293 r'''
294 class A {} 284 class A {}
295 class B extends Object with A {} 285 class B extends Object with A {}
296 '''); 286 ''');
297 var uri = writeFile( 287 var uri = writeFile('/test.dart', r'''
298 '/test.dart',
299 r'''
300 import 'a.dart'; 288 import 'a.dart';
301 class T1 extends A {} 289 class T1 extends A {}
302 class T2 extends B {} 290 class T2 extends B {}
303 '''); 291 ''');
304 FileState file = await fsState.getFile(uri); 292 FileState file = await fsState.getFile(uri);
305 expect(file.hasMixinApplication, isFalse); 293 expect(file.hasMixinApplication, isFalse);
306 } 294 }
307 295
308 test_hasMixinApplication_true_class() async { 296 test_hasMixinApplication_true_class() async {
309 var uri = writeFile( 297 var uri = writeFile('/test.dart', r'''
310 '/test.dart',
311 r'''
312 class A {} 298 class A {}
313 class B extends Object with A {} 299 class B extends Object with A {}
314 '''); 300 ''');
315 FileState file = await fsState.getFile(uri); 301 FileState file = await fsState.getFile(uri);
316 expect(file.hasMixinApplication, isTrue); 302 expect(file.hasMixinApplication, isTrue);
317 } 303 }
318 304
319 test_hasMixinApplication_true_named() async { 305 test_hasMixinApplication_true_named() async {
320 var uri = writeFile( 306 var uri = writeFile('/test.dart', r'''
321 '/test.dart',
322 r'''
323 class A {} 307 class A {}
324 class B = Object with A; 308 class B = Object with A;
325 '''); 309 ''');
326 FileState file = await fsState.getFile(uri); 310 FileState file = await fsState.getFile(uri);
327 expect(file.hasMixinApplication, isTrue); 311 expect(file.hasMixinApplication, isTrue);
328 } 312 }
329 313
330 test_hasMixinApplicationLibrary_false() async { 314 test_hasMixinApplicationLibrary_false() async {
331 var partUri = writeFile( 315 var partUri = writeFile('/part.dart', r'''
332 '/part.dart',
333 r'''
334 part of test; 316 part of test;
335 class A {} 317 class A {}
336 '''); 318 ''');
337 var libUri = writeFile( 319 var libUri = writeFile('/test.dart', r'''
338 '/test.dart',
339 r'''
340 library test; 320 library test;
341 part 'part.dart'; 321 part 'part.dart';
342 class B extends A {} 322 class B extends A {}
343 '''); 323 ''');
344 324
345 FileState part = await fsState.getFile(partUri); 325 FileState part = await fsState.getFile(partUri);
346 FileState lib = await fsState.getFile(libUri); 326 FileState lib = await fsState.getFile(libUri);
347 327
348 expect(part.hasMixinApplication, isFalse); 328 expect(part.hasMixinApplication, isFalse);
349 expect(lib.hasMixinApplication, isFalse); 329 expect(lib.hasMixinApplication, isFalse);
350 expect(lib.hasMixinApplicationLibrary, isFalse); 330 expect(lib.hasMixinApplicationLibrary, isFalse);
351 } 331 }
352 332
353 test_hasMixinApplicationLibrary_true_inDefiningUnit() async { 333 test_hasMixinApplicationLibrary_true_inDefiningUnit() async {
354 var partUri = writeFile( 334 var partUri = writeFile('/part.dart', r'''
355 '/part.dart',
356 r'''
357 part of test; 335 part of test;
358 class A {} 336 class A {}
359 '''); 337 ''');
360 var libUri = writeFile( 338 var libUri = writeFile('/test.dart', r'''
361 '/test.dart',
362 r'''
363 library test; 339 library test;
364 part 'part.dart'; 340 part 'part.dart';
365 class B extends Object with A {} 341 class B extends Object with A {}
366 '''); 342 ''');
367 343
368 FileState part = await fsState.getFile(partUri); 344 FileState part = await fsState.getFile(partUri);
369 FileState lib = await fsState.getFile(libUri); 345 FileState lib = await fsState.getFile(libUri);
370 346
371 expect(part.hasMixinApplication, isFalse); 347 expect(part.hasMixinApplication, isFalse);
372 expect(lib.hasMixinApplication, isTrue); 348 expect(lib.hasMixinApplication, isTrue);
373 expect(lib.hasMixinApplicationLibrary, isTrue); 349 expect(lib.hasMixinApplicationLibrary, isTrue);
374 } 350 }
375 351
376 test_hasMixinApplicationLibrary_true_inPart() async { 352 test_hasMixinApplicationLibrary_true_inPart() async {
377 var partUri = writeFile( 353 var partUri = writeFile('/part.dart', r'''
378 '/part.dart',
379 r'''
380 part of test; 354 part of test;
381 class A {} 355 class A {}
382 class B extends Object with A {} 356 class B extends Object with A {}
383 '''); 357 ''');
384 var libUri = writeFile( 358 var libUri = writeFile('/test.dart', r'''
385 '/test.dart',
386 r'''
387 library test; 359 library test;
388 part 'part.dart'; 360 part 'part.dart';
389 class C {} 361 class C {}
390 '''); 362 ''');
391 363
392 FileState part = await fsState.getFile(partUri); 364 FileState part = await fsState.getFile(partUri);
393 FileState lib = await fsState.getFile(libUri); 365 FileState lib = await fsState.getFile(libUri);
394 366
395 expect(part.hasMixinApplication, isTrue); 367 expect(part.hasMixinApplication, isTrue);
396 expect(lib.hasMixinApplication, isFalse); 368 expect(lib.hasMixinApplication, isFalse);
397 expect(lib.hasMixinApplicationLibrary, isTrue); 369 expect(lib.hasMixinApplicationLibrary, isTrue);
398 } 370 }
399 371
400 test_newFileListener() async { 372 test_newFileListener() async {
401 var a = writeFile('/a.dart', ''); 373 var a = writeFile('/a.dart', '');
402 var b = writeFile('/b.dart', ''); 374 var b = writeFile('/b.dart', '');
403 var c = writeFile( 375 var c = writeFile('/c.dart', r'''
404 '/c.dart',
405 r'''
406 import 'a.dart'; 376 import 'a.dart';
407 '''); 377 ''');
408 378
409 FileState cFile = await fsState.getFile(c); 379 FileState cFile = await fsState.getFile(c);
410 380
411 // c.dart uses c.dart and a.dart, but not b.dart yet. 381 // c.dart uses c.dart and a.dart, but not b.dart yet.
412 expect(_newFileUris, contains(c)); 382 expect(_newFileUris, contains(c));
413 expect(_newFileUris, contains(a)); 383 expect(_newFileUris, contains(a));
414 expect(_newFileUris, isNot(contains(b))); 384 expect(_newFileUris, isNot(contains(b)));
415 _newFileUris.clear(); 385 _newFileUris.clear();
416 386
417 // Update c.dart to use b.dart too. 387 // Update c.dart to use b.dart too.
418 writeFile( 388 writeFile('/c.dart', r'''
419 '/c.dart',
420 r'''
421 import 'a.dart'; 389 import 'a.dart';
422 import 'b.dart'; 390 import 'b.dart';
423 '''); 391 ''');
424 await cFile.refresh(); 392 await cFile.refresh();
425 393
426 // b.dart is the only new file. 394 // b.dart is the only new file.
427 expect(_newFileUris, [b]); 395 expect(_newFileUris, [b]);
428 } 396 }
429 397
430 test_topologicalOrder_cycleBeforeTarget() async { 398 test_topologicalOrder_cycleBeforeTarget() async {
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 Iterable<Uri> importedUris = _toUris(file.importedLibraries); 503 Iterable<Uri> importedUris = _toUris(file.importedLibraries);
536 expect(importedUris, unorderedEquals(expectedUris)); 504 expect(importedUris, unorderedEquals(expectedUris));
537 } 505 }
538 506
539 Iterable<Uri> _toUris(List<FileState> files) { 507 Iterable<Uri> _toUris(List<FileState> files) {
540 return files.map((f) => f.uri); 508 return files.map((f) => f.uri);
541 } 509 }
542 510
543 Uri _writeFileDirectives(String path, 511 Uri _writeFileDirectives(String path,
544 {List<String> imports: const [], List<String> exports: const []}) { 512 {List<String> imports: const [], List<String> exports: const []}) {
545 return writeFile( 513 return writeFile(path, '''
546 path,
547 '''
548 ${imports.map((uri) => 'import "$uri";').join('\n')} 514 ${imports.map((uri) => 'import "$uri";').join('\n')}
549 ${exports.map((uri) => 'export "$uri";').join('\n')} 515 ${exports.map((uri) => 'export "$uri";').join('\n')}
550 '''); 516 ''');
551 } 517 }
552 } 518 }
OLDNEW
« no previous file with comments | « pkg/front_end/test/incremental_kernel_generator_test.dart ('k') | pkg/front_end/test/src/incremental/kernel_driver_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698