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/memory_file_system.dart'; | 7 import 'package:front_end/memory_file_system.dart'; |
8 import 'package:front_end/src/base/performace_logger.dart'; | 8 import 'package:front_end/src/base/performace_logger.dart'; |
9 import 'package:front_end/src/fasta/kernel/utils.dart'; | 9 import 'package:front_end/src/fasta/kernel/utils.dart'; |
10 import 'package:front_end/src/fasta/uri_translator_impl.dart'; | 10 import 'package:front_end/src/fasta/uri_translator_impl.dart'; |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 // Add the library into the program. | 399 // Add the library into the program. |
400 program.libraries.add(loadedLibrary); | 400 program.libraries.add(loadedLibrary); |
401 loadedLibrary.parent = program; | 401 loadedLibrary.parent = program; |
402 program.mainMethod = loadedLibrary.procedures | 402 program.mainMethod = loadedLibrary.procedures |
403 .firstWhere((procedure) => procedure.name.name == 'main'); | 403 .firstWhere((procedure) => procedure.name.name == 'main'); |
404 | 404 |
405 expect(_getLibraryText(loadedLibrary), initialKernelText); | 405 expect(_getLibraryText(loadedLibrary), initialKernelText); |
406 verifyProgram(program); | 406 verifyProgram(program); |
407 } | 407 } |
408 | 408 |
| 409 test_limitedStore_exportDependencies() async { |
| 410 writeFile('/test/.packages', 'test:lib/'); |
| 411 String aPath = '/test/lib/a.dart'; |
| 412 String bPath = '/test/lib/b.dart'; |
| 413 String cPath = '/test/lib/c.dart'; |
| 414 Uri aUri = writeFile(aPath, 'class A {}'); |
| 415 var bUri = writeFile(bPath, 'export "a.dart";'); |
| 416 Uri cUri = writeFile(cPath, r''' |
| 417 import 'b.dart'; |
| 418 A a; |
| 419 '''); |
| 420 |
| 421 // Compile all libraries initially. |
| 422 await driver.getKernel(cUri); |
| 423 |
| 424 // Update c.dart and compile. |
| 425 // When we load "b", we should correctly read its exports. |
| 426 writeFile(cPath, r''' |
| 427 import 'b.dart'; |
| 428 A a2; |
| 429 '''); |
| 430 driver.invalidate(cUri); |
| 431 { |
| 432 KernelResult result = await driver.getKernel(cUri); |
| 433 Library library = _getLibrary(result, cUri); |
| 434 |
| 435 Library getDepLib(Library lib, int index) { |
| 436 return lib.dependencies[index].importedLibraryReference.asLibrary; |
| 437 } |
| 438 |
| 439 var b = getDepLib(library, 0); |
| 440 var a = getDepLib(b, 0); |
| 441 expect(b.importUri, bUri); |
| 442 expect(a.importUri, aUri); |
| 443 } |
| 444 } |
| 445 |
409 test_updatePackageSourceUsingFileUri() async { | 446 test_updatePackageSourceUsingFileUri() async { |
410 _createDriver(packages: {'test': _folderUri('/test/lib')}); | 447 _createDriver(packages: {'test': _folderUri('/test/lib')}); |
411 | 448 |
412 writeFile('/test/.packages', 'test:lib/'); | 449 writeFile('/test/.packages', 'test:lib/'); |
413 Uri aFileUri = writeFile('/test/bin/a.dart', r''' | 450 Uri aFileUri = writeFile('/test/bin/a.dart', r''' |
414 import 'package:test/b.dart'; | 451 import 'package:test/b.dart'; |
415 var a = b; | 452 var a = b; |
416 '''); | 453 '''); |
417 Uri bFileUri = writeFile('/test/lib/b.dart', 'var b = 1;'); | 454 Uri bFileUri = writeFile('/test/lib/b.dart', 'var b = 1;'); |
418 Uri bPackageUri = Uri.parse('package:test/b.dart'); | 455 Uri bPackageUri = Uri.parse('package:test/b.dart'); |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
645 .writeLibraryFile(library); | 682 .writeLibraryFile(library); |
646 return buffer.toString(); | 683 return buffer.toString(); |
647 } | 684 } |
648 | 685 |
649 /// Return the [Uri] for the given Posix [path]. | 686 /// Return the [Uri] for the given Posix [path]. |
650 static Uri _folderUri(String path) { | 687 static Uri _folderUri(String path) { |
651 if (!path.endsWith('/')) path += '/'; | 688 if (!path.endsWith('/')) path += '/'; |
652 return Uri.parse('file://$path'); | 689 return Uri.parse('file://$path'); |
653 } | 690 } |
654 } | 691 } |
OLD | NEW |