| 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 22 matching lines...) Expand all Loading... |
| 33 | 33 |
| 34 void expectHasNoBody(compiler, Element element) { | 34 void expectHasNoBody(compiler, Element element) { |
| 35 var node = element.parseNode(compiler); | 35 var node = element.parseNode(compiler); |
| 36 Expect.isNotNull(node, "Element isn't parseable, when a body was expected"); | 36 Expect.isNotNull(node, "Element isn't parseable, when a body was expected"); |
| 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 isPatched: false, | 43 {bool expectIsPatched: false, |
| 44 bool isPatch: false, | 44 bool expectIsPatch: false, |
| 45 bool isMethod: true, | 45 bool checkHasBody: false, |
| 46 bool isGetter: false, | 46 bool expectIsGetter: false, |
| 47 bool isFound: true}) { | 47 bool expectIsFound: true}) { |
| 48 var element = lookup(buildSourceString(name)); | 48 var element = lookup(buildSourceString(name)); |
| 49 if (!isFound) { | 49 if (!expectIsFound) { |
| 50 Expect.isNull(element); | 50 Expect.isNull(element); |
| 51 return element; | 51 return element; |
| 52 } | 52 } |
| 53 Expect.isNotNull(element); | 53 Expect.isNotNull(element); |
| 54 if (isGetter) { | 54 if (expectIsGetter) { |
| 55 Expect.isTrue(element is AbstractFieldElement); | 55 Expect.isTrue(element is AbstractFieldElement); |
| 56 Expect.isNotNull(element.getter); | 56 Expect.isNotNull(element.getter); |
| 57 element = element.getter; | 57 element = element.getter; |
| 58 } | 58 } |
| 59 Expect.equals(isPatched, element.isPatched); | 59 Expect.equals(expectIsPatched, element.isPatched); |
| 60 if (isPatched) { | 60 if (expectIsPatched) { |
| 61 Expect.isNull(element.origin); | 61 Expect.isNull(element.origin); |
| 62 Expect.isNotNull(element.patch); | 62 Expect.isNotNull(element.patch); |
| 63 | 63 |
| 64 Expect.equals(element, element.declaration); | 64 Expect.equals(element, element.declaration); |
| 65 Expect.equals(element.patch, element.implementation); | 65 Expect.equals(element.patch, element.implementation); |
| 66 | 66 |
| 67 if (isMethod) { | 67 if (checkHasBody) { |
| 68 expectHasNoBody(compiler, element); | 68 expectHasNoBody(compiler, element); |
| 69 expectHasBody(compiler, element.patch); | 69 expectHasBody(compiler, element.patch); |
| 70 } | 70 } |
| 71 } else { | 71 } else { |
| 72 Expect.isTrue(element.isImplementation); | 72 Expect.isTrue(element.isImplementation); |
| 73 } | 73 } |
| 74 Expect.equals(isPatch, element.isPatch); | 74 Expect.equals(expectIsPatch, element.isPatch); |
| 75 if (isPatch) { | 75 if (expectIsPatch) { |
| 76 Expect.isNotNull(element.origin); | 76 Expect.isNotNull(element.origin); |
| 77 Expect.isNull(element.patch); | 77 Expect.isNull(element.patch); |
| 78 | 78 |
| 79 Expect.equals(element.origin, element.declaration); | 79 Expect.equals(element.origin, element.declaration); |
| 80 Expect.equals(element, element.implementation); | 80 Expect.equals(element, element.implementation); |
| 81 | 81 |
| 82 if (isMethod) { | 82 if (checkHasBody) { |
| 83 expectHasBody(compiler, element); | 83 expectHasBody(compiler, element); |
| 84 expectHasNoBody(compiler, element.origin); | 84 expectHasNoBody(compiler, element.origin); |
| 85 } | 85 } |
| 86 } else { | 86 } else { |
| 87 Expect.isTrue(element.isDeclaration); | 87 Expect.isTrue(element.isDeclaration); |
| 88 } | 88 } |
| 89 if (!(element.isPatched || element.isPatch)) { | 89 if (!(element.isPatched || element.isPatch)) { |
| 90 Expect.isNull(element.origin); | 90 Expect.isNull(element.origin); |
| 91 Expect.isNull(element.patch); | 91 Expect.isNull(element.patch); |
| 92 | 92 |
| 93 Expect.equals(element, element.declaration); | 93 Expect.equals(element, element.declaration); |
| 94 Expect.equals(element, element.implementation); | 94 Expect.equals(element, element.implementation); |
| 95 | 95 |
| 96 if (isMethod) { | 96 if (checkHasBody) { |
| 97 expectHasBody(compiler, element); | 97 expectHasBody(compiler, element); |
| 98 } | 98 } |
| 99 } | 99 } |
| 100 Expect.isFalse(element.isPatched && element.isPatch); | 100 Expect.isFalse(element.isPatched && element.isPatch); |
| 101 return element; | 101 return element; |
| 102 } | 102 } |
| 103 | 103 |
| 104 testPatchFunction() { | 104 testPatchFunction() { |
| 105 var compiler = applyPatch( | 105 var compiler = applyPatch( |
| 106 "external test();", | 106 "external test();", |
| 107 "patch test() { return 'string'; } "); | 107 "patch test() { return 'string'; } "); |
| 108 ensure(compiler, "test", compiler.coreLibrary.find, isPatched: true); | 108 ensure(compiler, "test", compiler.coreLibrary.find, |
| 109 ensure(compiler, "test", compiler.coreLibrary.patch.find, isPatch: true); | 109 expectIsPatched: true, checkHasBody: true); |
| 110 ensure(compiler, "test", compiler.coreLibrary.patch.find, |
| 111 expectIsPatch: true, checkHasBody: true); |
| 110 | 112 |
| 111 Expect.isTrue(compiler.warnings.isEmpty, | 113 Expect.isTrue(compiler.warnings.isEmpty, |
| 112 "Unexpected warnings: ${compiler.warnings}"); | 114 "Unexpected warnings: ${compiler.warnings}"); |
| 113 Expect.isTrue(compiler.errors.isEmpty, | 115 Expect.isTrue(compiler.errors.isEmpty, |
| 114 "Unexpected errors: ${compiler.errors}"); | 116 "Unexpected errors: ${compiler.errors}"); |
| 115 } | 117 } |
| 116 | 118 |
| 117 testPatchMember() { | 119 testPatchMember() { |
| 118 var compiler = applyPatch( | 120 var compiler = applyPatch( |
| 119 """ | 121 """ |
| 120 class Class { | 122 class Class { |
| 121 external String toString(); | 123 external String toString(); |
| 122 } | 124 } |
| 123 """, | 125 """, |
| 124 """ | 126 """ |
| 125 patch class Class { | 127 patch class Class { |
| 126 patch String toString() => 'string'; | 128 patch String toString() => 'string'; |
| 127 } | 129 } |
| 128 """); | 130 """); |
| 129 var container = ensure(compiler, "Class", compiler.coreLibrary.find, | 131 var container = ensure(compiler, "Class", compiler.coreLibrary.find, |
| 130 isMethod: false, isPatched: true); | 132 expectIsPatched: true); |
| 131 container.parseNode(compiler); | 133 container.parseNode(compiler); |
| 132 ensure(compiler, "Class", compiler.coreLibrary.patch.find, | 134 ensure(compiler, "Class", compiler.coreLibrary.patch.find, |
| 133 isMethod: false, isPatch: true); | 135 expectIsPatch: true); |
| 134 | 136 |
| 135 ensure(compiler, "toString", container.lookupLocalMember, | 137 ensure(compiler, "toString", container.lookupLocalMember, |
| 136 isPatched: true); | 138 expectIsPatched: true, checkHasBody: true); |
| 137 ensure(compiler, "toString", container.patch.lookupLocalMember, | 139 ensure(compiler, "toString", container.patch.lookupLocalMember, |
| 138 isPatch: true); | 140 expectIsPatch: true, checkHasBody: true); |
| 139 | 141 |
| 140 Expect.isTrue(compiler.warnings.isEmpty, | 142 Expect.isTrue(compiler.warnings.isEmpty, |
| 141 "Unexpected warnings: ${compiler.warnings}"); | 143 "Unexpected warnings: ${compiler.warnings}"); |
| 142 Expect.isTrue(compiler.errors.isEmpty, | 144 Expect.isTrue(compiler.errors.isEmpty, |
| 143 "Unexpected errors: ${compiler.errors}"); | 145 "Unexpected errors: ${compiler.errors}"); |
| 144 } | 146 } |
| 145 | 147 |
| 146 testPatchGetter() { | 148 testPatchGetter() { |
| 147 var compiler = applyPatch( | 149 var compiler = applyPatch( |
| 148 """ | 150 """ |
| 149 class Class { | 151 class Class { |
| 150 external int get field; | 152 external int get field; |
| 151 } | 153 } |
| 152 """, | 154 """, |
| 153 """ | 155 """ |
| 154 patch class Class { | 156 patch class Class { |
| 155 patch int get field => 5; | 157 patch int get field => 5; |
| 156 } | 158 } |
| 157 """); | 159 """); |
| 158 var container = ensure(compiler, "Class", compiler.coreLibrary.find, | 160 var container = ensure(compiler, "Class", compiler.coreLibrary.find, |
| 159 isPatched: true, isMethod: false); | 161 expectIsPatched: true); |
| 160 container.parseNode(compiler); | 162 container.parseNode(compiler); |
| 161 ensure(compiler, | 163 ensure(compiler, |
| 162 "field", | 164 "field", |
| 163 container.lookupLocalMember, | 165 container.lookupLocalMember, |
| 164 isGetter: true, | 166 expectIsGetter: true, |
| 165 isPatched: true); | 167 expectIsPatched: true, |
| 168 checkHasBody: true); |
| 166 ensure(compiler, | 169 ensure(compiler, |
| 167 "field", | 170 "field", |
| 168 container.patch.lookupLocalMember, | 171 container.patch.lookupLocalMember, |
| 169 isGetter: true, | 172 expectIsGetter: true, |
| 170 isPatch: true); | 173 expectIsPatch: true, |
| 174 checkHasBody: true); |
| 171 | 175 |
| 172 Expect.isTrue(compiler.warnings.isEmpty, | 176 Expect.isTrue(compiler.warnings.isEmpty, |
| 173 "Unexpected warnings: ${compiler.warnings}"); | 177 "Unexpected warnings: ${compiler.warnings}"); |
| 174 Expect.isTrue(compiler.errors.isEmpty, | 178 Expect.isTrue(compiler.errors.isEmpty, |
| 175 "Unexpected errors: ${compiler.errors}"); | 179 "Unexpected errors: ${compiler.errors}"); |
| 176 } | 180 } |
| 177 | 181 |
| 178 testRegularMember() { | 182 testRegularMember() { |
| 179 var compiler = applyPatch( | 183 var compiler = applyPatch( |
| 180 """ | 184 """ |
| 181 class Class { | 185 class Class { |
| 182 void regular() {} | 186 void regular() {} |
| 183 } | 187 } |
| 184 """, | 188 """, |
| 185 """ | 189 """ |
| 186 patch class Class { | 190 patch class Class { |
| 187 } | 191 } |
| 188 """); | 192 """); |
| 189 var container = ensure(compiler, "Class", compiler.coreLibrary.find, | 193 var container = ensure(compiler, "Class", compiler.coreLibrary.find, |
| 190 isMethod: false, isPatched: true); | 194 expectIsPatched: true); |
| 191 container.parseNode(compiler); | 195 container.parseNode(compiler); |
| 192 ensure(compiler, "Class", compiler.coreLibrary.patch.find, | 196 ensure(compiler, "Class", compiler.coreLibrary.patch.find, |
| 193 isMethod: false, isPatch: true); | 197 expectIsPatch: true); |
| 194 | 198 |
| 195 ensure(compiler, "regular", container.lookupLocalMember); | 199 ensure(compiler, "regular", container.lookupLocalMember, |
| 196 ensure(compiler, "regular", container.patch.lookupLocalMember); | 200 checkHasBody: true); |
| 201 ensure(compiler, "regular", container.patch.lookupLocalMember, |
| 202 checkHasBody: true); |
| 197 | 203 |
| 198 Expect.isTrue(compiler.warnings.isEmpty, | 204 Expect.isTrue(compiler.warnings.isEmpty, |
| 199 "Unexpected warnings: ${compiler.warnings}"); | 205 "Unexpected warnings: ${compiler.warnings}"); |
| 200 Expect.isTrue(compiler.errors.isEmpty, | 206 Expect.isTrue(compiler.errors.isEmpty, |
| 201 "Unexpected errors: ${compiler.errors}"); | 207 "Unexpected errors: ${compiler.errors}"); |
| 202 } | 208 } |
| 203 | 209 |
| 204 testGhostMember() { | 210 testGhostMember() { |
| 205 var compiler = applyPatch( | 211 var compiler = applyPatch( |
| 206 """ | 212 """ |
| 207 class Class { | 213 class Class { |
| 208 } | 214 } |
| 209 """, | 215 """, |
| 210 """ | 216 """ |
| 211 patch class Class { | 217 patch class Class { |
| 212 void ghost() {} | 218 void ghost() {} |
| 213 } | 219 } |
| 214 """); | 220 """); |
| 215 var container = ensure(compiler, "Class", compiler.coreLibrary.find, | 221 var container = ensure(compiler, "Class", compiler.coreLibrary.find, |
| 216 isMethod: false, isPatched: true); | 222 expectIsPatched: true); |
| 217 container.parseNode(compiler); | 223 container.parseNode(compiler); |
| 218 ensure(compiler, "Class", compiler.coreLibrary.patch.find, | 224 ensure(compiler, "Class", compiler.coreLibrary.patch.find, |
| 219 isMethod: false, isPatch: true); | 225 expectIsPatch: true); |
| 220 | 226 |
| 221 ensure(compiler, "ghost", container.lookupLocalMember, isFound: false); | 227 ensure(compiler, "ghost", container.lookupLocalMember, |
| 222 ensure(compiler, "ghost", container.patch.lookupLocalMember); | 228 expectIsFound: false); |
| 229 ensure(compiler, "ghost", container.patch.lookupLocalMember, |
| 230 checkHasBody: true); |
| 223 | 231 |
| 224 Expect.isTrue(compiler.warnings.isEmpty, | 232 Expect.isTrue(compiler.warnings.isEmpty, |
| 225 "Unexpected warnings: ${compiler.warnings}"); | 233 "Unexpected warnings: ${compiler.warnings}"); |
| 226 Expect.isTrue(compiler.errors.isEmpty, | 234 Expect.isTrue(compiler.errors.isEmpty, |
| 227 "Unexpected errors: ${compiler.errors}"); | 235 "Unexpected errors: ${compiler.errors}"); |
| 228 } | 236 } |
| 229 | 237 |
| 230 testInjectFunction() { | 238 testInjectFunction() { |
| 231 var compiler = applyPatch( | 239 var compiler = applyPatch( |
| 232 "", | 240 "", |
| 233 "int _function() => 5;"); | 241 "int _function() => 5;"); |
| 234 ensure(compiler, | 242 ensure(compiler, |
| 235 "_function", | 243 "_function", |
| 236 compiler.coreLibrary.find, | 244 compiler.coreLibrary.find, |
| 237 isFound: false); | 245 expectIsFound: false); |
| 238 ensure(compiler, | 246 ensure(compiler, |
| 239 "_function", | 247 "_function", |
| 240 compiler.coreLibrary.patch.find); | 248 compiler.coreLibrary.patch.find, |
| 249 checkHasBody: true); |
| 241 | 250 |
| 242 Expect.isTrue(compiler.warnings.isEmpty, | 251 Expect.isTrue(compiler.warnings.isEmpty, |
| 243 "Unexpected warnings: ${compiler.warnings}"); | 252 "Unexpected warnings: ${compiler.warnings}"); |
| 244 Expect.isTrue(compiler.errors.isEmpty, | 253 Expect.isTrue(compiler.errors.isEmpty, |
| 245 "Unexpected errors: ${compiler.errors}"); | 254 "Unexpected errors: ${compiler.errors}"); |
| 246 } | 255 } |
| 247 | 256 |
| 248 testPatchSignatureCheck() { | 257 testPatchSignatureCheck() { |
| 249 var compiler = applyPatch( | 258 var compiler = applyPatch( |
| 250 """ | 259 """ |
| (...skipping 14 matching lines...) Expand all Loading... |
| 265 patch void method2() {} | 274 patch void method2() {} |
| 266 patch void method3(String s2) {} | 275 patch void method3(String s2) {} |
| 267 patch void method4([String str, int i]) {} | 276 patch void method4([String str, int i]) {} |
| 268 patch void method5() {} | 277 patch void method5() {} |
| 269 patch void method6([String str]) {} | 278 patch void method6([String str]) {} |
| 270 patch void method7([String s2]) {} | 279 patch void method7([String s2]) {} |
| 271 patch void method8({String s2}) {} | 280 patch void method8({String s2}) {} |
| 272 } | 281 } |
| 273 """); | 282 """); |
| 274 var container = ensure(compiler, "Class", compiler.coreLibrary.find, | 283 var container = ensure(compiler, "Class", compiler.coreLibrary.find, |
| 275 isMethod: false, isPatched: true); | 284 expectIsPatched: true); |
| 276 container.ensureResolved(compiler); | 285 container.ensureResolved(compiler); |
| 277 container.parseNode(compiler); | 286 container.parseNode(compiler); |
| 278 | 287 |
| 279 compiler.resolver.resolveMethodElement( | 288 compiler.resolver.resolveMethodElement( |
| 280 ensure(compiler, "method1", container.lookupLocalMember, | 289 ensure(compiler, "method1", container.lookupLocalMember, |
| 281 isPatched: true)); | 290 expectIsPatched: true, checkHasBody: true)); |
| 282 Expect.isTrue(compiler.warnings.isEmpty, | 291 Expect.isTrue(compiler.warnings.isEmpty, |
| 283 "Unexpected warnings: ${compiler.warnings}"); | 292 "Unexpected warnings: ${compiler.warnings}"); |
| 284 Expect.isFalse(compiler.errors.isEmpty); | 293 Expect.isFalse(compiler.errors.isEmpty); |
| 285 print('method1:${compiler.errors}'); | 294 print('method1:${compiler.errors}'); |
| 286 | 295 |
| 287 compiler.warnings.clear(); | 296 compiler.warnings.clear(); |
| 288 compiler.errors.clear(); | 297 compiler.errors.clear(); |
| 289 compiler.resolver.resolveMethodElement( | 298 compiler.resolver.resolveMethodElement( |
| 290 ensure(compiler, "method2", container.lookupLocalMember, | 299 ensure(compiler, "method2", container.lookupLocalMember, |
| 291 isPatched: true)); | 300 expectIsPatched: true, checkHasBody: true)); |
| 292 Expect.isTrue(compiler.warnings.isEmpty, | 301 Expect.isTrue(compiler.warnings.isEmpty, |
| 293 "Unexpected warnings: ${compiler.warnings}"); | 302 "Unexpected warnings: ${compiler.warnings}"); |
| 294 Expect.isFalse(compiler.errors.isEmpty); | 303 Expect.isFalse(compiler.errors.isEmpty); |
| 295 print('method2:${compiler.errors}'); | 304 print('method2:${compiler.errors}'); |
| 296 | 305 |
| 297 compiler.warnings.clear(); | 306 compiler.warnings.clear(); |
| 298 compiler.errors.clear(); | 307 compiler.errors.clear(); |
| 299 compiler.resolver.resolveMethodElement( | 308 compiler.resolver.resolveMethodElement( |
| 300 ensure(compiler, "method3", container.lookupLocalMember, | 309 ensure(compiler, "method3", container.lookupLocalMember, |
| 301 isPatched: true)); | 310 expectIsPatched: true, checkHasBody: true)); |
| 302 Expect.isTrue(compiler.warnings.isEmpty, | 311 Expect.isTrue(compiler.warnings.isEmpty, |
| 303 "Unexpected warnings: ${compiler.warnings}"); | 312 "Unexpected warnings: ${compiler.warnings}"); |
| 304 Expect.isFalse(compiler.errors.isEmpty); | 313 Expect.isFalse(compiler.errors.isEmpty); |
| 305 print('method3:${compiler.errors}'); | 314 print('method3:${compiler.errors}'); |
| 306 | 315 |
| 307 compiler.warnings.clear(); | 316 compiler.warnings.clear(); |
| 308 compiler.errors.clear(); | 317 compiler.errors.clear(); |
| 309 compiler.resolver.resolveMethodElement( | 318 compiler.resolver.resolveMethodElement( |
| 310 ensure(compiler, "method4", container.lookupLocalMember, | 319 ensure(compiler, "method4", container.lookupLocalMember, |
| 311 isPatched: true)); | 320 expectIsPatched: true, checkHasBody: true)); |
| 312 Expect.isTrue(compiler.warnings.isEmpty, | 321 Expect.isTrue(compiler.warnings.isEmpty, |
| 313 "Unexpected warnings: ${compiler.warnings}"); | 322 "Unexpected warnings: ${compiler.warnings}"); |
| 314 Expect.isFalse(compiler.errors.isEmpty); | 323 Expect.isFalse(compiler.errors.isEmpty); |
| 315 print('method4:${compiler.errors}'); | 324 print('method4:${compiler.errors}'); |
| 316 | 325 |
| 317 compiler.warnings.clear(); | 326 compiler.warnings.clear(); |
| 318 compiler.errors.clear(); | 327 compiler.errors.clear(); |
| 319 compiler.resolver.resolveMethodElement( | 328 compiler.resolver.resolveMethodElement( |
| 320 ensure(compiler, "method5", container.lookupLocalMember, | 329 ensure(compiler, "method5", container.lookupLocalMember, |
| 321 isPatched: true)); | 330 expectIsPatched: true, checkHasBody: true)); |
| 322 Expect.isTrue(compiler.warnings.isEmpty, | 331 Expect.isTrue(compiler.warnings.isEmpty, |
| 323 "Unexpected warnings: ${compiler.warnings}"); | 332 "Unexpected warnings: ${compiler.warnings}"); |
| 324 Expect.isFalse(compiler.errors.isEmpty); | 333 Expect.isFalse(compiler.errors.isEmpty); |
| 325 print('method5:${compiler.errors}'); | 334 print('method5:${compiler.errors}'); |
| 326 | 335 |
| 327 compiler.warnings.clear(); | 336 compiler.warnings.clear(); |
| 328 compiler.errors.clear(); | 337 compiler.errors.clear(); |
| 329 compiler.resolver.resolveMethodElement( | 338 compiler.resolver.resolveMethodElement( |
| 330 ensure(compiler, "method6", container.lookupLocalMember, | 339 ensure(compiler, "method6", container.lookupLocalMember, |
| 331 isPatched: true)); | 340 expectIsPatched: true, checkHasBody: true)); |
| 332 Expect.isTrue(compiler.warnings.isEmpty, | 341 Expect.isTrue(compiler.warnings.isEmpty, |
| 333 "Unexpected warnings: ${compiler.warnings}"); | 342 "Unexpected warnings: ${compiler.warnings}"); |
| 334 Expect.isFalse(compiler.errors.isEmpty); | 343 Expect.isFalse(compiler.errors.isEmpty); |
| 335 print('method6:${compiler.errors}'); | 344 print('method6:${compiler.errors}'); |
| 336 | 345 |
| 337 compiler.warnings.clear(); | 346 compiler.warnings.clear(); |
| 338 compiler.errors.clear(); | 347 compiler.errors.clear(); |
| 339 compiler.resolver.resolveMethodElement( | 348 compiler.resolver.resolveMethodElement( |
| 340 ensure(compiler, "method7", container.lookupLocalMember, | 349 ensure(compiler, "method7", container.lookupLocalMember, |
| 341 isPatched: true)); | 350 expectIsPatched: true, checkHasBody: true)); |
| 342 Expect.isTrue(compiler.warnings.isEmpty, | 351 Expect.isTrue(compiler.warnings.isEmpty, |
| 343 "Unexpected warnings: ${compiler.warnings}"); | 352 "Unexpected warnings: ${compiler.warnings}"); |
| 344 Expect.isFalse(compiler.errors.isEmpty); | 353 Expect.isFalse(compiler.errors.isEmpty); |
| 345 print('method7:${compiler.errors}'); | 354 print('method7:${compiler.errors}'); |
| 346 | 355 |
| 347 compiler.warnings.clear(); | 356 compiler.warnings.clear(); |
| 348 compiler.errors.clear(); | 357 compiler.errors.clear(); |
| 349 compiler.resolver.resolveMethodElement( | 358 compiler.resolver.resolveMethodElement( |
| 350 ensure(compiler, "method8", container.lookupLocalMember, | 359 ensure(compiler, "method8", container.lookupLocalMember, |
| 351 isPatched: true)); | 360 expectIsPatched: true, checkHasBody: true)); |
| 352 Expect.isTrue(compiler.warnings.isEmpty, | 361 Expect.isTrue(compiler.warnings.isEmpty, |
| 353 "Unexpected warnings: ${compiler.warnings}"); | 362 "Unexpected warnings: ${compiler.warnings}"); |
| 354 Expect.isFalse(compiler.errors.isEmpty); | 363 Expect.isFalse(compiler.errors.isEmpty); |
| 355 print('method8:${compiler.errors}'); | 364 print('method8:${compiler.errors}'); |
| 356 } | 365 } |
| 357 | 366 |
| 367 testExternalWithoutImplementationTopLevel() { |
| 368 var compiler = applyPatch( |
| 369 """ |
| 370 external void foo(); |
| 371 """, |
| 372 """ |
| 373 // patch void foo() {} |
| 374 """); |
| 375 compiler.resolver.resolveMethodElement( |
| 376 ensure(compiler, "foo", compiler.coreLibrary.find)); |
| 377 Expect.isTrue(compiler.warnings.isEmpty, |
| 378 "Unexpected warnings: ${compiler.warnings}"); |
| 379 print('testExternalWithoutImplementationTopLevel:${compiler.errors}'); |
| 380 Expect.equals(1, compiler.errors.length); |
| 381 Expect.isTrue( |
| 382 compiler.errors[0].message.kind == |
| 383 MessageKind.EXTERNAL_WITHOUT_IMPLEMENTATION); |
| 384 Expect.equals('External method without an implementation.', |
| 385 compiler.errors[0].message.toString()); |
| 386 } |
| 387 |
| 388 testExternalWithoutImplementationMember() { |
| 389 var compiler = applyPatch( |
| 390 """ |
| 391 class Class { |
| 392 external void foo(); |
| 393 } |
| 394 """, |
| 395 """ |
| 396 patch class Class { |
| 397 // patch void foo() {} |
| 398 } |
| 399 """); |
| 400 var container = ensure(compiler, "Class", compiler.coreLibrary.find, |
| 401 expectIsPatched: true); |
| 402 container.parseNode(compiler); |
| 403 |
| 404 compiler.warnings.clear(); |
| 405 compiler.errors.clear(); |
| 406 compiler.resolver.resolveMethodElement( |
| 407 ensure(compiler, "foo", container.lookupLocalMember)); |
| 408 Expect.isTrue(compiler.warnings.isEmpty, |
| 409 "Unexpected warnings: ${compiler.warnings}"); |
| 410 print('testExternalWithoutImplementationMember:${compiler.errors}'); |
| 411 Expect.equals(1, compiler.errors.length); |
| 412 Expect.isTrue( |
| 413 compiler.errors[0].message.kind == |
| 414 MessageKind.EXTERNAL_WITHOUT_IMPLEMENTATION); |
| 415 Expect.equals('External method without an implementation.', |
| 416 compiler.errors[0].message.toString()); |
| 417 } |
| 418 |
| 358 main() { | 419 main() { |
| 359 testPatchFunction(); | 420 testPatchFunction(); |
| 360 testPatchMember(); | 421 testPatchMember(); |
| 361 testPatchGetter(); | 422 testPatchGetter(); |
| 362 testRegularMember(); | 423 testRegularMember(); |
| 363 testGhostMember(); | 424 testGhostMember(); |
| 364 testInjectFunction(); | 425 testInjectFunction(); |
| 365 testPatchSignatureCheck(); | 426 testPatchSignatureCheck(); |
| 427 |
| 428 testExternalWithoutImplementationTopLevel(); |
| 429 testExternalWithoutImplementationMember(); |
| 366 } | 430 } |
| OLD | NEW |