| 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/memory_file_system.dart'; | 8 import 'package:front_end/memory_file_system.dart'; |
| 9 import 'package:front_end/src/base/performace_logger.dart'; | 9 import 'package:front_end/src/base/performace_logger.dart'; |
| 10 import 'package:front_end/src/base/processed_options.dart'; | 10 import 'package:front_end/src/base/processed_options.dart'; |
| 11 import 'package:front_end/src/byte_store/byte_store.dart'; |
| 11 import 'package:front_end/src/fasta/kernel/utils.dart'; | 12 import 'package:front_end/src/fasta/kernel/utils.dart'; |
| 12 import 'package:front_end/src/fasta/uri_translator_impl.dart'; | 13 import 'package:front_end/src/fasta/uri_translator_impl.dart'; |
| 13 import 'package:front_end/src/byte_store/byte_store.dart'; | |
| 14 import 'package:front_end/src/incremental/kernel_driver.dart'; | 14 import 'package:front_end/src/incremental/kernel_driver.dart'; |
| 15 import 'package:front_end/summary_generator.dart'; | 15 import 'package:front_end/summary_generator.dart'; |
| 16 import 'package:kernel/ast.dart'; | 16 import 'package:kernel/ast.dart'; |
| 17 import 'package:kernel/binary/ast_from_binary.dart'; | 17 import 'package:kernel/binary/ast_from_binary.dart'; |
| 18 import 'package:kernel/target/targets.dart'; | 18 import 'package:kernel/target/targets.dart'; |
| 19 import 'package:kernel/text/ast_to_text.dart'; | 19 import 'package:kernel/text/ast_to_text.dart'; |
| 20 import 'package:kernel/verifier.dart'; | 20 import 'package:kernel/verifier.dart'; |
| 21 import 'package:package_config/src/packages_impl.dart'; | 21 import 'package:package_config/src/packages_impl.dart'; |
| 22 import 'package:test/test.dart'; | 22 import 'package:test/test.dart'; |
| 23 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 23 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 } | 288 } |
| 289 | 289 |
| 290 test_compile_useSdkOutline() async { | 290 test_compile_useSdkOutline() async { |
| 291 List<int> sdkOutlineBytes = await _computeSdkOutlineBytes(); | 291 List<int> sdkOutlineBytes = await _computeSdkOutlineBytes(); |
| 292 | 292 |
| 293 // Configure the driver to use the SDK outline. | 293 // Configure the driver to use the SDK outline. |
| 294 _createDriver(sdkOutlineBytes: sdkOutlineBytes); | 294 _createDriver(sdkOutlineBytes: sdkOutlineBytes); |
| 295 | 295 |
| 296 writeFile('/test/.packages', 'test:lib/'); | 296 writeFile('/test/.packages', 'test:lib/'); |
| 297 String aPath = '/test/lib/a.dart'; | 297 String aPath = '/test/lib/a.dart'; |
| 298 String bPath = '/test/lib/b.dart'; |
| 298 Uri aUri = writeFile(aPath, r''' | 299 Uri aUri = writeFile(aPath, r''' |
| 300 int getValue() { |
| 301 return 1; |
| 302 } |
| 303 '''); |
| 304 Uri bUri = writeFile(bPath, r''' |
| 299 import 'dart:async'; | 305 import 'dart:async'; |
| 306 import 'a.dart'; |
| 300 var a = 1; | 307 var a = 1; |
| 301 Future<String> b; | 308 Future<String> b; |
| 302 '''); | 309 '''); |
| 303 | 310 |
| 304 KernelResult result = await driver.getKernel(aUri); | 311 KernelResult result = await driver.getKernel(bUri); |
| 305 | 312 |
| 306 // The result does not include SDK libraries. | 313 // The result does not include SDK libraries. |
| 307 _assertLibraryUris(result, | 314 _assertLibraryUris(result, |
| 308 includes: [aUri], | 315 includes: [bUri], |
| 309 excludes: [Uri.parse('dart:core'), Uri.parse('dart:core')]); | 316 excludes: [Uri.parse('dart:core'), Uri.parse('dart:core')]); |
| 310 | 317 |
| 311 // The types of top-level variables are resolved. | 318 // The types of top-level variables are resolved. |
| 312 var library = _getLibrary(result, aUri); | 319 var library = _getLibrary(result, bUri); |
| 313 expect(library.fields[0].type.toString(), 'dart.core::int'); | 320 expect(library.fields[0].type.toString(), 'dart.core::int'); |
| 314 expect(library.fields[1].type.toString(), | 321 expect(library.fields[1].type.toString(), |
| 315 'dart.async::Future<dart.core::String>'); | 322 'dart.async::Future<dart.core::String>'); |
| 323 |
| 324 { |
| 325 // Update a.dart and recompile. |
| 326 writeFile(aPath, r''' |
| 327 int getValue() { |
| 328 return 2; |
| 329 } |
| 330 '''); |
| 331 driver.invalidate(aUri); |
| 332 var kernelResult = await driver.getKernel(bUri); |
| 333 var allLibraries = kernelResult.results |
| 334 .map((c) => c.kernelLibraries) |
| 335 .expand((libs) => libs) |
| 336 .toList(); |
| 337 |
| 338 // The result does not include SDK libraries. |
| 339 _assertLibraryUris(result, |
| 340 includes: [bUri], |
| 341 excludes: [Uri.parse('dart:core'), Uri.parse('dart:core')]); |
| 342 |
| 343 // The types of top-level variables are resolved. |
| 344 var library = _getLibrary(result, bUri); |
| 345 expect(library.fields[0].type.toString(), 'dart.core::int'); |
| 346 expect(library.fields[1].type.toString(), |
| 347 'dart.async::Future<dart.core::String>'); |
| 348 |
| 349 // We should be able to serialize the libraries without SDK. |
| 350 var program = |
| 351 new Program(nameRoot: kernelResult.nameRoot, libraries: allLibraries); |
| 352 serializeProgram(program, |
| 353 filter: (library) => !library.importUri.isScheme('dart')); |
| 354 } |
| 316 } | 355 } |
| 317 | 356 |
| 318 test_limitedStore_exportDependencies() async { | 357 test_limitedStore_exportDependencies() async { |
| 319 writeFile('/test/.packages', 'test:lib/'); | 358 writeFile('/test/.packages', 'test:lib/'); |
| 320 String aPath = '/test/lib/a.dart'; | 359 String aPath = '/test/lib/a.dart'; |
| 321 String bPath = '/test/lib/b.dart'; | 360 String bPath = '/test/lib/b.dart'; |
| 322 String cPath = '/test/lib/c.dart'; | 361 String cPath = '/test/lib/c.dart'; |
| 323 Uri aUri = writeFile(aPath, 'class A {}'); | 362 Uri aUri = writeFile(aPath, 'class A {}'); |
| 324 var bUri = writeFile(bPath, 'export "a.dart";'); | 363 var bUri = writeFile(bPath, 'export "a.dart";'); |
| 325 Uri cUri = writeFile(cPath, r''' | 364 Uri cUri = writeFile(cPath, r''' |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 729 .writeLibraryFile(library); | 768 .writeLibraryFile(library); |
| 730 return buffer.toString(); | 769 return buffer.toString(); |
| 731 } | 770 } |
| 732 | 771 |
| 733 /// Return the [Uri] for the given Posix [path]. | 772 /// Return the [Uri] for the given Posix [path]. |
| 734 static Uri _folderUri(String path) { | 773 static Uri _folderUri(String path) { |
| 735 if (!path.endsWith('/')) path += '/'; | 774 if (!path.endsWith('/')) path += '/'; |
| 736 return Uri.parse('file://$path'); | 775 return Uri.parse('file://$path'); |
| 737 } | 776 } |
| 738 } | 777 } |
| OLD | NEW |