| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 library analyzer.test.generated.parser_test; | 5 library analyzer.test.generated.parser_test; |
| 6 | 6 |
| 7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
| 8 import 'package:analyzer/dart/ast/token.dart'; | 8 import 'package:analyzer/dart/ast/token.dart'; |
| 9 import 'package:analyzer/dart/ast/visitor.dart'; | 9 import 'package:analyzer/dart/ast/visitor.dart'; |
| 10 import 'package:analyzer/error/error.dart'; | 10 import 'package:analyzer/error/error.dart'; |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | 329 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, |
| 330 BinaryExpression, expression.condition); | 330 BinaryExpression, expression.condition); |
| 331 } | 331 } |
| 332 | 332 |
| 333 void test_conditionalExpression_precedence_logicalOrExpression() { | 333 void test_conditionalExpression_precedence_logicalOrExpression() { |
| 334 ConditionalExpression expression = parseExpression("a | b ? y : z"); | 334 ConditionalExpression expression = parseExpression("a | b ? y : z"); |
| 335 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | 335 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, |
| 336 BinaryExpression, expression.condition); | 336 BinaryExpression, expression.condition); |
| 337 } | 337 } |
| 338 | 338 |
| 339 void test_conditionalExpression_precedence_nullableType() { | 339 void test_conditionalExpression_precedence_nullableType_as() { |
| 340 enableNnbd = true; |
| 341 Expression expression = parseExpression('x as String ? (x + y) : z'); |
| 342 expect(expression, isNotNull); |
| 343 expect(expression, new isInstanceOf<ConditionalExpression>()); |
| 344 ConditionalExpression conditional = expression; |
| 345 Expression condition = conditional.condition; |
| 346 expect(condition, new isInstanceOf<AsExpression>()); |
| 347 Expression thenExpression = conditional.thenExpression; |
| 348 expect(thenExpression, new isInstanceOf<ParenthesizedExpression>()); |
| 349 Expression elseExpression = conditional.elseExpression; |
| 350 expect(elseExpression, new isInstanceOf<SimpleIdentifier>()); |
| 351 } |
| 352 |
| 353 void test_conditionalExpression_precedence_nullableType_is() { |
| 340 enableNnbd = true; | 354 enableNnbd = true; |
| 341 Expression expression = parseExpression('x is String ? (x + y) : z'); | 355 Expression expression = parseExpression('x is String ? (x + y) : z'); |
| 342 expect(expression, isNotNull); | 356 expect(expression, isNotNull); |
| 343 expect(expression, new isInstanceOf<ConditionalExpression>()); | 357 expect(expression, new isInstanceOf<ConditionalExpression>()); |
| 344 ConditionalExpression conditional = expression; | 358 ConditionalExpression conditional = expression; |
| 345 Expression condition = conditional.condition; | 359 Expression condition = conditional.condition; |
| 346 expect(condition, new isInstanceOf<IsExpression>()); | 360 expect(condition, new isInstanceOf<IsExpression>()); |
| 347 Expression thenExpression = conditional.thenExpression; | 361 Expression thenExpression = conditional.thenExpression; |
| 348 expect(thenExpression, new isInstanceOf<ParenthesizedExpression>()); | 362 expect(thenExpression, new isInstanceOf<ParenthesizedExpression>()); |
| 349 Expression elseExpression = conditional.elseExpression; | 363 Expression elseExpression = conditional.elseExpression; |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 566 expect(argumentList4.arguments, hasLength(1)); | 580 expect(argumentList4.arguments, hasLength(1)); |
| 567 } | 581 } |
| 568 } | 582 } |
| 569 | 583 |
| 570 /** | 584 /** |
| 571 * The class `ErrorParserTest` defines parser tests that test the parsing of cod
e to ensure | 585 * The class `ErrorParserTest` defines parser tests that test the parsing of cod
e to ensure |
| 572 * that errors are correctly reported, and in some cases, not reported. | 586 * that errors are correctly reported, and in some cases, not reported. |
| 573 */ | 587 */ |
| 574 @reflectiveTest | 588 @reflectiveTest |
| 575 class ErrorParserTest extends ParserTestCase { | 589 class ErrorParserTest extends ParserTestCase { |
| 576 void fail_expectedListOrMapLiteral() { | |
| 577 // It isn't clear that this test can ever pass. The parser is currently | |
| 578 // create a synthetic list literal in this case, but isSynthetic() isn't | |
| 579 // overridden for ListLiteral. The problem is that the synthetic list | |
| 580 // literals that are being created are not always zero length (because they | |
| 581 // could have type parameters), which violates the contract of | |
| 582 // isSynthetic(). | |
| 583 createParser('1'); | |
| 584 TypedLiteral literal = parser.parseListOrMapLiteral(null); | |
| 585 expectNotNullIfNoErrors(literal); | |
| 586 listener | |
| 587 .assertErrorsWithCodes([ParserErrorCode.EXPECTED_LIST_OR_MAP_LITERAL]); | |
| 588 expect(literal.isSynthetic, isTrue); | |
| 589 } | |
| 590 | |
| 591 void fail_illegalAssignmentToNonAssignable_superAssigned() { | |
| 592 // TODO(brianwilkerson) When this test starts to pass, remove the test | |
| 593 // test_illegalAssignmentToNonAssignable_superAssigned. | |
| 594 parseExpression( | |
| 595 "super = x;", [ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE]); | |
| 596 } | |
| 597 | |
| 598 void fail_invalidCommentReference__new_nonIdentifier() { | |
| 599 // This test fails because the method parseCommentReference returns null. | |
| 600 createParser(''); | |
| 601 CommentReference reference = parser.parseCommentReference('new 42', 0); | |
| 602 expectNotNullIfNoErrors(reference); | |
| 603 listener.assertErrorsWithCodes([ParserErrorCode.INVALID_COMMENT_REFERENCE]); | |
| 604 } | |
| 605 | |
| 606 void fail_invalidCommentReference__new_tooMuch() { | |
| 607 createParser(''); | |
| 608 CommentReference reference = parser.parseCommentReference('new a.b.c.d', 0); | |
| 609 expectNotNullIfNoErrors(reference); | |
| 610 listener.assertErrorsWithCodes([ParserErrorCode.INVALID_COMMENT_REFERENCE]); | |
| 611 } | |
| 612 | |
| 613 void fail_invalidCommentReference__nonNew_nonIdentifier() { | |
| 614 // This test fails because the method parseCommentReference returns null. | |
| 615 createParser(''); | |
| 616 CommentReference reference = parser.parseCommentReference('42', 0); | |
| 617 expectNotNullIfNoErrors(reference); | |
| 618 listener.assertErrorsWithCodes([ParserErrorCode.INVALID_COMMENT_REFERENCE]); | |
| 619 } | |
| 620 | |
| 621 void fail_invalidCommentReference__nonNew_tooMuch() { | |
| 622 createParser(''); | |
| 623 CommentReference reference = parser.parseCommentReference('a.b.c.d', 0); | |
| 624 expectNotNullIfNoErrors(reference); | |
| 625 listener.assertErrorsWithCodes([ParserErrorCode.INVALID_COMMENT_REFERENCE]); | |
| 626 } | |
| 627 | |
| 628 void fail_missingClosingParenthesis() { | |
| 629 // It is possible that it is not possible to generate this error (that it's | |
| 630 // being reported in code that cannot actually be reached), but that hasn't | |
| 631 // been proven yet. | |
| 632 createParser('(int a, int b ;'); | |
| 633 FormalParameterList list = parser.parseFormalParameterList(); | |
| 634 expectNotNullIfNoErrors(list); | |
| 635 listener | |
| 636 .assertErrorsWithCodes([ParserErrorCode.MISSING_CLOSING_PARENTHESIS]); | |
| 637 } | |
| 638 | |
| 639 void fail_missingFunctionParameters_local_nonVoid_block() { | |
| 640 // The parser does not recognize this as a function declaration, so it tries | |
| 641 // to parse it as an expression statement. It isn't clear what the best | |
| 642 // error message is in this case. | |
| 643 ParserTestCase.parseStatement( | |
| 644 "int f { return x;}", [ParserErrorCode.MISSING_FUNCTION_PARAMETERS]); | |
| 645 } | |
| 646 | |
| 647 void fail_missingFunctionParameters_local_nonVoid_expression() { | |
| 648 // The parser does not recognize this as a function declaration, so it tries | |
| 649 // to parse it as an expression statement. It isn't clear what the best | |
| 650 // error message is in this case. | |
| 651 ParserTestCase.parseStatement( | |
| 652 "int f => x;", [ParserErrorCode.MISSING_FUNCTION_PARAMETERS]); | |
| 653 } | |
| 654 | |
| 655 void fail_namedFunctionExpression() { | |
| 656 createParser('f() {}'); | |
| 657 Expression expression = parser.parsePrimaryExpression(); | |
| 658 expectNotNullIfNoErrors(expression); | |
| 659 listener.assertErrorsWithCodes([ParserErrorCode.NAMED_FUNCTION_EXPRESSION]); | |
| 660 expect(expression, new isInstanceOf<FunctionExpression>()); | |
| 661 } | |
| 662 | |
| 663 void fail_unexpectedToken_invalidPostfixExpression() { | |
| 664 // Note: this might not be the right error to produce, but some error should | |
| 665 // be produced | |
| 666 parseExpression("f()++", [ParserErrorCode.UNEXPECTED_TOKEN]); | |
| 667 } | |
| 668 | |
| 669 void fail_varAndType_local() { | |
| 670 // This is currently reporting EXPECTED_TOKEN for a missing semicolon, but | |
| 671 // this would be a better error message. | |
| 672 ParserTestCase.parseStatement("var int x;", [ParserErrorCode.VAR_AND_TYPE]); | |
| 673 } | |
| 674 | |
| 675 void fail_varAndType_parameter() { | |
| 676 // This is currently reporting EXPECTED_TOKEN for a missing semicolon, but | |
| 677 // this would be a better error message. | |
| 678 createParser('(var int x)'); | |
| 679 FormalParameterList list = parser.parseFormalParameterList(); | |
| 680 expectNotNullIfNoErrors(list); | |
| 681 listener.assertErrorsWithCodes([ParserErrorCode.VAR_AND_TYPE]); | |
| 682 } | |
| 683 | |
| 684 void test_abstractClassMember_constructor() { | 590 void test_abstractClassMember_constructor() { |
| 685 createParser('abstract C.c();'); | 591 createParser('abstract C.c();'); |
| 686 ClassMember member = parser.parseClassMember('C'); | 592 ClassMember member = parser.parseClassMember('C'); |
| 687 expectNotNullIfNoErrors(member); | 593 expectNotNullIfNoErrors(member); |
| 688 listener.assertErrorsWithCodes([ParserErrorCode.ABSTRACT_CLASS_MEMBER]); | 594 listener.assertErrorsWithCodes([ParserErrorCode.ABSTRACT_CLASS_MEMBER]); |
| 689 } | 595 } |
| 690 | 596 |
| 691 void test_abstractClassMember_field() { | 597 void test_abstractClassMember_field() { |
| 692 createParser('abstract C f;'); | 598 createParser('abstract C f;'); |
| 693 ClassMember member = parser.parseClassMember('C'); | 599 ClassMember member = parser.parseClassMember('C'); |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1140 // The scanner inserts an empty string token between the two $'s; we need to | 1046 // The scanner inserts an empty string token between the two $'s; we need to |
| 1141 // make sure that the MISSING_IDENTIFIER error that is generated has a | 1047 // make sure that the MISSING_IDENTIFIER error that is generated has a |
| 1142 // nonzero width so that it will show up in the editor UI. | 1048 // nonzero width so that it will show up in the editor UI. |
| 1143 createParser("'\$\$foo'"); | 1049 createParser("'\$\$foo'"); |
| 1144 StringLiteral literal = parser.parseStringLiteral(); | 1050 StringLiteral literal = parser.parseStringLiteral(); |
| 1145 expectNotNullIfNoErrors(literal); | 1051 expectNotNullIfNoErrors(literal); |
| 1146 listener.assertErrors( | 1052 listener.assertErrors( |
| 1147 [new AnalysisError(null, 2, 1, ParserErrorCode.MISSING_IDENTIFIER)]); | 1053 [new AnalysisError(null, 2, 1, ParserErrorCode.MISSING_IDENTIFIER)]); |
| 1148 } | 1054 } |
| 1149 | 1055 |
| 1056 @failingTest |
| 1057 void test_expectedListOrMapLiteral() { |
| 1058 // It isn't clear that this test can ever pass. The parser is currently |
| 1059 // create a synthetic list literal in this case, but isSynthetic() isn't |
| 1060 // overridden for ListLiteral. The problem is that the synthetic list |
| 1061 // literals that are being created are not always zero length (because they |
| 1062 // could have type parameters), which violates the contract of |
| 1063 // isSynthetic(). |
| 1064 createParser('1'); |
| 1065 TypedLiteral literal = parser.parseListOrMapLiteral(null); |
| 1066 expectNotNullIfNoErrors(literal); |
| 1067 listener |
| 1068 .assertErrorsWithCodes([ParserErrorCode.EXPECTED_LIST_OR_MAP_LITERAL]); |
| 1069 expect(literal.isSynthetic, isTrue); |
| 1070 } |
| 1071 |
| 1150 void test_expectedStringLiteral() { | 1072 void test_expectedStringLiteral() { |
| 1151 createParser('1'); | 1073 createParser('1'); |
| 1152 StringLiteral literal = parser.parseStringLiteral(); | 1074 StringLiteral literal = parser.parseStringLiteral(); |
| 1153 expectNotNullIfNoErrors(literal); | 1075 expectNotNullIfNoErrors(literal); |
| 1154 listener.assertErrorsWithCodes([ParserErrorCode.EXPECTED_STRING_LITERAL]); | 1076 listener.assertErrorsWithCodes([ParserErrorCode.EXPECTED_STRING_LITERAL]); |
| 1155 expect(literal.isSynthetic, isTrue); | 1077 expect(literal.isSynthetic, isTrue); |
| 1156 } | 1078 } |
| 1157 | 1079 |
| 1158 void test_expectedToken_commaMissingInArgumentList() { | 1080 void test_expectedToken_commaMissingInArgumentList() { |
| 1159 createParser('(x, y z)'); | 1081 createParser('(x, y z)'); |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1489 "(x)++", [ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE]); | 1411 "(x)++", [ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE]); |
| 1490 } | 1412 } |
| 1491 | 1413 |
| 1492 void test_illegalAssignmentToNonAssignable_primarySelectorPostfix() { | 1414 void test_illegalAssignmentToNonAssignable_primarySelectorPostfix() { |
| 1493 parseExpression( | 1415 parseExpression( |
| 1494 "x(y)(z)++", [ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE]); | 1416 "x(y)(z)++", [ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE]); |
| 1495 } | 1417 } |
| 1496 | 1418 |
| 1497 void test_illegalAssignmentToNonAssignable_superAssigned() { | 1419 void test_illegalAssignmentToNonAssignable_superAssigned() { |
| 1498 // TODO(brianwilkerson) When the test | 1420 // TODO(brianwilkerson) When the test |
| 1499 // fail_illegalAssignmentToNonAssignable_superAssigned starts to pass, | 1421 // test_illegalAssignmentToNonAssignable_superAssigned_failing starts to pas
s, |
| 1500 // remove this test (there should only be one error generated, but we're | 1422 // remove this test (there should only be one error generated, but we're |
| 1501 // keeping this test until that time so that we can catch other forms of | 1423 // keeping this test until that time so that we can catch other forms of |
| 1502 // regressions). | 1424 // regressions). |
| 1503 parseExpression("super = x;", [ | 1425 parseExpression("super = x;", [ |
| 1504 ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR, | 1426 ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR, |
| 1505 ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE | 1427 ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE |
| 1506 ]); | 1428 ]); |
| 1507 } | 1429 } |
| 1508 | 1430 |
| 1431 @failingTest |
| 1432 void test_illegalAssignmentToNonAssignable_superAssigned_failing() { |
| 1433 // TODO(brianwilkerson) When this test starts to pass, remove the test |
| 1434 // test_illegalAssignmentToNonAssignable_superAssigned. |
| 1435 parseExpression( |
| 1436 "super = x;", [ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE]); |
| 1437 } |
| 1438 |
| 1509 void test_implementsBeforeExtends() { | 1439 void test_implementsBeforeExtends() { |
| 1510 ParserTestCase.parseCompilationUnit("class A implements B extends C {}", | 1440 ParserTestCase.parseCompilationUnit("class A implements B extends C {}", |
| 1511 [ParserErrorCode.IMPLEMENTS_BEFORE_EXTENDS]); | 1441 [ParserErrorCode.IMPLEMENTS_BEFORE_EXTENDS]); |
| 1512 } | 1442 } |
| 1513 | 1443 |
| 1514 void test_implementsBeforeWith() { | 1444 void test_implementsBeforeWith() { |
| 1515 ParserTestCase.parseCompilationUnit( | 1445 ParserTestCase.parseCompilationUnit( |
| 1516 "class A extends B implements C with D {}", | 1446 "class A extends B implements C with D {}", |
| 1517 [ParserErrorCode.IMPLEMENTS_BEFORE_WITH]); | 1447 [ParserErrorCode.IMPLEMENTS_BEFORE_WITH]); |
| 1518 } | 1448 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1537 listener.assertErrorsWithCodes([ParserErrorCode.INVALID_AWAIT_IN_FOR]); | 1467 listener.assertErrorsWithCodes([ParserErrorCode.INVALID_AWAIT_IN_FOR]); |
| 1538 } | 1468 } |
| 1539 | 1469 |
| 1540 void test_invalidCodePoint() { | 1470 void test_invalidCodePoint() { |
| 1541 createParser("'\\uD900'"); | 1471 createParser("'\\uD900'"); |
| 1542 StringLiteral literal = parser.parseStringLiteral(); | 1472 StringLiteral literal = parser.parseStringLiteral(); |
| 1543 expectNotNullIfNoErrors(literal); | 1473 expectNotNullIfNoErrors(literal); |
| 1544 listener.assertErrorsWithCodes([ParserErrorCode.INVALID_CODE_POINT]); | 1474 listener.assertErrorsWithCodes([ParserErrorCode.INVALID_CODE_POINT]); |
| 1545 } | 1475 } |
| 1546 | 1476 |
| 1477 @failingTest |
| 1478 void test_invalidCommentReference__new_nonIdentifier() { |
| 1479 // This test fails because the method parseCommentReference returns null. |
| 1480 createParser(''); |
| 1481 CommentReference reference = parser.parseCommentReference('new 42', 0); |
| 1482 expectNotNullIfNoErrors(reference); |
| 1483 listener.assertErrorsWithCodes([ParserErrorCode.INVALID_COMMENT_REFERENCE]); |
| 1484 } |
| 1485 |
| 1486 @failingTest |
| 1487 void test_invalidCommentReference__new_tooMuch() { |
| 1488 createParser(''); |
| 1489 CommentReference reference = parser.parseCommentReference('new a.b.c.d', 0); |
| 1490 expectNotNullIfNoErrors(reference); |
| 1491 listener.assertErrorsWithCodes([ParserErrorCode.INVALID_COMMENT_REFERENCE]); |
| 1492 } |
| 1493 |
| 1494 @failingTest |
| 1495 void test_invalidCommentReference__nonNew_nonIdentifier() { |
| 1496 // This test fails because the method parseCommentReference returns null. |
| 1497 createParser(''); |
| 1498 CommentReference reference = parser.parseCommentReference('42', 0); |
| 1499 expectNotNullIfNoErrors(reference); |
| 1500 listener.assertErrorsWithCodes([ParserErrorCode.INVALID_COMMENT_REFERENCE]); |
| 1501 } |
| 1502 |
| 1503 @failingTest |
| 1504 void test_invalidCommentReference__nonNew_tooMuch() { |
| 1505 createParser(''); |
| 1506 CommentReference reference = parser.parseCommentReference('a.b.c.d', 0); |
| 1507 expectNotNullIfNoErrors(reference); |
| 1508 listener.assertErrorsWithCodes([ParserErrorCode.INVALID_COMMENT_REFERENCE]); |
| 1509 } |
| 1510 |
| 1547 void test_invalidHexEscape_invalidDigit() { | 1511 void test_invalidHexEscape_invalidDigit() { |
| 1548 createParser("'\\x0 a'"); | 1512 createParser("'\\x0 a'"); |
| 1549 StringLiteral literal = parser.parseStringLiteral(); | 1513 StringLiteral literal = parser.parseStringLiteral(); |
| 1550 expectNotNullIfNoErrors(literal); | 1514 expectNotNullIfNoErrors(literal); |
| 1551 listener.assertErrorsWithCodes([ParserErrorCode.INVALID_HEX_ESCAPE]); | 1515 listener.assertErrorsWithCodes([ParserErrorCode.INVALID_HEX_ESCAPE]); |
| 1552 } | 1516 } |
| 1553 | 1517 |
| 1554 void test_invalidHexEscape_tooFewDigits() { | 1518 void test_invalidHexEscape_tooFewDigits() { |
| 1555 createParser("'\\x0'"); | 1519 createParser("'\\x0'"); |
| 1556 StringLiteral literal = parser.parseStringLiteral(); | 1520 StringLiteral literal = parser.parseStringLiteral(); |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1817 expectNotNullIfNoErrors(statement); | 1781 expectNotNullIfNoErrors(statement); |
| 1818 listener.assertErrorsWithCodes([ParserErrorCode.MISSING_CATCH_OR_FINALLY]); | 1782 listener.assertErrorsWithCodes([ParserErrorCode.MISSING_CATCH_OR_FINALLY]); |
| 1819 expect(statement, isNotNull); | 1783 expect(statement, isNotNull); |
| 1820 } | 1784 } |
| 1821 | 1785 |
| 1822 void test_missingClassBody() { | 1786 void test_missingClassBody() { |
| 1823 ParserTestCase.parseCompilationUnit( | 1787 ParserTestCase.parseCompilationUnit( |
| 1824 "class A class B {}", [ParserErrorCode.MISSING_CLASS_BODY]); | 1788 "class A class B {}", [ParserErrorCode.MISSING_CLASS_BODY]); |
| 1825 } | 1789 } |
| 1826 | 1790 |
| 1791 @failingTest |
| 1792 void test_missingClosingParenthesis() { |
| 1793 // It is possible that it is not possible to generate this error (that it's |
| 1794 // being reported in code that cannot actually be reached), but that hasn't |
| 1795 // been proven yet. |
| 1796 createParser('(int a, int b ;'); |
| 1797 FormalParameterList list = parser.parseFormalParameterList(); |
| 1798 expectNotNullIfNoErrors(list); |
| 1799 listener |
| 1800 .assertErrorsWithCodes([ParserErrorCode.MISSING_CLOSING_PARENTHESIS]); |
| 1801 } |
| 1802 |
| 1827 void test_missingConstFinalVarOrType_static() { | 1803 void test_missingConstFinalVarOrType_static() { |
| 1828 ParserTestCase.parseCompilationUnit("class A { static f; }", | 1804 ParserTestCase.parseCompilationUnit("class A { static f; }", |
| 1829 [ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE]); | 1805 [ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE]); |
| 1830 } | 1806 } |
| 1831 | 1807 |
| 1832 void test_missingConstFinalVarOrType_topLevel() { | 1808 void test_missingConstFinalVarOrType_topLevel() { |
| 1833 createParser('a;'); | 1809 createParser('a;'); |
| 1834 FinalConstVarOrType result = parser.parseFinalConstVarOrType(false); | 1810 FinalConstVarOrType result = parser.parseFinalConstVarOrType(false); |
| 1835 expectNotNullIfNoErrors(result); | 1811 expectNotNullIfNoErrors(result); |
| 1836 listener.assertErrorsWithCodes( | 1812 listener.assertErrorsWithCodes( |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1870 } | 1846 } |
| 1871 | 1847 |
| 1872 void test_missingFunctionBody_invalid() { | 1848 void test_missingFunctionBody_invalid() { |
| 1873 createParser('return 0;'); | 1849 createParser('return 0;'); |
| 1874 FunctionBody functionBody = parser.parseFunctionBody( | 1850 FunctionBody functionBody = parser.parseFunctionBody( |
| 1875 false, ParserErrorCode.MISSING_FUNCTION_BODY, false); | 1851 false, ParserErrorCode.MISSING_FUNCTION_BODY, false); |
| 1876 expectNotNullIfNoErrors(functionBody); | 1852 expectNotNullIfNoErrors(functionBody); |
| 1877 listener.assertErrorsWithCodes([ParserErrorCode.MISSING_FUNCTION_BODY]); | 1853 listener.assertErrorsWithCodes([ParserErrorCode.MISSING_FUNCTION_BODY]); |
| 1878 } | 1854 } |
| 1879 | 1855 |
| 1856 @failingTest |
| 1857 void test_missingFunctionParameters_local_nonVoid_block() { |
| 1858 // The parser does not recognize this as a function declaration, so it tries |
| 1859 // to parse it as an expression statement. It isn't clear what the best |
| 1860 // error message is in this case. |
| 1861 ParserTestCase.parseStatement( |
| 1862 "int f { return x;}", [ParserErrorCode.MISSING_FUNCTION_PARAMETERS]); |
| 1863 } |
| 1864 |
| 1865 @failingTest |
| 1866 void test_missingFunctionParameters_local_nonVoid_expression() { |
| 1867 // The parser does not recognize this as a function declaration, so it tries |
| 1868 // to parse it as an expression statement. It isn't clear what the best |
| 1869 // error message is in this case. |
| 1870 ParserTestCase.parseStatement( |
| 1871 "int f => x;", [ParserErrorCode.MISSING_FUNCTION_PARAMETERS]); |
| 1872 } |
| 1873 |
| 1880 void test_missingFunctionParameters_local_void_block() { | 1874 void test_missingFunctionParameters_local_void_block() { |
| 1881 ParserTestCase.parseStatement( | 1875 ParserTestCase.parseStatement( |
| 1882 "void f { return x;}", [ParserErrorCode.MISSING_FUNCTION_PARAMETERS]); | 1876 "void f { return x;}", [ParserErrorCode.MISSING_FUNCTION_PARAMETERS]); |
| 1883 } | 1877 } |
| 1884 | 1878 |
| 1885 void test_missingFunctionParameters_local_void_expression() { | 1879 void test_missingFunctionParameters_local_void_expression() { |
| 1886 ParserTestCase.parseStatement( | 1880 ParserTestCase.parseStatement( |
| 1887 "void f => x;", [ParserErrorCode.MISSING_FUNCTION_PARAMETERS]); | 1881 "void f => x;", [ParserErrorCode.MISSING_FUNCTION_PARAMETERS]); |
| 1888 } | 1882 } |
| 1889 | 1883 |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2148 expectNotNullIfNoErrors(statement); | 2142 expectNotNullIfNoErrors(statement); |
| 2149 listener.assertErrorsWithCodes( | 2143 listener.assertErrorsWithCodes( |
| 2150 [ParserErrorCode.MULTIPLE_VARIABLES_IN_FOR_EACH]); | 2144 [ParserErrorCode.MULTIPLE_VARIABLES_IN_FOR_EACH]); |
| 2151 } | 2145 } |
| 2152 | 2146 |
| 2153 void test_multipleWithClauses() { | 2147 void test_multipleWithClauses() { |
| 2154 ParserTestCase.parseCompilationUnit("class A extends B with C with D {}", | 2148 ParserTestCase.parseCompilationUnit("class A extends B with C with D {}", |
| 2155 [ParserErrorCode.MULTIPLE_WITH_CLAUSES]); | 2149 [ParserErrorCode.MULTIPLE_WITH_CLAUSES]); |
| 2156 } | 2150 } |
| 2157 | 2151 |
| 2152 @failingTest |
| 2153 void test_namedFunctionExpression() { |
| 2154 createParser('f() {}'); |
| 2155 Expression expression = parser.parsePrimaryExpression(); |
| 2156 expectNotNullIfNoErrors(expression); |
| 2157 listener.assertErrorsWithCodes([ParserErrorCode.NAMED_FUNCTION_EXPRESSION]); |
| 2158 expect(expression, new isInstanceOf<FunctionExpression>()); |
| 2159 } |
| 2160 |
| 2158 void test_namedParameterOutsideGroup() { | 2161 void test_namedParameterOutsideGroup() { |
| 2159 createParser('(a, b : 0)'); | 2162 createParser('(a, b : 0)'); |
| 2160 FormalParameterList list = parser.parseFormalParameterList(); | 2163 FormalParameterList list = parser.parseFormalParameterList(); |
| 2161 expectNotNullIfNoErrors(list); | 2164 expectNotNullIfNoErrors(list); |
| 2162 listener | 2165 listener |
| 2163 .assertErrorsWithCodes([ParserErrorCode.NAMED_PARAMETER_OUTSIDE_GROUP]); | 2166 .assertErrorsWithCodes([ParserErrorCode.NAMED_PARAMETER_OUTSIDE_GROUP]); |
| 2164 } | 2167 } |
| 2165 | 2168 |
| 2166 void test_nonConstructorFactory_field() { | 2169 void test_nonConstructorFactory_field() { |
| 2167 createParser('factory int x;'); | 2170 createParser('factory int x;'); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2200 } | 2203 } |
| 2201 | 2204 |
| 2202 void test_nonUserDefinableOperator() { | 2205 void test_nonUserDefinableOperator() { |
| 2203 createParser('operator +=(int x) => x + 1;'); | 2206 createParser('operator +=(int x) => x + 1;'); |
| 2204 ClassMember member = parser.parseClassMember('C'); | 2207 ClassMember member = parser.parseClassMember('C'); |
| 2205 expectNotNullIfNoErrors(member); | 2208 expectNotNullIfNoErrors(member); |
| 2206 listener | 2209 listener |
| 2207 .assertErrorsWithCodes([ParserErrorCode.NON_USER_DEFINABLE_OPERATOR]); | 2210 .assertErrorsWithCodes([ParserErrorCode.NON_USER_DEFINABLE_OPERATOR]); |
| 2208 } | 2211 } |
| 2209 | 2212 |
| 2213 void test_nullableTypeInExtends() { |
| 2214 enableNnbd = true; |
| 2215 createParser('extends B?'); |
| 2216 ExtendsClause clause = parser.parseExtendsClause(); |
| 2217 expectNotNullIfNoErrors(clause); |
| 2218 listener.assertErrorsWithCodes([ParserErrorCode.NULLABLE_TYPE_IN_EXTENDS]); |
| 2219 } |
| 2220 |
| 2221 void test_nullableTypeInImplements() { |
| 2222 enableNnbd = true; |
| 2223 createParser('implements I?'); |
| 2224 ImplementsClause clause = parser.parseImplementsClause(); |
| 2225 expectNotNullIfNoErrors(clause); |
| 2226 listener |
| 2227 .assertErrorsWithCodes([ParserErrorCode.NULLABLE_TYPE_IN_IMPLEMENTS]); |
| 2228 } |
| 2229 |
| 2230 void test_nullableTypeInWith() { |
| 2231 enableNnbd = true; |
| 2232 createParser('with M?'); |
| 2233 WithClause clause = parser.parseWithClause(); |
| 2234 expectNotNullIfNoErrors(clause); |
| 2235 listener.assertErrorsWithCodes([ParserErrorCode.NULLABLE_TYPE_IN_WITH]); |
| 2236 } |
| 2237 |
| 2238 void test_nullableTypeParameter() { |
| 2239 enableNnbd = true; |
| 2240 createParser('T?'); |
| 2241 TypeParameter parameter = parser.parseTypeParameter(); |
| 2242 expectNotNullIfNoErrors(parameter); |
| 2243 listener.assertErrorsWithCodes([ParserErrorCode.NULLABLE_TYPE_PARAMETER]); |
| 2244 } |
| 2245 |
| 2210 void test_optionalAfterNormalParameters_named() { | 2246 void test_optionalAfterNormalParameters_named() { |
| 2211 ParserTestCase.parseCompilationUnit( | 2247 ParserTestCase.parseCompilationUnit( |
| 2212 "f({a}, b) {}", [ParserErrorCode.NORMAL_BEFORE_OPTIONAL_PARAMETERS]); | 2248 "f({a}, b) {}", [ParserErrorCode.NORMAL_BEFORE_OPTIONAL_PARAMETERS]); |
| 2213 } | 2249 } |
| 2214 | 2250 |
| 2215 void test_optionalAfterNormalParameters_positional() { | 2251 void test_optionalAfterNormalParameters_positional() { |
| 2216 ParserTestCase.parseCompilationUnit( | 2252 ParserTestCase.parseCompilationUnit( |
| 2217 "f([a], b) {}", [ParserErrorCode.NORMAL_BEFORE_OPTIONAL_PARAMETERS]); | 2253 "f([a], b) {}", [ParserErrorCode.NORMAL_BEFORE_OPTIONAL_PARAMETERS]); |
| 2218 } | 2254 } |
| 2219 | 2255 |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2491 expectNotNullIfNoErrors(list); | 2527 expectNotNullIfNoErrors(list); |
| 2492 listener.assertErrorsWithCodes( | 2528 listener.assertErrorsWithCodes( |
| 2493 [ParserErrorCode.UNEXPECTED_TERMINATOR_FOR_PARAMETER_GROUP]); | 2529 [ParserErrorCode.UNEXPECTED_TERMINATOR_FOR_PARAMETER_GROUP]); |
| 2494 } | 2530 } |
| 2495 | 2531 |
| 2496 void test_unexpectedToken_endOfFieldDeclarationStatement() { | 2532 void test_unexpectedToken_endOfFieldDeclarationStatement() { |
| 2497 ParserTestCase.parseStatement( | 2533 ParserTestCase.parseStatement( |
| 2498 "String s = (null));", [ParserErrorCode.UNEXPECTED_TOKEN]); | 2534 "String s = (null));", [ParserErrorCode.UNEXPECTED_TOKEN]); |
| 2499 } | 2535 } |
| 2500 | 2536 |
| 2537 @failingTest |
| 2538 void test_unexpectedToken_invalidPostfixExpression() { |
| 2539 // Note: this might not be the right error to produce, but some error should |
| 2540 // be produced |
| 2541 parseExpression("f()++", [ParserErrorCode.UNEXPECTED_TOKEN]); |
| 2542 } |
| 2543 |
| 2501 void test_unexpectedToken_returnInExpressionFuntionBody() { | 2544 void test_unexpectedToken_returnInExpressionFuntionBody() { |
| 2502 ParserTestCase.parseCompilationUnit( | 2545 ParserTestCase.parseCompilationUnit( |
| 2503 "f() => return null;", [ParserErrorCode.UNEXPECTED_TOKEN]); | 2546 "f() => return null;", [ParserErrorCode.UNEXPECTED_TOKEN]); |
| 2504 } | 2547 } |
| 2505 | 2548 |
| 2506 void test_unexpectedToken_semicolonBetweenClassMembers() { | 2549 void test_unexpectedToken_semicolonBetweenClassMembers() { |
| 2507 createParser('class C { int x; ; int y;}'); | 2550 createParser('class C { int x; ; int y;}'); |
| 2508 ClassDeclaration declaration = | 2551 ClassDeclaration declaration = |
| 2509 parser.parseClassDeclaration(emptyCommentAndMetadata(), null); | 2552 parser.parseClassDeclaration(emptyCommentAndMetadata(), null); |
| 2510 expectNotNullIfNoErrors(declaration); | 2553 expectNotNullIfNoErrors(declaration); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2598 expect(expression, new isInstanceOf<SimpleIdentifier>()); | 2641 expect(expression, new isInstanceOf<SimpleIdentifier>()); |
| 2599 SimpleIdentifier identifier = expression; | 2642 SimpleIdentifier identifier = expression; |
| 2600 expect(identifier.isSynthetic, isTrue); | 2643 expect(identifier.isSynthetic, isTrue); |
| 2601 } | 2644 } |
| 2602 | 2645 |
| 2603 void test_varAndType_field() { | 2646 void test_varAndType_field() { |
| 2604 ParserTestCase.parseCompilationUnit( | 2647 ParserTestCase.parseCompilationUnit( |
| 2605 "class C { var int x; }", [ParserErrorCode.VAR_AND_TYPE]); | 2648 "class C { var int x; }", [ParserErrorCode.VAR_AND_TYPE]); |
| 2606 } | 2649 } |
| 2607 | 2650 |
| 2651 @failingTest |
| 2652 void test_varAndType_local() { |
| 2653 // This is currently reporting EXPECTED_TOKEN for a missing semicolon, but |
| 2654 // this would be a better error message. |
| 2655 ParserTestCase.parseStatement("var int x;", [ParserErrorCode.VAR_AND_TYPE]); |
| 2656 } |
| 2657 |
| 2658 @failingTest |
| 2659 void test_varAndType_parameter() { |
| 2660 // This is currently reporting EXPECTED_TOKEN for a missing semicolon, but |
| 2661 // this would be a better error message. |
| 2662 createParser('(var int x)'); |
| 2663 FormalParameterList list = parser.parseFormalParameterList(); |
| 2664 expectNotNullIfNoErrors(list); |
| 2665 listener.assertErrorsWithCodes([ParserErrorCode.VAR_AND_TYPE]); |
| 2666 } |
| 2667 |
| 2608 void test_varAndType_topLevelVariable() { | 2668 void test_varAndType_topLevelVariable() { |
| 2609 ParserTestCase | 2669 ParserTestCase |
| 2610 .parseCompilationUnit("var int x;", [ParserErrorCode.VAR_AND_TYPE]); | 2670 .parseCompilationUnit("var int x;", [ParserErrorCode.VAR_AND_TYPE]); |
| 2611 } | 2671 } |
| 2612 | 2672 |
| 2613 void test_varAsTypeName_as() { | 2673 void test_varAsTypeName_as() { |
| 2614 parseExpression("x as var", [ParserErrorCode.VAR_AS_TYPE_NAME]); | 2674 parseExpression("x as var", [ParserErrorCode.VAR_AS_TYPE_NAME]); |
| 2615 } | 2675 } |
| 2616 | 2676 |
| 2617 void test_varClass() { | 2677 void test_varClass() { |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2845 Scanner scanner = new Scanner(source, reader, listener); | 2905 Scanner scanner = new Scanner(source, reader, listener); |
| 2846 scanner.scanGenericMethodComments = enableGenericMethodComments; | 2906 scanner.scanGenericMethodComments = enableGenericMethodComments; |
| 2847 scanner.scanLazyAssignmentOperators = enableLazyAssignmentOperators; | 2907 scanner.scanLazyAssignmentOperators = enableLazyAssignmentOperators; |
| 2848 Token tokenStream = scanner.tokenize(); | 2908 Token tokenStream = scanner.tokenize(); |
| 2849 listener.setLineInfo(source, scanner.lineStarts); | 2909 listener.setLineInfo(source, scanner.lineStarts); |
| 2850 // | 2910 // |
| 2851 // Create and initialize the parser. | 2911 // Create and initialize the parser. |
| 2852 // | 2912 // |
| 2853 parser = new Parser(source, listener); | 2913 parser = new Parser(source, listener); |
| 2854 parser.enableAssertInitializer = enableAssertInitializer; | 2914 parser.enableAssertInitializer = enableAssertInitializer; |
| 2855 parser.parseAsync = parseAsync; | |
| 2856 parser.parseGenericMethods = enableGenericMethods; | 2915 parser.parseGenericMethods = enableGenericMethods; |
| 2857 parser.parseGenericMethodComments = enableGenericMethodComments; | 2916 parser.parseGenericMethodComments = enableGenericMethodComments; |
| 2858 parser.parseFunctionBodies = parseFunctionBodies; | 2917 parser.parseFunctionBodies = parseFunctionBodies; |
| 2859 parser.enableNnbd = enableNnbd; | 2918 parser.enableNnbd = enableNnbd; |
| 2860 parser.currentToken = tokenStream; | 2919 parser.currentToken = tokenStream; |
| 2861 } | 2920 } |
| 2862 | 2921 |
| 2863 /** | 2922 /** |
| 2864 * Return an empty CommentAndMetadata object that can be used for testing. | 2923 * Return an empty CommentAndMetadata object that can be used for testing. |
| 2865 * | 2924 * |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2982 return statements; | 3041 return statements; |
| 2983 } | 3042 } |
| 2984 } | 3043 } |
| 2985 | 3044 |
| 2986 /** | 3045 /** |
| 2987 * The class `RecoveryParserTest` defines parser tests that test the parsing of
invalid code | 3046 * The class `RecoveryParserTest` defines parser tests that test the parsing of
invalid code |
| 2988 * sequences to ensure that the correct recovery steps are taken in the parser. | 3047 * sequences to ensure that the correct recovery steps are taken in the parser. |
| 2989 */ | 3048 */ |
| 2990 @reflectiveTest | 3049 @reflectiveTest |
| 2991 class RecoveryParserTest extends ParserTestCase { | 3050 class RecoveryParserTest extends ParserTestCase { |
| 2992 void fail_incomplete_returnType() { | |
| 2993 ParserTestCase.parseCompilationUnit(r''' | |
| 2994 Map<Symbol, convertStringToSymbolMap(Map<String, dynamic> map) { | |
| 2995 if (map == null) return null; | |
| 2996 Map<Symbol, dynamic> result = new Map<Symbol, dynamic>(); | |
| 2997 map.forEach((name, value) { | |
| 2998 result[new Symbol(name)] = value; | |
| 2999 }); | |
| 3000 return result; | |
| 3001 }'''); | |
| 3002 } | |
| 3003 | |
| 3004 void test_additiveExpression_missing_LHS() { | 3051 void test_additiveExpression_missing_LHS() { |
| 3005 BinaryExpression expression = | 3052 BinaryExpression expression = |
| 3006 parseExpression("+ y", [ParserErrorCode.MISSING_IDENTIFIER]); | 3053 parseExpression("+ y", [ParserErrorCode.MISSING_IDENTIFIER]); |
| 3007 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 3054 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
| 3008 SimpleIdentifier, expression.leftOperand); | 3055 SimpleIdentifier, expression.leftOperand); |
| 3009 expect(expression.leftOperand.isSynthetic, isTrue); | 3056 expect(expression.leftOperand.isSynthetic, isTrue); |
| 3010 } | 3057 } |
| 3011 | 3058 |
| 3012 void test_additiveExpression_missing_LHS_RHS() { | 3059 void test_additiveExpression_missing_LHS_RHS() { |
| 3013 BinaryExpression expression = parseExpression("+", [ | 3060 BinaryExpression expression = parseExpression("+", [ |
| (...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3534 } | 3581 } |
| 3535 | 3582 |
| 3536 void test_incomplete_constructorInitializers_variable() { | 3583 void test_incomplete_constructorInitializers_variable() { |
| 3537 createParser('C() : x {}'); | 3584 createParser('C() : x {}'); |
| 3538 ClassMember member = parser.parseClassMember('C'); | 3585 ClassMember member = parser.parseClassMember('C'); |
| 3539 expectNotNullIfNoErrors(member); | 3586 expectNotNullIfNoErrors(member); |
| 3540 listener.assertErrorsWithCodes( | 3587 listener.assertErrorsWithCodes( |
| 3541 [ParserErrorCode.MISSING_ASSIGNMENT_IN_INITIALIZER]); | 3588 [ParserErrorCode.MISSING_ASSIGNMENT_IN_INITIALIZER]); |
| 3542 } | 3589 } |
| 3543 | 3590 |
| 3591 @failingTest |
| 3592 void test_incomplete_returnType() { |
| 3593 ParserTestCase.parseCompilationUnit(r''' |
| 3594 Map<Symbol, convertStringToSymbolMap(Map<String, dynamic> map) { |
| 3595 if (map == null) return null; |
| 3596 Map<Symbol, dynamic> result = new Map<Symbol, dynamic>(); |
| 3597 map.forEach((name, value) { |
| 3598 result[new Symbol(name)] = value; |
| 3599 }); |
| 3600 return result; |
| 3601 }'''); |
| 3602 } |
| 3603 |
| 3544 void test_incomplete_topLevelFunction() { | 3604 void test_incomplete_topLevelFunction() { |
| 3545 ParserTestCase.parseCompilationUnit( | 3605 ParserTestCase.parseCompilationUnit( |
| 3546 "foo();", [ParserErrorCode.MISSING_FUNCTION_BODY]); | 3606 "foo();", [ParserErrorCode.MISSING_FUNCTION_BODY]); |
| 3547 } | 3607 } |
| 3548 | 3608 |
| 3549 void test_incomplete_topLevelVariable() { | 3609 void test_incomplete_topLevelVariable() { |
| 3550 CompilationUnit unit = ParserTestCase | 3610 CompilationUnit unit = ParserTestCase |
| 3551 .parseCompilationUnit("String", [ParserErrorCode.EXPECTED_EXECUTABLE]); | 3611 .parseCompilationUnit("String", [ParserErrorCode.EXPECTED_EXECUTABLE]); |
| 3552 NodeList<CompilationUnitMember> declarations = unit.declarations; | 3612 NodeList<CompilationUnitMember> declarations = unit.declarations; |
| 3553 expect(declarations, hasLength(1)); | 3613 expect(declarations, hasLength(1)); |
| (...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4185 | 4245 |
| 4186 /** | 4246 /** |
| 4187 * The class `SimpleParserTest` defines parser tests that test individual parsin
g method. The | 4247 * The class `SimpleParserTest` defines parser tests that test individual parsin
g method. The |
| 4188 * code fragments should be as minimal as possible in order to test the method,
but should not test | 4248 * code fragments should be as minimal as possible in order to test the method,
but should not test |
| 4189 * the interactions between the method under test and other methods. | 4249 * the interactions between the method under test and other methods. |
| 4190 * | 4250 * |
| 4191 * More complex tests should be defined in the class [ComplexParserTest]. | 4251 * More complex tests should be defined in the class [ComplexParserTest]. |
| 4192 */ | 4252 */ |
| 4193 @reflectiveTest | 4253 @reflectiveTest |
| 4194 class SimpleParserTest extends ParserTestCase { | 4254 class SimpleParserTest extends ParserTestCase { |
| 4195 void fail_parseAwaitExpression_inSync() { | |
| 4196 // This test requires better error recovery than we currently have. In | |
| 4197 // particular, we need to be able to distinguish between an await expression | |
| 4198 // in the wrong context, and the use of 'await' as an identifier. | |
| 4199 createParser('m() { return await x + await y; }'); | |
| 4200 MethodDeclaration method = parser.parseClassMember('C'); | |
| 4201 expectNotNullIfNoErrors(method); | |
| 4202 listener.assertNoErrors(); | |
| 4203 FunctionBody body = method.body; | |
| 4204 EngineTestCase.assertInstanceOf( | |
| 4205 (obj) => obj is BlockFunctionBody, BlockFunctionBody, body); | |
| 4206 Statement statement = (body as BlockFunctionBody).block.statements[0]; | |
| 4207 EngineTestCase.assertInstanceOf( | |
| 4208 (obj) => obj is ReturnStatement, ReturnStatement, statement); | |
| 4209 Expression expression = (statement as ReturnStatement).expression; | |
| 4210 EngineTestCase.assertInstanceOf( | |
| 4211 (obj) => obj is BinaryExpression, BinaryExpression, expression); | |
| 4212 EngineTestCase.assertInstanceOf((obj) => obj is AwaitExpression, | |
| 4213 AwaitExpression, (expression as BinaryExpression).leftOperand); | |
| 4214 EngineTestCase.assertInstanceOf((obj) => obj is AwaitExpression, | |
| 4215 AwaitExpression, (expression as BinaryExpression).rightOperand); | |
| 4216 } | |
| 4217 | |
| 4218 void fail_parseCommentReference_this() { | |
| 4219 // This fails because we are returning null from the method and asserting | |
| 4220 // that the return value is not null. | |
| 4221 createParser(''); | |
| 4222 CommentReference reference = parser.parseCommentReference('this', 5); | |
| 4223 expectNotNullIfNoErrors(reference); | |
| 4224 listener.assertNoErrors(); | |
| 4225 SimpleIdentifier identifier = EngineTestCase.assertInstanceOf( | |
| 4226 (obj) => obj is SimpleIdentifier, | |
| 4227 SimpleIdentifier, | |
| 4228 reference.identifier); | |
| 4229 expect(identifier.token, isNotNull); | |
| 4230 expect(identifier.name, "a"); | |
| 4231 expect(identifier.offset, 5); | |
| 4232 } | |
| 4233 | |
| 4234 void fail_parseStatement_functionDeclaration_noReturnType_typeParameters() { | |
| 4235 enableGenericMethods = true; | |
| 4236 createParser('f<E>(a, b) {};'); | |
| 4237 Statement statement = parser.parseStatement2(); | |
| 4238 expectNotNullIfNoErrors(statement); | |
| 4239 listener.assertNoErrors(); | |
| 4240 expect(statement, new isInstanceOf<FunctionDeclarationStatement>()); | |
| 4241 FunctionDeclarationStatement declaration = statement; | |
| 4242 expect(declaration.functionDeclaration, isNotNull); | |
| 4243 } | |
| 4244 | |
| 4245 void test_computeStringValue_emptyInterpolationPrefix() { | 4255 void test_computeStringValue_emptyInterpolationPrefix() { |
| 4246 expect(_computeStringValue("'''", true, false), ""); | 4256 expect(_computeStringValue("'''", true, false), ""); |
| 4247 } | 4257 } |
| 4248 | 4258 |
| 4249 void test_computeStringValue_escape_b() { | 4259 void test_computeStringValue_escape_b() { |
| 4250 expect(_computeStringValue("'\\b'", true, true), "\b"); | 4260 expect(_computeStringValue("'\\b'", true, true), "\b"); |
| 4251 } | 4261 } |
| 4252 | 4262 |
| 4253 void test_computeStringValue_escape_f() { | 4263 void test_computeStringValue_escape_f() { |
| 4254 expect(_computeStringValue("'\\f'", true, true), "\f"); | 4264 expect(_computeStringValue("'\\f'", true, true), "\f"); |
| (...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5109 FunctionBody body = method.body; | 5119 FunctionBody body = method.body; |
| 5110 EngineTestCase.assertInstanceOf( | 5120 EngineTestCase.assertInstanceOf( |
| 5111 (obj) => obj is BlockFunctionBody, BlockFunctionBody, body); | 5121 (obj) => obj is BlockFunctionBody, BlockFunctionBody, body); |
| 5112 Statement statement = (body as BlockFunctionBody).block.statements[0]; | 5122 Statement statement = (body as BlockFunctionBody).block.statements[0]; |
| 5113 EngineTestCase.assertInstanceOf( | 5123 EngineTestCase.assertInstanceOf( |
| 5114 (obj) => obj is VariableDeclarationStatement, | 5124 (obj) => obj is VariableDeclarationStatement, |
| 5115 VariableDeclarationStatement, | 5125 VariableDeclarationStatement, |
| 5116 statement); | 5126 statement); |
| 5117 } | 5127 } |
| 5118 | 5128 |
| 5129 @failingTest |
| 5130 void test_parseAwaitExpression_inSync() { |
| 5131 // This test requires better error recovery than we currently have. In |
| 5132 // particular, we need to be able to distinguish between an await expression |
| 5133 // in the wrong context, and the use of 'await' as an identifier. |
| 5134 createParser('m() { return await x + await y; }'); |
| 5135 MethodDeclaration method = parser.parseClassMember('C'); |
| 5136 expectNotNullIfNoErrors(method); |
| 5137 listener.assertNoErrors(); |
| 5138 FunctionBody body = method.body; |
| 5139 EngineTestCase.assertInstanceOf( |
| 5140 (obj) => obj is BlockFunctionBody, BlockFunctionBody, body); |
| 5141 Statement statement = (body as BlockFunctionBody).block.statements[0]; |
| 5142 EngineTestCase.assertInstanceOf( |
| 5143 (obj) => obj is ReturnStatement, ReturnStatement, statement); |
| 5144 Expression expression = (statement as ReturnStatement).expression; |
| 5145 EngineTestCase.assertInstanceOf( |
| 5146 (obj) => obj is BinaryExpression, BinaryExpression, expression); |
| 5147 EngineTestCase.assertInstanceOf((obj) => obj is AwaitExpression, |
| 5148 AwaitExpression, (expression as BinaryExpression).leftOperand); |
| 5149 EngineTestCase.assertInstanceOf((obj) => obj is AwaitExpression, |
| 5150 AwaitExpression, (expression as BinaryExpression).rightOperand); |
| 5151 } |
| 5152 |
| 5119 void test_parseBitwiseAndExpression_normal() { | 5153 void test_parseBitwiseAndExpression_normal() { |
| 5120 createParser('x & y'); | 5154 createParser('x & y'); |
| 5121 Expression expression = parser.parseBitwiseAndExpression(); | 5155 Expression expression = parser.parseBitwiseAndExpression(); |
| 5122 expectNotNullIfNoErrors(expression); | 5156 expectNotNullIfNoErrors(expression); |
| 5123 listener.assertNoErrors(); | 5157 listener.assertNoErrors(); |
| 5124 expect(expression, new isInstanceOf<BinaryExpression>()); | 5158 expect(expression, new isInstanceOf<BinaryExpression>()); |
| 5125 BinaryExpression binaryExpression = expression; | 5159 BinaryExpression binaryExpression = expression; |
| 5126 expect(binaryExpression.leftOperand, isNotNull); | 5160 expect(binaryExpression.leftOperand, isNotNull); |
| 5127 expect(binaryExpression.operator, isNotNull); | 5161 expect(binaryExpression.operator, isNotNull); |
| 5128 expect(binaryExpression.operator.type, TokenType.AMPERSAND); | 5162 expect(binaryExpression.operator.type, TokenType.AMPERSAND); |
| (...skipping 1650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6779 expect(identifier.isSynthetic, isTrue); | 6813 expect(identifier.isSynthetic, isTrue); |
| 6780 expect(identifier.token, isNotNull); | 6814 expect(identifier.token, isNotNull); |
| 6781 expect(identifier.name, ""); | 6815 expect(identifier.name, ""); |
| 6782 expect(identifier.offset, 5); | 6816 expect(identifier.offset, 5); |
| 6783 // Should end with EOF token. | 6817 // Should end with EOF token. |
| 6784 Token nextToken = identifier.token.next; | 6818 Token nextToken = identifier.token.next; |
| 6785 expect(nextToken, isNotNull); | 6819 expect(nextToken, isNotNull); |
| 6786 expect(nextToken.type, TokenType.EOF); | 6820 expect(nextToken.type, TokenType.EOF); |
| 6787 } | 6821 } |
| 6788 | 6822 |
| 6823 @failingTest |
| 6824 void test_parseCommentReference_this() { |
| 6825 // This fails because we are returning null from the method and asserting |
| 6826 // that the return value is not null. |
| 6827 createParser(''); |
| 6828 CommentReference reference = parser.parseCommentReference('this', 5); |
| 6829 expectNotNullIfNoErrors(reference); |
| 6830 listener.assertNoErrors(); |
| 6831 SimpleIdentifier identifier = EngineTestCase.assertInstanceOf( |
| 6832 (obj) => obj is SimpleIdentifier, |
| 6833 SimpleIdentifier, |
| 6834 reference.identifier); |
| 6835 expect(identifier.token, isNotNull); |
| 6836 expect(identifier.name, "a"); |
| 6837 expect(identifier.offset, 5); |
| 6838 } |
| 6839 |
| 6789 void test_parseCommentReferences_multiLine() { | 6840 void test_parseCommentReferences_multiLine() { |
| 6790 DocumentationCommentToken token = new DocumentationCommentToken( | 6841 DocumentationCommentToken token = new DocumentationCommentToken( |
| 6791 TokenType.MULTI_LINE_COMMENT, "/** xxx [a] yyy [bb] zzz */", 3); | 6842 TokenType.MULTI_LINE_COMMENT, "/** xxx [a] yyy [bb] zzz */", 3); |
| 6792 List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[token]; | 6843 List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[token]; |
| 6793 createParser(''); | 6844 createParser(''); |
| 6794 List<CommentReference> references = parser.parseCommentReferences(tokens); | 6845 List<CommentReference> references = parser.parseCommentReferences(tokens); |
| 6795 expectNotNullIfNoErrors(references); | 6846 expectNotNullIfNoErrors(references); |
| 6796 listener.assertNoErrors(); | 6847 listener.assertNoErrors(); |
| 6797 List<Token> tokenReferences = token.references; | 6848 List<Token> tokenReferences = token.references; |
| 6798 expect(references, hasLength(2)); | 6849 expect(references, hasLength(2)); |
| (...skipping 3273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10072 ConstructorName name = expression.constructorName; | 10123 ConstructorName name = expression.constructorName; |
| 10073 expect(name, isNotNull); | 10124 expect(name, isNotNull); |
| 10074 TypeName type = name.type; | 10125 TypeName type = name.type; |
| 10075 expect(type, isNotNull); | 10126 expect(type, isNotNull); |
| 10076 expect(type.typeArguments.arguments, hasLength(1)); | 10127 expect(type.typeArguments.arguments, hasLength(1)); |
| 10077 expect(name.period, isNull); | 10128 expect(name.period, isNull); |
| 10078 expect(name.name, isNull); | 10129 expect(name.name, isNull); |
| 10079 expect(expression.argumentList, isNotNull); | 10130 expect(expression.argumentList, isNotNull); |
| 10080 } | 10131 } |
| 10081 | 10132 |
| 10133 void test_parseInstanceCreationExpression_type_typeParameters_nullable() { |
| 10134 enableNnbd = true; |
| 10135 Token token = TokenFactory.tokenFromKeyword(Keyword.NEW); |
| 10136 createParser('A<B?>()'); |
| 10137 InstanceCreationExpression expression = |
| 10138 parser.parseInstanceCreationExpression(token); |
| 10139 expectNotNullIfNoErrors(expression); |
| 10140 listener.assertNoErrors(); |
| 10141 expect(expression.keyword, token); |
| 10142 ConstructorName name = expression.constructorName; |
| 10143 expect(name, isNotNull); |
| 10144 TypeName type = name.type; |
| 10145 expect(type, isNotNull); |
| 10146 expect(name.period, isNull); |
| 10147 expect(name.name, isNull); |
| 10148 expect(expression.argumentList, isNotNull); |
| 10149 NodeList<TypeName> arguments = type.typeArguments.arguments; |
| 10150 expect(arguments, hasLength(1)); |
| 10151 expect(arguments[0].question, isNotNull); |
| 10152 } |
| 10153 |
| 10082 void test_parseLibraryDirective() { | 10154 void test_parseLibraryDirective() { |
| 10083 createParser('library l;'); | 10155 createParser('library l;'); |
| 10084 LibraryDirective directive = | 10156 LibraryDirective directive = |
| 10085 parser.parseLibraryDirective(emptyCommentAndMetadata()); | 10157 parser.parseLibraryDirective(emptyCommentAndMetadata()); |
| 10086 expectNotNullIfNoErrors(directive); | 10158 expectNotNullIfNoErrors(directive); |
| 10087 listener.assertNoErrors(); | 10159 listener.assertNoErrors(); |
| 10088 expect(directive.libraryKeyword, isNotNull); | 10160 expect(directive.libraryKeyword, isNotNull); |
| 10089 expect(directive.name, isNotNull); | 10161 expect(directive.name, isNotNull); |
| 10090 expect(directive.semicolon, isNotNull); | 10162 expect(directive.semicolon, isNotNull); |
| 10091 } | 10163 } |
| (...skipping 1427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11519 Expression expression = parser.parseRelationalExpression(); | 11591 Expression expression = parser.parseRelationalExpression(); |
| 11520 expectNotNullIfNoErrors(expression); | 11592 expectNotNullIfNoErrors(expression); |
| 11521 listener.assertNoErrors(); | 11593 listener.assertNoErrors(); |
| 11522 expect(expression, new isInstanceOf<AsExpression>()); | 11594 expect(expression, new isInstanceOf<AsExpression>()); |
| 11523 AsExpression asExpression = expression; | 11595 AsExpression asExpression = expression; |
| 11524 expect(asExpression.expression, isNotNull); | 11596 expect(asExpression.expression, isNotNull); |
| 11525 expect(asExpression.asOperator, isNotNull); | 11597 expect(asExpression.asOperator, isNotNull); |
| 11526 expect(asExpression.type, isNotNull); | 11598 expect(asExpression.type, isNotNull); |
| 11527 } | 11599 } |
| 11528 | 11600 |
| 11601 void test_parseRelationalExpression_as_nullable() { |
| 11602 enableNnbd = true; |
| 11603 createParser('x as Y?)'); |
| 11604 Expression expression = parser.parseRelationalExpression(); |
| 11605 expectNotNullIfNoErrors(expression); |
| 11606 listener.assertNoErrors(); |
| 11607 expect(expression, new isInstanceOf<AsExpression>()); |
| 11608 AsExpression asExpression = expression; |
| 11609 expect(asExpression.expression, isNotNull); |
| 11610 expect(asExpression.asOperator, isNotNull); |
| 11611 expect(asExpression.type, isNotNull); |
| 11612 } |
| 11613 |
| 11529 void test_parseRelationalExpression_is() { | 11614 void test_parseRelationalExpression_is() { |
| 11530 createParser('x is y'); | 11615 createParser('x is y'); |
| 11531 Expression expression = parser.parseRelationalExpression(); | 11616 Expression expression = parser.parseRelationalExpression(); |
| 11532 expectNotNullIfNoErrors(expression); | 11617 expectNotNullIfNoErrors(expression); |
| 11533 listener.assertNoErrors(); | 11618 listener.assertNoErrors(); |
| 11534 expect(expression, new isInstanceOf<IsExpression>()); | 11619 expect(expression, new isInstanceOf<IsExpression>()); |
| 11535 IsExpression isExpression = expression; | 11620 IsExpression isExpression = expression; |
| 11536 expect(isExpression.expression, isNotNull); | 11621 expect(isExpression.expression, isNotNull); |
| 11537 expect(isExpression.isOperator, isNotNull); | 11622 expect(isExpression.isOperator, isNotNull); |
| 11538 expect(isExpression.notOperator, isNull); | 11623 expect(isExpression.notOperator, isNull); |
| 11539 expect(isExpression.type, isNotNull); | 11624 expect(isExpression.type, isNotNull); |
| 11540 } | 11625 } |
| 11541 | 11626 |
| 11627 void test_parseRelationalExpression_is_nullable() { |
| 11628 enableNnbd = true; |
| 11629 createParser('x is y?)'); |
| 11630 Expression expression = parser.parseRelationalExpression(); |
| 11631 expectNotNullIfNoErrors(expression); |
| 11632 listener.assertNoErrors(); |
| 11633 expect(expression, new isInstanceOf<IsExpression>()); |
| 11634 IsExpression isExpression = expression; |
| 11635 expect(isExpression.expression, isNotNull); |
| 11636 expect(isExpression.isOperator, isNotNull); |
| 11637 expect(isExpression.notOperator, isNull); |
| 11638 expect(isExpression.type, isNotNull); |
| 11639 } |
| 11640 |
| 11542 void test_parseRelationalExpression_isNot() { | 11641 void test_parseRelationalExpression_isNot() { |
| 11543 createParser('x is! y'); | 11642 createParser('x is! y'); |
| 11544 Expression expression = parser.parseRelationalExpression(); | 11643 Expression expression = parser.parseRelationalExpression(); |
| 11545 expectNotNullIfNoErrors(expression); | 11644 expectNotNullIfNoErrors(expression); |
| 11546 listener.assertNoErrors(); | 11645 listener.assertNoErrors(); |
| 11547 expect(expression, new isInstanceOf<IsExpression>()); | 11646 expect(expression, new isInstanceOf<IsExpression>()); |
| 11548 IsExpression isExpression = expression; | 11647 IsExpression isExpression = expression; |
| 11549 expect(isExpression.expression, isNotNull); | 11648 expect(isExpression.expression, isNotNull); |
| 11550 expect(isExpression.isOperator, isNotNull); | 11649 expect(isExpression.isOperator, isNotNull); |
| 11551 expect(isExpression.notOperator, isNotNull); | 11650 expect(isExpression.notOperator, isNotNull); |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11744 Statement statement = parser.parseStatement2(); | 11843 Statement statement = parser.parseStatement2(); |
| 11745 expectNotNullIfNoErrors(statement); | 11844 expectNotNullIfNoErrors(statement); |
| 11746 listener.assertNoErrors(); | 11845 listener.assertNoErrors(); |
| 11747 expect(statement, new isInstanceOf<FunctionDeclarationStatement>()); | 11846 expect(statement, new isInstanceOf<FunctionDeclarationStatement>()); |
| 11748 FunctionDeclarationStatement declaration = statement; | 11847 FunctionDeclarationStatement declaration = statement; |
| 11749 expect(declaration.functionDeclaration, isNotNull); | 11848 expect(declaration.functionDeclaration, isNotNull); |
| 11750 expect(declaration.functionDeclaration.functionExpression.typeParameters, | 11849 expect(declaration.functionDeclaration.functionExpression.typeParameters, |
| 11751 isNotNull); | 11850 isNotNull); |
| 11752 } | 11851 } |
| 11753 | 11852 |
| 11853 @failingTest |
| 11854 void test_parseStatement_functionDeclaration_noReturnType_typeParameters() { |
| 11855 enableGenericMethods = true; |
| 11856 createParser('f<E>(a, b) {};'); |
| 11857 Statement statement = parser.parseStatement2(); |
| 11858 expectNotNullIfNoErrors(statement); |
| 11859 listener.assertNoErrors(); |
| 11860 expect(statement, new isInstanceOf<FunctionDeclarationStatement>()); |
| 11861 FunctionDeclarationStatement declaration = statement; |
| 11862 expect(declaration.functionDeclaration, isNotNull); |
| 11863 } |
| 11864 |
| 11754 void test_parseStatement_functionDeclaration_returnType() { | 11865 void test_parseStatement_functionDeclaration_returnType() { |
| 11755 // TODO(brianwilkerson) Implement more tests for this method. | 11866 // TODO(brianwilkerson) Implement more tests for this method. |
| 11756 createParser('int f(a, b) {};'); | 11867 createParser('int f(a, b) {};'); |
| 11757 Statement statement = parser.parseStatement2(); | 11868 Statement statement = parser.parseStatement2(); |
| 11758 expectNotNullIfNoErrors(statement); | 11869 expectNotNullIfNoErrors(statement); |
| 11759 listener.assertNoErrors(); | 11870 listener.assertNoErrors(); |
| 11760 expect(statement, new isInstanceOf<FunctionDeclarationStatement>()); | 11871 expect(statement, new isInstanceOf<FunctionDeclarationStatement>()); |
| 11761 FunctionDeclarationStatement declaration = statement; | 11872 FunctionDeclarationStatement declaration = statement; |
| 11762 expect(declaration.functionDeclaration, isNotNull); | 11873 expect(declaration.functionDeclaration, isNotNull); |
| 11763 } | 11874 } |
| (...skipping 886 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12650 void test_parseTypeParameter_bounded() { | 12761 void test_parseTypeParameter_bounded() { |
| 12651 createParser('A extends B'); | 12762 createParser('A extends B'); |
| 12652 TypeParameter parameter = parser.parseTypeParameter(); | 12763 TypeParameter parameter = parser.parseTypeParameter(); |
| 12653 expectNotNullIfNoErrors(parameter); | 12764 expectNotNullIfNoErrors(parameter); |
| 12654 listener.assertNoErrors(); | 12765 listener.assertNoErrors(); |
| 12655 expect(parameter.bound, isNotNull); | 12766 expect(parameter.bound, isNotNull); |
| 12656 expect(parameter.extendsKeyword, isNotNull); | 12767 expect(parameter.extendsKeyword, isNotNull); |
| 12657 expect(parameter.name, isNotNull); | 12768 expect(parameter.name, isNotNull); |
| 12658 } | 12769 } |
| 12659 | 12770 |
| 12771 void test_parseTypeParameter_bounded_nullable() { |
| 12772 enableNnbd = true; |
| 12773 createParser('A extends B?'); |
| 12774 TypeParameter parameter = parser.parseTypeParameter(); |
| 12775 expectNotNullIfNoErrors(parameter); |
| 12776 listener.assertNoErrors(); |
| 12777 expect(parameter.bound, isNotNull); |
| 12778 expect(parameter.extendsKeyword, isNotNull); |
| 12779 expect(parameter.name, isNotNull); |
| 12780 TypeName bound = parameter.bound; |
| 12781 expect(bound, isNotNull); |
| 12782 expect(bound.question, isNotNull); |
| 12783 } |
| 12784 |
| 12660 void test_parseTypeParameter_simple() { | 12785 void test_parseTypeParameter_simple() { |
| 12661 createParser('A'); | 12786 createParser('A'); |
| 12662 TypeParameter parameter = parser.parseTypeParameter(); | 12787 TypeParameter parameter = parser.parseTypeParameter(); |
| 12663 expectNotNullIfNoErrors(parameter); | 12788 expectNotNullIfNoErrors(parameter); |
| 12664 listener.assertNoErrors(); | 12789 listener.assertNoErrors(); |
| 12665 expect(parameter.bound, isNull); | 12790 expect(parameter.bound, isNull); |
| 12666 expect(parameter.extendsKeyword, isNull); | 12791 expect(parameter.extendsKeyword, isNull); |
| 12667 expect(parameter.name, isNotNull); | 12792 expect(parameter.name, isNotNull); |
| 12668 } | 12793 } |
| 12669 | 12794 |
| (...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13317 CompilationUnit _parseDirectives(String source, | 13442 CompilationUnit _parseDirectives(String source, |
| 13318 [List<ErrorCode> errorCodes = ErrorCode.EMPTY_LIST]) { | 13443 [List<ErrorCode> errorCodes = ErrorCode.EMPTY_LIST]) { |
| 13319 createParser(source); | 13444 createParser(source); |
| 13320 CompilationUnit unit = parser.parseDirectives2(); | 13445 CompilationUnit unit = parser.parseDirectives2(); |
| 13321 expect(unit, isNotNull); | 13446 expect(unit, isNotNull); |
| 13322 expect(unit.declarations, hasLength(0)); | 13447 expect(unit.declarations, hasLength(0)); |
| 13323 listener.assertErrorsWithCodes(errorCodes); | 13448 listener.assertErrorsWithCodes(errorCodes); |
| 13324 return unit; | 13449 return unit; |
| 13325 } | 13450 } |
| 13326 } | 13451 } |
| OLD | NEW |