| 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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 library; | 231 library; |
| 232 import self as self; | 232 import self as self; |
| 233 import "./a.dart" as a; | 233 import "./a.dart" as a; |
| 234 import "./b.dart" as b; | 234 import "./b.dart" as b; |
| 235 | 235 |
| 236 static field a::A a; | 236 static field a::A a; |
| 237 static field b::B b; | 237 static field b::B b; |
| 238 '''); | 238 '''); |
| 239 } | 239 } |
| 240 | 240 |
| 241 test_compile_includePathToMain() async { |
| 242 writeFile('/test/.packages', 'test:lib/'); |
| 243 String aPath = '/test/lib/a.dart'; |
| 244 String bPath = '/test/lib/b.dart'; |
| 245 String cPath = '/test/lib/c.dart'; |
| 246 String dPath = '/test/lib/d.dart'; |
| 247 |
| 248 // A --> B -> C |
| 249 // \-> D |
| 250 |
| 251 Uri aUri = writeFile( |
| 252 aPath, |
| 253 r''' |
| 254 import 'b.dart'; |
| 255 import 'd.dart'; |
| 256 main() { |
| 257 b(); |
| 258 d(); |
| 259 } |
| 260 '''); |
| 261 Uri bUri = writeFile( |
| 262 bPath, |
| 263 r''' |
| 264 import 'c.dart'; |
| 265 b() { |
| 266 c(); |
| 267 } |
| 268 '''); |
| 269 Uri cUri = writeFile(cPath, 'c() { print(0); }'); |
| 270 Uri dUri = writeFile(dPath, 'd() {}'); |
| 271 |
| 272 { |
| 273 Program program = await getInitialState(aUri); |
| 274 _assertLibraryUris(program, |
| 275 includes: [aUri, bUri, cUri, dUri, Uri.parse('dart:core')]); |
| 276 } |
| 277 |
| 278 // Update c.dart and compute the delta. |
| 279 // It should include the changed c.dart, the affected b.dart, and |
| 280 // also a.dart because VM requires this (because of possible inlining). |
| 281 // But d.dart is not on the path from main() to the changed c.dart, |
| 282 // so it is not included. |
| 283 writeFile(cPath, 'c() { print(1); }'); |
| 284 incrementalKernelGenerator.invalidate(cUri); |
| 285 { |
| 286 DeltaProgram delta = await incrementalKernelGenerator.computeDelta(); |
| 287 Program program = delta.newProgram; |
| 288 _assertLibraryUris(program, |
| 289 includes: [aUri, bUri, cUri], |
| 290 excludes: [dUri, Uri.parse('dart:core')]); |
| 291 } |
| 292 } |
| 293 |
| 241 test_compile_typedef() async { | 294 test_compile_typedef() async { |
| 242 writeFile('/test/.packages', 'test:lib/'); | 295 writeFile('/test/.packages', 'test:lib/'); |
| 243 String aPath = '/test/lib/a.dart'; | 296 String aPath = '/test/lib/a.dart'; |
| 244 String bPath = '/test/lib/b.dart'; | 297 String bPath = '/test/lib/b.dart'; |
| 245 writeFile(aPath, 'typedef int F<T>(T x);'); | 298 writeFile(aPath, 'typedef int F<T>(T x);'); |
| 246 Uri bUri = writeFile( | 299 Uri bUri = writeFile( |
| 247 bPath, | 300 bPath, |
| 248 r''' | 301 r''' |
| 249 import 'a.dart'; | 302 import 'a.dart'; |
| 250 F<String> f; | 303 F<String> f; |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 throw fail('No library found with URI "$uri"'); | 507 throw fail('No library found with URI "$uri"'); |
| 455 } | 508 } |
| 456 | 509 |
| 457 String _getLibraryText(Library library) { | 510 String _getLibraryText(Library library) { |
| 458 StringBuffer buffer = new StringBuffer(); | 511 StringBuffer buffer = new StringBuffer(); |
| 459 new Printer(buffer, syntheticNames: new NameSystem()) | 512 new Printer(buffer, syntheticNames: new NameSystem()) |
| 460 .writeLibraryFile(library); | 513 .writeLibraryFile(library); |
| 461 return buffer.toString(); | 514 return buffer.toString(); |
| 462 } | 515 } |
| 463 } | 516 } |
| OLD | NEW |