OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 package com.google.dart.compiler.resolver; | 4 package com.google.dart.compiler.resolver; |
5 | 5 |
6 import com.google.common.base.Joiner; | 6 import com.google.common.base.Joiner; |
7 import com.google.dart.compiler.CompilerTestCase; | 7 import com.google.dart.compiler.CompilerTestCase; |
8 import com.google.dart.compiler.DartCompilationError; | 8 import com.google.dart.compiler.DartCompilationError; |
9 import com.google.dart.compiler.ast.DartNewExpression; | 9 import com.google.dart.compiler.ast.DartNewExpression; |
10 import com.google.dart.compiler.ast.DartNode; | 10 import com.google.dart.compiler.ast.DartNode; |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 " foo() {", | 278 " foo() {", |
279 " new I(0);", | 279 " new I(0);", |
280 " new I.foo(0);", | 280 " new I.foo(0);", |
281 " }", | 281 " }", |
282 "}")); | 282 "}")); |
283 // Check errors. | 283 // Check errors. |
284 { | 284 { |
285 List<DartCompilationError> errors = libraryResult.getCompilationErrors(); | 285 List<DartCompilationError> errors = libraryResult.getCompilationErrors(); |
286 assertErrors( | 286 assertErrors( |
287 errors, | 287 errors, |
288 errEx(ResolverErrorCode.FACTORY_CONSTRUCTOR_UNRESOLVED, 2, 3, 9), | 288 errEx(ResolverErrorCode.DEFAULT_CONSTRUCTOR_UNRESOLVED, 2, 3, 9), |
289 errEx(ResolverErrorCode.FACTORY_CONSTRUCTOR_UNRESOLVED, 3, 3, 13), | 289 errEx(ResolverErrorCode.DEFAULT_CONSTRUCTOR_UNRESOLVED, 3, 3, 13), |
290 errEx(ResolverErrorCode.FACTORY_CONSTRUCTOR_UNRESOLVED, 10, 9, 1), | 290 errEx(ResolverErrorCode.DEFAULT_CONSTRUCTOR_UNRESOLVED, 10, 9, 1), |
291 errEx(ResolverErrorCode.FACTORY_CONSTRUCTOR_UNRESOLVED, 11, 9, 5)); | 291 errEx(ResolverErrorCode.DEFAULT_CONSTRUCTOR_UNRESOLVED, 11, 9, 5)); |
292 { | 292 { |
293 String message = errors.get(0).getMessage(); | 293 String message = errors.get(0).getMessage(); |
294 assertTrue(message, message.contains("'F'")); | 294 assertTrue(message, message.contains("'F'")); |
295 assertTrue(message, message.contains("'F'")); | 295 assertTrue(message, message.contains("'F'")); |
296 } | 296 } |
297 { | 297 { |
298 String message = errors.get(1).getMessage(); | 298 String message = errors.get(1).getMessage(); |
299 assertTrue(message, message.contains("'F.foo'")); | 299 assertTrue(message, message.contains("'F.foo'")); |
300 assertTrue(message, message.contains("'F'")); | 300 assertTrue(message, message.contains("'F'")); |
301 } | 301 } |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 "class Test {", | 393 "class Test {", |
394 " foo() {", | 394 " foo() {", |
395 " new I.foo(0);", | 395 " new I.foo(0);", |
396 " }", | 396 " }", |
397 "}")); | 397 "}")); |
398 // Check errors. | 398 // Check errors. |
399 { | 399 { |
400 List<DartCompilationError> errors = libraryResult.getCompilationErrors(); | 400 List<DartCompilationError> errors = libraryResult.getCompilationErrors(); |
401 assertErrors( | 401 assertErrors( |
402 errors, | 402 errors, |
403 errEx(ResolverErrorCode.FACTORY_CONSTRUCTOR_UNRESOLVED, 2, 3, 13), | 403 errEx(ResolverErrorCode.DEFAULT_CONSTRUCTOR_UNRESOLVED, 2, 3, 13), |
404 errEx(ResolverErrorCode.FACTORY_CONSTRUCTOR_UNRESOLVED, 8, 9, 5)); | 404 errEx(ResolverErrorCode.DEFAULT_CONSTRUCTOR_UNRESOLVED, 8, 9, 5)); |
405 { | 405 { |
406 String message = errors.get(0).getMessage(); | 406 String message = errors.get(0).getMessage(); |
407 assertTrue(message, message.contains("'I.foo'")); | 407 assertTrue(message, message.contains("'I.foo'")); |
408 assertTrue(message, message.contains("'F'")); | 408 assertTrue(message, message.contains("'F'")); |
409 } | 409 } |
410 } | 410 } |
411 DartUnit unit = libraryResult.getLibraryUnitResult().getUnits().iterator().n
ext(); | 411 DartUnit unit = libraryResult.getLibraryUnitResult().getUnits().iterator().n
ext(); |
412 // "new I.foo()" | 412 // "new I.foo()" |
413 { | 413 { |
414 DartNewExpression newExpression = findNewExpression(unit, "new I.foo(0)"); | 414 DartNewExpression newExpression = findNewExpression(unit, "new I.foo(0)"); |
(...skipping 24 matching lines...) Expand all Loading... |
439 " foo() {", | 439 " foo() {", |
440 " new I.foo();", | 440 " new I.foo();", |
441 " }", | 441 " }", |
442 "}")); | 442 "}")); |
443 assertErrors(libraryResult.getTypeErrors()); | 443 assertErrors(libraryResult.getTypeErrors()); |
444 // Check errors. | 444 // Check errors. |
445 { | 445 { |
446 List<DartCompilationError> errors = libraryResult.getCompilationErrors(); | 446 List<DartCompilationError> errors = libraryResult.getCompilationErrors(); |
447 assertErrors( | 447 assertErrors( |
448 errors, | 448 errors, |
449 errEx(ResolverErrorCode.FACTORY_CONSTRUCTOR_NUMBER_OF_REQUIRED_PARAMET
ERS, 2, 3, 13)); | 449 errEx(ResolverErrorCode.DEFAULT_CONSTRUCTOR_NUMBER_OF_REQUIRED_PARAMET
ERS, 2, 3, 13)); |
450 { | 450 { |
451 String message = errors.get(0).getMessage(); | 451 String message = errors.get(0).getMessage(); |
452 assertTrue(message, message.contains("'F.foo'")); | 452 assertTrue(message, message.contains("'F.foo'")); |
453 assertTrue(message, message.contains("'F'")); | 453 assertTrue(message, message.contains("'F'")); |
454 assertTrue(message, message.contains("0")); | 454 assertTrue(message, message.contains("0")); |
455 assertTrue(message, message.contains("1")); | 455 assertTrue(message, message.contains("1")); |
456 assertTrue(message, message.contains("'F.foo'")); | 456 assertTrue(message, message.contains("'F.foo'")); |
457 } | 457 } |
458 } | 458 } |
459 DartUnit unit = libraryResult.getLibraryUnitResult().getUnits().iterator().n
ext(); | 459 DartUnit unit = libraryResult.getLibraryUnitResult().getUnits().iterator().n
ext(); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 " new I.bar(0);", | 495 " new I.bar(0);", |
496 " new I.baz(0);", | 496 " new I.baz(0);", |
497 " }", | 497 " }", |
498 "}")); | 498 "}")); |
499 assertErrors(libraryResult.getTypeErrors()); | 499 assertErrors(libraryResult.getTypeErrors()); |
500 // Check errors. | 500 // Check errors. |
501 { | 501 { |
502 List<DartCompilationError> errors = libraryResult.getCompilationErrors(); | 502 List<DartCompilationError> errors = libraryResult.getCompilationErrors(); |
503 assertErrors( | 503 assertErrors( |
504 errors, | 504 errors, |
505 errEx(ResolverErrorCode.FACTORY_CONSTRUCTOR_NAMED_PARAMETERS, 2, 3, 29
), | 505 errEx(ResolverErrorCode.DEFAULT_CONSTRUCTOR_NAMED_PARAMETERS, 2, 3, 29
), |
506 errEx(ResolverErrorCode.FACTORY_CONSTRUCTOR_NAMED_PARAMETERS, 3, 3, 29
), | 506 errEx(ResolverErrorCode.DEFAULT_CONSTRUCTOR_NAMED_PARAMETERS, 3, 3, 29
), |
507 errEx(ResolverErrorCode.FACTORY_CONSTRUCTOR_NAMED_PARAMETERS, 4, 3, 22
)); | 507 errEx(ResolverErrorCode.DEFAULT_CONSTRUCTOR_NAMED_PARAMETERS, 4, 3, 22
)); |
508 { | 508 { |
509 String message = errors.get(0).getMessage(); | 509 String message = errors.get(0).getMessage(); |
510 assertTrue(message, message.contains("'I.foo'")); | 510 assertTrue(message, message.contains("'I.foo'")); |
511 assertTrue(message, message.contains("'F'")); | 511 assertTrue(message, message.contains("'F'")); |
512 assertTrue(message, message.contains("[b]")); | 512 assertTrue(message, message.contains("[b]")); |
513 assertTrue(message, message.contains("[b, c]")); | 513 assertTrue(message, message.contains("[b, c]")); |
514 assertTrue(message, message.contains("'F.foo'")); | 514 assertTrue(message, message.contains("'F.foo'")); |
515 } | 515 } |
516 { | 516 { |
517 String message = errors.get(1).getMessage(); | 517 String message = errors.get(1).getMessage(); |
(...skipping 26 matching lines...) Expand all Loading... |
544 assertEquals(true, constructorNode.toSource().contains("F.bar(")); | 544 assertEquals(true, constructorNode.toSource().contains("F.bar(")); |
545 } | 545 } |
546 // "new I.baz()" - resolved, but we produce error. | 546 // "new I.baz()" - resolved, but we produce error. |
547 { | 547 { |
548 DartNewExpression newExpression = findNewExpression(unit, "new I.baz(0)"); | 548 DartNewExpression newExpression = findNewExpression(unit, "new I.baz(0)"); |
549 DartNode constructorNode = newExpression.getSymbol().getNode(); | 549 DartNode constructorNode = newExpression.getSymbol().getNode(); |
550 assertEquals(true, constructorNode.toSource().contains("F.baz(")); | 550 assertEquals(true, constructorNode.toSource().contains("F.baz(")); |
551 } | 551 } |
552 } | 552 } |
553 } | 553 } |
OLD | NEW |