| OLD | NEW |
| 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/compiler_options.dart'; | 7 import 'package:front_end/compiler_options.dart'; |
| 8 import 'package:front_end/incremental_kernel_generator.dart'; | 8 import 'package:front_end/incremental_kernel_generator.dart'; |
| 9 import 'package:front_end/memory_file_system.dart'; | 9 import 'package:front_end/memory_file_system.dart'; |
| 10 import 'package:front_end/src/incremental/byte_store.dart'; | 10 import 'package:front_end/src/incremental/byte_store.dart'; |
| (...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 import self as self; | 475 import self as self; |
| 476 import "dart:core" as core; | 476 import "dart:core" as core; |
| 477 | 477 |
| 478 static method main() → dynamic { | 478 static method main() → dynamic { |
| 479 core::double v = 2.3; | 479 core::double v = 2.3; |
| 480 } | 480 } |
| 481 '''); | 481 '''); |
| 482 } | 482 } |
| 483 } | 483 } |
| 484 | 484 |
| 485 test_updatePackageSourceUsingFileUri() async { |
| 486 writeFile('/test/.packages', 'test:lib/'); |
| 487 Uri aFileUri = writeFile( |
| 488 '/test/bin/a.dart', |
| 489 r''' |
| 490 import 'package:test/b.dart'; |
| 491 var a = b; |
| 492 '''); |
| 493 Uri bFileUri = writeFile('/test/lib/b.dart', 'var b = 1;'); |
| 494 Uri bPackageUri = Uri.parse('package:test/b.dart'); |
| 495 |
| 496 // Compute the initial state. |
| 497 { |
| 498 Program program = await getInitialState(aFileUri); |
| 499 Library library = _getLibrary(program, aFileUri); |
| 500 expect( |
| 501 _getLibraryText(library), |
| 502 r''' |
| 503 library; |
| 504 import self as self; |
| 505 import "dart:core" as core; |
| 506 import "package:test/b.dart" as b; |
| 507 |
| 508 static field core::int a = b::b; |
| 509 '''); |
| 510 } |
| 511 |
| 512 // Update b.dart and use file URI to invalidate it. |
| 513 // The delta is recomputed even though b.dart is used with the package URI. |
| 514 writeFile('/test/lib/b.dart', 'var b = 1.2;'); |
| 515 incrementalKernelGenerator.invalidate(bFileUri); |
| 516 { |
| 517 DeltaProgram delta = await incrementalKernelGenerator.computeDelta(); |
| 518 Program program = delta.newProgram; |
| 519 _assertLibraryUris(program, includes: [aFileUri, bPackageUri]); |
| 520 Library library = _getLibrary(program, aFileUri); |
| 521 expect( |
| 522 _getLibraryText(library), |
| 523 r''' |
| 524 library; |
| 525 import self as self; |
| 526 import "dart:core" as core; |
| 527 import "package:test/b.dart" as b; |
| 528 |
| 529 static field core::double a = b::b; |
| 530 '''); |
| 531 } |
| 532 } |
| 533 |
| 485 test_updatePart() async { | 534 test_updatePart() async { |
| 486 writeFile('/test/.packages', 'test:lib/'); | 535 writeFile('/test/.packages', 'test:lib/'); |
| 487 String libPath = '/test/lib/test.dart'; | 536 String libPath = '/test/lib/test.dart'; |
| 488 String partPath = '/test/lib/bar.dart'; | 537 String partPath = '/test/lib/bar.dart'; |
| 489 Uri libUri = writeFile( | 538 Uri libUri = writeFile( |
| 490 libPath, | 539 libPath, |
| 491 r''' | 540 r''' |
| 492 library foo; | 541 library foo; |
| 493 part 'bar.dart'; | 542 part 'bar.dart'; |
| 494 var a = 1; | 543 var a = 1; |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 609 throw fail('No library found with URI "$uri"'); | 658 throw fail('No library found with URI "$uri"'); |
| 610 } | 659 } |
| 611 | 660 |
| 612 String _getLibraryText(Library library) { | 661 String _getLibraryText(Library library) { |
| 613 StringBuffer buffer = new StringBuffer(); | 662 StringBuffer buffer = new StringBuffer(); |
| 614 new Printer(buffer, syntheticNames: new NameSystem()) | 663 new Printer(buffer, syntheticNames: new NameSystem()) |
| 615 .writeLibraryFile(library); | 664 .writeLibraryFile(library); |
| 616 return buffer.toString(); | 665 return buffer.toString(); |
| 617 } | 666 } |
| 618 } | 667 } |
| OLD | NEW |