| 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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 Program program = delta.newProgram; | 179 Program program = delta.newProgram; |
| 180 _assertLibraryUris(program, | 180 _assertLibraryUris(program, |
| 181 includes: [aUri, bUri, cUri], | 181 includes: [aUri, bUri, cUri], |
| 182 excludes: [dUri, Uri.parse('dart:core')]); | 182 excludes: [dUri, Uri.parse('dart:core')]); |
| 183 // While a.dart and b.dart are is included (VM needs them), they were not | 183 // While a.dart and b.dart are is included (VM needs them), they were not |
| 184 // recompiled, because the change to c.dart was in the function body. | 184 // recompiled, because the change to c.dart was in the function body. |
| 185 _assertCompiledUris([cUri]); | 185 _assertCompiledUris([cUri]); |
| 186 } | 186 } |
| 187 } | 187 } |
| 188 | 188 |
| 189 test_invalidateAll() async { | |
| 190 writeFile('/test/.packages', ''); | |
| 191 Uri aUri = writeFile('/test/a.dart', "import 'b.dart';\nint a = b;"); | |
| 192 Uri bUri = writeFile('/test/b.dart', 'var b = 1;'); | |
| 193 | |
| 194 Program program = await getInitialState(aUri); | |
| 195 expect(_getLibraryText(_getLibrary(program, aUri)), contains("int a =")); | |
| 196 expect(_getLibraryText(_getLibrary(program, bUri)), contains("b = 1")); | |
| 197 | |
| 198 writeFile('/test/a.dart', "import 'b.dart';\ndouble a = b;"); | |
| 199 writeFile('/test/b.dart', 'var b = 2;'); | |
| 200 incrementalKernelGenerator.invalidateAll(); | |
| 201 | |
| 202 DeltaProgram delta = await incrementalKernelGenerator.computeDelta(); | |
| 203 program = delta.newProgram; | |
| 204 _assertLibraryUris(program, includes: [aUri, bUri]); | |
| 205 expect(_getLibraryText(_getLibrary(program, aUri)), contains("double a =")); | |
| 206 expect(_getLibraryText(_getLibrary(program, bUri)), contains("b = 2")); | |
| 207 } | |
| 208 | |
| 209 test_updateEntryPoint() async { | 189 test_updateEntryPoint() async { |
| 210 writeFile('/test/.packages', 'test:lib/'); | 190 writeFile('/test/.packages', 'test:lib/'); |
| 211 String path = '/test/lib/test.dart'; | 191 String path = '/test/lib/test.dart'; |
| 212 Uri uri = writeFile( | 192 Uri uri = writeFile( |
| 213 path, | 193 path, |
| 214 r''' | 194 r''' |
| 215 main() { | 195 main() { |
| 216 var v = 1; | 196 var v = 1; |
| 217 } | 197 } |
| 218 '''); | 198 '''); |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 throw fail('No library found with URI "$uri"'); | 378 throw fail('No library found with URI "$uri"'); |
| 399 } | 379 } |
| 400 | 380 |
| 401 String _getLibraryText(Library library) { | 381 String _getLibraryText(Library library) { |
| 402 StringBuffer buffer = new StringBuffer(); | 382 StringBuffer buffer = new StringBuffer(); |
| 403 new Printer(buffer, syntheticNames: new NameSystem()) | 383 new Printer(buffer, syntheticNames: new NameSystem()) |
| 404 .writeLibraryFile(library); | 384 .writeLibraryFile(library); |
| 405 return buffer.toString(); | 385 return buffer.toString(); |
| 406 } | 386 } |
| 407 } | 387 } |
| OLD | NEW |