| 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 'dart:async'; | 5 import 'dart:async'; |
| 6 import 'package:expect/expect.dart'; | 6 import 'package:expect/expect.dart'; |
| 7 import 'package:async_helper/async_helper.dart'; | 7 import 'package:async_helper/async_helper.dart'; |
| 8 import 'package:compiler/src/compiler.dart'; | 8 import 'package:compiler/src/compiler.dart'; |
| 9 import 'package:compiler/src/diagnostics/messages.dart' show | 9 import 'package:compiler/src/diagnostics/messages.dart' show |
| 10 MessageKind; | 10 MessageKind; |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 "Unexpected errors: ${compiler.errors}"); | 141 "Unexpected errors: ${compiler.errors}"); |
| 142 } | 142 } |
| 143 | 143 |
| 144 Future testPatchFunctionMetadata() async { | 144 Future testPatchFunctionMetadata() async { |
| 145 var compiler = await applyPatch( | 145 var compiler = await applyPatch( |
| 146 """ | 146 """ |
| 147 const a = 0; | 147 const a = 0; |
| 148 @a external test(); | 148 @a external test(); |
| 149 """, | 149 """, |
| 150 """ | 150 """ |
| 151 const b = 1; | 151 const _b = 1; |
| 152 @patch @b test() {} | 152 @patch @_b test() {} |
| 153 """); | 153 """); |
| 154 Element origin = ensure(compiler, "test", compiler.coreLibrary.find, | 154 Element origin = ensure(compiler, "test", compiler.coreLibrary.find, |
| 155 expectIsPatched: true, checkHasBody: true); | 155 expectIsPatched: true, checkHasBody: true); |
| 156 Element patch = ensure(compiler, "test", compiler.coreLibrary.patch.find, | 156 Element patch = ensure(compiler, "test", compiler.coreLibrary.patch.find, |
| 157 expectIsPatch: true, checkHasBody: true); | 157 expectIsPatch: true, checkHasBody: true); |
| 158 | 158 |
| 159 Expect.isTrue(compiler.warnings.isEmpty, | 159 Expect.isTrue(compiler.warnings.isEmpty, |
| 160 "Unexpected warnings: ${compiler.warnings}"); | 160 "Unexpected warnings: ${compiler.warnings}"); |
| 161 Expect.isTrue(compiler.errors.isEmpty, | 161 Expect.isTrue(compiler.errors.isEmpty, |
| 162 "Unexpected errors: ${compiler.errors}"); | 162 "Unexpected errors: ${compiler.errors}"); |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 checkHasBody: true, expectIsRegular: true); | 401 checkHasBody: true, expectIsRegular: true); |
| 402 ensure(compiler, "regular", container.patch.lookupLocalMember, | 402 ensure(compiler, "regular", container.patch.lookupLocalMember, |
| 403 checkHasBody: true, expectIsRegular: true); | 403 checkHasBody: true, expectIsRegular: true); |
| 404 | 404 |
| 405 Expect.isTrue(compiler.warnings.isEmpty, | 405 Expect.isTrue(compiler.warnings.isEmpty, |
| 406 "Unexpected warnings: ${compiler.warnings}"); | 406 "Unexpected warnings: ${compiler.warnings}"); |
| 407 Expect.isTrue(compiler.errors.isEmpty, | 407 Expect.isTrue(compiler.errors.isEmpty, |
| 408 "Unexpected errors: ${compiler.errors}"); | 408 "Unexpected errors: ${compiler.errors}"); |
| 409 } | 409 } |
| 410 | 410 |
| 411 Future testGhostMember() async { | 411 Future testInjectedMember() async { |
| 412 var compiler = await applyPatch( | 412 var compiler = await applyPatch( |
| 413 """ | 413 """ |
| 414 class Class { | 414 class Class { |
| 415 } | 415 } |
| 416 """, | 416 """, |
| 417 """ | 417 """ |
| 418 @patch class Class { | 418 @patch class Class { |
| 419 void ghost() {} | 419 void _injected() {} |
| 420 } | 420 } |
| 421 """); | 421 """); |
| 422 var container = ensure(compiler, "Class", compiler.coreLibrary.find, | 422 var container = ensure(compiler, "Class", compiler.coreLibrary.find, |
| 423 expectIsPatched: true); | 423 expectIsPatched: true); |
| 424 container.parseNode(compiler.parsing); | 424 container.parseNode(compiler.parsing); |
| 425 ensure(compiler, "Class", compiler.coreLibrary.patch.find, | 425 ensure(compiler, "Class", compiler.coreLibrary.patch.find, |
| 426 expectIsPatch: true); | 426 expectIsPatch: true); |
| 427 | 427 |
| 428 ensure(compiler, "ghost", container.lookupLocalMember, | 428 ensure(compiler, "_injected", container.lookupLocalMember, |
| 429 expectIsFound: false); | 429 expectIsFound: false); |
| 430 ensure(compiler, "ghost", container.patch.lookupLocalMember, | 430 ensure(compiler, "_injected", container.patch.lookupLocalMember, |
| 431 checkHasBody: true, expectIsRegular: true); | 431 checkHasBody: true, expectIsRegular: true); |
| 432 | 432 |
| 433 Expect.isTrue(compiler.warnings.isEmpty, | 433 Expect.isTrue(compiler.warnings.isEmpty, |
| 434 "Unexpected warnings: ${compiler.warnings}"); | 434 "Unexpected warnings: ${compiler.warnings}"); |
| 435 Expect.isTrue(compiler.errors.isEmpty, | 435 Expect.isTrue(compiler.errors.isEmpty, |
| 436 "Unexpected errors: ${compiler.errors}"); | 436 "Unexpected errors: ${compiler.errors}"); |
| 437 } | 437 } |
| 438 | 438 |
| 439 Future testInjectFunction() async { | 439 Future testInjectedPublicMember() async { |
| 440 var compiler = await applyPatch( |
| 441 """ |
| 442 class Class { |
| 443 } |
| 444 """, |
| 445 """ |
| 446 @patch class Class { |
| 447 void injected() {} |
| 448 } |
| 449 """); |
| 450 var container = ensure(compiler, "Class", compiler.coreLibrary.find, |
| 451 expectIsPatched: true); |
| 452 container.parseNode(compiler.parsing); |
| 453 ensure(compiler, "Class", compiler.coreLibrary.patch.find, |
| 454 expectIsPatch: true); |
| 455 |
| 456 ensure(compiler, "injected", container.lookupLocalMember, |
| 457 expectIsFound: false); |
| 458 ensure(compiler, "injected", container.patch.lookupLocalMember, |
| 459 checkHasBody: true, expectIsRegular: true); |
| 460 |
| 461 Expect.isTrue(compiler.warnings.isEmpty, |
| 462 "Unexpected warnings: ${compiler.warnings}"); |
| 463 Expect.equals(1, compiler.errors.length, |
| 464 "Unexpected errors: ${compiler.errors}"); |
| 465 Expect.isTrue( |
| 466 compiler.errors[0].message.kind == MessageKind.INJECTED_PUBLIC_MEMBER); |
| 467 } |
| 468 |
| 469 Future testInjectedFunction() async { |
| 440 var compiler = await applyPatch( | 470 var compiler = await applyPatch( |
| 441 "", | 471 "", |
| 442 "int _function() => 5;"); | 472 "int _function() => 5;"); |
| 443 ensure(compiler, | 473 ensure(compiler, |
| 444 "_function", | 474 "_function", |
| 445 compiler.coreLibrary.find, | 475 compiler.coreLibrary.find, |
| 446 expectIsFound: false); | 476 expectIsFound: false); |
| 447 ensure(compiler, | 477 ensure(compiler, |
| 448 "_function", | 478 "_function", |
| 449 compiler.coreLibrary.patch.find, | 479 compiler.coreLibrary.patch.find, |
| 450 checkHasBody: true, expectIsRegular: true); | 480 checkHasBody: true, expectIsRegular: true); |
| 451 | 481 |
| 452 Expect.isTrue(compiler.warnings.isEmpty, | 482 Expect.isTrue(compiler.warnings.isEmpty, |
| 453 "Unexpected warnings: ${compiler.warnings}"); | 483 "Unexpected warnings: ${compiler.warnings}"); |
| 454 Expect.isTrue(compiler.errors.isEmpty, | 484 Expect.isTrue(compiler.errors.isEmpty, |
| 455 "Unexpected errors: ${compiler.errors}"); | 485 "Unexpected errors: ${compiler.errors}"); |
| 456 } | 486 } |
| 457 | 487 |
| 488 Future testInjectedPublicFunction() async { |
| 489 var compiler = await applyPatch( |
| 490 "", |
| 491 "int function() => 5;"); |
| 492 ensure(compiler, |
| 493 "function", |
| 494 compiler.coreLibrary.find, |
| 495 expectIsFound: false); |
| 496 ensure(compiler, |
| 497 "function", |
| 498 compiler.coreLibrary.patch.find, |
| 499 checkHasBody: true, expectIsRegular: true); |
| 500 |
| 501 Expect.isTrue(compiler.warnings.isEmpty, |
| 502 "Unexpected warnings: ${compiler.warnings}"); |
| 503 Expect.equals(1, compiler.errors.length, |
| 504 "Unexpected errors: ${compiler.errors}"); |
| 505 Expect.isTrue( |
| 506 compiler.errors[0].message.kind == MessageKind.INJECTED_PUBLIC_MEMBER); |
| 507 } |
| 508 |
| 458 Future testPatchSignatureCheck() async { | 509 Future testPatchSignatureCheck() async { |
| 459 var compiler = await applyPatch( | 510 var compiler = await applyPatch( |
| 460 """ | 511 """ |
| 461 class Class { | 512 class Class { |
| 462 external String method1(); | 513 external String method1(); |
| 463 external void method2(String str); | 514 external void method2(String str); |
| 464 external void method3(String s1); | 515 external void method3(String s1); |
| 465 external void method4([String str]); | 516 external void method4([String str]); |
| 466 external void method5({String str}); | 517 external void method5({String str}); |
| 467 external void method6({String str}); | 518 external void method6({String str}); |
| (...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 994 | 1045 |
| 995 main() { | 1046 main() { |
| 996 asyncTest(() async { | 1047 asyncTest(() async { |
| 997 await testPatchConstructor(); | 1048 await testPatchConstructor(); |
| 998 await testPatchRedirectingConstructor(); | 1049 await testPatchRedirectingConstructor(); |
| 999 await testPatchFunction(); | 1050 await testPatchFunction(); |
| 1000 await testPatchFunctionMetadata(); | 1051 await testPatchFunctionMetadata(); |
| 1001 await testPatchMember(); | 1052 await testPatchMember(); |
| 1002 await testPatchGetter(); | 1053 await testPatchGetter(); |
| 1003 await testRegularMember(); | 1054 await testRegularMember(); |
| 1004 await testGhostMember(); | 1055 await testInjectedMember(); |
| 1005 await testInjectFunction(); | 1056 await testInjectedPublicMember(); |
| 1057 await testInjectedFunction(); |
| 1058 await testInjectedPublicFunction(); |
| 1006 await testPatchSignatureCheck(); | 1059 await testPatchSignatureCheck(); |
| 1007 | 1060 |
| 1008 await testPatchVersioned(); | 1061 await testPatchVersioned(); |
| 1009 | 1062 |
| 1010 await testExternalWithoutImplementationTopLevel(); | 1063 await testExternalWithoutImplementationTopLevel(); |
| 1011 await testExternalWithoutImplementationMember(); | 1064 await testExternalWithoutImplementationMember(); |
| 1012 | 1065 |
| 1013 await testIsSubclass(); | 1066 await testIsSubclass(); |
| 1014 | 1067 |
| 1015 await testPatchNonExistingTopLevel(); | 1068 await testPatchNonExistingTopLevel(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1026 await testPatchNonFunction(); | 1079 await testPatchNonFunction(); |
| 1027 | 1080 |
| 1028 await testPatchAndSelector(); | 1081 await testPatchAndSelector(); |
| 1029 | 1082 |
| 1030 await testEffectiveTarget(); | 1083 await testEffectiveTarget(); |
| 1031 | 1084 |
| 1032 await testAnalyzeAllInjectedMembers(); | 1085 await testAnalyzeAllInjectedMembers(); |
| 1033 await testTypecheckPatchedMembers(); | 1086 await testTypecheckPatchedMembers(); |
| 1034 }); | 1087 }); |
| 1035 } | 1088 } |
| OLD | NEW |