| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 "../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart"; | 5 import "../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart"; |
| 6 import "../../../sdk/lib/_internal/compiler/implementation/elements/elements.dar
t"; | 6 import "../../../sdk/lib/_internal/compiler/implementation/elements/elements.dar
t"; |
| 7 import "../../../sdk/lib/_internal/compiler/implementation/tree/tree.dart"; | 7 import "../../../sdk/lib/_internal/compiler/implementation/tree/tree.dart"; |
| 8 import "../../../sdk/lib/_internal/compiler/implementation/util/util.dart"; | 8 import "../../../sdk/lib/_internal/compiler/implementation/util/util.dart"; |
| 9 import "mock_compiler.dart"; | 9 import "mock_compiler.dart"; |
| 10 import "parser_helper.dart"; | 10 import "parser_helper.dart"; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 Expect.isFalse(node.hasBody()); | 37 Expect.isFalse(node.hasBody()); |
| 38 } | 38 } |
| 39 | 39 |
| 40 Element ensure(compiler, | 40 Element ensure(compiler, |
| 41 String name, | 41 String name, |
| 42 Element lookup(name), | 42 Element lookup(name), |
| 43 {bool expectIsPatched: false, | 43 {bool expectIsPatched: false, |
| 44 bool expectIsPatch: false, | 44 bool expectIsPatch: false, |
| 45 bool checkHasBody: false, | 45 bool checkHasBody: false, |
| 46 bool expectIsGetter: false, | 46 bool expectIsGetter: false, |
| 47 bool expectIsFound: true}) { | 47 bool expectIsFound: true, |
| 48 bool expectIsRegular: false}) { |
| 48 var element = lookup(buildSourceString(name)); | 49 var element = lookup(buildSourceString(name)); |
| 49 if (!expectIsFound) { | 50 if (!expectIsFound) { |
| 50 Expect.isNull(element); | 51 Expect.isNull(element); |
| 51 return element; | 52 return element; |
| 52 } | 53 } |
| 53 Expect.isNotNull(element); | 54 Expect.isNotNull(element); |
| 54 if (expectIsGetter) { | 55 if (expectIsGetter) { |
| 55 Expect.isTrue(element is AbstractFieldElement); | 56 Expect.isTrue(element is AbstractFieldElement); |
| 56 Expect.isNotNull(element.getter); | 57 Expect.isNotNull(element.getter); |
| 57 element = element.getter; | 58 element = element.getter; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 79 Expect.equals(element.origin, element.declaration); | 80 Expect.equals(element.origin, element.declaration); |
| 80 Expect.equals(element, element.implementation); | 81 Expect.equals(element, element.implementation); |
| 81 | 82 |
| 82 if (checkHasBody) { | 83 if (checkHasBody) { |
| 83 expectHasBody(compiler, element); | 84 expectHasBody(compiler, element); |
| 84 expectHasNoBody(compiler, element.origin); | 85 expectHasNoBody(compiler, element.origin); |
| 85 } | 86 } |
| 86 } else { | 87 } else { |
| 87 Expect.isTrue(element.isDeclaration); | 88 Expect.isTrue(element.isDeclaration); |
| 88 } | 89 } |
| 89 if (!(element.isPatched || element.isPatch)) { | 90 if (expectIsRegular) { |
| 90 Expect.isNull(element.origin); | 91 Expect.isNull(element.origin); |
| 91 Expect.isNull(element.patch); | 92 Expect.isNull(element.patch); |
| 92 | 93 |
| 93 Expect.equals(element, element.declaration); | 94 Expect.equals(element, element.declaration); |
| 94 Expect.equals(element, element.implementation); | 95 Expect.equals(element, element.implementation); |
| 95 | 96 |
| 96 if (checkHasBody) { | 97 if (checkHasBody) { |
| 97 expectHasBody(compiler, element); | 98 expectHasBody(compiler, element); |
| 98 } | 99 } |
| 99 } | 100 } |
| 100 Expect.isFalse(element.isPatched && element.isPatch); | 101 Expect.isFalse(element.isPatched && element.isPatch); |
| 101 return element; | 102 return element; |
| 102 } | 103 } |
| 103 | 104 |
| 104 testPatchFunction() { | 105 testPatchFunction() { |
| 105 var compiler = applyPatch( | 106 var compiler = applyPatch( |
| 106 "external test();", | 107 "external test();", |
| 107 "patch test() { return 'string'; } "); | 108 "patch test() { return 'string'; } "); |
| 108 ensure(compiler, "test", compiler.coreLibrary.find, | 109 ensure(compiler, "test", compiler.coreLibrary.find, |
| 109 expectIsPatched: true, checkHasBody: true); | 110 expectIsPatched: true, checkHasBody: true); |
| 110 ensure(compiler, "test", compiler.coreLibrary.patch.find, | 111 ensure(compiler, "test", compiler.coreLibrary.patch.find, |
| 111 expectIsPatch: true, checkHasBody: true); | 112 expectIsPatch: true, checkHasBody: true); |
| 112 | 113 |
| 113 Expect.isTrue(compiler.warnings.isEmpty, | 114 Expect.isTrue(compiler.warnings.isEmpty, |
| 114 "Unexpected warnings: ${compiler.warnings}"); | 115 "Unexpected warnings: ${compiler.warnings}"); |
| 115 Expect.isTrue(compiler.errors.isEmpty, | 116 Expect.isTrue(compiler.errors.isEmpty, |
| 116 "Unexpected errors: ${compiler.errors}"); | 117 "Unexpected errors: ${compiler.errors}"); |
| 117 } | 118 } |
| 118 | 119 |
| 120 testPatchConstructor() { |
| 121 var compiler = applyPatch( |
| 122 """ |
| 123 class Class { |
| 124 external Class(); |
| 125 } |
| 126 """, |
| 127 """ |
| 128 patch class Class { |
| 129 patch Class(); |
| 130 } |
| 131 """); |
| 132 var classOrigin = ensure(compiler, "Class", compiler.coreLibrary.find, |
| 133 expectIsPatched: true); |
| 134 classOrigin.ensureResolved(compiler); |
| 135 var classPatch = ensure(compiler, "Class", compiler.coreLibrary.patch.find, |
| 136 expectIsPatch: true); |
| 137 |
| 138 Expect.equals(classPatch, classOrigin.patch); |
| 139 Expect.equals(classOrigin, classPatch.origin); |
| 140 |
| 141 var constructorOrigin = ensure(compiler, "Class", |
| 142 (name) => classOrigin.localLookup(name), |
| 143 expectIsPatched: true); |
| 144 var constructorPatch = ensure(compiler, "Class", |
| 145 (name) => classPatch.localLookup(name), |
| 146 expectIsPatch: true); |
| 147 |
| 148 Expect.equals(constructorPatch, constructorOrigin.patch); |
| 149 Expect.equals(constructorOrigin, constructorPatch.origin); |
| 150 |
| 151 Expect.isTrue(compiler.warnings.isEmpty, |
| 152 "Unexpected warnings: ${compiler.warnings}"); |
| 153 Expect.isTrue(compiler.errors.isEmpty, |
| 154 "Unexpected errors: ${compiler.errors}"); |
| 155 } |
| 156 |
| 119 testPatchMember() { | 157 testPatchMember() { |
| 120 var compiler = applyPatch( | 158 var compiler = applyPatch( |
| 121 """ | 159 """ |
| 122 class Class { | 160 class Class { |
| 123 external String toString(); | 161 external String toString(); |
| 124 } | 162 } |
| 125 """, | 163 """, |
| 126 """ | 164 """ |
| 127 patch class Class { | 165 patch class Class { |
| 128 patch String toString() => 'string'; | 166 patch String toString() => 'string'; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 patch class Class { | 228 patch class Class { |
| 191 } | 229 } |
| 192 """); | 230 """); |
| 193 var container = ensure(compiler, "Class", compiler.coreLibrary.find, | 231 var container = ensure(compiler, "Class", compiler.coreLibrary.find, |
| 194 expectIsPatched: true); | 232 expectIsPatched: true); |
| 195 container.parseNode(compiler); | 233 container.parseNode(compiler); |
| 196 ensure(compiler, "Class", compiler.coreLibrary.patch.find, | 234 ensure(compiler, "Class", compiler.coreLibrary.patch.find, |
| 197 expectIsPatch: true); | 235 expectIsPatch: true); |
| 198 | 236 |
| 199 ensure(compiler, "regular", container.lookupLocalMember, | 237 ensure(compiler, "regular", container.lookupLocalMember, |
| 200 checkHasBody: true); | 238 checkHasBody: true, expectIsRegular: true); |
| 201 ensure(compiler, "regular", container.patch.lookupLocalMember, | 239 ensure(compiler, "regular", container.patch.lookupLocalMember, |
| 202 checkHasBody: true); | 240 checkHasBody: true, expectIsRegular: true); |
| 203 | 241 |
| 204 Expect.isTrue(compiler.warnings.isEmpty, | 242 Expect.isTrue(compiler.warnings.isEmpty, |
| 205 "Unexpected warnings: ${compiler.warnings}"); | 243 "Unexpected warnings: ${compiler.warnings}"); |
| 206 Expect.isTrue(compiler.errors.isEmpty, | 244 Expect.isTrue(compiler.errors.isEmpty, |
| 207 "Unexpected errors: ${compiler.errors}"); | 245 "Unexpected errors: ${compiler.errors}"); |
| 208 } | 246 } |
| 209 | 247 |
| 210 testGhostMember() { | 248 testGhostMember() { |
| 211 var compiler = applyPatch( | 249 var compiler = applyPatch( |
| 212 """ | 250 """ |
| 213 class Class { | 251 class Class { |
| 214 } | 252 } |
| 215 """, | 253 """, |
| 216 """ | 254 """ |
| 217 patch class Class { | 255 patch class Class { |
| 218 void ghost() {} | 256 void ghost() {} |
| 219 } | 257 } |
| 220 """); | 258 """); |
| 221 var container = ensure(compiler, "Class", compiler.coreLibrary.find, | 259 var container = ensure(compiler, "Class", compiler.coreLibrary.find, |
| 222 expectIsPatched: true); | 260 expectIsPatched: true); |
| 223 container.parseNode(compiler); | 261 container.parseNode(compiler); |
| 224 ensure(compiler, "Class", compiler.coreLibrary.patch.find, | 262 ensure(compiler, "Class", compiler.coreLibrary.patch.find, |
| 225 expectIsPatch: true); | 263 expectIsPatch: true); |
| 226 | 264 |
| 227 ensure(compiler, "ghost", container.lookupLocalMember, | 265 ensure(compiler, "ghost", container.lookupLocalMember, |
| 228 expectIsFound: false); | 266 expectIsFound: false); |
| 229 ensure(compiler, "ghost", container.patch.lookupLocalMember, | 267 ensure(compiler, "ghost", container.patch.lookupLocalMember, |
| 230 checkHasBody: true); | 268 checkHasBody: true, expectIsRegular: true); |
| 231 | 269 |
| 232 Expect.isTrue(compiler.warnings.isEmpty, | 270 Expect.isTrue(compiler.warnings.isEmpty, |
| 233 "Unexpected warnings: ${compiler.warnings}"); | 271 "Unexpected warnings: ${compiler.warnings}"); |
| 234 Expect.isTrue(compiler.errors.isEmpty, | 272 Expect.isTrue(compiler.errors.isEmpty, |
| 235 "Unexpected errors: ${compiler.errors}"); | 273 "Unexpected errors: ${compiler.errors}"); |
| 236 } | 274 } |
| 237 | 275 |
| 238 testInjectFunction() { | 276 testInjectFunction() { |
| 239 var compiler = applyPatch( | 277 var compiler = applyPatch( |
| 240 "", | 278 "", |
| 241 "int _function() => 5;"); | 279 "int _function() => 5;"); |
| 242 ensure(compiler, | 280 ensure(compiler, |
| 243 "_function", | 281 "_function", |
| 244 compiler.coreLibrary.find, | 282 compiler.coreLibrary.find, |
| 245 expectIsFound: false); | 283 expectIsFound: false); |
| 246 ensure(compiler, | 284 ensure(compiler, |
| 247 "_function", | 285 "_function", |
| 248 compiler.coreLibrary.patch.find, | 286 compiler.coreLibrary.patch.find, |
| 249 checkHasBody: true); | 287 checkHasBody: true, expectIsRegular: true); |
| 250 | 288 |
| 251 Expect.isTrue(compiler.warnings.isEmpty, | 289 Expect.isTrue(compiler.warnings.isEmpty, |
| 252 "Unexpected warnings: ${compiler.warnings}"); | 290 "Unexpected warnings: ${compiler.warnings}"); |
| 253 Expect.isTrue(compiler.errors.isEmpty, | 291 Expect.isTrue(compiler.errors.isEmpty, |
| 254 "Unexpected errors: ${compiler.errors}"); | 292 "Unexpected errors: ${compiler.errors}"); |
| 255 } | 293 } |
| 256 | 294 |
| 257 testPatchSignatureCheck() { | 295 testPatchSignatureCheck() { |
| 258 var compiler = applyPatch( | 296 var compiler = applyPatch( |
| 259 """ | 297 """ |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 // patch void foo() {} | 411 // patch void foo() {} |
| 374 """); | 412 """); |
| 375 var function = ensure(compiler, "foo", compiler.coreLibrary.find); | 413 var function = ensure(compiler, "foo", compiler.coreLibrary.find); |
| 376 compiler.resolver.resolve(function); | 414 compiler.resolver.resolve(function); |
| 377 Expect.isTrue(compiler.warnings.isEmpty, | 415 Expect.isTrue(compiler.warnings.isEmpty, |
| 378 "Unexpected warnings: ${compiler.warnings}"); | 416 "Unexpected warnings: ${compiler.warnings}"); |
| 379 print('testExternalWithoutImplementationTopLevel:${compiler.errors}'); | 417 print('testExternalWithoutImplementationTopLevel:${compiler.errors}'); |
| 380 Expect.equals(1, compiler.errors.length); | 418 Expect.equals(1, compiler.errors.length); |
| 381 Expect.isTrue( | 419 Expect.isTrue( |
| 382 compiler.errors[0].message.kind == | 420 compiler.errors[0].message.kind == |
| 383 MessageKind.EXTERNAL_WITHOUT_IMPLEMENTATION); | 421 MessageKind.PATCH_EXTERNAL_WITHOUT_IMPLEMENTATION); |
| 384 Expect.equals('External method without an implementation.', | 422 Expect.equals('External method without an implementation.', |
| 385 compiler.errors[0].message.toString()); | 423 compiler.errors[0].message.toString()); |
| 386 } | 424 } |
| 387 | 425 |
| 388 testExternalWithoutImplementationMember() { | 426 testExternalWithoutImplementationMember() { |
| 389 var compiler = applyPatch( | 427 var compiler = applyPatch( |
| 390 """ | 428 """ |
| 391 class Class { | 429 class Class { |
| 392 external void foo(); | 430 external void foo(); |
| 393 } | 431 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 404 compiler.warnings.clear(); | 442 compiler.warnings.clear(); |
| 405 compiler.errors.clear(); | 443 compiler.errors.clear(); |
| 406 compiler.resolver.resolveMethodElement( | 444 compiler.resolver.resolveMethodElement( |
| 407 ensure(compiler, "foo", container.lookupLocalMember)); | 445 ensure(compiler, "foo", container.lookupLocalMember)); |
| 408 Expect.isTrue(compiler.warnings.isEmpty, | 446 Expect.isTrue(compiler.warnings.isEmpty, |
| 409 "Unexpected warnings: ${compiler.warnings}"); | 447 "Unexpected warnings: ${compiler.warnings}"); |
| 410 print('testExternalWithoutImplementationMember:${compiler.errors}'); | 448 print('testExternalWithoutImplementationMember:${compiler.errors}'); |
| 411 Expect.equals(1, compiler.errors.length); | 449 Expect.equals(1, compiler.errors.length); |
| 412 Expect.isTrue( | 450 Expect.isTrue( |
| 413 compiler.errors[0].message.kind == | 451 compiler.errors[0].message.kind == |
| 414 MessageKind.EXTERNAL_WITHOUT_IMPLEMENTATION); | 452 MessageKind.PATCH_EXTERNAL_WITHOUT_IMPLEMENTATION); |
| 415 Expect.equals('External method without an implementation.', | 453 Expect.equals('External method without an implementation.', |
| 416 compiler.errors[0].message.toString()); | 454 compiler.errors[0].message.toString()); |
| 417 } | 455 } |
| 418 | 456 |
| 419 testIsSubclass() { | 457 testIsSubclass() { |
| 420 var compiler = applyPatch( | 458 var compiler = applyPatch( |
| 421 """ | 459 """ |
| 422 class A {} | 460 class A {} |
| 423 """, | 461 """, |
| 424 """ | 462 """ |
| 425 patch class A {} | 463 patch class A {} |
| 426 """); | 464 """); |
| 427 ClassElement cls = ensure(compiler, "A", compiler.coreLibrary.find, | 465 ClassElement cls = ensure(compiler, "A", compiler.coreLibrary.find, |
| 428 expectIsPatched: true); | 466 expectIsPatched: true); |
| 429 ClassElement patch = cls.patch; | 467 ClassElement patch = cls.patch; |
| 430 Expect.isTrue(cls != patch); | 468 Expect.isTrue(cls != patch); |
| 431 Expect.isTrue(cls.isSubclassOf(patch)); | 469 Expect.isTrue(cls.isSubclassOf(patch)); |
| 432 Expect.isTrue(patch.isSubclassOf(cls)); | 470 Expect.isTrue(patch.isSubclassOf(cls)); |
| 433 } | 471 } |
| 434 | 472 |
| 473 testPatchNonExistingTopLevel() { |
| 474 var compiler = applyPatch( |
| 475 """ |
| 476 // class Class {} |
| 477 """, |
| 478 """ |
| 479 patch class Class {} |
| 480 """); |
| 481 Expect.isTrue(compiler.warnings.isEmpty, |
| 482 "Unexpected warnings: ${compiler.warnings}"); |
| 483 print('testPatchNonExistingTopLevel:${compiler.errors}'); |
| 484 Expect.equals(1, compiler.errors.length); |
| 485 Expect.isTrue( |
| 486 compiler.errors[0].message.kind == MessageKind.PATCH_NON_EXISTING); |
| 487 } |
| 488 |
| 489 testPatchNonExistingMember() { |
| 490 var compiler = applyPatch( |
| 491 """ |
| 492 class Class {} |
| 493 """, |
| 494 """ |
| 495 patch class Class { |
| 496 patch void foo() {} |
| 497 } |
| 498 """); |
| 499 var container = ensure(compiler, "Class", compiler.coreLibrary.find, |
| 500 expectIsPatched: true); |
| 501 container.parseNode(compiler); |
| 502 |
| 503 Expect.isTrue(compiler.warnings.isEmpty, |
| 504 "Unexpected warnings: ${compiler.warnings}"); |
| 505 print('testPatchNonExistingMember:${compiler.errors}'); |
| 506 Expect.equals(1, compiler.errors.length); |
| 507 Expect.isTrue( |
| 508 compiler.errors[0].message.kind == MessageKind.PATCH_NON_EXISTING); |
| 509 } |
| 510 |
| 511 testPatchNonPatchablePatch() { |
| 512 var compiler = applyPatch( |
| 513 """ |
| 514 external get foo; |
| 515 """, |
| 516 """ |
| 517 patch var foo; |
| 518 """); |
| 519 ensure(compiler, "foo", compiler.coreLibrary.find); |
| 520 |
| 521 Expect.isTrue(compiler.warnings.isEmpty, |
| 522 "Unexpected warnings: ${compiler.warnings}"); |
| 523 print('testPatchNonPatchablePatch:${compiler.errors}'); |
| 524 Expect.equals(1, compiler.errors.length); |
| 525 Expect.isTrue( |
| 526 compiler.errors[0].message.kind == MessageKind.PATCH_NONPATCHABLE); |
| 527 } |
| 528 |
| 529 testPatchNonPatchableOrigin() { |
| 530 var compiler = applyPatch( |
| 531 """ |
| 532 external var foo; |
| 533 """, |
| 534 """ |
| 535 patch get foo => 0; |
| 536 """); |
| 537 ensure(compiler, "foo", compiler.coreLibrary.find); |
| 538 |
| 539 Expect.isTrue(compiler.warnings.isEmpty, |
| 540 "Unexpected warnings: ${compiler.warnings}"); |
| 541 print('testPatchNonPatchableOrigin:${compiler.errors}'); |
| 542 Expect.equals(1, compiler.errors.length); |
| 543 Expect.isTrue( |
| 544 compiler.errors[0].message.kind == MessageKind.PATCH_NONPATCHABLE); |
| 545 } |
| 546 |
| 547 testPatchNonExternalTopLevel() { |
| 548 var compiler = applyPatch( |
| 549 """ |
| 550 void foo() {} |
| 551 """, |
| 552 """ |
| 553 patch void foo() {} |
| 554 """); |
| 555 print('testPatchNonExternalTopLevel.errors:${compiler.errors}'); |
| 556 print('testPatchNonExternalTopLevel.warnings:${compiler.warnings}'); |
| 557 Expect.equals(1, compiler.errors.length); |
| 558 Expect.isTrue( |
| 559 compiler.errors[0].message.kind == MessageKind.PATCH_NON_EXTERNAL); |
| 560 Expect.equals(1, compiler.warnings.length); |
| 561 Expect.isTrue( |
| 562 compiler.warnings[0].message.kind == MessageKind.PATCH_POINT_TO_FUNCTION); |
| 563 } |
| 564 |
| 565 testPatchNonExternalMember() { |
| 566 var compiler = applyPatch( |
| 567 """ |
| 568 class Class { |
| 569 void foo() {} |
| 570 } |
| 571 """, |
| 572 """ |
| 573 patch class Class { |
| 574 patch void foo() {} |
| 575 } |
| 576 """); |
| 577 var container = ensure(compiler, "Class", compiler.coreLibrary.find, |
| 578 expectIsPatched: true); |
| 579 container.parseNode(compiler); |
| 580 |
| 581 print('testPatchNonExternalMember.errors:${compiler.errors}'); |
| 582 print('testPatchNonExternalMember.warnings:${compiler.warnings}'); |
| 583 Expect.equals(1, compiler.errors.length); |
| 584 Expect.isTrue( |
| 585 compiler.errors[0].message.kind == MessageKind.PATCH_NON_EXTERNAL); |
| 586 Expect.equals(1, compiler.warnings.length); |
| 587 Expect.isTrue( |
| 588 compiler.warnings[0].message.kind == MessageKind.PATCH_POINT_TO_FUNCTION); |
| 589 } |
| 590 |
| 591 testPatchNonClass() { |
| 592 var compiler = applyPatch( |
| 593 """ |
| 594 external void Class() {} |
| 595 """, |
| 596 """ |
| 597 patch class Class {} |
| 598 """); |
| 599 print('testPatchNonClass.errors:${compiler.errors}'); |
| 600 print('testPatchNonClass.warnings:${compiler.warnings}'); |
| 601 Expect.equals(1, compiler.errors.length); |
| 602 Expect.isTrue( |
| 603 compiler.errors[0].message.kind == MessageKind.PATCH_NON_CLASS); |
| 604 Expect.equals(1, compiler.warnings.length); |
| 605 Expect.isTrue( |
| 606 compiler.warnings[0].message.kind == MessageKind.PATCH_POINT_TO_CLASS); |
| 607 } |
| 608 |
| 609 testPatchNonGetter() { |
| 610 var compiler = applyPatch( |
| 611 """ |
| 612 external void foo() {} |
| 613 """, |
| 614 """ |
| 615 patch get foo => 0; |
| 616 """); |
| 617 print('testPatchNonClass.errors:${compiler.errors}'); |
| 618 print('testPatchNonClass.warnings:${compiler.warnings}'); |
| 619 Expect.equals(1, compiler.errors.length); |
| 620 Expect.isTrue( |
| 621 compiler.errors[0].message.kind == MessageKind.PATCH_NON_GETTER); |
| 622 Expect.equals(1, compiler.warnings.length); |
| 623 Expect.isTrue( |
| 624 compiler.warnings[0].message.kind == MessageKind.PATCH_POINT_TO_GETTER); |
| 625 } |
| 626 |
| 627 testPatchNoGetter() { |
| 628 var compiler = applyPatch( |
| 629 """ |
| 630 external set foo(var value) {} |
| 631 """, |
| 632 """ |
| 633 patch get foo => 0; |
| 634 """); |
| 635 print('testPatchNonClass.errors:${compiler.errors}'); |
| 636 print('testPatchNonClass.warnings:${compiler.warnings}'); |
| 637 Expect.equals(1, compiler.errors.length); |
| 638 Expect.isTrue( |
| 639 compiler.errors[0].message.kind == MessageKind.PATCH_NO_GETTER); |
| 640 Expect.equals(1, compiler.warnings.length); |
| 641 Expect.isTrue( |
| 642 compiler.warnings[0].message.kind == MessageKind.PATCH_POINT_TO_GETTER); |
| 643 } |
| 644 |
| 645 testPatchNonSetter() { |
| 646 var compiler = applyPatch( |
| 647 """ |
| 648 external void foo() {} |
| 649 """, |
| 650 """ |
| 651 patch set foo(var value) {} |
| 652 """); |
| 653 print('testPatchNonClass.errors:${compiler.errors}'); |
| 654 print('testPatchNonClass.warnings:${compiler.warnings}'); |
| 655 Expect.equals(1, compiler.errors.length); |
| 656 Expect.isTrue( |
| 657 compiler.errors[0].message.kind == MessageKind.PATCH_NON_SETTER); |
| 658 Expect.equals(1, compiler.warnings.length); |
| 659 Expect.isTrue( |
| 660 compiler.warnings[0].message.kind == MessageKind.PATCH_POINT_TO_SETTER); |
| 661 } |
| 662 |
| 663 testPatchNoSetter() { |
| 664 var compiler = applyPatch( |
| 665 """ |
| 666 external get foo; |
| 667 """, |
| 668 """ |
| 669 patch set foo(var value) {} |
| 670 """); |
| 671 print('testPatchNonClass.errors:${compiler.errors}'); |
| 672 print('testPatchNonClass.warnings:${compiler.warnings}'); |
| 673 Expect.equals(1, compiler.errors.length); |
| 674 Expect.isTrue( |
| 675 compiler.errors[0].message.kind == MessageKind.PATCH_NO_SETTER); |
| 676 Expect.equals(1, compiler.warnings.length); |
| 677 Expect.isTrue( |
| 678 compiler.warnings[0].message.kind == MessageKind.PATCH_POINT_TO_SETTER); |
| 679 } |
| 680 |
| 681 testPatchNonFunction() { |
| 682 var compiler = applyPatch( |
| 683 """ |
| 684 external get foo; |
| 685 """, |
| 686 """ |
| 687 patch void foo() {} |
| 688 """); |
| 689 print('testPatchNonClass.errors:${compiler.errors}'); |
| 690 print('testPatchNonClass.warnings:${compiler.warnings}'); |
| 691 Expect.equals(1, compiler.errors.length); |
| 692 Expect.isTrue( |
| 693 compiler.errors[0].message.kind == MessageKind.PATCH_NON_FUNCTION); |
| 694 Expect.equals(1, compiler.warnings.length); |
| 695 Expect.isTrue( |
| 696 compiler.warnings[0].message.kind == MessageKind.PATCH_POINT_TO_FUNCTION); |
| 697 } |
| 698 |
| 435 main() { | 699 main() { |
| 700 testPatchConstructor(); |
| 436 testPatchFunction(); | 701 testPatchFunction(); |
| 437 testPatchMember(); | 702 testPatchMember(); |
| 438 testPatchGetter(); | 703 testPatchGetter(); |
| 439 testRegularMember(); | 704 testRegularMember(); |
| 440 testGhostMember(); | 705 testGhostMember(); |
| 441 testInjectFunction(); | 706 testInjectFunction(); |
| 442 testPatchSignatureCheck(); | 707 testPatchSignatureCheck(); |
| 443 | 708 |
| 444 testExternalWithoutImplementationTopLevel(); | 709 testExternalWithoutImplementationTopLevel(); |
| 445 testExternalWithoutImplementationMember(); | 710 testExternalWithoutImplementationMember(); |
| 446 | 711 |
| 447 testIsSubclass(); | 712 testIsSubclass(); |
| 713 |
| 714 testPatchNonExistingTopLevel(); |
| 715 testPatchNonExistingMember(); |
| 716 testPatchNonPatchablePatch(); |
| 717 testPatchNonPatchableOrigin(); |
| 718 testPatchNonExternalTopLevel(); |
| 719 testPatchNonExternalMember(); |
| 720 testPatchNonClass(); |
| 721 testPatchNonGetter(); |
| 722 testPatchNoGetter(); |
| 723 testPatchNonSetter(); |
| 724 testPatchNoSetter(); |
| 725 testPatchNonFunction(); |
| 448 } | 726 } |
| OLD | NEW |