| 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/fasta/kernel/utils.dart'; | |
| 11 import 'package:front_end/src/incremental/byte_store.dart'; | 10 import 'package:front_end/src/incremental/byte_store.dart'; |
| 12 import 'package:front_end/src/incremental_kernel_generator_impl.dart'; | 11 import 'package:front_end/src/incremental_kernel_generator_impl.dart'; |
| 13 import 'package:kernel/ast.dart'; | 12 import 'package:kernel/ast.dart'; |
| 14 import 'package:kernel/binary/ast_from_binary.dart'; | |
| 15 import 'package:kernel/text/ast_to_text.dart'; | 13 import 'package:kernel/text/ast_to_text.dart'; |
| 16 import 'package:kernel/verifier.dart'; | |
| 17 import 'package:test/test.dart'; | 14 import 'package:test/test.dart'; |
| 18 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 15 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| 19 | 16 |
| 20 import 'src/incremental/mock_sdk.dart'; | 17 import 'src/incremental/mock_sdk.dart'; |
| 21 | 18 |
| 22 main() { | 19 main() { |
| 23 defineReflectiveSuite(() { | 20 defineReflectiveSuite(() { |
| 24 defineReflectiveTests(IncrementalKernelGeneratorTest); | 21 defineReflectiveTests(IncrementalKernelGeneratorTest); |
| 25 }); | 22 }); |
| 26 } | 23 } |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 static field core::int c1 = a::a; | 124 static field core::int c1 = a::a; |
| 128 static field core::double c2 = b::b; | 125 static field core::double c2 = b::b; |
| 129 static method main() → void {} | 126 static method main() → void {} |
| 130 '''); | 127 '''); |
| 131 // The main method is set even though not the entry point is updated. | 128 // The main method is set even though not the entry point is updated. |
| 132 expect(program.mainMethod, isNotNull); | 129 expect(program.mainMethod, isNotNull); |
| 133 expect(program.mainMethod.enclosingLibrary.fileUri, cUri.toString()); | 130 expect(program.mainMethod.enclosingLibrary.fileUri, cUri.toString()); |
| 134 } | 131 } |
| 135 } | 132 } |
| 136 | 133 |
| 137 test_compile_export() async { | |
| 138 writeFile('/test/.packages', 'test:lib/'); | |
| 139 String aPath = '/test/lib/a.dart'; | |
| 140 String bPath = '/test/lib/b.dart'; | |
| 141 String cPath = '/test/lib/c.dart'; | |
| 142 writeFile(aPath, 'class A {}'); | |
| 143 writeFile(bPath, 'export "a.dart";'); | |
| 144 Uri cUri = writeFile( | |
| 145 cPath, | |
| 146 r''' | |
| 147 import 'b.dart'; | |
| 148 A a; | |
| 149 '''); | |
| 150 | |
| 151 Program program = await getInitialState(cUri); | |
| 152 Library library = _getLibrary(program, cUri); | |
| 153 expect( | |
| 154 _getLibraryText(library), | |
| 155 r''' | |
| 156 library; | |
| 157 import self as self; | |
| 158 import "./a.dart" as a; | |
| 159 | |
| 160 static field a::A a; | |
| 161 '''); | |
| 162 } | |
| 163 | |
| 164 test_compile_export_cycle() async { | |
| 165 writeFile('/test/.packages', 'test:lib/'); | |
| 166 String aPath = '/test/lib/a.dart'; | |
| 167 String bPath = '/test/lib/b.dart'; | |
| 168 String cPath = '/test/lib/c.dart'; | |
| 169 writeFile(aPath, 'export "b.dart"; class A {}'); | |
| 170 writeFile(bPath, 'export "a.dart"; class B {}'); | |
| 171 Uri cUri = writeFile( | |
| 172 cPath, | |
| 173 r''' | |
| 174 import 'b.dart'; | |
| 175 A a; | |
| 176 B b; | |
| 177 '''); | |
| 178 | |
| 179 { | |
| 180 Program program = await getInitialState(cUri); | |
| 181 Library library = _getLibrary(program, cUri); | |
| 182 expect( | |
| 183 _getLibraryText(library), | |
| 184 r''' | |
| 185 library; | |
| 186 import self as self; | |
| 187 import "./a.dart" as a; | |
| 188 import "./b.dart" as b; | |
| 189 | |
| 190 static field a::A a; | |
| 191 static field b::B b; | |
| 192 '''); | |
| 193 } | |
| 194 | |
| 195 // Update c.dart and compile. | |
| 196 // We should load the cycle [a.dart, b.dart] from the byte store. | |
| 197 // This tests that we compute export scopes after loading. | |
| 198 writeFile( | |
| 199 cPath, | |
| 200 r''' | |
| 201 import 'b.dart'; | |
| 202 A a; | |
| 203 B b; | |
| 204 int c; | |
| 205 '''); | |
| 206 incrementalKernelGenerator.invalidate(cUri); | |
| 207 { | |
| 208 DeltaProgram delta = await incrementalKernelGenerator.computeDelta(); | |
| 209 Program program = delta.newProgram; | |
| 210 Library library = _getLibrary(program, cUri); | |
| 211 expect( | |
| 212 _getLibraryText(library), | |
| 213 r''' | |
| 214 library; | |
| 215 import self as self; | |
| 216 import "./a.dart" as a; | |
| 217 import "./b.dart" as b; | |
| 218 import "dart:core" as core; | |
| 219 | |
| 220 static field a::A a; | |
| 221 static field b::B b; | |
| 222 static field core::int c; | |
| 223 '''); | |
| 224 } | |
| 225 } | |
| 226 | |
| 227 test_compile_export_hideWithLocal() async { | |
| 228 writeFile('/test/.packages', 'test:lib/'); | |
| 229 String aPath = '/test/lib/a.dart'; | |
| 230 String bPath = '/test/lib/b.dart'; | |
| 231 String cPath = '/test/lib/c.dart'; | |
| 232 writeFile(aPath, 'class A {} class B {}'); | |
| 233 writeFile(bPath, 'export "a.dart"; class B {}'); | |
| 234 Uri cUri = writeFile( | |
| 235 cPath, | |
| 236 r''' | |
| 237 import 'b.dart'; | |
| 238 A a; | |
| 239 B b; | |
| 240 '''); | |
| 241 | |
| 242 Program program = await getInitialState(cUri); | |
| 243 Library library = _getLibrary(program, cUri); | |
| 244 expect( | |
| 245 _getLibraryText(library), | |
| 246 r''' | |
| 247 library; | |
| 248 import self as self; | |
| 249 import "./a.dart" as a; | |
| 250 import "./b.dart" as b; | |
| 251 | |
| 252 static field a::A a; | |
| 253 static field b::B b; | |
| 254 '''); | |
| 255 } | |
| 256 | |
| 257 test_compile_includePathToMain() async { | 134 test_compile_includePathToMain() async { |
| 258 writeFile('/test/.packages', 'test:lib/'); | 135 writeFile('/test/.packages', 'test:lib/'); |
| 259 String aPath = '/test/lib/a.dart'; | 136 String aPath = '/test/lib/a.dart'; |
| 260 String bPath = '/test/lib/b.dart'; | 137 String bPath = '/test/lib/b.dart'; |
| 261 String cPath = '/test/lib/c.dart'; | 138 String cPath = '/test/lib/c.dart'; |
| 262 String dPath = '/test/lib/d.dart'; | 139 String dPath = '/test/lib/d.dart'; |
| 263 | 140 |
| 264 // A --> B -> C | 141 // A --> B -> C |
| 265 // \-> D | 142 // \-> D |
| 266 | 143 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 Program program = delta.newProgram; | 179 Program program = delta.newProgram; |
| 303 _assertLibraryUris(program, | 180 _assertLibraryUris(program, |
| 304 includes: [aUri, bUri, cUri], | 181 includes: [aUri, bUri, cUri], |
| 305 excludes: [dUri, Uri.parse('dart:core')]); | 182 excludes: [dUri, Uri.parse('dart:core')]); |
| 306 // 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 |
| 307 // 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. |
| 308 _assertCompiledUris([cUri]); | 185 _assertCompiledUris([cUri]); |
| 309 } | 186 } |
| 310 } | 187 } |
| 311 | 188 |
| 312 test_compile_recompileMixin() async { | |
| 313 writeFile('/test/.packages', 'test:lib/'); | |
| 314 String aPath = '/test/lib/a.dart'; | |
| 315 String bPath = '/test/lib/b.dart'; | |
| 316 String cPath = '/test/lib/c.dart'; | |
| 317 | |
| 318 Uri aUri = writeFile( | |
| 319 aPath, | |
| 320 r''' | |
| 321 import 'b.dart'; | |
| 322 main() { | |
| 323 new B().foo(); | |
| 324 } | |
| 325 '''); | |
| 326 Uri bUri = writeFile( | |
| 327 bPath, | |
| 328 r''' | |
| 329 import 'c.dart'; | |
| 330 class B extends Object with C {} | |
| 331 '''); | |
| 332 Uri cUri = writeFile( | |
| 333 cPath, | |
| 334 r''' | |
| 335 class C { | |
| 336 void foo() { | |
| 337 print(0); | |
| 338 } | |
| 339 } | |
| 340 '''); | |
| 341 | |
| 342 { | |
| 343 Program program = await getInitialState(aUri); | |
| 344 _assertLibraryUris(program, | |
| 345 includes: [aUri, bUri, cUri, Uri.parse('dart:core')]); | |
| 346 } | |
| 347 | |
| 348 // Update c.dart and compute the delta. | |
| 349 // Includes: c.dart, b.dart and a.dart files. | |
| 350 // Compiled: c.dart (changed) and b.dart (has mixin), but not a.dart file. | |
| 351 writeFile( | |
| 352 cPath, | |
| 353 r''' | |
| 354 class C { | |
| 355 void foo() { | |
| 356 print(1); | |
| 357 } | |
| 358 } | |
| 359 '''); | |
| 360 incrementalKernelGenerator.invalidate(cUri); | |
| 361 { | |
| 362 DeltaProgram delta = await incrementalKernelGenerator.computeDelta(); | |
| 363 Program program = delta.newProgram; | |
| 364 _assertLibraryUris(program, | |
| 365 includes: [aUri, bUri, cUri], excludes: [Uri.parse('dart:core')]); | |
| 366 // Compiled: c.dart (changed), and b.dart (has mixin). | |
| 367 _assertCompiledUris([cUri, bUri]); | |
| 368 } | |
| 369 } | |
| 370 | |
| 371 test_compile_typedef() async { | |
| 372 writeFile('/test/.packages', 'test:lib/'); | |
| 373 String aPath = '/test/lib/a.dart'; | |
| 374 String bPath = '/test/lib/b.dart'; | |
| 375 writeFile(aPath, 'typedef int F<T>(T x);'); | |
| 376 Uri bUri = writeFile( | |
| 377 bPath, | |
| 378 r''' | |
| 379 import 'a.dart'; | |
| 380 F<String> f; | |
| 381 '''); | |
| 382 | |
| 383 Program program = await getInitialState(bUri); | |
| 384 Library library = _getLibrary(program, bUri); | |
| 385 expect( | |
| 386 _getLibraryText(library), | |
| 387 r''' | |
| 388 library; | |
| 389 import self as self; | |
| 390 import "dart:core" as core; | |
| 391 | |
| 392 static field (core::String) → core::int f; | |
| 393 '''); | |
| 394 } | |
| 395 | |
| 396 test_invalidateAll() async { | 189 test_invalidateAll() async { |
| 397 writeFile('/test/.packages', ''); | 190 writeFile('/test/.packages', ''); |
| 398 Uri aUri = writeFile('/test/a.dart', "import 'b.dart';\nint a = b;"); | 191 Uri aUri = writeFile('/test/a.dart', "import 'b.dart';\nint a = b;"); |
| 399 Uri bUri = writeFile('/test/b.dart', 'var b = 1;'); | 192 Uri bUri = writeFile('/test/b.dart', 'var b = 1;'); |
| 400 | 193 |
| 401 Program program = await getInitialState(aUri); | 194 Program program = await getInitialState(aUri); |
| 402 expect(_getLibraryText(_getLibrary(program, aUri)), contains("int a =")); | 195 expect(_getLibraryText(_getLibrary(program, aUri)), contains("int a =")); |
| 403 expect(_getLibraryText(_getLibrary(program, bUri)), contains("b = 1")); | 196 expect(_getLibraryText(_getLibrary(program, bUri)), contains("b = 1")); |
| 404 | 197 |
| 405 writeFile('/test/a.dart', "import 'b.dart';\ndouble a = b;"); | 198 writeFile('/test/a.dart', "import 'b.dart';\ndouble a = b;"); |
| 406 writeFile('/test/b.dart', 'var b = 2;'); | 199 writeFile('/test/b.dart', 'var b = 2;'); |
| 407 incrementalKernelGenerator.invalidateAll(); | 200 incrementalKernelGenerator.invalidateAll(); |
| 408 | 201 |
| 409 DeltaProgram delta = await incrementalKernelGenerator.computeDelta(); | 202 DeltaProgram delta = await incrementalKernelGenerator.computeDelta(); |
| 410 program = delta.newProgram; | 203 program = delta.newProgram; |
| 411 _assertLibraryUris(program, includes: [aUri, bUri]); | 204 _assertLibraryUris(program, includes: [aUri, bUri]); |
| 412 expect(_getLibraryText(_getLibrary(program, aUri)), contains("double a =")); | 205 expect(_getLibraryText(_getLibrary(program, aUri)), contains("double a =")); |
| 413 expect(_getLibraryText(_getLibrary(program, bUri)), contains("b = 2")); | 206 expect(_getLibraryText(_getLibrary(program, bUri)), contains("b = 2")); |
| 414 } | 207 } |
| 415 | 208 |
| 416 test_limited_ast_to_binary() async { | |
| 417 writeFile('/test/.packages', 'test:lib/'); | |
| 418 String aPath = '/test/lib/a.dart'; | |
| 419 String bPath = '/test/lib/b.dart'; | |
| 420 writeFile( | |
| 421 aPath, | |
| 422 r''' | |
| 423 int topField = 0; | |
| 424 int get topGetter => 0; | |
| 425 int topFunction({p}) => 0; | |
| 426 | |
| 427 abstract class I { | |
| 428 int interfaceField; | |
| 429 int get interfaceGetter; | |
| 430 int interfaceMethod(); | |
| 431 } | |
| 432 | |
| 433 class A implements I { | |
| 434 static int staticField; | |
| 435 static int get staticGetter => 0; | |
| 436 static int staticMethod() => 0; | |
| 437 | |
| 438 int instanceField; | |
| 439 int get instanceGetter => 0; | |
| 440 int instanceMethod() => 0; | |
| 441 | |
| 442 int interfaceField; | |
| 443 int get interfaceGetter => 0; | |
| 444 int interfaceMethod() => 0; | |
| 445 | |
| 446 A(); | |
| 447 A.named(); | |
| 448 } | |
| 449 '''); | |
| 450 Uri bUri = writeFile( | |
| 451 bPath, | |
| 452 r''' | |
| 453 import 'a.dart'; | |
| 454 | |
| 455 class B extends A { | |
| 456 B() : super(); | |
| 457 B.named() : super.named(); | |
| 458 | |
| 459 void foo() { | |
| 460 super.instanceMethod(); | |
| 461 instanceMethod(); | |
| 462 | |
| 463 super.interfaceField; | |
| 464 super.interfaceField = 0; | |
| 465 super.interfaceGetter; | |
| 466 super.interfaceMethod(); | |
| 467 } | |
| 468 | |
| 469 int instanceMethod() => 0; | |
| 470 | |
| 471 int interfaceField; | |
| 472 int get interfaceGetter => 0; | |
| 473 int interfaceMethod() => 0; | |
| 474 } | |
| 475 | |
| 476 main() { | |
| 477 topField; | |
| 478 topField = 0; | |
| 479 var v1 = topGetter; | |
| 480 var v2 = topFunction(p: 0); | |
| 481 | |
| 482 A.staticField; | |
| 483 A.staticField = 0; | |
| 484 var v3 = A.staticGetter; | |
| 485 var v4 = A.staticMethod(); | |
| 486 | |
| 487 var a = new A(); | |
| 488 | |
| 489 a.instanceField; | |
| 490 a.instanceField = 0; | |
| 491 var v5 = a.instanceGetter; | |
| 492 var v6 = a.instanceMethod(); | |
| 493 | |
| 494 a.interfaceField; | |
| 495 a.interfaceField = 0; | |
| 496 var v7 = a.interfaceGetter; | |
| 497 var v8 = a.interfaceMethod(); | |
| 498 } | |
| 499 '''); | |
| 500 | |
| 501 Program program = await getInitialState(bUri); | |
| 502 | |
| 503 String initialKernelText; | |
| 504 List<int> bytes; | |
| 505 { | |
| 506 Library initialLibrary = _getLibrary(program, bUri); | |
| 507 initialKernelText = _getLibraryText(initialLibrary); | |
| 508 | |
| 509 bytes = serializeProgram(program, | |
| 510 filter: (library) => library.importUri == bUri); | |
| 511 | |
| 512 // Remove b.dart from the program. | |
| 513 // So, the program is now ready for re-adding the library. | |
| 514 program.mainMethod = null; | |
| 515 program.libraries.remove(initialLibrary); | |
| 516 program.root.removeChild(initialLibrary.importUri.toString()); | |
| 517 } | |
| 518 | |
| 519 // Load b.dart from bytes using the initial name root, so that | |
| 520 // serialized canonical names can be linked to corresponding nodes. | |
| 521 Library loadedLibrary; | |
| 522 { | |
| 523 var programForLoading = new Program(nameRoot: program.root); | |
| 524 var reader = new BinaryBuilder(bytes); | |
| 525 reader.readProgram(programForLoading); | |
| 526 loadedLibrary = _getLibrary(programForLoading, bUri); | |
| 527 } | |
| 528 | |
| 529 // Add the library into the program. | |
| 530 program.libraries.add(loadedLibrary); | |
| 531 loadedLibrary.parent = program; | |
| 532 program.mainMethod = loadedLibrary.procedures | |
| 533 .firstWhere((procedure) => procedure.name.name == 'main'); | |
| 534 | |
| 535 expect(_getLibraryText(loadedLibrary), initialKernelText); | |
| 536 verifyProgram(program); | |
| 537 } | |
| 538 | |
| 539 test_updateEntryPoint() async { | 209 test_updateEntryPoint() async { |
| 540 writeFile('/test/.packages', 'test:lib/'); | 210 writeFile('/test/.packages', 'test:lib/'); |
| 541 String path = '/test/lib/test.dart'; | 211 String path = '/test/lib/test.dart'; |
| 542 Uri uri = writeFile( | 212 Uri uri = writeFile( |
| 543 path, | 213 path, |
| 544 r''' | 214 r''' |
| 545 main() { | 215 main() { |
| 546 var v = 1; | 216 var v = 1; |
| 547 } | 217 } |
| 548 '''); | 218 '''); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 593 import self as self; | 263 import self as self; |
| 594 import "dart:core" as core; | 264 import "dart:core" as core; |
| 595 | 265 |
| 596 static method main() → dynamic { | 266 static method main() → dynamic { |
| 597 core::double v = 2.3; | 267 core::double v = 2.3; |
| 598 } | 268 } |
| 599 '''); | 269 '''); |
| 600 } | 270 } |
| 601 } | 271 } |
| 602 | 272 |
| 603 test_updatePackageSourceUsingFileUri() async { | |
| 604 writeFile('/test/.packages', 'test:lib/'); | |
| 605 Uri aFileUri = writeFile( | |
| 606 '/test/bin/a.dart', | |
| 607 r''' | |
| 608 import 'package:test/b.dart'; | |
| 609 var a = b; | |
| 610 '''); | |
| 611 Uri bFileUri = writeFile('/test/lib/b.dart', 'var b = 1;'); | |
| 612 Uri bPackageUri = Uri.parse('package:test/b.dart'); | |
| 613 | |
| 614 // Compute the initial state. | |
| 615 { | |
| 616 Program program = await getInitialState(aFileUri); | |
| 617 Library library = _getLibrary(program, aFileUri); | |
| 618 expect( | |
| 619 _getLibraryText(library), | |
| 620 r''' | |
| 621 library; | |
| 622 import self as self; | |
| 623 import "dart:core" as core; | |
| 624 import "package:test/b.dart" as b; | |
| 625 | |
| 626 static field core::int a = b::b; | |
| 627 '''); | |
| 628 } | |
| 629 | |
| 630 // Update b.dart and use file URI to invalidate it. | |
| 631 // The delta is recomputed even though b.dart is used with the package URI. | |
| 632 writeFile('/test/lib/b.dart', 'var b = 1.2;'); | |
| 633 incrementalKernelGenerator.invalidate(bFileUri); | |
| 634 { | |
| 635 DeltaProgram delta = await incrementalKernelGenerator.computeDelta(); | |
| 636 Program program = delta.newProgram; | |
| 637 _assertLibraryUris(program, includes: [aFileUri, bPackageUri]); | |
| 638 Library library = _getLibrary(program, aFileUri); | |
| 639 expect( | |
| 640 _getLibraryText(library), | |
| 641 r''' | |
| 642 library; | |
| 643 import self as self; | |
| 644 import "dart:core" as core; | |
| 645 import "package:test/b.dart" as b; | |
| 646 | |
| 647 static field core::double a = b::b; | |
| 648 '''); | |
| 649 } | |
| 650 } | |
| 651 | |
| 652 test_updatePart() async { | |
| 653 writeFile('/test/.packages', 'test:lib/'); | |
| 654 String libPath = '/test/lib/test.dart'; | |
| 655 String partPath = '/test/lib/bar.dart'; | |
| 656 Uri libUri = writeFile( | |
| 657 libPath, | |
| 658 r''' | |
| 659 library foo; | |
| 660 part 'bar.dart'; | |
| 661 var a = 1; | |
| 662 var c = b; | |
| 663 void main() {} | |
| 664 '''); | |
| 665 Uri partUri = writeFile( | |
| 666 partPath, | |
| 667 r''' | |
| 668 part of foo; | |
| 669 var b = 2; | |
| 670 var d = a; | |
| 671 '''); | |
| 672 | |
| 673 // Check the initial state - types flow between the part and the library. | |
| 674 Program program = await getInitialState(libUri); | |
| 675 Library library = _getLibrary(program, libUri); | |
| 676 expect( | |
| 677 _getLibraryText(library), | |
| 678 r''' | |
| 679 library foo; | |
| 680 import self as self; | |
| 681 import "dart:core" as core; | |
| 682 | |
| 683 static field core::int a = 1; | |
| 684 static field core::int c = self::b; | |
| 685 static field core::int b = 2 /* from file:///test/lib/bar.dart */; | |
| 686 static field core::int d = self::a /* from file:///test/lib/bar.dart */; | |
| 687 static method main() → void {} | |
| 688 '''); | |
| 689 | |
| 690 // Update [b] in the part, the type is changed in the part and library. | |
| 691 { | |
| 692 writeFile( | |
| 693 partPath, | |
| 694 r''' | |
| 695 part of foo; | |
| 696 var b = 2.3; | |
| 697 var d = a; | |
| 698 '''); | |
| 699 incrementalKernelGenerator.invalidate(partUri); | |
| 700 DeltaProgram delta = await incrementalKernelGenerator.computeDelta(); | |
| 701 Library library = _getLibrary(delta.newProgram, libUri); | |
| 702 expect( | |
| 703 _getLibraryText(library), | |
| 704 r''' | |
| 705 library foo; | |
| 706 import self as self; | |
| 707 import "dart:core" as core; | |
| 708 | |
| 709 static field core::int a = 1; | |
| 710 static field core::double c = self::b; | |
| 711 static field core::double b = 2.3 /* from file:///test/lib/bar.dart */; | |
| 712 static field core::int d = self::a /* from file:///test/lib/bar.dart */; | |
| 713 static method main() → void {} | |
| 714 '''); | |
| 715 } | |
| 716 | |
| 717 // Update [a] in the library, the type is changed in the part and library. | |
| 718 { | |
| 719 writeFile( | |
| 720 libPath, | |
| 721 r''' | |
| 722 library foo; | |
| 723 part 'bar.dart'; | |
| 724 var a = 'aaa'; | |
| 725 var c = b; | |
| 726 void main() {} | |
| 727 '''); | |
| 728 incrementalKernelGenerator.invalidate(libUri); | |
| 729 DeltaProgram delta = await incrementalKernelGenerator.computeDelta(); | |
| 730 Library library = _getLibrary(delta.newProgram, libUri); | |
| 731 expect( | |
| 732 _getLibraryText(library), | |
| 733 r''' | |
| 734 library foo; | |
| 735 import self as self; | |
| 736 import "dart:core" as core; | |
| 737 | |
| 738 static field core::String a = "aaa"; | |
| 739 static field core::double c = self::b; | |
| 740 static field core::double b = 2.3 /* from file:///test/lib/bar.dart */; | |
| 741 static field core::String d = self::a /* from file:///test/lib/bar.dart */; | |
| 742 static method main() → void {} | |
| 743 '''); | |
| 744 } | |
| 745 } | |
| 746 | |
| 747 test_watch() async { | 273 test_watch() async { |
| 748 writeFile('/test/.packages', 'test:lib/'); | 274 writeFile('/test/.packages', 'test:lib/'); |
| 749 String aPath = '/test/lib/a.dart'; | 275 String aPath = '/test/lib/a.dart'; |
| 750 String bPath = '/test/lib/b.dart'; | 276 String bPath = '/test/lib/b.dart'; |
| 751 String cPath = '/test/lib/c.dart'; | 277 String cPath = '/test/lib/c.dart'; |
| 752 Uri aUri = writeFile(aPath, ''); | 278 Uri aUri = writeFile(aPath, ''); |
| 753 Uri bUri = writeFile(bPath, ''); | 279 Uri bUri = writeFile(bPath, ''); |
| 754 Uri cUri = writeFile( | 280 Uri cUri = writeFile( |
| 755 cPath, | 281 cPath, |
| 756 r''' | 282 r''' |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 872 throw fail('No library found with URI "$uri"'); | 398 throw fail('No library found with URI "$uri"'); |
| 873 } | 399 } |
| 874 | 400 |
| 875 String _getLibraryText(Library library) { | 401 String _getLibraryText(Library library) { |
| 876 StringBuffer buffer = new StringBuffer(); | 402 StringBuffer buffer = new StringBuffer(); |
| 877 new Printer(buffer, syntheticNames: new NameSystem()) | 403 new Printer(buffer, syntheticNames: new NameSystem()) |
| 878 .writeLibraryFile(library); | 404 .writeLibraryFile(library); |
| 879 return buffer.toString(); | 405 return buffer.toString(); |
| 880 } | 406 } |
| 881 } | 407 } |
| OLD | NEW |