| 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/byte_store/byte_store.dart'; | 10 import 'package:front_end/src/byte_store/byte_store.dart'; |
| 11 import 'package:front_end/src/fasta/kernel/utils.dart'; |
| 11 import 'package:front_end/src/incremental_kernel_generator_impl.dart'; | 12 import 'package:front_end/src/incremental_kernel_generator_impl.dart'; |
| 12 import 'package:front_end/summary_generator.dart'; | 13 import 'package:front_end/summary_generator.dart'; |
| 13 import 'package:kernel/ast.dart'; | 14 import 'package:kernel/ast.dart'; |
| 14 import 'package:kernel/text/ast_to_text.dart'; | 15 import 'package:kernel/text/ast_to_text.dart'; |
| 15 import 'package:test/test.dart'; | 16 import 'package:test/test.dart'; |
| 16 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 17 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| 17 | 18 |
| 18 import 'src/incremental/mock_sdk.dart'; | 19 import 'src/incremental/mock_sdk.dart'; |
| 19 | 20 |
| 20 main() { | 21 main() { |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 } | 195 } |
| 195 | 196 |
| 196 test_compile_useSdkOutline() async { | 197 test_compile_useSdkOutline() async { |
| 197 createSdkFiles(fileSystem); | 198 createSdkFiles(fileSystem); |
| 198 List<int> sdkOutlineBytes = await _computeSdkOutlineBytes(); | 199 List<int> sdkOutlineBytes = await _computeSdkOutlineBytes(); |
| 199 | 200 |
| 200 Uri sdkOutlineUri = Uri.parse('file:///sdk/outline.dill'); | 201 Uri sdkOutlineUri = Uri.parse('file:///sdk/outline.dill'); |
| 201 fileSystem.entityForUri(sdkOutlineUri).writeAsBytesSync(sdkOutlineBytes); | 202 fileSystem.entityForUri(sdkOutlineUri).writeAsBytesSync(sdkOutlineBytes); |
| 202 | 203 |
| 203 writeFile('/test/.packages', 'test:lib/'); | 204 writeFile('/test/.packages', 'test:lib/'); |
| 204 String path = '/test/lib/test.dart'; | 205 String aPath = '/test/lib/a.dart'; |
| 205 Uri uri = writeFile(path, r''' | 206 String bPath = '/test/lib/b.dart'; |
| 207 Uri aUri = writeFile(aPath, r''' |
| 208 int getValue() { |
| 209 return 1; |
| 210 } |
| 211 '''); |
| 212 Uri bUri = writeFile(bPath, r''' |
| 206 import 'dart:async'; | 213 import 'dart:async'; |
| 214 import 'a.dart'; |
| 215 |
| 207 var a = 1; | 216 var a = 1; |
| 208 Future<String> b; | 217 Future<String> b; |
| 209 '''); | 218 '''); |
| 210 | 219 |
| 211 Program program = await getInitialState(uri, sdkOutlineUri: sdkOutlineUri); | 220 Program program = await getInitialState(bUri, sdkOutlineUri: sdkOutlineUri); |
| 221 incrementalKernelGenerator.acceptLastDelta(); |
| 212 _assertLibraryUris(program, | 222 _assertLibraryUris(program, |
| 213 includes: [uri], excludes: [Uri.parse('dart:core')]); | 223 includes: [bUri], excludes: [Uri.parse('dart:core')]); |
| 214 | 224 |
| 215 Library library = _getLibrary(program, uri); | 225 Library library = _getLibrary(program, bUri); |
| 216 expect(_getLibraryText(library), r'''library; | 226 expect(_getLibraryText(library), r''' |
| 227 library; |
| 217 import self as self; | 228 import self as self; |
| 218 import "dart:core" as core; | 229 import "dart:core" as core; |
| 219 import "dart:async" as asy; | 230 import "dart:async" as asy; |
| 220 | 231 |
| 221 static field core::int a = 1; | 232 static field core::int a = 1; |
| 222 static field asy::Future<core::String> b; | 233 static field asy::Future<core::String> b; |
| 223 '''); | 234 '''); |
| 235 |
| 236 // Update a.dart and recompile. |
| 237 writeFile(aPath, r''' |
| 238 int getValue() { |
| 239 return 2; |
| 240 } |
| 241 '''); |
| 242 incrementalKernelGenerator.invalidate(aUri); |
| 243 var deltaProgram = await incrementalKernelGenerator.computeDelta(); |
| 244 |
| 245 // Check that the canonical names for SDK libraries are serializable. |
| 246 serializeProgram(deltaProgram.newProgram, |
| 247 filter: (library) => !library.importUri.isScheme('dart')); |
| 224 } | 248 } |
| 225 | 249 |
| 226 test_computeDelta_hasAnotherRunning() async { | 250 test_computeDelta_hasAnotherRunning() async { |
| 227 writeFile('/test/.packages', 'test:lib/'); | 251 writeFile('/test/.packages', 'test:lib/'); |
| 228 String path = '/test/lib/test.dart'; | 252 String path = '/test/lib/test.dart'; |
| 229 Uri uri = writeFile(path, ''); | 253 Uri uri = writeFile(path, ''); |
| 230 | 254 |
| 231 await getInitialState(uri); | 255 await getInitialState(uri); |
| 232 incrementalKernelGenerator.acceptLastDelta(); | 256 incrementalKernelGenerator.acceptLastDelta(); |
| 233 | 257 |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 throw fail('No library found with URI "$uri"'); | 537 throw fail('No library found with URI "$uri"'); |
| 514 } | 538 } |
| 515 | 539 |
| 516 String _getLibraryText(Library library) { | 540 String _getLibraryText(Library library) { |
| 517 StringBuffer buffer = new StringBuffer(); | 541 StringBuffer buffer = new StringBuffer(); |
| 518 new Printer(buffer, syntheticNames: new NameSystem()) | 542 new Printer(buffer, syntheticNames: new NameSystem()) |
| 519 .writeLibraryFile(library); | 543 .writeLibraryFile(library); |
| 520 return buffer.toString(); | 544 return buffer.toString(); |
| 521 } | 545 } |
| 522 } | 546 } |
| OLD | NEW |