| 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'; |
| 11 import 'package:analyzer/error/listener.dart'; | |
| 12 import 'package:analyzer/src/dart/ast/token.dart'; | 11 import 'package:analyzer/src/dart/ast/token.dart'; |
| 13 import 'package:analyzer/src/dart/scanner/reader.dart'; | 12 import 'package:analyzer/src/dart/scanner/reader.dart'; |
| 14 import 'package:analyzer/src/dart/scanner/scanner.dart'; | 13 import 'package:analyzer/src/dart/scanner/scanner.dart'; |
| 15 import 'package:analyzer/src/generated/parser.dart'; | 14 import 'package:analyzer/src/generated/parser.dart'; |
| 16 import 'package:analyzer/src/generated/testing/ast_factory.dart'; | 15 import 'package:analyzer/src/generated/testing/ast_factory.dart'; |
| 17 import 'package:analyzer/src/generated/testing/token_factory.dart'; | 16 import 'package:analyzer/src/generated/testing/token_factory.dart'; |
| 18 import 'package:analyzer/src/generated/utilities_dart.dart'; | 17 import 'package:analyzer/src/generated/utilities_dart.dart'; |
| 19 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 18 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| 20 import 'package:unittest/unittest.dart' hide Configuration; | 19 import 'package:unittest/unittest.dart' hide Configuration; |
| 21 | 20 |
| 22 import '../utils.dart'; | 21 import '../utils.dart'; |
| 23 import 'test_support.dart'; | 22 import 'test_support.dart'; |
| 24 | 23 |
| 25 main() { | 24 main() { |
| 26 initializeTestEnvironment(); | 25 initializeTestEnvironment(); |
| 27 defineReflectiveTests(ComplexParserTest); | 26 defineReflectiveTests(ComplexParserTest); |
| 28 defineReflectiveTests(ErrorParserTest); | 27 defineReflectiveTests(ErrorParserTest); |
| 29 defineReflectiveTests(NonErrorParserTest); | 28 defineReflectiveTests(NonErrorParserTest); |
| 30 defineReflectiveTests(RecoveryParserTest); | 29 defineReflectiveTests(RecoveryParserTest); |
| 31 defineReflectiveTests(SimpleParserTest); | 30 defineReflectiveTests(SimpleParserTest); |
| 32 } | 31 } |
| 33 | 32 |
| 34 class AnalysisErrorListener_SimpleParserTest_computeStringValue | |
| 35 implements AnalysisErrorListener { | |
| 36 @override | |
| 37 void onError(AnalysisError event) { | |
| 38 fail( | |
| 39 "Unexpected compilation error: ${event.message} (${event.offset}, ${even
t.length})"); | |
| 40 } | |
| 41 } | |
| 42 | |
| 43 /** | 33 /** |
| 44 * Instances of the class `AstValidator` are used to validate the correct constr
uction of an | 34 * Instances of the class `AstValidator` are used to validate the correct constr
uction of an |
| 45 * AST structure. | 35 * AST structure. |
| 46 */ | 36 */ |
| 47 class AstValidator extends UnifyingAstVisitor<Object> { | 37 class AstValidator extends UnifyingAstVisitor<Object> { |
| 48 /** | 38 /** |
| 49 * A list containing the errors found while traversing the AST structure. | 39 * A list containing the errors found while traversing the AST structure. |
| 50 */ | 40 */ |
| 51 List<String> _errors = new List<String>(); | 41 List<String> _errors = new List<String>(); |
| 52 | 42 |
| (...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 583 */ | 573 */ |
| 584 @reflectiveTest | 574 @reflectiveTest |
| 585 class ErrorParserTest extends ParserTestCase { | 575 class ErrorParserTest extends ParserTestCase { |
| 586 void fail_expectedListOrMapLiteral() { | 576 void fail_expectedListOrMapLiteral() { |
| 587 // It isn't clear that this test can ever pass. The parser is currently | 577 // It isn't clear that this test can ever pass. The parser is currently |
| 588 // create a synthetic list literal in this case, but isSynthetic() isn't | 578 // create a synthetic list literal in this case, but isSynthetic() isn't |
| 589 // overridden for ListLiteral. The problem is that the synthetic list | 579 // overridden for ListLiteral. The problem is that the synthetic list |
| 590 // literals that are being created are not always zero length (because they | 580 // literals that are being created are not always zero length (because they |
| 591 // could have type parameters), which violates the contract of | 581 // could have type parameters), which violates the contract of |
| 592 // isSynthetic(). | 582 // isSynthetic(). |
| 593 TypedLiteral literal = parse3("parseListOrMapLiteral", <Object>[null], "1", | 583 createParser('1'); |
| 594 [ParserErrorCode.EXPECTED_LIST_OR_MAP_LITERAL]); | 584 TypedLiteral literal = parser.parseListOrMapLiteral(null); |
| 585 expectNotNullIfNoErrors(literal); |
| 586 listener |
| 587 .assertErrorsWithCodes([ParserErrorCode.EXPECTED_LIST_OR_MAP_LITERAL]); |
| 595 expect(literal.isSynthetic, isTrue); | 588 expect(literal.isSynthetic, isTrue); |
| 596 } | 589 } |
| 597 | 590 |
| 598 void fail_illegalAssignmentToNonAssignable_superAssigned() { | 591 void fail_illegalAssignmentToNonAssignable_superAssigned() { |
| 599 // TODO(brianwilkerson) When this test starts to pass, remove the test | 592 // TODO(brianwilkerson) When this test starts to pass, remove the test |
| 600 // test_illegalAssignmentToNonAssignable_superAssigned. | 593 // test_illegalAssignmentToNonAssignable_superAssigned. |
| 601 parseExpression( | 594 parseExpression( |
| 602 "super = x;", [ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE]); | 595 "super = x;", [ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE]); |
| 603 } | 596 } |
| 604 | 597 |
| 605 void fail_invalidCommentReference__new_nonIdentifier() { | 598 void fail_invalidCommentReference__new_nonIdentifier() { |
| 606 // This test fails because the method parseCommentReference returns null. | 599 // This test fails because the method parseCommentReference returns null. |
| 607 parse3("parseCommentReference", <Object>["new 42", 0], "", | 600 createParser(''); |
| 608 [ParserErrorCode.INVALID_COMMENT_REFERENCE]); | 601 CommentReference reference = parser.parseCommentReference('new 42', 0); |
| 602 expectNotNullIfNoErrors(reference); |
| 603 listener.assertErrorsWithCodes([ParserErrorCode.INVALID_COMMENT_REFERENCE]); |
| 609 } | 604 } |
| 610 | 605 |
| 611 void fail_invalidCommentReference__new_tooMuch() { | 606 void fail_invalidCommentReference__new_tooMuch() { |
| 612 parse3("parseCommentReference", <Object>["new a.b.c.d", 0], "", | 607 createParser(''); |
| 613 [ParserErrorCode.INVALID_COMMENT_REFERENCE]); | 608 CommentReference reference = parser.parseCommentReference('new a.b.c.d', 0); |
| 609 expectNotNullIfNoErrors(reference); |
| 610 listener.assertErrorsWithCodes([ParserErrorCode.INVALID_COMMENT_REFERENCE]); |
| 614 } | 611 } |
| 615 | 612 |
| 616 void fail_invalidCommentReference__nonNew_nonIdentifier() { | 613 void fail_invalidCommentReference__nonNew_nonIdentifier() { |
| 617 // This test fails because the method parseCommentReference returns null. | 614 // This test fails because the method parseCommentReference returns null. |
| 618 parse3("parseCommentReference", <Object>["42", 0], "", | 615 createParser(''); |
| 619 [ParserErrorCode.INVALID_COMMENT_REFERENCE]); | 616 CommentReference reference = parser.parseCommentReference('42', 0); |
| 617 expectNotNullIfNoErrors(reference); |
| 618 listener.assertErrorsWithCodes([ParserErrorCode.INVALID_COMMENT_REFERENCE]); |
| 620 } | 619 } |
| 621 | 620 |
| 622 void fail_invalidCommentReference__nonNew_tooMuch() { | 621 void fail_invalidCommentReference__nonNew_tooMuch() { |
| 623 parse3("parseCommentReference", <Object>["a.b.c.d", 0], "", | 622 createParser(''); |
| 624 [ParserErrorCode.INVALID_COMMENT_REFERENCE]); | 623 CommentReference reference = parser.parseCommentReference('a.b.c.d', 0); |
| 624 expectNotNullIfNoErrors(reference); |
| 625 listener.assertErrorsWithCodes([ParserErrorCode.INVALID_COMMENT_REFERENCE]); |
| 625 } | 626 } |
| 626 | 627 |
| 627 void fail_missingClosingParenthesis() { | 628 void fail_missingClosingParenthesis() { |
| 628 // It is possible that it is not possible to generate this error (that it's | 629 // It is possible that it is not possible to generate this error (that it's |
| 629 // being reported in code that cannot actually be reached), but that hasn't | 630 // being reported in code that cannot actually be reached), but that hasn't |
| 630 // been proven yet. | 631 // been proven yet. |
| 631 parse4("parseFormalParameterList", "(int a, int b ;", | 632 createParser('(int a, int b ;'); |
| 632 [ParserErrorCode.MISSING_CLOSING_PARENTHESIS]); | 633 FormalParameterList list = parser.parseFormalParameterList(); |
| 634 expectNotNullIfNoErrors(list); |
| 635 listener |
| 636 .assertErrorsWithCodes([ParserErrorCode.MISSING_CLOSING_PARENTHESIS]); |
| 633 } | 637 } |
| 634 | 638 |
| 635 void fail_missingFunctionParameters_local_nonVoid_block() { | 639 void fail_missingFunctionParameters_local_nonVoid_block() { |
| 636 // The parser does not recognize this as a function declaration, so it tries | 640 // The parser does not recognize this as a function declaration, so it tries |
| 637 // to parse it as an expression statement. It isn't clear what the best | 641 // to parse it as an expression statement. It isn't clear what the best |
| 638 // error message is in this case. | 642 // error message is in this case. |
| 639 ParserTestCase.parseStatement( | 643 ParserTestCase.parseStatement( |
| 640 "int f { return x;}", [ParserErrorCode.MISSING_FUNCTION_PARAMETERS]); | 644 "int f { return x;}", [ParserErrorCode.MISSING_FUNCTION_PARAMETERS]); |
| 641 } | 645 } |
| 642 | 646 |
| 643 void fail_missingFunctionParameters_local_nonVoid_expression() { | 647 void fail_missingFunctionParameters_local_nonVoid_expression() { |
| 644 // The parser does not recognize this as a function declaration, so it tries | 648 // The parser does not recognize this as a function declaration, so it tries |
| 645 // to parse it as an expression statement. It isn't clear what the best | 649 // to parse it as an expression statement. It isn't clear what the best |
| 646 // error message is in this case. | 650 // error message is in this case. |
| 647 ParserTestCase.parseStatement( | 651 ParserTestCase.parseStatement( |
| 648 "int f => x;", [ParserErrorCode.MISSING_FUNCTION_PARAMETERS]); | 652 "int f => x;", [ParserErrorCode.MISSING_FUNCTION_PARAMETERS]); |
| 649 } | 653 } |
| 650 | 654 |
| 651 void fail_namedFunctionExpression() { | 655 void fail_namedFunctionExpression() { |
| 652 Expression expression = parse4("parsePrimaryExpression", "f() {}", | 656 createParser('f() {}'); |
| 653 [ParserErrorCode.NAMED_FUNCTION_EXPRESSION]); | 657 Expression expression = parser.parsePrimaryExpression(); |
| 654 EngineTestCase.assertInstanceOf( | 658 expectNotNullIfNoErrors(expression); |
| 655 (obj) => obj is FunctionExpression, FunctionExpression, expression); | 659 listener.assertErrorsWithCodes([ParserErrorCode.NAMED_FUNCTION_EXPRESSION]); |
| 660 expect(expression, new isInstanceOf<FunctionExpression>()); |
| 656 } | 661 } |
| 657 | 662 |
| 658 void fail_unexpectedToken_invalidPostfixExpression() { | 663 void fail_unexpectedToken_invalidPostfixExpression() { |
| 659 // Note: this might not be the right error to produce, but some error should | 664 // Note: this might not be the right error to produce, but some error should |
| 660 // be produced | 665 // be produced |
| 661 parseExpression("f()++", [ParserErrorCode.UNEXPECTED_TOKEN]); | 666 parseExpression("f()++", [ParserErrorCode.UNEXPECTED_TOKEN]); |
| 662 } | 667 } |
| 663 | 668 |
| 664 void fail_varAndType_local() { | 669 void fail_varAndType_local() { |
| 665 // This is currently reporting EXPECTED_TOKEN for a missing semicolon, but | 670 // This is currently reporting EXPECTED_TOKEN for a missing semicolon, but |
| 666 // this would be a better error message. | 671 // this would be a better error message. |
| 667 ParserTestCase.parseStatement("var int x;", [ParserErrorCode.VAR_AND_TYPE]); | 672 ParserTestCase.parseStatement("var int x;", [ParserErrorCode.VAR_AND_TYPE]); |
| 668 } | 673 } |
| 669 | 674 |
| 670 void fail_varAndType_parameter() { | 675 void fail_varAndType_parameter() { |
| 671 // This is currently reporting EXPECTED_TOKEN for a missing semicolon, but | 676 // This is currently reporting EXPECTED_TOKEN for a missing semicolon, but |
| 672 // this would be a better error message. | 677 // this would be a better error message. |
| 673 parse4("parseFormalParameterList", "(var int x)", | 678 createParser('(var int x)'); |
| 674 [ParserErrorCode.VAR_AND_TYPE]); | 679 FormalParameterList list = parser.parseFormalParameterList(); |
| 680 expectNotNullIfNoErrors(list); |
| 681 listener.assertErrorsWithCodes([ParserErrorCode.VAR_AND_TYPE]); |
| 675 } | 682 } |
| 676 | 683 |
| 677 void test_abstractClassMember_constructor() { | 684 void test_abstractClassMember_constructor() { |
| 678 parse3("parseClassMember", <Object>["C"], "abstract C.c();", | 685 createParser('abstract C.c();'); |
| 679 [ParserErrorCode.ABSTRACT_CLASS_MEMBER]); | 686 ClassMember member = parser.parseClassMember('C'); |
| 687 expectNotNullIfNoErrors(member); |
| 688 listener.assertErrorsWithCodes([ParserErrorCode.ABSTRACT_CLASS_MEMBER]); |
| 680 } | 689 } |
| 681 | 690 |
| 682 void test_abstractClassMember_field() { | 691 void test_abstractClassMember_field() { |
| 683 parse3("parseClassMember", <Object>["C"], "abstract C f;", | 692 createParser('abstract C f;'); |
| 684 [ParserErrorCode.ABSTRACT_CLASS_MEMBER]); | 693 ClassMember member = parser.parseClassMember('C'); |
| 694 expectNotNullIfNoErrors(member); |
| 695 listener.assertErrorsWithCodes([ParserErrorCode.ABSTRACT_CLASS_MEMBER]); |
| 685 } | 696 } |
| 686 | 697 |
| 687 void test_abstractClassMember_getter() { | 698 void test_abstractClassMember_getter() { |
| 688 parse3("parseClassMember", <Object>["C"], "abstract get m;", | 699 createParser('abstract get m;'); |
| 689 [ParserErrorCode.ABSTRACT_CLASS_MEMBER]); | 700 ClassMember member = parser.parseClassMember('C'); |
| 701 expectNotNullIfNoErrors(member); |
| 702 listener.assertErrorsWithCodes([ParserErrorCode.ABSTRACT_CLASS_MEMBER]); |
| 690 } | 703 } |
| 691 | 704 |
| 692 void test_abstractClassMember_method() { | 705 void test_abstractClassMember_method() { |
| 693 parse3("parseClassMember", <Object>["C"], "abstract m();", | 706 createParser('abstract m();'); |
| 694 [ParserErrorCode.ABSTRACT_CLASS_MEMBER]); | 707 ClassMember member = parser.parseClassMember('C'); |
| 708 expectNotNullIfNoErrors(member); |
| 709 listener.assertErrorsWithCodes([ParserErrorCode.ABSTRACT_CLASS_MEMBER]); |
| 695 } | 710 } |
| 696 | 711 |
| 697 void test_abstractClassMember_setter() { | 712 void test_abstractClassMember_setter() { |
| 698 parse3("parseClassMember", <Object>["C"], "abstract set m(v);", | 713 createParser('abstract set m(v);'); |
| 699 [ParserErrorCode.ABSTRACT_CLASS_MEMBER]); | 714 ClassMember member = parser.parseClassMember('C'); |
| 715 expectNotNullIfNoErrors(member); |
| 716 listener.assertErrorsWithCodes([ParserErrorCode.ABSTRACT_CLASS_MEMBER]); |
| 700 } | 717 } |
| 701 | 718 |
| 702 void test_abstractEnum() { | 719 void test_abstractEnum() { |
| 703 ParserTestCase.parseCompilationUnit( | 720 ParserTestCase.parseCompilationUnit( |
| 704 "abstract enum E {ONE}", [ParserErrorCode.ABSTRACT_ENUM]); | 721 "abstract enum E {ONE}", [ParserErrorCode.ABSTRACT_ENUM]); |
| 705 } | 722 } |
| 706 | 723 |
| 707 void test_abstractTopLevelFunction_function() { | 724 void test_abstractTopLevelFunction_function() { |
| 708 ParserTestCase.parseCompilationUnit( | 725 ParserTestCase.parseCompilationUnit( |
| 709 "abstract f(v) {}", [ParserErrorCode.ABSTRACT_TOP_LEVEL_FUNCTION]); | 726 "abstract f(v) {}", [ParserErrorCode.ABSTRACT_TOP_LEVEL_FUNCTION]); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 733 ParserTestCase.parseCompilationUnit("enum E { @override C }", | 750 ParserTestCase.parseCompilationUnit("enum E { @override C }", |
| 734 [ParserErrorCode.ANNOTATION_ON_ENUM_CONSTANT]); | 751 [ParserErrorCode.ANNOTATION_ON_ENUM_CONSTANT]); |
| 735 } | 752 } |
| 736 | 753 |
| 737 void test_annotationOnEnumConstant_middle() { | 754 void test_annotationOnEnumConstant_middle() { |
| 738 ParserTestCase.parseCompilationUnit("enum E { C, @override D, E }", | 755 ParserTestCase.parseCompilationUnit("enum E { C, @override D, E }", |
| 739 [ParserErrorCode.ANNOTATION_ON_ENUM_CONSTANT]); | 756 [ParserErrorCode.ANNOTATION_ON_ENUM_CONSTANT]); |
| 740 } | 757 } |
| 741 | 758 |
| 742 void test_breakOutsideOfLoop_breakInDoStatement() { | 759 void test_breakOutsideOfLoop_breakInDoStatement() { |
| 743 parse4("parseDoStatement", "do {break;} while (x);"); | 760 createParser('do {break;} while (x);'); |
| 761 DoStatement statement = parser.parseDoStatement(); |
| 762 expectNotNullIfNoErrors(statement); |
| 763 listener.assertNoErrors(); |
| 744 } | 764 } |
| 745 | 765 |
| 746 void test_breakOutsideOfLoop_breakInForStatement() { | 766 void test_breakOutsideOfLoop_breakInForStatement() { |
| 747 parse4("parseForStatement", "for (; x;) {break;}"); | 767 createParser('for (; x;) {break;}'); |
| 768 Statement statement = parser.parseForStatement(); |
| 769 expectNotNullIfNoErrors(statement); |
| 770 listener.assertNoErrors(); |
| 748 } | 771 } |
| 749 | 772 |
| 750 void test_breakOutsideOfLoop_breakInIfStatement() { | 773 void test_breakOutsideOfLoop_breakInIfStatement() { |
| 751 parse4("parseIfStatement", "if (x) {break;}", | 774 createParser('if (x) {break;}'); |
| 752 [ParserErrorCode.BREAK_OUTSIDE_OF_LOOP]); | 775 IfStatement statement = parser.parseIfStatement(); |
| 776 expectNotNullIfNoErrors(statement); |
| 777 listener.assertErrorsWithCodes([ParserErrorCode.BREAK_OUTSIDE_OF_LOOP]); |
| 753 } | 778 } |
| 754 | 779 |
| 755 void test_breakOutsideOfLoop_breakInSwitchStatement() { | 780 void test_breakOutsideOfLoop_breakInSwitchStatement() { |
| 756 parse4("parseSwitchStatement", "switch (x) {case 1: break;}"); | 781 createParser('switch (x) {case 1: break;}'); |
| 782 SwitchStatement statement = parser.parseSwitchStatement(); |
| 783 expectNotNullIfNoErrors(statement); |
| 784 listener.assertNoErrors(); |
| 757 } | 785 } |
| 758 | 786 |
| 759 void test_breakOutsideOfLoop_breakInWhileStatement() { | 787 void test_breakOutsideOfLoop_breakInWhileStatement() { |
| 760 parse4("parseWhileStatement", "while (x) {break;}"); | 788 createParser('while (x) {break;}'); |
| 789 WhileStatement statement = parser.parseWhileStatement(); |
| 790 expectNotNullIfNoErrors(statement); |
| 791 listener.assertNoErrors(); |
| 761 } | 792 } |
| 762 | 793 |
| 763 void test_breakOutsideOfLoop_functionExpression_inALoop() { | 794 void test_breakOutsideOfLoop_functionExpression_inALoop() { |
| 764 ParserTestCase.parseStatement( | 795 ParserTestCase.parseStatement( |
| 765 "for(; x;) {() {break;};}", [ParserErrorCode.BREAK_OUTSIDE_OF_LOOP]); | 796 "for(; x;) {() {break;};}", [ParserErrorCode.BREAK_OUTSIDE_OF_LOOP]); |
| 766 } | 797 } |
| 767 | 798 |
| 768 void test_breakOutsideOfLoop_functionExpression_withALoop() { | 799 void test_breakOutsideOfLoop_functionExpression_withALoop() { |
| 769 ParserTestCase.parseStatement("() {for (; x;) {break;}};"); | 800 ParserTestCase.parseStatement("() {for (; x;) {break;}};"); |
| 770 } | 801 } |
| 771 | 802 |
| 772 void test_classInClass_abstract() { | 803 void test_classInClass_abstract() { |
| 773 ParserTestCase.parseCompilationUnit( | 804 ParserTestCase.parseCompilationUnit( |
| 774 "class C { abstract class B {} }", [ParserErrorCode.CLASS_IN_CLASS]); | 805 "class C { abstract class B {} }", [ParserErrorCode.CLASS_IN_CLASS]); |
| 775 } | 806 } |
| 776 | 807 |
| 777 void test_classInClass_nonAbstract() { | 808 void test_classInClass_nonAbstract() { |
| 778 ParserTestCase.parseCompilationUnit( | 809 ParserTestCase.parseCompilationUnit( |
| 779 "class C { class B {} }", [ParserErrorCode.CLASS_IN_CLASS]); | 810 "class C { class B {} }", [ParserErrorCode.CLASS_IN_CLASS]); |
| 780 } | 811 } |
| 781 | 812 |
| 782 void test_classTypeAlias_abstractAfterEq() { | 813 void test_classTypeAlias_abstractAfterEq() { |
| 783 // This syntax has been removed from the language in favor of | 814 // This syntax has been removed from the language in favor of |
| 784 // "abstract class A = B with C;" (issue 18098). | 815 // "abstract class A = B with C;" (issue 18098). |
| 785 parse3( | 816 createParser('class A = abstract B with C;'); |
| 786 "parseCompilationUnitMember", | 817 CompilationUnitMember member = |
| 787 <Object>[emptyCommentAndMetadata()], | 818 parser.parseCompilationUnitMember(emptyCommentAndMetadata()); |
| 788 "class A = abstract B with C;", | 819 expectNotNullIfNoErrors(member); |
| 820 listener.assertErrorsWithCodes( |
| 789 [ParserErrorCode.EXPECTED_TOKEN, ParserErrorCode.EXPECTED_TOKEN]); | 821 [ParserErrorCode.EXPECTED_TOKEN, ParserErrorCode.EXPECTED_TOKEN]); |
| 790 } | 822 } |
| 791 | 823 |
| 792 void test_colonInPlaceOfIn() { | 824 void test_colonInPlaceOfIn() { |
| 793 ParserTestCase.parseStatement( | 825 ParserTestCase.parseStatement( |
| 794 "for (var x : list) {}", [ParserErrorCode.COLON_IN_PLACE_OF_IN]); | 826 "for (var x : list) {}", [ParserErrorCode.COLON_IN_PLACE_OF_IN]); |
| 795 } | 827 } |
| 796 | 828 |
| 797 void test_constAndFinal() { | 829 void test_constAndFinal() { |
| 798 parse3("parseClassMember", <Object>["C"], "const final int x;", | 830 createParser('const final int x;'); |
| 799 [ParserErrorCode.CONST_AND_FINAL]); | 831 ClassMember member = parser.parseClassMember('C'); |
| 832 expectNotNullIfNoErrors(member); |
| 833 listener.assertErrorsWithCodes([ParserErrorCode.CONST_AND_FINAL]); |
| 800 } | 834 } |
| 801 | 835 |
| 802 void test_constAndVar() { | 836 void test_constAndVar() { |
| 803 parse3("parseClassMember", <Object>["C"], "const var x;", | 837 createParser('const var x;'); |
| 804 [ParserErrorCode.CONST_AND_VAR]); | 838 ClassMember member = parser.parseClassMember('C'); |
| 839 expectNotNullIfNoErrors(member); |
| 840 listener.assertErrorsWithCodes([ParserErrorCode.CONST_AND_VAR]); |
| 805 } | 841 } |
| 806 | 842 |
| 807 void test_constClass() { | 843 void test_constClass() { |
| 808 ParserTestCase.parseCompilationUnit( | 844 ParserTestCase.parseCompilationUnit( |
| 809 "const class C {}", [ParserErrorCode.CONST_CLASS]); | 845 "const class C {}", [ParserErrorCode.CONST_CLASS]); |
| 810 } | 846 } |
| 811 | 847 |
| 812 void test_constConstructorWithBody() { | 848 void test_constConstructorWithBody() { |
| 813 parse3("parseClassMember", <Object>["C"], "const C() {}", | 849 createParser('const C() {}'); |
| 814 [ParserErrorCode.CONST_CONSTRUCTOR_WITH_BODY]); | 850 ClassMember member = parser.parseClassMember('C'); |
| 851 expectNotNullIfNoErrors(member); |
| 852 listener |
| 853 .assertErrorsWithCodes([ParserErrorCode.CONST_CONSTRUCTOR_WITH_BODY]); |
| 815 } | 854 } |
| 816 | 855 |
| 817 void test_constEnum() { | 856 void test_constEnum() { |
| 818 ParserTestCase.parseCompilationUnit( | 857 ParserTestCase.parseCompilationUnit( |
| 819 "const enum E {ONE}", [ParserErrorCode.CONST_ENUM]); | 858 "const enum E {ONE}", [ParserErrorCode.CONST_ENUM]); |
| 820 } | 859 } |
| 821 | 860 |
| 822 void test_constFactory() { | 861 void test_constFactory() { |
| 823 parse3("parseClassMember", <Object>["C"], "const factory C() {}", | 862 createParser('const factory C() {}'); |
| 824 [ParserErrorCode.CONST_FACTORY]); | 863 ClassMember member = parser.parseClassMember('C'); |
| 864 expectNotNullIfNoErrors(member); |
| 865 listener.assertErrorsWithCodes([ParserErrorCode.CONST_FACTORY]); |
| 825 } | 866 } |
| 826 | 867 |
| 827 void test_constMethod() { | 868 void test_constMethod() { |
| 828 parse3("parseClassMember", <Object>["C"], "const int m() {}", | 869 createParser('const int m() {}'); |
| 829 [ParserErrorCode.CONST_METHOD]); | 870 ClassMember member = parser.parseClassMember('C'); |
| 871 expectNotNullIfNoErrors(member); |
| 872 listener.assertErrorsWithCodes([ParserErrorCode.CONST_METHOD]); |
| 830 } | 873 } |
| 831 | 874 |
| 832 void test_constructorWithReturnType() { | 875 void test_constructorWithReturnType() { |
| 833 parse3("parseClassMember", <Object>["C"], "C C() {}", | 876 createParser('C C() {}'); |
| 834 [ParserErrorCode.CONSTRUCTOR_WITH_RETURN_TYPE]); | 877 ClassMember member = parser.parseClassMember('C'); |
| 878 expectNotNullIfNoErrors(member); |
| 879 listener |
| 880 .assertErrorsWithCodes([ParserErrorCode.CONSTRUCTOR_WITH_RETURN_TYPE]); |
| 835 } | 881 } |
| 836 | 882 |
| 837 void test_constructorWithReturnType_var() { | 883 void test_constructorWithReturnType_var() { |
| 838 parse3("parseClassMember", <Object>["C"], "var C() {}", | 884 createParser('var C() {}'); |
| 839 [ParserErrorCode.CONSTRUCTOR_WITH_RETURN_TYPE]); | 885 ClassMember member = parser.parseClassMember('C'); |
| 886 expectNotNullIfNoErrors(member); |
| 887 listener |
| 888 .assertErrorsWithCodes([ParserErrorCode.CONSTRUCTOR_WITH_RETURN_TYPE]); |
| 840 } | 889 } |
| 841 | 890 |
| 842 void test_constTypedef() { | 891 void test_constTypedef() { |
| 843 ParserTestCase.parseCompilationUnit( | 892 ParserTestCase.parseCompilationUnit( |
| 844 "const typedef F();", [ParserErrorCode.CONST_TYPEDEF]); | 893 "const typedef F();", [ParserErrorCode.CONST_TYPEDEF]); |
| 845 } | 894 } |
| 846 | 895 |
| 847 void test_continueOutsideOfLoop_continueInDoStatement() { | 896 void test_continueOutsideOfLoop_continueInDoStatement() { |
| 848 parse4("parseDoStatement", "do {continue;} while (x);"); | 897 createParser('do {continue;} while (x);'); |
| 898 DoStatement statement = parser.parseDoStatement(); |
| 899 expectNotNullIfNoErrors(statement); |
| 900 listener.assertNoErrors(); |
| 849 } | 901 } |
| 850 | 902 |
| 851 void test_continueOutsideOfLoop_continueInForStatement() { | 903 void test_continueOutsideOfLoop_continueInForStatement() { |
| 852 parse4("parseForStatement", "for (; x;) {continue;}"); | 904 createParser('for (; x;) {continue;}'); |
| 905 Statement statement = parser.parseForStatement(); |
| 906 expectNotNullIfNoErrors(statement); |
| 907 listener.assertNoErrors(); |
| 853 } | 908 } |
| 854 | 909 |
| 855 void test_continueOutsideOfLoop_continueInIfStatement() { | 910 void test_continueOutsideOfLoop_continueInIfStatement() { |
| 856 parse4("parseIfStatement", "if (x) {continue;}", | 911 createParser('if (x) {continue;}'); |
| 857 [ParserErrorCode.CONTINUE_OUTSIDE_OF_LOOP]); | 912 IfStatement statement = parser.parseIfStatement(); |
| 913 expectNotNullIfNoErrors(statement); |
| 914 listener.assertErrorsWithCodes([ParserErrorCode.CONTINUE_OUTSIDE_OF_LOOP]); |
| 858 } | 915 } |
| 859 | 916 |
| 860 void test_continueOutsideOfLoop_continueInSwitchStatement() { | 917 void test_continueOutsideOfLoop_continueInSwitchStatement() { |
| 861 parse4("parseSwitchStatement", "switch (x) {case 1: continue a;}"); | 918 createParser('switch (x) {case 1: continue a;}'); |
| 919 SwitchStatement statement = parser.parseSwitchStatement(); |
| 920 expectNotNullIfNoErrors(statement); |
| 921 listener.assertNoErrors(); |
| 862 } | 922 } |
| 863 | 923 |
| 864 void test_continueOutsideOfLoop_continueInWhileStatement() { | 924 void test_continueOutsideOfLoop_continueInWhileStatement() { |
| 865 parse4("parseWhileStatement", "while (x) {continue;}"); | 925 createParser('while (x) {continue;}'); |
| 926 WhileStatement statement = parser.parseWhileStatement(); |
| 927 expectNotNullIfNoErrors(statement); |
| 928 listener.assertNoErrors(); |
| 866 } | 929 } |
| 867 | 930 |
| 868 void test_continueOutsideOfLoop_functionExpression_inALoop() { | 931 void test_continueOutsideOfLoop_functionExpression_inALoop() { |
| 869 ParserTestCase.parseStatement("for(; x;) {() {continue;};}", | 932 ParserTestCase.parseStatement("for(; x;) {() {continue;};}", |
| 870 [ParserErrorCode.CONTINUE_OUTSIDE_OF_LOOP]); | 933 [ParserErrorCode.CONTINUE_OUTSIDE_OF_LOOP]); |
| 871 } | 934 } |
| 872 | 935 |
| 873 void test_continueOutsideOfLoop_functionExpression_withALoop() { | 936 void test_continueOutsideOfLoop_functionExpression_withALoop() { |
| 874 ParserTestCase.parseStatement("() {for (; x;) {continue;}};"); | 937 ParserTestCase.parseStatement("() {for (; x;) {continue;}};"); |
| 875 } | 938 } |
| 876 | 939 |
| 877 void test_continueWithoutLabelInCase_error() { | 940 void test_continueWithoutLabelInCase_error() { |
| 878 parse4("parseSwitchStatement", "switch (x) {case 1: continue;}", | 941 createParser('switch (x) {case 1: continue;}'); |
| 942 SwitchStatement statement = parser.parseSwitchStatement(); |
| 943 expectNotNullIfNoErrors(statement); |
| 944 listener.assertErrorsWithCodes( |
| 879 [ParserErrorCode.CONTINUE_WITHOUT_LABEL_IN_CASE]); | 945 [ParserErrorCode.CONTINUE_WITHOUT_LABEL_IN_CASE]); |
| 880 } | 946 } |
| 881 | 947 |
| 882 void test_continueWithoutLabelInCase_noError() { | 948 void test_continueWithoutLabelInCase_noError() { |
| 883 parse4("parseSwitchStatement", "switch (x) {case 1: continue a;}"); | 949 createParser('switch (x) {case 1: continue a;}'); |
| 950 SwitchStatement statement = parser.parseSwitchStatement(); |
| 951 expectNotNullIfNoErrors(statement); |
| 952 listener.assertNoErrors(); |
| 884 } | 953 } |
| 885 | 954 |
| 886 void test_continueWithoutLabelInCase_noError_switchInLoop() { | 955 void test_continueWithoutLabelInCase_noError_switchInLoop() { |
| 887 parse4( | 956 createParser('while (a) { switch (b) {default: continue;}}'); |
| 888 "parseWhileStatement", "while (a) { switch (b) {default: continue;}}"); | 957 WhileStatement statement = parser.parseWhileStatement(); |
| 958 expectNotNullIfNoErrors(statement); |
| 959 listener.assertNoErrors(); |
| 889 } | 960 } |
| 890 | 961 |
| 891 void test_deprecatedClassTypeAlias() { | 962 void test_deprecatedClassTypeAlias() { |
| 892 ParserTestCase.parseCompilationUnit( | 963 ParserTestCase.parseCompilationUnit( |
| 893 "typedef C = S with M;", [ParserErrorCode.DEPRECATED_CLASS_TYPE_ALIAS]); | 964 "typedef C = S with M;", [ParserErrorCode.DEPRECATED_CLASS_TYPE_ALIAS]); |
| 894 } | 965 } |
| 895 | 966 |
| 896 void test_deprecatedClassTypeAlias_withGeneric() { | 967 void test_deprecatedClassTypeAlias_withGeneric() { |
| 897 ParserTestCase.parseCompilationUnit("typedef C<T> = S<T> with M;", | 968 ParserTestCase.parseCompilationUnit("typedef C<T> = S<T> with M;", |
| 898 [ParserErrorCode.DEPRECATED_CLASS_TYPE_ALIAS]); | 969 [ParserErrorCode.DEPRECATED_CLASS_TYPE_ALIAS]); |
| 899 } | 970 } |
| 900 | 971 |
| 901 void test_directiveAfterDeclaration_classBeforeDirective() { | 972 void test_directiveAfterDeclaration_classBeforeDirective() { |
| 902 CompilationUnit unit = ParserTestCase.parseCompilationUnit( | 973 CompilationUnit unit = ParserTestCase.parseCompilationUnit( |
| 903 "class Foo{} library l;", | 974 "class Foo{} library l;", |
| 904 [ParserErrorCode.DIRECTIVE_AFTER_DECLARATION]); | 975 [ParserErrorCode.DIRECTIVE_AFTER_DECLARATION]); |
| 905 expect(unit, isNotNull); | 976 expect(unit, isNotNull); |
| 906 } | 977 } |
| 907 | 978 |
| 908 void test_directiveAfterDeclaration_classBetweenDirectives() { | 979 void test_directiveAfterDeclaration_classBetweenDirectives() { |
| 909 CompilationUnit unit = ParserTestCase.parseCompilationUnit( | 980 CompilationUnit unit = ParserTestCase.parseCompilationUnit( |
| 910 "library l;\nclass Foo{}\npart 'a.dart';", | 981 "library l;\nclass Foo{}\npart 'a.dart';", |
| 911 [ParserErrorCode.DIRECTIVE_AFTER_DECLARATION]); | 982 [ParserErrorCode.DIRECTIVE_AFTER_DECLARATION]); |
| 912 expect(unit, isNotNull); | 983 expect(unit, isNotNull); |
| 913 } | 984 } |
| 914 | 985 |
| 915 void test_duplicatedModifier_const() { | 986 void test_duplicatedModifier_const() { |
| 916 parse3("parseClassMember", <Object>["C"], "const const m;", | 987 createParser('const const m;'); |
| 917 [ParserErrorCode.DUPLICATED_MODIFIER]); | 988 ClassMember member = parser.parseClassMember('C'); |
| 989 expectNotNullIfNoErrors(member); |
| 990 listener.assertErrorsWithCodes([ParserErrorCode.DUPLICATED_MODIFIER]); |
| 918 } | 991 } |
| 919 | 992 |
| 920 void test_duplicatedModifier_external() { | 993 void test_duplicatedModifier_external() { |
| 921 parse3("parseClassMember", <Object>["C"], "external external f();", | 994 createParser('external external f();'); |
| 922 [ParserErrorCode.DUPLICATED_MODIFIER]); | 995 ClassMember member = parser.parseClassMember('C'); |
| 996 expectNotNullIfNoErrors(member); |
| 997 listener.assertErrorsWithCodes([ParserErrorCode.DUPLICATED_MODIFIER]); |
| 923 } | 998 } |
| 924 | 999 |
| 925 void test_duplicatedModifier_factory() { | 1000 void test_duplicatedModifier_factory() { |
| 926 parse3("parseClassMember", <Object>["C"], "factory factory C() {}", | 1001 createParser('factory factory C() {}'); |
| 927 [ParserErrorCode.DUPLICATED_MODIFIER]); | 1002 ClassMember member = parser.parseClassMember('C'); |
| 1003 expectNotNullIfNoErrors(member); |
| 1004 listener.assertErrorsWithCodes([ParserErrorCode.DUPLICATED_MODIFIER]); |
| 928 } | 1005 } |
| 929 | 1006 |
| 930 void test_duplicatedModifier_final() { | 1007 void test_duplicatedModifier_final() { |
| 931 parse3("parseClassMember", <Object>["C"], "final final m;", | 1008 createParser('final final m;'); |
| 932 [ParserErrorCode.DUPLICATED_MODIFIER]); | 1009 ClassMember member = parser.parseClassMember('C'); |
| 1010 expectNotNullIfNoErrors(member); |
| 1011 listener.assertErrorsWithCodes([ParserErrorCode.DUPLICATED_MODIFIER]); |
| 933 } | 1012 } |
| 934 | 1013 |
| 935 void test_duplicatedModifier_static() { | 1014 void test_duplicatedModifier_static() { |
| 936 parse3("parseClassMember", <Object>["C"], "static static var m;", | 1015 createParser('static static var m;'); |
| 937 [ParserErrorCode.DUPLICATED_MODIFIER]); | 1016 ClassMember member = parser.parseClassMember('C'); |
| 1017 expectNotNullIfNoErrors(member); |
| 1018 listener.assertErrorsWithCodes([ParserErrorCode.DUPLICATED_MODIFIER]); |
| 938 } | 1019 } |
| 939 | 1020 |
| 940 void test_duplicatedModifier_var() { | 1021 void test_duplicatedModifier_var() { |
| 941 parse3("parseClassMember", <Object>["C"], "var var m;", | 1022 createParser('var var m;'); |
| 942 [ParserErrorCode.DUPLICATED_MODIFIER]); | 1023 ClassMember member = parser.parseClassMember('C'); |
| 1024 expectNotNullIfNoErrors(member); |
| 1025 listener.assertErrorsWithCodes([ParserErrorCode.DUPLICATED_MODIFIER]); |
| 943 } | 1026 } |
| 944 | 1027 |
| 945 void test_duplicateLabelInSwitchStatement() { | 1028 void test_duplicateLabelInSwitchStatement() { |
| 946 parse4( | 1029 createParser('switch (e) {l1: case 0: break; l1: case 1: break;}'); |
| 947 "parseSwitchStatement", | 1030 SwitchStatement statement = parser.parseSwitchStatement(); |
| 948 "switch (e) {l1: case 0: break; l1: case 1: break;}", | 1031 expectNotNullIfNoErrors(statement); |
| 1032 listener.assertErrorsWithCodes( |
| 949 [ParserErrorCode.DUPLICATE_LABEL_IN_SWITCH_STATEMENT]); | 1033 [ParserErrorCode.DUPLICATE_LABEL_IN_SWITCH_STATEMENT]); |
| 950 } | 1034 } |
| 951 | 1035 |
| 952 void test_emptyEnumBody() { | 1036 void test_emptyEnumBody() { |
| 953 parse3("parseEnumDeclaration", <Object>[emptyCommentAndMetadata()], | 1037 createParser('enum E {}'); |
| 954 "enum E {}", [ParserErrorCode.EMPTY_ENUM_BODY]); | 1038 EnumDeclaration declaration = |
| 1039 parser.parseEnumDeclaration(emptyCommentAndMetadata()); |
| 1040 expectNotNullIfNoErrors(declaration); |
| 1041 listener.assertErrorsWithCodes([ParserErrorCode.EMPTY_ENUM_BODY]); |
| 955 } | 1042 } |
| 956 | 1043 |
| 957 void test_enableAsync_false_1() { | 1044 void test_enableAsync_false_1() { |
| 958 parseAsync = false; | 1045 parseAsync = false; |
| 959 FunctionDeclarationStatement stmt = parse4( | 1046 createParser('foo() async {}'); |
| 960 "parseFunctionDeclarationStatement", | 1047 FunctionDeclarationStatement statement = |
| 961 "foo() async {}", | 1048 parser.parseFunctionDeclarationStatement(); |
| 962 [ParserErrorCode.ASYNC_NOT_SUPPORTED]); | 1049 expectNotNullIfNoErrors(statement); |
| 963 FunctionExpression expr = stmt.functionDeclaration.functionExpression; | 1050 listener.assertErrorsWithCodes([ParserErrorCode.ASYNC_NOT_SUPPORTED]); |
| 1051 FunctionExpression expr = statement.functionDeclaration.functionExpression; |
| 964 expect(expr.body.isAsynchronous, isTrue); | 1052 expect(expr.body.isAsynchronous, isTrue); |
| 965 expect(expr.body.isGenerator, isFalse); | 1053 expect(expr.body.isGenerator, isFalse); |
| 966 } | 1054 } |
| 967 | 1055 |
| 968 void test_enableAsync_false_2() { | 1056 void test_enableAsync_false_2() { |
| 969 parseAsync = false; | 1057 parseAsync = false; |
| 970 FunctionDeclarationStatement stmt = parse4( | 1058 createParser('foo() async => 0;'); |
| 971 "parseFunctionDeclarationStatement", | 1059 FunctionDeclarationStatement statement = |
| 972 "foo() async => 0;", | 1060 parser.parseFunctionDeclarationStatement(); |
| 973 [ParserErrorCode.ASYNC_NOT_SUPPORTED]); | 1061 expectNotNullIfNoErrors(statement); |
| 974 FunctionExpression expr = stmt.functionDeclaration.functionExpression; | 1062 listener.assertErrorsWithCodes([ParserErrorCode.ASYNC_NOT_SUPPORTED]); |
| 1063 FunctionExpression expr = statement.functionDeclaration.functionExpression; |
| 975 expect(expr.body.isAsynchronous, isTrue); | 1064 expect(expr.body.isAsynchronous, isTrue); |
| 976 expect(expr.body.isGenerator, isFalse); | 1065 expect(expr.body.isGenerator, isFalse); |
| 977 } | 1066 } |
| 978 | 1067 |
| 979 void test_enableAsync_false_3() { | 1068 void test_enableAsync_false_3() { |
| 980 parseAsync = false; | 1069 parseAsync = false; |
| 981 FunctionDeclarationStatement stmt = parse4( | 1070 createParser('foo() sync* {}'); |
| 982 "parseFunctionDeclarationStatement", | 1071 FunctionDeclarationStatement statement = |
| 983 "foo() sync* {}", | 1072 parser.parseFunctionDeclarationStatement(); |
| 984 [ParserErrorCode.ASYNC_NOT_SUPPORTED]); | 1073 expectNotNullIfNoErrors(statement); |
| 985 FunctionExpression expr = stmt.functionDeclaration.functionExpression; | 1074 listener.assertErrorsWithCodes([ParserErrorCode.ASYNC_NOT_SUPPORTED]); |
| 1075 FunctionExpression expr = statement.functionDeclaration.functionExpression; |
| 986 expect(expr.body.isAsynchronous, isFalse); | 1076 expect(expr.body.isAsynchronous, isFalse); |
| 987 expect(expr.body.isGenerator, isTrue); | 1077 expect(expr.body.isGenerator, isTrue); |
| 988 } | 1078 } |
| 989 | 1079 |
| 990 void test_enumInClass() { | 1080 void test_enumInClass() { |
| 991 ParserTestCase.parseCompilationUnit( | 1081 ParserTestCase.parseCompilationUnit( |
| 992 r''' | 1082 r''' |
| 993 class Foo { | 1083 class Foo { |
| 994 enum Bar { | 1084 enum Bar { |
| 995 Bar1, Bar2, Bar3 | 1085 Bar1, Bar2, Bar3 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1008 parseExpression( | 1098 parseExpression( |
| 1009 "1 == 2 != 3", [ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND]); | 1099 "1 == 2 != 3", [ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND]); |
| 1010 } | 1100 } |
| 1011 | 1101 |
| 1012 void test_equalityCannotBeEqualityOperand_neq_eq() { | 1102 void test_equalityCannotBeEqualityOperand_neq_eq() { |
| 1013 parseExpression( | 1103 parseExpression( |
| 1014 "1 != 2 == 3", [ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND]); | 1104 "1 != 2 == 3", [ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND]); |
| 1015 } | 1105 } |
| 1016 | 1106 |
| 1017 void test_expectedCaseOrDefault() { | 1107 void test_expectedCaseOrDefault() { |
| 1018 parse4("parseSwitchStatement", "switch (e) {break;}", | 1108 createParser('switch (e) {break;}'); |
| 1019 [ParserErrorCode.EXPECTED_CASE_OR_DEFAULT]); | 1109 SwitchStatement statement = parser.parseSwitchStatement(); |
| 1110 expectNotNullIfNoErrors(statement); |
| 1111 listener.assertErrorsWithCodes([ParserErrorCode.EXPECTED_CASE_OR_DEFAULT]); |
| 1020 } | 1112 } |
| 1021 | 1113 |
| 1022 void test_expectedClassMember_inClass_afterType() { | 1114 void test_expectedClassMember_inClass_afterType() { |
| 1023 parse3("parseClassMember", <Object>["C"], "heart 2 heart", | 1115 createParser('heart 2 heart'); |
| 1024 [ParserErrorCode.EXPECTED_CLASS_MEMBER]); | 1116 ClassMember member = parser.parseClassMember('C'); |
| 1117 expectNotNullIfNoErrors(member); |
| 1118 listener.assertErrorsWithCodes([ParserErrorCode.EXPECTED_CLASS_MEMBER]); |
| 1025 } | 1119 } |
| 1026 | 1120 |
| 1027 void test_expectedClassMember_inClass_beforeType() { | 1121 void test_expectedClassMember_inClass_beforeType() { |
| 1028 parse3("parseClassMember", <Object>["C"], "4 score", | 1122 createParser('4 score'); |
| 1029 [ParserErrorCode.EXPECTED_CLASS_MEMBER]); | 1123 ClassMember member = parser.parseClassMember('C'); |
| 1124 expectNotNullIfNoErrors(member); |
| 1125 listener.assertErrorsWithCodes([ParserErrorCode.EXPECTED_CLASS_MEMBER]); |
| 1030 } | 1126 } |
| 1031 | 1127 |
| 1032 void test_expectedExecutable_inClass_afterVoid() { | 1128 void test_expectedExecutable_inClass_afterVoid() { |
| 1033 parse3("parseClassMember", <Object>["C"], "void 2 void", | 1129 createParser('void 2 void'); |
| 1034 [ParserErrorCode.EXPECTED_EXECUTABLE]); | 1130 ClassMember member = parser.parseClassMember('C'); |
| 1131 expectNotNullIfNoErrors(member); |
| 1132 listener.assertErrorsWithCodes([ParserErrorCode.EXPECTED_EXECUTABLE]); |
| 1035 } | 1133 } |
| 1036 | 1134 |
| 1037 void test_expectedExecutable_topLevel_afterType() { | 1135 void test_expectedExecutable_topLevel_afterType() { |
| 1038 parse3("parseCompilationUnitMember", <Object>[emptyCommentAndMetadata()], | 1136 createParser('heart 2 heart'); |
| 1039 "heart 2 heart", [ParserErrorCode.EXPECTED_EXECUTABLE]); | 1137 CompilationUnitMember member = |
| 1138 parser.parseCompilationUnitMember(emptyCommentAndMetadata()); |
| 1139 expectNotNullIfNoErrors(member); |
| 1140 listener.assertErrorsWithCodes([ParserErrorCode.EXPECTED_EXECUTABLE]); |
| 1040 } | 1141 } |
| 1041 | 1142 |
| 1042 void test_expectedExecutable_topLevel_afterVoid() { | 1143 void test_expectedExecutable_topLevel_afterVoid() { |
| 1043 parse3("parseCompilationUnitMember", <Object>[emptyCommentAndMetadata()], | 1144 createParser('void 2 void'); |
| 1044 "void 2 void", [ParserErrorCode.EXPECTED_EXECUTABLE]); | 1145 CompilationUnitMember member = |
| 1146 parser.parseCompilationUnitMember(emptyCommentAndMetadata()); |
| 1147 expectNotNullIfNoErrors(member); |
| 1148 listener.assertErrorsWithCodes([ParserErrorCode.EXPECTED_EXECUTABLE]); |
| 1045 } | 1149 } |
| 1046 | 1150 |
| 1047 void test_expectedExecutable_topLevel_beforeType() { | 1151 void test_expectedExecutable_topLevel_beforeType() { |
| 1048 parse3("parseCompilationUnitMember", <Object>[emptyCommentAndMetadata()], | 1152 createParser('4 score'); |
| 1049 "4 score", [ParserErrorCode.EXPECTED_EXECUTABLE]); | 1153 CompilationUnitMember member = |
| 1154 parser.parseCompilationUnitMember(emptyCommentAndMetadata()); |
| 1155 expectNotNullIfNoErrors(member); |
| 1156 listener.assertErrorsWithCodes([ParserErrorCode.EXPECTED_EXECUTABLE]); |
| 1050 } | 1157 } |
| 1051 | 1158 |
| 1052 void test_expectedExecutable_topLevel_eof() { | 1159 void test_expectedExecutable_topLevel_eof() { |
| 1053 parse2( | 1160 parse( |
| 1054 "parseCompilationUnitMember", | 1161 "parseCompilationUnitMember", |
| 1055 <Object>[emptyCommentAndMetadata()], | 1162 <Object>[emptyCommentAndMetadata()], |
| 1056 "x", | 1163 "x", |
| 1057 [new AnalysisError(null, 0, 1, ParserErrorCode.EXPECTED_EXECUTABLE)]); | 1164 [new AnalysisError(null, 0, 1, ParserErrorCode.EXPECTED_EXECUTABLE)]); |
| 1058 } | 1165 } |
| 1059 | 1166 |
| 1060 void test_expectedInterpolationIdentifier() { | 1167 void test_expectedInterpolationIdentifier() { |
| 1061 parse4( | 1168 createParser("'\$x\$'"); |
| 1062 "parseStringLiteral", "'\$x\$'", [ParserErrorCode.MISSING_IDENTIFIER]); | 1169 StringLiteral literal = parser.parseStringLiteral(); |
| 1170 expectNotNullIfNoErrors(literal); |
| 1171 listener.assertErrorsWithCodes([ParserErrorCode.MISSING_IDENTIFIER]); |
| 1063 } | 1172 } |
| 1064 | 1173 |
| 1065 void test_expectedInterpolationIdentifier_emptyString() { | 1174 void test_expectedInterpolationIdentifier_emptyString() { |
| 1066 // The scanner inserts an empty string token between the two $'s; we need to | 1175 // The scanner inserts an empty string token between the two $'s; we need to |
| 1067 // make sure that the MISSING_IDENTIFIER error that is generated has a | 1176 // make sure that the MISSING_IDENTIFIER error that is generated has a |
| 1068 // nonzero width so that it will show up in the editor UI. | 1177 // nonzero width so that it will show up in the editor UI. |
| 1069 parse2("parseStringLiteral", <Object>[], "'\$\$foo'", | 1178 parse("parseStringLiteral", <Object>[], "'\$\$foo'", |
| 1070 [new AnalysisError(null, 2, 1, ParserErrorCode.MISSING_IDENTIFIER)]); | 1179 [new AnalysisError(null, 2, 1, ParserErrorCode.MISSING_IDENTIFIER)]); |
| 1071 } | 1180 } |
| 1072 | 1181 |
| 1073 void test_expectedStringLiteral() { | 1182 void test_expectedStringLiteral() { |
| 1074 StringLiteral expression = parse4( | 1183 createParser('1'); |
| 1075 "parseStringLiteral", "1", [ParserErrorCode.EXPECTED_STRING_LITERAL]); | 1184 StringLiteral literal = parser.parseStringLiteral(); |
| 1076 expect(expression.isSynthetic, isTrue); | 1185 expectNotNullIfNoErrors(literal); |
| 1186 listener.assertErrorsWithCodes([ParserErrorCode.EXPECTED_STRING_LITERAL]); |
| 1187 expect(literal.isSynthetic, isTrue); |
| 1077 } | 1188 } |
| 1078 | 1189 |
| 1079 void test_expectedToken_commaMissingInArgumentList() { | 1190 void test_expectedToken_commaMissingInArgumentList() { |
| 1080 parse4("parseArgumentList", "(x, y z)", [ParserErrorCode.EXPECTED_TOKEN]); | 1191 createParser('(x, y z)'); |
| 1192 ArgumentList list = parser.parseArgumentList(); |
| 1193 expectNotNullIfNoErrors(list); |
| 1194 listener.assertErrorsWithCodes([ParserErrorCode.EXPECTED_TOKEN]); |
| 1081 } | 1195 } |
| 1082 | 1196 |
| 1083 void test_expectedToken_parseStatement_afterVoid() { | 1197 void test_expectedToken_parseStatement_afterVoid() { |
| 1084 ParserTestCase.parseStatement("void}", | 1198 ParserTestCase.parseStatement("void}", |
| 1085 [ParserErrorCode.EXPECTED_TOKEN, ParserErrorCode.MISSING_IDENTIFIER]); | 1199 [ParserErrorCode.EXPECTED_TOKEN, ParserErrorCode.MISSING_IDENTIFIER]); |
| 1086 } | 1200 } |
| 1087 | 1201 |
| 1088 void test_expectedToken_semicolonAfterClass() { | 1202 void test_expectedToken_semicolonAfterClass() { |
| 1089 Token token = TokenFactory.tokenFromKeyword(Keyword.CLASS); | 1203 Token token = TokenFactory.tokenFromKeyword(Keyword.CLASS); |
| 1090 parse3( | 1204 createParser('A = B with C'); |
| 1091 "parseClassTypeAlias", | 1205 ClassTypeAlias declaration = |
| 1092 <Object>[emptyCommentAndMetadata(), null, token], | 1206 parser.parseClassTypeAlias(emptyCommentAndMetadata(), null, token); |
| 1093 "A = B with C", | 1207 expectNotNullIfNoErrors(declaration); |
| 1094 [ParserErrorCode.EXPECTED_TOKEN]); | 1208 listener.assertErrorsWithCodes([ParserErrorCode.EXPECTED_TOKEN]); |
| 1095 } | 1209 } |
| 1096 | 1210 |
| 1097 void test_expectedToken_semicolonMissingAfterExport() { | 1211 void test_expectedToken_semicolonMissingAfterExport() { |
| 1098 CompilationUnit unit = ParserTestCase.parseCompilationUnit( | 1212 CompilationUnit unit = ParserTestCase.parseCompilationUnit( |
| 1099 "export '' class A {}", [ParserErrorCode.EXPECTED_TOKEN]); | 1213 "export '' class A {}", [ParserErrorCode.EXPECTED_TOKEN]); |
| 1100 ExportDirective directive = unit.directives[0] as ExportDirective; | 1214 ExportDirective directive = unit.directives[0] as ExportDirective; |
| 1101 Token semicolon = directive.semicolon; | 1215 Token semicolon = directive.semicolon; |
| 1102 expect(semicolon, isNotNull); | 1216 expect(semicolon, isNotNull); |
| 1103 expect(semicolon.isSynthetic, isTrue); | 1217 expect(semicolon.isSynthetic, isTrue); |
| 1104 } | 1218 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1124 void test_expectedTypeName_is() { | 1238 void test_expectedTypeName_is() { |
| 1125 parseExpression("x is", [ParserErrorCode.EXPECTED_TYPE_NAME]); | 1239 parseExpression("x is", [ParserErrorCode.EXPECTED_TYPE_NAME]); |
| 1126 } | 1240 } |
| 1127 | 1241 |
| 1128 void test_exportDirectiveAfterPartDirective() { | 1242 void test_exportDirectiveAfterPartDirective() { |
| 1129 ParserTestCase.parseCompilationUnit("part 'a.dart'; export 'b.dart';", | 1243 ParserTestCase.parseCompilationUnit("part 'a.dart'; export 'b.dart';", |
| 1130 [ParserErrorCode.EXPORT_DIRECTIVE_AFTER_PART_DIRECTIVE]); | 1244 [ParserErrorCode.EXPORT_DIRECTIVE_AFTER_PART_DIRECTIVE]); |
| 1131 } | 1245 } |
| 1132 | 1246 |
| 1133 void test_externalAfterConst() { | 1247 void test_externalAfterConst() { |
| 1134 parse3("parseClassMember", <Object>["C"], "const external C();", | 1248 createParser('const external C();'); |
| 1135 [ParserErrorCode.EXTERNAL_AFTER_CONST]); | 1249 ClassMember member = parser.parseClassMember('C'); |
| 1250 expectNotNullIfNoErrors(member); |
| 1251 listener.assertErrorsWithCodes([ParserErrorCode.EXTERNAL_AFTER_CONST]); |
| 1136 } | 1252 } |
| 1137 | 1253 |
| 1138 void test_externalAfterFactory() { | 1254 void test_externalAfterFactory() { |
| 1139 parse3("parseClassMember", <Object>["C"], "factory external C();", | 1255 createParser('factory external C();'); |
| 1140 [ParserErrorCode.EXTERNAL_AFTER_FACTORY]); | 1256 ClassMember member = parser.parseClassMember('C'); |
| 1257 expectNotNullIfNoErrors(member); |
| 1258 listener.assertErrorsWithCodes([ParserErrorCode.EXTERNAL_AFTER_FACTORY]); |
| 1141 } | 1259 } |
| 1142 | 1260 |
| 1143 void test_externalAfterStatic() { | 1261 void test_externalAfterStatic() { |
| 1144 parse3("parseClassMember", <Object>["C"], "static external int m();", | 1262 createParser('static external int m();'); |
| 1145 [ParserErrorCode.EXTERNAL_AFTER_STATIC]); | 1263 ClassMember member = parser.parseClassMember('C'); |
| 1264 expectNotNullIfNoErrors(member); |
| 1265 listener.assertErrorsWithCodes([ParserErrorCode.EXTERNAL_AFTER_STATIC]); |
| 1146 } | 1266 } |
| 1147 | 1267 |
| 1148 void test_externalClass() { | 1268 void test_externalClass() { |
| 1149 ParserTestCase.parseCompilationUnit( | 1269 ParserTestCase.parseCompilationUnit( |
| 1150 "external class C {}", [ParserErrorCode.EXTERNAL_CLASS]); | 1270 "external class C {}", [ParserErrorCode.EXTERNAL_CLASS]); |
| 1151 } | 1271 } |
| 1152 | 1272 |
| 1153 void test_externalConstructorWithBody_factory() { | 1273 void test_externalConstructorWithBody_factory() { |
| 1154 parse3("parseClassMember", <Object>["C"], "external factory C() {}", | 1274 createParser('external factory C() {}'); |
| 1275 ClassMember member = parser.parseClassMember('C'); |
| 1276 expectNotNullIfNoErrors(member); |
| 1277 listener.assertErrorsWithCodes( |
| 1155 [ParserErrorCode.EXTERNAL_CONSTRUCTOR_WITH_BODY]); | 1278 [ParserErrorCode.EXTERNAL_CONSTRUCTOR_WITH_BODY]); |
| 1156 } | 1279 } |
| 1157 | 1280 |
| 1158 void test_externalConstructorWithBody_named() { | 1281 void test_externalConstructorWithBody_named() { |
| 1159 parse3("parseClassMember", <Object>["C"], "external C.c() {}", | 1282 createParser('external C.c() {}'); |
| 1283 ClassMember member = parser.parseClassMember('C'); |
| 1284 expectNotNullIfNoErrors(member); |
| 1285 listener.assertErrorsWithCodes( |
| 1160 [ParserErrorCode.EXTERNAL_CONSTRUCTOR_WITH_BODY]); | 1286 [ParserErrorCode.EXTERNAL_CONSTRUCTOR_WITH_BODY]); |
| 1161 } | 1287 } |
| 1162 | 1288 |
| 1163 void test_externalEnum() { | 1289 void test_externalEnum() { |
| 1164 ParserTestCase.parseCompilationUnit( | 1290 ParserTestCase.parseCompilationUnit( |
| 1165 "external enum E {ONE}", [ParserErrorCode.EXTERNAL_ENUM]); | 1291 "external enum E {ONE}", [ParserErrorCode.EXTERNAL_ENUM]); |
| 1166 } | 1292 } |
| 1167 | 1293 |
| 1168 void test_externalField_const() { | 1294 void test_externalField_const() { |
| 1169 parse3("parseClassMember", <Object>["C"], "external const A f;", | 1295 createParser('external const A f;'); |
| 1170 [ParserErrorCode.EXTERNAL_FIELD]); | 1296 ClassMember member = parser.parseClassMember('C'); |
| 1297 expectNotNullIfNoErrors(member); |
| 1298 listener.assertErrorsWithCodes([ParserErrorCode.EXTERNAL_FIELD]); |
| 1171 } | 1299 } |
| 1172 | 1300 |
| 1173 void test_externalField_final() { | 1301 void test_externalField_final() { |
| 1174 parse3("parseClassMember", <Object>["C"], "external final A f;", | 1302 createParser('external final A f;'); |
| 1175 [ParserErrorCode.EXTERNAL_FIELD]); | 1303 ClassMember member = parser.parseClassMember('C'); |
| 1304 expectNotNullIfNoErrors(member); |
| 1305 listener.assertErrorsWithCodes([ParserErrorCode.EXTERNAL_FIELD]); |
| 1176 } | 1306 } |
| 1177 | 1307 |
| 1178 void test_externalField_static() { | 1308 void test_externalField_static() { |
| 1179 parse3("parseClassMember", <Object>["C"], "external static A f;", | 1309 createParser('external static A f;'); |
| 1180 [ParserErrorCode.EXTERNAL_FIELD]); | 1310 ClassMember member = parser.parseClassMember('C'); |
| 1311 expectNotNullIfNoErrors(member); |
| 1312 listener.assertErrorsWithCodes([ParserErrorCode.EXTERNAL_FIELD]); |
| 1181 } | 1313 } |
| 1182 | 1314 |
| 1183 void test_externalField_typed() { | 1315 void test_externalField_typed() { |
| 1184 parse3("parseClassMember", <Object>["C"], "external A f;", | 1316 createParser('external A f;'); |
| 1185 [ParserErrorCode.EXTERNAL_FIELD]); | 1317 ClassMember member = parser.parseClassMember('C'); |
| 1318 expectNotNullIfNoErrors(member); |
| 1319 listener.assertErrorsWithCodes([ParserErrorCode.EXTERNAL_FIELD]); |
| 1186 } | 1320 } |
| 1187 | 1321 |
| 1188 void test_externalField_untyped() { | 1322 void test_externalField_untyped() { |
| 1189 parse3("parseClassMember", <Object>["C"], "external var f;", | 1323 createParser('external var f;'); |
| 1190 [ParserErrorCode.EXTERNAL_FIELD]); | 1324 ClassMember member = parser.parseClassMember('C'); |
| 1325 expectNotNullIfNoErrors(member); |
| 1326 listener.assertErrorsWithCodes([ParserErrorCode.EXTERNAL_FIELD]); |
| 1191 } | 1327 } |
| 1192 | 1328 |
| 1193 void test_externalGetterWithBody() { | 1329 void test_externalGetterWithBody() { |
| 1194 parse3("parseClassMember", <Object>["C"], "external int get x {}", | 1330 createParser('external int get x {}'); |
| 1195 [ParserErrorCode.EXTERNAL_GETTER_WITH_BODY]); | 1331 ClassMember member = parser.parseClassMember('C'); |
| 1332 expectNotNullIfNoErrors(member); |
| 1333 listener.assertErrorsWithCodes([ParserErrorCode.EXTERNAL_GETTER_WITH_BODY]); |
| 1196 } | 1334 } |
| 1197 | 1335 |
| 1198 void test_externalMethodWithBody() { | 1336 void test_externalMethodWithBody() { |
| 1199 parse3("parseClassMember", <Object>["C"], "external m() {}", | 1337 createParser('external m() {}'); |
| 1200 [ParserErrorCode.EXTERNAL_METHOD_WITH_BODY]); | 1338 ClassMember member = parser.parseClassMember('C'); |
| 1339 expectNotNullIfNoErrors(member); |
| 1340 listener.assertErrorsWithCodes([ParserErrorCode.EXTERNAL_METHOD_WITH_BODY]); |
| 1201 } | 1341 } |
| 1202 | 1342 |
| 1203 void test_externalOperatorWithBody() { | 1343 void test_externalOperatorWithBody() { |
| 1204 parse3( | 1344 createParser('external operator +(int value) {}'); |
| 1205 "parseClassMember", | 1345 ClassMember member = parser.parseClassMember('C'); |
| 1206 <Object>["C"], | 1346 expectNotNullIfNoErrors(member); |
| 1207 "external operator +(int value) {}", | 1347 listener |
| 1208 [ParserErrorCode.EXTERNAL_OPERATOR_WITH_BODY]); | 1348 .assertErrorsWithCodes([ParserErrorCode.EXTERNAL_OPERATOR_WITH_BODY]); |
| 1209 } | 1349 } |
| 1210 | 1350 |
| 1211 void test_externalSetterWithBody() { | 1351 void test_externalSetterWithBody() { |
| 1212 parse3("parseClassMember", <Object>["C"], "external set x(int value) {}", | 1352 createParser('external set x(int value) {}'); |
| 1213 [ParserErrorCode.EXTERNAL_SETTER_WITH_BODY]); | 1353 ClassMember member = parser.parseClassMember('C'); |
| 1354 expectNotNullIfNoErrors(member); |
| 1355 listener.assertErrorsWithCodes([ParserErrorCode.EXTERNAL_SETTER_WITH_BODY]); |
| 1214 } | 1356 } |
| 1215 | 1357 |
| 1216 void test_externalTypedef() { | 1358 void test_externalTypedef() { |
| 1217 ParserTestCase.parseCompilationUnit( | 1359 ParserTestCase.parseCompilationUnit( |
| 1218 "external typedef F();", [ParserErrorCode.EXTERNAL_TYPEDEF]); | 1360 "external typedef F();", [ParserErrorCode.EXTERNAL_TYPEDEF]); |
| 1219 } | 1361 } |
| 1220 | 1362 |
| 1221 void test_extraCommaInParameterList() { | 1363 void test_extraCommaInParameterList() { |
| 1222 parse4("parseFormalParameterList", "(int a, , int b)", | 1364 createParser('(int a, , int b)'); |
| 1365 FormalParameterList list = parser.parseFormalParameterList(); |
| 1366 expectNotNullIfNoErrors(list); |
| 1367 listener.assertErrorsWithCodes( |
| 1223 [ParserErrorCode.MISSING_IDENTIFIER, ParserErrorCode.EXPECTED_TOKEN]); | 1368 [ParserErrorCode.MISSING_IDENTIFIER, ParserErrorCode.EXPECTED_TOKEN]); |
| 1224 } | 1369 } |
| 1225 | 1370 |
| 1226 void test_extraCommaTrailingNamedParameterGroup() { | 1371 void test_extraCommaTrailingNamedParameterGroup() { |
| 1227 parse4("parseFormalParameterList", "({int b},)", [ | 1372 createParser('({int b},)'); |
| 1373 FormalParameterList list = parser.parseFormalParameterList(); |
| 1374 expectNotNullIfNoErrors(list); |
| 1375 listener.assertErrorsWithCodes([ |
| 1228 ParserErrorCode.MISSING_IDENTIFIER, | 1376 ParserErrorCode.MISSING_IDENTIFIER, |
| 1229 ParserErrorCode.NORMAL_BEFORE_OPTIONAL_PARAMETERS | 1377 ParserErrorCode.NORMAL_BEFORE_OPTIONAL_PARAMETERS |
| 1230 ]); | 1378 ]); |
| 1231 } | 1379 } |
| 1232 | 1380 |
| 1233 void test_extraCommaTrailingPositionalParameterGroup() { | 1381 void test_extraCommaTrailingPositionalParameterGroup() { |
| 1234 parse4("parseFormalParameterList", "([int b],)", [ | 1382 createParser('([int b],)'); |
| 1383 FormalParameterList list = parser.parseFormalParameterList(); |
| 1384 expectNotNullIfNoErrors(list); |
| 1385 listener.assertErrorsWithCodes([ |
| 1235 ParserErrorCode.MISSING_IDENTIFIER, | 1386 ParserErrorCode.MISSING_IDENTIFIER, |
| 1236 ParserErrorCode.NORMAL_BEFORE_OPTIONAL_PARAMETERS | 1387 ParserErrorCode.NORMAL_BEFORE_OPTIONAL_PARAMETERS |
| 1237 ]); | 1388 ]); |
| 1238 } | 1389 } |
| 1239 | 1390 |
| 1240 void test_extraTrailingCommaInParameterList() { | 1391 void test_extraTrailingCommaInParameterList() { |
| 1241 parse4("parseFormalParameterList", "(a,,)", | 1392 createParser('(a,,)'); |
| 1242 [ParserErrorCode.MISSING_IDENTIFIER]); | 1393 FormalParameterList list = parser.parseFormalParameterList(); |
| 1394 expectNotNullIfNoErrors(list); |
| 1395 listener.assertErrorsWithCodes([ParserErrorCode.MISSING_IDENTIFIER]); |
| 1243 } | 1396 } |
| 1244 | 1397 |
| 1245 void test_factoryTopLevelDeclaration_class() { | 1398 void test_factoryTopLevelDeclaration_class() { |
| 1246 ParserTestCase.parseCompilationUnit( | 1399 ParserTestCase.parseCompilationUnit( |
| 1247 "factory class C {}", [ParserErrorCode.FACTORY_TOP_LEVEL_DECLARATION]); | 1400 "factory class C {}", [ParserErrorCode.FACTORY_TOP_LEVEL_DECLARATION]); |
| 1248 } | 1401 } |
| 1249 | 1402 |
| 1250 void test_factoryTopLevelDeclaration_typedef() { | 1403 void test_factoryTopLevelDeclaration_typedef() { |
| 1251 ParserTestCase.parseCompilationUnit("factory typedef F();", | 1404 ParserTestCase.parseCompilationUnit("factory typedef F();", |
| 1252 [ParserErrorCode.FACTORY_TOP_LEVEL_DECLARATION]); | 1405 [ParserErrorCode.FACTORY_TOP_LEVEL_DECLARATION]); |
| 1253 } | 1406 } |
| 1254 | 1407 |
| 1255 void test_factoryWithInitializers() { | 1408 void test_factoryWithInitializers() { |
| 1256 parse3("parseClassMember", <Object>["C"], "factory C() : x = 3 {}", | 1409 createParser('factory C() : x = 3 {}'); |
| 1257 [ParserErrorCode.FACTORY_WITH_INITIALIZERS]); | 1410 ClassMember member = parser.parseClassMember('C'); |
| 1411 expectNotNullIfNoErrors(member); |
| 1412 listener.assertErrorsWithCodes([ParserErrorCode.FACTORY_WITH_INITIALIZERS]); |
| 1258 } | 1413 } |
| 1259 | 1414 |
| 1260 void test_factoryWithoutBody() { | 1415 void test_factoryWithoutBody() { |
| 1261 parse3("parseClassMember", <Object>["C"], "factory C();", | 1416 createParser('factory C();'); |
| 1262 [ParserErrorCode.FACTORY_WITHOUT_BODY]); | 1417 ClassMember member = parser.parseClassMember('C'); |
| 1418 expectNotNullIfNoErrors(member); |
| 1419 listener.assertErrorsWithCodes([ParserErrorCode.FACTORY_WITHOUT_BODY]); |
| 1263 } | 1420 } |
| 1264 | 1421 |
| 1265 void test_fieldInitializerOutsideConstructor() { | 1422 void test_fieldInitializerOutsideConstructor() { |
| 1266 parse3("parseClassMember", <Object>["C"], "void m(this.x);", | 1423 createParser('void m(this.x);'); |
| 1424 ClassMember member = parser.parseClassMember('C'); |
| 1425 expectNotNullIfNoErrors(member); |
| 1426 listener.assertErrorsWithCodes( |
| 1267 [ParserErrorCode.FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR]); | 1427 [ParserErrorCode.FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR]); |
| 1268 } | 1428 } |
| 1269 | 1429 |
| 1270 void test_finalAndVar() { | 1430 void test_finalAndVar() { |
| 1271 parse3("parseClassMember", <Object>["C"], "final var x;", | 1431 createParser('final var x;'); |
| 1272 [ParserErrorCode.FINAL_AND_VAR]); | 1432 ClassMember member = parser.parseClassMember('C'); |
| 1433 expectNotNullIfNoErrors(member); |
| 1434 listener.assertErrorsWithCodes([ParserErrorCode.FINAL_AND_VAR]); |
| 1273 } | 1435 } |
| 1274 | 1436 |
| 1275 void test_finalClass() { | 1437 void test_finalClass() { |
| 1276 ParserTestCase.parseCompilationUnit( | 1438 ParserTestCase.parseCompilationUnit( |
| 1277 "final class C {}", [ParserErrorCode.FINAL_CLASS]); | 1439 "final class C {}", [ParserErrorCode.FINAL_CLASS]); |
| 1278 } | 1440 } |
| 1279 | 1441 |
| 1280 void test_finalConstructor() { | 1442 void test_finalConstructor() { |
| 1281 parse3("parseClassMember", <Object>["C"], "final C() {}", | 1443 createParser('final C() {}'); |
| 1282 [ParserErrorCode.FINAL_CONSTRUCTOR]); | 1444 ClassMember member = parser.parseClassMember('C'); |
| 1445 expectNotNullIfNoErrors(member); |
| 1446 listener.assertErrorsWithCodes([ParserErrorCode.FINAL_CONSTRUCTOR]); |
| 1283 } | 1447 } |
| 1284 | 1448 |
| 1285 void test_finalEnum() { | 1449 void test_finalEnum() { |
| 1286 ParserTestCase.parseCompilationUnit( | 1450 ParserTestCase.parseCompilationUnit( |
| 1287 "final enum E {ONE}", [ParserErrorCode.FINAL_ENUM]); | 1451 "final enum E {ONE}", [ParserErrorCode.FINAL_ENUM]); |
| 1288 } | 1452 } |
| 1289 | 1453 |
| 1290 void test_finalMethod() { | 1454 void test_finalMethod() { |
| 1291 parse3("parseClassMember", <Object>["C"], "final int m() {}", | 1455 createParser('final int m() {}'); |
| 1292 [ParserErrorCode.FINAL_METHOD]); | 1456 ClassMember member = parser.parseClassMember('C'); |
| 1457 expectNotNullIfNoErrors(member); |
| 1458 listener.assertErrorsWithCodes([ParserErrorCode.FINAL_METHOD]); |
| 1293 } | 1459 } |
| 1294 | 1460 |
| 1295 void test_finalTypedef() { | 1461 void test_finalTypedef() { |
| 1296 ParserTestCase.parseCompilationUnit( | 1462 ParserTestCase.parseCompilationUnit( |
| 1297 "final typedef F();", [ParserErrorCode.FINAL_TYPEDEF]); | 1463 "final typedef F();", [ParserErrorCode.FINAL_TYPEDEF]); |
| 1298 } | 1464 } |
| 1299 | 1465 |
| 1300 void test_functionTypedParameter_const() { | 1466 void test_functionTypedParameter_const() { |
| 1301 ParserTestCase.parseCompilationUnit( | 1467 ParserTestCase.parseCompilationUnit( |
| 1302 "void f(const x()) {}", [ParserErrorCode.FUNCTION_TYPED_PARAMETER_VAR]); | 1468 "void f(const x()) {}", [ParserErrorCode.FUNCTION_TYPED_PARAMETER_VAR]); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1327 ParserTestCase | 1493 ParserTestCase |
| 1328 .parseStatement("get x => _x;", [ParserErrorCode.GETTER_IN_FUNCTION]); | 1494 .parseStatement("get x => _x;", [ParserErrorCode.GETTER_IN_FUNCTION]); |
| 1329 } | 1495 } |
| 1330 | 1496 |
| 1331 void test_getterInFunction_expression_returnType() { | 1497 void test_getterInFunction_expression_returnType() { |
| 1332 ParserTestCase.parseStatement( | 1498 ParserTestCase.parseStatement( |
| 1333 "int get x => _x;", [ParserErrorCode.GETTER_IN_FUNCTION]); | 1499 "int get x => _x;", [ParserErrorCode.GETTER_IN_FUNCTION]); |
| 1334 } | 1500 } |
| 1335 | 1501 |
| 1336 void test_getterWithParameters() { | 1502 void test_getterWithParameters() { |
| 1337 parse3("parseClassMember", <Object>["C"], "int get x() {}", | 1503 createParser('int get x() {}'); |
| 1338 [ParserErrorCode.GETTER_WITH_PARAMETERS]); | 1504 ClassMember member = parser.parseClassMember('C'); |
| 1505 expectNotNullIfNoErrors(member); |
| 1506 listener.assertErrorsWithCodes([ParserErrorCode.GETTER_WITH_PARAMETERS]); |
| 1339 } | 1507 } |
| 1340 | 1508 |
| 1341 void test_illegalAssignmentToNonAssignable_postfix_minusMinus_literal() { | 1509 void test_illegalAssignmentToNonAssignable_postfix_minusMinus_literal() { |
| 1342 parseExpression( | 1510 parseExpression( |
| 1343 "0--", [ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE]); | 1511 "0--", [ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE]); |
| 1344 } | 1512 } |
| 1345 | 1513 |
| 1346 void test_illegalAssignmentToNonAssignable_postfix_plusPlus_literal() { | 1514 void test_illegalAssignmentToNonAssignable_postfix_plusPlus_literal() { |
| 1347 parseExpression( | 1515 parseExpression( |
| 1348 "0++", [ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE]); | 1516 "0++", [ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE]); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1380 "class A extends B implements C with D {}", | 1548 "class A extends B implements C with D {}", |
| 1381 [ParserErrorCode.IMPLEMENTS_BEFORE_WITH]); | 1549 [ParserErrorCode.IMPLEMENTS_BEFORE_WITH]); |
| 1382 } | 1550 } |
| 1383 | 1551 |
| 1384 void test_importDirectiveAfterPartDirective() { | 1552 void test_importDirectiveAfterPartDirective() { |
| 1385 ParserTestCase.parseCompilationUnit("part 'a.dart'; import 'b.dart';", | 1553 ParserTestCase.parseCompilationUnit("part 'a.dart'; import 'b.dart';", |
| 1386 [ParserErrorCode.IMPORT_DIRECTIVE_AFTER_PART_DIRECTIVE]); | 1554 [ParserErrorCode.IMPORT_DIRECTIVE_AFTER_PART_DIRECTIVE]); |
| 1387 } | 1555 } |
| 1388 | 1556 |
| 1389 void test_initializedVariableInForEach() { | 1557 void test_initializedVariableInForEach() { |
| 1390 parse4("parseForStatement", "for (int a = 0 in foo) {}", | 1558 createParser('for (int a = 0 in foo) {}'); |
| 1559 Statement statement = parser.parseForStatement(); |
| 1560 expectNotNullIfNoErrors(statement); |
| 1561 listener.assertErrorsWithCodes( |
| 1391 [ParserErrorCode.INITIALIZED_VARIABLE_IN_FOR_EACH]); | 1562 [ParserErrorCode.INITIALIZED_VARIABLE_IN_FOR_EACH]); |
| 1392 } | 1563 } |
| 1393 | 1564 |
| 1394 void test_invalidAwaitInFor() { | 1565 void test_invalidAwaitInFor() { |
| 1395 parse4("parseForStatement", "await for (; ;) {}", | 1566 createParser('await for (; ;) {}'); |
| 1396 [ParserErrorCode.INVALID_AWAIT_IN_FOR]); | 1567 Statement statement = parser.parseForStatement(); |
| 1568 expectNotNullIfNoErrors(statement); |
| 1569 listener.assertErrorsWithCodes([ParserErrorCode.INVALID_AWAIT_IN_FOR]); |
| 1397 } | 1570 } |
| 1398 | 1571 |
| 1399 void test_invalidCodePoint() { | 1572 void test_invalidCodePoint() { |
| 1400 parse4("parseStringLiteral", "'\\uD900'", | 1573 createParser("'\\uD900'"); |
| 1401 [ParserErrorCode.INVALID_CODE_POINT]); | 1574 StringLiteral literal = parser.parseStringLiteral(); |
| 1575 expectNotNullIfNoErrors(literal); |
| 1576 listener.assertErrorsWithCodes([ParserErrorCode.INVALID_CODE_POINT]); |
| 1402 } | 1577 } |
| 1403 | 1578 |
| 1404 void test_invalidHexEscape_invalidDigit() { | 1579 void test_invalidHexEscape_invalidDigit() { |
| 1405 parse4( | 1580 createParser("'\\x0 a'"); |
| 1406 "parseStringLiteral", "'\\x0 a'", [ParserErrorCode.INVALID_HEX_ESCAPE]); | 1581 StringLiteral literal = parser.parseStringLiteral(); |
| 1582 expectNotNullIfNoErrors(literal); |
| 1583 listener.assertErrorsWithCodes([ParserErrorCode.INVALID_HEX_ESCAPE]); |
| 1407 } | 1584 } |
| 1408 | 1585 |
| 1409 void test_invalidHexEscape_tooFewDigits() { | 1586 void test_invalidHexEscape_tooFewDigits() { |
| 1410 parse4( | 1587 createParser("'\\x0'"); |
| 1411 "parseStringLiteral", "'\\x0'", [ParserErrorCode.INVALID_HEX_ESCAPE]); | 1588 StringLiteral literal = parser.parseStringLiteral(); |
| 1589 expectNotNullIfNoErrors(literal); |
| 1590 listener.assertErrorsWithCodes([ParserErrorCode.INVALID_HEX_ESCAPE]); |
| 1412 } | 1591 } |
| 1413 | 1592 |
| 1414 void test_invalidInterpolationIdentifier_startWithDigit() { | 1593 void test_invalidInterpolationIdentifier_startWithDigit() { |
| 1415 parse4("parseStringLiteral", "'\$1'", [ParserErrorCode.MISSING_IDENTIFIER]); | 1594 createParser("'\$1'"); |
| 1595 StringLiteral literal = parser.parseStringLiteral(); |
| 1596 expectNotNullIfNoErrors(literal); |
| 1597 listener.assertErrorsWithCodes([ParserErrorCode.MISSING_IDENTIFIER]); |
| 1416 } | 1598 } |
| 1417 | 1599 |
| 1418 void test_invalidLiteralInConfiguration() { | 1600 void test_invalidLiteralInConfiguration() { |
| 1419 parse4("parseConfiguration", "if (a == 'x \$y z') 'a.dart'", | 1601 createParser("if (a == 'x \$y z') 'a.dart'"); |
| 1602 Configuration configuration = parser.parseConfiguration(); |
| 1603 expectNotNullIfNoErrors(configuration); |
| 1604 listener.assertErrorsWithCodes( |
| 1420 [ParserErrorCode.INVALID_LITERAL_IN_CONFIGURATION]); | 1605 [ParserErrorCode.INVALID_LITERAL_IN_CONFIGURATION]); |
| 1421 } | 1606 } |
| 1422 | 1607 |
| 1423 void test_invalidOperator() { | 1608 void test_invalidOperator() { |
| 1424 parse3("parseClassMember", <Object>["C"], "void operator ===(x) {}", | 1609 createParser('void operator ===(x) {}'); |
| 1425 [ParserErrorCode.INVALID_OPERATOR]); | 1610 ClassMember member = parser.parseClassMember('C'); |
| 1611 expectNotNullIfNoErrors(member); |
| 1612 listener.assertErrorsWithCodes([ParserErrorCode.INVALID_OPERATOR]); |
| 1426 } | 1613 } |
| 1427 | 1614 |
| 1428 void test_invalidOperatorAfterSuper_assignableExpression() { | 1615 void test_invalidOperatorAfterSuper_assignableExpression() { |
| 1429 parse3('parseAssignableExpression', <Object>[false], 'super?.v', | 1616 createParser('super?.v'); |
| 1430 [ParserErrorCode.INVALID_OPERATOR_FOR_SUPER]); | 1617 Expression expression = parser.parseAssignableExpression(false); |
| 1618 expectNotNullIfNoErrors(expression); |
| 1619 listener |
| 1620 .assertErrorsWithCodes([ParserErrorCode.INVALID_OPERATOR_FOR_SUPER]); |
| 1431 } | 1621 } |
| 1432 | 1622 |
| 1433 void test_invalidOperatorAfterSuper_primaryExpression() { | 1623 void test_invalidOperatorAfterSuper_primaryExpression() { |
| 1434 parse4('parsePrimaryExpression', 'super?.v', | 1624 createParser('super?.v'); |
| 1435 [ParserErrorCode.INVALID_OPERATOR_FOR_SUPER]); | 1625 Expression expression = parser.parsePrimaryExpression(); |
| 1626 expectNotNullIfNoErrors(expression); |
| 1627 listener |
| 1628 .assertErrorsWithCodes([ParserErrorCode.INVALID_OPERATOR_FOR_SUPER]); |
| 1436 } | 1629 } |
| 1437 | 1630 |
| 1438 void test_invalidOperatorForSuper() { | 1631 void test_invalidOperatorForSuper() { |
| 1439 parse4("parseUnaryExpression", "++super", | 1632 createParser('++super'); |
| 1440 [ParserErrorCode.INVALID_OPERATOR_FOR_SUPER]); | 1633 Expression expression = parser.parseUnaryExpression(); |
| 1634 expectNotNullIfNoErrors(expression); |
| 1635 listener |
| 1636 .assertErrorsWithCodes([ParserErrorCode.INVALID_OPERATOR_FOR_SUPER]); |
| 1441 } | 1637 } |
| 1442 | 1638 |
| 1443 void test_invalidStarAfterAsync() { | 1639 void test_invalidStarAfterAsync() { |
| 1444 parse3("parseFunctionBody", <Object>[false, null, false], "async* => 0;", | 1640 createParser('async* => 0;'); |
| 1445 [ParserErrorCode.INVALID_STAR_AFTER_ASYNC]); | 1641 FunctionBody functionBody = parser.parseFunctionBody(false, null, false); |
| 1642 expectNotNullIfNoErrors(functionBody); |
| 1643 listener.assertErrorsWithCodes([ParserErrorCode.INVALID_STAR_AFTER_ASYNC]); |
| 1446 } | 1644 } |
| 1447 | 1645 |
| 1448 void test_invalidSync() { | 1646 void test_invalidSync() { |
| 1449 parse3("parseFunctionBody", <Object>[false, null, false], "sync* => 0;", | 1647 createParser('sync* => 0;'); |
| 1450 [ParserErrorCode.INVALID_SYNC]); | 1648 FunctionBody functionBody = parser.parseFunctionBody(false, null, false); |
| 1649 expectNotNullIfNoErrors(functionBody); |
| 1650 listener.assertErrorsWithCodes([ParserErrorCode.INVALID_SYNC]); |
| 1451 } | 1651 } |
| 1452 | 1652 |
| 1453 void test_invalidUnicodeEscape_incomplete_noDigits() { | 1653 void test_invalidUnicodeEscape_incomplete_noDigits() { |
| 1454 parse4("parseStringLiteral", "'\\u{'", | 1654 createParser("'\\u{'"); |
| 1455 [ParserErrorCode.INVALID_UNICODE_ESCAPE]); | 1655 Expression expression = parser.parseStringLiteral(); |
| 1656 expectNotNullIfNoErrors(expression); |
| 1657 listener.assertErrorsWithCodes([ParserErrorCode.INVALID_UNICODE_ESCAPE]); |
| 1456 } | 1658 } |
| 1457 | 1659 |
| 1458 void test_invalidUnicodeEscape_incomplete_someDigits() { | 1660 void test_invalidUnicodeEscape_incomplete_someDigits() { |
| 1459 parse4("parseStringLiteral", "'\\u{0A'", | 1661 createParser("'\\u{0A'"); |
| 1460 [ParserErrorCode.INVALID_UNICODE_ESCAPE]); | 1662 Expression expression = parser.parseStringLiteral(); |
| 1663 expectNotNullIfNoErrors(expression); |
| 1664 listener.assertErrorsWithCodes([ParserErrorCode.INVALID_UNICODE_ESCAPE]); |
| 1461 } | 1665 } |
| 1462 | 1666 |
| 1463 void test_invalidUnicodeEscape_invalidDigit() { | 1667 void test_invalidUnicodeEscape_invalidDigit() { |
| 1464 parse4("parseStringLiteral", "'\\u0 a'", | 1668 createParser("'\\u0 a'"); |
| 1465 [ParserErrorCode.INVALID_UNICODE_ESCAPE]); | 1669 Expression expression = parser.parseStringLiteral(); |
| 1670 expectNotNullIfNoErrors(expression); |
| 1671 listener.assertErrorsWithCodes([ParserErrorCode.INVALID_UNICODE_ESCAPE]); |
| 1466 } | 1672 } |
| 1467 | 1673 |
| 1468 void test_invalidUnicodeEscape_tooFewDigits_fixed() { | 1674 void test_invalidUnicodeEscape_tooFewDigits_fixed() { |
| 1469 parse4("parseStringLiteral", "'\\u04'", | 1675 createParser("'\\u04'"); |
| 1470 [ParserErrorCode.INVALID_UNICODE_ESCAPE]); | 1676 Expression expression = parser.parseStringLiteral(); |
| 1677 expectNotNullIfNoErrors(expression); |
| 1678 listener.assertErrorsWithCodes([ParserErrorCode.INVALID_UNICODE_ESCAPE]); |
| 1471 } | 1679 } |
| 1472 | 1680 |
| 1473 void test_invalidUnicodeEscape_tooFewDigits_variable() { | 1681 void test_invalidUnicodeEscape_tooFewDigits_variable() { |
| 1474 parse4("parseStringLiteral", "'\\u{}'", | 1682 createParser("'\\u{}'"); |
| 1475 [ParserErrorCode.INVALID_UNICODE_ESCAPE]); | 1683 Expression expression = parser.parseStringLiteral(); |
| 1684 expectNotNullIfNoErrors(expression); |
| 1685 listener.assertErrorsWithCodes([ParserErrorCode.INVALID_UNICODE_ESCAPE]); |
| 1476 } | 1686 } |
| 1477 | 1687 |
| 1478 void test_invalidUnicodeEscape_tooManyDigits_variable() { | 1688 void test_invalidUnicodeEscape_tooManyDigits_variable() { |
| 1479 parse4("parseStringLiteral", "'\\u{12345678}'", [ | 1689 createParser("'\\u{12345678}'"); |
| 1690 Expression expression = parser.parseStringLiteral(); |
| 1691 expectNotNullIfNoErrors(expression); |
| 1692 listener.assertErrorsWithCodes([ |
| 1480 ParserErrorCode.INVALID_UNICODE_ESCAPE, | 1693 ParserErrorCode.INVALID_UNICODE_ESCAPE, |
| 1481 ParserErrorCode.INVALID_CODE_POINT | 1694 ParserErrorCode.INVALID_CODE_POINT |
| 1482 ]); | 1695 ]); |
| 1483 } | 1696 } |
| 1484 | 1697 |
| 1485 void test_libraryDirectiveNotFirst() { | 1698 void test_libraryDirectiveNotFirst() { |
| 1486 ParserTestCase.parseCompilationUnit("import 'x.dart'; library l;", | 1699 ParserTestCase.parseCompilationUnit("import 'x.dart'; library l;", |
| 1487 [ParserErrorCode.LIBRARY_DIRECTIVE_NOT_FIRST]); | 1700 [ParserErrorCode.LIBRARY_DIRECTIVE_NOT_FIRST]); |
| 1488 } | 1701 } |
| 1489 | 1702 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1509 [ParserErrorCode.LOCAL_FUNCTION_DECLARATION_MODIFIER]); | 1722 [ParserErrorCode.LOCAL_FUNCTION_DECLARATION_MODIFIER]); |
| 1510 } | 1723 } |
| 1511 | 1724 |
| 1512 void test_localFunctionDeclarationModifier_static() { | 1725 void test_localFunctionDeclarationModifier_static() { |
| 1513 ParserTestCase.parseStatement( | 1726 ParserTestCase.parseStatement( |
| 1514 "static f() {}", [ParserErrorCode.LOCAL_FUNCTION_DECLARATION_MODIFIER]); | 1727 "static f() {}", [ParserErrorCode.LOCAL_FUNCTION_DECLARATION_MODIFIER]); |
| 1515 } | 1728 } |
| 1516 | 1729 |
| 1517 void test_method_invalidTypeParameterComments() { | 1730 void test_method_invalidTypeParameterComments() { |
| 1518 enableGenericMethodComments = true; | 1731 enableGenericMethodComments = true; |
| 1519 MethodDeclaration method = parse3( | 1732 createParser('void m/*<E, hello!>*/() {}'); |
| 1520 "parseClassMember", | 1733 ClassMember member = parser.parseClassMember('C'); |
| 1521 <Object>["C"], | 1734 expectNotNullIfNoErrors(member); |
| 1522 "void m/*<E, hello!>*/() {}", | 1735 listener.assertErrorsWithCodes([ |
| 1523 [ | 1736 ParserErrorCode.EXPECTED_TOKEN /*>*/, |
| 1524 ParserErrorCode.EXPECTED_TOKEN /*>*/, | 1737 ParserErrorCode.MISSING_IDENTIFIER, |
| 1525 ParserErrorCode.MISSING_IDENTIFIER, | 1738 ParserErrorCode.EXPECTED_TOKEN /*(*/, |
| 1526 ParserErrorCode.EXPECTED_TOKEN /*(*/, | 1739 ParserErrorCode.EXPECTED_TOKEN /*)*/, |
| 1527 ParserErrorCode.EXPECTED_TOKEN /*)*/, | 1740 ParserErrorCode.MISSING_FUNCTION_BODY |
| 1528 ParserErrorCode.MISSING_FUNCTION_BODY | 1741 ]); |
| 1529 ]); | 1742 expect(member, new isInstanceOf<MethodDeclaration>()); |
| 1743 MethodDeclaration method = member; |
| 1530 expect(method.typeParameters.toString(), '<E, hello>', | 1744 expect(method.typeParameters.toString(), '<E, hello>', |
| 1531 reason: 'parser recovers what it can'); | 1745 reason: 'parser recovers what it can'); |
| 1532 } | 1746 } |
| 1533 | 1747 |
| 1534 void test_method_invalidTypeParameterExtends() { | 1748 void test_method_invalidTypeParameterExtends() { |
| 1535 // Regression test for https://github.com/dart-lang/sdk/issues/25739. | 1749 // Regression test for https://github.com/dart-lang/sdk/issues/25739. |
| 1536 | 1750 |
| 1537 // TODO(jmesserly): ideally we'd be better at parser recovery here. | 1751 // TODO(jmesserly): ideally we'd be better at parser recovery here. |
| 1538 enableGenericMethods = true; | 1752 enableGenericMethods = true; |
| 1539 MethodDeclaration method = parse3( | 1753 createParser('f<E>(E extends num p);'); |
| 1540 "parseClassMember", | 1754 ClassMember member = parser.parseClassMember('C'); |
| 1541 <Object>["C"], | 1755 expectNotNullIfNoErrors(member); |
| 1542 "f<E>(E extends num p);", | 1756 listener.assertErrorsWithCodes([ |
| 1543 [ | 1757 ParserErrorCode.MISSING_IDENTIFIER, // `extends` is a keyword |
| 1544 ParserErrorCode.MISSING_IDENTIFIER, // `extends` is a keyword | 1758 ParserErrorCode.EXPECTED_TOKEN, // comma |
| 1545 ParserErrorCode.EXPECTED_TOKEN, // comma | 1759 ParserErrorCode.EXPECTED_TOKEN, // close paren |
| 1546 ParserErrorCode.EXPECTED_TOKEN, // close paren | 1760 ParserErrorCode.MISSING_FUNCTION_BODY |
| 1547 ParserErrorCode.MISSING_FUNCTION_BODY | 1761 ]); |
| 1548 ]); | 1762 expect(member, new isInstanceOf<MethodDeclaration>()); |
| 1763 MethodDeclaration method = member; |
| 1549 expect(method.parameters.toString(), '(E, extends)', | 1764 expect(method.parameters.toString(), '(E, extends)', |
| 1550 reason: 'parser recovers what it can'); | 1765 reason: 'parser recovers what it can'); |
| 1551 } | 1766 } |
| 1552 | 1767 |
| 1553 void test_method_invalidTypeParameterExtendsComment() { | 1768 void test_method_invalidTypeParameterExtendsComment() { |
| 1554 // Regression test for https://github.com/dart-lang/sdk/issues/25739. | 1769 // Regression test for https://github.com/dart-lang/sdk/issues/25739. |
| 1555 | 1770 |
| 1556 // TODO(jmesserly): ideally we'd be better at parser recovery here. | 1771 // TODO(jmesserly): ideally we'd be better at parser recovery here. |
| 1557 // Also, this behavior is slightly different from how we would parse a | 1772 // Also, this behavior is slightly different from how we would parse a |
| 1558 // normal generic method, because we "discover" the comment at a different | 1773 // normal generic method, because we "discover" the comment at a different |
| 1559 // point in the parser. This has a slight effect on the AST that results | 1774 // point in the parser. This has a slight effect on the AST that results |
| 1560 // from error recovery. | 1775 // from error recovery. |
| 1561 enableGenericMethodComments = true; | 1776 enableGenericMethodComments = true; |
| 1562 MethodDeclaration method = parse3( | 1777 createParser('f/*<E>*/(dynamic/*=E extends num*/p);'); |
| 1563 "parseClassMember", | 1778 ClassMember member = parser.parseClassMember('C'); |
| 1564 <Object>["C"], | 1779 expectNotNullIfNoErrors(member); |
| 1565 "f/*<E>*/(dynamic/*=E extends num*/p);", | 1780 listener.assertErrorsWithCodes([ |
| 1566 [ | 1781 ParserErrorCode.MISSING_IDENTIFIER, // `extends` is a keyword |
| 1567 ParserErrorCode.MISSING_IDENTIFIER, // `extends` is a keyword | 1782 ParserErrorCode.EXPECTED_TOKEN, // comma |
| 1568 ParserErrorCode.EXPECTED_TOKEN, // comma | 1783 ParserErrorCode.MISSING_IDENTIFIER, // `extends` is a keyword |
| 1569 ParserErrorCode.MISSING_IDENTIFIER, // `extends` is a keyword | 1784 ParserErrorCode.EXPECTED_TOKEN, // close paren |
| 1570 ParserErrorCode.EXPECTED_TOKEN, // close paren | 1785 ParserErrorCode.MISSING_FUNCTION_BODY |
| 1571 ParserErrorCode.MISSING_FUNCTION_BODY | 1786 ]); |
| 1572 ]); | 1787 expect(member, new isInstanceOf<MethodDeclaration>()); |
| 1788 MethodDeclaration method = member; |
| 1573 expect(method.parameters.toString(), '(E extends, extends)', | 1789 expect(method.parameters.toString(), '(E extends, extends)', |
| 1574 reason: 'parser recovers what it can'); | 1790 reason: 'parser recovers what it can'); |
| 1575 } | 1791 } |
| 1576 | 1792 |
| 1577 void test_method_invalidTypeParameters() { | 1793 void test_method_invalidTypeParameters() { |
| 1578 // TODO(jmesserly): ideally we'd be better at parser recovery here. | 1794 // TODO(jmesserly): ideally we'd be better at parser recovery here. |
| 1579 // It doesn't try to advance past the invalid token `!` to find the | 1795 // It doesn't try to advance past the invalid token `!` to find the |
| 1580 // valid `>`. If it did we'd get less cascading errors, at least for this | 1796 // valid `>`. If it did we'd get less cascading errors, at least for this |
| 1581 // particular example. | 1797 // particular example. |
| 1582 enableGenericMethods = true; | 1798 enableGenericMethods = true; |
| 1583 MethodDeclaration method = parse3( | 1799 createParser('void m<E, hello!>() {}'); |
| 1584 "parseClassMember", | 1800 ClassMember member = parser.parseClassMember('C'); |
| 1585 <Object>["C"], | 1801 expectNotNullIfNoErrors(member); |
| 1586 "void m<E, hello!>() {}", | 1802 listener.assertErrorsWithCodes([ |
| 1587 [ | 1803 ParserErrorCode.EXPECTED_TOKEN /*>*/, |
| 1588 ParserErrorCode.EXPECTED_TOKEN /*>*/, | 1804 ParserErrorCode.MISSING_IDENTIFIER, |
| 1589 ParserErrorCode.MISSING_IDENTIFIER, | 1805 ParserErrorCode.EXPECTED_TOKEN /*(*/, |
| 1590 ParserErrorCode.EXPECTED_TOKEN /*(*/, | 1806 ParserErrorCode.EXPECTED_TOKEN /*)*/, |
| 1591 ParserErrorCode.EXPECTED_TOKEN /*)*/, | 1807 ParserErrorCode.MISSING_FUNCTION_BODY |
| 1592 ParserErrorCode.MISSING_FUNCTION_BODY | 1808 ]); |
| 1593 ]); | 1809 expect(member, new isInstanceOf<MethodDeclaration>()); |
| 1810 MethodDeclaration method = member; |
| 1594 expect(method.typeParameters.toString(), '<E, hello>', | 1811 expect(method.typeParameters.toString(), '<E, hello>', |
| 1595 reason: 'parser recovers what it can'); | 1812 reason: 'parser recovers what it can'); |
| 1596 } | 1813 } |
| 1597 | 1814 |
| 1598 void test_missingAssignableSelector_identifiersAssigned() { | 1815 void test_missingAssignableSelector_identifiersAssigned() { |
| 1599 parseExpression("x.y = y;"); | 1816 parseExpression("x.y = y;"); |
| 1600 } | 1817 } |
| 1601 | 1818 |
| 1602 void test_missingAssignableSelector_prefix_minusMinus_literal() { | 1819 void test_missingAssignableSelector_prefix_minusMinus_literal() { |
| 1603 parseExpression("--0", [ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR]); | 1820 parseExpression("--0", [ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR]); |
| 1604 } | 1821 } |
| 1605 | 1822 |
| 1606 void test_missingAssignableSelector_prefix_plusPlus_literal() { | 1823 void test_missingAssignableSelector_prefix_plusPlus_literal() { |
| 1607 parseExpression("++0", [ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR]); | 1824 parseExpression("++0", [ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR]); |
| 1608 } | 1825 } |
| 1609 | 1826 |
| 1610 void test_missingAssignableSelector_selector() { | 1827 void test_missingAssignableSelector_selector() { |
| 1611 parseExpression("x(y)(z).a++"); | 1828 parseExpression("x(y)(z).a++"); |
| 1612 } | 1829 } |
| 1613 | 1830 |
| 1614 void test_missingAssignableSelector_superPrimaryExpression() { | 1831 void test_missingAssignableSelector_superPrimaryExpression() { |
| 1615 SuperExpression expression = parse4("parsePrimaryExpression", "super", | 1832 createParser('super'); |
| 1616 [ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR]); | 1833 Expression expression = parser.parsePrimaryExpression(); |
| 1617 expect(expression.superKeyword, isNotNull); | 1834 expectNotNullIfNoErrors(expression); |
| 1835 listener |
| 1836 .assertErrorsWithCodes([ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR]); |
| 1837 expect(expression, new isInstanceOf<SuperExpression>()); |
| 1838 SuperExpression superExpression = expression; |
| 1839 expect(superExpression.superKeyword, isNotNull); |
| 1618 } | 1840 } |
| 1619 | 1841 |
| 1620 void test_missingAssignableSelector_superPropertyAccessAssigned() { | 1842 void test_missingAssignableSelector_superPropertyAccessAssigned() { |
| 1621 parseExpression("super.x = x;"); | 1843 parseExpression("super.x = x;"); |
| 1622 } | 1844 } |
| 1623 | 1845 |
| 1624 void test_missingCatchOrFinally() { | 1846 void test_missingCatchOrFinally() { |
| 1625 TryStatement statement = parse4("parseTryStatement", "try {}", | 1847 createParser('try {}'); |
| 1626 [ParserErrorCode.MISSING_CATCH_OR_FINALLY]); | 1848 TryStatement statement = parser.parseTryStatement(); |
| 1849 expectNotNullIfNoErrors(statement); |
| 1850 listener.assertErrorsWithCodes([ParserErrorCode.MISSING_CATCH_OR_FINALLY]); |
| 1627 expect(statement, isNotNull); | 1851 expect(statement, isNotNull); |
| 1628 } | 1852 } |
| 1629 | 1853 |
| 1630 void test_missingClassBody() { | 1854 void test_missingClassBody() { |
| 1631 ParserTestCase.parseCompilationUnit( | 1855 ParserTestCase.parseCompilationUnit( |
| 1632 "class A class B {}", [ParserErrorCode.MISSING_CLASS_BODY]); | 1856 "class A class B {}", [ParserErrorCode.MISSING_CLASS_BODY]); |
| 1633 } | 1857 } |
| 1634 | 1858 |
| 1635 void test_missingConstFinalVarOrType_static() { | 1859 void test_missingConstFinalVarOrType_static() { |
| 1636 ParserTestCase.parseCompilationUnit("class A { static f; }", | 1860 ParserTestCase.parseCompilationUnit("class A { static f; }", |
| 1637 [ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE]); | 1861 [ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE]); |
| 1638 } | 1862 } |
| 1639 | 1863 |
| 1640 void test_missingConstFinalVarOrType_topLevel() { | 1864 void test_missingConstFinalVarOrType_topLevel() { |
| 1641 parse3("parseFinalConstVarOrType", <Object>[false], "a;", | 1865 createParser('a;'); |
| 1866 FinalConstVarOrType result = parser.parseFinalConstVarOrType(false); |
| 1867 expectNotNullIfNoErrors(result); |
| 1868 listener.assertErrorsWithCodes( |
| 1642 [ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE]); | 1869 [ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE]); |
| 1643 } | 1870 } |
| 1644 | 1871 |
| 1645 void test_missingEnumBody() { | 1872 void test_missingEnumBody() { |
| 1646 parse3("parseEnumDeclaration", <Object>[emptyCommentAndMetadata()], | 1873 createParser('enum E;'); |
| 1647 "enum E;", [ParserErrorCode.MISSING_ENUM_BODY]); | 1874 EnumDeclaration declaration = |
| 1875 parser.parseEnumDeclaration(emptyCommentAndMetadata()); |
| 1876 expectNotNullIfNoErrors(declaration); |
| 1877 listener.assertErrorsWithCodes([ParserErrorCode.MISSING_ENUM_BODY]); |
| 1648 } | 1878 } |
| 1649 | 1879 |
| 1650 void test_missingExpressionInThrow_withCascade() { | 1880 void test_missingExpressionInThrow_withCascade() { |
| 1651 parse4("parseThrowExpression", "throw;", | 1881 createParser('throw;'); |
| 1652 [ParserErrorCode.MISSING_EXPRESSION_IN_THROW]); | 1882 ThrowExpression expression = parser.parseThrowExpression(); |
| 1883 expectNotNullIfNoErrors(expression); |
| 1884 listener |
| 1885 .assertErrorsWithCodes([ParserErrorCode.MISSING_EXPRESSION_IN_THROW]); |
| 1653 } | 1886 } |
| 1654 | 1887 |
| 1655 void test_missingExpressionInThrow_withoutCascade() { | 1888 void test_missingExpressionInThrow_withoutCascade() { |
| 1656 parse4("parseThrowExpressionWithoutCascade", "throw;", | 1889 createParser('throw;'); |
| 1657 [ParserErrorCode.MISSING_EXPRESSION_IN_THROW]); | 1890 ThrowExpression expression = parser.parseThrowExpressionWithoutCascade(); |
| 1891 expectNotNullIfNoErrors(expression); |
| 1892 listener |
| 1893 .assertErrorsWithCodes([ParserErrorCode.MISSING_EXPRESSION_IN_THROW]); |
| 1658 } | 1894 } |
| 1659 | 1895 |
| 1660 void test_missingFunctionBody_emptyNotAllowed() { | 1896 void test_missingFunctionBody_emptyNotAllowed() { |
| 1661 parse3( | 1897 createParser(';'); |
| 1662 "parseFunctionBody", | 1898 FunctionBody functionBody = parser.parseFunctionBody( |
| 1663 <Object>[false, ParserErrorCode.MISSING_FUNCTION_BODY, false], | 1899 false, ParserErrorCode.MISSING_FUNCTION_BODY, false); |
| 1664 ";", | 1900 expectNotNullIfNoErrors(functionBody); |
| 1665 [ParserErrorCode.MISSING_FUNCTION_BODY]); | 1901 listener.assertErrorsWithCodes([ParserErrorCode.MISSING_FUNCTION_BODY]); |
| 1666 } | 1902 } |
| 1667 | 1903 |
| 1668 void test_missingFunctionBody_invalid() { | 1904 void test_missingFunctionBody_invalid() { |
| 1669 parse3( | 1905 createParser('return 0;'); |
| 1670 "parseFunctionBody", | 1906 FunctionBody functionBody = parser.parseFunctionBody( |
| 1671 <Object>[false, ParserErrorCode.MISSING_FUNCTION_BODY, false], | 1907 false, ParserErrorCode.MISSING_FUNCTION_BODY, false); |
| 1672 "return 0;", | 1908 expectNotNullIfNoErrors(functionBody); |
| 1673 [ParserErrorCode.MISSING_FUNCTION_BODY]); | 1909 listener.assertErrorsWithCodes([ParserErrorCode.MISSING_FUNCTION_BODY]); |
| 1674 } | 1910 } |
| 1675 | 1911 |
| 1676 void test_missingFunctionParameters_local_void_block() { | 1912 void test_missingFunctionParameters_local_void_block() { |
| 1677 ParserTestCase.parseStatement( | 1913 ParserTestCase.parseStatement( |
| 1678 "void f { return x;}", [ParserErrorCode.MISSING_FUNCTION_PARAMETERS]); | 1914 "void f { return x;}", [ParserErrorCode.MISSING_FUNCTION_PARAMETERS]); |
| 1679 } | 1915 } |
| 1680 | 1916 |
| 1681 void test_missingFunctionParameters_local_void_expression() { | 1917 void test_missingFunctionParameters_local_void_expression() { |
| 1682 ParserTestCase.parseStatement( | 1918 ParserTestCase.parseStatement( |
| 1683 "void f => x;", [ParserErrorCode.MISSING_FUNCTION_PARAMETERS]); | 1919 "void f => x;", [ParserErrorCode.MISSING_FUNCTION_PARAMETERS]); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1701 } | 1937 } |
| 1702 | 1938 |
| 1703 void test_missingFunctionParameters_topLevel_void_expression() { | 1939 void test_missingFunctionParameters_topLevel_void_expression() { |
| 1704 CompilationUnit unit = ParserTestCase.parseCompilationUnit( | 1940 CompilationUnit unit = ParserTestCase.parseCompilationUnit( |
| 1705 "void f => x;", [ParserErrorCode.MISSING_FUNCTION_PARAMETERS]); | 1941 "void f => x;", [ParserErrorCode.MISSING_FUNCTION_PARAMETERS]); |
| 1706 FunctionDeclaration funct = unit.declarations[0]; | 1942 FunctionDeclaration funct = unit.declarations[0]; |
| 1707 expect(funct.functionExpression.parameters, hasLength(0)); | 1943 expect(funct.functionExpression.parameters, hasLength(0)); |
| 1708 } | 1944 } |
| 1709 | 1945 |
| 1710 void test_missingIdentifier_afterOperator() { | 1946 void test_missingIdentifier_afterOperator() { |
| 1711 parse4("parseMultiplicativeExpression", "1 *", | 1947 createParser('1 *'); |
| 1712 [ParserErrorCode.MISSING_IDENTIFIER]); | 1948 BinaryExpression expression = parser.parseMultiplicativeExpression(); |
| 1949 expectNotNullIfNoErrors(expression); |
| 1950 listener.assertErrorsWithCodes([ParserErrorCode.MISSING_IDENTIFIER]); |
| 1713 } | 1951 } |
| 1714 | 1952 |
| 1715 void test_missingIdentifier_beforeClosingCurly() { | 1953 void test_missingIdentifier_beforeClosingCurly() { |
| 1716 parse3("parseClassMember", <Object>["C"], "int}", | 1954 createParser('int}'); |
| 1955 ClassMember member = parser.parseClassMember('C'); |
| 1956 expectNotNullIfNoErrors(member); |
| 1957 listener.assertErrorsWithCodes( |
| 1717 [ParserErrorCode.MISSING_IDENTIFIER, ParserErrorCode.EXPECTED_TOKEN]); | 1958 [ParserErrorCode.MISSING_IDENTIFIER, ParserErrorCode.EXPECTED_TOKEN]); |
| 1718 } | 1959 } |
| 1719 | 1960 |
| 1720 void test_missingIdentifier_functionDeclaration_returnTypeWithoutName() { | 1961 void test_missingIdentifier_functionDeclaration_returnTypeWithoutName() { |
| 1721 parse4("parseFunctionDeclarationStatement", "A<T> () {}", | 1962 createParser('A<T> () {}'); |
| 1722 [ParserErrorCode.MISSING_IDENTIFIER]); | 1963 Statement statement = parser.parseFunctionDeclarationStatement(); |
| 1964 expectNotNullIfNoErrors(statement); |
| 1965 listener.assertErrorsWithCodes([ParserErrorCode.MISSING_IDENTIFIER]); |
| 1723 } | 1966 } |
| 1724 | 1967 |
| 1725 void test_missingIdentifier_inEnum() { | 1968 void test_missingIdentifier_inEnum() { |
| 1726 parse3("parseEnumDeclaration", <Object>[emptyCommentAndMetadata()], | 1969 createParser('enum E {, TWO}'); |
| 1727 "enum E {, TWO}", [ParserErrorCode.MISSING_IDENTIFIER]); | 1970 EnumDeclaration declaration = |
| 1971 parser.parseEnumDeclaration(emptyCommentAndMetadata()); |
| 1972 expectNotNullIfNoErrors(declaration); |
| 1973 listener.assertErrorsWithCodes([ParserErrorCode.MISSING_IDENTIFIER]); |
| 1728 } | 1974 } |
| 1729 | 1975 |
| 1730 void test_missingIdentifier_inSymbol_afterPeriod() { | 1976 void test_missingIdentifier_inSymbol_afterPeriod() { |
| 1731 parse4("parseSymbolLiteral", "#a.", [ParserErrorCode.MISSING_IDENTIFIER]); | 1977 createParser('#a.'); |
| 1978 SymbolLiteral literal = parser.parseSymbolLiteral(); |
| 1979 expectNotNullIfNoErrors(literal); |
| 1980 listener.assertErrorsWithCodes([ParserErrorCode.MISSING_IDENTIFIER]); |
| 1732 } | 1981 } |
| 1733 | 1982 |
| 1734 void test_missingIdentifier_inSymbol_first() { | 1983 void test_missingIdentifier_inSymbol_first() { |
| 1735 parse4("parseSymbolLiteral", "#", [ParserErrorCode.MISSING_IDENTIFIER]); | 1984 createParser('#'); |
| 1985 SymbolLiteral literal = parser.parseSymbolLiteral(); |
| 1986 expectNotNullIfNoErrors(literal); |
| 1987 listener.assertErrorsWithCodes([ParserErrorCode.MISSING_IDENTIFIER]); |
| 1736 } | 1988 } |
| 1737 | 1989 |
| 1738 void test_missingIdentifier_number() { | 1990 void test_missingIdentifier_number() { |
| 1739 SimpleIdentifier expression = parse4( | 1991 createParser('1'); |
| 1740 "parseSimpleIdentifier", "1", [ParserErrorCode.MISSING_IDENTIFIER]); | 1992 SimpleIdentifier expression = parser.parseSimpleIdentifier(); |
| 1993 expectNotNullIfNoErrors(expression); |
| 1994 listener.assertErrorsWithCodes([ParserErrorCode.MISSING_IDENTIFIER]); |
| 1741 expect(expression.isSynthetic, isTrue); | 1995 expect(expression.isSynthetic, isTrue); |
| 1742 } | 1996 } |
| 1743 | 1997 |
| 1744 void test_missingIdentifierForParameterGroup() { | 1998 void test_missingIdentifierForParameterGroup() { |
| 1745 parse4("parseFormalParameterList", "(,)", | 1999 createParser('(,)'); |
| 1746 [ParserErrorCode.MISSING_IDENTIFIER]); | 2000 FormalParameterList list = parser.parseFormalParameterList(); |
| 2001 expectNotNullIfNoErrors(list); |
| 2002 listener.assertErrorsWithCodes([ParserErrorCode.MISSING_IDENTIFIER]); |
| 1747 } | 2003 } |
| 1748 | 2004 |
| 1749 void test_missingKeywordOperator() { | 2005 void test_missingKeywordOperator() { |
| 1750 parse3("parseOperator", <Object>[emptyCommentAndMetadata(), null, null], | 2006 createParser('+(x) {}'); |
| 1751 "+(x) {}", [ParserErrorCode.MISSING_KEYWORD_OPERATOR]); | 2007 MethodDeclaration method = |
| 2008 parser.parseOperator(emptyCommentAndMetadata(), null, null); |
| 2009 expectNotNullIfNoErrors(method); |
| 2010 listener.assertErrorsWithCodes([ParserErrorCode.MISSING_KEYWORD_OPERATOR]); |
| 1752 } | 2011 } |
| 1753 | 2012 |
| 1754 void test_missingKeywordOperator_parseClassMember() { | 2013 void test_missingKeywordOperator_parseClassMember() { |
| 1755 parse3("parseClassMember", <Object>["C"], "+() {}", | 2014 createParser('+() {}'); |
| 1756 [ParserErrorCode.MISSING_KEYWORD_OPERATOR]); | 2015 ClassMember member = parser.parseClassMember('C'); |
| 2016 expectNotNullIfNoErrors(member); |
| 2017 listener.assertErrorsWithCodes([ParserErrorCode.MISSING_KEYWORD_OPERATOR]); |
| 1757 } | 2018 } |
| 1758 | 2019 |
| 1759 void test_missingKeywordOperator_parseClassMember_afterTypeName() { | 2020 void test_missingKeywordOperator_parseClassMember_afterTypeName() { |
| 1760 parse3("parseClassMember", <Object>["C"], "int +() {}", | 2021 createParser('int +() {}'); |
| 1761 [ParserErrorCode.MISSING_KEYWORD_OPERATOR]); | 2022 ClassMember member = parser.parseClassMember('C'); |
| 2023 expectNotNullIfNoErrors(member); |
| 2024 listener.assertErrorsWithCodes([ParserErrorCode.MISSING_KEYWORD_OPERATOR]); |
| 1762 } | 2025 } |
| 1763 | 2026 |
| 1764 void test_missingKeywordOperator_parseClassMember_afterVoid() { | 2027 void test_missingKeywordOperator_parseClassMember_afterVoid() { |
| 1765 parse3("parseClassMember", <Object>["C"], "void +() {}", | 2028 createParser('void +() {}'); |
| 1766 [ParserErrorCode.MISSING_KEYWORD_OPERATOR]); | 2029 ClassMember member = parser.parseClassMember('C'); |
| 2030 expectNotNullIfNoErrors(member); |
| 2031 listener.assertErrorsWithCodes([ParserErrorCode.MISSING_KEYWORD_OPERATOR]); |
| 1767 } | 2032 } |
| 1768 | 2033 |
| 1769 void test_missingMethodParameters_void_block() { | 2034 void test_missingMethodParameters_void_block() { |
| 1770 MethodDeclaration method = parse3("parseClassMember", <Object>["C"], | 2035 createParser('void m {} }'); |
| 1771 "void m {} }", [ParserErrorCode.MISSING_METHOD_PARAMETERS]); | 2036 ClassMember member = parser.parseClassMember('C'); |
| 2037 expectNotNullIfNoErrors(member); |
| 2038 listener.assertErrorsWithCodes([ParserErrorCode.MISSING_METHOD_PARAMETERS]); |
| 2039 expect(member, new isInstanceOf<MethodDeclaration>()); |
| 2040 MethodDeclaration method = member; |
| 1772 expect(method.parameters, hasLength(0)); | 2041 expect(method.parameters, hasLength(0)); |
| 1773 } | 2042 } |
| 1774 | 2043 |
| 1775 void test_missingMethodParameters_void_expression() { | 2044 void test_missingMethodParameters_void_expression() { |
| 1776 parse3("parseClassMember", <Object>["C"], "void m => null; }", | 2045 createParser('void m => null; }'); |
| 1777 [ParserErrorCode.MISSING_METHOD_PARAMETERS]); | 2046 ClassMember member = parser.parseClassMember('C'); |
| 2047 expectNotNullIfNoErrors(member); |
| 2048 listener.assertErrorsWithCodes([ParserErrorCode.MISSING_METHOD_PARAMETERS]); |
| 1778 } | 2049 } |
| 1779 | 2050 |
| 1780 void test_missingNameInLibraryDirective() { | 2051 void test_missingNameInLibraryDirective() { |
| 1781 CompilationUnit unit = ParserTestCase.parseCompilationUnit( | 2052 CompilationUnit unit = ParserTestCase.parseCompilationUnit( |
| 1782 "library;", [ParserErrorCode.MISSING_NAME_IN_LIBRARY_DIRECTIVE]); | 2053 "library;", [ParserErrorCode.MISSING_NAME_IN_LIBRARY_DIRECTIVE]); |
| 1783 expect(unit, isNotNull); | 2054 expect(unit, isNotNull); |
| 1784 } | 2055 } |
| 1785 | 2056 |
| 1786 void test_missingNameInPartOfDirective() { | 2057 void test_missingNameInPartOfDirective() { |
| 1787 CompilationUnit unit = ParserTestCase.parseCompilationUnit( | 2058 CompilationUnit unit = ParserTestCase.parseCompilationUnit( |
| 1788 "part of;", [ParserErrorCode.MISSING_NAME_IN_PART_OF_DIRECTIVE]); | 2059 "part of;", [ParserErrorCode.MISSING_NAME_IN_PART_OF_DIRECTIVE]); |
| 1789 expect(unit, isNotNull); | 2060 expect(unit, isNotNull); |
| 1790 } | 2061 } |
| 1791 | 2062 |
| 1792 void test_missingPrefixInDeferredImport() { | 2063 void test_missingPrefixInDeferredImport() { |
| 1793 ParserTestCase.parseCompilationUnit("import 'foo.dart' deferred;", | 2064 ParserTestCase.parseCompilationUnit("import 'foo.dart' deferred;", |
| 1794 [ParserErrorCode.MISSING_PREFIX_IN_DEFERRED_IMPORT]); | 2065 [ParserErrorCode.MISSING_PREFIX_IN_DEFERRED_IMPORT]); |
| 1795 } | 2066 } |
| 1796 | 2067 |
| 1797 void test_missingStartAfterSync() { | 2068 void test_missingStartAfterSync() { |
| 1798 parse3("parseFunctionBody", <Object>[false, null, false], "sync {}", | 2069 createParser('sync {}'); |
| 1799 [ParserErrorCode.MISSING_STAR_AFTER_SYNC]); | 2070 FunctionBody functionBody = parser.parseFunctionBody(false, null, false); |
| 2071 expectNotNullIfNoErrors(functionBody); |
| 2072 listener.assertErrorsWithCodes([ParserErrorCode.MISSING_STAR_AFTER_SYNC]); |
| 1800 } | 2073 } |
| 1801 | 2074 |
| 1802 void test_missingStatement() { | 2075 void test_missingStatement() { |
| 1803 ParserTestCase.parseStatement("is", [ParserErrorCode.MISSING_STATEMENT]); | 2076 ParserTestCase.parseStatement("is", [ParserErrorCode.MISSING_STATEMENT]); |
| 1804 } | 2077 } |
| 1805 | 2078 |
| 1806 void test_missingStatement_afterVoid() { | 2079 void test_missingStatement_afterVoid() { |
| 1807 ParserTestCase.parseStatement("void;", [ParserErrorCode.MISSING_STATEMENT]); | 2080 ParserTestCase.parseStatement("void;", [ParserErrorCode.MISSING_STATEMENT]); |
| 1808 } | 2081 } |
| 1809 | 2082 |
| 1810 void test_missingTerminatorForParameterGroup_named() { | 2083 void test_missingTerminatorForParameterGroup_named() { |
| 1811 parse4("parseFormalParameterList", "(a, {b: 0)", | 2084 createParser('(a, {b: 0)'); |
| 2085 FormalParameterList list = parser.parseFormalParameterList(); |
| 2086 expectNotNullIfNoErrors(list); |
| 2087 listener.assertErrorsWithCodes( |
| 1812 [ParserErrorCode.MISSING_TERMINATOR_FOR_PARAMETER_GROUP]); | 2088 [ParserErrorCode.MISSING_TERMINATOR_FOR_PARAMETER_GROUP]); |
| 1813 } | 2089 } |
| 1814 | 2090 |
| 1815 void test_missingTerminatorForParameterGroup_optional() { | 2091 void test_missingTerminatorForParameterGroup_optional() { |
| 1816 parse4("parseFormalParameterList", "(a, [b = 0)", | 2092 createParser('(a, [b = 0)'); |
| 2093 FormalParameterList list = parser.parseFormalParameterList(); |
| 2094 expectNotNullIfNoErrors(list); |
| 2095 listener.assertErrorsWithCodes( |
| 1817 [ParserErrorCode.MISSING_TERMINATOR_FOR_PARAMETER_GROUP]); | 2096 [ParserErrorCode.MISSING_TERMINATOR_FOR_PARAMETER_GROUP]); |
| 1818 } | 2097 } |
| 1819 | 2098 |
| 1820 void test_missingTypedefParameters_nonVoid() { | 2099 void test_missingTypedefParameters_nonVoid() { |
| 1821 ParserTestCase.parseCompilationUnit( | 2100 ParserTestCase.parseCompilationUnit( |
| 1822 "typedef int F;", [ParserErrorCode.MISSING_TYPEDEF_PARAMETERS]); | 2101 "typedef int F;", [ParserErrorCode.MISSING_TYPEDEF_PARAMETERS]); |
| 1823 } | 2102 } |
| 1824 | 2103 |
| 1825 void test_missingTypedefParameters_typeParameters() { | 2104 void test_missingTypedefParameters_typeParameters() { |
| 1826 ParserTestCase.parseCompilationUnit( | 2105 ParserTestCase.parseCompilationUnit( |
| 1827 "typedef F<E>;", [ParserErrorCode.MISSING_TYPEDEF_PARAMETERS]); | 2106 "typedef F<E>;", [ParserErrorCode.MISSING_TYPEDEF_PARAMETERS]); |
| 1828 } | 2107 } |
| 1829 | 2108 |
| 1830 void test_missingTypedefParameters_void() { | 2109 void test_missingTypedefParameters_void() { |
| 1831 ParserTestCase.parseCompilationUnit( | 2110 ParserTestCase.parseCompilationUnit( |
| 1832 "typedef void F;", [ParserErrorCode.MISSING_TYPEDEF_PARAMETERS]); | 2111 "typedef void F;", [ParserErrorCode.MISSING_TYPEDEF_PARAMETERS]); |
| 1833 } | 2112 } |
| 1834 | 2113 |
| 1835 void test_missingVariableInForEach() { | 2114 void test_missingVariableInForEach() { |
| 1836 parse4("parseForStatement", "for (a < b in foo) {}", | 2115 createParser('for (a < b in foo) {}'); |
| 1837 [ParserErrorCode.MISSING_VARIABLE_IN_FOR_EACH]); | 2116 Statement statement = parser.parseForStatement(); |
| 2117 expectNotNullIfNoErrors(statement); |
| 2118 listener |
| 2119 .assertErrorsWithCodes([ParserErrorCode.MISSING_VARIABLE_IN_FOR_EACH]); |
| 1838 } | 2120 } |
| 1839 | 2121 |
| 1840 void test_mixedParameterGroups_namedPositional() { | 2122 void test_mixedParameterGroups_namedPositional() { |
| 1841 parse4("parseFormalParameterList", "(a, {b}, [c])", | 2123 createParser('(a, {b}, [c])'); |
| 1842 [ParserErrorCode.MIXED_PARAMETER_GROUPS]); | 2124 FormalParameterList list = parser.parseFormalParameterList(); |
| 2125 expectNotNullIfNoErrors(list); |
| 2126 listener.assertErrorsWithCodes([ParserErrorCode.MIXED_PARAMETER_GROUPS]); |
| 1843 } | 2127 } |
| 1844 | 2128 |
| 1845 void test_mixedParameterGroups_positionalNamed() { | 2129 void test_mixedParameterGroups_positionalNamed() { |
| 1846 parse4("parseFormalParameterList", "(a, [b], {c})", | 2130 createParser('(a, [b], {c})'); |
| 1847 [ParserErrorCode.MIXED_PARAMETER_GROUPS]); | 2131 FormalParameterList list = parser.parseFormalParameterList(); |
| 2132 expectNotNullIfNoErrors(list); |
| 2133 listener.assertErrorsWithCodes([ParserErrorCode.MIXED_PARAMETER_GROUPS]); |
| 1848 } | 2134 } |
| 1849 | 2135 |
| 1850 void test_mixin_application_lacks_with_clause() { | 2136 void test_mixin_application_lacks_with_clause() { |
| 1851 ParserTestCase.parseCompilationUnit( | 2137 ParserTestCase.parseCompilationUnit( |
| 1852 "class Foo = Bar;", [ParserErrorCode.EXPECTED_TOKEN]); | 2138 "class Foo = Bar;", [ParserErrorCode.EXPECTED_TOKEN]); |
| 1853 } | 2139 } |
| 1854 | 2140 |
| 1855 void test_multipleExtendsClauses() { | 2141 void test_multipleExtendsClauses() { |
| 1856 ParserTestCase.parseCompilationUnit("class A extends B extends C {}", | 2142 ParserTestCase.parseCompilationUnit("class A extends B extends C {}", |
| 1857 [ParserErrorCode.MULTIPLE_EXTENDS_CLAUSES]); | 2143 [ParserErrorCode.MULTIPLE_EXTENDS_CLAUSES]); |
| 1858 } | 2144 } |
| 1859 | 2145 |
| 1860 void test_multipleImplementsClauses() { | 2146 void test_multipleImplementsClauses() { |
| 1861 ParserTestCase.parseCompilationUnit("class A implements B implements C {}", | 2147 ParserTestCase.parseCompilationUnit("class A implements B implements C {}", |
| 1862 [ParserErrorCode.MULTIPLE_IMPLEMENTS_CLAUSES]); | 2148 [ParserErrorCode.MULTIPLE_IMPLEMENTS_CLAUSES]); |
| 1863 } | 2149 } |
| 1864 | 2150 |
| 1865 void test_multipleLibraryDirectives() { | 2151 void test_multipleLibraryDirectives() { |
| 1866 ParserTestCase.parseCompilationUnit( | 2152 ParserTestCase.parseCompilationUnit( |
| 1867 "library l; library m;", [ParserErrorCode.MULTIPLE_LIBRARY_DIRECTIVES]); | 2153 "library l; library m;", [ParserErrorCode.MULTIPLE_LIBRARY_DIRECTIVES]); |
| 1868 } | 2154 } |
| 1869 | 2155 |
| 1870 void test_multipleNamedParameterGroups() { | 2156 void test_multipleNamedParameterGroups() { |
| 1871 parse4("parseFormalParameterList", "(a, {b}, {c})", | 2157 createParser('(a, {b}, {c})'); |
| 2158 FormalParameterList list = parser.parseFormalParameterList(); |
| 2159 expectNotNullIfNoErrors(list); |
| 2160 listener.assertErrorsWithCodes( |
| 1872 [ParserErrorCode.MULTIPLE_NAMED_PARAMETER_GROUPS]); | 2161 [ParserErrorCode.MULTIPLE_NAMED_PARAMETER_GROUPS]); |
| 1873 } | 2162 } |
| 1874 | 2163 |
| 1875 void test_multiplePartOfDirectives() { | 2164 void test_multiplePartOfDirectives() { |
| 1876 ParserTestCase.parseCompilationUnit( | 2165 ParserTestCase.parseCompilationUnit( |
| 1877 "part of l; part of m;", [ParserErrorCode.MULTIPLE_PART_OF_DIRECTIVES]); | 2166 "part of l; part of m;", [ParserErrorCode.MULTIPLE_PART_OF_DIRECTIVES]); |
| 1878 } | 2167 } |
| 1879 | 2168 |
| 1880 void test_multiplePositionalParameterGroups() { | 2169 void test_multiplePositionalParameterGroups() { |
| 1881 parse4("parseFormalParameterList", "(a, [b], [c])", | 2170 createParser('(a, [b], [c])'); |
| 2171 FormalParameterList list = parser.parseFormalParameterList(); |
| 2172 expectNotNullIfNoErrors(list); |
| 2173 listener.assertErrorsWithCodes( |
| 1882 [ParserErrorCode.MULTIPLE_POSITIONAL_PARAMETER_GROUPS]); | 2174 [ParserErrorCode.MULTIPLE_POSITIONAL_PARAMETER_GROUPS]); |
| 1883 } | 2175 } |
| 1884 | 2176 |
| 1885 void test_multipleVariablesInForEach() { | 2177 void test_multipleVariablesInForEach() { |
| 1886 parse4("parseForStatement", "for (int a, b in foo) {}", | 2178 createParser('for (int a, b in foo) {}'); |
| 2179 Statement statement = parser.parseForStatement(); |
| 2180 expectNotNullIfNoErrors(statement); |
| 2181 listener.assertErrorsWithCodes( |
| 1887 [ParserErrorCode.MULTIPLE_VARIABLES_IN_FOR_EACH]); | 2182 [ParserErrorCode.MULTIPLE_VARIABLES_IN_FOR_EACH]); |
| 1888 } | 2183 } |
| 1889 | 2184 |
| 1890 void test_multipleWithClauses() { | 2185 void test_multipleWithClauses() { |
| 1891 ParserTestCase.parseCompilationUnit("class A extends B with C with D {}", | 2186 ParserTestCase.parseCompilationUnit("class A extends B with C with D {}", |
| 1892 [ParserErrorCode.MULTIPLE_WITH_CLAUSES]); | 2187 [ParserErrorCode.MULTIPLE_WITH_CLAUSES]); |
| 1893 } | 2188 } |
| 1894 | 2189 |
| 1895 void test_namedParameterOutsideGroup() { | 2190 void test_namedParameterOutsideGroup() { |
| 1896 parse4("parseFormalParameterList", "(a, b : 0)", | 2191 createParser('(a, b : 0)'); |
| 1897 [ParserErrorCode.NAMED_PARAMETER_OUTSIDE_GROUP]); | 2192 FormalParameterList list = parser.parseFormalParameterList(); |
| 2193 expectNotNullIfNoErrors(list); |
| 2194 listener |
| 2195 .assertErrorsWithCodes([ParserErrorCode.NAMED_PARAMETER_OUTSIDE_GROUP]); |
| 1898 } | 2196 } |
| 1899 | 2197 |
| 1900 void test_nonConstructorFactory_field() { | 2198 void test_nonConstructorFactory_field() { |
| 1901 parse3("parseClassMember", <Object>["C"], "factory int x;", | 2199 createParser('factory int x;'); |
| 1902 [ParserErrorCode.NON_CONSTRUCTOR_FACTORY]); | 2200 ClassMember member = parser.parseClassMember('C'); |
| 2201 expectNotNullIfNoErrors(member); |
| 2202 listener.assertErrorsWithCodes([ParserErrorCode.NON_CONSTRUCTOR_FACTORY]); |
| 1903 } | 2203 } |
| 1904 | 2204 |
| 1905 void test_nonConstructorFactory_method() { | 2205 void test_nonConstructorFactory_method() { |
| 1906 parse3("parseClassMember", <Object>["C"], "factory int m() {}", | 2206 createParser('factory int m() {}'); |
| 1907 [ParserErrorCode.NON_CONSTRUCTOR_FACTORY]); | 2207 ClassMember member = parser.parseClassMember('C'); |
| 2208 expectNotNullIfNoErrors(member); |
| 2209 listener.assertErrorsWithCodes([ParserErrorCode.NON_CONSTRUCTOR_FACTORY]); |
| 1908 } | 2210 } |
| 1909 | 2211 |
| 1910 void test_nonIdentifierLibraryName_library() { | 2212 void test_nonIdentifierLibraryName_library() { |
| 1911 CompilationUnit unit = ParserTestCase.parseCompilationUnit( | 2213 CompilationUnit unit = ParserTestCase.parseCompilationUnit( |
| 1912 "library 'lib';", [ParserErrorCode.NON_IDENTIFIER_LIBRARY_NAME]); | 2214 "library 'lib';", [ParserErrorCode.NON_IDENTIFIER_LIBRARY_NAME]); |
| 1913 expect(unit, isNotNull); | 2215 expect(unit, isNotNull); |
| 1914 } | 2216 } |
| 1915 | 2217 |
| 1916 void test_nonIdentifierLibraryName_partOf() { | 2218 void test_nonIdentifierLibraryName_partOf() { |
| 1917 CompilationUnit unit = ParserTestCase.parseCompilationUnit( | 2219 CompilationUnit unit = ParserTestCase.parseCompilationUnit( |
| 1918 "part of 'lib';", [ParserErrorCode.NON_IDENTIFIER_LIBRARY_NAME]); | 2220 "part of 'lib';", [ParserErrorCode.NON_IDENTIFIER_LIBRARY_NAME]); |
| 1919 expect(unit, isNotNull); | 2221 expect(unit, isNotNull); |
| 1920 } | 2222 } |
| 1921 | 2223 |
| 1922 void test_nonPartOfDirectiveInPart_after() { | 2224 void test_nonPartOfDirectiveInPart_after() { |
| 1923 ParserTestCase.parseCompilationUnit("part of l; part 'f.dart';", | 2225 ParserTestCase.parseCompilationUnit("part of l; part 'f.dart';", |
| 1924 [ParserErrorCode.NON_PART_OF_DIRECTIVE_IN_PART]); | 2226 [ParserErrorCode.NON_PART_OF_DIRECTIVE_IN_PART]); |
| 1925 } | 2227 } |
| 1926 | 2228 |
| 1927 void test_nonPartOfDirectiveInPart_before() { | 2229 void test_nonPartOfDirectiveInPart_before() { |
| 1928 ParserTestCase.parseCompilationUnit("part 'f.dart'; part of m;", | 2230 ParserTestCase.parseCompilationUnit("part 'f.dart'; part of m;", |
| 1929 [ParserErrorCode.NON_PART_OF_DIRECTIVE_IN_PART]); | 2231 [ParserErrorCode.NON_PART_OF_DIRECTIVE_IN_PART]); |
| 1930 } | 2232 } |
| 1931 | 2233 |
| 1932 void test_nonUserDefinableOperator() { | 2234 void test_nonUserDefinableOperator() { |
| 1933 parse3("parseClassMember", <Object>["C"], "operator +=(int x) => x + 1;", | 2235 createParser('operator +=(int x) => x + 1;'); |
| 1934 [ParserErrorCode.NON_USER_DEFINABLE_OPERATOR]); | 2236 ClassMember member = parser.parseClassMember('C'); |
| 2237 expectNotNullIfNoErrors(member); |
| 2238 listener |
| 2239 .assertErrorsWithCodes([ParserErrorCode.NON_USER_DEFINABLE_OPERATOR]); |
| 1935 } | 2240 } |
| 1936 | 2241 |
| 1937 void test_optionalAfterNormalParameters_named() { | 2242 void test_optionalAfterNormalParameters_named() { |
| 1938 ParserTestCase.parseCompilationUnit( | 2243 ParserTestCase.parseCompilationUnit( |
| 1939 "f({a}, b) {}", [ParserErrorCode.NORMAL_BEFORE_OPTIONAL_PARAMETERS]); | 2244 "f({a}, b) {}", [ParserErrorCode.NORMAL_BEFORE_OPTIONAL_PARAMETERS]); |
| 1940 } | 2245 } |
| 1941 | 2246 |
| 1942 void test_optionalAfterNormalParameters_positional() { | 2247 void test_optionalAfterNormalParameters_positional() { |
| 1943 ParserTestCase.parseCompilationUnit( | 2248 ParserTestCase.parseCompilationUnit( |
| 1944 "f([a], b) {}", [ParserErrorCode.NORMAL_BEFORE_OPTIONAL_PARAMETERS]); | 2249 "f([a], b) {}", [ParserErrorCode.NORMAL_BEFORE_OPTIONAL_PARAMETERS]); |
| 1945 } | 2250 } |
| 1946 | 2251 |
| 1947 void test_parseCascadeSection_missingIdentifier() { | 2252 void test_parseCascadeSection_missingIdentifier() { |
| 1948 MethodInvocation methodInvocation = parse4( | 2253 createParser('..()'); |
| 1949 "parseCascadeSection", "..()", [ParserErrorCode.MISSING_IDENTIFIER]); | 2254 MethodInvocation methodInvocation = parser.parseCascadeSection(); |
| 2255 expectNotNullIfNoErrors(methodInvocation); |
| 2256 listener.assertErrorsWithCodes([ParserErrorCode.MISSING_IDENTIFIER]); |
| 1950 expect(methodInvocation.target, isNull); | 2257 expect(methodInvocation.target, isNull); |
| 1951 expect(methodInvocation.methodName.name, ""); | 2258 expect(methodInvocation.methodName.name, ""); |
| 1952 expect(methodInvocation.typeArguments, isNull); | 2259 expect(methodInvocation.typeArguments, isNull); |
| 1953 expect(methodInvocation.argumentList.arguments, hasLength(0)); | 2260 expect(methodInvocation.argumentList.arguments, hasLength(0)); |
| 1954 } | 2261 } |
| 1955 | 2262 |
| 1956 void test_parseCascadeSection_missingIdentifier_typeArguments() { | 2263 void test_parseCascadeSection_missingIdentifier_typeArguments() { |
| 1957 enableGenericMethods = true; | 2264 enableGenericMethods = true; |
| 1958 MethodInvocation methodInvocation = parse4( | 2265 createParser('..<E>()'); |
| 1959 "parseCascadeSection", "..<E>()", [ParserErrorCode.MISSING_IDENTIFIER]); | 2266 MethodInvocation methodInvocation = parser.parseCascadeSection(); |
| 2267 expectNotNullIfNoErrors(methodInvocation); |
| 2268 listener.assertErrorsWithCodes([ParserErrorCode.MISSING_IDENTIFIER]); |
| 1960 expect(methodInvocation.target, isNull); | 2269 expect(methodInvocation.target, isNull); |
| 1961 expect(methodInvocation.methodName.name, ""); | 2270 expect(methodInvocation.methodName.name, ""); |
| 1962 expect(methodInvocation.typeArguments, isNotNull); | 2271 expect(methodInvocation.typeArguments, isNotNull); |
| 1963 expect(methodInvocation.argumentList.arguments, hasLength(0)); | 2272 expect(methodInvocation.argumentList.arguments, hasLength(0)); |
| 1964 } | 2273 } |
| 1965 | 2274 |
| 1966 void test_positionalAfterNamedArgument() { | 2275 void test_positionalAfterNamedArgument() { |
| 1967 parse4("parseArgumentList", "(x: 1, 2)", | 2276 createParser('(x: 1, 2)'); |
| 2277 ArgumentList list = parser.parseArgumentList(); |
| 2278 expectNotNullIfNoErrors(list); |
| 2279 listener.assertErrorsWithCodes( |
| 1968 [ParserErrorCode.POSITIONAL_AFTER_NAMED_ARGUMENT]); | 2280 [ParserErrorCode.POSITIONAL_AFTER_NAMED_ARGUMENT]); |
| 1969 } | 2281 } |
| 1970 | 2282 |
| 1971 void test_positionalParameterOutsideGroup() { | 2283 void test_positionalParameterOutsideGroup() { |
| 1972 parse4("parseFormalParameterList", "(a, b = 0)", | 2284 createParser('(a, b = 0)'); |
| 2285 FormalParameterList list = parser.parseFormalParameterList(); |
| 2286 expectNotNullIfNoErrors(list); |
| 2287 listener.assertErrorsWithCodes( |
| 1973 [ParserErrorCode.POSITIONAL_PARAMETER_OUTSIDE_GROUP]); | 2288 [ParserErrorCode.POSITIONAL_PARAMETER_OUTSIDE_GROUP]); |
| 1974 } | 2289 } |
| 1975 | 2290 |
| 1976 void test_redirectingConstructorWithBody_named() { | 2291 void test_redirectingConstructorWithBody_named() { |
| 1977 parse3("parseClassMember", <Object>["C"], "C.x() : this() {}", | 2292 createParser('C.x() : this() {}'); |
| 2293 ClassMember member = parser.parseClassMember('C'); |
| 2294 expectNotNullIfNoErrors(member); |
| 2295 listener.assertErrorsWithCodes( |
| 1978 [ParserErrorCode.REDIRECTING_CONSTRUCTOR_WITH_BODY]); | 2296 [ParserErrorCode.REDIRECTING_CONSTRUCTOR_WITH_BODY]); |
| 1979 } | 2297 } |
| 1980 | 2298 |
| 1981 void test_redirectingConstructorWithBody_unnamed() { | 2299 void test_redirectingConstructorWithBody_unnamed() { |
| 1982 parse3("parseClassMember", <Object>["C"], "C() : this.x() {}", | 2300 createParser('C() : this.x() {}'); |
| 2301 ClassMember member = parser.parseClassMember('C'); |
| 2302 expectNotNullIfNoErrors(member); |
| 2303 listener.assertErrorsWithCodes( |
| 1983 [ParserErrorCode.REDIRECTING_CONSTRUCTOR_WITH_BODY]); | 2304 [ParserErrorCode.REDIRECTING_CONSTRUCTOR_WITH_BODY]); |
| 1984 } | 2305 } |
| 1985 | 2306 |
| 1986 void test_redirectionInNonFactoryConstructor() { | 2307 void test_redirectionInNonFactoryConstructor() { |
| 1987 parse3("parseClassMember", <Object>["C"], "C() = D;", | 2308 createParser('C() = D;'); |
| 2309 ClassMember member = parser.parseClassMember('C'); |
| 2310 expectNotNullIfNoErrors(member); |
| 2311 listener.assertErrorsWithCodes( |
| 1988 [ParserErrorCode.REDIRECTION_IN_NON_FACTORY_CONSTRUCTOR]); | 2312 [ParserErrorCode.REDIRECTION_IN_NON_FACTORY_CONSTRUCTOR]); |
| 1989 } | 2313 } |
| 1990 | 2314 |
| 1991 void test_setterInFunction_block() { | 2315 void test_setterInFunction_block() { |
| 1992 ParserTestCase.parseStatement( | 2316 ParserTestCase.parseStatement( |
| 1993 "set x(v) {_x = v;}", [ParserErrorCode.SETTER_IN_FUNCTION]); | 2317 "set x(v) {_x = v;}", [ParserErrorCode.SETTER_IN_FUNCTION]); |
| 1994 } | 2318 } |
| 1995 | 2319 |
| 1996 void test_setterInFunction_expression() { | 2320 void test_setterInFunction_expression() { |
| 1997 ParserTestCase.parseStatement( | 2321 ParserTestCase.parseStatement( |
| 1998 "set x(v) => _x = v;", [ParserErrorCode.SETTER_IN_FUNCTION]); | 2322 "set x(v) => _x = v;", [ParserErrorCode.SETTER_IN_FUNCTION]); |
| 1999 } | 2323 } |
| 2000 | 2324 |
| 2001 void test_staticAfterConst() { | 2325 void test_staticAfterConst() { |
| 2002 parse3("parseClassMember", <Object>["C"], "final static int f;", | 2326 createParser('final static int f;'); |
| 2003 [ParserErrorCode.STATIC_AFTER_FINAL]); | 2327 ClassMember member = parser.parseClassMember('C'); |
| 2328 expectNotNullIfNoErrors(member); |
| 2329 listener.assertErrorsWithCodes([ParserErrorCode.STATIC_AFTER_FINAL]); |
| 2004 } | 2330 } |
| 2005 | 2331 |
| 2006 void test_staticAfterFinal() { | 2332 void test_staticAfterFinal() { |
| 2007 parse3("parseClassMember", <Object>["C"], "const static int f;", | 2333 createParser('const static int f;'); |
| 2008 [ParserErrorCode.STATIC_AFTER_CONST]); | 2334 ClassMember member = parser.parseClassMember('C'); |
| 2335 expectNotNullIfNoErrors(member); |
| 2336 listener.assertErrorsWithCodes([ParserErrorCode.STATIC_AFTER_CONST]); |
| 2009 } | 2337 } |
| 2010 | 2338 |
| 2011 void test_staticAfterVar() { | 2339 void test_staticAfterVar() { |
| 2012 parse3("parseClassMember", <Object>["C"], "var static f;", | 2340 createParser('var static f;'); |
| 2013 [ParserErrorCode.STATIC_AFTER_VAR]); | 2341 ClassMember member = parser.parseClassMember('C'); |
| 2342 expectNotNullIfNoErrors(member); |
| 2343 listener.assertErrorsWithCodes([ParserErrorCode.STATIC_AFTER_VAR]); |
| 2014 } | 2344 } |
| 2015 | 2345 |
| 2016 void test_staticConstructor() { | 2346 void test_staticConstructor() { |
| 2017 parse3("parseClassMember", <Object>["C"], "static C.m() {}", | 2347 createParser('static C.m() {}'); |
| 2018 [ParserErrorCode.STATIC_CONSTRUCTOR]); | 2348 ClassMember member = parser.parseClassMember('C'); |
| 2349 expectNotNullIfNoErrors(member); |
| 2350 listener.assertErrorsWithCodes([ParserErrorCode.STATIC_CONSTRUCTOR]); |
| 2019 } | 2351 } |
| 2020 | 2352 |
| 2021 void test_staticGetterWithoutBody() { | 2353 void test_staticGetterWithoutBody() { |
| 2022 parse3("parseClassMember", <Object>["C"], "static get m;", | 2354 createParser('static get m;'); |
| 2023 [ParserErrorCode.STATIC_GETTER_WITHOUT_BODY]); | 2355 ClassMember member = parser.parseClassMember('C'); |
| 2356 expectNotNullIfNoErrors(member); |
| 2357 listener |
| 2358 .assertErrorsWithCodes([ParserErrorCode.STATIC_GETTER_WITHOUT_BODY]); |
| 2024 } | 2359 } |
| 2025 | 2360 |
| 2026 void test_staticOperator_noReturnType() { | 2361 void test_staticOperator_noReturnType() { |
| 2027 parse3( | 2362 createParser('static operator +(int x) => x + 1;'); |
| 2028 "parseClassMember", | 2363 ClassMember member = parser.parseClassMember('C'); |
| 2029 <Object>["C"], | 2364 expectNotNullIfNoErrors(member); |
| 2030 "static operator +(int x) => x + 1;", | 2365 listener.assertErrorsWithCodes([ParserErrorCode.STATIC_OPERATOR]); |
| 2031 [ParserErrorCode.STATIC_OPERATOR]); | |
| 2032 } | 2366 } |
| 2033 | 2367 |
| 2034 void test_staticOperator_returnType() { | 2368 void test_staticOperator_returnType() { |
| 2035 parse3( | 2369 createParser('static int operator +(int x) => x + 1;'); |
| 2036 "parseClassMember", | 2370 ClassMember member = parser.parseClassMember('C'); |
| 2037 <Object>["C"], | 2371 expectNotNullIfNoErrors(member); |
| 2038 "static int operator +(int x) => x + 1;", | 2372 listener.assertErrorsWithCodes([ParserErrorCode.STATIC_OPERATOR]); |
| 2039 [ParserErrorCode.STATIC_OPERATOR]); | |
| 2040 } | 2373 } |
| 2041 | 2374 |
| 2042 void test_staticSetterWithoutBody() { | 2375 void test_staticSetterWithoutBody() { |
| 2043 parse3("parseClassMember", <Object>["C"], "static set m(x);", | 2376 createParser('static set m(x);'); |
| 2044 [ParserErrorCode.STATIC_SETTER_WITHOUT_BODY]); | 2377 ClassMember member = parser.parseClassMember('C'); |
| 2378 expectNotNullIfNoErrors(member); |
| 2379 listener |
| 2380 .assertErrorsWithCodes([ParserErrorCode.STATIC_SETTER_WITHOUT_BODY]); |
| 2045 } | 2381 } |
| 2046 | 2382 |
| 2047 void test_staticTopLevelDeclaration_class() { | 2383 void test_staticTopLevelDeclaration_class() { |
| 2048 ParserTestCase.parseCompilationUnit( | 2384 ParserTestCase.parseCompilationUnit( |
| 2049 "static class C {}", [ParserErrorCode.STATIC_TOP_LEVEL_DECLARATION]); | 2385 "static class C {}", [ParserErrorCode.STATIC_TOP_LEVEL_DECLARATION]); |
| 2050 } | 2386 } |
| 2051 | 2387 |
| 2052 void test_staticTopLevelDeclaration_function() { | 2388 void test_staticTopLevelDeclaration_function() { |
| 2053 ParserTestCase.parseCompilationUnit( | 2389 ParserTestCase.parseCompilationUnit( |
| 2054 "static f() {}", [ParserErrorCode.STATIC_TOP_LEVEL_DECLARATION]); | 2390 "static f() {}", [ParserErrorCode.STATIC_TOP_LEVEL_DECLARATION]); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2076 ParserErrorCode.EXPECTED_TOKEN, | 2412 ParserErrorCode.EXPECTED_TOKEN, |
| 2077 ParserErrorCode.EXPECTED_TOKEN, | 2413 ParserErrorCode.EXPECTED_TOKEN, |
| 2078 ParserErrorCode.EXPECTED_TOKEN, | 2414 ParserErrorCode.EXPECTED_TOKEN, |
| 2079 ParserErrorCode.EXPECTED_TOKEN, | 2415 ParserErrorCode.EXPECTED_TOKEN, |
| 2080 ParserErrorCode.EXPECTED_TOKEN, | 2416 ParserErrorCode.EXPECTED_TOKEN, |
| 2081 ParserErrorCode.EXPECTED_TOKEN, | 2417 ParserErrorCode.EXPECTED_TOKEN, |
| 2082 ]); | 2418 ]); |
| 2083 } | 2419 } |
| 2084 | 2420 |
| 2085 void test_switchHasCaseAfterDefaultCase() { | 2421 void test_switchHasCaseAfterDefaultCase() { |
| 2086 parse4( | 2422 createParser('switch (a) {default: return 0; case 1: return 1;}'); |
| 2087 "parseSwitchStatement", | 2423 SwitchStatement statement = parser.parseSwitchStatement(); |
| 2088 "switch (a) {default: return 0; case 1: return 1;}", | 2424 expectNotNullIfNoErrors(statement); |
| 2425 listener.assertErrorsWithCodes( |
| 2089 [ParserErrorCode.SWITCH_HAS_CASE_AFTER_DEFAULT_CASE]); | 2426 [ParserErrorCode.SWITCH_HAS_CASE_AFTER_DEFAULT_CASE]); |
| 2090 } | 2427 } |
| 2091 | 2428 |
| 2092 void test_switchHasCaseAfterDefaultCase_repeated() { | 2429 void test_switchHasCaseAfterDefaultCase_repeated() { |
| 2093 parse4("parseSwitchStatement", | 2430 createParser( |
| 2094 "switch (a) {default: return 0; case 1: return 1; case 2: return 2;}", [ | 2431 'switch (a) {default: return 0; case 1: return 1; case 2: return 2;}'); |
| 2432 SwitchStatement statement = parser.parseSwitchStatement(); |
| 2433 expectNotNullIfNoErrors(statement); |
| 2434 listener.assertErrorsWithCodes([ |
| 2095 ParserErrorCode.SWITCH_HAS_CASE_AFTER_DEFAULT_CASE, | 2435 ParserErrorCode.SWITCH_HAS_CASE_AFTER_DEFAULT_CASE, |
| 2096 ParserErrorCode.SWITCH_HAS_CASE_AFTER_DEFAULT_CASE | 2436 ParserErrorCode.SWITCH_HAS_CASE_AFTER_DEFAULT_CASE |
| 2097 ]); | 2437 ]); |
| 2098 } | 2438 } |
| 2099 | 2439 |
| 2100 void test_switchHasMultipleDefaultCases() { | 2440 void test_switchHasMultipleDefaultCases() { |
| 2101 parse4( | 2441 createParser('switch (a) {default: return 0; default: return 1;}'); |
| 2102 "parseSwitchStatement", | 2442 SwitchStatement statement = parser.parseSwitchStatement(); |
| 2103 "switch (a) {default: return 0; default: return 1;}", | 2443 expectNotNullIfNoErrors(statement); |
| 2444 listener.assertErrorsWithCodes( |
| 2104 [ParserErrorCode.SWITCH_HAS_MULTIPLE_DEFAULT_CASES]); | 2445 [ParserErrorCode.SWITCH_HAS_MULTIPLE_DEFAULT_CASES]); |
| 2105 } | 2446 } |
| 2106 | 2447 |
| 2107 void test_switchHasMultipleDefaultCases_repeated() { | 2448 void test_switchHasMultipleDefaultCases_repeated() { |
| 2108 parse4( | 2449 createParser( |
| 2109 "parseSwitchStatement", | 2450 'switch (a) {default: return 0; default: return 1; default: return 2;}')
; |
| 2110 "switch (a) {default: return 0; default: return 1; default: return 2;}", | 2451 SwitchStatement statement = parser.parseSwitchStatement(); |
| 2111 [ | 2452 expectNotNullIfNoErrors(statement); |
| 2112 ParserErrorCode.SWITCH_HAS_MULTIPLE_DEFAULT_CASES, | 2453 listener.assertErrorsWithCodes([ |
| 2113 ParserErrorCode.SWITCH_HAS_MULTIPLE_DEFAULT_CASES | 2454 ParserErrorCode.SWITCH_HAS_MULTIPLE_DEFAULT_CASES, |
| 2114 ]); | 2455 ParserErrorCode.SWITCH_HAS_MULTIPLE_DEFAULT_CASES |
| 2456 ]); |
| 2115 } | 2457 } |
| 2116 | 2458 |
| 2117 void test_topLevel_getter() { | 2459 void test_topLevel_getter() { |
| 2118 FunctionDeclaration funct = parse3("parseCompilationUnitMember", | 2460 createParser('get x => 7;'); |
| 2119 <Object>[emptyCommentAndMetadata()], "get x => 7;"); | 2461 CompilationUnitMember member = |
| 2120 expect(funct.functionExpression.parameters, isNull); | 2462 parser.parseCompilationUnitMember(emptyCommentAndMetadata()); |
| 2463 expectNotNullIfNoErrors(member); |
| 2464 listener.assertNoErrors(); |
| 2465 expect(member, new isInstanceOf<FunctionDeclaration>()); |
| 2466 FunctionDeclaration function = member; |
| 2467 expect(function.functionExpression.parameters, isNull); |
| 2121 } | 2468 } |
| 2122 | 2469 |
| 2123 void test_topLevelOperator_withoutType() { | 2470 void test_topLevelOperator_withoutType() { |
| 2124 parse3( | 2471 createParser('operator +(bool x, bool y) => x | y;'); |
| 2125 "parseCompilationUnitMember", | 2472 CompilationUnitMember member = |
| 2126 <Object>[emptyCommentAndMetadata()], | 2473 parser.parseCompilationUnitMember(emptyCommentAndMetadata()); |
| 2127 "operator +(bool x, bool y) => x | y;", | 2474 expectNotNullIfNoErrors(member); |
| 2128 [ParserErrorCode.TOP_LEVEL_OPERATOR]); | 2475 listener.assertErrorsWithCodes([ParserErrorCode.TOP_LEVEL_OPERATOR]); |
| 2129 } | 2476 } |
| 2130 | 2477 |
| 2131 void test_topLevelOperator_withType() { | 2478 void test_topLevelOperator_withType() { |
| 2132 parse3( | 2479 createParser('bool operator +(bool x, bool y) => x | y;'); |
| 2133 "parseCompilationUnitMember", | 2480 CompilationUnitMember member = |
| 2134 <Object>[emptyCommentAndMetadata()], | 2481 parser.parseCompilationUnitMember(emptyCommentAndMetadata()); |
| 2135 "bool operator +(bool x, bool y) => x | y;", | 2482 expectNotNullIfNoErrors(member); |
| 2136 [ParserErrorCode.TOP_LEVEL_OPERATOR]); | 2483 listener.assertErrorsWithCodes([ParserErrorCode.TOP_LEVEL_OPERATOR]); |
| 2137 } | 2484 } |
| 2138 | 2485 |
| 2139 void test_topLevelOperator_withVoid() { | 2486 void test_topLevelOperator_withVoid() { |
| 2140 parse3( | 2487 createParser('void operator +(bool x, bool y) => x | y;'); |
| 2141 "parseCompilationUnitMember", | 2488 CompilationUnitMember member = |
| 2142 <Object>[emptyCommentAndMetadata()], | 2489 parser.parseCompilationUnitMember(emptyCommentAndMetadata()); |
| 2143 "void operator +(bool x, bool y) => x | y;", | 2490 expectNotNullIfNoErrors(member); |
| 2144 [ParserErrorCode.TOP_LEVEL_OPERATOR]); | 2491 listener.assertErrorsWithCodes([ParserErrorCode.TOP_LEVEL_OPERATOR]); |
| 2145 } | 2492 } |
| 2146 | 2493 |
| 2147 void test_topLevelVariable_withMetadata() { | 2494 void test_topLevelVariable_withMetadata() { |
| 2148 ParserTestCase.parseCompilationUnit("String @A string;", [ | 2495 ParserTestCase.parseCompilationUnit("String @A string;", [ |
| 2149 ParserErrorCode.MISSING_IDENTIFIER, | 2496 ParserErrorCode.MISSING_IDENTIFIER, |
| 2150 ParserErrorCode.EXPECTED_TOKEN, | 2497 ParserErrorCode.EXPECTED_TOKEN, |
| 2151 ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE | 2498 ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE |
| 2152 ]); | 2499 ]); |
| 2153 } | 2500 } |
| 2154 | 2501 |
| 2155 void test_typedefInClass_withoutReturnType() { | 2502 void test_typedefInClass_withoutReturnType() { |
| 2156 ParserTestCase.parseCompilationUnit( | 2503 ParserTestCase.parseCompilationUnit( |
| 2157 "class C { typedef F(x); }", [ParserErrorCode.TYPEDEF_IN_CLASS]); | 2504 "class C { typedef F(x); }", [ParserErrorCode.TYPEDEF_IN_CLASS]); |
| 2158 } | 2505 } |
| 2159 | 2506 |
| 2160 void test_typedefInClass_withReturnType() { | 2507 void test_typedefInClass_withReturnType() { |
| 2161 ParserTestCase.parseCompilationUnit("class C { typedef int F(int x); }", | 2508 ParserTestCase.parseCompilationUnit("class C { typedef int F(int x); }", |
| 2162 [ParserErrorCode.TYPEDEF_IN_CLASS]); | 2509 [ParserErrorCode.TYPEDEF_IN_CLASS]); |
| 2163 } | 2510 } |
| 2164 | 2511 |
| 2165 void test_unexpectedTerminatorForParameterGroup_named() { | 2512 void test_unexpectedTerminatorForParameterGroup_named() { |
| 2166 parse4("parseFormalParameterList", "(a, b})", | 2513 createParser('(a, b})'); |
| 2514 FormalParameterList list = parser.parseFormalParameterList(); |
| 2515 expectNotNullIfNoErrors(list); |
| 2516 listener.assertErrorsWithCodes( |
| 2167 [ParserErrorCode.UNEXPECTED_TERMINATOR_FOR_PARAMETER_GROUP]); | 2517 [ParserErrorCode.UNEXPECTED_TERMINATOR_FOR_PARAMETER_GROUP]); |
| 2168 } | 2518 } |
| 2169 | 2519 |
| 2170 void test_unexpectedTerminatorForParameterGroup_optional() { | 2520 void test_unexpectedTerminatorForParameterGroup_optional() { |
| 2171 parse4("parseFormalParameterList", "(a, b])", | 2521 createParser('(a, b])'); |
| 2522 FormalParameterList list = parser.parseFormalParameterList(); |
| 2523 expectNotNullIfNoErrors(list); |
| 2524 listener.assertErrorsWithCodes( |
| 2172 [ParserErrorCode.UNEXPECTED_TERMINATOR_FOR_PARAMETER_GROUP]); | 2525 [ParserErrorCode.UNEXPECTED_TERMINATOR_FOR_PARAMETER_GROUP]); |
| 2173 } | 2526 } |
| 2174 | 2527 |
| 2175 void test_unexpectedToken_endOfFieldDeclarationStatement() { | 2528 void test_unexpectedToken_endOfFieldDeclarationStatement() { |
| 2176 ParserTestCase.parseStatement( | 2529 ParserTestCase.parseStatement( |
| 2177 "String s = (null));", [ParserErrorCode.UNEXPECTED_TOKEN]); | 2530 "String s = (null));", [ParserErrorCode.UNEXPECTED_TOKEN]); |
| 2178 } | 2531 } |
| 2179 | 2532 |
| 2180 void test_unexpectedToken_returnInExpressionFuntionBody() { | 2533 void test_unexpectedToken_returnInExpressionFuntionBody() { |
| 2181 ParserTestCase.parseCompilationUnit( | 2534 ParserTestCase.parseCompilationUnit( |
| 2182 "f() => return null;", [ParserErrorCode.UNEXPECTED_TOKEN]); | 2535 "f() => return null;", [ParserErrorCode.UNEXPECTED_TOKEN]); |
| 2183 } | 2536 } |
| 2184 | 2537 |
| 2185 void test_unexpectedToken_semicolonBetweenClassMembers() { | 2538 void test_unexpectedToken_semicolonBetweenClassMembers() { |
| 2186 parse3("parseClassDeclaration", <Object>[emptyCommentAndMetadata(), null], | 2539 createParser('class C { int x; ; int y;}'); |
| 2187 "class C { int x; ; int y;}", [ParserErrorCode.UNEXPECTED_TOKEN]); | 2540 ClassDeclaration declaration = |
| 2541 parser.parseClassDeclaration(emptyCommentAndMetadata(), null); |
| 2542 expectNotNullIfNoErrors(declaration); |
| 2543 listener.assertErrorsWithCodes([ParserErrorCode.UNEXPECTED_TOKEN]); |
| 2188 } | 2544 } |
| 2189 | 2545 |
| 2190 void test_unexpectedToken_semicolonBetweenCompilationUnitMembers() { | 2546 void test_unexpectedToken_semicolonBetweenCompilationUnitMembers() { |
| 2191 ParserTestCase.parseCompilationUnit( | 2547 ParserTestCase.parseCompilationUnit( |
| 2192 "int x; ; int y;", [ParserErrorCode.UNEXPECTED_TOKEN]); | 2548 "int x; ; int y;", [ParserErrorCode.UNEXPECTED_TOKEN]); |
| 2193 } | 2549 } |
| 2194 | 2550 |
| 2195 void test_unterminatedString_at_eof() { | 2551 void test_unterminatedString_at_eof() { |
| 2196 // Although the "unterminated string" error message is produced by the | 2552 // Although the "unterminated string" error message is produced by the |
| 2197 // scanner, we need to verify that the parser can handle the tokens | 2553 // scanner, we need to verify that the parser can handle the tokens |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2260 void main() { | 2616 void main() { |
| 2261 var x = """""''', | 2617 var x = """""''', |
| 2262 [ | 2618 [ |
| 2263 ScannerErrorCode.UNTERMINATED_STRING_LITERAL, | 2619 ScannerErrorCode.UNTERMINATED_STRING_LITERAL, |
| 2264 ParserErrorCode.EXPECTED_TOKEN, | 2620 ParserErrorCode.EXPECTED_TOKEN, |
| 2265 ParserErrorCode.EXPECTED_TOKEN | 2621 ParserErrorCode.EXPECTED_TOKEN |
| 2266 ]); | 2622 ]); |
| 2267 } | 2623 } |
| 2268 | 2624 |
| 2269 void test_useOfUnaryPlusOperator() { | 2625 void test_useOfUnaryPlusOperator() { |
| 2270 SimpleIdentifier expression = parse4( | 2626 createParser('+x'); |
| 2271 "parseUnaryExpression", "+x", [ParserErrorCode.MISSING_IDENTIFIER]); | 2627 Expression expression = parser.parseUnaryExpression(); |
| 2272 EngineTestCase.assertInstanceOf( | 2628 expectNotNullIfNoErrors(expression); |
| 2273 (obj) => obj is SimpleIdentifier, SimpleIdentifier, expression); | 2629 listener.assertErrorsWithCodes([ParserErrorCode.MISSING_IDENTIFIER]); |
| 2274 expect(expression.isSynthetic, isTrue); | 2630 expect(expression, new isInstanceOf<SimpleIdentifier>()); |
| 2631 SimpleIdentifier identifier = expression; |
| 2632 expect(identifier.isSynthetic, isTrue); |
| 2275 } | 2633 } |
| 2276 | 2634 |
| 2277 void test_varAndType_field() { | 2635 void test_varAndType_field() { |
| 2278 ParserTestCase.parseCompilationUnit( | 2636 ParserTestCase.parseCompilationUnit( |
| 2279 "class C { var int x; }", [ParserErrorCode.VAR_AND_TYPE]); | 2637 "class C { var int x; }", [ParserErrorCode.VAR_AND_TYPE]); |
| 2280 } | 2638 } |
| 2281 | 2639 |
| 2282 void test_varAndType_topLevelVariable() { | 2640 void test_varAndType_topLevelVariable() { |
| 2283 ParserTestCase | 2641 ParserTestCase |
| 2284 .parseCompilationUnit("var int x;", [ParserErrorCode.VAR_AND_TYPE]); | 2642 .parseCompilationUnit("var int x;", [ParserErrorCode.VAR_AND_TYPE]); |
| 2285 } | 2643 } |
| 2286 | 2644 |
| 2287 void test_varAsTypeName_as() { | 2645 void test_varAsTypeName_as() { |
| 2288 parseExpression("x as var", [ParserErrorCode.VAR_AS_TYPE_NAME]); | 2646 parseExpression("x as var", [ParserErrorCode.VAR_AS_TYPE_NAME]); |
| 2289 } | 2647 } |
| 2290 | 2648 |
| 2291 void test_varClass() { | 2649 void test_varClass() { |
| 2292 ParserTestCase | 2650 ParserTestCase |
| 2293 .parseCompilationUnit("var class C {}", [ParserErrorCode.VAR_CLASS]); | 2651 .parseCompilationUnit("var class C {}", [ParserErrorCode.VAR_CLASS]); |
| 2294 } | 2652 } |
| 2295 | 2653 |
| 2296 void test_varEnum() { | 2654 void test_varEnum() { |
| 2297 ParserTestCase | 2655 ParserTestCase |
| 2298 .parseCompilationUnit("var enum E {ONE}", [ParserErrorCode.VAR_ENUM]); | 2656 .parseCompilationUnit("var enum E {ONE}", [ParserErrorCode.VAR_ENUM]); |
| 2299 } | 2657 } |
| 2300 | 2658 |
| 2301 void test_varReturnType() { | 2659 void test_varReturnType() { |
| 2302 parse3("parseClassMember", <Object>["C"], "var m() {}", | 2660 createParser('var m() {}'); |
| 2303 [ParserErrorCode.VAR_RETURN_TYPE]); | 2661 ClassMember member = parser.parseClassMember('C'); |
| 2662 expectNotNullIfNoErrors(member); |
| 2663 listener.assertErrorsWithCodes([ParserErrorCode.VAR_RETURN_TYPE]); |
| 2304 } | 2664 } |
| 2305 | 2665 |
| 2306 void test_varTypedef() { | 2666 void test_varTypedef() { |
| 2307 ParserTestCase.parseCompilationUnit( | 2667 ParserTestCase.parseCompilationUnit( |
| 2308 "var typedef F();", [ParserErrorCode.VAR_TYPEDEF]); | 2668 "var typedef F();", [ParserErrorCode.VAR_TYPEDEF]); |
| 2309 } | 2669 } |
| 2310 | 2670 |
| 2311 void test_voidParameter() { | 2671 void test_voidParameter() { |
| 2312 parse4("parseNormalFormalParameter", "void a)", | 2672 createParser('void a)'); |
| 2313 [ParserErrorCode.VOID_PARAMETER]); | 2673 NormalFormalParameter parameter = parser.parseNormalFormalParameter(); |
| 2674 expectNotNullIfNoErrors(parameter); |
| 2675 listener.assertErrorsWithCodes([ParserErrorCode.VOID_PARAMETER]); |
| 2314 } | 2676 } |
| 2315 | 2677 |
| 2316 void test_voidVariable_parseClassMember_initializer() { | 2678 void test_voidVariable_parseClassMember_initializer() { |
| 2317 parse3("parseClassMember", <Object>["C"], "void x = 0;", | 2679 createParser('void x = 0;'); |
| 2318 [ParserErrorCode.VOID_VARIABLE]); | 2680 ClassMember member = parser.parseClassMember('C'); |
| 2681 expectNotNullIfNoErrors(member); |
| 2682 listener.assertErrorsWithCodes([ParserErrorCode.VOID_VARIABLE]); |
| 2319 } | 2683 } |
| 2320 | 2684 |
| 2321 void test_voidVariable_parseClassMember_noInitializer() { | 2685 void test_voidVariable_parseClassMember_noInitializer() { |
| 2322 parse3("parseClassMember", <Object>["C"], "void x;", | 2686 createParser('void x;'); |
| 2323 [ParserErrorCode.VOID_VARIABLE]); | 2687 ClassMember member = parser.parseClassMember('C'); |
| 2688 expectNotNullIfNoErrors(member); |
| 2689 listener.assertErrorsWithCodes([ParserErrorCode.VOID_VARIABLE]); |
| 2324 } | 2690 } |
| 2325 | 2691 |
| 2326 void test_voidVariable_parseCompilationUnit_initializer() { | 2692 void test_voidVariable_parseCompilationUnit_initializer() { |
| 2327 ParserTestCase | 2693 ParserTestCase |
| 2328 .parseCompilationUnit("void x = 0;", [ParserErrorCode.VOID_VARIABLE]); | 2694 .parseCompilationUnit("void x = 0;", [ParserErrorCode.VOID_VARIABLE]); |
| 2329 } | 2695 } |
| 2330 | 2696 |
| 2331 void test_voidVariable_parseCompilationUnit_noInitializer() { | 2697 void test_voidVariable_parseCompilationUnit_noInitializer() { |
| 2332 ParserTestCase | 2698 ParserTestCase |
| 2333 .parseCompilationUnit("void x;", [ParserErrorCode.VOID_VARIABLE]); | 2699 .parseCompilationUnit("void x;", [ParserErrorCode.VOID_VARIABLE]); |
| 2334 } | 2700 } |
| 2335 | 2701 |
| 2336 void test_voidVariable_parseCompilationUnitMember_initializer() { | 2702 void test_voidVariable_parseCompilationUnitMember_initializer() { |
| 2337 parse3("parseCompilationUnitMember", <Object>[emptyCommentAndMetadata()], | 2703 createParser('void a = 0;'); |
| 2338 "void a = 0;", [ParserErrorCode.VOID_VARIABLE]); | 2704 CompilationUnitMember member = |
| 2705 parser.parseCompilationUnitMember(emptyCommentAndMetadata()); |
| 2706 expectNotNullIfNoErrors(member); |
| 2707 listener.assertErrorsWithCodes([ParserErrorCode.VOID_VARIABLE]); |
| 2339 } | 2708 } |
| 2340 | 2709 |
| 2341 void test_voidVariable_parseCompilationUnitMember_noInitializer() { | 2710 void test_voidVariable_parseCompilationUnitMember_noInitializer() { |
| 2342 parse3("parseCompilationUnitMember", <Object>[emptyCommentAndMetadata()], | 2711 createParser('void a;'); |
| 2343 "void a;", [ParserErrorCode.VOID_VARIABLE]); | 2712 CompilationUnitMember member = |
| 2713 parser.parseCompilationUnitMember(emptyCommentAndMetadata()); |
| 2714 expectNotNullIfNoErrors(member); |
| 2715 listener.assertErrorsWithCodes([ParserErrorCode.VOID_VARIABLE]); |
| 2344 } | 2716 } |
| 2345 | 2717 |
| 2346 void test_voidVariable_statement_initializer() { | 2718 void test_voidVariable_statement_initializer() { |
| 2347 ParserTestCase.parseStatement("void x = 0;", [ | 2719 ParserTestCase.parseStatement("void x = 0;", [ |
| 2348 ParserErrorCode.VOID_VARIABLE, | 2720 ParserErrorCode.VOID_VARIABLE, |
| 2349 ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE | 2721 ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE |
| 2350 ]); | 2722 ]); |
| 2351 } | 2723 } |
| 2352 | 2724 |
| 2353 void test_voidVariable_statement_noInitializer() { | 2725 void test_voidVariable_statement_noInitializer() { |
| 2354 ParserTestCase.parseStatement("void x;", [ | 2726 ParserTestCase.parseStatement("void x;", [ |
| 2355 ParserErrorCode.VOID_VARIABLE, | 2727 ParserErrorCode.VOID_VARIABLE, |
| 2356 ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE | 2728 ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE |
| 2357 ]); | 2729 ]); |
| 2358 } | 2730 } |
| 2359 | 2731 |
| 2360 void test_withBeforeExtends() { | 2732 void test_withBeforeExtends() { |
| 2361 ParserTestCase.parseCompilationUnit( | 2733 ParserTestCase.parseCompilationUnit( |
| 2362 "class A with B extends C {}", [ParserErrorCode.WITH_BEFORE_EXTENDS]); | 2734 "class A with B extends C {}", [ParserErrorCode.WITH_BEFORE_EXTENDS]); |
| 2363 } | 2735 } |
| 2364 | 2736 |
| 2365 void test_withWithoutExtends() { | 2737 void test_withWithoutExtends() { |
| 2366 parse3("parseClassDeclaration", <Object>[emptyCommentAndMetadata(), null], | 2738 createParser('class A with B, C {}'); |
| 2367 "class A with B, C {}", [ParserErrorCode.WITH_WITHOUT_EXTENDS]); | 2739 ClassDeclaration declaration = |
| 2740 parser.parseClassDeclaration(emptyCommentAndMetadata(), null); |
| 2741 expectNotNullIfNoErrors(declaration); |
| 2742 listener.assertErrorsWithCodes([ParserErrorCode.WITH_WITHOUT_EXTENDS]); |
| 2368 } | 2743 } |
| 2369 | 2744 |
| 2370 void test_wrongSeparatorForNamedParameter() { | 2745 void test_wrongSeparatorForNamedParameter() { |
| 2371 parse4("parseFormalParameterList", "(a, {b = 0})", | 2746 createParser('(a, {b = 0})'); |
| 2747 FormalParameterList list = parser.parseFormalParameterList(); |
| 2748 expectNotNullIfNoErrors(list); |
| 2749 listener.assertErrorsWithCodes( |
| 2372 [ParserErrorCode.WRONG_SEPARATOR_FOR_NAMED_PARAMETER]); | 2750 [ParserErrorCode.WRONG_SEPARATOR_FOR_NAMED_PARAMETER]); |
| 2373 } | 2751 } |
| 2374 | 2752 |
| 2375 void test_wrongSeparatorForPositionalParameter() { | 2753 void test_wrongSeparatorForPositionalParameter() { |
| 2376 parse4("parseFormalParameterList", "(a, [b : 0])", | 2754 createParser('(a, [b : 0])'); |
| 2755 FormalParameterList list = parser.parseFormalParameterList(); |
| 2756 expectNotNullIfNoErrors(list); |
| 2757 listener.assertErrorsWithCodes( |
| 2377 [ParserErrorCode.WRONG_SEPARATOR_FOR_POSITIONAL_PARAMETER]); | 2758 [ParserErrorCode.WRONG_SEPARATOR_FOR_POSITIONAL_PARAMETER]); |
| 2378 } | 2759 } |
| 2379 | 2760 |
| 2380 void test_wrongTerminatorForParameterGroup_named() { | 2761 void test_wrongTerminatorForParameterGroup_named() { |
| 2381 parse4("parseFormalParameterList", "(a, {b, c])", | 2762 createParser('(a, {b, c])'); |
| 2763 FormalParameterList list = parser.parseFormalParameterList(); |
| 2764 expectNotNullIfNoErrors(list); |
| 2765 listener.assertErrorsWithCodes( |
| 2382 [ParserErrorCode.WRONG_TERMINATOR_FOR_PARAMETER_GROUP]); | 2766 [ParserErrorCode.WRONG_TERMINATOR_FOR_PARAMETER_GROUP]); |
| 2383 } | 2767 } |
| 2384 | 2768 |
| 2385 void test_wrongTerminatorForParameterGroup_optional() { | 2769 void test_wrongTerminatorForParameterGroup_optional() { |
| 2386 parse4("parseFormalParameterList", "(a, [b, c})", | 2770 createParser('(a, [b, c})'); |
| 2771 FormalParameterList list = parser.parseFormalParameterList(); |
| 2772 expectNotNullIfNoErrors(list); |
| 2773 listener.assertErrorsWithCodes( |
| 2387 [ParserErrorCode.WRONG_TERMINATOR_FOR_PARAMETER_GROUP]); | 2774 [ParserErrorCode.WRONG_TERMINATOR_FOR_PARAMETER_GROUP]); |
| 2388 } | 2775 } |
| 2389 } | 2776 } |
| 2390 | 2777 |
| 2391 @reflectiveTest | 2778 @reflectiveTest |
| 2392 class NonErrorParserTest extends ParserTestCase { | 2779 class NonErrorParserTest extends ParserTestCase { |
| 2393 void test_constFactory_external() { | 2780 void test_constFactory_external() { |
| 2394 parse("parseClassMember", <Object>["C"], "external const factory C();"); | 2781 parse("parseClassMember", <Object>["C"], "external const factory C();"); |
| 2395 } | 2782 } |
| 2396 | 2783 |
| 2397 void test_staticMethod_notParsingFunctionBodies() { | 2784 void test_staticMethod_notParsingFunctionBodies() { |
| 2398 ParserTestCase.parseFunctionBodies = false; | 2785 ParserTestCase.parseFunctionBodies = false; |
| 2399 try { | 2786 try { |
| 2400 parse4("parseCompilationUnit", "class C { static void m() {} }"); | 2787 createParser('class C { static void m() {} }'); |
| 2788 CompilationUnit unit = parser.parseCompilationUnit2(); |
| 2789 expectNotNullIfNoErrors(unit); |
| 2790 listener.assertNoErrors(); |
| 2401 } finally { | 2791 } finally { |
| 2402 ParserTestCase.parseFunctionBodies = true; | 2792 ParserTestCase.parseFunctionBodies = true; |
| 2403 } | 2793 } |
| 2404 } | 2794 } |
| 2405 } | 2795 } |
| 2406 | 2796 |
| 2407 class ParserTestCase extends EngineTestCase { | 2797 class ParserTestCase extends EngineTestCase { |
| 2408 /** | 2798 /** |
| 2409 * An empty list of objects used as arguments to zero-argument methods. | 2799 * An empty list of objects used as arguments to zero-argument methods. |
| 2410 */ | 2800 */ |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2443 */ | 2833 */ |
| 2444 bool enableLazyAssignmentOperators = false; | 2834 bool enableLazyAssignmentOperators = false; |
| 2445 | 2835 |
| 2446 /** | 2836 /** |
| 2447 * A flag indicating whether the parser is to parse the non-nullable modifier | 2837 * A flag indicating whether the parser is to parse the non-nullable modifier |
| 2448 * in type names. | 2838 * in type names. |
| 2449 */ | 2839 */ |
| 2450 bool enableNnbd = false; | 2840 bool enableNnbd = false; |
| 2451 | 2841 |
| 2452 /** | 2842 /** |
| 2843 * The error listener to which scanner and parser errors will be reported. |
| 2844 * |
| 2845 * This field is typically initialized by invoking [createParser]. |
| 2846 */ |
| 2847 GatheringErrorListener listener; |
| 2848 |
| 2849 /** |
| 2850 * The parser used by the test. |
| 2851 * |
| 2852 * This field is typically initialized by invoking [createParser]. |
| 2853 */ |
| 2854 Parser parser; |
| 2855 |
| 2856 /** |
| 2453 * Return a CommentAndMetadata object with the given values that can be used f
or testing. | 2857 * Return a CommentAndMetadata object with the given values that can be used f
or testing. |
| 2454 * | 2858 * |
| 2455 * @param comment the comment to be wrapped in the object | 2859 * @param comment the comment to be wrapped in the object |
| 2456 * @param annotations the annotations to be wrapped in the object | 2860 * @param annotations the annotations to be wrapped in the object |
| 2457 * @return a CommentAndMetadata object that can be used for testing | 2861 * @return a CommentAndMetadata object that can be used for testing |
| 2458 */ | 2862 */ |
| 2459 CommentAndMetadata commentAndMetadata(Comment comment, | 2863 CommentAndMetadata commentAndMetadata(Comment comment, |
| 2460 [List<Annotation> annotations]) { | 2864 [List<Annotation> annotations]) { |
| 2461 return new CommentAndMetadata(comment, annotations); | 2865 return new CommentAndMetadata(comment, annotations); |
| 2462 } | 2866 } |
| 2463 | 2867 |
| 2464 /** | 2868 /** |
| 2869 * Create the [parser] and [listener] used by a test. The [parser] will be |
| 2870 * prepared to parse the tokens scanned from the given [content]. |
| 2871 */ |
| 2872 void createParser(String content) { |
| 2873 listener = new GatheringErrorListener(); |
| 2874 // |
| 2875 // Scan the source. |
| 2876 // |
| 2877 TestSource source = new TestSource(); |
| 2878 CharacterReader reader = new CharSequenceReader(content); |
| 2879 Scanner scanner = new Scanner(source, reader, listener); |
| 2880 scanner.scanGenericMethodComments = enableGenericMethodComments; |
| 2881 scanner.scanLazyAssignmentOperators = enableLazyAssignmentOperators; |
| 2882 Token tokenStream = scanner.tokenize(); |
| 2883 listener.setLineInfo(source, scanner.lineStarts); |
| 2884 // |
| 2885 // Create and initialize the parser. |
| 2886 // |
| 2887 parser = new Parser(source, listener); |
| 2888 parser.enableAssertInitializer = enableAssertInitializer; |
| 2889 parser.parseAsync = parseAsync; |
| 2890 parser.parseGenericMethods = enableGenericMethods; |
| 2891 parser.parseGenericMethodComments = enableGenericMethodComments; |
| 2892 parser.parseFunctionBodies = parseFunctionBodies; |
| 2893 parser.enableNnbd = enableNnbd; |
| 2894 parser.currentToken = tokenStream; |
| 2895 } |
| 2896 |
| 2897 /** |
| 2465 * Return an empty CommentAndMetadata object that can be used for testing. | 2898 * Return an empty CommentAndMetadata object that can be used for testing. |
| 2466 * | 2899 * |
| 2467 * @return an empty CommentAndMetadata object that can be used for testing | 2900 * @return an empty CommentAndMetadata object that can be used for testing |
| 2468 */ | 2901 */ |
| 2469 CommentAndMetadata emptyCommentAndMetadata() => | 2902 CommentAndMetadata emptyCommentAndMetadata() => |
| 2470 new CommentAndMetadata(null, null); | 2903 new CommentAndMetadata(null, null); |
| 2471 | 2904 |
| 2905 void expectNotNullIfNoErrors(Object result) { |
| 2906 if (!listener.hasErrors) { |
| 2907 expect(result, isNotNull); |
| 2908 } |
| 2909 } |
| 2910 |
| 2472 /** | 2911 /** |
| 2473 * Invoke a method in [Parser]. The method is assumed to have the given number
and type of | 2912 * Invoke a method in [Parser]. The method is assumed to have the given number
and type of |
| 2474 * parameters and will be invoked with the given arguments. | 2913 * parameters and will be invoked with the given arguments. |
| 2475 * | 2914 * |
| 2476 * The given source is scanned and the parser is initialized to start with the
first token in the | 2915 * The given source is scanned and the parser is initialized to start with the
first token in the |
| 2477 * source before the method is invoked. | 2916 * source before the method is invoked. |
| 2478 * | 2917 * |
| 2479 * @param methodName the name of the method that should be invoked | 2918 * @param methodName the name of the method that should be invoked |
| 2480 * @param objects the values of the arguments to the method | 2919 * @param objects the values of the arguments to the method |
| 2481 * @param source the source to be processed by the parse method | 2920 * @param source the source to be processed by the parse method |
| 2482 * @param listener the error listener that will be used for both scanning and
parsing | |
| 2483 * @return the result of invoking the method | 2921 * @return the result of invoking the method |
| 2484 * @throws Exception if the method could not be invoked or throws an exception | 2922 * @throws Exception if the method could not be invoked or throws an exception |
| 2485 * @throws AssertionFailedError if the result is `null` or the errors produced
while | 2923 * @throws AssertionFailedError if the result is `null` or the errors produced
while |
| 2486 * scanning and parsing the source do not match the expected errors | 2924 * scanning and parsing the source do not match the expected errors |
| 2487 */ | 2925 */ |
| 2488 Object invokeParserMethod(String methodName, List<Object> objects, | 2926 Object invokeParserMethod( |
| 2489 String source, GatheringErrorListener listener) { | 2927 String methodName, List<Object> objects, String source) { |
| 2490 // | 2928 createParser(source); |
| 2491 // Scan the source. | 2929 Object result = invokeParserMethodImpl(parser, methodName, objects); |
| 2492 // | 2930 expectNotNullIfNoErrors(result); |
| 2493 Scanner scanner = | |
| 2494 new Scanner(null, new CharSequenceReader(source), listener); | |
| 2495 scanner.scanGenericMethodComments = enableGenericMethodComments; | |
| 2496 scanner.scanLazyAssignmentOperators = enableLazyAssignmentOperators; | |
| 2497 Token tokenStream = scanner.tokenize(); | |
| 2498 listener.setLineInfo(new TestSource(), scanner.lineStarts); | |
| 2499 // | |
| 2500 // Parse the source. | |
| 2501 // | |
| 2502 Parser parser = createParser(listener); | |
| 2503 parser.enableAssertInitializer = enableAssertInitializer; | |
| 2504 parser.parseAsync = parseAsync; | |
| 2505 parser.parseGenericMethods = enableGenericMethods; | |
| 2506 parser.parseGenericMethodComments = enableGenericMethodComments; | |
| 2507 parser.parseFunctionBodies = parseFunctionBodies; | |
| 2508 parser.enableNnbd = enableNnbd; | |
| 2509 Object result = | |
| 2510 invokeParserMethodImpl(parser, methodName, objects, tokenStream); | |
| 2511 // | |
| 2512 // Partially test the results. | |
| 2513 // | |
| 2514 if (!listener.hasErrors) { | |
| 2515 expect(result, isNotNull); | |
| 2516 } | |
| 2517 return result; | 2931 return result; |
| 2518 } | 2932 } |
| 2519 | 2933 |
| 2520 /** | 2934 /** |
| 2521 * Invoke a method in [Parser]. The method is assumed to have no arguments. | |
| 2522 * | |
| 2523 * The given source is scanned and the parser is initialized to start with the
first token in the | |
| 2524 * source before the method is invoked. | |
| 2525 * | |
| 2526 * @param methodName the name of the method that should be invoked | |
| 2527 * @param source the source to be processed by the parse method | |
| 2528 * @param listener the error listener that will be used for both scanning and
parsing | |
| 2529 * @return the result of invoking the method | |
| 2530 * @throws Exception if the method could not be invoked or throws an exception | |
| 2531 * @throws AssertionFailedError if the result is `null` or the errors produced
while | |
| 2532 * scanning and parsing the source do not match the expected errors | |
| 2533 */ | |
| 2534 Object invokeParserMethod2( | |
| 2535 String methodName, String source, GatheringErrorListener listener) => | |
| 2536 invokeParserMethod(methodName, _EMPTY_ARGUMENTS, source, listener); | |
| 2537 | |
| 2538 /** | |
| 2539 * Invoke a parse method in [Parser]. The method is assumed to have the given
number and | 2935 * Invoke a parse method in [Parser]. The method is assumed to have the given
number and |
| 2540 * type of parameters and will be invoked with the given arguments. | |
| 2541 * | |
| 2542 * The given source is scanned and the parser is initialized to start with the
first token in the | |
| 2543 * source before the parse method is invoked. | |
| 2544 * | |
| 2545 * @param methodName the name of the parse method that should be invoked to pa
rse the source | |
| 2546 * @param objects the values of the arguments to the method | |
| 2547 * @param source the source to be parsed by the parse method | |
| 2548 * @return the result of invoking the method | |
| 2549 * @throws Exception if the method could not be invoked or throws an exception | |
| 2550 * @throws AssertionFailedError if the result is `null` or if any errors are p
roduced | |
| 2551 */ | |
| 2552 Object parse(String methodName, List<Object> objects, String source) => | |
| 2553 parse2(methodName, objects, source); | |
| 2554 | |
| 2555 /** | |
| 2556 * Invoke a parse method in [Parser]. The method is assumed to have the given
number and | |
| 2557 * type of parameters and will be invoked with the given arguments. | 2936 * type of parameters and will be invoked with the given arguments. |
| 2558 * | 2937 * |
| 2559 * The given source is scanned and the parser is initialized to start with the
first token in the | 2938 * The given source is scanned and the parser is initialized to start with the
first token in the |
| 2560 * source before the parse method is invoked. | 2939 * source before the parse method is invoked. |
| 2561 * | 2940 * |
| 2562 * @param methodName the name of the parse method that should be invoked to pa
rse the source | 2941 * @param methodName the name of the parse method that should be invoked to pa
rse the source |
| 2563 * @param objects the values of the arguments to the method | 2942 * @param objects the values of the arguments to the method |
| 2564 * @param source the source to be parsed by the parse method | 2943 * @param source the source to be parsed by the parse method |
| 2565 * @param errors the errors that should be generated | 2944 * @param errors the errors that should be generated |
| 2566 * @return the result of invoking the method | 2945 * @return the result of invoking the method |
| 2567 * @throws Exception if the method could not be invoked or throws an exception | 2946 * @throws Exception if the method could not be invoked or throws an exception |
| 2568 * @throws AssertionFailedError if the result is `null` or the errors produced
while | 2947 * @throws AssertionFailedError if the result is `null` or the errors produced
while |
| 2569 * scanning and parsing the source do not match the expected errors | 2948 * scanning and parsing the source do not match the expected errors |
| 2570 */ | 2949 */ |
| 2571 Object parse2(String methodName, List<Object> objects, String source, | 2950 Object parse(String methodName, List<Object> objects, String source, |
| 2572 [List<AnalysisError> errors = AnalysisError.NO_ERRORS]) { | 2951 [List<AnalysisError> errors = AnalysisError.NO_ERRORS]) { |
| 2573 GatheringErrorListener listener = new GatheringErrorListener(); | 2952 Object result = invokeParserMethod(methodName, objects, source); |
| 2574 Object result = invokeParserMethod(methodName, objects, source, listener); | |
| 2575 listener.assertErrors(errors); | 2953 listener.assertErrors(errors); |
| 2576 return result; | 2954 return result; |
| 2577 } | 2955 } |
| 2578 | 2956 |
| 2579 /** | 2957 /** |
| 2580 * Invoke a parse method in [Parser]. The method is assumed to have the given
number and | 2958 * Invoke a parse method in [Parser]. The method is assumed to have no argumen
ts. |
| 2581 * type of parameters and will be invoked with the given arguments. | |
| 2582 * | 2959 * |
| 2583 * The given source is scanned and the parser is initialized to start with the
first token in the | 2960 * The given source is scanned and the parser is initialized to start with the
first token in the |
| 2584 * source before the parse method is invoked. | 2961 * source before the parse method is invoked. |
| 2585 * | 2962 * |
| 2586 * @param methodName the name of the parse method that should be invoked to pa
rse the source | 2963 * @param methodName the name of the parse method that should be invoked to pa
rse the source |
| 2587 * @param objects the values of the arguments to the method | |
| 2588 * @param source the source to be parsed by the parse method | 2964 * @param source the source to be parsed by the parse method |
| 2589 * @param errorCodes the error codes of the errors that should be generated | 2965 * @param errorCodes the error codes of the errors that should be generated |
| 2590 * @return the result of invoking the method | 2966 * @return the result of invoking the method |
| 2591 * @throws Exception if the method could not be invoked or throws an exception | 2967 * @throws Exception if the method could not be invoked or throws an exception |
| 2592 * @throws AssertionFailedError if the result is `null` or the errors produced
while | 2968 * @throws AssertionFailedError if the result is `null` or the errors produced
while |
| 2593 * scanning and parsing the source do not match the expected errors | 2969 * scanning and parsing the source do not match the expected errors |
| 2594 */ | 2970 */ |
| 2595 Object parse3(String methodName, List<Object> objects, String source, | |
| 2596 [List<ErrorCode> errorCodes = ErrorCode.EMPTY_LIST]) { | |
| 2597 GatheringErrorListener listener = new GatheringErrorListener(); | |
| 2598 Object result = invokeParserMethod(methodName, objects, source, listener); | |
| 2599 listener.assertErrorsWithCodes(errorCodes); | |
| 2600 return result; | |
| 2601 } | |
| 2602 | |
| 2603 /** | |
| 2604 * Invoke a parse method in [Parser]. The method is assumed to have no argumen
ts. | |
| 2605 * | |
| 2606 * The given source is scanned and the parser is initialized to start with the
first token in the | |
| 2607 * source before the parse method is invoked. | |
| 2608 * | |
| 2609 * @param methodName the name of the parse method that should be invoked to pa
rse the source | |
| 2610 * @param source the source to be parsed by the parse method | |
| 2611 * @param errorCodes the error codes of the errors that should be generated | |
| 2612 * @return the result of invoking the method | |
| 2613 * @throws Exception if the method could not be invoked or throws an exception | |
| 2614 * @throws AssertionFailedError if the result is `null` or the errors produced
while | |
| 2615 * scanning and parsing the source do not match the expected errors | |
| 2616 */ | |
| 2617 Object parse4(String methodName, String source, | 2971 Object parse4(String methodName, String source, |
| 2618 [List<ErrorCode> errorCodes = ErrorCode.EMPTY_LIST]) => | 2972 [List<ErrorCode> errorCodes = ErrorCode.EMPTY_LIST]) { |
| 2619 parse3(methodName, _EMPTY_ARGUMENTS, source, errorCodes); | 2973 Object result = invokeParserMethod(methodName, _EMPTY_ARGUMENTS, source); |
| 2974 listener.assertErrorsWithCodes(errorCodes); |
| 2975 return result; |
| 2976 } |
| 2620 | 2977 |
| 2621 /** | 2978 /** |
| 2622 * Parse the given [source] as a compilation unit. Throw an exception if the | 2979 * Parse the given [source] as a compilation unit. Throw an exception if the |
| 2623 * source could not be parsed, if the compilation errors in the source do not | 2980 * source could not be parsed, if the compilation errors in the source do not |
| 2624 * match those that are expected, or if the result would have been `null`. | 2981 * match those that are expected, or if the result would have been `null`. |
| 2625 */ | 2982 */ |
| 2626 CompilationUnit parseCompilationUnitWithOptions(String source, | 2983 CompilationUnit parseCompilationUnitWithOptions(String source, |
| 2627 [List<ErrorCode> errorCodes = ErrorCode.EMPTY_LIST]) { | 2984 [List<ErrorCode> errorCodes = ErrorCode.EMPTY_LIST]) { |
| 2628 GatheringErrorListener listener = new GatheringErrorListener(); | 2985 createParser(source); |
| 2629 Scanner scanner = | 2986 CompilationUnit unit = parser.parseCompilationUnit2(); |
| 2630 new Scanner(null, new CharSequenceReader(source), listener); | |
| 2631 listener.setLineInfo(new TestSource(), scanner.lineStarts); | |
| 2632 Token token = scanner.tokenize(); | |
| 2633 Parser parser = createParser(listener); | |
| 2634 parser.enableAssertInitializer = enableAssertInitializer; | |
| 2635 parser.parseAsync = parseAsync; | |
| 2636 parser.parseFunctionBodies = parseFunctionBodies; | |
| 2637 parser.parseGenericMethods = enableGenericMethods; | |
| 2638 parser.parseGenericMethodComments = enableGenericMethodComments; | |
| 2639 parser.enableNnbd = enableNnbd; | |
| 2640 CompilationUnit unit = parser.parseCompilationUnit(token); | |
| 2641 expect(unit, isNotNull); | 2987 expect(unit, isNotNull); |
| 2642 listener.assertErrorsWithCodes(errorCodes); | 2988 listener.assertErrorsWithCodes(errorCodes); |
| 2643 return unit; | 2989 return unit; |
| 2644 } | 2990 } |
| 2645 | 2991 |
| 2646 /** | 2992 /** |
| 2647 * Parse the given source as an expression. | 2993 * Parse the given source as an expression. |
| 2648 * | 2994 * |
| 2649 * @param source the source to be parsed | 2995 * @param source the source to be parsed |
| 2650 * @param errorCodes the error codes of the errors that are expected to be fou
nd | 2996 * @param errorCodes the error codes of the errors that are expected to be fou
nd |
| 2651 * @return the expression that was parsed | 2997 * @return the expression that was parsed |
| 2652 * @throws Exception if the source could not be parsed, if the compilation err
ors in the source do | 2998 * @throws Exception if the source could not be parsed, if the compilation err
ors in the source do |
| 2653 * not match those that are expected, or if the result would have be
en `null` | 2999 * not match those that are expected, or if the result would have be
en `null` |
| 2654 */ | 3000 */ |
| 2655 Expression parseExpression(String source, | 3001 Expression parseExpression(String source, |
| 2656 [List<ErrorCode> errorCodes = ErrorCode.EMPTY_LIST]) { | 3002 [List<ErrorCode> errorCodes = ErrorCode.EMPTY_LIST]) { |
| 2657 GatheringErrorListener listener = new GatheringErrorListener(); | 3003 createParser(source); |
| 2658 Scanner scanner = | 3004 Expression expression = parser.parseExpression2(); |
| 2659 new Scanner(null, new CharSequenceReader(source), listener); | |
| 2660 scanner.scanGenericMethodComments = enableGenericMethodComments; | |
| 2661 listener.setLineInfo(new TestSource(), scanner.lineStarts); | |
| 2662 Token token = scanner.tokenize(); | |
| 2663 Parser parser = createParser(listener); | |
| 2664 parser.parseGenericMethods = enableGenericMethods; | |
| 2665 parser.parseGenericMethodComments = enableGenericMethodComments; | |
| 2666 parser.enableNnbd = enableNnbd; | |
| 2667 Expression expression = parser.parseExpression(token); | |
| 2668 expect(expression, isNotNull); | 3005 expect(expression, isNotNull); |
| 2669 listener.assertErrorsWithCodes(errorCodes); | 3006 listener.assertErrorsWithCodes(errorCodes); |
| 2670 return expression; | 3007 return expression; |
| 2671 } | 3008 } |
| 2672 | 3009 |
| 2673 @override | 3010 @override |
| 2674 void setUp() { | 3011 void setUp() { |
| 2675 super.setUp(); | 3012 super.setUp(); |
| 2676 parseFunctionBodies = true; | 3013 parseFunctionBodies = true; |
| 2677 } | 3014 } |
| 2678 | 3015 |
| 2679 /** | 3016 /** |
| 2680 * Create a parser. | |
| 2681 * | |
| 2682 * @param listener the listener to be passed to the parser | |
| 2683 * @return the parser that was created | |
| 2684 */ | |
| 2685 static Parser createParser(GatheringErrorListener listener) { | |
| 2686 return new Parser(null, listener); | |
| 2687 } | |
| 2688 | |
| 2689 /** | |
| 2690 * Parse the given source as a compilation unit. | 3017 * Parse the given source as a compilation unit. |
| 2691 * | 3018 * |
| 2692 * @param source the source to be parsed | 3019 * @param source the source to be parsed |
| 2693 * @param errorCodes the error codes of the errors that are expected to be fou
nd | 3020 * @param errorCodes the error codes of the errors that are expected to be fou
nd |
| 2694 * @return the compilation unit that was parsed | 3021 * @return the compilation unit that was parsed |
| 2695 * @throws Exception if the source could not be parsed, if the compilation err
ors in the source do | 3022 * @throws Exception if the source could not be parsed, if the compilation err
ors in the source do |
| 2696 * not match those that are expected, or if the result would have be
en `null` | 3023 * not match those that are expected, or if the result would have be
en `null` |
| 2697 */ | 3024 */ |
| 2698 static CompilationUnit parseCompilationUnit(String source, | 3025 static CompilationUnit parseCompilationUnit(String source, |
| 2699 [List<ErrorCode> errorCodes = ErrorCode.EMPTY_LIST]) { | 3026 [List<ErrorCode> errorCodes = ErrorCode.EMPTY_LIST]) { |
| 2700 GatheringErrorListener listener = new GatheringErrorListener(); | 3027 GatheringErrorListener listener = new GatheringErrorListener(); |
| 2701 Scanner scanner = | 3028 Scanner scanner = |
| 2702 new Scanner(null, new CharSequenceReader(source), listener); | 3029 new Scanner(null, new CharSequenceReader(source), listener); |
| 2703 listener.setLineInfo(new TestSource(), scanner.lineStarts); | 3030 listener.setLineInfo(new TestSource(), scanner.lineStarts); |
| 2704 Token token = scanner.tokenize(); | 3031 Token token = scanner.tokenize(); |
| 2705 Parser parser = createParser(listener); | 3032 Parser parser = new Parser(null, listener); |
| 2706 CompilationUnit unit = parser.parseCompilationUnit(token); | 3033 CompilationUnit unit = parser.parseCompilationUnit(token); |
| 2707 expect(unit, isNotNull); | 3034 expect(unit, isNotNull); |
| 2708 listener.assertErrorsWithCodes(errorCodes); | 3035 listener.assertErrorsWithCodes(errorCodes); |
| 2709 return unit; | 3036 return unit; |
| 2710 } | 3037 } |
| 2711 | 3038 |
| 2712 /** | 3039 /** |
| 2713 * Parse the given [source] as a statement. The [errorCodes] are the error | 3040 * Parse the given [source] as a statement. The [errorCodes] are the error |
| 2714 * codes of the errors that are expected to be found. If | 3041 * codes of the errors that are expected to be found. If |
| 2715 * [enableLazyAssignmentOperators] is `true`, then lazy assignment operators | 3042 * [enableLazyAssignmentOperators] is `true`, then lazy assignment operators |
| 2716 * should be enabled. | 3043 * should be enabled. |
| 2717 */ | 3044 */ |
| 2718 static Statement parseStatement(String source, | 3045 static Statement parseStatement(String source, |
| 2719 [List<ErrorCode> errorCodes = ErrorCode.EMPTY_LIST, | 3046 [List<ErrorCode> errorCodes = ErrorCode.EMPTY_LIST, |
| 2720 bool enableLazyAssignmentOperators]) { | 3047 bool enableLazyAssignmentOperators]) { |
| 2721 GatheringErrorListener listener = new GatheringErrorListener(); | 3048 GatheringErrorListener listener = new GatheringErrorListener(); |
| 2722 Scanner scanner = | 3049 Scanner scanner = |
| 2723 new Scanner(null, new CharSequenceReader(source), listener); | 3050 new Scanner(null, new CharSequenceReader(source), listener); |
| 2724 scanner.scanLazyAssignmentOperators = enableLazyAssignmentOperators; | 3051 scanner.scanLazyAssignmentOperators = enableLazyAssignmentOperators; |
| 2725 listener.setLineInfo(new TestSource(), scanner.lineStarts); | 3052 listener.setLineInfo(new TestSource(), scanner.lineStarts); |
| 2726 Token token = scanner.tokenize(); | 3053 Token token = scanner.tokenize(); |
| 2727 Parser parser = createParser(listener); | 3054 Parser parser = new Parser(null, listener); |
| 2728 Statement statement = parser.parseStatement(token); | 3055 Statement statement = parser.parseStatement(token); |
| 2729 expect(statement, isNotNull); | 3056 expect(statement, isNotNull); |
| 2730 listener.assertErrorsWithCodes(errorCodes); | 3057 listener.assertErrorsWithCodes(errorCodes); |
| 2731 return statement; | 3058 return statement; |
| 2732 } | 3059 } |
| 2733 | 3060 |
| 2734 /** | 3061 /** |
| 2735 * Parse the given source as a sequence of statements. | 3062 * Parse the given source as a sequence of statements. |
| 2736 * | 3063 * |
| 2737 * @param source the source to be parsed | 3064 * @param source the source to be parsed |
| 2738 * @param expectedCount the number of statements that are expected | 3065 * @param expectedCount the number of statements that are expected |
| 2739 * @param errorCodes the error codes of the errors that are expected to be fou
nd | 3066 * @param errorCodes the error codes of the errors that are expected to be fou
nd |
| 2740 * @return the statements that were parsed | 3067 * @return the statements that were parsed |
| 2741 * @throws Exception if the source could not be parsed, if the number of state
ments does not match | 3068 * @throws Exception if the source could not be parsed, if the number of state
ments does not match |
| 2742 * the expected count, if the compilation errors in the source do no
t match those that | 3069 * the expected count, if the compilation errors in the source do no
t match those that |
| 2743 * are expected, or if the result would have been `null` | 3070 * are expected, or if the result would have been `null` |
| 2744 */ | 3071 */ |
| 2745 static List<Statement> parseStatements(String source, int expectedCount, | 3072 static List<Statement> parseStatements(String source, int expectedCount, |
| 2746 [List<ErrorCode> errorCodes = ErrorCode.EMPTY_LIST]) { | 3073 [List<ErrorCode> errorCodes = ErrorCode.EMPTY_LIST]) { |
| 2747 GatheringErrorListener listener = new GatheringErrorListener(); | 3074 GatheringErrorListener listener = new GatheringErrorListener(); |
| 2748 Scanner scanner = | 3075 Scanner scanner = |
| 2749 new Scanner(null, new CharSequenceReader(source), listener); | 3076 new Scanner(null, new CharSequenceReader(source), listener); |
| 2750 listener.setLineInfo(new TestSource(), scanner.lineStarts); | 3077 listener.setLineInfo(new TestSource(), scanner.lineStarts); |
| 2751 Token token = scanner.tokenize(); | 3078 Token token = scanner.tokenize(); |
| 2752 Parser parser = createParser(listener); | 3079 Parser parser = new Parser(null, listener); |
| 2753 List<Statement> statements = parser.parseStatements(token); | 3080 List<Statement> statements = parser.parseStatements(token); |
| 2754 expect(statements, hasLength(expectedCount)); | 3081 expect(statements, hasLength(expectedCount)); |
| 2755 listener.assertErrorsWithCodes(errorCodes); | 3082 listener.assertErrorsWithCodes(errorCodes); |
| 2756 return statements; | 3083 return statements; |
| 2757 } | 3084 } |
| 2758 } | 3085 } |
| 2759 | 3086 |
| 2760 /** | 3087 /** |
| 2761 * The class `RecoveryParserTest` defines parser tests that test the parsing of
invalid code | 3088 * The class `RecoveryParserTest` defines parser tests that test the parsing of
invalid code |
| 2762 * sequences to ensure that the correct recovery steps are taken in the parser. | 3089 * sequences to ensure that the correct recovery steps are taken in the parser. |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3086 | 3413 |
| 3087 void test_classTypeAlias_withBody() { | 3414 void test_classTypeAlias_withBody() { |
| 3088 ParserTestCase.parseCompilationUnit( | 3415 ParserTestCase.parseCompilationUnit( |
| 3089 r''' | 3416 r''' |
| 3090 class A {} | 3417 class A {} |
| 3091 class B = Object with A {}''', | 3418 class B = Object with A {}''', |
| 3092 [ParserErrorCode.EXPECTED_TOKEN]); | 3419 [ParserErrorCode.EXPECTED_TOKEN]); |
| 3093 } | 3420 } |
| 3094 | 3421 |
| 3095 void test_conditionalExpression_missingElse() { | 3422 void test_conditionalExpression_missingElse() { |
| 3096 ConditionalExpression expression = parse4("parseConditionalExpression", | 3423 createParser('x ? y :'); |
| 3097 "x ? y :", [ParserErrorCode.MISSING_IDENTIFIER]); | 3424 Expression expression = parser.parseConditionalExpression(); |
| 3098 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 3425 expectNotNullIfNoErrors(expression); |
| 3099 SimpleIdentifier, expression.elseExpression); | 3426 listener.assertErrorsWithCodes([ParserErrorCode.MISSING_IDENTIFIER]); |
| 3100 expect(expression.elseExpression.isSynthetic, isTrue); | 3427 expect(expression, new isInstanceOf<ConditionalExpression>()); |
| 3428 ConditionalExpression conditionalExpression = expression; |
| 3429 expect(conditionalExpression.elseExpression, |
| 3430 new isInstanceOf<SimpleIdentifier>()); |
| 3431 expect(conditionalExpression.elseExpression.isSynthetic, isTrue); |
| 3101 } | 3432 } |
| 3102 | 3433 |
| 3103 void test_conditionalExpression_missingThen() { | 3434 void test_conditionalExpression_missingThen() { |
| 3104 ConditionalExpression expression = parse4("parseConditionalExpression", | 3435 createParser('x ? : z'); |
| 3105 "x ? : z", [ParserErrorCode.MISSING_IDENTIFIER]); | 3436 Expression expression = parser.parseConditionalExpression(); |
| 3106 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 3437 expectNotNullIfNoErrors(expression); |
| 3107 SimpleIdentifier, expression.thenExpression); | 3438 listener.assertErrorsWithCodes([ParserErrorCode.MISSING_IDENTIFIER]); |
| 3108 expect(expression.thenExpression.isSynthetic, isTrue); | 3439 expect(expression, new isInstanceOf<ConditionalExpression>()); |
| 3440 ConditionalExpression conditionalExpression = expression; |
| 3441 expect(conditionalExpression.thenExpression, |
| 3442 new isInstanceOf<SimpleIdentifier>()); |
| 3443 expect(conditionalExpression.thenExpression.isSynthetic, isTrue); |
| 3109 } | 3444 } |
| 3110 | 3445 |
| 3111 void test_declarationBeforeDirective() { | 3446 void test_declarationBeforeDirective() { |
| 3112 CompilationUnit unit = ParserTestCase.parseCompilationUnit( | 3447 CompilationUnit unit = ParserTestCase.parseCompilationUnit( |
| 3113 "class foo { } import 'bar.dart';", | 3448 "class foo { } import 'bar.dart';", |
| 3114 [ParserErrorCode.DIRECTIVE_AFTER_DECLARATION]); | 3449 [ParserErrorCode.DIRECTIVE_AFTER_DECLARATION]); |
| 3115 expect(unit.directives, hasLength(1)); | 3450 expect(unit.directives, hasLength(1)); |
| 3116 expect(unit.declarations, hasLength(1)); | 3451 expect(unit.declarations, hasLength(1)); |
| 3117 ClassDeclaration classDecl = unit.childEntities.first; | 3452 ClassDeclaration classDecl = unit.childEntities.first; |
| 3118 expect(classDecl, isNotNull); | 3453 expect(classDecl, isNotNull); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3180 BinaryExpression expression = parseExpression("super == ==", [ | 3515 BinaryExpression expression = parseExpression("super == ==", [ |
| 3181 ParserErrorCode.MISSING_IDENTIFIER, | 3516 ParserErrorCode.MISSING_IDENTIFIER, |
| 3182 ParserErrorCode.MISSING_IDENTIFIER, | 3517 ParserErrorCode.MISSING_IDENTIFIER, |
| 3183 ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND | 3518 ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND |
| 3184 ]); | 3519 ]); |
| 3185 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | 3520 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, |
| 3186 BinaryExpression, expression.leftOperand); | 3521 BinaryExpression, expression.leftOperand); |
| 3187 } | 3522 } |
| 3188 | 3523 |
| 3189 void test_expressionList_multiple_end() { | 3524 void test_expressionList_multiple_end() { |
| 3190 List<Expression> result = parse4("parseExpressionList", ", 2, 3, 4", | 3525 createParser(', 2, 3, 4'); |
| 3191 [ParserErrorCode.MISSING_IDENTIFIER]) as List<Expression>; | 3526 List<Expression> result = parser.parseExpressionList(); |
| 3527 expectNotNullIfNoErrors(result); |
| 3528 listener.assertErrorsWithCodes([ParserErrorCode.MISSING_IDENTIFIER]); |
| 3192 expect(result, hasLength(4)); | 3529 expect(result, hasLength(4)); |
| 3193 Expression syntheticExpression = result[0]; | 3530 Expression syntheticExpression = result[0]; |
| 3194 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 3531 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
| 3195 SimpleIdentifier, syntheticExpression); | 3532 SimpleIdentifier, syntheticExpression); |
| 3196 expect(syntheticExpression.isSynthetic, isTrue); | 3533 expect(syntheticExpression.isSynthetic, isTrue); |
| 3197 } | 3534 } |
| 3198 | 3535 |
| 3199 void test_expressionList_multiple_middle() { | 3536 void test_expressionList_multiple_middle() { |
| 3200 List<Expression> result = parse4("parseExpressionList", "1, 2, , 4", | 3537 createParser('1, 2, , 4'); |
| 3201 [ParserErrorCode.MISSING_IDENTIFIER]) as List<Expression>; | 3538 List<Expression> result = parser.parseExpressionList(); |
| 3539 expectNotNullIfNoErrors(result); |
| 3540 listener.assertErrorsWithCodes([ParserErrorCode.MISSING_IDENTIFIER]); |
| 3202 expect(result, hasLength(4)); | 3541 expect(result, hasLength(4)); |
| 3203 Expression syntheticExpression = result[2]; | 3542 Expression syntheticExpression = result[2]; |
| 3204 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 3543 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
| 3205 SimpleIdentifier, syntheticExpression); | 3544 SimpleIdentifier, syntheticExpression); |
| 3206 expect(syntheticExpression.isSynthetic, isTrue); | 3545 expect(syntheticExpression.isSynthetic, isTrue); |
| 3207 } | 3546 } |
| 3208 | 3547 |
| 3209 void test_expressionList_multiple_start() { | 3548 void test_expressionList_multiple_start() { |
| 3210 List<Expression> result = parse4("parseExpressionList", "1, 2, 3,", | 3549 createParser('1, 2, 3,'); |
| 3211 [ParserErrorCode.MISSING_IDENTIFIER]) as List<Expression>; | 3550 List<Expression> result = parser.parseExpressionList(); |
| 3551 expectNotNullIfNoErrors(result); |
| 3552 listener.assertErrorsWithCodes([ParserErrorCode.MISSING_IDENTIFIER]); |
| 3212 expect(result, hasLength(4)); | 3553 expect(result, hasLength(4)); |
| 3213 Expression syntheticExpression = result[3]; | 3554 Expression syntheticExpression = result[3]; |
| 3214 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 3555 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
| 3215 SimpleIdentifier, syntheticExpression); | 3556 SimpleIdentifier, syntheticExpression); |
| 3216 expect(syntheticExpression.isSynthetic, isTrue); | 3557 expect(syntheticExpression.isSynthetic, isTrue); |
| 3217 } | 3558 } |
| 3218 | 3559 |
| 3219 void test_functionExpression_in_ConstructorFieldInitializer() { | 3560 void test_functionExpression_in_ConstructorFieldInitializer() { |
| 3220 CompilationUnit unit = ParserTestCase.parseCompilationUnit( | 3561 CompilationUnit unit = ParserTestCase.parseCompilationUnit( |
| 3221 "class A { A() : a = (){}; var v; }", | 3562 "class A { A() : a = (){}; var v; }", |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3262 expect(unit.directives, hasLength(1)); | 3603 expect(unit.directives, hasLength(1)); |
| 3263 expect(unit.declarations, hasLength(0)); | 3604 expect(unit.declarations, hasLength(0)); |
| 3264 } | 3605 } |
| 3265 | 3606 |
| 3266 void test_incomplete_conditionalExpression() { | 3607 void test_incomplete_conditionalExpression() { |
| 3267 parseExpression("x ? 0", | 3608 parseExpression("x ? 0", |
| 3268 [ParserErrorCode.EXPECTED_TOKEN, ParserErrorCode.MISSING_IDENTIFIER]); | 3609 [ParserErrorCode.EXPECTED_TOKEN, ParserErrorCode.MISSING_IDENTIFIER]); |
| 3269 } | 3610 } |
| 3270 | 3611 |
| 3271 void test_incomplete_constructorInitializers_empty() { | 3612 void test_incomplete_constructorInitializers_empty() { |
| 3272 parse3("parseClassMember", ["C"], "C() : {}", | 3613 createParser('C() : {}'); |
| 3273 [ParserErrorCode.MISSING_INITIALIZER]); | 3614 ClassMember member = parser.parseClassMember('C'); |
| 3615 expectNotNullIfNoErrors(member); |
| 3616 listener.assertErrorsWithCodes([ParserErrorCode.MISSING_INITIALIZER]); |
| 3274 } | 3617 } |
| 3275 | 3618 |
| 3276 void test_incomplete_constructorInitializers_missingEquals() { | 3619 void test_incomplete_constructorInitializers_missingEquals() { |
| 3277 ClassMember member = parse3("parseClassMember", ["C"], "C() : x(3) {}", | 3620 createParser('C() : x(3) {}'); |
| 3621 ClassMember member = parser.parseClassMember('C'); |
| 3622 expectNotNullIfNoErrors(member); |
| 3623 listener.assertErrorsWithCodes( |
| 3278 [ParserErrorCode.MISSING_ASSIGNMENT_IN_INITIALIZER]); | 3624 [ParserErrorCode.MISSING_ASSIGNMENT_IN_INITIALIZER]); |
| 3279 expect(member, new isInstanceOf<ConstructorDeclaration>()); | 3625 expect(member, new isInstanceOf<ConstructorDeclaration>()); |
| 3280 NodeList<ConstructorInitializer> initializers = | 3626 NodeList<ConstructorInitializer> initializers = |
| 3281 (member as ConstructorDeclaration).initializers; | 3627 (member as ConstructorDeclaration).initializers; |
| 3282 expect(initializers, hasLength(1)); | 3628 expect(initializers, hasLength(1)); |
| 3283 ConstructorInitializer initializer = initializers[0]; | 3629 ConstructorInitializer initializer = initializers[0]; |
| 3284 expect(initializer, new isInstanceOf<ConstructorFieldInitializer>()); | 3630 expect(initializer, new isInstanceOf<ConstructorFieldInitializer>()); |
| 3285 Expression expression = | 3631 Expression expression = |
| 3286 (initializer as ConstructorFieldInitializer).expression; | 3632 (initializer as ConstructorFieldInitializer).expression; |
| 3287 expect(expression, isNotNull); | 3633 expect(expression, isNotNull); |
| 3288 expect(expression, new isInstanceOf<ParenthesizedExpression>()); | 3634 expect(expression, new isInstanceOf<ParenthesizedExpression>()); |
| 3289 } | 3635 } |
| 3290 | 3636 |
| 3291 void test_incomplete_constructorInitializers_variable() { | 3637 void test_incomplete_constructorInitializers_variable() { |
| 3292 parse3("parseClassMember", ["C"], "C() : x {}", | 3638 createParser('C() : x {}'); |
| 3639 ClassMember member = parser.parseClassMember('C'); |
| 3640 expectNotNullIfNoErrors(member); |
| 3641 listener.assertErrorsWithCodes( |
| 3293 [ParserErrorCode.MISSING_ASSIGNMENT_IN_INITIALIZER]); | 3642 [ParserErrorCode.MISSING_ASSIGNMENT_IN_INITIALIZER]); |
| 3294 } | 3643 } |
| 3295 | 3644 |
| 3296 void test_incomplete_topLevelFunction() { | 3645 void test_incomplete_topLevelFunction() { |
| 3297 ParserTestCase.parseCompilationUnit( | 3646 ParserTestCase.parseCompilationUnit( |
| 3298 "foo();", [ParserErrorCode.MISSING_FUNCTION_BODY]); | 3647 "foo();", [ParserErrorCode.MISSING_FUNCTION_BODY]); |
| 3299 } | 3648 } |
| 3300 | 3649 |
| 3301 void test_incomplete_topLevelVariable() { | 3650 void test_incomplete_topLevelVariable() { |
| 3302 CompilationUnit unit = ParserTestCase | 3651 CompilationUnit unit = ParserTestCase |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3684 expect(members, hasLength(2)); | 4033 expect(members, hasLength(2)); |
| 3685 EngineTestCase.assertInstanceOf( | 4034 EngineTestCase.assertInstanceOf( |
| 3686 (obj) => obj is MethodDeclaration, MethodDeclaration, members[0]); | 4035 (obj) => obj is MethodDeclaration, MethodDeclaration, members[0]); |
| 3687 ClassMember member = members[1]; | 4036 ClassMember member = members[1]; |
| 3688 EngineTestCase.assertInstanceOf( | 4037 EngineTestCase.assertInstanceOf( |
| 3689 (obj) => obj is MethodDeclaration, MethodDeclaration, member); | 4038 (obj) => obj is MethodDeclaration, MethodDeclaration, member); |
| 3690 expect((member as MethodDeclaration).name.name, "foo"); | 4039 expect((member as MethodDeclaration).name.name, "foo"); |
| 3691 } | 4040 } |
| 3692 | 4041 |
| 3693 void test_missingIdentifier_afterAnnotation() { | 4042 void test_missingIdentifier_afterAnnotation() { |
| 3694 MethodDeclaration method = parse3("parseClassMember", <Object>["C"], | 4043 createParser('@override }'); |
| 3695 "@override }", [ParserErrorCode.EXPECTED_CLASS_MEMBER]); | 4044 ClassMember member = parser.parseClassMember('C'); |
| 4045 expectNotNullIfNoErrors(member); |
| 4046 listener.assertErrorsWithCodes([ParserErrorCode.EXPECTED_CLASS_MEMBER]); |
| 4047 expect(member, new isInstanceOf<MethodDeclaration>()); |
| 4048 MethodDeclaration method = member; |
| 3696 expect(method.documentationComment, isNull); | 4049 expect(method.documentationComment, isNull); |
| 3697 NodeList<Annotation> metadata = method.metadata; | 4050 NodeList<Annotation> metadata = method.metadata; |
| 3698 expect(metadata, hasLength(1)); | 4051 expect(metadata, hasLength(1)); |
| 3699 expect(metadata[0].name.name, "override"); | 4052 expect(metadata[0].name.name, "override"); |
| 3700 } | 4053 } |
| 3701 | 4054 |
| 3702 void test_missingSemicolon_varialeDeclarationList() { | 4055 void test_missingSemicolon_varialeDeclarationList() { |
| 3703 void verify(CompilationUnitMember member, String expectedTypeName, | 4056 void verify(CompilationUnitMember member, String expectedTypeName, |
| 3704 String expectedName, String expectedSemicolon) { | 4057 String expectedName, String expectedSemicolon) { |
| 3705 expect(member, new isInstanceOf<TopLevelVariableDeclaration>()); | 4058 expect(member, new isInstanceOf<TopLevelVariableDeclaration>()); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3795 void test_prefixExpression_missing_operand_minus() { | 4148 void test_prefixExpression_missing_operand_minus() { |
| 3796 PrefixExpression expression = | 4149 PrefixExpression expression = |
| 3797 parseExpression("-", [ParserErrorCode.MISSING_IDENTIFIER]); | 4150 parseExpression("-", [ParserErrorCode.MISSING_IDENTIFIER]); |
| 3798 EngineTestCase.assertInstanceOf( | 4151 EngineTestCase.assertInstanceOf( |
| 3799 (obj) => obj is SimpleIdentifier, SimpleIdentifier, expression.operand); | 4152 (obj) => obj is SimpleIdentifier, SimpleIdentifier, expression.operand); |
| 3800 expect(expression.operand.isSynthetic, isTrue); | 4153 expect(expression.operand.isSynthetic, isTrue); |
| 3801 expect(expression.operator.type, TokenType.MINUS); | 4154 expect(expression.operator.type, TokenType.MINUS); |
| 3802 } | 4155 } |
| 3803 | 4156 |
| 3804 void test_primaryExpression_argumentDefinitionTest() { | 4157 void test_primaryExpression_argumentDefinitionTest() { |
| 3805 Expression expression = parse4( | 4158 createParser('?a'); |
| 3806 "parsePrimaryExpression", "?a", [ParserErrorCode.UNEXPECTED_TOKEN]); | 4159 Expression expression = parser.parsePrimaryExpression(); |
| 3807 EngineTestCase.assertInstanceOf( | 4160 expectNotNullIfNoErrors(expression); |
| 3808 (obj) => obj is SimpleIdentifier, SimpleIdentifier, expression); | 4161 listener.assertErrorsWithCodes([ParserErrorCode.UNEXPECTED_TOKEN]); |
| 4162 expect(expression, new isInstanceOf<SimpleIdentifier>()); |
| 3809 } | 4163 } |
| 3810 | 4164 |
| 3811 void test_relationalExpression_missing_LHS() { | 4165 void test_relationalExpression_missing_LHS() { |
| 3812 IsExpression expression = | 4166 IsExpression expression = |
| 3813 parseExpression("is y", [ParserErrorCode.MISSING_IDENTIFIER]); | 4167 parseExpression("is y", [ParserErrorCode.MISSING_IDENTIFIER]); |
| 3814 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 4168 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
| 3815 SimpleIdentifier, expression.expression); | 4169 SimpleIdentifier, expression.expression); |
| 3816 expect(expression.expression.isSynthetic, isTrue); | 4170 expect(expression.expression.isSynthetic, isTrue); |
| 3817 } | 4171 } |
| 3818 | 4172 |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3969 (obj) => obj is SimpleIdentifier, | 4323 (obj) => obj is SimpleIdentifier, |
| 3970 SimpleIdentifier, | 4324 SimpleIdentifier, |
| 3971 reference.identifier); | 4325 reference.identifier); |
| 3972 expect(identifier.token, isNotNull); | 4326 expect(identifier.token, isNotNull); |
| 3973 expect(identifier.name, "a"); | 4327 expect(identifier.name, "a"); |
| 3974 expect(identifier.offset, 5); | 4328 expect(identifier.offset, 5); |
| 3975 } | 4329 } |
| 3976 | 4330 |
| 3977 void fail_parseStatement_functionDeclaration_noReturnType_typeParameters() { | 4331 void fail_parseStatement_functionDeclaration_noReturnType_typeParameters() { |
| 3978 enableGenericMethods = true; | 4332 enableGenericMethods = true; |
| 3979 FunctionDeclarationStatement statement = | 4333 createParser('f<E>(a, b) {};'); |
| 3980 parse4("parseStatement", "f<E>(a, b) {};"); | 4334 Statement statement = parser.parseStatement2(); |
| 3981 expect(statement.functionDeclaration, isNotNull); | 4335 expectNotNullIfNoErrors(statement); |
| 4336 listener.assertNoErrors(); |
| 4337 expect(statement, new isInstanceOf<FunctionDeclarationStatement>()); |
| 4338 FunctionDeclarationStatement declaration = statement; |
| 4339 expect(declaration.functionDeclaration, isNotNull); |
| 3982 } | 4340 } |
| 3983 | 4341 |
| 3984 void test_computeStringValue_emptyInterpolationPrefix() { | 4342 void test_computeStringValue_emptyInterpolationPrefix() { |
| 3985 expect(_computeStringValue("'''", true, false), ""); | 4343 expect(_computeStringValue("'''", true, false), ""); |
| 3986 } | 4344 } |
| 3987 | 4345 |
| 3988 void test_computeStringValue_escape_b() { | 4346 void test_computeStringValue_escape_b() { |
| 3989 expect(_computeStringValue("'\\b'", true, true), "\b"); | 4347 expect(_computeStringValue("'\\b'", true, true), "\b"); |
| 3990 } | 4348 } |
| 3991 | 4349 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4059 | 4417 |
| 4060 void test_computeStringValue_triple_internalQuote_last_nonEmpty() { | 4418 void test_computeStringValue_triple_internalQuote_last_nonEmpty() { |
| 4061 expect(_computeStringValue("text'''", false, true), "text"); | 4419 expect(_computeStringValue("text'''", false, true), "text"); |
| 4062 } | 4420 } |
| 4063 | 4421 |
| 4064 void test_constFactory() { | 4422 void test_constFactory() { |
| 4065 parse("parseClassMember", <Object>["C"], "const factory C() = A;"); | 4423 parse("parseClassMember", <Object>["C"], "const factory C() = A;"); |
| 4066 } | 4424 } |
| 4067 | 4425 |
| 4068 void test_createSyntheticIdentifier() { | 4426 void test_createSyntheticIdentifier() { |
| 4069 SimpleIdentifier identifier = _createSyntheticIdentifier(); | 4427 createParser(''); |
| 4428 SimpleIdentifier identifier = parser.createSyntheticIdentifier(); |
| 4429 expectNotNullIfNoErrors(identifier); |
| 4070 expect(identifier.isSynthetic, isTrue); | 4430 expect(identifier.isSynthetic, isTrue); |
| 4071 } | 4431 } |
| 4072 | 4432 |
| 4073 void test_createSyntheticStringLiteral() { | 4433 void test_createSyntheticStringLiteral() { |
| 4074 SimpleStringLiteral literal = _createSyntheticStringLiteral(); | 4434 createParser(''); |
| 4435 SimpleStringLiteral literal = parser.createSyntheticStringLiteral(); |
| 4436 expectNotNullIfNoErrors(literal); |
| 4075 expect(literal.isSynthetic, isTrue); | 4437 expect(literal.isSynthetic, isTrue); |
| 4076 } | 4438 } |
| 4077 | 4439 |
| 4078 void test_function_literal_allowed_at_toplevel() { | 4440 void test_function_literal_allowed_at_toplevel() { |
| 4079 ParserTestCase.parseCompilationUnit("var x = () {};"); | 4441 ParserTestCase.parseCompilationUnit("var x = () {};"); |
| 4080 } | 4442 } |
| 4081 | 4443 |
| 4082 void | 4444 void |
| 4083 test_function_literal_allowed_in_ArgumentList_in_ConstructorFieldInitializ
er() { | 4445 test_function_literal_allowed_in_ArgumentList_in_ConstructorFieldInitializ
er() { |
| 4084 ParserTestCase.parseCompilationUnit("class C { C() : a = f(() {}); }"); | 4446 ParserTestCase.parseCompilationUnit("class C { C() : a = f(() {}); }"); |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4315 | 4677 |
| 4316 void test_isSwitchMember_default_unlabeled() { | 4678 void test_isSwitchMember_default_unlabeled() { |
| 4317 expect(_isSwitchMember("default"), isTrue); | 4679 expect(_isSwitchMember("default"), isTrue); |
| 4318 } | 4680 } |
| 4319 | 4681 |
| 4320 void test_isSwitchMember_false() { | 4682 void test_isSwitchMember_false() { |
| 4321 expect(_isSwitchMember("break;"), isFalse); | 4683 expect(_isSwitchMember("break;"), isFalse); |
| 4322 } | 4684 } |
| 4323 | 4685 |
| 4324 void test_parseAdditiveExpression_normal() { | 4686 void test_parseAdditiveExpression_normal() { |
| 4325 BinaryExpression expression = parse4("parseAdditiveExpression", "x + y"); | 4687 createParser('x + y'); |
| 4326 expect(expression.leftOperand, isNotNull); | 4688 Expression expression = parser.parseAdditiveExpression(); |
| 4327 expect(expression.operator, isNotNull); | 4689 expectNotNullIfNoErrors(expression); |
| 4328 expect(expression.operator.type, TokenType.PLUS); | 4690 listener.assertNoErrors(); |
| 4329 expect(expression.rightOperand, isNotNull); | 4691 expect(expression, new isInstanceOf<BinaryExpression>()); |
| 4692 BinaryExpression binaryExpression = expression; |
| 4693 expect(binaryExpression.leftOperand, isNotNull); |
| 4694 expect(binaryExpression.operator, isNotNull); |
| 4695 expect(binaryExpression.operator.type, TokenType.PLUS); |
| 4696 expect(binaryExpression.rightOperand, isNotNull); |
| 4330 } | 4697 } |
| 4331 | 4698 |
| 4332 void test_parseAdditiveExpression_super() { | 4699 void test_parseAdditiveExpression_super() { |
| 4333 BinaryExpression expression = | 4700 createParser('super + y'); |
| 4334 parse4("parseAdditiveExpression", "super + y"); | 4701 Expression expression = parser.parseAdditiveExpression(); |
| 4335 EngineTestCase.assertInstanceOf((obj) => obj is SuperExpression, | 4702 expectNotNullIfNoErrors(expression); |
| 4336 SuperExpression, expression.leftOperand); | 4703 listener.assertNoErrors(); |
| 4337 expect(expression.operator, isNotNull); | 4704 expect(expression, new isInstanceOf<BinaryExpression>()); |
| 4338 expect(expression.operator.type, TokenType.PLUS); | 4705 BinaryExpression binaryExpression = expression; |
| 4339 expect(expression.rightOperand, isNotNull); | 4706 expect(binaryExpression.leftOperand, new isInstanceOf<SuperExpression>()); |
| 4707 expect(binaryExpression.operator, isNotNull); |
| 4708 expect(binaryExpression.operator.type, TokenType.PLUS); |
| 4709 expect(binaryExpression.rightOperand, isNotNull); |
| 4340 } | 4710 } |
| 4341 | 4711 |
| 4342 void test_parseAnnotation_n1() { | 4712 void test_parseAnnotation_n1() { |
| 4343 Annotation annotation = parse4("parseAnnotation", "@A"); | 4713 createParser('@A'); |
| 4714 Annotation annotation = parser.parseAnnotation(); |
| 4715 expectNotNullIfNoErrors(annotation); |
| 4716 listener.assertNoErrors(); |
| 4344 expect(annotation.atSign, isNotNull); | 4717 expect(annotation.atSign, isNotNull); |
| 4345 expect(annotation.name, isNotNull); | 4718 expect(annotation.name, isNotNull); |
| 4346 expect(annotation.period, isNull); | 4719 expect(annotation.period, isNull); |
| 4347 expect(annotation.constructorName, isNull); | 4720 expect(annotation.constructorName, isNull); |
| 4348 expect(annotation.arguments, isNull); | 4721 expect(annotation.arguments, isNull); |
| 4349 } | 4722 } |
| 4350 | 4723 |
| 4351 void test_parseAnnotation_n1_a() { | 4724 void test_parseAnnotation_n1_a() { |
| 4352 Annotation annotation = parse4("parseAnnotation", "@A(x,y)"); | 4725 createParser('@A(x,y)'); |
| 4726 Annotation annotation = parser.parseAnnotation(); |
| 4727 expectNotNullIfNoErrors(annotation); |
| 4728 listener.assertNoErrors(); |
| 4353 expect(annotation.atSign, isNotNull); | 4729 expect(annotation.atSign, isNotNull); |
| 4354 expect(annotation.name, isNotNull); | 4730 expect(annotation.name, isNotNull); |
| 4355 expect(annotation.period, isNull); | 4731 expect(annotation.period, isNull); |
| 4356 expect(annotation.constructorName, isNull); | 4732 expect(annotation.constructorName, isNull); |
| 4357 expect(annotation.arguments, isNotNull); | 4733 expect(annotation.arguments, isNotNull); |
| 4358 } | 4734 } |
| 4359 | 4735 |
| 4360 void test_parseAnnotation_n2() { | 4736 void test_parseAnnotation_n2() { |
| 4361 Annotation annotation = parse4("parseAnnotation", "@A.B"); | 4737 createParser('@A.B'); |
| 4738 Annotation annotation = parser.parseAnnotation(); |
| 4739 expectNotNullIfNoErrors(annotation); |
| 4740 listener.assertNoErrors(); |
| 4362 expect(annotation.atSign, isNotNull); | 4741 expect(annotation.atSign, isNotNull); |
| 4363 expect(annotation.name, isNotNull); | 4742 expect(annotation.name, isNotNull); |
| 4364 expect(annotation.period, isNull); | 4743 expect(annotation.period, isNull); |
| 4365 expect(annotation.constructorName, isNull); | 4744 expect(annotation.constructorName, isNull); |
| 4366 expect(annotation.arguments, isNull); | 4745 expect(annotation.arguments, isNull); |
| 4367 } | 4746 } |
| 4368 | 4747 |
| 4369 void test_parseAnnotation_n2_a() { | 4748 void test_parseAnnotation_n2_a() { |
| 4370 Annotation annotation = parse4("parseAnnotation", "@A.B(x,y)"); | 4749 createParser('@A.B(x,y)'); |
| 4750 Annotation annotation = parser.parseAnnotation(); |
| 4751 expectNotNullIfNoErrors(annotation); |
| 4752 listener.assertNoErrors(); |
| 4371 expect(annotation.atSign, isNotNull); | 4753 expect(annotation.atSign, isNotNull); |
| 4372 expect(annotation.name, isNotNull); | 4754 expect(annotation.name, isNotNull); |
| 4373 expect(annotation.period, isNull); | 4755 expect(annotation.period, isNull); |
| 4374 expect(annotation.constructorName, isNull); | 4756 expect(annotation.constructorName, isNull); |
| 4375 expect(annotation.arguments, isNotNull); | 4757 expect(annotation.arguments, isNotNull); |
| 4376 } | 4758 } |
| 4377 | 4759 |
| 4378 void test_parseAnnotation_n3() { | 4760 void test_parseAnnotation_n3() { |
| 4379 Annotation annotation = parse4("parseAnnotation", "@A.B.C"); | 4761 createParser('@A.B.C'); |
| 4762 Annotation annotation = parser.parseAnnotation(); |
| 4763 expectNotNullIfNoErrors(annotation); |
| 4764 listener.assertNoErrors(); |
| 4380 expect(annotation.atSign, isNotNull); | 4765 expect(annotation.atSign, isNotNull); |
| 4381 expect(annotation.name, isNotNull); | 4766 expect(annotation.name, isNotNull); |
| 4382 expect(annotation.period, isNotNull); | 4767 expect(annotation.period, isNotNull); |
| 4383 expect(annotation.constructorName, isNotNull); | 4768 expect(annotation.constructorName, isNotNull); |
| 4384 expect(annotation.arguments, isNull); | 4769 expect(annotation.arguments, isNull); |
| 4385 } | 4770 } |
| 4386 | 4771 |
| 4387 void test_parseAnnotation_n3_a() { | 4772 void test_parseAnnotation_n3_a() { |
| 4388 Annotation annotation = parse4("parseAnnotation", "@A.B.C(x,y)"); | 4773 createParser('@A.B.C(x,y)'); |
| 4774 Annotation annotation = parser.parseAnnotation(); |
| 4775 expectNotNullIfNoErrors(annotation); |
| 4776 listener.assertNoErrors(); |
| 4389 expect(annotation.atSign, isNotNull); | 4777 expect(annotation.atSign, isNotNull); |
| 4390 expect(annotation.name, isNotNull); | 4778 expect(annotation.name, isNotNull); |
| 4391 expect(annotation.period, isNotNull); | 4779 expect(annotation.period, isNotNull); |
| 4392 expect(annotation.constructorName, isNotNull); | 4780 expect(annotation.constructorName, isNotNull); |
| 4393 expect(annotation.arguments, isNotNull); | 4781 expect(annotation.arguments, isNotNull); |
| 4394 } | 4782 } |
| 4395 | 4783 |
| 4396 void test_parseArgument_named() { | 4784 void test_parseArgument_named() { |
| 4397 NamedExpression expression = parse4("parseArgument", "n: x"); | 4785 createParser('n: x'); |
| 4398 Label name = expression.name; | 4786 Expression expression = parser.parseArgument(); |
| 4787 expectNotNullIfNoErrors(expression); |
| 4788 listener.assertNoErrors(); |
| 4789 expect(expression, new isInstanceOf<NamedExpression>()); |
| 4790 NamedExpression namedExpression = expression; |
| 4791 Label name = namedExpression.name; |
| 4399 expect(name, isNotNull); | 4792 expect(name, isNotNull); |
| 4400 expect(name.label, isNotNull); | 4793 expect(name.label, isNotNull); |
| 4401 expect(name.colon, isNotNull); | 4794 expect(name.colon, isNotNull); |
| 4402 expect(expression.expression, isNotNull); | 4795 expect(namedExpression.expression, isNotNull); |
| 4403 } | 4796 } |
| 4404 | 4797 |
| 4405 void test_parseArgument_unnamed() { | 4798 void test_parseArgument_unnamed() { |
| 4406 String lexeme = "x"; | 4799 String lexeme = "x"; |
| 4407 SimpleIdentifier identifier = parse4("parseArgument", lexeme); | 4800 createParser(lexeme); |
| 4801 Expression expression = parser.parseArgument(); |
| 4802 expectNotNullIfNoErrors(expression); |
| 4803 listener.assertNoErrors(); |
| 4804 expect(expression, new isInstanceOf<SimpleIdentifier>()); |
| 4805 SimpleIdentifier identifier = expression; |
| 4408 expect(identifier.name, lexeme); | 4806 expect(identifier.name, lexeme); |
| 4409 } | 4807 } |
| 4410 | 4808 |
| 4411 void test_parseArgumentList_empty() { | 4809 void test_parseArgumentList_empty() { |
| 4412 ArgumentList argumentList = parse4("parseArgumentList", "()"); | 4810 createParser('()'); |
| 4811 ArgumentList argumentList = parser.parseArgumentList(); |
| 4812 expectNotNullIfNoErrors(argumentList); |
| 4813 listener.assertNoErrors(); |
| 4413 NodeList<Expression> arguments = argumentList.arguments; | 4814 NodeList<Expression> arguments = argumentList.arguments; |
| 4414 expect(arguments, hasLength(0)); | 4815 expect(arguments, hasLength(0)); |
| 4415 } | 4816 } |
| 4416 | 4817 |
| 4417 void test_parseArgumentList_mixed() { | 4818 void test_parseArgumentList_mixed() { |
| 4418 ArgumentList argumentList = | 4819 createParser('(w, x, y: y, z: z)'); |
| 4419 parse4("parseArgumentList", "(w, x, y: y, z: z)"); | 4820 ArgumentList argumentList = parser.parseArgumentList(); |
| 4821 expectNotNullIfNoErrors(argumentList); |
| 4822 listener.assertNoErrors(); |
| 4420 NodeList<Expression> arguments = argumentList.arguments; | 4823 NodeList<Expression> arguments = argumentList.arguments; |
| 4421 expect(arguments, hasLength(4)); | 4824 expect(arguments, hasLength(4)); |
| 4422 } | 4825 } |
| 4423 | 4826 |
| 4424 void test_parseArgumentList_noNamed() { | 4827 void test_parseArgumentList_noNamed() { |
| 4425 ArgumentList argumentList = parse4("parseArgumentList", "(x, y, z)"); | 4828 createParser('(x, y, z)'); |
| 4829 ArgumentList argumentList = parser.parseArgumentList(); |
| 4830 expectNotNullIfNoErrors(argumentList); |
| 4831 listener.assertNoErrors(); |
| 4426 NodeList<Expression> arguments = argumentList.arguments; | 4832 NodeList<Expression> arguments = argumentList.arguments; |
| 4427 expect(arguments, hasLength(3)); | 4833 expect(arguments, hasLength(3)); |
| 4428 } | 4834 } |
| 4429 | 4835 |
| 4430 void test_parseArgumentList_onlyNamed() { | 4836 void test_parseArgumentList_onlyNamed() { |
| 4431 ArgumentList argumentList = parse4("parseArgumentList", "(x: x, y: y)"); | 4837 createParser('(x: x, y: y)'); |
| 4838 ArgumentList argumentList = parser.parseArgumentList(); |
| 4839 expectNotNullIfNoErrors(argumentList); |
| 4840 listener.assertNoErrors(); |
| 4432 NodeList<Expression> arguments = argumentList.arguments; | 4841 NodeList<Expression> arguments = argumentList.arguments; |
| 4433 expect(arguments, hasLength(2)); | 4842 expect(arguments, hasLength(2)); |
| 4434 } | 4843 } |
| 4435 | 4844 |
| 4436 void test_parseArgumentList_trailing_comma() { | 4845 void test_parseArgumentList_trailing_comma() { |
| 4437 ArgumentList argumentList = parse4("parseArgumentList", "(x, y, z,)"); | 4846 createParser('(x, y, z,)'); |
| 4847 ArgumentList argumentList = parser.parseArgumentList(); |
| 4848 expectNotNullIfNoErrors(argumentList); |
| 4849 listener.assertNoErrors(); |
| 4438 NodeList<Expression> arguments = argumentList.arguments; | 4850 NodeList<Expression> arguments = argumentList.arguments; |
| 4439 expect(arguments, hasLength(3)); | 4851 expect(arguments, hasLength(3)); |
| 4440 } | 4852 } |
| 4441 | 4853 |
| 4442 void test_parseAssertStatement() { | 4854 void test_parseAssertStatement() { |
| 4443 AssertStatement statement = parse4("parseAssertStatement", "assert (x);"); | 4855 createParser('assert (x);'); |
| 4856 AssertStatement statement = parser.parseAssertStatement(); |
| 4857 expectNotNullIfNoErrors(statement); |
| 4858 listener.assertNoErrors(); |
| 4444 expect(statement.assertKeyword, isNotNull); | 4859 expect(statement.assertKeyword, isNotNull); |
| 4445 expect(statement.leftParenthesis, isNotNull); | 4860 expect(statement.leftParenthesis, isNotNull); |
| 4446 expect(statement.condition, isNotNull); | 4861 expect(statement.condition, isNotNull); |
| 4447 expect(statement.comma, isNull); | 4862 expect(statement.comma, isNull); |
| 4448 expect(statement.message, isNull); | 4863 expect(statement.message, isNull); |
| 4449 expect(statement.rightParenthesis, isNotNull); | 4864 expect(statement.rightParenthesis, isNotNull); |
| 4450 expect(statement.semicolon, isNotNull); | 4865 expect(statement.semicolon, isNotNull); |
| 4451 } | 4866 } |
| 4452 | 4867 |
| 4453 void test_parseAssertStatement_messageLowPrecedence() { | 4868 void test_parseAssertStatement_messageLowPrecedence() { |
| 4454 // Using a throw expression as an assert message would be silly in | 4869 // Using a throw expression as an assert message would be silly in |
| 4455 // practice, but it's the lowest precedence expression type, so verifying | 4870 // practice, but it's the lowest precedence expression type, so verifying |
| 4456 // that it works should give us high confidence that other expression types | 4871 // that it works should give us high confidence that other expression types |
| 4457 // will work as well. | 4872 // will work as well. |
| 4458 AssertStatement statement = | 4873 createParser('assert (x, throw "foo");'); |
| 4459 parse4('parseAssertStatement', 'assert (x, throw "foo");'); | 4874 AssertStatement statement = parser.parseAssertStatement(); |
| 4875 expectNotNullIfNoErrors(statement); |
| 4876 listener.assertNoErrors(); |
| 4460 expect(statement.assertKeyword, isNotNull); | 4877 expect(statement.assertKeyword, isNotNull); |
| 4461 expect(statement.leftParenthesis, isNotNull); | 4878 expect(statement.leftParenthesis, isNotNull); |
| 4462 expect(statement.condition, isNotNull); | 4879 expect(statement.condition, isNotNull); |
| 4463 expect(statement.comma, isNotNull); | 4880 expect(statement.comma, isNotNull); |
| 4464 expect(statement.message, isNotNull); | 4881 expect(statement.message, isNotNull); |
| 4465 expect(statement.rightParenthesis, isNotNull); | 4882 expect(statement.rightParenthesis, isNotNull); |
| 4466 expect(statement.semicolon, isNotNull); | 4883 expect(statement.semicolon, isNotNull); |
| 4467 } | 4884 } |
| 4468 | 4885 |
| 4469 void test_parseAssertStatement_messageString() { | 4886 void test_parseAssertStatement_messageString() { |
| 4470 AssertStatement statement = | 4887 createParser('assert (x, "foo");'); |
| 4471 parse4('parseAssertStatement', 'assert (x, "foo");'); | 4888 AssertStatement statement = parser.parseAssertStatement(); |
| 4889 expectNotNullIfNoErrors(statement); |
| 4890 listener.assertNoErrors(); |
| 4472 expect(statement.assertKeyword, isNotNull); | 4891 expect(statement.assertKeyword, isNotNull); |
| 4473 expect(statement.leftParenthesis, isNotNull); | 4892 expect(statement.leftParenthesis, isNotNull); |
| 4474 expect(statement.condition, isNotNull); | 4893 expect(statement.condition, isNotNull); |
| 4475 expect(statement.comma, isNotNull); | 4894 expect(statement.comma, isNotNull); |
| 4476 expect(statement.message, isNotNull); | 4895 expect(statement.message, isNotNull); |
| 4477 expect(statement.rightParenthesis, isNotNull); | 4896 expect(statement.rightParenthesis, isNotNull); |
| 4478 expect(statement.semicolon, isNotNull); | 4897 expect(statement.semicolon, isNotNull); |
| 4479 } | 4898 } |
| 4480 | 4899 |
| 4481 void test_parseAssignableExpression_expression_args_dot() { | 4900 void test_parseAssignableExpression_expression_args_dot() { |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4663 } | 5082 } |
| 4664 | 5083 |
| 4665 void test_parseAssignableSelector_question_dot() { | 5084 void test_parseAssignableSelector_question_dot() { |
| 4666 PropertyAccess selector = | 5085 PropertyAccess selector = |
| 4667 parse("parseAssignableSelector", <Object>[null, true], "?.x"); | 5086 parse("parseAssignableSelector", <Object>[null, true], "?.x"); |
| 4668 expect(selector.operator.type, TokenType.QUESTION_PERIOD); | 5087 expect(selector.operator.type, TokenType.QUESTION_PERIOD); |
| 4669 expect(selector.propertyName, isNotNull); | 5088 expect(selector.propertyName, isNotNull); |
| 4670 } | 5089 } |
| 4671 | 5090 |
| 4672 void test_parseAwaitExpression() { | 5091 void test_parseAwaitExpression() { |
| 4673 AwaitExpression expression = parse4("parseAwaitExpression", "await x;"); | 5092 createParser('await x;'); |
| 5093 AwaitExpression expression = parser.parseAwaitExpression(); |
| 5094 expectNotNullIfNoErrors(expression); |
| 5095 listener.assertNoErrors(); |
| 4674 expect(expression.awaitKeyword, isNotNull); | 5096 expect(expression.awaitKeyword, isNotNull); |
| 4675 expect(expression.expression, isNotNull); | 5097 expect(expression.expression, isNotNull); |
| 4676 } | 5098 } |
| 4677 | 5099 |
| 4678 void test_parseAwaitExpression_asStatement_inAsync() { | 5100 void test_parseAwaitExpression_asStatement_inAsync() { |
| 4679 MethodDeclaration method = | 5101 MethodDeclaration method = |
| 4680 parse("parseClassMember", <Object>["C"], "m() async { await x; }"); | 5102 parse("parseClassMember", <Object>["C"], "m() async { await x; }"); |
| 4681 FunctionBody body = method.body; | 5103 FunctionBody body = method.body; |
| 4682 EngineTestCase.assertInstanceOf( | 5104 EngineTestCase.assertInstanceOf( |
| 4683 (obj) => obj is BlockFunctionBody, BlockFunctionBody, body); | 5105 (obj) => obj is BlockFunctionBody, BlockFunctionBody, body); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 4698 EngineTestCase.assertInstanceOf( | 5120 EngineTestCase.assertInstanceOf( |
| 4699 (obj) => obj is BlockFunctionBody, BlockFunctionBody, body); | 5121 (obj) => obj is BlockFunctionBody, BlockFunctionBody, body); |
| 4700 Statement statement = (body as BlockFunctionBody).block.statements[0]; | 5122 Statement statement = (body as BlockFunctionBody).block.statements[0]; |
| 4701 EngineTestCase.assertInstanceOf( | 5123 EngineTestCase.assertInstanceOf( |
| 4702 (obj) => obj is VariableDeclarationStatement, | 5124 (obj) => obj is VariableDeclarationStatement, |
| 4703 VariableDeclarationStatement, | 5125 VariableDeclarationStatement, |
| 4704 statement); | 5126 statement); |
| 4705 } | 5127 } |
| 4706 | 5128 |
| 4707 void test_parseBitwiseAndExpression_normal() { | 5129 void test_parseBitwiseAndExpression_normal() { |
| 4708 BinaryExpression expression = parse4("parseBitwiseAndExpression", "x & y"); | 5130 createParser('x & y'); |
| 4709 expect(expression.leftOperand, isNotNull); | 5131 Expression expression = parser.parseBitwiseAndExpression(); |
| 4710 expect(expression.operator, isNotNull); | 5132 expectNotNullIfNoErrors(expression); |
| 4711 expect(expression.operator.type, TokenType.AMPERSAND); | 5133 listener.assertNoErrors(); |
| 4712 expect(expression.rightOperand, isNotNull); | 5134 expect(expression, new isInstanceOf<BinaryExpression>()); |
| 5135 BinaryExpression binaryExpression = expression; |
| 5136 expect(binaryExpression.leftOperand, isNotNull); |
| 5137 expect(binaryExpression.operator, isNotNull); |
| 5138 expect(binaryExpression.operator.type, TokenType.AMPERSAND); |
| 5139 expect(binaryExpression.rightOperand, isNotNull); |
| 4713 } | 5140 } |
| 4714 | 5141 |
| 4715 void test_parseBitwiseAndExpression_super() { | 5142 void test_parseBitwiseAndExpression_super() { |
| 4716 BinaryExpression expression = | 5143 createParser('super & y'); |
| 4717 parse4("parseBitwiseAndExpression", "super & y"); | 5144 Expression expression = parser.parseBitwiseAndExpression(); |
| 4718 EngineTestCase.assertInstanceOf((obj) => obj is SuperExpression, | 5145 expectNotNullIfNoErrors(expression); |
| 4719 SuperExpression, expression.leftOperand); | 5146 listener.assertNoErrors(); |
| 4720 expect(expression.operator, isNotNull); | 5147 expect(expression, new isInstanceOf<BinaryExpression>()); |
| 4721 expect(expression.operator.type, TokenType.AMPERSAND); | 5148 BinaryExpression binaryExpression = expression; |
| 4722 expect(expression.rightOperand, isNotNull); | 5149 expect(binaryExpression.leftOperand, new isInstanceOf<SuperExpression>()); |
| 5150 expect(binaryExpression.operator, isNotNull); |
| 5151 expect(binaryExpression.operator.type, TokenType.AMPERSAND); |
| 5152 expect(binaryExpression.rightOperand, isNotNull); |
| 4723 } | 5153 } |
| 4724 | 5154 |
| 4725 void test_parseBitwiseOrExpression_normal() { | 5155 void test_parseBitwiseOrExpression_normal() { |
| 4726 BinaryExpression expression = parse4("parseBitwiseOrExpression", "x | y"); | 5156 createParser('x | y'); |
| 4727 expect(expression.leftOperand, isNotNull); | 5157 Expression expression = parser.parseBitwiseOrExpression(); |
| 4728 expect(expression.operator, isNotNull); | 5158 expectNotNullIfNoErrors(expression); |
| 4729 expect(expression.operator.type, TokenType.BAR); | 5159 listener.assertNoErrors(); |
| 4730 expect(expression.rightOperand, isNotNull); | 5160 expect(expression, new isInstanceOf<BinaryExpression>()); |
| 5161 BinaryExpression binaryExpression = expression; |
| 5162 expect(binaryExpression.leftOperand, isNotNull); |
| 5163 expect(binaryExpression.operator, isNotNull); |
| 5164 expect(binaryExpression.operator.type, TokenType.BAR); |
| 5165 expect(binaryExpression.rightOperand, isNotNull); |
| 4731 } | 5166 } |
| 4732 | 5167 |
| 4733 void test_parseBitwiseOrExpression_super() { | 5168 void test_parseBitwiseOrExpression_super() { |
| 4734 BinaryExpression expression = | 5169 createParser('super | y'); |
| 4735 parse4("parseBitwiseOrExpression", "super | y"); | 5170 Expression expression = parser.parseBitwiseOrExpression(); |
| 4736 EngineTestCase.assertInstanceOf((obj) => obj is SuperExpression, | 5171 expectNotNullIfNoErrors(expression); |
| 4737 SuperExpression, expression.leftOperand); | 5172 listener.assertNoErrors(); |
| 4738 expect(expression.operator, isNotNull); | 5173 expect(expression, new isInstanceOf<BinaryExpression>()); |
| 4739 expect(expression.operator.type, TokenType.BAR); | 5174 BinaryExpression binaryExpression = expression; |
| 4740 expect(expression.rightOperand, isNotNull); | 5175 expect(binaryExpression.leftOperand, new isInstanceOf<SuperExpression>()); |
| 5176 expect(binaryExpression.operator, isNotNull); |
| 5177 expect(binaryExpression.operator.type, TokenType.BAR); |
| 5178 expect(binaryExpression.rightOperand, isNotNull); |
| 4741 } | 5179 } |
| 4742 | 5180 |
| 4743 void test_parseBitwiseXorExpression_normal() { | 5181 void test_parseBitwiseXorExpression_normal() { |
| 4744 BinaryExpression expression = parse4("parseBitwiseXorExpression", "x ^ y"); | 5182 createParser('x ^ y'); |
| 4745 expect(expression.leftOperand, isNotNull); | 5183 Expression expression = parser.parseBitwiseXorExpression(); |
| 4746 expect(expression.operator, isNotNull); | 5184 expectNotNullIfNoErrors(expression); |
| 4747 expect(expression.operator.type, TokenType.CARET); | 5185 listener.assertNoErrors(); |
| 4748 expect(expression.rightOperand, isNotNull); | 5186 expect(expression, new isInstanceOf<BinaryExpression>()); |
| 5187 BinaryExpression binaryExpression = expression; |
| 5188 expect(binaryExpression.leftOperand, isNotNull); |
| 5189 expect(binaryExpression.operator, isNotNull); |
| 5190 expect(binaryExpression.operator.type, TokenType.CARET); |
| 5191 expect(binaryExpression.rightOperand, isNotNull); |
| 4749 } | 5192 } |
| 4750 | 5193 |
| 4751 void test_parseBitwiseXorExpression_super() { | 5194 void test_parseBitwiseXorExpression_super() { |
| 4752 BinaryExpression expression = | 5195 createParser('super ^ y'); |
| 4753 parse4("parseBitwiseXorExpression", "super ^ y"); | 5196 Expression expression = parser.parseBitwiseXorExpression(); |
| 4754 EngineTestCase.assertInstanceOf((obj) => obj is SuperExpression, | 5197 expectNotNullIfNoErrors(expression); |
| 4755 SuperExpression, expression.leftOperand); | 5198 listener.assertNoErrors(); |
| 4756 expect(expression.operator, isNotNull); | 5199 expect(expression, new isInstanceOf<BinaryExpression>()); |
| 4757 expect(expression.operator.type, TokenType.CARET); | 5200 BinaryExpression binaryExpression = expression; |
| 4758 expect(expression.rightOperand, isNotNull); | 5201 expect(binaryExpression.leftOperand, new isInstanceOf<SuperExpression>()); |
| 5202 expect(binaryExpression.operator, isNotNull); |
| 5203 expect(binaryExpression.operator.type, TokenType.CARET); |
| 5204 expect(binaryExpression.rightOperand, isNotNull); |
| 4759 } | 5205 } |
| 4760 | 5206 |
| 4761 void test_parseBlock_empty() { | 5207 void test_parseBlock_empty() { |
| 4762 Block block = parse4("parseBlock", "{}"); | 5208 createParser('{}'); |
| 5209 Block block = parser.parseBlock(); |
| 5210 expectNotNullIfNoErrors(block); |
| 5211 listener.assertNoErrors(); |
| 4763 expect(block.leftBracket, isNotNull); | 5212 expect(block.leftBracket, isNotNull); |
| 4764 expect(block.statements, hasLength(0)); | 5213 expect(block.statements, hasLength(0)); |
| 4765 expect(block.rightBracket, isNotNull); | 5214 expect(block.rightBracket, isNotNull); |
| 4766 } | 5215 } |
| 4767 | 5216 |
| 4768 void test_parseBlock_nonEmpty() { | 5217 void test_parseBlock_nonEmpty() { |
| 4769 Block block = parse4("parseBlock", "{;}"); | 5218 createParser('{;}'); |
| 5219 Block block = parser.parseBlock(); |
| 5220 expectNotNullIfNoErrors(block); |
| 5221 listener.assertNoErrors(); |
| 4770 expect(block.leftBracket, isNotNull); | 5222 expect(block.leftBracket, isNotNull); |
| 4771 expect(block.statements, hasLength(1)); | 5223 expect(block.statements, hasLength(1)); |
| 4772 expect(block.rightBracket, isNotNull); | 5224 expect(block.rightBracket, isNotNull); |
| 4773 } | 5225 } |
| 4774 | 5226 |
| 4775 void test_parseBreakStatement_label() { | 5227 void test_parseBreakStatement_label() { |
| 4776 BreakStatement statement = parse4("parseBreakStatement", "break foo;"); | 5228 createParser('break foo;'); |
| 5229 BreakStatement statement = parser.parseBreakStatement(); |
| 5230 expectNotNullIfNoErrors(statement); |
| 5231 listener.assertNoErrors(); |
| 4777 expect(statement.breakKeyword, isNotNull); | 5232 expect(statement.breakKeyword, isNotNull); |
| 4778 expect(statement.label, isNotNull); | 5233 expect(statement.label, isNotNull); |
| 4779 expect(statement.semicolon, isNotNull); | 5234 expect(statement.semicolon, isNotNull); |
| 4780 } | 5235 } |
| 4781 | 5236 |
| 4782 void test_parseBreakStatement_noLabel() { | 5237 void test_parseBreakStatement_noLabel() { |
| 4783 BreakStatement statement = parse4("parseBreakStatement", "break;", | 5238 createParser('break;'); |
| 4784 [ParserErrorCode.BREAK_OUTSIDE_OF_LOOP]); | 5239 BreakStatement statement = parser.parseBreakStatement(); |
| 5240 expectNotNullIfNoErrors(statement); |
| 5241 listener.assertErrorsWithCodes([ParserErrorCode.BREAK_OUTSIDE_OF_LOOP]); |
| 4785 expect(statement.breakKeyword, isNotNull); | 5242 expect(statement.breakKeyword, isNotNull); |
| 4786 expect(statement.label, isNull); | 5243 expect(statement.label, isNull); |
| 4787 expect(statement.semicolon, isNotNull); | 5244 expect(statement.semicolon, isNotNull); |
| 4788 } | 5245 } |
| 4789 | 5246 |
| 4790 void test_parseCascadeSection_i() { | 5247 void test_parseCascadeSection_i() { |
| 4791 IndexExpression section = parse4("parseCascadeSection", "..[i]"); | 5248 createParser('..[i]'); |
| 5249 Expression expression = parser.parseCascadeSection(); |
| 5250 expectNotNullIfNoErrors(expression); |
| 5251 listener.assertNoErrors(); |
| 5252 expect(expression, new isInstanceOf<IndexExpression>()); |
| 5253 IndexExpression section = expression; |
| 4792 expect(section.target, isNull); | 5254 expect(section.target, isNull); |
| 4793 expect(section.leftBracket, isNotNull); | 5255 expect(section.leftBracket, isNotNull); |
| 4794 expect(section.index, isNotNull); | 5256 expect(section.index, isNotNull); |
| 4795 expect(section.rightBracket, isNotNull); | 5257 expect(section.rightBracket, isNotNull); |
| 4796 } | 5258 } |
| 4797 | 5259 |
| 4798 void test_parseCascadeSection_ia() { | 5260 void test_parseCascadeSection_ia() { |
| 4799 FunctionExpressionInvocation section = | 5261 createParser('..[i](b)'); |
| 4800 parse4("parseCascadeSection", "..[i](b)"); | 5262 Expression expression = parser.parseCascadeSection(); |
| 4801 EngineTestCase.assertInstanceOf( | 5263 expectNotNullIfNoErrors(expression); |
| 4802 (obj) => obj is IndexExpression, IndexExpression, section.function); | 5264 listener.assertNoErrors(); |
| 5265 expect(expression, new isInstanceOf<FunctionExpressionInvocation>()); |
| 5266 FunctionExpressionInvocation section = expression; |
| 5267 expect(section.function, new isInstanceOf<IndexExpression>()); |
| 4803 expect(section.typeArguments, isNull); | 5268 expect(section.typeArguments, isNull); |
| 4804 expect(section.argumentList, isNotNull); | 5269 expect(section.argumentList, isNotNull); |
| 4805 } | 5270 } |
| 4806 | 5271 |
| 4807 void test_parseCascadeSection_ia_typeArgumentComments() { | 5272 void test_parseCascadeSection_ia_typeArgumentComments() { |
| 4808 enableGenericMethodComments = true; | 5273 enableGenericMethodComments = true; |
| 4809 FunctionExpressionInvocation section = | 5274 createParser('..[i]/*<E>*/(b)'); |
| 4810 parse4("parseCascadeSection", "..[i]/*<E>*/(b)"); | 5275 Expression expression = parser.parseCascadeSection(); |
| 4811 EngineTestCase.assertInstanceOf( | 5276 expectNotNullIfNoErrors(expression); |
| 4812 (obj) => obj is IndexExpression, IndexExpression, section.function); | 5277 listener.assertNoErrors(); |
| 5278 expect(expression, new isInstanceOf<FunctionExpressionInvocation>()); |
| 5279 FunctionExpressionInvocation section = expression; |
| 5280 expect(section.function, new isInstanceOf<IndexExpression>()); |
| 4813 expect(section.typeArguments, isNotNull); | 5281 expect(section.typeArguments, isNotNull); |
| 4814 expect(section.argumentList, isNotNull); | 5282 expect(section.argumentList, isNotNull); |
| 4815 } | 5283 } |
| 4816 | 5284 |
| 4817 void test_parseCascadeSection_ia_typeArguments() { | 5285 void test_parseCascadeSection_ia_typeArguments() { |
| 4818 enableGenericMethods = true; | 5286 enableGenericMethods = true; |
| 4819 FunctionExpressionInvocation section = | 5287 createParser('..[i]<E>(b)'); |
| 4820 parse4("parseCascadeSection", "..[i]<E>(b)"); | 5288 Expression expression = parser.parseCascadeSection(); |
| 4821 EngineTestCase.assertInstanceOf( | 5289 expectNotNullIfNoErrors(expression); |
| 4822 (obj) => obj is IndexExpression, IndexExpression, section.function); | 5290 listener.assertNoErrors(); |
| 5291 expect(expression, new isInstanceOf<FunctionExpressionInvocation>()); |
| 5292 FunctionExpressionInvocation section = expression; |
| 5293 expect(section.function, new isInstanceOf<IndexExpression>()); |
| 4823 expect(section.typeArguments, isNotNull); | 5294 expect(section.typeArguments, isNotNull); |
| 4824 expect(section.argumentList, isNotNull); | 5295 expect(section.argumentList, isNotNull); |
| 4825 } | 5296 } |
| 4826 | 5297 |
| 4827 void test_parseCascadeSection_ii() { | 5298 void test_parseCascadeSection_ii() { |
| 4828 MethodInvocation section = parse4("parseCascadeSection", "..a(b).c(d)"); | 5299 createParser('..a(b).c(d)'); |
| 4829 EngineTestCase.assertInstanceOf( | 5300 Expression expression = parser.parseCascadeSection(); |
| 4830 (obj) => obj is MethodInvocation, MethodInvocation, section.target); | 5301 expectNotNullIfNoErrors(expression); |
| 5302 listener.assertNoErrors(); |
| 5303 expect(expression, new isInstanceOf<MethodInvocation>()); |
| 5304 MethodInvocation section = expression; |
| 5305 expect(section.target, new isInstanceOf<MethodInvocation>()); |
| 4831 expect(section.operator, isNotNull); | 5306 expect(section.operator, isNotNull); |
| 4832 expect(section.methodName, isNotNull); | 5307 expect(section.methodName, isNotNull); |
| 4833 expect(section.typeArguments, isNull); | 5308 expect(section.typeArguments, isNull); |
| 4834 expect(section.argumentList, isNotNull); | 5309 expect(section.argumentList, isNotNull); |
| 4835 expect(section.argumentList.arguments, hasLength(1)); | 5310 expect(section.argumentList.arguments, hasLength(1)); |
| 4836 } | 5311 } |
| 4837 | 5312 |
| 4838 void test_parseCascadeSection_ii_typeArgumentComments() { | 5313 void test_parseCascadeSection_ii_typeArgumentComments() { |
| 4839 enableGenericMethodComments = true; | 5314 enableGenericMethodComments = true; |
| 4840 MethodInvocation section = | 5315 createParser('..a/*<E>*/(b).c/*<F>*/(d)'); |
| 4841 parse4("parseCascadeSection", "..a/*<E>*/(b).c/*<F>*/(d)"); | 5316 Expression expression = parser.parseCascadeSection(); |
| 4842 EngineTestCase.assertInstanceOf( | 5317 expectNotNullIfNoErrors(expression); |
| 4843 (obj) => obj is MethodInvocation, MethodInvocation, section.target); | 5318 listener.assertNoErrors(); |
| 5319 expect(expression, new isInstanceOf<MethodInvocation>()); |
| 5320 MethodInvocation section = expression; |
| 5321 expect(section.target, new isInstanceOf<MethodInvocation>()); |
| 4844 expect(section.operator, isNotNull); | 5322 expect(section.operator, isNotNull); |
| 4845 expect(section.methodName, isNotNull); | 5323 expect(section.methodName, isNotNull); |
| 4846 expect(section.typeArguments, isNotNull); | 5324 expect(section.typeArguments, isNotNull); |
| 4847 expect(section.argumentList, isNotNull); | 5325 expect(section.argumentList, isNotNull); |
| 4848 expect(section.argumentList.arguments, hasLength(1)); | 5326 expect(section.argumentList.arguments, hasLength(1)); |
| 4849 } | 5327 } |
| 4850 | 5328 |
| 4851 void test_parseCascadeSection_ii_typeArguments() { | 5329 void test_parseCascadeSection_ii_typeArguments() { |
| 4852 enableGenericMethods = true; | 5330 enableGenericMethods = true; |
| 4853 MethodInvocation section = | 5331 createParser('..a<E>(b).c<F>(d)'); |
| 4854 parse4("parseCascadeSection", "..a<E>(b).c<F>(d)"); | 5332 Expression expression = parser.parseCascadeSection(); |
| 4855 EngineTestCase.assertInstanceOf( | 5333 expectNotNullIfNoErrors(expression); |
| 4856 (obj) => obj is MethodInvocation, MethodInvocation, section.target); | 5334 listener.assertNoErrors(); |
| 5335 expect(expression, new isInstanceOf<MethodInvocation>()); |
| 5336 MethodInvocation section = expression; |
| 5337 expect(section.target, new isInstanceOf<MethodInvocation>()); |
| 4857 expect(section.operator, isNotNull); | 5338 expect(section.operator, isNotNull); |
| 4858 expect(section.methodName, isNotNull); | 5339 expect(section.methodName, isNotNull); |
| 4859 expect(section.typeArguments, isNotNull); | 5340 expect(section.typeArguments, isNotNull); |
| 4860 expect(section.argumentList, isNotNull); | 5341 expect(section.argumentList, isNotNull); |
| 4861 expect(section.argumentList.arguments, hasLength(1)); | 5342 expect(section.argumentList.arguments, hasLength(1)); |
| 4862 } | 5343 } |
| 4863 | 5344 |
| 4864 void test_parseCascadeSection_p() { | 5345 void test_parseCascadeSection_p() { |
| 4865 PropertyAccess section = parse4("parseCascadeSection", "..a"); | 5346 createParser('..a'); |
| 5347 Expression expression = parser.parseCascadeSection(); |
| 5348 expectNotNullIfNoErrors(expression); |
| 5349 listener.assertNoErrors(); |
| 5350 expect(expression, new isInstanceOf<PropertyAccess>()); |
| 5351 PropertyAccess section = expression; |
| 4866 expect(section.target, isNull); | 5352 expect(section.target, isNull); |
| 4867 expect(section.operator, isNotNull); | 5353 expect(section.operator, isNotNull); |
| 4868 expect(section.propertyName, isNotNull); | 5354 expect(section.propertyName, isNotNull); |
| 4869 } | 5355 } |
| 4870 | 5356 |
| 4871 void test_parseCascadeSection_p_assign() { | 5357 void test_parseCascadeSection_p_assign() { |
| 4872 AssignmentExpression section = parse4("parseCascadeSection", "..a = 3"); | 5358 createParser('..a = 3'); |
| 5359 Expression expression = parser.parseCascadeSection(); |
| 5360 expectNotNullIfNoErrors(expression); |
| 5361 listener.assertNoErrors(); |
| 5362 expect(expression, new isInstanceOf<AssignmentExpression>()); |
| 5363 AssignmentExpression section = expression; |
| 4873 expect(section.leftHandSide, isNotNull); | 5364 expect(section.leftHandSide, isNotNull); |
| 4874 expect(section.operator, isNotNull); | 5365 expect(section.operator, isNotNull); |
| 4875 Expression rhs = section.rightHandSide; | 5366 Expression rhs = section.rightHandSide; |
| 4876 expect(rhs, isNotNull); | 5367 expect(rhs, isNotNull); |
| 4877 } | 5368 } |
| 4878 | 5369 |
| 4879 void test_parseCascadeSection_p_assign_withCascade() { | 5370 void test_parseCascadeSection_p_assign_withCascade() { |
| 4880 AssignmentExpression section = | 5371 createParser('..a = 3..m()'); |
| 4881 parse4("parseCascadeSection", "..a = 3..m()"); | 5372 Expression expression = parser.parseCascadeSection(); |
| 5373 expectNotNullIfNoErrors(expression); |
| 5374 listener.assertNoErrors(); |
| 5375 expect(expression, new isInstanceOf<AssignmentExpression>()); |
| 5376 AssignmentExpression section = expression; |
| 4882 expect(section.leftHandSide, isNotNull); | 5377 expect(section.leftHandSide, isNotNull); |
| 4883 expect(section.operator, isNotNull); | 5378 expect(section.operator, isNotNull); |
| 4884 Expression rhs = section.rightHandSide; | 5379 Expression rhs = section.rightHandSide; |
| 4885 EngineTestCase.assertInstanceOf( | 5380 EngineTestCase.assertInstanceOf( |
| 4886 (obj) => obj is IntegerLiteral, IntegerLiteral, rhs); | 5381 (obj) => obj is IntegerLiteral, IntegerLiteral, rhs); |
| 4887 } | 5382 } |
| 4888 | 5383 |
| 4889 void test_parseCascadeSection_p_assign_withCascade_typeArgumentComments() { | 5384 void test_parseCascadeSection_p_assign_withCascade_typeArgumentComments() { |
| 4890 enableGenericMethodComments = true; | 5385 enableGenericMethodComments = true; |
| 4891 AssignmentExpression section = | 5386 createParser('..a = 3..m/*<E>*/()'); |
| 4892 parse4("parseCascadeSection", "..a = 3..m/*<E>*/()"); | 5387 Expression expression = parser.parseCascadeSection(); |
| 5388 expectNotNullIfNoErrors(expression); |
| 5389 listener.assertNoErrors(); |
| 5390 expect(expression, new isInstanceOf<AssignmentExpression>()); |
| 5391 AssignmentExpression section = expression; |
| 4893 expect(section.leftHandSide, isNotNull); | 5392 expect(section.leftHandSide, isNotNull); |
| 4894 expect(section.operator, isNotNull); | 5393 expect(section.operator, isNotNull); |
| 4895 Expression rhs = section.rightHandSide; | 5394 Expression rhs = section.rightHandSide; |
| 4896 EngineTestCase.assertInstanceOf( | 5395 EngineTestCase.assertInstanceOf( |
| 4897 (obj) => obj is IntegerLiteral, IntegerLiteral, rhs); | 5396 (obj) => obj is IntegerLiteral, IntegerLiteral, rhs); |
| 4898 } | 5397 } |
| 4899 | 5398 |
| 4900 void test_parseCascadeSection_p_assign_withCascade_typeArguments() { | 5399 void test_parseCascadeSection_p_assign_withCascade_typeArguments() { |
| 4901 enableGenericMethods = true; | 5400 enableGenericMethods = true; |
| 4902 AssignmentExpression section = | 5401 createParser('..a = 3..m<E>()'); |
| 4903 parse4("parseCascadeSection", "..a = 3..m<E>()"); | 5402 Expression expression = parser.parseCascadeSection(); |
| 5403 expectNotNullIfNoErrors(expression); |
| 5404 listener.assertNoErrors(); |
| 5405 expect(expression, new isInstanceOf<AssignmentExpression>()); |
| 5406 AssignmentExpression section = expression; |
| 4904 expect(section.leftHandSide, isNotNull); | 5407 expect(section.leftHandSide, isNotNull); |
| 4905 expect(section.operator, isNotNull); | 5408 expect(section.operator, isNotNull); |
| 4906 Expression rhs = section.rightHandSide; | 5409 Expression rhs = section.rightHandSide; |
| 4907 EngineTestCase.assertInstanceOf( | 5410 EngineTestCase.assertInstanceOf( |
| 4908 (obj) => obj is IntegerLiteral, IntegerLiteral, rhs); | 5411 (obj) => obj is IntegerLiteral, IntegerLiteral, rhs); |
| 4909 } | 5412 } |
| 4910 | 5413 |
| 4911 void test_parseCascadeSection_p_builtIn() { | 5414 void test_parseCascadeSection_p_builtIn() { |
| 4912 PropertyAccess section = parse4("parseCascadeSection", "..as"); | 5415 createParser('..as'); |
| 5416 Expression expression = parser.parseCascadeSection(); |
| 5417 expectNotNullIfNoErrors(expression); |
| 5418 listener.assertNoErrors(); |
| 5419 expect(expression, new isInstanceOf<PropertyAccess>()); |
| 5420 PropertyAccess section = expression; |
| 4913 expect(section.target, isNull); | 5421 expect(section.target, isNull); |
| 4914 expect(section.operator, isNotNull); | 5422 expect(section.operator, isNotNull); |
| 4915 expect(section.propertyName, isNotNull); | 5423 expect(section.propertyName, isNotNull); |
| 4916 } | 5424 } |
| 4917 | 5425 |
| 4918 void test_parseCascadeSection_pa() { | 5426 void test_parseCascadeSection_pa() { |
| 4919 MethodInvocation section = parse4("parseCascadeSection", "..a(b)"); | 5427 createParser('..a(b)'); |
| 5428 Expression expression = parser.parseCascadeSection(); |
| 5429 expectNotNullIfNoErrors(expression); |
| 5430 listener.assertNoErrors(); |
| 5431 expect(expression, new isInstanceOf<MethodInvocation>()); |
| 5432 MethodInvocation section = expression; |
| 4920 expect(section.target, isNull); | 5433 expect(section.target, isNull); |
| 4921 expect(section.operator, isNotNull); | 5434 expect(section.operator, isNotNull); |
| 4922 expect(section.methodName, isNotNull); | 5435 expect(section.methodName, isNotNull); |
| 4923 expect(section.typeArguments, isNull); | 5436 expect(section.typeArguments, isNull); |
| 4924 expect(section.argumentList, isNotNull); | 5437 expect(section.argumentList, isNotNull); |
| 4925 expect(section.argumentList.arguments, hasLength(1)); | 5438 expect(section.argumentList.arguments, hasLength(1)); |
| 4926 } | 5439 } |
| 4927 | 5440 |
| 4928 void test_parseCascadeSection_pa_typeArgumentComments() { | 5441 void test_parseCascadeSection_pa_typeArgumentComments() { |
| 4929 enableGenericMethodComments = true; | 5442 enableGenericMethodComments = true; |
| 4930 MethodInvocation section = parse4("parseCascadeSection", "..a/*<E>*/(b)"); | 5443 createParser('..a/*<E>*/(b)'); |
| 5444 Expression expression = parser.parseCascadeSection(); |
| 5445 expectNotNullIfNoErrors(expression); |
| 5446 listener.assertNoErrors(); |
| 5447 expect(expression, new isInstanceOf<MethodInvocation>()); |
| 5448 MethodInvocation section = expression; |
| 4931 expect(section.target, isNull); | 5449 expect(section.target, isNull); |
| 4932 expect(section.operator, isNotNull); | 5450 expect(section.operator, isNotNull); |
| 4933 expect(section.methodName, isNotNull); | 5451 expect(section.methodName, isNotNull); |
| 4934 expect(section.typeArguments, isNotNull); | 5452 expect(section.typeArguments, isNotNull); |
| 4935 expect(section.argumentList, isNotNull); | 5453 expect(section.argumentList, isNotNull); |
| 4936 expect(section.argumentList.arguments, hasLength(1)); | 5454 expect(section.argumentList.arguments, hasLength(1)); |
| 4937 } | 5455 } |
| 4938 | 5456 |
| 4939 void test_parseCascadeSection_pa_typeArguments() { | 5457 void test_parseCascadeSection_pa_typeArguments() { |
| 4940 enableGenericMethods = true; | 5458 enableGenericMethods = true; |
| 4941 MethodInvocation section = parse4("parseCascadeSection", "..a<E>(b)"); | 5459 createParser('..a<E>(b)'); |
| 5460 Expression expression = parser.parseCascadeSection(); |
| 5461 expectNotNullIfNoErrors(expression); |
| 5462 listener.assertNoErrors(); |
| 5463 expect(expression, new isInstanceOf<MethodInvocation>()); |
| 5464 MethodInvocation section = expression; |
| 4942 expect(section.target, isNull); | 5465 expect(section.target, isNull); |
| 4943 expect(section.operator, isNotNull); | 5466 expect(section.operator, isNotNull); |
| 4944 expect(section.methodName, isNotNull); | 5467 expect(section.methodName, isNotNull); |
| 4945 expect(section.typeArguments, isNotNull); | 5468 expect(section.typeArguments, isNotNull); |
| 4946 expect(section.argumentList, isNotNull); | 5469 expect(section.argumentList, isNotNull); |
| 4947 expect(section.argumentList.arguments, hasLength(1)); | 5470 expect(section.argumentList.arguments, hasLength(1)); |
| 4948 } | 5471 } |
| 4949 | 5472 |
| 4950 void test_parseCascadeSection_paa() { | 5473 void test_parseCascadeSection_paa() { |
| 4951 FunctionExpressionInvocation section = | 5474 createParser('..a(b)(c)'); |
| 4952 parse4("parseCascadeSection", "..a(b)(c)"); | 5475 Expression expression = parser.parseCascadeSection(); |
| 4953 EngineTestCase.assertInstanceOf( | 5476 expectNotNullIfNoErrors(expression); |
| 4954 (obj) => obj is MethodInvocation, MethodInvocation, section.function); | 5477 listener.assertNoErrors(); |
| 5478 expect(expression, new isInstanceOf<FunctionExpressionInvocation>()); |
| 5479 FunctionExpressionInvocation section = expression; |
| 5480 expect(section.function, new isInstanceOf<MethodInvocation>()); |
| 4955 expect(section.typeArguments, isNull); | 5481 expect(section.typeArguments, isNull); |
| 4956 expect(section.argumentList, isNotNull); | 5482 expect(section.argumentList, isNotNull); |
| 4957 expect(section.argumentList.arguments, hasLength(1)); | 5483 expect(section.argumentList.arguments, hasLength(1)); |
| 4958 } | 5484 } |
| 4959 | 5485 |
| 4960 void test_parseCascadeSection_paa_typeArgumentComments() { | 5486 void test_parseCascadeSection_paa_typeArgumentComments() { |
| 4961 enableGenericMethodComments = true; | 5487 enableGenericMethodComments = true; |
| 4962 FunctionExpressionInvocation section = | 5488 createParser('..a/*<E>*/(b)/*<F>*/(c)'); |
| 4963 parse4("parseCascadeSection", "..a/*<E>*/(b)/*<F>*/(c)"); | 5489 Expression expression = parser.parseCascadeSection(); |
| 4964 EngineTestCase.assertInstanceOf( | 5490 expectNotNullIfNoErrors(expression); |
| 4965 (obj) => obj is MethodInvocation, MethodInvocation, section.function); | 5491 listener.assertNoErrors(); |
| 5492 expect(expression, new isInstanceOf<FunctionExpressionInvocation>()); |
| 5493 FunctionExpressionInvocation section = expression; |
| 5494 expect(section.function, new isInstanceOf<MethodInvocation>()); |
| 4966 expect(section.typeArguments, isNotNull); | 5495 expect(section.typeArguments, isNotNull); |
| 4967 expect(section.argumentList, isNotNull); | 5496 expect(section.argumentList, isNotNull); |
| 4968 expect(section.argumentList.arguments, hasLength(1)); | 5497 expect(section.argumentList.arguments, hasLength(1)); |
| 4969 } | 5498 } |
| 4970 | 5499 |
| 4971 void test_parseCascadeSection_paa_typeArguments() { | 5500 void test_parseCascadeSection_paa_typeArguments() { |
| 4972 enableGenericMethods = true; | 5501 enableGenericMethods = true; |
| 4973 FunctionExpressionInvocation section = | 5502 createParser('..a<E>(b)<F>(c)'); |
| 4974 parse4("parseCascadeSection", "..a<E>(b)<F>(c)"); | 5503 Expression expression = parser.parseCascadeSection(); |
| 4975 EngineTestCase.assertInstanceOf( | 5504 expectNotNullIfNoErrors(expression); |
| 4976 (obj) => obj is MethodInvocation, MethodInvocation, section.function); | 5505 listener.assertNoErrors(); |
| 5506 expect(expression, new isInstanceOf<FunctionExpressionInvocation>()); |
| 5507 FunctionExpressionInvocation section = expression; |
| 5508 expect(section.function, new isInstanceOf<MethodInvocation>()); |
| 4977 expect(section.typeArguments, isNotNull); | 5509 expect(section.typeArguments, isNotNull); |
| 4978 expect(section.argumentList, isNotNull); | 5510 expect(section.argumentList, isNotNull); |
| 4979 expect(section.argumentList.arguments, hasLength(1)); | 5511 expect(section.argumentList.arguments, hasLength(1)); |
| 4980 } | 5512 } |
| 4981 | 5513 |
| 4982 void test_parseCascadeSection_paapaa() { | 5514 void test_parseCascadeSection_paapaa() { |
| 4983 FunctionExpressionInvocation section = | 5515 createParser('..a(b)(c).d(e)(f)'); |
| 4984 parse4("parseCascadeSection", "..a(b)(c).d(e)(f)"); | 5516 Expression expression = parser.parseCascadeSection(); |
| 4985 EngineTestCase.assertInstanceOf( | 5517 expectNotNullIfNoErrors(expression); |
| 4986 (obj) => obj is MethodInvocation, MethodInvocation, section.function); | 5518 listener.assertNoErrors(); |
| 5519 expect(expression, new isInstanceOf<FunctionExpressionInvocation>()); |
| 5520 FunctionExpressionInvocation section = expression; |
| 5521 expect(section.function, new isInstanceOf<MethodInvocation>()); |
| 4987 expect(section.typeArguments, isNull); | 5522 expect(section.typeArguments, isNull); |
| 4988 expect(section.argumentList, isNotNull); | 5523 expect(section.argumentList, isNotNull); |
| 4989 expect(section.argumentList.arguments, hasLength(1)); | 5524 expect(section.argumentList.arguments, hasLength(1)); |
| 4990 } | 5525 } |
| 4991 | 5526 |
| 4992 void test_parseCascadeSection_paapaa_typeArgumentComments() { | 5527 void test_parseCascadeSection_paapaa_typeArgumentComments() { |
| 4993 enableGenericMethodComments = true; | 5528 enableGenericMethodComments = true; |
| 4994 FunctionExpressionInvocation section = parse4( | 5529 createParser('..a/*<E>*/(b)/*<F>*/(c).d/*<G>*/(e)/*<H>*/(f)'); |
| 4995 "parseCascadeSection", "..a/*<E>*/(b)/*<F>*/(c).d/*<G>*/(e)/*<H>*/(f)"); | 5530 Expression expression = parser.parseCascadeSection(); |
| 4996 EngineTestCase.assertInstanceOf( | 5531 expectNotNullIfNoErrors(expression); |
| 4997 (obj) => obj is MethodInvocation, MethodInvocation, section.function); | 5532 listener.assertNoErrors(); |
| 5533 expect(expression, new isInstanceOf<FunctionExpressionInvocation>()); |
| 5534 FunctionExpressionInvocation section = expression; |
| 5535 expect(section.function, new isInstanceOf<MethodInvocation>()); |
| 4998 expect(section.typeArguments, isNotNull); | 5536 expect(section.typeArguments, isNotNull); |
| 4999 expect(section.argumentList, isNotNull); | 5537 expect(section.argumentList, isNotNull); |
| 5000 expect(section.argumentList.arguments, hasLength(1)); | 5538 expect(section.argumentList.arguments, hasLength(1)); |
| 5001 } | 5539 } |
| 5002 | 5540 |
| 5003 void test_parseCascadeSection_paapaa_typeArguments() { | 5541 void test_parseCascadeSection_paapaa_typeArguments() { |
| 5004 enableGenericMethods = true; | 5542 enableGenericMethods = true; |
| 5005 FunctionExpressionInvocation section = | 5543 createParser('..a<E>(b)<F>(c).d<G>(e)<H>(f)'); |
| 5006 parse4("parseCascadeSection", "..a<E>(b)<F>(c).d<G>(e)<H>(f)"); | 5544 Expression expression = parser.parseCascadeSection(); |
| 5007 EngineTestCase.assertInstanceOf( | 5545 expectNotNullIfNoErrors(expression); |
| 5008 (obj) => obj is MethodInvocation, MethodInvocation, section.function); | 5546 listener.assertNoErrors(); |
| 5547 expect(expression, new isInstanceOf<FunctionExpressionInvocation>()); |
| 5548 FunctionExpressionInvocation section = expression; |
| 5549 expect(section.function, new isInstanceOf<MethodInvocation>()); |
| 5009 expect(section.typeArguments, isNotNull); | 5550 expect(section.typeArguments, isNotNull); |
| 5010 expect(section.argumentList, isNotNull); | 5551 expect(section.argumentList, isNotNull); |
| 5011 expect(section.argumentList.arguments, hasLength(1)); | 5552 expect(section.argumentList.arguments, hasLength(1)); |
| 5012 } | 5553 } |
| 5013 | 5554 |
| 5014 void test_parseCascadeSection_pap() { | 5555 void test_parseCascadeSection_pap() { |
| 5015 PropertyAccess section = parse4("parseCascadeSection", "..a(b).c"); | 5556 createParser('..a(b).c'); |
| 5557 Expression expression = parser.parseCascadeSection(); |
| 5558 expectNotNullIfNoErrors(expression); |
| 5559 listener.assertNoErrors(); |
| 5560 expect(expression, new isInstanceOf<PropertyAccess>()); |
| 5561 PropertyAccess section = expression; |
| 5016 expect(section.target, isNotNull); | 5562 expect(section.target, isNotNull); |
| 5017 expect(section.operator, isNotNull); | 5563 expect(section.operator, isNotNull); |
| 5018 expect(section.propertyName, isNotNull); | 5564 expect(section.propertyName, isNotNull); |
| 5019 } | 5565 } |
| 5020 | 5566 |
| 5021 void test_parseCascadeSection_pap_typeArgumentComments() { | 5567 void test_parseCascadeSection_pap_typeArgumentComments() { |
| 5022 enableGenericMethodComments = true; | 5568 enableGenericMethodComments = true; |
| 5023 PropertyAccess section = parse4("parseCascadeSection", "..a/*<E>*/(b).c"); | 5569 createParser('..a/*<E>*/(b).c'); |
| 5570 Expression expression = parser.parseCascadeSection(); |
| 5571 expectNotNullIfNoErrors(expression); |
| 5572 listener.assertNoErrors(); |
| 5573 expect(expression, new isInstanceOf<PropertyAccess>()); |
| 5574 PropertyAccess section = expression; |
| 5024 expect(section.target, isNotNull); | 5575 expect(section.target, isNotNull); |
| 5025 expect(section.operator, isNotNull); | 5576 expect(section.operator, isNotNull); |
| 5026 expect(section.propertyName, isNotNull); | 5577 expect(section.propertyName, isNotNull); |
| 5027 } | 5578 } |
| 5028 | 5579 |
| 5029 void test_parseCascadeSection_pap_typeArguments() { | 5580 void test_parseCascadeSection_pap_typeArguments() { |
| 5030 enableGenericMethods = true; | 5581 enableGenericMethods = true; |
| 5031 PropertyAccess section = parse4("parseCascadeSection", "..a<E>(b).c"); | 5582 createParser('..a<E>(b).c'); |
| 5583 Expression expression = parser.parseCascadeSection(); |
| 5584 expectNotNullIfNoErrors(expression); |
| 5585 listener.assertNoErrors(); |
| 5586 expect(expression, new isInstanceOf<PropertyAccess>()); |
| 5587 PropertyAccess section = expression; |
| 5032 expect(section.target, isNotNull); | 5588 expect(section.target, isNotNull); |
| 5033 expect(section.operator, isNotNull); | 5589 expect(section.operator, isNotNull); |
| 5034 expect(section.propertyName, isNotNull); | 5590 expect(section.propertyName, isNotNull); |
| 5035 } | 5591 } |
| 5036 | 5592 |
| 5037 void test_parseClassDeclaration_abstract() { | 5593 void test_parseClassDeclaration_abstract() { |
| 5038 ClassDeclaration declaration = parse( | 5594 ClassDeclaration declaration = parse( |
| 5039 "parseClassDeclaration", | 5595 "parseClassDeclaration", |
| 5040 <Object>[ | 5596 <Object>[ |
| 5041 emptyCommentAndMetadata(), | 5597 emptyCommentAndMetadata(), |
| (...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5755 expect(classTypeAlias.name.name, "A"); | 6311 expect(classTypeAlias.name.name, "A"); |
| 5756 expect(classTypeAlias.equals, isNotNull); | 6312 expect(classTypeAlias.equals, isNotNull); |
| 5757 expect(classTypeAlias.abstractKeyword, isNull); | 6313 expect(classTypeAlias.abstractKeyword, isNull); |
| 5758 expect(classTypeAlias.superclass.name.name, isNotNull, reason: "B"); | 6314 expect(classTypeAlias.superclass.name.name, isNotNull, reason: "B"); |
| 5759 expect(classTypeAlias.withClause, isNotNull); | 6315 expect(classTypeAlias.withClause, isNotNull); |
| 5760 expect(classTypeAlias.implementsClause, isNotNull); | 6316 expect(classTypeAlias.implementsClause, isNotNull); |
| 5761 expect(classTypeAlias.semicolon, isNotNull); | 6317 expect(classTypeAlias.semicolon, isNotNull); |
| 5762 } | 6318 } |
| 5763 | 6319 |
| 5764 void test_parseCombinator_hide() { | 6320 void test_parseCombinator_hide() { |
| 5765 HideCombinator combinator = parse4('parseCombinator', 'hide a;'); | 6321 createParser('hide a;'); |
| 6322 Combinator combinator = parser.parseCombinator(); |
| 6323 expectNotNullIfNoErrors(combinator); |
| 6324 listener.assertNoErrors(); |
| 5766 expect(combinator, new isInstanceOf<HideCombinator>()); | 6325 expect(combinator, new isInstanceOf<HideCombinator>()); |
| 5767 expect(combinator.keyword, isNotNull); | 6326 HideCombinator hideCombinator = combinator; |
| 5768 expect(combinator.hiddenNames, hasLength(1)); | 6327 expect(hideCombinator.keyword, isNotNull); |
| 6328 expect(hideCombinator.hiddenNames, hasLength(1)); |
| 5769 } | 6329 } |
| 5770 | 6330 |
| 5771 void test_parseCombinator_show() { | 6331 void test_parseCombinator_show() { |
| 5772 ShowCombinator combinator = parse4('parseCombinator', 'show a;'); | 6332 createParser('show a;'); |
| 6333 Combinator combinator = parser.parseCombinator(); |
| 6334 expectNotNullIfNoErrors(combinator); |
| 6335 listener.assertNoErrors(); |
| 5773 expect(combinator, new isInstanceOf<ShowCombinator>()); | 6336 expect(combinator, new isInstanceOf<ShowCombinator>()); |
| 5774 expect(combinator.keyword, isNotNull); | 6337 ShowCombinator showCombinator = combinator; |
| 5775 expect(combinator.shownNames, hasLength(1)); | 6338 expect(showCombinator.keyword, isNotNull); |
| 6339 expect(showCombinator.shownNames, hasLength(1)); |
| 5776 } | 6340 } |
| 5777 | 6341 |
| 5778 void test_parseCombinators_h() { | 6342 void test_parseCombinators_h() { |
| 5779 List<Combinator> combinators = | 6343 createParser('hide a;'); |
| 5780 parse4("parseCombinators", "hide a;") as List<Combinator>; | 6344 List<Combinator> combinators = parser.parseCombinators(); |
| 6345 expectNotNullIfNoErrors(combinators); |
| 6346 listener.assertNoErrors(); |
| 5781 expect(combinators, hasLength(1)); | 6347 expect(combinators, hasLength(1)); |
| 5782 HideCombinator combinator = combinators[0] as HideCombinator; | 6348 HideCombinator combinator = combinators[0] as HideCombinator; |
| 5783 expect(combinator, isNotNull); | 6349 expect(combinator, isNotNull); |
| 5784 expect(combinator.keyword, isNotNull); | 6350 expect(combinator.keyword, isNotNull); |
| 5785 expect(combinator.hiddenNames, hasLength(1)); | 6351 expect(combinator.hiddenNames, hasLength(1)); |
| 5786 } | 6352 } |
| 5787 | 6353 |
| 5788 void test_parseCombinators_hs() { | 6354 void test_parseCombinators_hs() { |
| 5789 List<Combinator> combinators = | 6355 createParser('hide a show b;'); |
| 5790 parse4("parseCombinators", "hide a show b;") as List<Combinator>; | 6356 List<Combinator> combinators = parser.parseCombinators(); |
| 6357 expectNotNullIfNoErrors(combinators); |
| 6358 listener.assertNoErrors(); |
| 5791 expect(combinators, hasLength(2)); | 6359 expect(combinators, hasLength(2)); |
| 5792 HideCombinator hideCombinator = combinators[0] as HideCombinator; | 6360 HideCombinator hideCombinator = combinators[0] as HideCombinator; |
| 5793 expect(hideCombinator, isNotNull); | 6361 expect(hideCombinator, isNotNull); |
| 5794 expect(hideCombinator.keyword, isNotNull); | 6362 expect(hideCombinator.keyword, isNotNull); |
| 5795 expect(hideCombinator.hiddenNames, hasLength(1)); | 6363 expect(hideCombinator.hiddenNames, hasLength(1)); |
| 5796 ShowCombinator showCombinator = combinators[1] as ShowCombinator; | 6364 ShowCombinator showCombinator = combinators[1] as ShowCombinator; |
| 5797 expect(showCombinator, isNotNull); | 6365 expect(showCombinator, isNotNull); |
| 5798 expect(showCombinator.keyword, isNotNull); | 6366 expect(showCombinator.keyword, isNotNull); |
| 5799 expect(showCombinator.shownNames, hasLength(1)); | 6367 expect(showCombinator.shownNames, hasLength(1)); |
| 5800 } | 6368 } |
| 5801 | 6369 |
| 5802 void test_parseCombinators_hshs() { | 6370 void test_parseCombinators_hshs() { |
| 5803 List<Combinator> combinators = | 6371 createParser('hide a show b hide c show d;'); |
| 5804 parse4("parseCombinators", "hide a show b hide c show d;") | 6372 List<Combinator> combinators = parser.parseCombinators(); |
| 5805 as List<Combinator>; | 6373 expectNotNullIfNoErrors(combinators); |
| 6374 listener.assertNoErrors(); |
| 5806 expect(combinators, hasLength(4)); | 6375 expect(combinators, hasLength(4)); |
| 5807 } | 6376 } |
| 5808 | 6377 |
| 5809 void test_parseCombinators_s() { | 6378 void test_parseCombinators_s() { |
| 5810 List<Combinator> combinators = | 6379 createParser('show a;'); |
| 5811 parse4("parseCombinators", "show a;") as List<Combinator>; | 6380 List<Combinator> combinators = parser.parseCombinators(); |
| 6381 expectNotNullIfNoErrors(combinators); |
| 6382 listener.assertNoErrors(); |
| 5812 expect(combinators, hasLength(1)); | 6383 expect(combinators, hasLength(1)); |
| 5813 ShowCombinator combinator = combinators[0] as ShowCombinator; | 6384 ShowCombinator combinator = combinators[0] as ShowCombinator; |
| 5814 expect(combinator, isNotNull); | 6385 expect(combinator, isNotNull); |
| 5815 expect(combinator.keyword, isNotNull); | 6386 expect(combinator.keyword, isNotNull); |
| 5816 expect(combinator.shownNames, hasLength(1)); | 6387 expect(combinator.shownNames, hasLength(1)); |
| 5817 } | 6388 } |
| 5818 | 6389 |
| 5819 void test_parseCommentAndMetadata_c() { | 6390 void test_parseCommentAndMetadata_c() { |
| 5820 CommentAndMetadata commentAndMetadata = | 6391 createParser('/** 1 */ void'); |
| 5821 parse4("parseCommentAndMetadata", "/** 1 */ void"); | 6392 CommentAndMetadata commentAndMetadata = parser.parseCommentAndMetadata(); |
| 6393 expectNotNullIfNoErrors(commentAndMetadata); |
| 6394 listener.assertNoErrors(); |
| 5822 expect(commentAndMetadata.comment, isNotNull); | 6395 expect(commentAndMetadata.comment, isNotNull); |
| 5823 expect(commentAndMetadata.metadata, isNull); | 6396 expect(commentAndMetadata.metadata, isNull); |
| 5824 } | 6397 } |
| 5825 | 6398 |
| 5826 void test_parseCommentAndMetadata_cmc() { | 6399 void test_parseCommentAndMetadata_cmc() { |
| 5827 CommentAndMetadata commentAndMetadata = | 6400 createParser('/** 1 */ @A /** 2 */ void'); |
| 5828 parse4("parseCommentAndMetadata", "/** 1 */ @A /** 2 */ void"); | 6401 CommentAndMetadata commentAndMetadata = parser.parseCommentAndMetadata(); |
| 6402 expectNotNullIfNoErrors(commentAndMetadata); |
| 6403 listener.assertNoErrors(); |
| 5829 expect(commentAndMetadata.comment, isNotNull); | 6404 expect(commentAndMetadata.comment, isNotNull); |
| 5830 expect(commentAndMetadata.metadata, hasLength(1)); | 6405 expect(commentAndMetadata.metadata, hasLength(1)); |
| 5831 } | 6406 } |
| 5832 | 6407 |
| 5833 void test_parseCommentAndMetadata_cmcm() { | 6408 void test_parseCommentAndMetadata_cmcm() { |
| 5834 CommentAndMetadata commentAndMetadata = | 6409 createParser('/** 1 */ @A /** 2 */ @B void'); |
| 5835 parse4("parseCommentAndMetadata", "/** 1 */ @A /** 2 */ @B void"); | 6410 CommentAndMetadata commentAndMetadata = parser.parseCommentAndMetadata(); |
| 6411 expectNotNullIfNoErrors(commentAndMetadata); |
| 6412 listener.assertNoErrors(); |
| 5836 expect(commentAndMetadata.comment, isNotNull); | 6413 expect(commentAndMetadata.comment, isNotNull); |
| 5837 expect(commentAndMetadata.metadata, hasLength(2)); | 6414 expect(commentAndMetadata.metadata, hasLength(2)); |
| 5838 } | 6415 } |
| 5839 | 6416 |
| 5840 void test_parseCommentAndMetadata_cmm() { | 6417 void test_parseCommentAndMetadata_cmm() { |
| 5841 CommentAndMetadata commentAndMetadata = | 6418 createParser('/** 1 */ @A @B void'); |
| 5842 parse4("parseCommentAndMetadata", "/** 1 */ @A @B void"); | 6419 CommentAndMetadata commentAndMetadata = parser.parseCommentAndMetadata(); |
| 6420 expectNotNullIfNoErrors(commentAndMetadata); |
| 6421 listener.assertNoErrors(); |
| 5843 expect(commentAndMetadata.comment, isNotNull); | 6422 expect(commentAndMetadata.comment, isNotNull); |
| 5844 expect(commentAndMetadata.metadata, hasLength(2)); | 6423 expect(commentAndMetadata.metadata, hasLength(2)); |
| 5845 } | 6424 } |
| 5846 | 6425 |
| 5847 void test_parseCommentAndMetadata_m() { | 6426 void test_parseCommentAndMetadata_m() { |
| 5848 CommentAndMetadata commentAndMetadata = | 6427 createParser('@A void'); |
| 5849 parse4("parseCommentAndMetadata", "@A void"); | 6428 CommentAndMetadata commentAndMetadata = parser.parseCommentAndMetadata(); |
| 6429 expectNotNullIfNoErrors(commentAndMetadata); |
| 6430 listener.assertNoErrors(); |
| 5850 expect(commentAndMetadata.comment, isNull); | 6431 expect(commentAndMetadata.comment, isNull); |
| 5851 expect(commentAndMetadata.metadata, hasLength(1)); | 6432 expect(commentAndMetadata.metadata, hasLength(1)); |
| 5852 } | 6433 } |
| 5853 | 6434 |
| 5854 void test_parseCommentAndMetadata_mcm() { | 6435 void test_parseCommentAndMetadata_mcm() { |
| 5855 CommentAndMetadata commentAndMetadata = | 6436 createParser('@A /** 1 */ @B void'); |
| 5856 parse4("parseCommentAndMetadata", "@A /** 1 */ @B void"); | 6437 CommentAndMetadata commentAndMetadata = parser.parseCommentAndMetadata(); |
| 6438 expectNotNullIfNoErrors(commentAndMetadata); |
| 6439 listener.assertNoErrors(); |
| 5857 expect(commentAndMetadata.comment, isNotNull); | 6440 expect(commentAndMetadata.comment, isNotNull); |
| 5858 expect(commentAndMetadata.metadata, hasLength(2)); | 6441 expect(commentAndMetadata.metadata, hasLength(2)); |
| 5859 } | 6442 } |
| 5860 | 6443 |
| 5861 void test_parseCommentAndMetadata_mcmc() { | 6444 void test_parseCommentAndMetadata_mcmc() { |
| 5862 CommentAndMetadata commentAndMetadata = | 6445 createParser('@A /** 1 */ @B /** 2 */ void'); |
| 5863 parse4("parseCommentAndMetadata", "@A /** 1 */ @B /** 2 */ void"); | 6446 CommentAndMetadata commentAndMetadata = parser.parseCommentAndMetadata(); |
| 6447 expectNotNullIfNoErrors(commentAndMetadata); |
| 6448 listener.assertNoErrors(); |
| 5864 expect(commentAndMetadata.comment, isNotNull); | 6449 expect(commentAndMetadata.comment, isNotNull); |
| 5865 expect(commentAndMetadata.metadata, hasLength(2)); | 6450 expect(commentAndMetadata.metadata, hasLength(2)); |
| 5866 } | 6451 } |
| 5867 | 6452 |
| 5868 void test_parseCommentAndMetadata_mm() { | 6453 void test_parseCommentAndMetadata_mm() { |
| 5869 CommentAndMetadata commentAndMetadata = | 6454 createParser('@A @B(x) void'); |
| 5870 parse4("parseCommentAndMetadata", "@A @B(x) void"); | 6455 CommentAndMetadata commentAndMetadata = parser.parseCommentAndMetadata(); |
| 6456 expectNotNullIfNoErrors(commentAndMetadata); |
| 6457 listener.assertNoErrors(); |
| 5871 expect(commentAndMetadata.comment, isNull); | 6458 expect(commentAndMetadata.comment, isNull); |
| 5872 expect(commentAndMetadata.metadata, hasLength(2)); | 6459 expect(commentAndMetadata.metadata, hasLength(2)); |
| 5873 } | 6460 } |
| 5874 | 6461 |
| 5875 void test_parseCommentAndMetadata_none() { | 6462 void test_parseCommentAndMetadata_none() { |
| 5876 CommentAndMetadata commentAndMetadata = | 6463 createParser('void'); |
| 5877 parse4("parseCommentAndMetadata", "void"); | 6464 CommentAndMetadata commentAndMetadata = parser.parseCommentAndMetadata(); |
| 6465 expectNotNullIfNoErrors(commentAndMetadata); |
| 6466 listener.assertNoErrors(); |
| 5878 expect(commentAndMetadata.comment, isNull); | 6467 expect(commentAndMetadata.comment, isNull); |
| 5879 expect(commentAndMetadata.metadata, isNull); | 6468 expect(commentAndMetadata.metadata, isNull); |
| 5880 } | 6469 } |
| 5881 | 6470 |
| 5882 void test_parseCommentAndMetadata_singleLine() { | 6471 void test_parseCommentAndMetadata_singleLine() { |
| 5883 CommentAndMetadata commentAndMetadata = parse4( | 6472 createParser(r''' |
| 5884 "parseCommentAndMetadata", | |
| 5885 r''' | |
| 5886 /// 1 | 6473 /// 1 |
| 5887 /// 2 | 6474 /// 2 |
| 5888 void'''); | 6475 void'''); |
| 6476 CommentAndMetadata commentAndMetadata = parser.parseCommentAndMetadata(); |
| 6477 expectNotNullIfNoErrors(commentAndMetadata); |
| 6478 listener.assertNoErrors(); |
| 5889 expect(commentAndMetadata.comment, isNotNull); | 6479 expect(commentAndMetadata.comment, isNotNull); |
| 5890 expect(commentAndMetadata.metadata, isNull); | 6480 expect(commentAndMetadata.metadata, isNull); |
| 5891 } | 6481 } |
| 5892 | 6482 |
| 5893 void test_parseCommentReference_new_prefixed() { | 6483 void test_parseCommentReference_new_prefixed() { |
| 5894 CommentReference reference = | 6484 CommentReference reference = |
| 5895 parse("parseCommentReference", <Object>["new a.b", 7], ""); | 6485 parse("parseCommentReference", <Object>["new a.b", 7], ""); |
| 5896 PrefixedIdentifier prefixedIdentifier = EngineTestCase.assertInstanceOf( | 6486 PrefixedIdentifier prefixedIdentifier = EngineTestCase.assertInstanceOf( |
| 5897 (obj) => obj is PrefixedIdentifier, | 6487 (obj) => obj is PrefixedIdentifier, |
| 5898 PrefixedIdentifier, | 6488 PrefixedIdentifier, |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6292 parse("parseCommentReferences", <Object>[tokens], "") | 6882 parse("parseCommentReferences", <Object>[tokens], "") |
| 6293 as List<CommentReference>; | 6883 as List<CommentReference>; |
| 6294 expect(references, hasLength(1)); | 6884 expect(references, hasLength(1)); |
| 6295 CommentReference reference = references[0]; | 6885 CommentReference reference = references[0]; |
| 6296 expect(reference, isNotNull); | 6886 expect(reference, isNotNull); |
| 6297 expect(reference.identifier, isNotNull); | 6887 expect(reference.identifier, isNotNull); |
| 6298 expect(reference.offset, 15); | 6888 expect(reference.offset, 15); |
| 6299 } | 6889 } |
| 6300 | 6890 |
| 6301 void test_parseCompilationUnit_abstractAsPrefix_parameterized() { | 6891 void test_parseCompilationUnit_abstractAsPrefix_parameterized() { |
| 6302 CompilationUnit unit = parse4("parseCompilationUnit", | 6892 createParser('abstract<dynamic> _abstract = new abstract.A();'); |
| 6303 "abstract<dynamic> _abstract = new abstract.A();"); | 6893 CompilationUnit unit = parser.parseCompilationUnit2(); |
| 6894 expectNotNullIfNoErrors(unit); |
| 6895 listener.assertNoErrors(); |
| 6304 expect(unit.scriptTag, isNull); | 6896 expect(unit.scriptTag, isNull); |
| 6305 expect(unit.directives, hasLength(0)); | 6897 expect(unit.directives, hasLength(0)); |
| 6306 expect(unit.declarations, hasLength(1)); | 6898 expect(unit.declarations, hasLength(1)); |
| 6307 } | 6899 } |
| 6308 | 6900 |
| 6309 void test_parseCompilationUnit_builtIn_asFunctionName() { | 6901 void test_parseCompilationUnit_builtIn_asFunctionName() { |
| 6310 parse4("parseCompilationUnit", "abstract(x) => 0;"); | 6902 ParserTestCase.parseCompilationUnit('abstract(x) => 0;'); |
| 6311 parse4("parseCompilationUnit", "as(x) => 0;"); | 6903 ParserTestCase.parseCompilationUnit('as(x) => 0;'); |
| 6312 parse4("parseCompilationUnit", "dynamic(x) => 0;"); | 6904 ParserTestCase.parseCompilationUnit('dynamic(x) => 0;'); |
| 6313 parse4("parseCompilationUnit", "export(x) => 0;"); | 6905 ParserTestCase.parseCompilationUnit('export(x) => 0;'); |
| 6314 parse4("parseCompilationUnit", "external(x) => 0;"); | 6906 ParserTestCase.parseCompilationUnit('external(x) => 0;'); |
| 6315 parse4("parseCompilationUnit", "factory(x) => 0;"); | 6907 ParserTestCase.parseCompilationUnit('factory(x) => 0;'); |
| 6316 parse4("parseCompilationUnit", "get(x) => 0;"); | 6908 ParserTestCase.parseCompilationUnit('get(x) => 0;'); |
| 6317 parse4("parseCompilationUnit", "implements(x) => 0;"); | 6909 ParserTestCase.parseCompilationUnit('implements(x) => 0;'); |
| 6318 parse4("parseCompilationUnit", "import(x) => 0;"); | 6910 ParserTestCase.parseCompilationUnit('import(x) => 0;'); |
| 6319 parse4("parseCompilationUnit", "library(x) => 0;"); | 6911 ParserTestCase.parseCompilationUnit('library(x) => 0;'); |
| 6320 parse4("parseCompilationUnit", "operator(x) => 0;"); | 6912 ParserTestCase.parseCompilationUnit('operator(x) => 0;'); |
| 6321 parse4("parseCompilationUnit", "part(x) => 0;"); | 6913 ParserTestCase.parseCompilationUnit('part(x) => 0;'); |
| 6322 parse4("parseCompilationUnit", "set(x) => 0;"); | 6914 ParserTestCase.parseCompilationUnit('set(x) => 0;'); |
| 6323 parse4("parseCompilationUnit", "static(x) => 0;"); | 6915 ParserTestCase.parseCompilationUnit('static(x) => 0;'); |
| 6324 parse4("parseCompilationUnit", "typedef(x) => 0;"); | 6916 ParserTestCase.parseCompilationUnit('typedef(x) => 0;'); |
| 6325 } | 6917 } |
| 6326 | 6918 |
| 6327 void test_parseCompilationUnit_directives_multiple() { | 6919 void test_parseCompilationUnit_directives_multiple() { |
| 6328 CompilationUnit unit = | 6920 createParser("library l;\npart 'a.dart';"); |
| 6329 parse4("parseCompilationUnit", "library l;\npart 'a.dart';"); | 6921 CompilationUnit unit = parser.parseCompilationUnit2(); |
| 6922 expectNotNullIfNoErrors(unit); |
| 6923 listener.assertNoErrors(); |
| 6330 expect(unit.scriptTag, isNull); | 6924 expect(unit.scriptTag, isNull); |
| 6331 expect(unit.directives, hasLength(2)); | 6925 expect(unit.directives, hasLength(2)); |
| 6332 expect(unit.declarations, hasLength(0)); | 6926 expect(unit.declarations, hasLength(0)); |
| 6333 } | 6927 } |
| 6334 | 6928 |
| 6335 void test_parseCompilationUnit_directives_single() { | 6929 void test_parseCompilationUnit_directives_single() { |
| 6336 CompilationUnit unit = parse4("parseCompilationUnit", "library l;"); | 6930 createParser('library l;'); |
| 6931 CompilationUnit unit = parser.parseCompilationUnit2(); |
| 6932 expectNotNullIfNoErrors(unit); |
| 6933 listener.assertNoErrors(); |
| 6337 expect(unit.scriptTag, isNull); | 6934 expect(unit.scriptTag, isNull); |
| 6338 expect(unit.directives, hasLength(1)); | 6935 expect(unit.directives, hasLength(1)); |
| 6339 expect(unit.declarations, hasLength(0)); | 6936 expect(unit.declarations, hasLength(0)); |
| 6340 } | 6937 } |
| 6341 | 6938 |
| 6342 void test_parseCompilationUnit_empty() { | 6939 void test_parseCompilationUnit_empty() { |
| 6343 CompilationUnit unit = parse4("parseCompilationUnit", ""); | 6940 createParser(''); |
| 6941 CompilationUnit unit = parser.parseCompilationUnit2(); |
| 6942 expectNotNullIfNoErrors(unit); |
| 6943 listener.assertNoErrors(); |
| 6344 expect(unit.scriptTag, isNull); | 6944 expect(unit.scriptTag, isNull); |
| 6345 expect(unit.directives, hasLength(0)); | 6945 expect(unit.directives, hasLength(0)); |
| 6346 expect(unit.declarations, hasLength(0)); | 6946 expect(unit.declarations, hasLength(0)); |
| 6347 } | 6947 } |
| 6348 | 6948 |
| 6349 void test_parseCompilationUnit_exportAsPrefix() { | 6949 void test_parseCompilationUnit_exportAsPrefix() { |
| 6350 CompilationUnit unit = | 6950 createParser('export.A _export = new export.A();'); |
| 6351 parse4("parseCompilationUnit", "export.A _export = new export.A();"); | 6951 CompilationUnit unit = parser.parseCompilationUnit2(); |
| 6952 expectNotNullIfNoErrors(unit); |
| 6953 listener.assertNoErrors(); |
| 6352 expect(unit.scriptTag, isNull); | 6954 expect(unit.scriptTag, isNull); |
| 6353 expect(unit.directives, hasLength(0)); | 6955 expect(unit.directives, hasLength(0)); |
| 6354 expect(unit.declarations, hasLength(1)); | 6956 expect(unit.declarations, hasLength(1)); |
| 6355 } | 6957 } |
| 6356 | 6958 |
| 6357 void test_parseCompilationUnit_exportAsPrefix_parameterized() { | 6959 void test_parseCompilationUnit_exportAsPrefix_parameterized() { |
| 6358 CompilationUnit unit = parse4( | 6960 createParser('export<dynamic> _export = new export.A();'); |
| 6359 "parseCompilationUnit", "export<dynamic> _export = new export.A();"); | 6961 CompilationUnit unit = parser.parseCompilationUnit2(); |
| 6962 expectNotNullIfNoErrors(unit); |
| 6963 listener.assertNoErrors(); |
| 6360 expect(unit.scriptTag, isNull); | 6964 expect(unit.scriptTag, isNull); |
| 6361 expect(unit.directives, hasLength(0)); | 6965 expect(unit.directives, hasLength(0)); |
| 6362 expect(unit.declarations, hasLength(1)); | 6966 expect(unit.declarations, hasLength(1)); |
| 6363 } | 6967 } |
| 6364 | 6968 |
| 6365 void test_parseCompilationUnit_operatorAsPrefix_parameterized() { | 6969 void test_parseCompilationUnit_operatorAsPrefix_parameterized() { |
| 6366 CompilationUnit unit = parse4("parseCompilationUnit", | 6970 createParser('operator<dynamic> _operator = new operator.A();'); |
| 6367 "operator<dynamic> _operator = new operator.A();"); | 6971 CompilationUnit unit = parser.parseCompilationUnit2(); |
| 6972 expectNotNullIfNoErrors(unit); |
| 6973 listener.assertNoErrors(); |
| 6368 expect(unit.scriptTag, isNull); | 6974 expect(unit.scriptTag, isNull); |
| 6369 expect(unit.directives, hasLength(0)); | 6975 expect(unit.directives, hasLength(0)); |
| 6370 expect(unit.declarations, hasLength(1)); | 6976 expect(unit.declarations, hasLength(1)); |
| 6371 } | 6977 } |
| 6372 | 6978 |
| 6373 void test_parseCompilationUnit_script() { | 6979 void test_parseCompilationUnit_script() { |
| 6374 CompilationUnit unit = parse4("parseCompilationUnit", "#! /bin/dart"); | 6980 createParser('#! /bin/dart'); |
| 6981 CompilationUnit unit = parser.parseCompilationUnit2(); |
| 6982 expectNotNullIfNoErrors(unit); |
| 6983 listener.assertNoErrors(); |
| 6375 expect(unit.scriptTag, isNotNull); | 6984 expect(unit.scriptTag, isNotNull); |
| 6376 expect(unit.directives, hasLength(0)); | 6985 expect(unit.directives, hasLength(0)); |
| 6377 expect(unit.declarations, hasLength(0)); | 6986 expect(unit.declarations, hasLength(0)); |
| 6378 } | 6987 } |
| 6379 | 6988 |
| 6380 void test_parseCompilationUnit_skipFunctionBody_withInterpolation() { | 6989 void test_parseCompilationUnit_skipFunctionBody_withInterpolation() { |
| 6381 ParserTestCase.parseFunctionBodies = false; | 6990 ParserTestCase.parseFunctionBodies = false; |
| 6382 CompilationUnit unit = parse4("parseCompilationUnit", "f() { '\${n}'; }"); | 6991 createParser('f() { "\${n}"; }'); |
| 6992 CompilationUnit unit = parser.parseCompilationUnit2(); |
| 6993 expectNotNullIfNoErrors(unit); |
| 6994 listener.assertNoErrors(); |
| 6383 expect(unit.scriptTag, isNull); | 6995 expect(unit.scriptTag, isNull); |
| 6384 expect(unit.declarations, hasLength(1)); | 6996 expect(unit.declarations, hasLength(1)); |
| 6385 } | 6997 } |
| 6386 | 6998 |
| 6387 void test_parseCompilationUnit_topLevelDeclaration() { | 6999 void test_parseCompilationUnit_topLevelDeclaration() { |
| 6388 CompilationUnit unit = parse4("parseCompilationUnit", "class A {}"); | 7000 createParser('class A {}'); |
| 7001 CompilationUnit unit = parser.parseCompilationUnit2(); |
| 7002 expectNotNullIfNoErrors(unit); |
| 7003 listener.assertNoErrors(); |
| 6389 expect(unit.scriptTag, isNull); | 7004 expect(unit.scriptTag, isNull); |
| 6390 expect(unit.directives, hasLength(0)); | 7005 expect(unit.directives, hasLength(0)); |
| 6391 expect(unit.declarations, hasLength(1)); | 7006 expect(unit.declarations, hasLength(1)); |
| 6392 } | 7007 } |
| 6393 | 7008 |
| 6394 void test_parseCompilationUnit_typedefAsPrefix() { | 7009 void test_parseCompilationUnit_typedefAsPrefix() { |
| 6395 CompilationUnit unit = | 7010 createParser('typedef.A _typedef = new typedef.A();'); |
| 6396 parse4("parseCompilationUnit", "typedef.A _typedef = new typedef.A();"); | 7011 CompilationUnit unit = parser.parseCompilationUnit2(); |
| 7012 expectNotNullIfNoErrors(unit); |
| 7013 listener.assertNoErrors(); |
| 6397 expect(unit.scriptTag, isNull); | 7014 expect(unit.scriptTag, isNull); |
| 6398 expect(unit.directives, hasLength(0)); | 7015 expect(unit.directives, hasLength(0)); |
| 6399 expect(unit.declarations, hasLength(1)); | 7016 expect(unit.declarations, hasLength(1)); |
| 6400 } | 7017 } |
| 6401 | 7018 |
| 6402 void test_parseCompilationUnitMember_abstractAsPrefix() { | 7019 void test_parseCompilationUnitMember_abstractAsPrefix() { |
| 6403 TopLevelVariableDeclaration declaration = parse( | 7020 TopLevelVariableDeclaration declaration = parse( |
| 6404 "parseCompilationUnitMember", | 7021 "parseCompilationUnitMember", |
| 6405 <Object>[emptyCommentAndMetadata()], | 7022 <Object>[emptyCommentAndMetadata()], |
| 6406 "abstract.A _abstract = new abstract.A();"); | 7023 "abstract.A _abstract = new abstract.A();"); |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6658 void test_parseCompilationUnitMember_variableSet() { | 7275 void test_parseCompilationUnitMember_variableSet() { |
| 6659 TopLevelVariableDeclaration declaration = parse( | 7276 TopLevelVariableDeclaration declaration = parse( |
| 6660 "parseCompilationUnitMember", | 7277 "parseCompilationUnitMember", |
| 6661 <Object>[emptyCommentAndMetadata()], | 7278 <Object>[emptyCommentAndMetadata()], |
| 6662 "String set = null;"); | 7279 "String set = null;"); |
| 6663 expect(declaration.semicolon, isNotNull); | 7280 expect(declaration.semicolon, isNotNull); |
| 6664 expect(declaration.variables, isNotNull); | 7281 expect(declaration.variables, isNotNull); |
| 6665 } | 7282 } |
| 6666 | 7283 |
| 6667 void test_parseConditionalExpression() { | 7284 void test_parseConditionalExpression() { |
| 6668 ConditionalExpression expression = | 7285 createParser('x ? y : z'); |
| 6669 parse4("parseConditionalExpression", "x ? y : z"); | 7286 ConditionalExpression expression = parser.parseConditionalExpression(); |
| 7287 expectNotNullIfNoErrors(expression); |
| 7288 listener.assertNoErrors(); |
| 6670 expect(expression.condition, isNotNull); | 7289 expect(expression.condition, isNotNull); |
| 6671 expect(expression.question, isNotNull); | 7290 expect(expression.question, isNotNull); |
| 6672 expect(expression.thenExpression, isNotNull); | 7291 expect(expression.thenExpression, isNotNull); |
| 6673 expect(expression.colon, isNotNull); | 7292 expect(expression.colon, isNotNull); |
| 6674 expect(expression.elseExpression, isNotNull); | 7293 expect(expression.elseExpression, isNotNull); |
| 6675 } | 7294 } |
| 6676 | 7295 |
| 6677 void test_parseConfiguration_noOperator_dottedIdentifier() { | 7296 void test_parseConfiguration_noOperator_dottedIdentifier() { |
| 6678 Configuration configuration = | 7297 createParser("if (a.b) 'c.dart'"); |
| 6679 parse4('parseConfiguration', "if (a.b) 'c.dart'"); | 7298 Configuration configuration = parser.parseConfiguration(); |
| 7299 expectNotNullIfNoErrors(configuration); |
| 7300 listener.assertNoErrors(); |
| 6680 expect(configuration.ifKeyword, isNotNull); | 7301 expect(configuration.ifKeyword, isNotNull); |
| 6681 expect(configuration.leftParenthesis, isNotNull); | 7302 expect(configuration.leftParenthesis, isNotNull); |
| 6682 _expectDottedName(configuration.name, ["a", "b"]); | 7303 _expectDottedName(configuration.name, ["a", "b"]); |
| 6683 expect(configuration.equalToken, isNull); | 7304 expect(configuration.equalToken, isNull); |
| 6684 expect(configuration.value, isNull); | 7305 expect(configuration.value, isNull); |
| 6685 expect(configuration.rightParenthesis, isNotNull); | 7306 expect(configuration.rightParenthesis, isNotNull); |
| 6686 expect(configuration.uri, isNotNull); | 7307 expect(configuration.uri, isNotNull); |
| 6687 } | 7308 } |
| 6688 | 7309 |
| 6689 void test_parseConfiguration_noOperator_simpleIdentifier() { | 7310 void test_parseConfiguration_noOperator_simpleIdentifier() { |
| 6690 Configuration configuration = | 7311 createParser("if (a) 'b.dart'"); |
| 6691 parse4('parseConfiguration', "if (a) 'b.dart'"); | 7312 Configuration configuration = parser.parseConfiguration(); |
| 7313 expectNotNullIfNoErrors(configuration); |
| 7314 listener.assertNoErrors(); |
| 6692 expect(configuration.ifKeyword, isNotNull); | 7315 expect(configuration.ifKeyword, isNotNull); |
| 6693 expect(configuration.leftParenthesis, isNotNull); | 7316 expect(configuration.leftParenthesis, isNotNull); |
| 6694 _expectDottedName(configuration.name, ["a"]); | 7317 _expectDottedName(configuration.name, ["a"]); |
| 6695 expect(configuration.equalToken, isNull); | 7318 expect(configuration.equalToken, isNull); |
| 6696 expect(configuration.value, isNull); | 7319 expect(configuration.value, isNull); |
| 6697 expect(configuration.rightParenthesis, isNotNull); | 7320 expect(configuration.rightParenthesis, isNotNull); |
| 6698 expect(configuration.uri, isNotNull); | 7321 expect(configuration.uri, isNotNull); |
| 6699 } | 7322 } |
| 6700 | 7323 |
| 6701 void test_parseConfiguration_operator_dottedIdentifier() { | 7324 void test_parseConfiguration_operator_dottedIdentifier() { |
| 6702 Configuration configuration = | 7325 createParser("if (a.b == 'c') 'd.dart'"); |
| 6703 parse4('parseConfiguration', "if (a.b == 'c') 'd.dart'"); | 7326 Configuration configuration = parser.parseConfiguration(); |
| 7327 expectNotNullIfNoErrors(configuration); |
| 7328 listener.assertNoErrors(); |
| 6704 expect(configuration.ifKeyword, isNotNull); | 7329 expect(configuration.ifKeyword, isNotNull); |
| 6705 expect(configuration.leftParenthesis, isNotNull); | 7330 expect(configuration.leftParenthesis, isNotNull); |
| 6706 _expectDottedName(configuration.name, ["a", "b"]); | 7331 _expectDottedName(configuration.name, ["a", "b"]); |
| 6707 expect(configuration.equalToken, isNotNull); | 7332 expect(configuration.equalToken, isNotNull); |
| 6708 expect(configuration.value, isNotNull); | 7333 expect(configuration.value, isNotNull); |
| 6709 expect(configuration.rightParenthesis, isNotNull); | 7334 expect(configuration.rightParenthesis, isNotNull); |
| 6710 expect(configuration.uri, isNotNull); | 7335 expect(configuration.uri, isNotNull); |
| 6711 } | 7336 } |
| 6712 | 7337 |
| 6713 void test_parseConfiguration_operator_simpleIdentifier() { | 7338 void test_parseConfiguration_operator_simpleIdentifier() { |
| 6714 Configuration configuration = | 7339 createParser("if (a == 'b') 'c.dart'"); |
| 6715 parse4('parseConfiguration', "if (a == 'b') 'c.dart'"); | 7340 Configuration configuration = parser.parseConfiguration(); |
| 7341 expectNotNullIfNoErrors(configuration); |
| 7342 listener.assertNoErrors(); |
| 6716 expect(configuration.ifKeyword, isNotNull); | 7343 expect(configuration.ifKeyword, isNotNull); |
| 6717 expect(configuration.leftParenthesis, isNotNull); | 7344 expect(configuration.leftParenthesis, isNotNull); |
| 6718 _expectDottedName(configuration.name, ["a"]); | 7345 _expectDottedName(configuration.name, ["a"]); |
| 6719 expect(configuration.equalToken, isNotNull); | 7346 expect(configuration.equalToken, isNotNull); |
| 6720 expect(configuration.value, isNotNull); | 7347 expect(configuration.value, isNotNull); |
| 6721 expect(configuration.rightParenthesis, isNotNull); | 7348 expect(configuration.rightParenthesis, isNotNull); |
| 6722 expect(configuration.uri, isNotNull); | 7349 expect(configuration.uri, isNotNull); |
| 6723 } | 7350 } |
| 6724 | 7351 |
| 6725 void test_parseConstExpression_instanceCreation() { | 7352 void test_parseConstExpression_instanceCreation() { |
| 6726 InstanceCreationExpression expression = | 7353 createParser('const A()'); |
| 6727 parse4("parseConstExpression", "const A()"); | 7354 Expression expression = parser.parseConstExpression(); |
| 6728 expect(expression.keyword, isNotNull); | 7355 expectNotNullIfNoErrors(expression); |
| 6729 ConstructorName name = expression.constructorName; | 7356 listener.assertNoErrors(); |
| 7357 expect(expression, new isInstanceOf<InstanceCreationExpression>()); |
| 7358 InstanceCreationExpression instanceCreation = expression; |
| 7359 expect(instanceCreation.keyword, isNotNull); |
| 7360 ConstructorName name = instanceCreation.constructorName; |
| 6730 expect(name, isNotNull); | 7361 expect(name, isNotNull); |
| 6731 expect(name.type, isNotNull); | 7362 expect(name.type, isNotNull); |
| 6732 expect(name.period, isNull); | 7363 expect(name.period, isNull); |
| 6733 expect(name.name, isNull); | 7364 expect(name.name, isNull); |
| 6734 expect(expression.argumentList, isNotNull); | 7365 expect(instanceCreation.argumentList, isNotNull); |
| 6735 } | 7366 } |
| 6736 | 7367 |
| 6737 void test_parseConstExpression_listLiteral_typed() { | 7368 void test_parseConstExpression_listLiteral_typed() { |
| 6738 ListLiteral literal = parse4("parseConstExpression", "const <A> []"); | 7369 createParser('const <A> []'); |
| 7370 Expression expression = parser.parseConstExpression(); |
| 7371 expectNotNullIfNoErrors(expression); |
| 7372 listener.assertNoErrors(); |
| 7373 expect(expression, new isInstanceOf<ListLiteral>()); |
| 7374 ListLiteral literal = expression; |
| 6739 expect(literal.constKeyword, isNotNull); | 7375 expect(literal.constKeyword, isNotNull); |
| 6740 expect(literal.typeArguments, isNotNull); | 7376 expect(literal.typeArguments, isNotNull); |
| 6741 expect(literal.leftBracket, isNotNull); | 7377 expect(literal.leftBracket, isNotNull); |
| 6742 expect(literal.elements, hasLength(0)); | 7378 expect(literal.elements, hasLength(0)); |
| 6743 expect(literal.rightBracket, isNotNull); | 7379 expect(literal.rightBracket, isNotNull); |
| 6744 } | 7380 } |
| 6745 | 7381 |
| 6746 void test_parseConstExpression_listLiteral_typed_genericComment() { | 7382 void test_parseConstExpression_listLiteral_typed_genericComment() { |
| 6747 enableGenericMethodComments = true; | 7383 enableGenericMethodComments = true; |
| 6748 ListLiteral literal = parse4("parseConstExpression", "const /*<A>*/ []"); | 7384 createParser('const /*<A>*/ []'); |
| 7385 Expression expression = parser.parseConstExpression(); |
| 7386 expectNotNullIfNoErrors(expression); |
| 7387 listener.assertNoErrors(); |
| 7388 expect(expression, new isInstanceOf<ListLiteral>()); |
| 7389 ListLiteral literal = expression; |
| 6749 expect(literal.constKeyword, isNotNull); | 7390 expect(literal.constKeyword, isNotNull); |
| 6750 expect(literal.typeArguments, isNotNull); | 7391 expect(literal.typeArguments, isNotNull); |
| 6751 expect(literal.leftBracket, isNotNull); | 7392 expect(literal.leftBracket, isNotNull); |
| 6752 expect(literal.elements, hasLength(0)); | 7393 expect(literal.elements, hasLength(0)); |
| 6753 expect(literal.rightBracket, isNotNull); | 7394 expect(literal.rightBracket, isNotNull); |
| 6754 } | 7395 } |
| 6755 | 7396 |
| 6756 void test_parseConstExpression_listLiteral_untyped() { | 7397 void test_parseConstExpression_listLiteral_untyped() { |
| 6757 ListLiteral literal = parse4("parseConstExpression", "const []"); | 7398 createParser('const []'); |
| 7399 Expression expression = parser.parseConstExpression(); |
| 7400 expectNotNullIfNoErrors(expression); |
| 7401 listener.assertNoErrors(); |
| 7402 expect(expression, new isInstanceOf<ListLiteral>()); |
| 7403 ListLiteral literal = expression; |
| 6758 expect(literal.constKeyword, isNotNull); | 7404 expect(literal.constKeyword, isNotNull); |
| 6759 expect(literal.typeArguments, isNull); | 7405 expect(literal.typeArguments, isNull); |
| 6760 expect(literal.leftBracket, isNotNull); | 7406 expect(literal.leftBracket, isNotNull); |
| 6761 expect(literal.elements, hasLength(0)); | 7407 expect(literal.elements, hasLength(0)); |
| 6762 expect(literal.rightBracket, isNotNull); | 7408 expect(literal.rightBracket, isNotNull); |
| 6763 } | 7409 } |
| 6764 | 7410 |
| 6765 void test_parseConstExpression_mapLiteral_typed() { | 7411 void test_parseConstExpression_mapLiteral_typed() { |
| 6766 MapLiteral literal = parse4("parseConstExpression", "const <A, B> {}"); | 7412 createParser('const <A, B> {}'); |
| 7413 Expression expression = parser.parseConstExpression(); |
| 7414 expectNotNullIfNoErrors(expression); |
| 7415 listener.assertNoErrors(); |
| 7416 expect(expression, new isInstanceOf<MapLiteral>()); |
| 7417 MapLiteral literal = expression; |
| 6767 expect(literal.leftBracket, isNotNull); | 7418 expect(literal.leftBracket, isNotNull); |
| 6768 expect(literal.entries, hasLength(0)); | 7419 expect(literal.entries, hasLength(0)); |
| 6769 expect(literal.rightBracket, isNotNull); | 7420 expect(literal.rightBracket, isNotNull); |
| 6770 expect(literal.typeArguments, isNotNull); | 7421 expect(literal.typeArguments, isNotNull); |
| 6771 } | 7422 } |
| 6772 | 7423 |
| 6773 void test_parseConstExpression_mapLiteral_typed_genericComment() { | 7424 void test_parseConstExpression_mapLiteral_typed_genericComment() { |
| 6774 enableGenericMethodComments = true; | 7425 enableGenericMethodComments = true; |
| 6775 MapLiteral literal = parse4("parseConstExpression", "const /*<A, B>*/ {}"); | 7426 createParser('const /*<A, B>*/ {}'); |
| 7427 Expression expression = parser.parseConstExpression(); |
| 7428 expectNotNullIfNoErrors(expression); |
| 7429 listener.assertNoErrors(); |
| 7430 expect(expression, new isInstanceOf<MapLiteral>()); |
| 7431 MapLiteral literal = expression; |
| 6776 expect(literal.leftBracket, isNotNull); | 7432 expect(literal.leftBracket, isNotNull); |
| 6777 expect(literal.entries, hasLength(0)); | 7433 expect(literal.entries, hasLength(0)); |
| 6778 expect(literal.rightBracket, isNotNull); | 7434 expect(literal.rightBracket, isNotNull); |
| 6779 expect(literal.typeArguments, isNotNull); | 7435 expect(literal.typeArguments, isNotNull); |
| 6780 } | 7436 } |
| 6781 | 7437 |
| 6782 void test_parseConstExpression_mapLiteral_untyped() { | 7438 void test_parseConstExpression_mapLiteral_untyped() { |
| 6783 MapLiteral literal = parse4("parseConstExpression", "const {}"); | 7439 createParser('const {}'); |
| 7440 Expression expression = parser.parseConstExpression(); |
| 7441 expectNotNullIfNoErrors(expression); |
| 7442 listener.assertNoErrors(); |
| 7443 expect(expression, new isInstanceOf<MapLiteral>()); |
| 7444 MapLiteral literal = expression; |
| 6784 expect(literal.leftBracket, isNotNull); | 7445 expect(literal.leftBracket, isNotNull); |
| 6785 expect(literal.entries, hasLength(0)); | 7446 expect(literal.entries, hasLength(0)); |
| 6786 expect(literal.rightBracket, isNotNull); | 7447 expect(literal.rightBracket, isNotNull); |
| 6787 expect(literal.typeArguments, isNull); | 7448 expect(literal.typeArguments, isNull); |
| 6788 } | 7449 } |
| 6789 | 7450 |
| 6790 void test_parseConstructor() { | 7451 void test_parseConstructor() { |
| 6791 // TODO(brianwilkerson) Implement tests for this method. | 7452 // TODO(brianwilkerson) Implement tests for this method. |
| 6792 // parse("parseConstructor", new Class[] {Parser.CommentAndMetadata.class, | 7453 // parse("parseConstructor", new Class[] {Parser.CommentAndMetadata.class, |
| 6793 // Token.class, Token.class, SimpleIdentifier.class, Token.class, | 7454 // Token.class, Token.class, SimpleIdentifier.class, Token.class, |
| (...skipping 27 matching lines...) Expand all Loading... |
| 6821 EngineTestCase.assertInstanceOf( | 7482 EngineTestCase.assertInstanceOf( |
| 6822 (obj) => obj is ParenthesizedExpression, | 7483 (obj) => obj is ParenthesizedExpression, |
| 6823 ParenthesizedExpression, | 7484 ParenthesizedExpression, |
| 6824 (initializer as ConstructorFieldInitializer).expression); | 7485 (initializer as ConstructorFieldInitializer).expression); |
| 6825 EngineTestCase.assertInstanceOf( | 7486 EngineTestCase.assertInstanceOf( |
| 6826 (obj) => obj is BlockFunctionBody, BlockFunctionBody, constructor.body); | 7487 (obj) => obj is BlockFunctionBody, BlockFunctionBody, constructor.body); |
| 6827 } | 7488 } |
| 6828 | 7489 |
| 6829 void test_parseConstructorFieldInitializer_qualified() { | 7490 void test_parseConstructorFieldInitializer_qualified() { |
| 6830 ConstructorFieldInitializer invocation = | 7491 ConstructorFieldInitializer invocation = |
| 6831 parse2("parseConstructorFieldInitializer", [true], "this.a = b"); | 7492 parse("parseConstructorFieldInitializer", [true], "this.a = b"); |
| 6832 expect(invocation.equals, isNotNull); | 7493 expect(invocation.equals, isNotNull); |
| 6833 expect(invocation.expression, isNotNull); | 7494 expect(invocation.expression, isNotNull); |
| 6834 expect(invocation.fieldName, isNotNull); | 7495 expect(invocation.fieldName, isNotNull); |
| 6835 expect(invocation.thisKeyword, isNotNull); | 7496 expect(invocation.thisKeyword, isNotNull); |
| 6836 expect(invocation.period, isNotNull); | 7497 expect(invocation.period, isNotNull); |
| 6837 } | 7498 } |
| 6838 | 7499 |
| 6839 void test_parseConstructorFieldInitializer_unqualified() { | 7500 void test_parseConstructorFieldInitializer_unqualified() { |
| 6840 ConstructorFieldInitializer invocation = | 7501 ConstructorFieldInitializer invocation = |
| 6841 parse2("parseConstructorFieldInitializer", [false], "a = b"); | 7502 parse("parseConstructorFieldInitializer", [false], "a = b"); |
| 6842 expect(invocation.equals, isNotNull); | 7503 expect(invocation.equals, isNotNull); |
| 6843 expect(invocation.expression, isNotNull); | 7504 expect(invocation.expression, isNotNull); |
| 6844 expect(invocation.fieldName, isNotNull); | 7505 expect(invocation.fieldName, isNotNull); |
| 6845 expect(invocation.thisKeyword, isNull); | 7506 expect(invocation.thisKeyword, isNull); |
| 6846 expect(invocation.period, isNull); | 7507 expect(invocation.period, isNull); |
| 6847 } | 7508 } |
| 6848 | 7509 |
| 6849 void test_parseConstructorName_named_noPrefix() { | 7510 void test_parseConstructorName_named_noPrefix() { |
| 6850 ConstructorName name = parse4("parseConstructorName", "A.n;"); | 7511 createParser('A.n;'); |
| 7512 ConstructorName name = parser.parseConstructorName(); |
| 7513 expectNotNullIfNoErrors(name); |
| 7514 listener.assertNoErrors(); |
| 6851 expect(name.type, isNotNull); | 7515 expect(name.type, isNotNull); |
| 6852 expect(name.period, isNull); | 7516 expect(name.period, isNull); |
| 6853 expect(name.name, isNull); | 7517 expect(name.name, isNull); |
| 6854 } | 7518 } |
| 6855 | 7519 |
| 6856 void test_parseConstructorName_named_prefixed() { | 7520 void test_parseConstructorName_named_prefixed() { |
| 6857 ConstructorName name = parse4("parseConstructorName", "p.A.n;"); | 7521 createParser('p.A.n;'); |
| 7522 ConstructorName name = parser.parseConstructorName(); |
| 7523 expectNotNullIfNoErrors(name); |
| 7524 listener.assertNoErrors(); |
| 6858 expect(name.type, isNotNull); | 7525 expect(name.type, isNotNull); |
| 6859 expect(name.period, isNotNull); | 7526 expect(name.period, isNotNull); |
| 6860 expect(name.name, isNotNull); | 7527 expect(name.name, isNotNull); |
| 6861 } | 7528 } |
| 6862 | 7529 |
| 6863 void test_parseConstructorName_unnamed_noPrefix() { | 7530 void test_parseConstructorName_unnamed_noPrefix() { |
| 6864 ConstructorName name = parse4("parseConstructorName", "A;"); | 7531 createParser('A;'); |
| 7532 ConstructorName name = parser.parseConstructorName(); |
| 7533 expectNotNullIfNoErrors(name); |
| 7534 listener.assertNoErrors(); |
| 6865 expect(name.type, isNotNull); | 7535 expect(name.type, isNotNull); |
| 6866 expect(name.period, isNull); | 7536 expect(name.period, isNull); |
| 6867 expect(name.name, isNull); | 7537 expect(name.name, isNull); |
| 6868 } | 7538 } |
| 6869 | 7539 |
| 6870 void test_parseConstructorName_unnamed_prefixed() { | 7540 void test_parseConstructorName_unnamed_prefixed() { |
| 6871 ConstructorName name = parse4("parseConstructorName", "p.A;"); | 7541 createParser('p.A;'); |
| 7542 ConstructorName name = parser.parseConstructorName(); |
| 7543 expectNotNullIfNoErrors(name); |
| 7544 listener.assertNoErrors(); |
| 6872 expect(name.type, isNotNull); | 7545 expect(name.type, isNotNull); |
| 6873 expect(name.period, isNull); | 7546 expect(name.period, isNull); |
| 6874 expect(name.name, isNull); | 7547 expect(name.name, isNull); |
| 6875 } | 7548 } |
| 6876 | 7549 |
| 6877 void test_parseContinueStatement_label() { | 7550 void test_parseContinueStatement_label() { |
| 6878 ContinueStatement statement = parse4("parseContinueStatement", | 7551 createParser('continue foo;'); |
| 6879 "continue foo;", [ParserErrorCode.CONTINUE_OUTSIDE_OF_LOOP]); | 7552 ContinueStatement statement = parser.parseContinueStatement(); |
| 7553 expectNotNullIfNoErrors(statement); |
| 7554 listener.assertErrorsWithCodes([ParserErrorCode.CONTINUE_OUTSIDE_OF_LOOP]); |
| 6880 expect(statement.continueKeyword, isNotNull); | 7555 expect(statement.continueKeyword, isNotNull); |
| 6881 expect(statement.label, isNotNull); | 7556 expect(statement.label, isNotNull); |
| 6882 expect(statement.semicolon, isNotNull); | 7557 expect(statement.semicolon, isNotNull); |
| 6883 } | 7558 } |
| 6884 | 7559 |
| 6885 void test_parseContinueStatement_noLabel() { | 7560 void test_parseContinueStatement_noLabel() { |
| 6886 ContinueStatement statement = parse4("parseContinueStatement", "continue;", | 7561 createParser('continue;'); |
| 6887 [ParserErrorCode.CONTINUE_OUTSIDE_OF_LOOP]); | 7562 ContinueStatement statement = parser.parseContinueStatement(); |
| 7563 expectNotNullIfNoErrors(statement); |
| 7564 listener.assertErrorsWithCodes([ParserErrorCode.CONTINUE_OUTSIDE_OF_LOOP]); |
| 6888 expect(statement.continueKeyword, isNotNull); | 7565 expect(statement.continueKeyword, isNotNull); |
| 6889 expect(statement.label, isNull); | 7566 expect(statement.label, isNull); |
| 6890 expect(statement.semicolon, isNotNull); | 7567 expect(statement.semicolon, isNotNull); |
| 6891 } | 7568 } |
| 6892 | 7569 |
| 6893 void test_parseDirective_export() { | 7570 void test_parseDirective_export() { |
| 6894 ExportDirective directive = parse("parseDirective", | 7571 ExportDirective directive = parse("parseDirective", |
| 6895 <Object>[emptyCommentAndMetadata()], "export 'lib/lib.dart';"); | 7572 <Object>[emptyCommentAndMetadata()], "export 'lib/lib.dart';"); |
| 6896 expect(directive.keyword, isNotNull); | 7573 expect(directive.keyword, isNotNull); |
| 6897 expect(directive.uri, isNotNull); | 7574 expect(directive.uri, isNotNull); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6973 expect(unit.directives, hasLength(1)); | 7650 expect(unit.directives, hasLength(1)); |
| 6974 } | 7651 } |
| 6975 | 7652 |
| 6976 void test_parseDirectives_topLevelDeclaration() { | 7653 void test_parseDirectives_topLevelDeclaration() { |
| 6977 CompilationUnit unit = _parseDirectives("class A {}"); | 7654 CompilationUnit unit = _parseDirectives("class A {}"); |
| 6978 expect(unit.scriptTag, isNull); | 7655 expect(unit.scriptTag, isNull); |
| 6979 expect(unit.directives, hasLength(0)); | 7656 expect(unit.directives, hasLength(0)); |
| 6980 } | 7657 } |
| 6981 | 7658 |
| 6982 void test_parseDocumentationComment_block() { | 7659 void test_parseDocumentationComment_block() { |
| 6983 Comment comment = parse4("parseDocumentationComment", "/** */ class"); | 7660 createParser('/** */ class'); |
| 7661 Comment comment = parser |
| 7662 .parseDocumentationComment(parser.parseDocumentationCommentTokens()); |
| 7663 expectNotNullIfNoErrors(comment); |
| 7664 listener.assertNoErrors(); |
| 6984 expect(comment.isBlock, isFalse); | 7665 expect(comment.isBlock, isFalse); |
| 6985 expect(comment.isDocumentation, isTrue); | 7666 expect(comment.isDocumentation, isTrue); |
| 6986 expect(comment.isEndOfLine, isFalse); | 7667 expect(comment.isEndOfLine, isFalse); |
| 6987 } | 7668 } |
| 6988 | 7669 |
| 6989 void test_parseDocumentationComment_block_withReference() { | 7670 void test_parseDocumentationComment_block_withReference() { |
| 6990 Comment comment = parse4("parseDocumentationComment", "/** [a] */ class"); | 7671 createParser('/** [a] */ class'); |
| 7672 Comment comment = parser |
| 7673 .parseDocumentationComment(parser.parseDocumentationCommentTokens()); |
| 7674 expectNotNullIfNoErrors(comment); |
| 7675 listener.assertNoErrors(); |
| 6991 expect(comment.isBlock, isFalse); | 7676 expect(comment.isBlock, isFalse); |
| 6992 expect(comment.isDocumentation, isTrue); | 7677 expect(comment.isDocumentation, isTrue); |
| 6993 expect(comment.isEndOfLine, isFalse); | 7678 expect(comment.isEndOfLine, isFalse); |
| 6994 NodeList<CommentReference> references = comment.references; | 7679 NodeList<CommentReference> references = comment.references; |
| 6995 expect(references, hasLength(1)); | 7680 expect(references, hasLength(1)); |
| 6996 CommentReference reference = references[0]; | 7681 CommentReference reference = references[0]; |
| 6997 expect(reference, isNotNull); | 7682 expect(reference, isNotNull); |
| 6998 expect(reference.offset, 5); | 7683 expect(reference.offset, 5); |
| 6999 } | 7684 } |
| 7000 | 7685 |
| 7001 void test_parseDocumentationComment_endOfLine() { | 7686 void test_parseDocumentationComment_endOfLine() { |
| 7002 Comment comment = parse4("parseDocumentationComment", "/// \n/// \n class"); | 7687 createParser('/// \n/// \n class'); |
| 7688 Comment comment = parser |
| 7689 .parseDocumentationComment(parser.parseDocumentationCommentTokens()); |
| 7690 expectNotNullIfNoErrors(comment); |
| 7691 listener.assertNoErrors(); |
| 7003 expect(comment.isBlock, isFalse); | 7692 expect(comment.isBlock, isFalse); |
| 7004 expect(comment.isDocumentation, isTrue); | 7693 expect(comment.isDocumentation, isTrue); |
| 7005 expect(comment.isEndOfLine, isFalse); | 7694 expect(comment.isEndOfLine, isFalse); |
| 7006 } | 7695 } |
| 7007 | 7696 |
| 7008 void test_parseDoStatement() { | 7697 void test_parseDoStatement() { |
| 7009 DoStatement statement = parse4("parseDoStatement", "do {} while (x);"); | 7698 createParser('do {} while (x);'); |
| 7699 DoStatement statement = parser.parseDoStatement(); |
| 7700 expectNotNullIfNoErrors(statement); |
| 7701 listener.assertNoErrors(); |
| 7010 expect(statement.doKeyword, isNotNull); | 7702 expect(statement.doKeyword, isNotNull); |
| 7011 expect(statement.body, isNotNull); | 7703 expect(statement.body, isNotNull); |
| 7012 expect(statement.whileKeyword, isNotNull); | 7704 expect(statement.whileKeyword, isNotNull); |
| 7013 expect(statement.leftParenthesis, isNotNull); | 7705 expect(statement.leftParenthesis, isNotNull); |
| 7014 expect(statement.condition, isNotNull); | 7706 expect(statement.condition, isNotNull); |
| 7015 expect(statement.rightParenthesis, isNotNull); | 7707 expect(statement.rightParenthesis, isNotNull); |
| 7016 expect(statement.semicolon, isNotNull); | 7708 expect(statement.semicolon, isNotNull); |
| 7017 } | 7709 } |
| 7018 | 7710 |
| 7019 void test_parseDottedName_multiple() { | 7711 void test_parseDottedName_multiple() { |
| 7020 DottedName name = parse4("parseDottedName", "a.b.c"); | 7712 createParser('a.b.c'); |
| 7713 DottedName name = parser.parseDottedName(); |
| 7714 expectNotNullIfNoErrors(name); |
| 7715 listener.assertNoErrors(); |
| 7021 _expectDottedName(name, ["a", "b", "c"]); | 7716 _expectDottedName(name, ["a", "b", "c"]); |
| 7022 } | 7717 } |
| 7023 | 7718 |
| 7024 void test_parseDottedName_single() { | 7719 void test_parseDottedName_single() { |
| 7025 DottedName name = parse4("parseDottedName", "a"); | 7720 createParser('a'); |
| 7721 DottedName name = parser.parseDottedName(); |
| 7722 expectNotNullIfNoErrors(name); |
| 7723 listener.assertNoErrors(); |
| 7026 _expectDottedName(name, ["a"]); | 7724 _expectDottedName(name, ["a"]); |
| 7027 } | 7725 } |
| 7028 | 7726 |
| 7029 void test_parseEmptyStatement() { | 7727 void test_parseEmptyStatement() { |
| 7030 EmptyStatement statement = parse4("parseEmptyStatement", ";"); | 7728 createParser(';'); |
| 7729 EmptyStatement statement = parser.parseEmptyStatement(); |
| 7730 expectNotNullIfNoErrors(statement); |
| 7731 listener.assertNoErrors(); |
| 7031 expect(statement.semicolon, isNotNull); | 7732 expect(statement.semicolon, isNotNull); |
| 7032 } | 7733 } |
| 7033 | 7734 |
| 7034 void test_parseEnumDeclaration_one() { | 7735 void test_parseEnumDeclaration_one() { |
| 7035 EnumDeclaration declaration = parse("parseEnumDeclaration", | 7736 EnumDeclaration declaration = parse("parseEnumDeclaration", |
| 7036 <Object>[emptyCommentAndMetadata()], "enum E {ONE}"); | 7737 <Object>[emptyCommentAndMetadata()], "enum E {ONE}"); |
| 7037 expect(declaration.documentationComment, isNull); | 7738 expect(declaration.documentationComment, isNull); |
| 7038 expect(declaration.enumKeyword, isNotNull); | 7739 expect(declaration.enumKeyword, isNotNull); |
| 7039 expect(declaration.leftBracket, isNotNull); | 7740 expect(declaration.leftBracket, isNotNull); |
| 7040 expect(declaration.name, isNotNull); | 7741 expect(declaration.name, isNotNull); |
| (...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7560 expect(simpleParameter.identifier, isNotNull); | 8261 expect(simpleParameter.identifier, isNotNull); |
| 7561 expect(simpleParameter.keyword, isNotNull); | 8262 expect(simpleParameter.keyword, isNotNull); |
| 7562 expect(simpleParameter.type, isNull); | 8263 expect(simpleParameter.type, isNull); |
| 7563 expect(simpleParameter.kind, kind); | 8264 expect(simpleParameter.kind, kind); |
| 7564 expect(parameter.separator, isNotNull); | 8265 expect(parameter.separator, isNotNull); |
| 7565 expect(parameter.defaultValue, isNotNull); | 8266 expect(parameter.defaultValue, isNotNull); |
| 7566 expect(parameter.kind, kind); | 8267 expect(parameter.kind, kind); |
| 7567 } | 8268 } |
| 7568 | 8269 |
| 7569 void test_parseFormalParameterList_empty() { | 8270 void test_parseFormalParameterList_empty() { |
| 7570 FormalParameterList parameterList = | 8271 createParser('()'); |
| 7571 parse4("parseFormalParameterList", "()"); | 8272 FormalParameterList list = parser.parseFormalParameterList(); |
| 7572 expect(parameterList.leftParenthesis, isNotNull); | 8273 expectNotNullIfNoErrors(list); |
| 7573 expect(parameterList.leftDelimiter, isNull); | 8274 listener.assertNoErrors(); |
| 7574 expect(parameterList.parameters, hasLength(0)); | 8275 expect(list.leftParenthesis, isNotNull); |
| 7575 expect(parameterList.rightDelimiter, isNull); | 8276 expect(list.leftDelimiter, isNull); |
| 7576 expect(parameterList.rightParenthesis, isNotNull); | 8277 expect(list.parameters, hasLength(0)); |
| 8278 expect(list.rightDelimiter, isNull); |
| 8279 expect(list.rightParenthesis, isNotNull); |
| 7577 } | 8280 } |
| 7578 | 8281 |
| 7579 void test_parseFormalParameterList_named_multiple() { | 8282 void test_parseFormalParameterList_named_multiple() { |
| 7580 FormalParameterList parameterList = | 8283 createParser('({A a : 1, B b, C c : 3})'); |
| 7581 parse4("parseFormalParameterList", "({A a : 1, B b, C c : 3})"); | 8284 FormalParameterList list = parser.parseFormalParameterList(); |
| 7582 expect(parameterList.leftParenthesis, isNotNull); | 8285 expectNotNullIfNoErrors(list); |
| 7583 expect(parameterList.leftDelimiter, isNotNull); | 8286 listener.assertNoErrors(); |
| 7584 expect(parameterList.parameters, hasLength(3)); | 8287 expect(list.leftParenthesis, isNotNull); |
| 7585 expect(parameterList.rightDelimiter, isNotNull); | 8288 expect(list.leftDelimiter, isNotNull); |
| 7586 expect(parameterList.rightParenthesis, isNotNull); | 8289 expect(list.parameters, hasLength(3)); |
| 8290 expect(list.rightDelimiter, isNotNull); |
| 8291 expect(list.rightParenthesis, isNotNull); |
| 7587 } | 8292 } |
| 7588 | 8293 |
| 7589 void test_parseFormalParameterList_named_single() { | 8294 void test_parseFormalParameterList_named_single() { |
| 7590 FormalParameterList parameterList = | 8295 createParser('({A a})'); |
| 7591 parse4("parseFormalParameterList", "({A a})"); | 8296 FormalParameterList list = parser.parseFormalParameterList(); |
| 7592 expect(parameterList.leftParenthesis, isNotNull); | 8297 expectNotNullIfNoErrors(list); |
| 7593 expect(parameterList.leftDelimiter, isNotNull); | 8298 listener.assertNoErrors(); |
| 7594 expect(parameterList.parameters, hasLength(1)); | 8299 expect(list.leftParenthesis, isNotNull); |
| 7595 expect(parameterList.rightDelimiter, isNotNull); | 8300 expect(list.leftDelimiter, isNotNull); |
| 7596 expect(parameterList.rightParenthesis, isNotNull); | 8301 expect(list.parameters, hasLength(1)); |
| 8302 expect(list.rightDelimiter, isNotNull); |
| 8303 expect(list.rightParenthesis, isNotNull); |
| 7597 } | 8304 } |
| 7598 | 8305 |
| 7599 void test_parseFormalParameterList_named_trailing_comma() { | 8306 void test_parseFormalParameterList_named_trailing_comma() { |
| 7600 FormalParameterList parameterList = | 8307 createParser('(A a, {B b,})'); |
| 7601 parse4("parseFormalParameterList", "(A a, {B b,})"); | 8308 FormalParameterList list = parser.parseFormalParameterList(); |
| 7602 expect(parameterList.leftParenthesis, isNotNull); | 8309 expectNotNullIfNoErrors(list); |
| 7603 expect(parameterList.leftDelimiter, isNotNull); | 8310 listener.assertNoErrors(); |
| 7604 expect(parameterList.parameters, hasLength(2)); | 8311 expect(list.leftParenthesis, isNotNull); |
| 7605 expect(parameterList.rightDelimiter, isNotNull); | 8312 expect(list.leftDelimiter, isNotNull); |
| 7606 expect(parameterList.rightParenthesis, isNotNull); | 8313 expect(list.parameters, hasLength(2)); |
| 8314 expect(list.rightDelimiter, isNotNull); |
| 8315 expect(list.rightParenthesis, isNotNull); |
| 7607 } | 8316 } |
| 7608 | 8317 |
| 7609 void test_parseFormalParameterList_normal_multiple() { | 8318 void test_parseFormalParameterList_normal_multiple() { |
| 7610 FormalParameterList parameterList = | 8319 createParser('(A a, B b, C c)'); |
| 7611 parse4("parseFormalParameterList", "(A a, B b, C c)"); | 8320 FormalParameterList list = parser.parseFormalParameterList(); |
| 7612 expect(parameterList.leftParenthesis, isNotNull); | 8321 expectNotNullIfNoErrors(list); |
| 7613 expect(parameterList.leftDelimiter, isNull); | 8322 listener.assertNoErrors(); |
| 7614 expect(parameterList.parameters, hasLength(3)); | 8323 expect(list.leftParenthesis, isNotNull); |
| 7615 expect(parameterList.rightDelimiter, isNull); | 8324 expect(list.leftDelimiter, isNull); |
| 7616 expect(parameterList.rightParenthesis, isNotNull); | 8325 expect(list.parameters, hasLength(3)); |
| 8326 expect(list.rightDelimiter, isNull); |
| 8327 expect(list.rightParenthesis, isNotNull); |
| 7617 } | 8328 } |
| 7618 | 8329 |
| 7619 void test_parseFormalParameterList_normal_named() { | 8330 void test_parseFormalParameterList_normal_named() { |
| 7620 FormalParameterList parameterList = | 8331 createParser('(A a, {B b})'); |
| 7621 parse4("parseFormalParameterList", "(A a, {B b})"); | 8332 FormalParameterList list = parser.parseFormalParameterList(); |
| 7622 expect(parameterList.leftParenthesis, isNotNull); | 8333 expectNotNullIfNoErrors(list); |
| 7623 expect(parameterList.leftDelimiter, isNotNull); | 8334 listener.assertNoErrors(); |
| 7624 expect(parameterList.parameters, hasLength(2)); | 8335 expect(list.leftParenthesis, isNotNull); |
| 7625 expect(parameterList.rightDelimiter, isNotNull); | 8336 expect(list.leftDelimiter, isNotNull); |
| 7626 expect(parameterList.rightParenthesis, isNotNull); | 8337 expect(list.parameters, hasLength(2)); |
| 8338 expect(list.rightDelimiter, isNotNull); |
| 8339 expect(list.rightParenthesis, isNotNull); |
| 7627 } | 8340 } |
| 7628 | 8341 |
| 7629 void test_parseFormalParameterList_normal_positional() { | 8342 void test_parseFormalParameterList_normal_positional() { |
| 7630 FormalParameterList parameterList = | 8343 createParser('(A a, [B b])'); |
| 7631 parse4("parseFormalParameterList", "(A a, [B b])"); | 8344 FormalParameterList list = parser.parseFormalParameterList(); |
| 7632 expect(parameterList.leftParenthesis, isNotNull); | 8345 expectNotNullIfNoErrors(list); |
| 7633 expect(parameterList.leftDelimiter, isNotNull); | 8346 listener.assertNoErrors(); |
| 7634 expect(parameterList.parameters, hasLength(2)); | 8347 expect(list.leftParenthesis, isNotNull); |
| 7635 expect(parameterList.rightDelimiter, isNotNull); | 8348 expect(list.leftDelimiter, isNotNull); |
| 7636 expect(parameterList.rightParenthesis, isNotNull); | 8349 expect(list.parameters, hasLength(2)); |
| 8350 expect(list.rightDelimiter, isNotNull); |
| 8351 expect(list.rightParenthesis, isNotNull); |
| 7637 } | 8352 } |
| 7638 | 8353 |
| 7639 void test_parseFormalParameterList_normal_single() { | 8354 void test_parseFormalParameterList_normal_single() { |
| 7640 FormalParameterList parameterList = | 8355 createParser('(A a)'); |
| 7641 parse4("parseFormalParameterList", "(A a)"); | 8356 FormalParameterList list = parser.parseFormalParameterList(); |
| 7642 expect(parameterList.leftParenthesis, isNotNull); | 8357 expectNotNullIfNoErrors(list); |
| 7643 expect(parameterList.leftDelimiter, isNull); | 8358 listener.assertNoErrors(); |
| 7644 expect(parameterList.parameters, hasLength(1)); | 8359 expect(list.leftParenthesis, isNotNull); |
| 7645 expect(parameterList.rightDelimiter, isNull); | 8360 expect(list.leftDelimiter, isNull); |
| 7646 expect(parameterList.rightParenthesis, isNotNull); | 8361 expect(list.parameters, hasLength(1)); |
| 8362 expect(list.rightDelimiter, isNull); |
| 8363 expect(list.rightParenthesis, isNotNull); |
| 7647 } | 8364 } |
| 7648 | 8365 |
| 7649 void test_parseFormalParameterList_normal_single_trailing_comma() { | 8366 void test_parseFormalParameterList_normal_single_trailing_comma() { |
| 7650 FormalParameterList parameterList = | 8367 createParser('(A a,)'); |
| 7651 parse4("parseFormalParameterList", "(A a,)"); | 8368 FormalParameterList list = parser.parseFormalParameterList(); |
| 7652 expect(parameterList.leftParenthesis, isNotNull); | 8369 expectNotNullIfNoErrors(list); |
| 7653 expect(parameterList.leftDelimiter, isNull); | 8370 listener.assertNoErrors(); |
| 7654 expect(parameterList.parameters, hasLength(1)); | 8371 expect(list.leftParenthesis, isNotNull); |
| 7655 expect(parameterList.rightDelimiter, isNull); | 8372 expect(list.leftDelimiter, isNull); |
| 7656 expect(parameterList.rightParenthesis, isNotNull); | 8373 expect(list.parameters, hasLength(1)); |
| 8374 expect(list.rightDelimiter, isNull); |
| 8375 expect(list.rightParenthesis, isNotNull); |
| 7657 } | 8376 } |
| 7658 | 8377 |
| 7659 void test_parseFormalParameterList_positional_multiple() { | 8378 void test_parseFormalParameterList_positional_multiple() { |
| 7660 FormalParameterList parameterList = | 8379 createParser('([A a = null, B b, C c = null])'); |
| 7661 parse4("parseFormalParameterList", "([A a = null, B b, C c = null])"); | 8380 FormalParameterList list = parser.parseFormalParameterList(); |
| 7662 expect(parameterList.leftParenthesis, isNotNull); | 8381 expectNotNullIfNoErrors(list); |
| 7663 expect(parameterList.leftDelimiter, isNotNull); | 8382 listener.assertNoErrors(); |
| 7664 expect(parameterList.parameters, hasLength(3)); | 8383 expect(list.leftParenthesis, isNotNull); |
| 7665 expect(parameterList.rightDelimiter, isNotNull); | 8384 expect(list.leftDelimiter, isNotNull); |
| 7666 expect(parameterList.rightParenthesis, isNotNull); | 8385 expect(list.parameters, hasLength(3)); |
| 8386 expect(list.rightDelimiter, isNotNull); |
| 8387 expect(list.rightParenthesis, isNotNull); |
| 7667 } | 8388 } |
| 7668 | 8389 |
| 7669 void test_parseFormalParameterList_positional_single() { | 8390 void test_parseFormalParameterList_positional_single() { |
| 7670 FormalParameterList parameterList = | 8391 createParser('([A a = null])'); |
| 7671 parse4("parseFormalParameterList", "([A a = null])"); | 8392 FormalParameterList list = parser.parseFormalParameterList(); |
| 7672 expect(parameterList.leftParenthesis, isNotNull); | 8393 expectNotNullIfNoErrors(list); |
| 7673 expect(parameterList.leftDelimiter, isNotNull); | 8394 listener.assertNoErrors(); |
| 7674 expect(parameterList.parameters, hasLength(1)); | 8395 expect(list.leftParenthesis, isNotNull); |
| 7675 expect(parameterList.rightDelimiter, isNotNull); | 8396 expect(list.leftDelimiter, isNotNull); |
| 7676 expect(parameterList.rightParenthesis, isNotNull); | 8397 expect(list.parameters, hasLength(1)); |
| 8398 expect(list.rightDelimiter, isNotNull); |
| 8399 expect(list.rightParenthesis, isNotNull); |
| 7677 } | 8400 } |
| 7678 | 8401 |
| 7679 void test_parseFormalParameterList_positional_trailing_comma() { | 8402 void test_parseFormalParameterList_positional_trailing_comma() { |
| 7680 FormalParameterList parameterList = | 8403 createParser('(A a, [B b,])'); |
| 7681 parse4("parseFormalParameterList", "(A a, [B b,])"); | 8404 FormalParameterList list = parser.parseFormalParameterList(); |
| 7682 expect(parameterList.leftParenthesis, isNotNull); | 8405 expectNotNullIfNoErrors(list); |
| 7683 expect(parameterList.leftDelimiter, isNotNull); | 8406 listener.assertNoErrors(); |
| 7684 expect(parameterList.parameters, hasLength(2)); | 8407 expect(list.leftParenthesis, isNotNull); |
| 7685 expect(parameterList.rightDelimiter, isNotNull); | 8408 expect(list.leftDelimiter, isNotNull); |
| 7686 expect(parameterList.rightParenthesis, isNotNull); | 8409 expect(list.parameters, hasLength(2)); |
| 8410 expect(list.rightDelimiter, isNotNull); |
| 8411 expect(list.rightParenthesis, isNotNull); |
| 7687 } | 8412 } |
| 7688 | 8413 |
| 7689 void test_parseFormalParameterList_prefixedType() { | 8414 void test_parseFormalParameterList_prefixedType() { |
| 7690 FormalParameterList parameterList = | 8415 createParser('(io.File f)'); |
| 7691 parse4("parseFormalParameterList", "(io.File f)"); | 8416 FormalParameterList list = parser.parseFormalParameterList(); |
| 7692 expect(parameterList.leftParenthesis, isNotNull); | 8417 expectNotNullIfNoErrors(list); |
| 7693 expect(parameterList.leftDelimiter, isNull); | 8418 listener.assertNoErrors(); |
| 7694 expect(parameterList.parameters, hasLength(1)); | 8419 expect(list.leftParenthesis, isNotNull); |
| 7695 expect(parameterList.parameters[0].toSource(), 'io.File f'); | 8420 expect(list.leftDelimiter, isNull); |
| 7696 expect(parameterList.rightDelimiter, isNull); | 8421 expect(list.parameters, hasLength(1)); |
| 7697 expect(parameterList.rightParenthesis, isNotNull); | 8422 expect(list.parameters[0].toSource(), 'io.File f'); |
| 8423 expect(list.rightDelimiter, isNull); |
| 8424 expect(list.rightParenthesis, isNotNull); |
| 7698 } | 8425 } |
| 7699 | 8426 |
| 7700 void test_parseFormalParameterList_prefixedType_partial() { | 8427 void test_parseFormalParameterList_prefixedType_partial() { |
| 7701 FormalParameterList parameterList = parse4( | 8428 createParser('(io.)'); |
| 7702 "parseFormalParameterList", "(io.)", [ | 8429 FormalParameterList list = parser.parseFormalParameterList(); |
| 8430 expectNotNullIfNoErrors(list); |
| 8431 listener.assertErrorsWithCodes([ |
| 7703 ParserErrorCode.MISSING_IDENTIFIER, | 8432 ParserErrorCode.MISSING_IDENTIFIER, |
| 7704 ParserErrorCode.MISSING_IDENTIFIER | 8433 ParserErrorCode.MISSING_IDENTIFIER |
| 7705 ]); | 8434 ]); |
| 7706 expect(parameterList.leftParenthesis, isNotNull); | 8435 expect(list.leftParenthesis, isNotNull); |
| 7707 expect(parameterList.leftDelimiter, isNull); | 8436 expect(list.leftDelimiter, isNull); |
| 7708 expect(parameterList.parameters, hasLength(1)); | 8437 expect(list.parameters, hasLength(1)); |
| 7709 expect(parameterList.parameters[0].toSource(), 'io. '); | 8438 expect(list.parameters[0].toSource(), 'io. '); |
| 7710 expect(parameterList.rightDelimiter, isNull); | 8439 expect(list.rightDelimiter, isNull); |
| 7711 expect(parameterList.rightParenthesis, isNotNull); | 8440 expect(list.rightParenthesis, isNotNull); |
| 7712 } | 8441 } |
| 7713 | 8442 |
| 7714 void test_parseFormalParameterList_prefixedType_partial2() { | 8443 void test_parseFormalParameterList_prefixedType_partial2() { |
| 7715 FormalParameterList parameterList = parse4( | 8444 createParser('(io.,a)'); |
| 7716 "parseFormalParameterList", "(io.,a)", [ | 8445 FormalParameterList list = parser.parseFormalParameterList(); |
| 8446 expectNotNullIfNoErrors(list); |
| 8447 listener.assertErrorsWithCodes([ |
| 7717 ParserErrorCode.MISSING_IDENTIFIER, | 8448 ParserErrorCode.MISSING_IDENTIFIER, |
| 7718 ParserErrorCode.MISSING_IDENTIFIER | 8449 ParserErrorCode.MISSING_IDENTIFIER |
| 7719 ]); | 8450 ]); |
| 7720 expect(parameterList.leftParenthesis, isNotNull); | 8451 expect(list.leftParenthesis, isNotNull); |
| 7721 expect(parameterList.leftDelimiter, isNull); | 8452 expect(list.leftDelimiter, isNull); |
| 7722 expect(parameterList.parameters, hasLength(2)); | 8453 expect(list.parameters, hasLength(2)); |
| 7723 expect(parameterList.parameters[0].toSource(), 'io. '); | 8454 expect(list.parameters[0].toSource(), 'io. '); |
| 7724 expect(parameterList.parameters[1].toSource(), 'a'); | 8455 expect(list.parameters[1].toSource(), 'a'); |
| 7725 expect(parameterList.rightDelimiter, isNull); | 8456 expect(list.rightDelimiter, isNull); |
| 7726 expect(parameterList.rightParenthesis, isNotNull); | 8457 expect(list.rightParenthesis, isNotNull); |
| 7727 } | 8458 } |
| 7728 | 8459 |
| 7729 void test_parseForStatement_each_await() { | 8460 void test_parseForStatement_each_await() { |
| 7730 ForEachStatement statement = | 8461 createParser('await for (element in list) {}'); |
| 7731 parse4("parseForStatement", "await for (element in list) {}"); | 8462 Statement statement = parser.parseForStatement(); |
| 7732 expect(statement.awaitKeyword, isNotNull); | 8463 expectNotNullIfNoErrors(statement); |
| 7733 expect(statement.forKeyword, isNotNull); | 8464 listener.assertNoErrors(); |
| 7734 expect(statement.leftParenthesis, isNotNull); | 8465 expect(statement, new isInstanceOf<ForEachStatement>()); |
| 7735 expect(statement.loopVariable, isNull); | 8466 ForEachStatement forStatement = statement; |
| 7736 expect(statement.identifier, isNotNull); | 8467 expect(forStatement.awaitKeyword, isNotNull); |
| 7737 expect(statement.inKeyword, isNotNull); | 8468 expect(forStatement.forKeyword, isNotNull); |
| 7738 expect(statement.iterable, isNotNull); | 8469 expect(forStatement.leftParenthesis, isNotNull); |
| 7739 expect(statement.rightParenthesis, isNotNull); | 8470 expect(forStatement.loopVariable, isNull); |
| 7740 expect(statement.body, isNotNull); | 8471 expect(forStatement.identifier, isNotNull); |
| 8472 expect(forStatement.inKeyword, isNotNull); |
| 8473 expect(forStatement.iterable, isNotNull); |
| 8474 expect(forStatement.rightParenthesis, isNotNull); |
| 8475 expect(forStatement.body, isNotNull); |
| 7741 } | 8476 } |
| 7742 | 8477 |
| 7743 void test_parseForStatement_each_identifier() { | 8478 void test_parseForStatement_each_identifier() { |
| 7744 ForEachStatement statement = | 8479 createParser('for (element in list) {}'); |
| 7745 parse4("parseForStatement", "for (element in list) {}"); | 8480 Statement statement = parser.parseForStatement(); |
| 7746 expect(statement.awaitKeyword, isNull); | 8481 expectNotNullIfNoErrors(statement); |
| 7747 expect(statement.forKeyword, isNotNull); | 8482 listener.assertNoErrors(); |
| 7748 expect(statement.leftParenthesis, isNotNull); | 8483 expect(statement, new isInstanceOf<ForEachStatement>()); |
| 7749 expect(statement.loopVariable, isNull); | 8484 ForEachStatement forStatement = statement; |
| 7750 expect(statement.identifier, isNotNull); | 8485 expect(forStatement.awaitKeyword, isNull); |
| 7751 expect(statement.inKeyword, isNotNull); | 8486 expect(forStatement.forKeyword, isNotNull); |
| 7752 expect(statement.iterable, isNotNull); | 8487 expect(forStatement.leftParenthesis, isNotNull); |
| 7753 expect(statement.rightParenthesis, isNotNull); | 8488 expect(forStatement.loopVariable, isNull); |
| 7754 expect(statement.body, isNotNull); | 8489 expect(forStatement.identifier, isNotNull); |
| 8490 expect(forStatement.inKeyword, isNotNull); |
| 8491 expect(forStatement.iterable, isNotNull); |
| 8492 expect(forStatement.rightParenthesis, isNotNull); |
| 8493 expect(forStatement.body, isNotNull); |
| 7755 } | 8494 } |
| 7756 | 8495 |
| 7757 void test_parseForStatement_each_noType_metadata() { | 8496 void test_parseForStatement_each_noType_metadata() { |
| 7758 ForEachStatement statement = | 8497 createParser('for (@A var element in list) {}'); |
| 7759 parse4("parseForStatement", "for (@A var element in list) {}"); | 8498 Statement statement = parser.parseForStatement(); |
| 7760 expect(statement.awaitKeyword, isNull); | 8499 expectNotNullIfNoErrors(statement); |
| 7761 expect(statement.forKeyword, isNotNull); | 8500 listener.assertNoErrors(); |
| 7762 expect(statement.leftParenthesis, isNotNull); | 8501 expect(statement, new isInstanceOf<ForEachStatement>()); |
| 7763 expect(statement.loopVariable, isNotNull); | 8502 ForEachStatement forStatement = statement; |
| 7764 expect(statement.loopVariable.metadata, hasLength(1)); | 8503 expect(forStatement.awaitKeyword, isNull); |
| 7765 expect(statement.identifier, isNull); | 8504 expect(forStatement.forKeyword, isNotNull); |
| 7766 expect(statement.inKeyword, isNotNull); | 8505 expect(forStatement.leftParenthesis, isNotNull); |
| 7767 expect(statement.iterable, isNotNull); | 8506 expect(forStatement.loopVariable, isNotNull); |
| 7768 expect(statement.rightParenthesis, isNotNull); | 8507 expect(forStatement.loopVariable.metadata, hasLength(1)); |
| 7769 expect(statement.body, isNotNull); | 8508 expect(forStatement.identifier, isNull); |
| 8509 expect(forStatement.inKeyword, isNotNull); |
| 8510 expect(forStatement.iterable, isNotNull); |
| 8511 expect(forStatement.rightParenthesis, isNotNull); |
| 8512 expect(forStatement.body, isNotNull); |
| 7770 } | 8513 } |
| 7771 | 8514 |
| 7772 void test_parseForStatement_each_type() { | 8515 void test_parseForStatement_each_type() { |
| 7773 ForEachStatement statement = | 8516 createParser('for (A element in list) {}'); |
| 7774 parse4("parseForStatement", "for (A element in list) {}"); | 8517 Statement statement = parser.parseForStatement(); |
| 7775 expect(statement.awaitKeyword, isNull); | 8518 expectNotNullIfNoErrors(statement); |
| 7776 expect(statement.forKeyword, isNotNull); | 8519 listener.assertNoErrors(); |
| 7777 expect(statement.leftParenthesis, isNotNull); | 8520 expect(statement, new isInstanceOf<ForEachStatement>()); |
| 7778 expect(statement.loopVariable, isNotNull); | 8521 ForEachStatement forStatement = statement; |
| 7779 expect(statement.identifier, isNull); | 8522 expect(forStatement.awaitKeyword, isNull); |
| 7780 expect(statement.inKeyword, isNotNull); | 8523 expect(forStatement.forKeyword, isNotNull); |
| 7781 expect(statement.iterable, isNotNull); | 8524 expect(forStatement.leftParenthesis, isNotNull); |
| 7782 expect(statement.rightParenthesis, isNotNull); | 8525 expect(forStatement.loopVariable, isNotNull); |
| 7783 expect(statement.body, isNotNull); | 8526 expect(forStatement.identifier, isNull); |
| 8527 expect(forStatement.inKeyword, isNotNull); |
| 8528 expect(forStatement.iterable, isNotNull); |
| 8529 expect(forStatement.rightParenthesis, isNotNull); |
| 8530 expect(forStatement.body, isNotNull); |
| 7784 } | 8531 } |
| 7785 | 8532 |
| 7786 void test_parseForStatement_each_var() { | 8533 void test_parseForStatement_each_var() { |
| 7787 ForEachStatement statement = | 8534 createParser('for (var element in list) {}'); |
| 7788 parse4("parseForStatement", "for (var element in list) {}"); | 8535 Statement statement = parser.parseForStatement(); |
| 7789 expect(statement.awaitKeyword, isNull); | 8536 expectNotNullIfNoErrors(statement); |
| 7790 expect(statement.forKeyword, isNotNull); | 8537 listener.assertNoErrors(); |
| 7791 expect(statement.leftParenthesis, isNotNull); | 8538 expect(statement, new isInstanceOf<ForEachStatement>()); |
| 7792 expect(statement.loopVariable, isNotNull); | 8539 ForEachStatement forStatement = statement; |
| 7793 expect(statement.identifier, isNull); | 8540 expect(forStatement.awaitKeyword, isNull); |
| 7794 expect(statement.inKeyword, isNotNull); | 8541 expect(forStatement.forKeyword, isNotNull); |
| 7795 expect(statement.iterable, isNotNull); | 8542 expect(forStatement.leftParenthesis, isNotNull); |
| 7796 expect(statement.rightParenthesis, isNotNull); | 8543 expect(forStatement.loopVariable, isNotNull); |
| 7797 expect(statement.body, isNotNull); | 8544 expect(forStatement.identifier, isNull); |
| 8545 expect(forStatement.inKeyword, isNotNull); |
| 8546 expect(forStatement.iterable, isNotNull); |
| 8547 expect(forStatement.rightParenthesis, isNotNull); |
| 8548 expect(forStatement.body, isNotNull); |
| 7798 } | 8549 } |
| 7799 | 8550 |
| 7800 void test_parseForStatement_loop_c() { | 8551 void test_parseForStatement_loop_c() { |
| 7801 ForStatement statement = | 8552 createParser('for (; i < count;) {}'); |
| 7802 parse4("parseForStatement", "for (; i < count;) {}"); | 8553 Statement statement = parser.parseForStatement(); |
| 7803 expect(statement.forKeyword, isNotNull); | 8554 expectNotNullIfNoErrors(statement); |
| 7804 expect(statement.leftParenthesis, isNotNull); | 8555 listener.assertNoErrors(); |
| 7805 expect(statement.variables, isNull); | 8556 expect(statement, new isInstanceOf<ForStatement>()); |
| 7806 expect(statement.initialization, isNull); | 8557 ForStatement forStatement = statement; |
| 7807 expect(statement.leftSeparator, isNotNull); | 8558 expect(forStatement.forKeyword, isNotNull); |
| 7808 expect(statement.condition, isNotNull); | 8559 expect(forStatement.leftParenthesis, isNotNull); |
| 7809 expect(statement.rightSeparator, isNotNull); | 8560 expect(forStatement.variables, isNull); |
| 7810 expect(statement.updaters, hasLength(0)); | 8561 expect(forStatement.initialization, isNull); |
| 7811 expect(statement.rightParenthesis, isNotNull); | 8562 expect(forStatement.leftSeparator, isNotNull); |
| 7812 expect(statement.body, isNotNull); | 8563 expect(forStatement.condition, isNotNull); |
| 8564 expect(forStatement.rightSeparator, isNotNull); |
| 8565 expect(forStatement.updaters, hasLength(0)); |
| 8566 expect(forStatement.rightParenthesis, isNotNull); |
| 8567 expect(forStatement.body, isNotNull); |
| 7813 } | 8568 } |
| 7814 | 8569 |
| 7815 void test_parseForStatement_loop_cu() { | 8570 void test_parseForStatement_loop_cu() { |
| 7816 ForStatement statement = | 8571 createParser('for (; i < count; i++) {}'); |
| 7817 parse4("parseForStatement", "for (; i < count; i++) {}"); | 8572 Statement statement = parser.parseForStatement(); |
| 7818 expect(statement.forKeyword, isNotNull); | 8573 expectNotNullIfNoErrors(statement); |
| 7819 expect(statement.leftParenthesis, isNotNull); | 8574 listener.assertNoErrors(); |
| 7820 expect(statement.variables, isNull); | 8575 expect(statement, new isInstanceOf<ForStatement>()); |
| 7821 expect(statement.initialization, isNull); | 8576 ForStatement forStatement = statement; |
| 7822 expect(statement.leftSeparator, isNotNull); | 8577 expect(forStatement.forKeyword, isNotNull); |
| 7823 expect(statement.condition, isNotNull); | 8578 expect(forStatement.leftParenthesis, isNotNull); |
| 7824 expect(statement.rightSeparator, isNotNull); | 8579 expect(forStatement.variables, isNull); |
| 7825 expect(statement.updaters, hasLength(1)); | 8580 expect(forStatement.initialization, isNull); |
| 7826 expect(statement.rightParenthesis, isNotNull); | 8581 expect(forStatement.leftSeparator, isNotNull); |
| 7827 expect(statement.body, isNotNull); | 8582 expect(forStatement.condition, isNotNull); |
| 8583 expect(forStatement.rightSeparator, isNotNull); |
| 8584 expect(forStatement.updaters, hasLength(1)); |
| 8585 expect(forStatement.rightParenthesis, isNotNull); |
| 8586 expect(forStatement.body, isNotNull); |
| 7828 } | 8587 } |
| 7829 | 8588 |
| 7830 void test_parseForStatement_loop_ecu() { | 8589 void test_parseForStatement_loop_ecu() { |
| 7831 ForStatement statement = | 8590 createParser('for (i--; i < count; i++) {}'); |
| 7832 parse4("parseForStatement", "for (i--; i < count; i++) {}"); | 8591 Statement statement = parser.parseForStatement(); |
| 7833 expect(statement.forKeyword, isNotNull); | 8592 expectNotNullIfNoErrors(statement); |
| 7834 expect(statement.leftParenthesis, isNotNull); | 8593 listener.assertNoErrors(); |
| 7835 expect(statement.variables, isNull); | 8594 expect(statement, new isInstanceOf<ForStatement>()); |
| 7836 expect(statement.initialization, isNotNull); | 8595 ForStatement forStatement = statement; |
| 7837 expect(statement.leftSeparator, isNotNull); | 8596 expect(forStatement.forKeyword, isNotNull); |
| 7838 expect(statement.condition, isNotNull); | 8597 expect(forStatement.leftParenthesis, isNotNull); |
| 7839 expect(statement.rightSeparator, isNotNull); | 8598 expect(forStatement.variables, isNull); |
| 7840 expect(statement.updaters, hasLength(1)); | 8599 expect(forStatement.initialization, isNotNull); |
| 7841 expect(statement.rightParenthesis, isNotNull); | 8600 expect(forStatement.leftSeparator, isNotNull); |
| 7842 expect(statement.body, isNotNull); | 8601 expect(forStatement.condition, isNotNull); |
| 8602 expect(forStatement.rightSeparator, isNotNull); |
| 8603 expect(forStatement.updaters, hasLength(1)); |
| 8604 expect(forStatement.rightParenthesis, isNotNull); |
| 8605 expect(forStatement.body, isNotNull); |
| 7843 } | 8606 } |
| 7844 | 8607 |
| 7845 void test_parseForStatement_loop_i() { | 8608 void test_parseForStatement_loop_i() { |
| 7846 ForStatement statement = | 8609 createParser('for (var i = 0;;) {}'); |
| 7847 parse4("parseForStatement", "for (var i = 0;;) {}"); | 8610 Statement statement = parser.parseForStatement(); |
| 7848 expect(statement.forKeyword, isNotNull); | 8611 expectNotNullIfNoErrors(statement); |
| 7849 expect(statement.leftParenthesis, isNotNull); | 8612 listener.assertNoErrors(); |
| 7850 VariableDeclarationList variables = statement.variables; | 8613 expect(statement, new isInstanceOf<ForStatement>()); |
| 8614 ForStatement forStatement = statement; |
| 8615 expect(forStatement.forKeyword, isNotNull); |
| 8616 expect(forStatement.leftParenthesis, isNotNull); |
| 8617 VariableDeclarationList variables = forStatement.variables; |
| 7851 expect(variables, isNotNull); | 8618 expect(variables, isNotNull); |
| 7852 expect(variables.metadata, hasLength(0)); | 8619 expect(variables.metadata, hasLength(0)); |
| 7853 expect(variables.variables, hasLength(1)); | 8620 expect(variables.variables, hasLength(1)); |
| 7854 expect(statement.initialization, isNull); | 8621 expect(forStatement.initialization, isNull); |
| 7855 expect(statement.leftSeparator, isNotNull); | 8622 expect(forStatement.leftSeparator, isNotNull); |
| 7856 expect(statement.condition, isNull); | 8623 expect(forStatement.condition, isNull); |
| 7857 expect(statement.rightSeparator, isNotNull); | 8624 expect(forStatement.rightSeparator, isNotNull); |
| 7858 expect(statement.updaters, hasLength(0)); | 8625 expect(forStatement.updaters, hasLength(0)); |
| 7859 expect(statement.rightParenthesis, isNotNull); | 8626 expect(forStatement.rightParenthesis, isNotNull); |
| 7860 expect(statement.body, isNotNull); | 8627 expect(forStatement.body, isNotNull); |
| 7861 } | 8628 } |
| 7862 | 8629 |
| 7863 void test_parseForStatement_loop_i_withMetadata() { | 8630 void test_parseForStatement_loop_i_withMetadata() { |
| 7864 ForStatement statement = | 8631 createParser('for (@A var i = 0;;) {}'); |
| 7865 parse4("parseForStatement", "for (@A var i = 0;;) {}"); | 8632 Statement statement = parser.parseForStatement(); |
| 7866 expect(statement.forKeyword, isNotNull); | 8633 expectNotNullIfNoErrors(statement); |
| 7867 expect(statement.leftParenthesis, isNotNull); | 8634 listener.assertNoErrors(); |
| 7868 VariableDeclarationList variables = statement.variables; | 8635 expect(statement, new isInstanceOf<ForStatement>()); |
| 8636 ForStatement forStatement = statement; |
| 8637 expect(forStatement.forKeyword, isNotNull); |
| 8638 expect(forStatement.leftParenthesis, isNotNull); |
| 8639 VariableDeclarationList variables = forStatement.variables; |
| 7869 expect(variables, isNotNull); | 8640 expect(variables, isNotNull); |
| 7870 expect(variables.metadata, hasLength(1)); | 8641 expect(variables.metadata, hasLength(1)); |
| 7871 expect(variables.variables, hasLength(1)); | 8642 expect(variables.variables, hasLength(1)); |
| 7872 expect(statement.initialization, isNull); | 8643 expect(forStatement.initialization, isNull); |
| 7873 expect(statement.leftSeparator, isNotNull); | 8644 expect(forStatement.leftSeparator, isNotNull); |
| 7874 expect(statement.condition, isNull); | 8645 expect(forStatement.condition, isNull); |
| 7875 expect(statement.rightSeparator, isNotNull); | 8646 expect(forStatement.rightSeparator, isNotNull); |
| 7876 expect(statement.updaters, hasLength(0)); | 8647 expect(forStatement.updaters, hasLength(0)); |
| 7877 expect(statement.rightParenthesis, isNotNull); | 8648 expect(forStatement.rightParenthesis, isNotNull); |
| 7878 expect(statement.body, isNotNull); | 8649 expect(forStatement.body, isNotNull); |
| 7879 } | 8650 } |
| 7880 | 8651 |
| 7881 void test_parseForStatement_loop_ic() { | 8652 void test_parseForStatement_loop_ic() { |
| 7882 ForStatement statement = | 8653 createParser('for (var i = 0; i < count;) {}'); |
| 7883 parse4("parseForStatement", "for (var i = 0; i < count;) {}"); | 8654 Statement statement = parser.parseForStatement(); |
| 7884 expect(statement.forKeyword, isNotNull); | 8655 expectNotNullIfNoErrors(statement); |
| 7885 expect(statement.leftParenthesis, isNotNull); | 8656 listener.assertNoErrors(); |
| 7886 VariableDeclarationList variables = statement.variables; | 8657 expect(statement, new isInstanceOf<ForStatement>()); |
| 8658 ForStatement forStatement = statement; |
| 8659 expect(forStatement.forKeyword, isNotNull); |
| 8660 expect(forStatement.leftParenthesis, isNotNull); |
| 8661 VariableDeclarationList variables = forStatement.variables; |
| 7887 expect(variables, isNotNull); | 8662 expect(variables, isNotNull); |
| 7888 expect(variables.variables, hasLength(1)); | 8663 expect(variables.variables, hasLength(1)); |
| 7889 expect(statement.initialization, isNull); | 8664 expect(forStatement.initialization, isNull); |
| 7890 expect(statement.leftSeparator, isNotNull); | 8665 expect(forStatement.leftSeparator, isNotNull); |
| 7891 expect(statement.condition, isNotNull); | 8666 expect(forStatement.condition, isNotNull); |
| 7892 expect(statement.rightSeparator, isNotNull); | 8667 expect(forStatement.rightSeparator, isNotNull); |
| 7893 expect(statement.updaters, hasLength(0)); | 8668 expect(forStatement.updaters, hasLength(0)); |
| 7894 expect(statement.rightParenthesis, isNotNull); | 8669 expect(forStatement.rightParenthesis, isNotNull); |
| 7895 expect(statement.body, isNotNull); | 8670 expect(forStatement.body, isNotNull); |
| 7896 } | 8671 } |
| 7897 | 8672 |
| 7898 void test_parseForStatement_loop_icu() { | 8673 void test_parseForStatement_loop_icu() { |
| 7899 ForStatement statement = | 8674 createParser('for (var i = 0; i < count; i++) {}'); |
| 7900 parse4("parseForStatement", "for (var i = 0; i < count; i++) {}"); | 8675 Statement statement = parser.parseForStatement(); |
| 7901 expect(statement.forKeyword, isNotNull); | 8676 expectNotNullIfNoErrors(statement); |
| 7902 expect(statement.leftParenthesis, isNotNull); | 8677 listener.assertNoErrors(); |
| 7903 VariableDeclarationList variables = statement.variables; | 8678 expect(statement, new isInstanceOf<ForStatement>()); |
| 8679 ForStatement forStatement = statement; |
| 8680 expect(forStatement.forKeyword, isNotNull); |
| 8681 expect(forStatement.leftParenthesis, isNotNull); |
| 8682 VariableDeclarationList variables = forStatement.variables; |
| 7904 expect(variables, isNotNull); | 8683 expect(variables, isNotNull); |
| 7905 expect(variables.variables, hasLength(1)); | 8684 expect(variables.variables, hasLength(1)); |
| 7906 expect(statement.initialization, isNull); | 8685 expect(forStatement.initialization, isNull); |
| 7907 expect(statement.leftSeparator, isNotNull); | 8686 expect(forStatement.leftSeparator, isNotNull); |
| 7908 expect(statement.condition, isNotNull); | 8687 expect(forStatement.condition, isNotNull); |
| 7909 expect(statement.rightSeparator, isNotNull); | 8688 expect(forStatement.rightSeparator, isNotNull); |
| 7910 expect(statement.updaters, hasLength(1)); | 8689 expect(forStatement.updaters, hasLength(1)); |
| 7911 expect(statement.rightParenthesis, isNotNull); | 8690 expect(forStatement.rightParenthesis, isNotNull); |
| 7912 expect(statement.body, isNotNull); | 8691 expect(forStatement.body, isNotNull); |
| 7913 } | 8692 } |
| 7914 | 8693 |
| 7915 void test_parseForStatement_loop_iicuu() { | 8694 void test_parseForStatement_loop_iicuu() { |
| 7916 ForStatement statement = parse4( | 8695 createParser('for (int i = 0, j = count; i < j; i++, j--) {}'); |
| 7917 "parseForStatement", "for (int i = 0, j = count; i < j; i++, j--) {}"); | 8696 Statement statement = parser.parseForStatement(); |
| 7918 expect(statement.forKeyword, isNotNull); | 8697 expectNotNullIfNoErrors(statement); |
| 7919 expect(statement.leftParenthesis, isNotNull); | 8698 listener.assertNoErrors(); |
| 7920 VariableDeclarationList variables = statement.variables; | 8699 expect(statement, new isInstanceOf<ForStatement>()); |
| 8700 ForStatement forStatement = statement; |
| 8701 expect(forStatement.forKeyword, isNotNull); |
| 8702 expect(forStatement.leftParenthesis, isNotNull); |
| 8703 VariableDeclarationList variables = forStatement.variables; |
| 7921 expect(variables, isNotNull); | 8704 expect(variables, isNotNull); |
| 7922 expect(variables.variables, hasLength(2)); | 8705 expect(variables.variables, hasLength(2)); |
| 7923 expect(statement.initialization, isNull); | 8706 expect(forStatement.initialization, isNull); |
| 7924 expect(statement.leftSeparator, isNotNull); | 8707 expect(forStatement.leftSeparator, isNotNull); |
| 7925 expect(statement.condition, isNotNull); | 8708 expect(forStatement.condition, isNotNull); |
| 7926 expect(statement.rightSeparator, isNotNull); | 8709 expect(forStatement.rightSeparator, isNotNull); |
| 7927 expect(statement.updaters, hasLength(2)); | 8710 expect(forStatement.updaters, hasLength(2)); |
| 7928 expect(statement.rightParenthesis, isNotNull); | 8711 expect(forStatement.rightParenthesis, isNotNull); |
| 7929 expect(statement.body, isNotNull); | 8712 expect(forStatement.body, isNotNull); |
| 7930 } | 8713 } |
| 7931 | 8714 |
| 7932 void test_parseForStatement_loop_iu() { | 8715 void test_parseForStatement_loop_iu() { |
| 7933 ForStatement statement = | 8716 createParser('for (var i = 0;; i++) {}'); |
| 7934 parse4("parseForStatement", "for (var i = 0;; i++) {}"); | 8717 Statement statement = parser.parseForStatement(); |
| 7935 expect(statement.forKeyword, isNotNull); | 8718 expectNotNullIfNoErrors(statement); |
| 7936 expect(statement.leftParenthesis, isNotNull); | 8719 listener.assertNoErrors(); |
| 7937 VariableDeclarationList variables = statement.variables; | 8720 expect(statement, new isInstanceOf<ForStatement>()); |
| 8721 ForStatement forStatement = statement; |
| 8722 expect(forStatement.forKeyword, isNotNull); |
| 8723 expect(forStatement.leftParenthesis, isNotNull); |
| 8724 VariableDeclarationList variables = forStatement.variables; |
| 7938 expect(variables, isNotNull); | 8725 expect(variables, isNotNull); |
| 7939 expect(variables.variables, hasLength(1)); | 8726 expect(variables.variables, hasLength(1)); |
| 7940 expect(statement.initialization, isNull); | 8727 expect(forStatement.initialization, isNull); |
| 7941 expect(statement.leftSeparator, isNotNull); | 8728 expect(forStatement.leftSeparator, isNotNull); |
| 7942 expect(statement.condition, isNull); | 8729 expect(forStatement.condition, isNull); |
| 7943 expect(statement.rightSeparator, isNotNull); | 8730 expect(forStatement.rightSeparator, isNotNull); |
| 7944 expect(statement.updaters, hasLength(1)); | 8731 expect(forStatement.updaters, hasLength(1)); |
| 7945 expect(statement.rightParenthesis, isNotNull); | 8732 expect(forStatement.rightParenthesis, isNotNull); |
| 7946 expect(statement.body, isNotNull); | 8733 expect(forStatement.body, isNotNull); |
| 7947 } | 8734 } |
| 7948 | 8735 |
| 7949 void test_parseForStatement_loop_u() { | 8736 void test_parseForStatement_loop_u() { |
| 7950 ForStatement statement = parse4("parseForStatement", "for (;; i++) {}"); | 8737 createParser('for (;; i++) {}'); |
| 7951 expect(statement.forKeyword, isNotNull); | 8738 Statement statement = parser.parseForStatement(); |
| 7952 expect(statement.leftParenthesis, isNotNull); | 8739 expectNotNullIfNoErrors(statement); |
| 7953 expect(statement.variables, isNull); | 8740 listener.assertNoErrors(); |
| 7954 expect(statement.initialization, isNull); | 8741 expect(statement, new isInstanceOf<ForStatement>()); |
| 7955 expect(statement.leftSeparator, isNotNull); | 8742 ForStatement forStatement = statement; |
| 7956 expect(statement.condition, isNull); | 8743 expect(forStatement.forKeyword, isNotNull); |
| 7957 expect(statement.rightSeparator, isNotNull); | 8744 expect(forStatement.leftParenthesis, isNotNull); |
| 7958 expect(statement.updaters, hasLength(1)); | 8745 expect(forStatement.variables, isNull); |
| 7959 expect(statement.rightParenthesis, isNotNull); | 8746 expect(forStatement.initialization, isNull); |
| 7960 expect(statement.body, isNotNull); | 8747 expect(forStatement.leftSeparator, isNotNull); |
| 8748 expect(forStatement.condition, isNull); |
| 8749 expect(forStatement.rightSeparator, isNotNull); |
| 8750 expect(forStatement.updaters, hasLength(1)); |
| 8751 expect(forStatement.rightParenthesis, isNotNull); |
| 8752 expect(forStatement.body, isNotNull); |
| 7961 } | 8753 } |
| 7962 | 8754 |
| 7963 void test_parseFunctionBody_block() { | 8755 void test_parseFunctionBody_block() { |
| 7964 BlockFunctionBody functionBody = | 8756 BlockFunctionBody functionBody = |
| 7965 parse("parseFunctionBody", <Object>[false, null, false], "{}"); | 8757 parse("parseFunctionBody", <Object>[false, null, false], "{}"); |
| 7966 expect(functionBody.keyword, isNull); | 8758 expect(functionBody.keyword, isNull); |
| 7967 expect(functionBody.star, isNull); | 8759 expect(functionBody.star, isNull); |
| 7968 expect(functionBody.block, isNotNull); | 8760 expect(functionBody.block, isNotNull); |
| 7969 expect(functionBody.isAsynchronous, isFalse); | 8761 expect(functionBody.isAsynchronous, isFalse); |
| 7970 expect(functionBody.isGenerator, isFalse); | 8762 expect(functionBody.isGenerator, isFalse); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8049 void test_parseFunctionBody_skip_block() { | 8841 void test_parseFunctionBody_skip_block() { |
| 8050 ParserTestCase.parseFunctionBodies = false; | 8842 ParserTestCase.parseFunctionBodies = false; |
| 8051 FunctionBody functionBody = | 8843 FunctionBody functionBody = |
| 8052 parse("parseFunctionBody", <Object>[false, null, false], "{}"); | 8844 parse("parseFunctionBody", <Object>[false, null, false], "{}"); |
| 8053 EngineTestCase.assertInstanceOf( | 8845 EngineTestCase.assertInstanceOf( |
| 8054 (obj) => obj is EmptyFunctionBody, EmptyFunctionBody, functionBody); | 8846 (obj) => obj is EmptyFunctionBody, EmptyFunctionBody, functionBody); |
| 8055 } | 8847 } |
| 8056 | 8848 |
| 8057 void test_parseFunctionBody_skip_block_invalid() { | 8849 void test_parseFunctionBody_skip_block_invalid() { |
| 8058 ParserTestCase.parseFunctionBodies = false; | 8850 ParserTestCase.parseFunctionBodies = false; |
| 8059 FunctionBody functionBody = parse3("parseFunctionBody", | 8851 createParser('{'); |
| 8060 <Object>[false, null, false], "{", [ParserErrorCode.EXPECTED_TOKEN]); | 8852 FunctionBody functionBody = parser.parseFunctionBody(false, null, false); |
| 8061 EngineTestCase.assertInstanceOf( | 8853 expectNotNullIfNoErrors(functionBody); |
| 8062 (obj) => obj is EmptyFunctionBody, EmptyFunctionBody, functionBody); | 8854 listener.assertErrorsWithCodes([ParserErrorCode.EXPECTED_TOKEN]); |
| 8855 expect(functionBody, new isInstanceOf<EmptyFunctionBody>()); |
| 8063 } | 8856 } |
| 8064 | 8857 |
| 8065 void test_parseFunctionBody_skip_blocks() { | 8858 void test_parseFunctionBody_skip_blocks() { |
| 8066 ParserTestCase.parseFunctionBodies = false; | 8859 ParserTestCase.parseFunctionBodies = false; |
| 8067 FunctionBody functionBody = | 8860 FunctionBody functionBody = |
| 8068 parse("parseFunctionBody", <Object>[false, null, false], "{ {} }"); | 8861 parse("parseFunctionBody", <Object>[false, null, false], "{ {} }"); |
| 8069 EngineTestCase.assertInstanceOf( | 8862 EngineTestCase.assertInstanceOf( |
| 8070 (obj) => obj is EmptyFunctionBody, EmptyFunctionBody, functionBody); | 8863 (obj) => obj is EmptyFunctionBody, EmptyFunctionBody, functionBody); |
| 8071 } | 8864 } |
| 8072 | 8865 |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8265 expect(list, hasLength(3)); | 9058 expect(list, hasLength(3)); |
| 8266 } | 9059 } |
| 8267 | 9060 |
| 8268 void test_parseIdentifierList_single() { | 9061 void test_parseIdentifierList_single() { |
| 8269 List<SimpleIdentifier> list = | 9062 List<SimpleIdentifier> list = |
| 8270 parse4("parseIdentifierList", "a") as List<SimpleIdentifier>; | 9063 parse4("parseIdentifierList", "a") as List<SimpleIdentifier>; |
| 8271 expect(list, hasLength(1)); | 9064 expect(list, hasLength(1)); |
| 8272 } | 9065 } |
| 8273 | 9066 |
| 8274 void test_parseIfStatement_else_block() { | 9067 void test_parseIfStatement_else_block() { |
| 8275 IfStatement statement = parse4("parseIfStatement", "if (x) {} else {}"); | 9068 createParser('if (x) {} else {}'); |
| 9069 IfStatement statement = parser.parseIfStatement(); |
| 9070 expectNotNullIfNoErrors(statement); |
| 9071 listener.assertNoErrors(); |
| 8276 expect(statement.ifKeyword, isNotNull); | 9072 expect(statement.ifKeyword, isNotNull); |
| 8277 expect(statement.leftParenthesis, isNotNull); | 9073 expect(statement.leftParenthesis, isNotNull); |
| 8278 expect(statement.condition, isNotNull); | 9074 expect(statement.condition, isNotNull); |
| 8279 expect(statement.rightParenthesis, isNotNull); | 9075 expect(statement.rightParenthesis, isNotNull); |
| 8280 expect(statement.thenStatement, isNotNull); | 9076 expect(statement.thenStatement, isNotNull); |
| 8281 expect(statement.elseKeyword, isNotNull); | 9077 expect(statement.elseKeyword, isNotNull); |
| 8282 expect(statement.elseStatement, isNotNull); | 9078 expect(statement.elseStatement, isNotNull); |
| 8283 } | 9079 } |
| 8284 | 9080 |
| 8285 void test_parseIfStatement_else_statement() { | 9081 void test_parseIfStatement_else_statement() { |
| 8286 IfStatement statement = | 9082 createParser('if (x) f(x); else f(y);'); |
| 8287 parse4("parseIfStatement", "if (x) f(x); else f(y);"); | 9083 IfStatement statement = parser.parseIfStatement(); |
| 9084 expectNotNullIfNoErrors(statement); |
| 9085 listener.assertNoErrors(); |
| 8288 expect(statement.ifKeyword, isNotNull); | 9086 expect(statement.ifKeyword, isNotNull); |
| 8289 expect(statement.leftParenthesis, isNotNull); | 9087 expect(statement.leftParenthesis, isNotNull); |
| 8290 expect(statement.condition, isNotNull); | 9088 expect(statement.condition, isNotNull); |
| 8291 expect(statement.rightParenthesis, isNotNull); | 9089 expect(statement.rightParenthesis, isNotNull); |
| 8292 expect(statement.thenStatement, isNotNull); | 9090 expect(statement.thenStatement, isNotNull); |
| 8293 expect(statement.elseKeyword, isNotNull); | 9091 expect(statement.elseKeyword, isNotNull); |
| 8294 expect(statement.elseStatement, isNotNull); | 9092 expect(statement.elseStatement, isNotNull); |
| 8295 } | 9093 } |
| 8296 | 9094 |
| 8297 void test_parseIfStatement_noElse_block() { | 9095 void test_parseIfStatement_noElse_block() { |
| 8298 IfStatement statement = parse4("parseIfStatement", "if (x) {}"); | 9096 createParser('if (x) {}'); |
| 9097 IfStatement statement = parser.parseIfStatement(); |
| 9098 expectNotNullIfNoErrors(statement); |
| 9099 listener.assertNoErrors(); |
| 8299 expect(statement.ifKeyword, isNotNull); | 9100 expect(statement.ifKeyword, isNotNull); |
| 8300 expect(statement.leftParenthesis, isNotNull); | 9101 expect(statement.leftParenthesis, isNotNull); |
| 8301 expect(statement.condition, isNotNull); | 9102 expect(statement.condition, isNotNull); |
| 8302 expect(statement.rightParenthesis, isNotNull); | 9103 expect(statement.rightParenthesis, isNotNull); |
| 8303 expect(statement.thenStatement, isNotNull); | 9104 expect(statement.thenStatement, isNotNull); |
| 8304 expect(statement.elseKeyword, isNull); | 9105 expect(statement.elseKeyword, isNull); |
| 8305 expect(statement.elseStatement, isNull); | 9106 expect(statement.elseStatement, isNull); |
| 8306 } | 9107 } |
| 8307 | 9108 |
| 8308 void test_parseIfStatement_noElse_statement() { | 9109 void test_parseIfStatement_noElse_statement() { |
| 8309 IfStatement statement = parse4("parseIfStatement", "if (x) f(x);"); | 9110 createParser('if (x) f(x);'); |
| 9111 IfStatement statement = parser.parseIfStatement(); |
| 9112 expectNotNullIfNoErrors(statement); |
| 9113 listener.assertNoErrors(); |
| 8310 expect(statement.ifKeyword, isNotNull); | 9114 expect(statement.ifKeyword, isNotNull); |
| 8311 expect(statement.leftParenthesis, isNotNull); | 9115 expect(statement.leftParenthesis, isNotNull); |
| 8312 expect(statement.condition, isNotNull); | 9116 expect(statement.condition, isNotNull); |
| 8313 expect(statement.rightParenthesis, isNotNull); | 9117 expect(statement.rightParenthesis, isNotNull); |
| 8314 expect(statement.thenStatement, isNotNull); | 9118 expect(statement.thenStatement, isNotNull); |
| 8315 expect(statement.elseKeyword, isNull); | 9119 expect(statement.elseKeyword, isNull); |
| 8316 expect(statement.elseStatement, isNull); | 9120 expect(statement.elseStatement, isNull); |
| 8317 } | 9121 } |
| 8318 | 9122 |
| 8319 void test_parseImplementsClause_multiple() { | 9123 void test_parseImplementsClause_multiple() { |
| (...skipping 1153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9473 | 10277 |
| 9474 void test_parsePrefixedIdentifier_prefix() { | 10278 void test_parsePrefixedIdentifier_prefix() { |
| 9475 String lexeme = "foo.bar"; | 10279 String lexeme = "foo.bar"; |
| 9476 PrefixedIdentifier identifier = parse4("parsePrefixedIdentifier", lexeme); | 10280 PrefixedIdentifier identifier = parse4("parsePrefixedIdentifier", lexeme); |
| 9477 expect(identifier.prefix.name, "foo"); | 10281 expect(identifier.prefix.name, "foo"); |
| 9478 expect(identifier.period, isNotNull); | 10282 expect(identifier.period, isNotNull); |
| 9479 expect(identifier.identifier.name, "bar"); | 10283 expect(identifier.identifier.name, "bar"); |
| 9480 } | 10284 } |
| 9481 | 10285 |
| 9482 void test_parsePrimaryExpression_const() { | 10286 void test_parsePrimaryExpression_const() { |
| 9483 InstanceCreationExpression expression = | 10287 createParser('const A()'); |
| 9484 parse4("parsePrimaryExpression", "const A()"); | 10288 Expression expression = parser.parsePrimaryExpression(); |
| 10289 expectNotNullIfNoErrors(expression); |
| 10290 listener.assertNoErrors(); |
| 9485 expect(expression, isNotNull); | 10291 expect(expression, isNotNull); |
| 9486 } | 10292 } |
| 9487 | 10293 |
| 9488 void test_parsePrimaryExpression_double() { | 10294 void test_parsePrimaryExpression_double() { |
| 9489 String doubleLiteral = "3.2e4"; | 10295 String doubleLiteral = "3.2e4"; |
| 9490 DoubleLiteral literal = parse4("parsePrimaryExpression", doubleLiteral); | 10296 createParser(doubleLiteral); |
| 10297 Expression expression = parser.parsePrimaryExpression(); |
| 10298 expectNotNullIfNoErrors(expression); |
| 10299 listener.assertNoErrors(); |
| 10300 expect(expression, new isInstanceOf<DoubleLiteral>()); |
| 10301 DoubleLiteral literal = expression; |
| 9491 expect(literal.literal, isNotNull); | 10302 expect(literal.literal, isNotNull); |
| 9492 expect(literal.value, double.parse(doubleLiteral)); | 10303 expect(literal.value, double.parse(doubleLiteral)); |
| 9493 } | 10304 } |
| 9494 | 10305 |
| 9495 void test_parsePrimaryExpression_false() { | 10306 void test_parsePrimaryExpression_false() { |
| 9496 BooleanLiteral literal = parse4("parsePrimaryExpression", "false"); | 10307 createParser('false'); |
| 10308 Expression expression = parser.parsePrimaryExpression(); |
| 10309 expectNotNullIfNoErrors(expression); |
| 10310 listener.assertNoErrors(); |
| 10311 expect(expression, new isInstanceOf<BooleanLiteral>()); |
| 10312 BooleanLiteral literal = expression; |
| 9497 expect(literal.literal, isNotNull); | 10313 expect(literal.literal, isNotNull); |
| 9498 expect(literal.value, isFalse); | 10314 expect(literal.value, isFalse); |
| 9499 } | 10315 } |
| 9500 | 10316 |
| 9501 void test_parsePrimaryExpression_function_arguments() { | 10317 void test_parsePrimaryExpression_function_arguments() { |
| 9502 FunctionExpression expression = | 10318 createParser('(int i) => i + 1'); |
| 9503 parse4("parsePrimaryExpression", "(int i) => i + 1"); | 10319 Expression expression = parser.parsePrimaryExpression(); |
| 9504 expect(expression.parameters, isNotNull); | 10320 expectNotNullIfNoErrors(expression); |
| 9505 expect(expression.body, isNotNull); | 10321 listener.assertNoErrors(); |
| 10322 expect(expression, new isInstanceOf<FunctionExpression>()); |
| 10323 FunctionExpression functionExpression = expression; |
| 10324 expect(functionExpression.parameters, isNotNull); |
| 10325 expect(functionExpression.body, isNotNull); |
| 9506 } | 10326 } |
| 9507 | 10327 |
| 9508 void test_parsePrimaryExpression_function_noArguments() { | 10328 void test_parsePrimaryExpression_function_noArguments() { |
| 9509 FunctionExpression expression = | 10329 createParser('() => 42'); |
| 9510 parse4("parsePrimaryExpression", "() => 42"); | 10330 Expression expression = parser.parsePrimaryExpression(); |
| 9511 expect(expression.parameters, isNotNull); | 10331 expectNotNullIfNoErrors(expression); |
| 9512 expect(expression.body, isNotNull); | 10332 listener.assertNoErrors(); |
| 10333 expect(expression, new isInstanceOf<FunctionExpression>()); |
| 10334 FunctionExpression functionExpression = expression; |
| 10335 expect(functionExpression.parameters, isNotNull); |
| 10336 expect(functionExpression.body, isNotNull); |
| 9513 } | 10337 } |
| 9514 | 10338 |
| 9515 void test_parsePrimaryExpression_hex() { | 10339 void test_parsePrimaryExpression_hex() { |
| 9516 String hexLiteral = "3F"; | 10340 String hexLiteral = "3F"; |
| 9517 IntegerLiteral literal = parse4("parsePrimaryExpression", "0x$hexLiteral"); | 10341 createParser('0x$hexLiteral'); |
| 10342 Expression expression = parser.parsePrimaryExpression(); |
| 10343 expectNotNullIfNoErrors(expression); |
| 10344 listener.assertNoErrors(); |
| 10345 expect(expression, new isInstanceOf<IntegerLiteral>()); |
| 10346 IntegerLiteral literal = expression; |
| 9518 expect(literal.literal, isNotNull); | 10347 expect(literal.literal, isNotNull); |
| 9519 expect(literal.value, int.parse(hexLiteral, radix: 16)); | 10348 expect(literal.value, int.parse(hexLiteral, radix: 16)); |
| 9520 } | 10349 } |
| 9521 | 10350 |
| 9522 void test_parsePrimaryExpression_identifier() { | 10351 void test_parsePrimaryExpression_identifier() { |
| 9523 SimpleIdentifier identifier = parse4("parsePrimaryExpression", "a"); | 10352 createParser('a'); |
| 10353 Expression expression = parser.parsePrimaryExpression(); |
| 10354 expectNotNullIfNoErrors(expression); |
| 10355 listener.assertNoErrors(); |
| 10356 expect(expression, new isInstanceOf<SimpleIdentifier>()); |
| 10357 SimpleIdentifier identifier = expression; |
| 9524 expect(identifier, isNotNull); | 10358 expect(identifier, isNotNull); |
| 9525 } | 10359 } |
| 9526 | 10360 |
| 9527 void test_parsePrimaryExpression_int() { | 10361 void test_parsePrimaryExpression_int() { |
| 9528 String intLiteral = "472"; | 10362 String intLiteral = "472"; |
| 9529 IntegerLiteral literal = parse4("parsePrimaryExpression", intLiteral); | 10363 createParser(intLiteral); |
| 10364 Expression expression = parser.parsePrimaryExpression(); |
| 10365 expectNotNullIfNoErrors(expression); |
| 10366 listener.assertNoErrors(); |
| 10367 expect(expression, new isInstanceOf<IntegerLiteral>()); |
| 10368 IntegerLiteral literal = expression; |
| 9530 expect(literal.literal, isNotNull); | 10369 expect(literal.literal, isNotNull); |
| 9531 expect(literal.value, int.parse(intLiteral)); | 10370 expect(literal.value, int.parse(intLiteral)); |
| 9532 } | 10371 } |
| 9533 | 10372 |
| 9534 void test_parsePrimaryExpression_listLiteral() { | 10373 void test_parsePrimaryExpression_listLiteral() { |
| 9535 ListLiteral literal = parse4("parsePrimaryExpression", "[ ]"); | 10374 createParser('[ ]'); |
| 10375 Expression expression = parser.parsePrimaryExpression(); |
| 10376 expectNotNullIfNoErrors(expression); |
| 10377 listener.assertNoErrors(); |
| 10378 expect(expression, new isInstanceOf<ListLiteral>()); |
| 10379 ListLiteral literal = expression; |
| 9536 expect(literal, isNotNull); | 10380 expect(literal, isNotNull); |
| 9537 } | 10381 } |
| 9538 | 10382 |
| 9539 void test_parsePrimaryExpression_listLiteral_index() { | 10383 void test_parsePrimaryExpression_listLiteral_index() { |
| 9540 ListLiteral literal = parse4("parsePrimaryExpression", "[]"); | 10384 createParser('[]'); |
| 10385 Expression expression = parser.parsePrimaryExpression(); |
| 10386 expectNotNullIfNoErrors(expression); |
| 10387 listener.assertNoErrors(); |
| 10388 expect(expression, new isInstanceOf<ListLiteral>()); |
| 10389 ListLiteral literal = expression; |
| 9541 expect(literal, isNotNull); | 10390 expect(literal, isNotNull); |
| 9542 } | 10391 } |
| 9543 | 10392 |
| 9544 void test_parsePrimaryExpression_listLiteral_typed() { | 10393 void test_parsePrimaryExpression_listLiteral_typed() { |
| 9545 ListLiteral literal = parse4("parsePrimaryExpression", "<A>[ ]"); | 10394 createParser('<A>[ ]'); |
| 10395 Expression expression = parser.parsePrimaryExpression(); |
| 10396 expectNotNullIfNoErrors(expression); |
| 10397 listener.assertNoErrors(); |
| 10398 expect(expression, new isInstanceOf<ListLiteral>()); |
| 10399 ListLiteral literal = expression; |
| 9546 expect(literal.typeArguments, isNotNull); | 10400 expect(literal.typeArguments, isNotNull); |
| 9547 expect(literal.typeArguments.arguments, hasLength(1)); | 10401 expect(literal.typeArguments.arguments, hasLength(1)); |
| 9548 } | 10402 } |
| 9549 | 10403 |
| 9550 void test_parsePrimaryExpression_listLiteral_typed_genericComment() { | 10404 void test_parsePrimaryExpression_listLiteral_typed_genericComment() { |
| 9551 enableGenericMethodComments = true; | 10405 enableGenericMethodComments = true; |
| 9552 ListLiteral literal = parse4("parsePrimaryExpression", "/*<A>*/[ ]"); | 10406 createParser('/*<A>*/[ ]'); |
| 10407 Expression expression = parser.parsePrimaryExpression(); |
| 10408 expectNotNullIfNoErrors(expression); |
| 10409 listener.assertNoErrors(); |
| 10410 expect(expression, new isInstanceOf<ListLiteral>()); |
| 10411 ListLiteral literal = expression; |
| 9553 expect(literal.typeArguments, isNotNull); | 10412 expect(literal.typeArguments, isNotNull); |
| 9554 expect(literal.typeArguments.arguments, hasLength(1)); | 10413 expect(literal.typeArguments.arguments, hasLength(1)); |
| 9555 } | 10414 } |
| 9556 | 10415 |
| 9557 void test_parsePrimaryExpression_mapLiteral() { | 10416 void test_parsePrimaryExpression_mapLiteral() { |
| 9558 MapLiteral literal = parse4("parsePrimaryExpression", "{}"); | 10417 createParser('{}'); |
| 10418 Expression expression = parser.parsePrimaryExpression(); |
| 10419 expectNotNullIfNoErrors(expression); |
| 10420 listener.assertNoErrors(); |
| 10421 expect(expression, new isInstanceOf<MapLiteral>()); |
| 10422 MapLiteral literal = expression; |
| 10423 expect(literal.typeArguments, isNull); |
| 9559 expect(literal, isNotNull); | 10424 expect(literal, isNotNull); |
| 9560 } | 10425 } |
| 9561 | 10426 |
| 9562 void test_parsePrimaryExpression_mapLiteral_typed() { | 10427 void test_parsePrimaryExpression_mapLiteral_typed() { |
| 9563 MapLiteral literal = parse4("parsePrimaryExpression", "<A, B>{}"); | 10428 createParser('<A, B>{}'); |
| 10429 Expression expression = parser.parsePrimaryExpression(); |
| 10430 expectNotNullIfNoErrors(expression); |
| 10431 listener.assertNoErrors(); |
| 10432 expect(expression, new isInstanceOf<MapLiteral>()); |
| 10433 MapLiteral literal = expression; |
| 9564 expect(literal.typeArguments, isNotNull); | 10434 expect(literal.typeArguments, isNotNull); |
| 9565 expect(literal.typeArguments.arguments, hasLength(2)); | 10435 expect(literal.typeArguments.arguments, hasLength(2)); |
| 9566 } | 10436 } |
| 9567 | 10437 |
| 9568 void test_parsePrimaryExpression_mapLiteral_typed_genericComment() { | 10438 void test_parsePrimaryExpression_mapLiteral_typed_genericComment() { |
| 9569 enableGenericMethodComments = true; | 10439 enableGenericMethodComments = true; |
| 9570 MapLiteral literal = parse4("parsePrimaryExpression", "/*<A, B>*/{}"); | 10440 createParser('/*<A, B>*/{}'); |
| 10441 Expression expression = parser.parsePrimaryExpression(); |
| 10442 expectNotNullIfNoErrors(expression); |
| 10443 listener.assertNoErrors(); |
| 10444 expect(expression, new isInstanceOf<MapLiteral>()); |
| 10445 MapLiteral literal = expression; |
| 9571 expect(literal.typeArguments, isNotNull); | 10446 expect(literal.typeArguments, isNotNull); |
| 9572 expect(literal.typeArguments.arguments, hasLength(2)); | 10447 expect(literal.typeArguments.arguments, hasLength(2)); |
| 9573 } | 10448 } |
| 9574 | 10449 |
| 9575 void test_parsePrimaryExpression_new() { | 10450 void test_parsePrimaryExpression_new() { |
| 9576 InstanceCreationExpression expression = | 10451 createParser('new A()'); |
| 9577 parse4("parsePrimaryExpression", "new A()"); | 10452 Expression expression = parser.parsePrimaryExpression(); |
| 9578 expect(expression, isNotNull); | 10453 expectNotNullIfNoErrors(expression); |
| 10454 listener.assertNoErrors(); |
| 10455 expect(expression, new isInstanceOf<InstanceCreationExpression>()); |
| 10456 InstanceCreationExpression creation = expression; |
| 10457 expect(creation, isNotNull); |
| 9579 } | 10458 } |
| 9580 | 10459 |
| 9581 void test_parsePrimaryExpression_null() { | 10460 void test_parsePrimaryExpression_null() { |
| 9582 NullLiteral literal = parse4("parsePrimaryExpression", "null"); | 10461 createParser('null'); |
| 10462 Expression expression = parser.parsePrimaryExpression(); |
| 10463 expectNotNullIfNoErrors(expression); |
| 10464 listener.assertNoErrors(); |
| 10465 expect(expression, new isInstanceOf<NullLiteral>()); |
| 10466 NullLiteral literal = expression; |
| 9583 expect(literal.literal, isNotNull); | 10467 expect(literal.literal, isNotNull); |
| 9584 } | 10468 } |
| 9585 | 10469 |
| 9586 void test_parsePrimaryExpression_parenthesized() { | 10470 void test_parsePrimaryExpression_parenthesized() { |
| 9587 ParenthesizedExpression expression = | 10471 createParser('(x)'); |
| 9588 parse4("parsePrimaryExpression", "(x)"); | 10472 Expression expression = parser.parsePrimaryExpression(); |
| 9589 expect(expression, isNotNull); | 10473 expectNotNullIfNoErrors(expression); |
| 10474 listener.assertNoErrors(); |
| 10475 expect(expression, new isInstanceOf<ParenthesizedExpression>()); |
| 10476 ParenthesizedExpression parens = expression; |
| 10477 expect(parens, isNotNull); |
| 9590 } | 10478 } |
| 9591 | 10479 |
| 9592 void test_parsePrimaryExpression_string() { | 10480 void test_parsePrimaryExpression_string() { |
| 9593 SimpleStringLiteral literal = | 10481 createParser('"string"'); |
| 9594 parse4("parsePrimaryExpression", "\"string\""); | 10482 Expression expression = parser.parsePrimaryExpression(); |
| 10483 expectNotNullIfNoErrors(expression); |
| 10484 listener.assertNoErrors(); |
| 10485 expect(expression, new isInstanceOf<SimpleStringLiteral>()); |
| 10486 SimpleStringLiteral literal = expression; |
| 9595 expect(literal.isMultiline, isFalse); | 10487 expect(literal.isMultiline, isFalse); |
| 9596 expect(literal.isRaw, isFalse); | 10488 expect(literal.isRaw, isFalse); |
| 9597 expect(literal.value, "string"); | 10489 expect(literal.value, "string"); |
| 9598 } | 10490 } |
| 9599 | 10491 |
| 9600 void test_parsePrimaryExpression_string_multiline() { | 10492 void test_parsePrimaryExpression_string_multiline() { |
| 9601 SimpleStringLiteral literal = | 10493 createParser("'''string'''"); |
| 9602 parse4("parsePrimaryExpression", "'''string'''"); | 10494 Expression expression = parser.parsePrimaryExpression(); |
| 10495 expectNotNullIfNoErrors(expression); |
| 10496 listener.assertNoErrors(); |
| 10497 expect(expression, new isInstanceOf<SimpleStringLiteral>()); |
| 10498 SimpleStringLiteral literal = expression; |
| 9603 expect(literal.isMultiline, isTrue); | 10499 expect(literal.isMultiline, isTrue); |
| 9604 expect(literal.isRaw, isFalse); | 10500 expect(literal.isRaw, isFalse); |
| 9605 expect(literal.value, "string"); | 10501 expect(literal.value, "string"); |
| 9606 } | 10502 } |
| 9607 | 10503 |
| 9608 void test_parsePrimaryExpression_string_raw() { | 10504 void test_parsePrimaryExpression_string_raw() { |
| 9609 SimpleStringLiteral literal = parse4("parsePrimaryExpression", "r'string'"); | 10505 createParser("r'string'"); |
| 10506 Expression expression = parser.parsePrimaryExpression(); |
| 10507 expectNotNullIfNoErrors(expression); |
| 10508 listener.assertNoErrors(); |
| 10509 expect(expression, new isInstanceOf<SimpleStringLiteral>()); |
| 10510 SimpleStringLiteral literal = expression; |
| 9610 expect(literal.isMultiline, isFalse); | 10511 expect(literal.isMultiline, isFalse); |
| 9611 expect(literal.isRaw, isTrue); | 10512 expect(literal.isRaw, isTrue); |
| 9612 expect(literal.value, "string"); | 10513 expect(literal.value, "string"); |
| 9613 } | 10514 } |
| 9614 | 10515 |
| 9615 void test_parsePrimaryExpression_super() { | 10516 void test_parsePrimaryExpression_super() { |
| 9616 PropertyAccess propertyAccess = parse4("parsePrimaryExpression", "super.x"); | 10517 createParser('super.x'); |
| 10518 Expression expression = parser.parsePrimaryExpression(); |
| 10519 expectNotNullIfNoErrors(expression); |
| 10520 listener.assertNoErrors(); |
| 10521 expect(expression, new isInstanceOf<PropertyAccess>()); |
| 10522 PropertyAccess propertyAccess = expression; |
| 9617 expect(propertyAccess.target is SuperExpression, isTrue); | 10523 expect(propertyAccess.target is SuperExpression, isTrue); |
| 9618 expect(propertyAccess.operator, isNotNull); | 10524 expect(propertyAccess.operator, isNotNull); |
| 9619 expect(propertyAccess.operator.type, TokenType.PERIOD); | 10525 expect(propertyAccess.operator.type, TokenType.PERIOD); |
| 9620 expect(propertyAccess.propertyName, isNotNull); | 10526 expect(propertyAccess.propertyName, isNotNull); |
| 9621 } | 10527 } |
| 9622 | 10528 |
| 9623 void test_parsePrimaryExpression_this() { | 10529 void test_parsePrimaryExpression_this() { |
| 9624 ThisExpression expression = parse4("parsePrimaryExpression", "this"); | 10530 createParser('this'); |
| 9625 expect(expression.thisKeyword, isNotNull); | 10531 Expression expression = parser.parsePrimaryExpression(); |
| 10532 expectNotNullIfNoErrors(expression); |
| 10533 listener.assertNoErrors(); |
| 10534 expect(expression, new isInstanceOf<ThisExpression>()); |
| 10535 ThisExpression thisExpression = expression; |
| 10536 expect(thisExpression.thisKeyword, isNotNull); |
| 9626 } | 10537 } |
| 9627 | 10538 |
| 9628 void test_parsePrimaryExpression_true() { | 10539 void test_parsePrimaryExpression_true() { |
| 9629 BooleanLiteral literal = parse4("parsePrimaryExpression", "true"); | 10540 createParser('true'); |
| 10541 Expression expression = parser.parsePrimaryExpression(); |
| 10542 expectNotNullIfNoErrors(expression); |
| 10543 listener.assertNoErrors(); |
| 10544 expect(expression, new isInstanceOf<BooleanLiteral>()); |
| 10545 BooleanLiteral literal = expression; |
| 9630 expect(literal.literal, isNotNull); | 10546 expect(literal.literal, isNotNull); |
| 9631 expect(literal.value, isTrue); | 10547 expect(literal.value, isTrue); |
| 9632 } | 10548 } |
| 9633 | 10549 |
| 9634 void test_Parser() { | 10550 void test_Parser() { |
| 9635 expect(new Parser(null, null), isNotNull); | 10551 expect(new Parser(null, null), isNotNull); |
| 9636 } | 10552 } |
| 9637 | 10553 |
| 9638 void test_parseRedirectingConstructorInvocation_named() { | 10554 void test_parseRedirectingConstructorInvocation_named() { |
| 9639 RedirectingConstructorInvocation invocation = | 10555 RedirectingConstructorInvocation invocation = |
| 9640 parse2("parseRedirectingConstructorInvocation", [true], "this.a()"); | 10556 parse("parseRedirectingConstructorInvocation", [true], "this.a()"); |
| 9641 expect(invocation.argumentList, isNotNull); | 10557 expect(invocation.argumentList, isNotNull); |
| 9642 expect(invocation.constructorName, isNotNull); | 10558 expect(invocation.constructorName, isNotNull); |
| 9643 expect(invocation.thisKeyword, isNotNull); | 10559 expect(invocation.thisKeyword, isNotNull); |
| 9644 expect(invocation.period, isNotNull); | 10560 expect(invocation.period, isNotNull); |
| 9645 } | 10561 } |
| 9646 | 10562 |
| 9647 void test_parseRedirectingConstructorInvocation_unnamed() { | 10563 void test_parseRedirectingConstructorInvocation_unnamed() { |
| 9648 RedirectingConstructorInvocation invocation = | 10564 RedirectingConstructorInvocation invocation = |
| 9649 parse2("parseRedirectingConstructorInvocation", [false], "this()"); | 10565 parse("parseRedirectingConstructorInvocation", [false], "this()"); |
| 9650 expect(invocation.argumentList, isNotNull); | 10566 expect(invocation.argumentList, isNotNull); |
| 9651 expect(invocation.constructorName, isNull); | 10567 expect(invocation.constructorName, isNull); |
| 9652 expect(invocation.thisKeyword, isNotNull); | 10568 expect(invocation.thisKeyword, isNotNull); |
| 9653 expect(invocation.period, isNull); | 10569 expect(invocation.period, isNull); |
| 9654 } | 10570 } |
| 9655 | 10571 |
| 9656 void test_parseRelationalExpression_as() { | 10572 void test_parseRelationalExpression_as() { |
| 9657 AsExpression expression = parse4("parseRelationalExpression", "x as Y"); | 10573 createParser('x as Y'); |
| 9658 expect(expression.expression, isNotNull); | 10574 Expression expression = parser.parseRelationalExpression(); |
| 9659 expect(expression.asOperator, isNotNull); | 10575 expectNotNullIfNoErrors(expression); |
| 9660 expect(expression.type, isNotNull); | 10576 listener.assertNoErrors(); |
| 10577 expect(expression, new isInstanceOf<AsExpression>()); |
| 10578 AsExpression asExpression = expression; |
| 10579 expect(asExpression.expression, isNotNull); |
| 10580 expect(asExpression.asOperator, isNotNull); |
| 10581 expect(asExpression.type, isNotNull); |
| 9661 } | 10582 } |
| 9662 | 10583 |
| 9663 void test_parseRelationalExpression_is() { | 10584 void test_parseRelationalExpression_is() { |
| 9664 IsExpression expression = parse4("parseRelationalExpression", "x is y"); | 10585 createParser('x is y'); |
| 9665 expect(expression.expression, isNotNull); | 10586 Expression expression = parser.parseRelationalExpression(); |
| 9666 expect(expression.isOperator, isNotNull); | 10587 expectNotNullIfNoErrors(expression); |
| 9667 expect(expression.notOperator, isNull); | 10588 listener.assertNoErrors(); |
| 9668 expect(expression.type, isNotNull); | 10589 expect(expression, new isInstanceOf<IsExpression>()); |
| 10590 IsExpression isExpression = expression; |
| 10591 expect(isExpression.expression, isNotNull); |
| 10592 expect(isExpression.isOperator, isNotNull); |
| 10593 expect(isExpression.notOperator, isNull); |
| 10594 expect(isExpression.type, isNotNull); |
| 9669 } | 10595 } |
| 9670 | 10596 |
| 9671 void test_parseRelationalExpression_isNot() { | 10597 void test_parseRelationalExpression_isNot() { |
| 9672 IsExpression expression = parse4("parseRelationalExpression", "x is! y"); | 10598 createParser('x is! y'); |
| 9673 expect(expression.expression, isNotNull); | 10599 Expression expression = parser.parseRelationalExpression(); |
| 9674 expect(expression.isOperator, isNotNull); | 10600 expectNotNullIfNoErrors(expression); |
| 9675 expect(expression.notOperator, isNotNull); | 10601 listener.assertNoErrors(); |
| 9676 expect(expression.type, isNotNull); | 10602 expect(expression, new isInstanceOf<IsExpression>()); |
| 10603 IsExpression isExpression = expression; |
| 10604 expect(isExpression.expression, isNotNull); |
| 10605 expect(isExpression.isOperator, isNotNull); |
| 10606 expect(isExpression.notOperator, isNotNull); |
| 10607 expect(isExpression.type, isNotNull); |
| 9677 } | 10608 } |
| 9678 | 10609 |
| 9679 void test_parseRelationalExpression_normal() { | 10610 void test_parseRelationalExpression_normal() { |
| 9680 BinaryExpression expression = parse4("parseRelationalExpression", "x < y"); | 10611 createParser('x < y'); |
| 9681 expect(expression.leftOperand, isNotNull); | 10612 Expression expression = parser.parseRelationalExpression(); |
| 9682 expect(expression.operator, isNotNull); | 10613 expectNotNullIfNoErrors(expression); |
| 9683 expect(expression.operator.type, TokenType.LT); | 10614 listener.assertNoErrors(); |
| 9684 expect(expression.rightOperand, isNotNull); | 10615 expect(expression, new isInstanceOf<BinaryExpression>()); |
| 10616 BinaryExpression binaryExpression = expression; |
| 10617 expect(binaryExpression.leftOperand, isNotNull); |
| 10618 expect(binaryExpression.operator, isNotNull); |
| 10619 expect(binaryExpression.operator.type, TokenType.LT); |
| 10620 expect(binaryExpression.rightOperand, isNotNull); |
| 9685 } | 10621 } |
| 9686 | 10622 |
| 9687 void test_parseRelationalExpression_super() { | 10623 void test_parseRelationalExpression_super() { |
| 9688 BinaryExpression expression = | 10624 createParser('super < y'); |
| 9689 parse4("parseRelationalExpression", "super < y"); | 10625 Expression expression = parser.parseRelationalExpression(); |
| 9690 expect(expression.leftOperand, isNotNull); | 10626 expectNotNullIfNoErrors(expression); |
| 9691 expect(expression.operator, isNotNull); | 10627 listener.assertNoErrors(); |
| 9692 expect(expression.operator.type, TokenType.LT); | 10628 expect(expression, new isInstanceOf<BinaryExpression>()); |
| 9693 expect(expression.rightOperand, isNotNull); | 10629 BinaryExpression binaryExpression = expression; |
| 10630 expect(binaryExpression.leftOperand, isNotNull); |
| 10631 expect(binaryExpression.operator, isNotNull); |
| 10632 expect(binaryExpression.operator.type, TokenType.LT); |
| 10633 expect(binaryExpression.rightOperand, isNotNull); |
| 9694 } | 10634 } |
| 9695 | 10635 |
| 9696 void test_parseRethrowExpression() { | 10636 void test_parseRethrowExpression() { |
| 9697 RethrowExpression expression = parse4("parseRethrowExpression", "rethrow;"); | 10637 createParser('rethrow;'); |
| 10638 RethrowExpression expression = parser.parseRethrowExpression(); |
| 10639 expectNotNullIfNoErrors(expression); |
| 10640 listener.assertNoErrors(); |
| 9698 expect(expression.rethrowKeyword, isNotNull); | 10641 expect(expression.rethrowKeyword, isNotNull); |
| 9699 } | 10642 } |
| 9700 | 10643 |
| 9701 void test_parseReturnStatement_noValue() { | 10644 void test_parseReturnStatement_noValue() { |
| 9702 ReturnStatement statement = parse4("parseReturnStatement", "return;"); | 10645 createParser('return;'); |
| 10646 ReturnStatement statement = parser.parseReturnStatement(); |
| 10647 expectNotNullIfNoErrors(statement); |
| 10648 listener.assertNoErrors(); |
| 9703 expect(statement.returnKeyword, isNotNull); | 10649 expect(statement.returnKeyword, isNotNull); |
| 9704 expect(statement.expression, isNull); | 10650 expect(statement.expression, isNull); |
| 9705 expect(statement.semicolon, isNotNull); | 10651 expect(statement.semicolon, isNotNull); |
| 9706 } | 10652 } |
| 9707 | 10653 |
| 9708 void test_parseReturnStatement_value() { | 10654 void test_parseReturnStatement_value() { |
| 9709 ReturnStatement statement = parse4("parseReturnStatement", "return x;"); | 10655 createParser('return x;'); |
| 10656 ReturnStatement statement = parser.parseReturnStatement(); |
| 10657 expectNotNullIfNoErrors(statement); |
| 10658 listener.assertNoErrors(); |
| 9710 expect(statement.returnKeyword, isNotNull); | 10659 expect(statement.returnKeyword, isNotNull); |
| 9711 expect(statement.expression, isNotNull); | 10660 expect(statement.expression, isNotNull); |
| 9712 expect(statement.semicolon, isNotNull); | 10661 expect(statement.semicolon, isNotNull); |
| 9713 } | 10662 } |
| 9714 | 10663 |
| 9715 void test_parseReturnType_nonVoid() { | 10664 void test_parseReturnType_nonVoid() { |
| 9716 TypeName typeName = parse4("parseReturnType", "A<B>"); | 10665 createParser('A<B>'); |
| 10666 TypeName typeName = parser.parseReturnType(); |
| 10667 expectNotNullIfNoErrors(typeName); |
| 10668 listener.assertNoErrors(); |
| 9717 expect(typeName.name, isNotNull); | 10669 expect(typeName.name, isNotNull); |
| 9718 expect(typeName.typeArguments, isNotNull); | 10670 expect(typeName.typeArguments, isNotNull); |
| 9719 } | 10671 } |
| 9720 | 10672 |
| 9721 void test_parseReturnType_void() { | 10673 void test_parseReturnType_void() { |
| 9722 TypeName typeName = parse4("parseReturnType", "void"); | 10674 createParser('void'); |
| 10675 TypeName typeName = parser.parseReturnType(); |
| 10676 expectNotNullIfNoErrors(typeName); |
| 10677 listener.assertNoErrors(); |
| 9723 expect(typeName.name, isNotNull); | 10678 expect(typeName.name, isNotNull); |
| 9724 expect(typeName.typeArguments, isNull); | 10679 expect(typeName.typeArguments, isNull); |
| 9725 } | 10680 } |
| 9726 | 10681 |
| 9727 void test_parseSetter_nonStatic() { | 10682 void test_parseSetter_nonStatic() { |
| 9728 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); | 10683 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); |
| 9729 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); | 10684 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); |
| 9730 MethodDeclaration method = parse( | 10685 MethodDeclaration method = parse( |
| 9731 "parseSetter", | 10686 "parseSetter", |
| 9732 <Object>[commentAndMetadata(comment), null, null, returnType], | 10687 <Object>[commentAndMetadata(comment), null, null, returnType], |
| (...skipping 24 matching lines...) Expand all Loading... |
| 9757 expect(method.modifierKeyword, staticKeyword); | 10712 expect(method.modifierKeyword, staticKeyword); |
| 9758 expect(method.name, isNotNull); | 10713 expect(method.name, isNotNull); |
| 9759 expect(method.operatorKeyword, isNull); | 10714 expect(method.operatorKeyword, isNull); |
| 9760 expect(method.typeParameters, isNull); | 10715 expect(method.typeParameters, isNull); |
| 9761 expect(method.parameters, isNotNull); | 10716 expect(method.parameters, isNotNull); |
| 9762 expect(method.propertyKeyword, isNotNull); | 10717 expect(method.propertyKeyword, isNotNull); |
| 9763 expect(method.returnType, returnType); | 10718 expect(method.returnType, returnType); |
| 9764 } | 10719 } |
| 9765 | 10720 |
| 9766 void test_parseShiftExpression_normal() { | 10721 void test_parseShiftExpression_normal() { |
| 9767 BinaryExpression expression = parse4("parseShiftExpression", "x << y"); | 10722 createParser('x << y'); |
| 10723 BinaryExpression expression = parser.parseShiftExpression(); |
| 10724 expectNotNullIfNoErrors(expression); |
| 10725 listener.assertNoErrors(); |
| 9768 expect(expression.leftOperand, isNotNull); | 10726 expect(expression.leftOperand, isNotNull); |
| 9769 expect(expression.operator, isNotNull); | 10727 expect(expression.operator, isNotNull); |
| 9770 expect(expression.operator.type, TokenType.LT_LT); | 10728 expect(expression.operator.type, TokenType.LT_LT); |
| 9771 expect(expression.rightOperand, isNotNull); | 10729 expect(expression.rightOperand, isNotNull); |
| 9772 } | 10730 } |
| 9773 | 10731 |
| 9774 void test_parseShiftExpression_super() { | 10732 void test_parseShiftExpression_super() { |
| 9775 BinaryExpression expression = parse4("parseShiftExpression", "super << y"); | 10733 createParser('super << y'); |
| 10734 BinaryExpression expression = parser.parseShiftExpression(); |
| 10735 expectNotNullIfNoErrors(expression); |
| 10736 listener.assertNoErrors(); |
| 9776 expect(expression.leftOperand, isNotNull); | 10737 expect(expression.leftOperand, isNotNull); |
| 9777 expect(expression.operator, isNotNull); | 10738 expect(expression.operator, isNotNull); |
| 9778 expect(expression.operator.type, TokenType.LT_LT); | 10739 expect(expression.operator.type, TokenType.LT_LT); |
| 9779 expect(expression.rightOperand, isNotNull); | 10740 expect(expression.rightOperand, isNotNull); |
| 9780 } | 10741 } |
| 9781 | 10742 |
| 9782 void test_parseSimpleIdentifier1_normalIdentifier() { | 10743 void test_parseSimpleIdentifier1_normalIdentifier() { |
| 9783 // TODO(brianwilkerson) Implement tests for this method. | 10744 // TODO(brianwilkerson) Implement tests for this method. |
| 9784 } | 10745 } |
| 9785 | 10746 |
| 9786 void test_parseSimpleIdentifier_builtInIdentifier() { | 10747 void test_parseSimpleIdentifier_builtInIdentifier() { |
| 9787 String lexeme = "as"; | 10748 String lexeme = "as"; |
| 9788 SimpleIdentifier identifier = parse4("parseSimpleIdentifier", lexeme); | 10749 createParser(lexeme); |
| 10750 SimpleIdentifier identifier = parser.parseSimpleIdentifier(); |
| 10751 expectNotNullIfNoErrors(identifier); |
| 10752 listener.assertNoErrors(); |
| 9789 expect(identifier.token, isNotNull); | 10753 expect(identifier.token, isNotNull); |
| 9790 expect(identifier.name, lexeme); | 10754 expect(identifier.name, lexeme); |
| 9791 } | 10755 } |
| 9792 | 10756 |
| 9793 void test_parseSimpleIdentifier_normalIdentifier() { | 10757 void test_parseSimpleIdentifier_normalIdentifier() { |
| 9794 String lexeme = "foo"; | 10758 String lexeme = "foo"; |
| 9795 SimpleIdentifier identifier = parse4("parseSimpleIdentifier", lexeme); | 10759 createParser(lexeme); |
| 10760 SimpleIdentifier identifier = parser.parseSimpleIdentifier(); |
| 10761 expectNotNullIfNoErrors(identifier); |
| 10762 listener.assertNoErrors(); |
| 9796 expect(identifier.token, isNotNull); | 10763 expect(identifier.token, isNotNull); |
| 9797 expect(identifier.name, lexeme); | 10764 expect(identifier.name, lexeme); |
| 9798 } | 10765 } |
| 9799 | 10766 |
| 9800 void test_parseStatement_emptyTypeArgumentList() { | 10767 void test_parseStatement_emptyTypeArgumentList() { |
| 9801 VariableDeclarationStatement statement = parse4( | 10768 createParser('C<> c;'); |
| 9802 "parseStatement", "C<> c;", [ParserErrorCode.EXPECTED_TYPE_NAME]); | 10769 Statement statement = parser.parseStatement2(); |
| 9803 VariableDeclarationList variables = statement.variables; | 10770 expectNotNullIfNoErrors(statement); |
| 10771 listener.assertErrorsWithCodes([ParserErrorCode.EXPECTED_TYPE_NAME]); |
| 10772 expect(statement, new isInstanceOf<VariableDeclarationStatement>()); |
| 10773 VariableDeclarationStatement declaration = statement; |
| 10774 VariableDeclarationList variables = declaration.variables; |
| 9804 TypeName type = variables.type; | 10775 TypeName type = variables.type; |
| 9805 TypeArgumentList argumentList = type.typeArguments; | 10776 TypeArgumentList argumentList = type.typeArguments; |
| 9806 expect(argumentList.leftBracket, isNotNull); | 10777 expect(argumentList.leftBracket, isNotNull); |
| 9807 expect(argumentList.arguments, hasLength(1)); | 10778 expect(argumentList.arguments, hasLength(1)); |
| 9808 expect(argumentList.arguments[0].isSynthetic, isTrue); | 10779 expect(argumentList.arguments[0].isSynthetic, isTrue); |
| 9809 expect(argumentList.rightBracket, isNotNull); | 10780 expect(argumentList.rightBracket, isNotNull); |
| 9810 } | 10781 } |
| 9811 | 10782 |
| 9812 void test_parseStatement_functionDeclaration_noReturnType() { | 10783 void test_parseStatement_functionDeclaration_noReturnType() { |
| 9813 FunctionDeclarationStatement statement = | 10784 createParser('f(a, b) {};'); |
| 9814 parse4("parseStatement", "f(a, b) {};"); | 10785 Statement statement = parser.parseStatement2(); |
| 9815 expect(statement.functionDeclaration, isNotNull); | 10786 expectNotNullIfNoErrors(statement); |
| 10787 listener.assertNoErrors(); |
| 10788 expect(statement, new isInstanceOf<FunctionDeclarationStatement>()); |
| 10789 FunctionDeclarationStatement declaration = statement; |
| 10790 expect(declaration.functionDeclaration, isNotNull); |
| 9816 } | 10791 } |
| 9817 | 10792 |
| 9818 void | 10793 void |
| 9819 test_parseStatement_functionDeclaration_noReturnType_typeParameterComments
() { | 10794 test_parseStatement_functionDeclaration_noReturnType_typeParameterComments
() { |
| 9820 enableGenericMethodComments = true; | 10795 enableGenericMethodComments = true; |
| 9821 FunctionDeclarationStatement statement = | 10796 createParser('f/*<E>*/(a, b) {};'); |
| 9822 parse4("parseStatement", "f/*<E>*/(a, b) {};"); | 10797 Statement statement = parser.parseStatement2(); |
| 9823 expect(statement.functionDeclaration, isNotNull); | 10798 expectNotNullIfNoErrors(statement); |
| 9824 expect(statement.functionDeclaration.functionExpression.typeParameters, | 10799 listener.assertNoErrors(); |
| 10800 expect(statement, new isInstanceOf<FunctionDeclarationStatement>()); |
| 10801 FunctionDeclarationStatement declaration = statement; |
| 10802 expect(declaration.functionDeclaration, isNotNull); |
| 10803 expect(declaration.functionDeclaration.functionExpression.typeParameters, |
| 9825 isNotNull); | 10804 isNotNull); |
| 9826 } | 10805 } |
| 9827 | 10806 |
| 9828 void test_parseStatement_functionDeclaration_returnType() { | 10807 void test_parseStatement_functionDeclaration_returnType() { |
| 9829 // TODO(brianwilkerson) Implement more tests for this method. | 10808 // TODO(brianwilkerson) Implement more tests for this method. |
| 9830 FunctionDeclarationStatement statement = | 10809 createParser('int f(a, b) {};'); |
| 9831 parse4("parseStatement", "int f(a, b) {};", []); | 10810 Statement statement = parser.parseStatement2(); |
| 9832 expect(statement.functionDeclaration, isNotNull); | 10811 expectNotNullIfNoErrors(statement); |
| 10812 listener.assertNoErrors(); |
| 10813 expect(statement, new isInstanceOf<FunctionDeclarationStatement>()); |
| 10814 FunctionDeclarationStatement declaration = statement; |
| 10815 expect(declaration.functionDeclaration, isNotNull); |
| 9833 } | 10816 } |
| 9834 | 10817 |
| 9835 void test_parseStatement_functionDeclaration_returnType_typeParameters() { | 10818 void test_parseStatement_functionDeclaration_returnType_typeParameters() { |
| 9836 enableGenericMethods = true; | 10819 enableGenericMethods = true; |
| 9837 FunctionDeclarationStatement statement = | 10820 createParser('int f<E>(a, b) {};'); |
| 9838 parse4("parseStatement", "int f<E>(a, b) {};"); | 10821 Statement statement = parser.parseStatement2(); |
| 9839 expect(statement.functionDeclaration, isNotNull); | 10822 expectNotNullIfNoErrors(statement); |
| 10823 listener.assertNoErrors(); |
| 10824 expect(statement, new isInstanceOf<FunctionDeclarationStatement>()); |
| 10825 FunctionDeclarationStatement declaration = statement; |
| 10826 expect(declaration.functionDeclaration, isNotNull); |
| 9840 } | 10827 } |
| 9841 | 10828 |
| 9842 void test_parseStatement_mulipleLabels() { | 10829 void test_parseStatement_mulipleLabels() { |
| 9843 LabeledStatement statement = parse4("parseStatement", "l: m: return x;"); | 10830 createParser('l: m: return x;'); |
| 9844 expect(statement.labels, hasLength(2)); | 10831 Statement statement = parser.parseStatement2(); |
| 9845 expect(statement.statement, isNotNull); | 10832 expectNotNullIfNoErrors(statement); |
| 10833 listener.assertNoErrors(); |
| 10834 expect(statement, new isInstanceOf<LabeledStatement>()); |
| 10835 LabeledStatement labeledStatement = statement; |
| 10836 expect(labeledStatement.labels, hasLength(2)); |
| 10837 expect(labeledStatement.statement, isNotNull); |
| 9846 } | 10838 } |
| 9847 | 10839 |
| 9848 void test_parseStatement_noLabels() { | 10840 void test_parseStatement_noLabels() { |
| 9849 parse4("parseStatement", "return x;"); | 10841 createParser('return x;'); |
| 10842 Statement statement = parser.parseStatement2(); |
| 10843 expectNotNullIfNoErrors(statement); |
| 10844 listener.assertNoErrors(); |
| 9850 } | 10845 } |
| 9851 | 10846 |
| 9852 void test_parseStatement_singleLabel() { | 10847 void test_parseStatement_singleLabel() { |
| 9853 LabeledStatement statement = parse4("parseStatement", "l: return x;"); | 10848 createParser('l: return x;'); |
| 9854 expect(statement.labels, hasLength(1)); | 10849 Statement statement = parser.parseStatement2(); |
| 9855 expect(statement.labels[0].label.inDeclarationContext(), isTrue); | 10850 expectNotNullIfNoErrors(statement); |
| 9856 expect(statement.statement, isNotNull); | 10851 listener.assertNoErrors(); |
| 10852 expect(statement, new isInstanceOf<LabeledStatement>()); |
| 10853 LabeledStatement labeledStatement = statement; |
| 10854 expect(labeledStatement.labels, hasLength(1)); |
| 10855 expect(labeledStatement.labels[0].label.inDeclarationContext(), isTrue); |
| 10856 expect(labeledStatement.statement, isNotNull); |
| 9857 } | 10857 } |
| 9858 | 10858 |
| 9859 void test_parseStatements_multiple() { | 10859 void test_parseStatements_multiple() { |
| 9860 List<Statement> statements = | 10860 List<Statement> statements = |
| 9861 ParserTestCase.parseStatements("return; return;", 2); | 10861 ParserTestCase.parseStatements("return; return;", 2); |
| 9862 expect(statements, hasLength(2)); | 10862 expect(statements, hasLength(2)); |
| 9863 } | 10863 } |
| 9864 | 10864 |
| 9865 void test_parseStatements_single() { | 10865 void test_parseStatements_single() { |
| 9866 List<Statement> statements = ParserTestCase.parseStatements("return;", 1); | 10866 List<Statement> statements = ParserTestCase.parseStatements("return;", 1); |
| 9867 expect(statements, hasLength(1)); | 10867 expect(statements, hasLength(1)); |
| 9868 } | 10868 } |
| 9869 | 10869 |
| 9870 void test_parseStringLiteral_adjacent() { | 10870 void test_parseStringLiteral_adjacent() { |
| 9871 AdjacentStrings literal = parse4("parseStringLiteral", "'a' 'b'"); | 10871 createParser("'a' 'b'"); |
| 10872 Expression expression = parser.parseStringLiteral(); |
| 10873 expectNotNullIfNoErrors(expression); |
| 10874 listener.assertNoErrors(); |
| 10875 expect(expression, new isInstanceOf<AdjacentStrings>()); |
| 10876 AdjacentStrings literal = expression; |
| 9872 NodeList<StringLiteral> strings = literal.strings; | 10877 NodeList<StringLiteral> strings = literal.strings; |
| 9873 expect(strings, hasLength(2)); | 10878 expect(strings, hasLength(2)); |
| 9874 StringLiteral firstString = strings[0]; | 10879 StringLiteral firstString = strings[0]; |
| 9875 StringLiteral secondString = strings[1]; | 10880 StringLiteral secondString = strings[1]; |
| 9876 expect((firstString as SimpleStringLiteral).value, "a"); | 10881 expect((firstString as SimpleStringLiteral).value, "a"); |
| 9877 expect((secondString as SimpleStringLiteral).value, "b"); | 10882 expect((secondString as SimpleStringLiteral).value, "b"); |
| 9878 } | 10883 } |
| 9879 | 10884 |
| 9880 void test_parseStringLiteral_endsWithInterpolation() { | 10885 void test_parseStringLiteral_endsWithInterpolation() { |
| 9881 StringLiteral literal = parse4('parseStringLiteral', r"'x$y'"); | 10886 createParser(r"'x$y'"); |
| 9882 expect(literal, new isInstanceOf<StringInterpolation>()); | 10887 Expression expression = parser.parseStringLiteral(); |
| 9883 StringInterpolation interpolation = literal; | 10888 expectNotNullIfNoErrors(expression); |
| 10889 listener.assertNoErrors(); |
| 10890 expect(expression, new isInstanceOf<StringInterpolation>()); |
| 10891 StringInterpolation interpolation = expression; |
| 9884 expect(interpolation.elements, hasLength(3)); | 10892 expect(interpolation.elements, hasLength(3)); |
| 9885 expect(interpolation.elements[0], new isInstanceOf<InterpolationString>()); | 10893 expect(interpolation.elements[0], new isInstanceOf<InterpolationString>()); |
| 9886 InterpolationString element0 = interpolation.elements[0]; | 10894 InterpolationString element0 = interpolation.elements[0]; |
| 9887 expect(element0.value, 'x'); | 10895 expect(element0.value, 'x'); |
| 9888 expect( | 10896 expect( |
| 9889 interpolation.elements[1], new isInstanceOf<InterpolationExpression>()); | 10897 interpolation.elements[1], new isInstanceOf<InterpolationExpression>()); |
| 9890 InterpolationExpression element1 = interpolation.elements[1]; | 10898 InterpolationExpression element1 = interpolation.elements[1]; |
| 9891 expect(element1.expression, new isInstanceOf<SimpleIdentifier>()); | 10899 expect(element1.expression, new isInstanceOf<SimpleIdentifier>()); |
| 9892 expect(interpolation.elements[2], new isInstanceOf<InterpolationString>()); | 10900 expect(interpolation.elements[2], new isInstanceOf<InterpolationString>()); |
| 9893 InterpolationString element2 = interpolation.elements[2]; | 10901 InterpolationString element2 = interpolation.elements[2]; |
| 9894 expect(element2.value, ''); | 10902 expect(element2.value, ''); |
| 9895 } | 10903 } |
| 9896 | 10904 |
| 9897 void test_parseStringLiteral_interpolated() { | 10905 void test_parseStringLiteral_interpolated() { |
| 9898 StringInterpolation literal = | 10906 createParser("'a \${b} c \$this d'"); |
| 9899 parse4("parseStringLiteral", "'a \${b} c \$this d'"); | 10907 Expression expression = parser.parseStringLiteral(); |
| 10908 expectNotNullIfNoErrors(expression); |
| 10909 listener.assertNoErrors(); |
| 10910 expect(expression, new isInstanceOf<StringInterpolation>()); |
| 10911 StringInterpolation literal = expression; |
| 9900 NodeList<InterpolationElement> elements = literal.elements; | 10912 NodeList<InterpolationElement> elements = literal.elements; |
| 9901 expect(elements, hasLength(5)); | 10913 expect(elements, hasLength(5)); |
| 9902 expect(elements[0] is InterpolationString, isTrue); | 10914 expect(elements[0] is InterpolationString, isTrue); |
| 9903 expect(elements[1] is InterpolationExpression, isTrue); | 10915 expect(elements[1] is InterpolationExpression, isTrue); |
| 9904 expect(elements[2] is InterpolationString, isTrue); | 10916 expect(elements[2] is InterpolationString, isTrue); |
| 9905 expect(elements[3] is InterpolationExpression, isTrue); | 10917 expect(elements[3] is InterpolationExpression, isTrue); |
| 9906 expect(elements[4] is InterpolationString, isTrue); | 10918 expect(elements[4] is InterpolationString, isTrue); |
| 9907 } | 10919 } |
| 9908 | 10920 |
| 9909 void test_parseStringLiteral_multiline_encodedSpace() { | 10921 void test_parseStringLiteral_multiline_encodedSpace() { |
| 9910 SimpleStringLiteral literal = | 10922 createParser("'''\\x20\na'''"); |
| 9911 parse4("parseStringLiteral", "'''\\x20\na'''"); | 10923 Expression expression = parser.parseStringLiteral(); |
| 10924 expectNotNullIfNoErrors(expression); |
| 10925 listener.assertNoErrors(); |
| 10926 expect(expression, new isInstanceOf<SimpleStringLiteral>()); |
| 10927 SimpleStringLiteral literal = expression; |
| 9912 expect(literal.literal, isNotNull); | 10928 expect(literal.literal, isNotNull); |
| 9913 expect(literal.value, " \na"); | 10929 expect(literal.value, " \na"); |
| 9914 } | 10930 } |
| 9915 | 10931 |
| 9916 void test_parseStringLiteral_multiline_endsWithInterpolation() { | 10932 void test_parseStringLiteral_multiline_endsWithInterpolation() { |
| 9917 StringLiteral literal = parse4('parseStringLiteral', r"'''x$y'''"); | 10933 createParser(r"'''x$y'''"); |
| 9918 expect(literal, new isInstanceOf<StringInterpolation>()); | 10934 Expression expression = parser.parseStringLiteral(); |
| 9919 StringInterpolation interpolation = literal; | 10935 expectNotNullIfNoErrors(expression); |
| 10936 listener.assertNoErrors(); |
| 10937 expect(expression, new isInstanceOf<StringInterpolation>()); |
| 10938 StringInterpolation interpolation = expression; |
| 9920 expect(interpolation.elements, hasLength(3)); | 10939 expect(interpolation.elements, hasLength(3)); |
| 9921 expect(interpolation.elements[0], new isInstanceOf<InterpolationString>()); | 10940 expect(interpolation.elements[0], new isInstanceOf<InterpolationString>()); |
| 9922 InterpolationString element0 = interpolation.elements[0]; | 10941 InterpolationString element0 = interpolation.elements[0]; |
| 9923 expect(element0.value, 'x'); | 10942 expect(element0.value, 'x'); |
| 9924 expect( | 10943 expect( |
| 9925 interpolation.elements[1], new isInstanceOf<InterpolationExpression>()); | 10944 interpolation.elements[1], new isInstanceOf<InterpolationExpression>()); |
| 9926 InterpolationExpression element1 = interpolation.elements[1]; | 10945 InterpolationExpression element1 = interpolation.elements[1]; |
| 9927 expect(element1.expression, new isInstanceOf<SimpleIdentifier>()); | 10946 expect(element1.expression, new isInstanceOf<SimpleIdentifier>()); |
| 9928 expect(interpolation.elements[2], new isInstanceOf<InterpolationString>()); | 10947 expect(interpolation.elements[2], new isInstanceOf<InterpolationString>()); |
| 9929 InterpolationString element2 = interpolation.elements[2]; | 10948 InterpolationString element2 = interpolation.elements[2]; |
| 9930 expect(element2.value, ''); | 10949 expect(element2.value, ''); |
| 9931 } | 10950 } |
| 9932 | 10951 |
| 9933 void test_parseStringLiteral_multiline_escapedBackslash() { | 10952 void test_parseStringLiteral_multiline_escapedBackslash() { |
| 9934 SimpleStringLiteral literal = parse4("parseStringLiteral", "'''\\\\\na'''"); | 10953 createParser("'''\\\\\na'''"); |
| 10954 Expression expression = parser.parseStringLiteral(); |
| 10955 expectNotNullIfNoErrors(expression); |
| 10956 listener.assertNoErrors(); |
| 10957 expect(expression, new isInstanceOf<SimpleStringLiteral>()); |
| 10958 SimpleStringLiteral literal = expression; |
| 9935 expect(literal.literal, isNotNull); | 10959 expect(literal.literal, isNotNull); |
| 9936 expect(literal.value, "\\\na"); | 10960 expect(literal.value, "\\\na"); |
| 9937 } | 10961 } |
| 9938 | 10962 |
| 9939 void test_parseStringLiteral_multiline_escapedBackslash_raw() { | 10963 void test_parseStringLiteral_multiline_escapedBackslash_raw() { |
| 9940 SimpleStringLiteral literal = | 10964 createParser("r'''\\\\\na'''"); |
| 9941 parse4("parseStringLiteral", "r'''\\\\\na'''"); | 10965 Expression expression = parser.parseStringLiteral(); |
| 10966 expectNotNullIfNoErrors(expression); |
| 10967 listener.assertNoErrors(); |
| 10968 expect(expression, new isInstanceOf<SimpleStringLiteral>()); |
| 10969 SimpleStringLiteral literal = expression; |
| 9942 expect(literal.literal, isNotNull); | 10970 expect(literal.literal, isNotNull); |
| 9943 expect(literal.value, "\\\\\na"); | 10971 expect(literal.value, "\\\\\na"); |
| 9944 } | 10972 } |
| 9945 | 10973 |
| 9946 void test_parseStringLiteral_multiline_escapedEolMarker() { | 10974 void test_parseStringLiteral_multiline_escapedEolMarker() { |
| 9947 SimpleStringLiteral literal = parse4("parseStringLiteral", "'''\\\na'''"); | 10975 createParser("'''\\\na'''"); |
| 10976 Expression expression = parser.parseStringLiteral(); |
| 10977 expectNotNullIfNoErrors(expression); |
| 10978 listener.assertNoErrors(); |
| 10979 expect(expression, new isInstanceOf<SimpleStringLiteral>()); |
| 10980 SimpleStringLiteral literal = expression; |
| 9948 expect(literal.literal, isNotNull); | 10981 expect(literal.literal, isNotNull); |
| 9949 expect(literal.value, "a"); | 10982 expect(literal.value, "a"); |
| 9950 } | 10983 } |
| 9951 | 10984 |
| 9952 void test_parseStringLiteral_multiline_escapedEolMarker_raw() { | 10985 void test_parseStringLiteral_multiline_escapedEolMarker_raw() { |
| 9953 SimpleStringLiteral literal = parse4("parseStringLiteral", "r'''\\\na'''"); | 10986 createParser("r'''\\\na'''"); |
| 10987 Expression expression = parser.parseStringLiteral(); |
| 10988 expectNotNullIfNoErrors(expression); |
| 10989 listener.assertNoErrors(); |
| 10990 expect(expression, new isInstanceOf<SimpleStringLiteral>()); |
| 10991 SimpleStringLiteral literal = expression; |
| 9954 expect(literal.literal, isNotNull); | 10992 expect(literal.literal, isNotNull); |
| 9955 expect(literal.value, "a"); | 10993 expect(literal.value, "a"); |
| 9956 } | 10994 } |
| 9957 | 10995 |
| 9958 void test_parseStringLiteral_multiline_escapedSpaceAndEolMarker() { | 10996 void test_parseStringLiteral_multiline_escapedSpaceAndEolMarker() { |
| 9959 SimpleStringLiteral literal = | 10997 createParser("'''\\ \\\na'''"); |
| 9960 parse4("parseStringLiteral", "'''\\ \\\na'''"); | 10998 Expression expression = parser.parseStringLiteral(); |
| 10999 expectNotNullIfNoErrors(expression); |
| 11000 listener.assertNoErrors(); |
| 11001 expect(expression, new isInstanceOf<SimpleStringLiteral>()); |
| 11002 SimpleStringLiteral literal = expression; |
| 9961 expect(literal.literal, isNotNull); | 11003 expect(literal.literal, isNotNull); |
| 9962 expect(literal.value, "a"); | 11004 expect(literal.value, "a"); |
| 9963 } | 11005 } |
| 9964 | 11006 |
| 9965 void test_parseStringLiteral_multiline_escapedSpaceAndEolMarker_raw() { | 11007 void test_parseStringLiteral_multiline_escapedSpaceAndEolMarker_raw() { |
| 9966 SimpleStringLiteral literal = | 11008 createParser("r'''\\ \\\na'''"); |
| 9967 parse4("parseStringLiteral", "r'''\\ \\\na'''"); | 11009 Expression expression = parser.parseStringLiteral(); |
| 11010 expectNotNullIfNoErrors(expression); |
| 11011 listener.assertNoErrors(); |
| 11012 expect(expression, new isInstanceOf<SimpleStringLiteral>()); |
| 11013 SimpleStringLiteral literal = expression; |
| 9968 expect(literal.literal, isNotNull); | 11014 expect(literal.literal, isNotNull); |
| 9969 expect(literal.value, "a"); | 11015 expect(literal.value, "a"); |
| 9970 } | 11016 } |
| 9971 | 11017 |
| 9972 void test_parseStringLiteral_multiline_escapedTab() { | 11018 void test_parseStringLiteral_multiline_escapedTab() { |
| 9973 SimpleStringLiteral literal = parse4("parseStringLiteral", "'''\\t\na'''"); | 11019 createParser("'''\\t\na'''"); |
| 11020 Expression expression = parser.parseStringLiteral(); |
| 11021 expectNotNullIfNoErrors(expression); |
| 11022 listener.assertNoErrors(); |
| 11023 expect(expression, new isInstanceOf<SimpleStringLiteral>()); |
| 11024 SimpleStringLiteral literal = expression; |
| 9974 expect(literal.literal, isNotNull); | 11025 expect(literal.literal, isNotNull); |
| 9975 expect(literal.value, "\t\na"); | 11026 expect(literal.value, "\t\na"); |
| 9976 } | 11027 } |
| 9977 | 11028 |
| 9978 void test_parseStringLiteral_multiline_escapedTab_raw() { | 11029 void test_parseStringLiteral_multiline_escapedTab_raw() { |
| 9979 SimpleStringLiteral literal = parse4("parseStringLiteral", "r'''\\t\na'''"); | 11030 createParser("r'''\\t\na'''"); |
| 11031 Expression expression = parser.parseStringLiteral(); |
| 11032 expectNotNullIfNoErrors(expression); |
| 11033 listener.assertNoErrors(); |
| 11034 expect(expression, new isInstanceOf<SimpleStringLiteral>()); |
| 11035 SimpleStringLiteral literal = expression; |
| 9980 expect(literal.literal, isNotNull); | 11036 expect(literal.literal, isNotNull); |
| 9981 expect(literal.value, "\\t\na"); | 11037 expect(literal.value, "\\t\na"); |
| 9982 } | 11038 } |
| 9983 | 11039 |
| 9984 void test_parseStringLiteral_multiline_quoteAfterInterpolation() { | 11040 void test_parseStringLiteral_multiline_quoteAfterInterpolation() { |
| 9985 StringLiteral literal = parse4('parseStringLiteral', r"""'''$x'y'''"""); | 11041 createParser(r"""'''$x'y'''"""); |
| 9986 expect(literal, new isInstanceOf<StringInterpolation>()); | 11042 Expression expression = parser.parseStringLiteral(); |
| 9987 StringInterpolation interpolation = literal; | 11043 expectNotNullIfNoErrors(expression); |
| 11044 listener.assertNoErrors(); |
| 11045 expect(expression, new isInstanceOf<StringInterpolation>()); |
| 11046 StringInterpolation interpolation = expression; |
| 9988 expect(interpolation.elements, hasLength(3)); | 11047 expect(interpolation.elements, hasLength(3)); |
| 9989 expect(interpolation.elements[0], new isInstanceOf<InterpolationString>()); | 11048 expect(interpolation.elements[0], new isInstanceOf<InterpolationString>()); |
| 9990 InterpolationString element0 = interpolation.elements[0]; | 11049 InterpolationString element0 = interpolation.elements[0]; |
| 9991 expect(element0.value, ''); | 11050 expect(element0.value, ''); |
| 9992 expect( | 11051 expect( |
| 9993 interpolation.elements[1], new isInstanceOf<InterpolationExpression>()); | 11052 interpolation.elements[1], new isInstanceOf<InterpolationExpression>()); |
| 9994 InterpolationExpression element1 = interpolation.elements[1]; | 11053 InterpolationExpression element1 = interpolation.elements[1]; |
| 9995 expect(element1.expression, new isInstanceOf<SimpleIdentifier>()); | 11054 expect(element1.expression, new isInstanceOf<SimpleIdentifier>()); |
| 9996 expect(interpolation.elements[2], new isInstanceOf<InterpolationString>()); | 11055 expect(interpolation.elements[2], new isInstanceOf<InterpolationString>()); |
| 9997 InterpolationString element2 = interpolation.elements[2]; | 11056 InterpolationString element2 = interpolation.elements[2]; |
| 9998 expect(element2.value, "'y"); | 11057 expect(element2.value, "'y"); |
| 9999 } | 11058 } |
| 10000 | 11059 |
| 10001 void test_parseStringLiteral_multiline_startsWithInterpolation() { | 11060 void test_parseStringLiteral_multiline_startsWithInterpolation() { |
| 10002 StringLiteral literal = parse4('parseStringLiteral', r"'''${x}y'''"); | 11061 createParser(r"'''${x}y'''"); |
| 10003 expect(literal, new isInstanceOf<StringInterpolation>()); | 11062 Expression expression = parser.parseStringLiteral(); |
| 10004 StringInterpolation interpolation = literal; | 11063 expectNotNullIfNoErrors(expression); |
| 11064 listener.assertNoErrors(); |
| 11065 expect(expression, new isInstanceOf<StringInterpolation>()); |
| 11066 StringInterpolation interpolation = expression; |
| 10005 expect(interpolation.elements, hasLength(3)); | 11067 expect(interpolation.elements, hasLength(3)); |
| 10006 expect(interpolation.elements[0], new isInstanceOf<InterpolationString>()); | 11068 expect(interpolation.elements[0], new isInstanceOf<InterpolationString>()); |
| 10007 InterpolationString element0 = interpolation.elements[0]; | 11069 InterpolationString element0 = interpolation.elements[0]; |
| 10008 expect(element0.value, ''); | 11070 expect(element0.value, ''); |
| 10009 expect( | 11071 expect( |
| 10010 interpolation.elements[1], new isInstanceOf<InterpolationExpression>()); | 11072 interpolation.elements[1], new isInstanceOf<InterpolationExpression>()); |
| 10011 InterpolationExpression element1 = interpolation.elements[1]; | 11073 InterpolationExpression element1 = interpolation.elements[1]; |
| 10012 expect(element1.expression, new isInstanceOf<SimpleIdentifier>()); | 11074 expect(element1.expression, new isInstanceOf<SimpleIdentifier>()); |
| 10013 expect(interpolation.elements[2], new isInstanceOf<InterpolationString>()); | 11075 expect(interpolation.elements[2], new isInstanceOf<InterpolationString>()); |
| 10014 InterpolationString element2 = interpolation.elements[2]; | 11076 InterpolationString element2 = interpolation.elements[2]; |
| 10015 expect(element2.value, 'y'); | 11077 expect(element2.value, 'y'); |
| 10016 } | 11078 } |
| 10017 | 11079 |
| 10018 void test_parseStringLiteral_multiline_twoSpaces() { | 11080 void test_parseStringLiteral_multiline_twoSpaces() { |
| 10019 SimpleStringLiteral literal = parse4("parseStringLiteral", "''' \na'''"); | 11081 createParser("''' \na'''"); |
| 11082 Expression expression = parser.parseStringLiteral(); |
| 11083 expectNotNullIfNoErrors(expression); |
| 11084 listener.assertNoErrors(); |
| 11085 expect(expression, new isInstanceOf<SimpleStringLiteral>()); |
| 11086 SimpleStringLiteral literal = expression; |
| 10020 expect(literal.literal, isNotNull); | 11087 expect(literal.literal, isNotNull); |
| 10021 expect(literal.value, "a"); | 11088 expect(literal.value, "a"); |
| 10022 } | 11089 } |
| 10023 | 11090 |
| 10024 void test_parseStringLiteral_multiline_twoSpaces_raw() { | 11091 void test_parseStringLiteral_multiline_twoSpaces_raw() { |
| 10025 SimpleStringLiteral literal = parse4("parseStringLiteral", "r''' \na'''"); | 11092 createParser("r''' \na'''"); |
| 11093 Expression expression = parser.parseStringLiteral(); |
| 11094 expectNotNullIfNoErrors(expression); |
| 11095 listener.assertNoErrors(); |
| 11096 expect(expression, new isInstanceOf<SimpleStringLiteral>()); |
| 11097 SimpleStringLiteral literal = expression; |
| 10026 expect(literal.literal, isNotNull); | 11098 expect(literal.literal, isNotNull); |
| 10027 expect(literal.value, "a"); | 11099 expect(literal.value, "a"); |
| 10028 } | 11100 } |
| 10029 | 11101 |
| 10030 void test_parseStringLiteral_multiline_untrimmed() { | 11102 void test_parseStringLiteral_multiline_untrimmed() { |
| 10031 SimpleStringLiteral literal = parse4("parseStringLiteral", "''' a\nb'''"); | 11103 createParser("''' a\nb'''"); |
| 11104 Expression expression = parser.parseStringLiteral(); |
| 11105 expectNotNullIfNoErrors(expression); |
| 11106 listener.assertNoErrors(); |
| 11107 expect(expression, new isInstanceOf<SimpleStringLiteral>()); |
| 11108 SimpleStringLiteral literal = expression; |
| 10032 expect(literal.literal, isNotNull); | 11109 expect(literal.literal, isNotNull); |
| 10033 expect(literal.value, " a\nb"); | 11110 expect(literal.value, " a\nb"); |
| 10034 } | 11111 } |
| 10035 | 11112 |
| 10036 void test_parseStringLiteral_quoteAfterInterpolation() { | 11113 void test_parseStringLiteral_quoteAfterInterpolation() { |
| 10037 StringLiteral literal = parse4('parseStringLiteral', r"""'$x"'"""); | 11114 createParser(r"""'$x"'"""); |
| 10038 expect(literal, new isInstanceOf<StringInterpolation>()); | 11115 Expression expression = parser.parseStringLiteral(); |
| 10039 StringInterpolation interpolation = literal; | 11116 expectNotNullIfNoErrors(expression); |
| 11117 listener.assertNoErrors(); |
| 11118 expect(expression, new isInstanceOf<StringInterpolation>()); |
| 11119 StringInterpolation interpolation = expression; |
| 10040 expect(interpolation.elements, hasLength(3)); | 11120 expect(interpolation.elements, hasLength(3)); |
| 10041 expect(interpolation.elements[0], new isInstanceOf<InterpolationString>()); | 11121 expect(interpolation.elements[0], new isInstanceOf<InterpolationString>()); |
| 10042 InterpolationString element0 = interpolation.elements[0]; | 11122 InterpolationString element0 = interpolation.elements[0]; |
| 10043 expect(element0.value, ''); | 11123 expect(element0.value, ''); |
| 10044 expect( | 11124 expect( |
| 10045 interpolation.elements[1], new isInstanceOf<InterpolationExpression>()); | 11125 interpolation.elements[1], new isInstanceOf<InterpolationExpression>()); |
| 10046 InterpolationExpression element1 = interpolation.elements[1]; | 11126 InterpolationExpression element1 = interpolation.elements[1]; |
| 10047 expect(element1.expression, new isInstanceOf<SimpleIdentifier>()); | 11127 expect(element1.expression, new isInstanceOf<SimpleIdentifier>()); |
| 10048 expect(interpolation.elements[2], new isInstanceOf<InterpolationString>()); | 11128 expect(interpolation.elements[2], new isInstanceOf<InterpolationString>()); |
| 10049 InterpolationString element2 = interpolation.elements[2]; | 11129 InterpolationString element2 = interpolation.elements[2]; |
| 10050 expect(element2.value, '"'); | 11130 expect(element2.value, '"'); |
| 10051 } | 11131 } |
| 10052 | 11132 |
| 10053 void test_parseStringLiteral_single() { | 11133 void test_parseStringLiteral_single() { |
| 10054 SimpleStringLiteral literal = parse4("parseStringLiteral", "'a'"); | 11134 createParser("'a'"); |
| 11135 Expression expression = parser.parseStringLiteral(); |
| 11136 expectNotNullIfNoErrors(expression); |
| 11137 listener.assertNoErrors(); |
| 11138 expect(expression, new isInstanceOf<SimpleStringLiteral>()); |
| 11139 SimpleStringLiteral literal = expression; |
| 10055 expect(literal.literal, isNotNull); | 11140 expect(literal.literal, isNotNull); |
| 10056 expect(literal.value, "a"); | 11141 expect(literal.value, "a"); |
| 10057 } | 11142 } |
| 10058 | 11143 |
| 10059 void test_parseStringLiteral_startsWithInterpolation() { | 11144 void test_parseStringLiteral_startsWithInterpolation() { |
| 10060 StringLiteral literal = parse4('parseStringLiteral', r"'${x}y'"); | 11145 createParser(r"'${x}y'"); |
| 10061 expect(literal, new isInstanceOf<StringInterpolation>()); | 11146 Expression expression = parser.parseStringLiteral(); |
| 10062 StringInterpolation interpolation = literal; | 11147 expectNotNullIfNoErrors(expression); |
| 11148 listener.assertNoErrors(); |
| 11149 expect(expression, new isInstanceOf<StringInterpolation>()); |
| 11150 StringInterpolation interpolation = expression; |
| 10063 expect(interpolation.elements, hasLength(3)); | 11151 expect(interpolation.elements, hasLength(3)); |
| 10064 expect(interpolation.elements[0], new isInstanceOf<InterpolationString>()); | 11152 expect(interpolation.elements[0], new isInstanceOf<InterpolationString>()); |
| 10065 InterpolationString element0 = interpolation.elements[0]; | 11153 InterpolationString element0 = interpolation.elements[0]; |
| 10066 expect(element0.value, ''); | 11154 expect(element0.value, ''); |
| 10067 expect( | 11155 expect( |
| 10068 interpolation.elements[1], new isInstanceOf<InterpolationExpression>()); | 11156 interpolation.elements[1], new isInstanceOf<InterpolationExpression>()); |
| 10069 InterpolationExpression element1 = interpolation.elements[1]; | 11157 InterpolationExpression element1 = interpolation.elements[1]; |
| 10070 expect(element1.expression, new isInstanceOf<SimpleIdentifier>()); | 11158 expect(element1.expression, new isInstanceOf<SimpleIdentifier>()); |
| 10071 expect(interpolation.elements[2], new isInstanceOf<InterpolationString>()); | 11159 expect(interpolation.elements[2], new isInstanceOf<InterpolationString>()); |
| 10072 InterpolationString element2 = interpolation.elements[2]; | 11160 InterpolationString element2 = interpolation.elements[2]; |
| 10073 expect(element2.value, 'y'); | 11161 expect(element2.value, 'y'); |
| 10074 } | 11162 } |
| 10075 | 11163 |
| 10076 void test_parseSuperConstructorInvocation_named() { | 11164 void test_parseSuperConstructorInvocation_named() { |
| 11165 createParser('super.a()'); |
| 10077 SuperConstructorInvocation invocation = | 11166 SuperConstructorInvocation invocation = |
| 10078 parse4("parseSuperConstructorInvocation", "super.a()"); | 11167 parser.parseSuperConstructorInvocation(); |
| 11168 expectNotNullIfNoErrors(invocation); |
| 11169 listener.assertNoErrors(); |
| 10079 expect(invocation.argumentList, isNotNull); | 11170 expect(invocation.argumentList, isNotNull); |
| 10080 expect(invocation.constructorName, isNotNull); | 11171 expect(invocation.constructorName, isNotNull); |
| 10081 expect(invocation.superKeyword, isNotNull); | 11172 expect(invocation.superKeyword, isNotNull); |
| 10082 expect(invocation.period, isNotNull); | 11173 expect(invocation.period, isNotNull); |
| 10083 } | 11174 } |
| 10084 | 11175 |
| 10085 void test_parseSuperConstructorInvocation_unnamed() { | 11176 void test_parseSuperConstructorInvocation_unnamed() { |
| 11177 createParser('super()'); |
| 10086 SuperConstructorInvocation invocation = | 11178 SuperConstructorInvocation invocation = |
| 10087 parse4("parseSuperConstructorInvocation", "super()"); | 11179 parser.parseSuperConstructorInvocation(); |
| 11180 expectNotNullIfNoErrors(invocation); |
| 11181 listener.assertNoErrors(); |
| 10088 expect(invocation.argumentList, isNotNull); | 11182 expect(invocation.argumentList, isNotNull); |
| 10089 expect(invocation.constructorName, isNull); | 11183 expect(invocation.constructorName, isNull); |
| 10090 expect(invocation.superKeyword, isNotNull); | 11184 expect(invocation.superKeyword, isNotNull); |
| 10091 expect(invocation.period, isNull); | 11185 expect(invocation.period, isNull); |
| 10092 } | 11186 } |
| 10093 | 11187 |
| 10094 void test_parseSwitchStatement_case() { | 11188 void test_parseSwitchStatement_case() { |
| 10095 SwitchStatement statement = | 11189 createParser('switch (a) {case 1: return "I";}'); |
| 10096 parse4("parseSwitchStatement", "switch (a) {case 1: return 'I';}"); | 11190 SwitchStatement statement = parser.parseSwitchStatement(); |
| 11191 expectNotNullIfNoErrors(statement); |
| 11192 listener.assertNoErrors(); |
| 10097 expect(statement.switchKeyword, isNotNull); | 11193 expect(statement.switchKeyword, isNotNull); |
| 10098 expect(statement.leftParenthesis, isNotNull); | 11194 expect(statement.leftParenthesis, isNotNull); |
| 10099 expect(statement.expression, isNotNull); | 11195 expect(statement.expression, isNotNull); |
| 10100 expect(statement.rightParenthesis, isNotNull); | 11196 expect(statement.rightParenthesis, isNotNull); |
| 10101 expect(statement.leftBracket, isNotNull); | 11197 expect(statement.leftBracket, isNotNull); |
| 10102 expect(statement.members, hasLength(1)); | 11198 expect(statement.members, hasLength(1)); |
| 10103 expect(statement.rightBracket, isNotNull); | 11199 expect(statement.rightBracket, isNotNull); |
| 10104 } | 11200 } |
| 10105 | 11201 |
| 10106 void test_parseSwitchStatement_empty() { | 11202 void test_parseSwitchStatement_empty() { |
| 10107 SwitchStatement statement = parse4("parseSwitchStatement", "switch (a) {}"); | 11203 createParser('switch (a) {}'); |
| 11204 SwitchStatement statement = parser.parseSwitchStatement(); |
| 11205 expectNotNullIfNoErrors(statement); |
| 11206 listener.assertNoErrors(); |
| 10108 expect(statement.switchKeyword, isNotNull); | 11207 expect(statement.switchKeyword, isNotNull); |
| 10109 expect(statement.leftParenthesis, isNotNull); | 11208 expect(statement.leftParenthesis, isNotNull); |
| 10110 expect(statement.expression, isNotNull); | 11209 expect(statement.expression, isNotNull); |
| 10111 expect(statement.rightParenthesis, isNotNull); | 11210 expect(statement.rightParenthesis, isNotNull); |
| 10112 expect(statement.leftBracket, isNotNull); | 11211 expect(statement.leftBracket, isNotNull); |
| 10113 expect(statement.members, hasLength(0)); | 11212 expect(statement.members, hasLength(0)); |
| 10114 expect(statement.rightBracket, isNotNull); | 11213 expect(statement.rightBracket, isNotNull); |
| 10115 } | 11214 } |
| 10116 | 11215 |
| 10117 void test_parseSwitchStatement_labeledCase() { | 11216 void test_parseSwitchStatement_labeledCase() { |
| 10118 SwitchStatement statement = | 11217 createParser('switch (a) {l1: l2: l3: case(1):}'); |
| 10119 parse4("parseSwitchStatement", "switch (a) {l1: l2: l3: case(1):}"); | 11218 SwitchStatement statement = parser.parseSwitchStatement(); |
| 11219 expectNotNullIfNoErrors(statement); |
| 11220 listener.assertNoErrors(); |
| 10120 expect(statement.switchKeyword, isNotNull); | 11221 expect(statement.switchKeyword, isNotNull); |
| 10121 expect(statement.leftParenthesis, isNotNull); | 11222 expect(statement.leftParenthesis, isNotNull); |
| 10122 expect(statement.expression, isNotNull); | 11223 expect(statement.expression, isNotNull); |
| 10123 expect(statement.rightParenthesis, isNotNull); | 11224 expect(statement.rightParenthesis, isNotNull); |
| 10124 expect(statement.leftBracket, isNotNull); | 11225 expect(statement.leftBracket, isNotNull); |
| 10125 expect(statement.members, hasLength(1)); | 11226 expect(statement.members, hasLength(1)); |
| 10126 { | 11227 { |
| 10127 List<Label> labels = statement.members[0].labels; | 11228 List<Label> labels = statement.members[0].labels; |
| 10128 expect(labels, hasLength(3)); | 11229 expect(labels, hasLength(3)); |
| 10129 expect(labels[0].label.inDeclarationContext(), isTrue); | 11230 expect(labels[0].label.inDeclarationContext(), isTrue); |
| 10130 expect(labels[1].label.inDeclarationContext(), isTrue); | 11231 expect(labels[1].label.inDeclarationContext(), isTrue); |
| 10131 expect(labels[2].label.inDeclarationContext(), isTrue); | 11232 expect(labels[2].label.inDeclarationContext(), isTrue); |
| 10132 } | 11233 } |
| 10133 expect(statement.rightBracket, isNotNull); | 11234 expect(statement.rightBracket, isNotNull); |
| 10134 } | 11235 } |
| 10135 | 11236 |
| 10136 void test_parseSwitchStatement_labeledDefault() { | 11237 void test_parseSwitchStatement_labeledDefault() { |
| 10137 SwitchStatement statement = | 11238 createParser('switch (a) {l1: l2: l3: default:}'); |
| 10138 parse4("parseSwitchStatement", "switch (a) {l1: l2: l3: default:}"); | 11239 SwitchStatement statement = parser.parseSwitchStatement(); |
| 11240 expectNotNullIfNoErrors(statement); |
| 11241 listener.assertNoErrors(); |
| 10139 expect(statement.switchKeyword, isNotNull); | 11242 expect(statement.switchKeyword, isNotNull); |
| 10140 expect(statement.leftParenthesis, isNotNull); | 11243 expect(statement.leftParenthesis, isNotNull); |
| 10141 expect(statement.expression, isNotNull); | 11244 expect(statement.expression, isNotNull); |
| 10142 expect(statement.rightParenthesis, isNotNull); | 11245 expect(statement.rightParenthesis, isNotNull); |
| 10143 expect(statement.leftBracket, isNotNull); | 11246 expect(statement.leftBracket, isNotNull); |
| 10144 expect(statement.members, hasLength(1)); | 11247 expect(statement.members, hasLength(1)); |
| 10145 { | 11248 { |
| 10146 List<Label> labels = statement.members[0].labels; | 11249 List<Label> labels = statement.members[0].labels; |
| 10147 expect(labels, hasLength(3)); | 11250 expect(labels, hasLength(3)); |
| 10148 expect(labels[0].label.inDeclarationContext(), isTrue); | 11251 expect(labels[0].label.inDeclarationContext(), isTrue); |
| 10149 expect(labels[1].label.inDeclarationContext(), isTrue); | 11252 expect(labels[1].label.inDeclarationContext(), isTrue); |
| 10150 expect(labels[2].label.inDeclarationContext(), isTrue); | 11253 expect(labels[2].label.inDeclarationContext(), isTrue); |
| 10151 } | 11254 } |
| 10152 expect(statement.rightBracket, isNotNull); | 11255 expect(statement.rightBracket, isNotNull); |
| 10153 } | 11256 } |
| 10154 | 11257 |
| 10155 void test_parseSwitchStatement_labeledStatementInCase() { | 11258 void test_parseSwitchStatement_labeledStatementInCase() { |
| 10156 SwitchStatement statement = parse4( | 11259 createParser('switch (a) {case 0: f(); l1: g(); break;}'); |
| 10157 "parseSwitchStatement", "switch (a) {case 0: f(); l1: g(); break;}"); | 11260 SwitchStatement statement = parser.parseSwitchStatement(); |
| 11261 expectNotNullIfNoErrors(statement); |
| 11262 listener.assertNoErrors(); |
| 10158 expect(statement.switchKeyword, isNotNull); | 11263 expect(statement.switchKeyword, isNotNull); |
| 10159 expect(statement.leftParenthesis, isNotNull); | 11264 expect(statement.leftParenthesis, isNotNull); |
| 10160 expect(statement.expression, isNotNull); | 11265 expect(statement.expression, isNotNull); |
| 10161 expect(statement.rightParenthesis, isNotNull); | 11266 expect(statement.rightParenthesis, isNotNull); |
| 10162 expect(statement.leftBracket, isNotNull); | 11267 expect(statement.leftBracket, isNotNull); |
| 10163 expect(statement.members, hasLength(1)); | 11268 expect(statement.members, hasLength(1)); |
| 10164 expect(statement.members[0].statements, hasLength(3)); | 11269 expect(statement.members[0].statements, hasLength(3)); |
| 10165 expect(statement.rightBracket, isNotNull); | 11270 expect(statement.rightBracket, isNotNull); |
| 10166 } | 11271 } |
| 10167 | 11272 |
| 10168 void test_parseSymbolLiteral_builtInIdentifier() { | 11273 void test_parseSymbolLiteral_builtInIdentifier() { |
| 10169 SymbolLiteral literal = | 11274 createParser('#dynamic.static.abstract'); |
| 10170 parse4("parseSymbolLiteral", "#dynamic.static.abstract"); | 11275 SymbolLiteral literal = parser.parseSymbolLiteral(); |
| 11276 expectNotNullIfNoErrors(literal); |
| 11277 listener.assertNoErrors(); |
| 10171 expect(literal.poundSign, isNotNull); | 11278 expect(literal.poundSign, isNotNull); |
| 10172 List<Token> components = literal.components; | 11279 List<Token> components = literal.components; |
| 10173 expect(components, hasLength(3)); | 11280 expect(components, hasLength(3)); |
| 10174 expect(components[0].lexeme, "dynamic"); | 11281 expect(components[0].lexeme, "dynamic"); |
| 10175 expect(components[1].lexeme, "static"); | 11282 expect(components[1].lexeme, "static"); |
| 10176 expect(components[2].lexeme, "abstract"); | 11283 expect(components[2].lexeme, "abstract"); |
| 10177 } | 11284 } |
| 10178 | 11285 |
| 10179 void test_parseSymbolLiteral_multiple() { | 11286 void test_parseSymbolLiteral_multiple() { |
| 10180 SymbolLiteral literal = parse4("parseSymbolLiteral", "#a.b.c"); | 11287 createParser('#a.b.c'); |
| 11288 SymbolLiteral literal = parser.parseSymbolLiteral(); |
| 11289 expectNotNullIfNoErrors(literal); |
| 11290 listener.assertNoErrors(); |
| 10181 expect(literal.poundSign, isNotNull); | 11291 expect(literal.poundSign, isNotNull); |
| 10182 List<Token> components = literal.components; | 11292 List<Token> components = literal.components; |
| 10183 expect(components, hasLength(3)); | 11293 expect(components, hasLength(3)); |
| 10184 expect(components[0].lexeme, "a"); | 11294 expect(components[0].lexeme, "a"); |
| 10185 expect(components[1].lexeme, "b"); | 11295 expect(components[1].lexeme, "b"); |
| 10186 expect(components[2].lexeme, "c"); | 11296 expect(components[2].lexeme, "c"); |
| 10187 } | 11297 } |
| 10188 | 11298 |
| 10189 void test_parseSymbolLiteral_operator() { | 11299 void test_parseSymbolLiteral_operator() { |
| 10190 SymbolLiteral literal = parse4("parseSymbolLiteral", "#=="); | 11300 createParser('#=='); |
| 11301 SymbolLiteral literal = parser.parseSymbolLiteral(); |
| 11302 expectNotNullIfNoErrors(literal); |
| 11303 listener.assertNoErrors(); |
| 10191 expect(literal.poundSign, isNotNull); | 11304 expect(literal.poundSign, isNotNull); |
| 10192 List<Token> components = literal.components; | 11305 List<Token> components = literal.components; |
| 10193 expect(components, hasLength(1)); | 11306 expect(components, hasLength(1)); |
| 10194 expect(components[0].lexeme, "=="); | 11307 expect(components[0].lexeme, "=="); |
| 10195 } | 11308 } |
| 10196 | 11309 |
| 10197 void test_parseSymbolLiteral_single() { | 11310 void test_parseSymbolLiteral_single() { |
| 10198 SymbolLiteral literal = parse4("parseSymbolLiteral", "#a"); | 11311 createParser('#a'); |
| 11312 SymbolLiteral literal = parser.parseSymbolLiteral(); |
| 11313 expectNotNullIfNoErrors(literal); |
| 11314 listener.assertNoErrors(); |
| 10199 expect(literal.poundSign, isNotNull); | 11315 expect(literal.poundSign, isNotNull); |
| 10200 List<Token> components = literal.components; | 11316 List<Token> components = literal.components; |
| 10201 expect(components, hasLength(1)); | 11317 expect(components, hasLength(1)); |
| 10202 expect(components[0].lexeme, "a"); | 11318 expect(components[0].lexeme, "a"); |
| 10203 } | 11319 } |
| 10204 | 11320 |
| 10205 void test_parseSymbolLiteral_void() { | 11321 void test_parseSymbolLiteral_void() { |
| 10206 SymbolLiteral literal = parse4("parseSymbolLiteral", "#void"); | 11322 createParser('#void'); |
| 11323 SymbolLiteral literal = parser.parseSymbolLiteral(); |
| 11324 expectNotNullIfNoErrors(literal); |
| 11325 listener.assertNoErrors(); |
| 10207 expect(literal.poundSign, isNotNull); | 11326 expect(literal.poundSign, isNotNull); |
| 10208 List<Token> components = literal.components; | 11327 List<Token> components = literal.components; |
| 10209 expect(components, hasLength(1)); | 11328 expect(components, hasLength(1)); |
| 10210 expect(components[0].lexeme, "void"); | 11329 expect(components[0].lexeme, "void"); |
| 10211 } | 11330 } |
| 10212 | 11331 |
| 10213 void test_parseThrowExpression() { | 11332 void test_parseThrowExpression() { |
| 10214 ThrowExpression expression = parse4("parseThrowExpression", "throw x;"); | 11333 createParser('throw x;'); |
| 10215 expect(expression.throwKeyword, isNotNull); | 11334 Expression expression = parser.parseThrowExpression(); |
| 10216 expect(expression.expression, isNotNull); | 11335 expectNotNullIfNoErrors(expression); |
| 11336 listener.assertNoErrors(); |
| 11337 expect(expression, new isInstanceOf<ThrowExpression>()); |
| 11338 ThrowExpression throwExpression = expression; |
| 11339 expect(throwExpression.throwKeyword, isNotNull); |
| 11340 expect(throwExpression.expression, isNotNull); |
| 10217 } | 11341 } |
| 10218 | 11342 |
| 10219 void test_parseThrowExpressionWithoutCascade() { | 11343 void test_parseThrowExpressionWithoutCascade() { |
| 10220 ThrowExpression expression = | 11344 createParser('throw x;'); |
| 10221 parse4("parseThrowExpressionWithoutCascade", "throw x;"); | 11345 Expression expression = parser.parseThrowExpressionWithoutCascade(); |
| 10222 expect(expression.throwKeyword, isNotNull); | 11346 expectNotNullIfNoErrors(expression); |
| 10223 expect(expression.expression, isNotNull); | 11347 listener.assertNoErrors(); |
| 11348 expect(expression, new isInstanceOf<ThrowExpression>()); |
| 11349 ThrowExpression throwExpression = expression; |
| 11350 expect(throwExpression.throwKeyword, isNotNull); |
| 11351 expect(throwExpression.expression, isNotNull); |
| 10224 } | 11352 } |
| 10225 | 11353 |
| 10226 void test_parseTryStatement_catch() { | 11354 void test_parseTryStatement_catch() { |
| 10227 TryStatement statement = parse4("parseTryStatement", "try {} catch (e) {}"); | 11355 createParser('try {} catch (e) {}'); |
| 11356 TryStatement statement = parser.parseTryStatement(); |
| 11357 expectNotNullIfNoErrors(statement); |
| 11358 listener.assertNoErrors(); |
| 10228 expect(statement.tryKeyword, isNotNull); | 11359 expect(statement.tryKeyword, isNotNull); |
| 10229 expect(statement.body, isNotNull); | 11360 expect(statement.body, isNotNull); |
| 10230 NodeList<CatchClause> catchClauses = statement.catchClauses; | 11361 NodeList<CatchClause> catchClauses = statement.catchClauses; |
| 10231 expect(catchClauses, hasLength(1)); | 11362 expect(catchClauses, hasLength(1)); |
| 10232 CatchClause clause = catchClauses[0]; | 11363 CatchClause clause = catchClauses[0]; |
| 10233 expect(clause.onKeyword, isNull); | 11364 expect(clause.onKeyword, isNull); |
| 10234 expect(clause.exceptionType, isNull); | 11365 expect(clause.exceptionType, isNull); |
| 10235 expect(clause.catchKeyword, isNotNull); | 11366 expect(clause.catchKeyword, isNotNull); |
| 10236 expect(clause.exceptionParameter, isNotNull); | 11367 expect(clause.exceptionParameter, isNotNull); |
| 10237 expect(clause.comma, isNull); | 11368 expect(clause.comma, isNull); |
| 10238 expect(clause.stackTraceParameter, isNull); | 11369 expect(clause.stackTraceParameter, isNull); |
| 10239 expect(clause.body, isNotNull); | 11370 expect(clause.body, isNotNull); |
| 10240 expect(statement.finallyKeyword, isNull); | 11371 expect(statement.finallyKeyword, isNull); |
| 10241 expect(statement.finallyBlock, isNull); | 11372 expect(statement.finallyBlock, isNull); |
| 10242 } | 11373 } |
| 10243 | 11374 |
| 10244 void test_parseTryStatement_catch_finally() { | 11375 void test_parseTryStatement_catch_finally() { |
| 10245 TryStatement statement = | 11376 createParser('try {} catch (e, s) {} finally {}'); |
| 10246 parse4("parseTryStatement", "try {} catch (e, s) {} finally {}"); | 11377 TryStatement statement = parser.parseTryStatement(); |
| 11378 expectNotNullIfNoErrors(statement); |
| 11379 listener.assertNoErrors(); |
| 10247 expect(statement.tryKeyword, isNotNull); | 11380 expect(statement.tryKeyword, isNotNull); |
| 10248 expect(statement.body, isNotNull); | 11381 expect(statement.body, isNotNull); |
| 10249 NodeList<CatchClause> catchClauses = statement.catchClauses; | 11382 NodeList<CatchClause> catchClauses = statement.catchClauses; |
| 10250 expect(catchClauses, hasLength(1)); | 11383 expect(catchClauses, hasLength(1)); |
| 10251 CatchClause clause = catchClauses[0]; | 11384 CatchClause clause = catchClauses[0]; |
| 10252 expect(clause.onKeyword, isNull); | 11385 expect(clause.onKeyword, isNull); |
| 10253 expect(clause.exceptionType, isNull); | 11386 expect(clause.exceptionType, isNull); |
| 10254 expect(clause.catchKeyword, isNotNull); | 11387 expect(clause.catchKeyword, isNotNull); |
| 10255 expect(clause.exceptionParameter, isNotNull); | 11388 expect(clause.exceptionParameter, isNotNull); |
| 10256 expect(clause.comma, isNotNull); | 11389 expect(clause.comma, isNotNull); |
| 10257 expect(clause.stackTraceParameter, isNotNull); | 11390 expect(clause.stackTraceParameter, isNotNull); |
| 10258 expect(clause.body, isNotNull); | 11391 expect(clause.body, isNotNull); |
| 10259 expect(statement.finallyKeyword, isNotNull); | 11392 expect(statement.finallyKeyword, isNotNull); |
| 10260 expect(statement.finallyBlock, isNotNull); | 11393 expect(statement.finallyBlock, isNotNull); |
| 10261 } | 11394 } |
| 10262 | 11395 |
| 10263 void test_parseTryStatement_finally() { | 11396 void test_parseTryStatement_finally() { |
| 10264 TryStatement statement = parse4("parseTryStatement", "try {} finally {}"); | 11397 createParser('try {} finally {}'); |
| 11398 TryStatement statement = parser.parseTryStatement(); |
| 11399 expectNotNullIfNoErrors(statement); |
| 11400 listener.assertNoErrors(); |
| 10265 expect(statement.tryKeyword, isNotNull); | 11401 expect(statement.tryKeyword, isNotNull); |
| 10266 expect(statement.body, isNotNull); | 11402 expect(statement.body, isNotNull); |
| 10267 expect(statement.catchClauses, hasLength(0)); | 11403 expect(statement.catchClauses, hasLength(0)); |
| 10268 expect(statement.finallyKeyword, isNotNull); | 11404 expect(statement.finallyKeyword, isNotNull); |
| 10269 expect(statement.finallyBlock, isNotNull); | 11405 expect(statement.finallyBlock, isNotNull); |
| 10270 } | 11406 } |
| 10271 | 11407 |
| 10272 void test_parseTryStatement_multiple() { | 11408 void test_parseTryStatement_multiple() { |
| 10273 TryStatement statement = parse4("parseTryStatement", | 11409 createParser('try {} on NPE catch (e) {} on Error {} catch (e) {}'); |
| 10274 "try {} on NPE catch (e) {} on Error {} catch (e) {}"); | 11410 TryStatement statement = parser.parseTryStatement(); |
| 11411 expectNotNullIfNoErrors(statement); |
| 11412 listener.assertNoErrors(); |
| 10275 expect(statement.tryKeyword, isNotNull); | 11413 expect(statement.tryKeyword, isNotNull); |
| 10276 expect(statement.body, isNotNull); | 11414 expect(statement.body, isNotNull); |
| 10277 expect(statement.catchClauses, hasLength(3)); | 11415 expect(statement.catchClauses, hasLength(3)); |
| 10278 expect(statement.finallyKeyword, isNull); | 11416 expect(statement.finallyKeyword, isNull); |
| 10279 expect(statement.finallyBlock, isNull); | 11417 expect(statement.finallyBlock, isNull); |
| 10280 } | 11418 } |
| 10281 | 11419 |
| 10282 void test_parseTryStatement_on() { | 11420 void test_parseTryStatement_on() { |
| 10283 TryStatement statement = parse4("parseTryStatement", "try {} on Error {}"); | 11421 createParser('try {} on Error {}'); |
| 11422 TryStatement statement = parser.parseTryStatement(); |
| 11423 expectNotNullIfNoErrors(statement); |
| 11424 listener.assertNoErrors(); |
| 10284 expect(statement.tryKeyword, isNotNull); | 11425 expect(statement.tryKeyword, isNotNull); |
| 10285 expect(statement.body, isNotNull); | 11426 expect(statement.body, isNotNull); |
| 10286 NodeList<CatchClause> catchClauses = statement.catchClauses; | 11427 NodeList<CatchClause> catchClauses = statement.catchClauses; |
| 10287 expect(catchClauses, hasLength(1)); | 11428 expect(catchClauses, hasLength(1)); |
| 10288 CatchClause clause = catchClauses[0]; | 11429 CatchClause clause = catchClauses[0]; |
| 10289 expect(clause.onKeyword, isNotNull); | 11430 expect(clause.onKeyword, isNotNull); |
| 10290 expect(clause.exceptionType, isNotNull); | 11431 expect(clause.exceptionType, isNotNull); |
| 10291 expect(clause.catchKeyword, isNull); | 11432 expect(clause.catchKeyword, isNull); |
| 10292 expect(clause.exceptionParameter, isNull); | 11433 expect(clause.exceptionParameter, isNull); |
| 10293 expect(clause.comma, isNull); | 11434 expect(clause.comma, isNull); |
| 10294 expect(clause.stackTraceParameter, isNull); | 11435 expect(clause.stackTraceParameter, isNull); |
| 10295 expect(clause.body, isNotNull); | 11436 expect(clause.body, isNotNull); |
| 10296 expect(statement.finallyKeyword, isNull); | 11437 expect(statement.finallyKeyword, isNull); |
| 10297 expect(statement.finallyBlock, isNull); | 11438 expect(statement.finallyBlock, isNull); |
| 10298 } | 11439 } |
| 10299 | 11440 |
| 10300 void test_parseTryStatement_on_catch() { | 11441 void test_parseTryStatement_on_catch() { |
| 10301 TryStatement statement = | 11442 createParser('try {} on Error catch (e, s) {}'); |
| 10302 parse4("parseTryStatement", "try {} on Error catch (e, s) {}"); | 11443 TryStatement statement = parser.parseTryStatement(); |
| 11444 expectNotNullIfNoErrors(statement); |
| 11445 listener.assertNoErrors(); |
| 10303 expect(statement.tryKeyword, isNotNull); | 11446 expect(statement.tryKeyword, isNotNull); |
| 10304 expect(statement.body, isNotNull); | 11447 expect(statement.body, isNotNull); |
| 10305 NodeList<CatchClause> catchClauses = statement.catchClauses; | 11448 NodeList<CatchClause> catchClauses = statement.catchClauses; |
| 10306 expect(catchClauses, hasLength(1)); | 11449 expect(catchClauses, hasLength(1)); |
| 10307 CatchClause clause = catchClauses[0]; | 11450 CatchClause clause = catchClauses[0]; |
| 10308 expect(clause.onKeyword, isNotNull); | 11451 expect(clause.onKeyword, isNotNull); |
| 10309 expect(clause.exceptionType, isNotNull); | 11452 expect(clause.exceptionType, isNotNull); |
| 10310 expect(clause.catchKeyword, isNotNull); | 11453 expect(clause.catchKeyword, isNotNull); |
| 10311 expect(clause.exceptionParameter, isNotNull); | 11454 expect(clause.exceptionParameter, isNotNull); |
| 10312 expect(clause.comma, isNotNull); | 11455 expect(clause.comma, isNotNull); |
| 10313 expect(clause.stackTraceParameter, isNotNull); | 11456 expect(clause.stackTraceParameter, isNotNull); |
| 10314 expect(clause.body, isNotNull); | 11457 expect(clause.body, isNotNull); |
| 10315 expect(statement.finallyKeyword, isNull); | 11458 expect(statement.finallyKeyword, isNull); |
| 10316 expect(statement.finallyBlock, isNull); | 11459 expect(statement.finallyBlock, isNull); |
| 10317 } | 11460 } |
| 10318 | 11461 |
| 10319 void test_parseTryStatement_on_catch_finally() { | 11462 void test_parseTryStatement_on_catch_finally() { |
| 10320 TryStatement statement = parse4( | 11463 createParser('try {} on Error catch (e, s) {} finally {}'); |
| 10321 "parseTryStatement", "try {} on Error catch (e, s) {} finally {}"); | 11464 TryStatement statement = parser.parseTryStatement(); |
| 11465 expectNotNullIfNoErrors(statement); |
| 11466 listener.assertNoErrors(); |
| 10322 expect(statement.tryKeyword, isNotNull); | 11467 expect(statement.tryKeyword, isNotNull); |
| 10323 expect(statement.body, isNotNull); | 11468 expect(statement.body, isNotNull); |
| 10324 NodeList<CatchClause> catchClauses = statement.catchClauses; | 11469 NodeList<CatchClause> catchClauses = statement.catchClauses; |
| 10325 expect(catchClauses, hasLength(1)); | 11470 expect(catchClauses, hasLength(1)); |
| 10326 CatchClause clause = catchClauses[0]; | 11471 CatchClause clause = catchClauses[0]; |
| 10327 expect(clause.onKeyword, isNotNull); | 11472 expect(clause.onKeyword, isNotNull); |
| 10328 expect(clause.exceptionType, isNotNull); | 11473 expect(clause.exceptionType, isNotNull); |
| 10329 expect(clause.catchKeyword, isNotNull); | 11474 expect(clause.catchKeyword, isNotNull); |
| 10330 expect(clause.exceptionParameter, isNotNull); | 11475 expect(clause.exceptionParameter, isNotNull); |
| 10331 expect(clause.comma, isNotNull); | 11476 expect(clause.comma, isNotNull); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10395 <Object>[emptyCommentAndMetadata()], "typedef void F();"); | 11540 <Object>[emptyCommentAndMetadata()], "typedef void F();"); |
| 10396 expect(typeAlias.typedefKeyword, isNotNull); | 11541 expect(typeAlias.typedefKeyword, isNotNull); |
| 10397 expect(typeAlias.name, isNotNull); | 11542 expect(typeAlias.name, isNotNull); |
| 10398 expect(typeAlias.parameters, isNotNull); | 11543 expect(typeAlias.parameters, isNotNull); |
| 10399 expect(typeAlias.returnType, isNotNull); | 11544 expect(typeAlias.returnType, isNotNull); |
| 10400 expect(typeAlias.semicolon, isNotNull); | 11545 expect(typeAlias.semicolon, isNotNull); |
| 10401 expect(typeAlias.typeParameters, isNull); | 11546 expect(typeAlias.typeParameters, isNull); |
| 10402 } | 11547 } |
| 10403 | 11548 |
| 10404 void test_parseTypeArgumentList_empty() { | 11549 void test_parseTypeArgumentList_empty() { |
| 10405 TypeArgumentList argumentList = parse4( | 11550 createParser('<>'); |
| 10406 "parseTypeArgumentList", "<>", [ParserErrorCode.EXPECTED_TYPE_NAME]); | 11551 TypeArgumentList argumentList = parser.parseTypeArgumentList(); |
| 11552 expectNotNullIfNoErrors(argumentList); |
| 11553 listener.assertErrorsWithCodes([ParserErrorCode.EXPECTED_TYPE_NAME]); |
| 10407 expect(argumentList.leftBracket, isNotNull); | 11554 expect(argumentList.leftBracket, isNotNull); |
| 10408 expect(argumentList.arguments, hasLength(1)); | 11555 expect(argumentList.arguments, hasLength(1)); |
| 10409 expect(argumentList.rightBracket, isNotNull); | 11556 expect(argumentList.rightBracket, isNotNull); |
| 10410 } | 11557 } |
| 10411 | 11558 |
| 10412 void test_parseTypeArgumentList_multiple() { | 11559 void test_parseTypeArgumentList_multiple() { |
| 10413 TypeArgumentList argumentList = | 11560 createParser('<int, int, int>'); |
| 10414 parse4("parseTypeArgumentList", "<int, int, int>"); | 11561 TypeArgumentList argumentList = parser.parseTypeArgumentList(); |
| 11562 expectNotNullIfNoErrors(argumentList); |
| 11563 listener.assertNoErrors(); |
| 10415 expect(argumentList.leftBracket, isNotNull); | 11564 expect(argumentList.leftBracket, isNotNull); |
| 10416 expect(argumentList.arguments, hasLength(3)); | 11565 expect(argumentList.arguments, hasLength(3)); |
| 10417 expect(argumentList.rightBracket, isNotNull); | 11566 expect(argumentList.rightBracket, isNotNull); |
| 10418 } | 11567 } |
| 10419 | 11568 |
| 10420 void test_parseTypeArgumentList_nested() { | 11569 void test_parseTypeArgumentList_nested() { |
| 10421 TypeArgumentList argumentList = parse4("parseTypeArgumentList", "<A<B>>"); | 11570 createParser('<A<B>>'); |
| 11571 TypeArgumentList argumentList = parser.parseTypeArgumentList(); |
| 11572 expectNotNullIfNoErrors(argumentList); |
| 11573 listener.assertNoErrors(); |
| 10422 expect(argumentList.leftBracket, isNotNull); | 11574 expect(argumentList.leftBracket, isNotNull); |
| 10423 expect(argumentList.arguments, hasLength(1)); | 11575 expect(argumentList.arguments, hasLength(1)); |
| 10424 TypeName argument = argumentList.arguments[0]; | 11576 TypeName argument = argumentList.arguments[0]; |
| 10425 expect(argument, isNotNull); | 11577 expect(argument, isNotNull); |
| 10426 TypeArgumentList innerList = argument.typeArguments; | 11578 TypeArgumentList innerList = argument.typeArguments; |
| 10427 expect(innerList, isNotNull); | 11579 expect(innerList, isNotNull); |
| 10428 expect(innerList.arguments, hasLength(1)); | 11580 expect(innerList.arguments, hasLength(1)); |
| 10429 expect(argumentList.rightBracket, isNotNull); | 11581 expect(argumentList.rightBracket, isNotNull); |
| 10430 } | 11582 } |
| 10431 | 11583 |
| 10432 void test_parseTypeArgumentList_nested_withComment_double() { | 11584 void test_parseTypeArgumentList_nested_withComment_double() { |
| 10433 TypeArgumentList argumentList = | 11585 createParser('<A<B /* 0 */ >>'); |
| 10434 parse4("parseTypeArgumentList", "<A<B /* 0 */ >>"); | 11586 TypeArgumentList argumentList = parser.parseTypeArgumentList(); |
| 11587 expectNotNullIfNoErrors(argumentList); |
| 11588 listener.assertNoErrors(); |
| 10435 expect(argumentList.leftBracket, isNotNull); | 11589 expect(argumentList.leftBracket, isNotNull); |
| 10436 expect(argumentList.rightBracket, isNotNull); | 11590 expect(argumentList.rightBracket, isNotNull); |
| 10437 expect(argumentList.arguments, hasLength(1)); | 11591 expect(argumentList.arguments, hasLength(1)); |
| 10438 | 11592 |
| 10439 TypeName argument = argumentList.arguments[0]; | 11593 TypeName argument = argumentList.arguments[0]; |
| 10440 expect(argument, isNotNull); | 11594 expect(argument, isNotNull); |
| 10441 | 11595 |
| 10442 TypeArgumentList innerList = argument.typeArguments; | 11596 TypeArgumentList innerList = argument.typeArguments; |
| 10443 expect(innerList, isNotNull); | 11597 expect(innerList, isNotNull); |
| 10444 expect(innerList.leftBracket, isNotNull); | 11598 expect(innerList.leftBracket, isNotNull); |
| 10445 expect(innerList.arguments, hasLength(1)); | 11599 expect(innerList.arguments, hasLength(1)); |
| 10446 expect(innerList.rightBracket, isNotNull); | 11600 expect(innerList.rightBracket, isNotNull); |
| 10447 expect(innerList.rightBracket.precedingComments, isNotNull); | 11601 expect(innerList.rightBracket.precedingComments, isNotNull); |
| 10448 } | 11602 } |
| 10449 | 11603 |
| 10450 void test_parseTypeArgumentList_nested_withComment_tripple() { | 11604 void test_parseTypeArgumentList_nested_withComment_tripple() { |
| 10451 TypeArgumentList argumentList = | 11605 createParser('<A<B<C /* 0 */ >>>'); |
| 10452 parse4("parseTypeArgumentList", "<A<B<C /* 0 */ >>>"); | 11606 TypeArgumentList argumentList = parser.parseTypeArgumentList(); |
| 11607 expectNotNullIfNoErrors(argumentList); |
| 11608 listener.assertNoErrors(); |
| 10453 expect(argumentList.leftBracket, isNotNull); | 11609 expect(argumentList.leftBracket, isNotNull); |
| 10454 expect(argumentList.rightBracket, isNotNull); | 11610 expect(argumentList.rightBracket, isNotNull); |
| 10455 expect(argumentList.arguments, hasLength(1)); | 11611 expect(argumentList.arguments, hasLength(1)); |
| 10456 | 11612 |
| 10457 TypeName argument = argumentList.arguments[0]; | 11613 TypeName argument = argumentList.arguments[0]; |
| 10458 expect(argument, isNotNull); | 11614 expect(argument, isNotNull); |
| 10459 | 11615 |
| 10460 TypeArgumentList innerList = argument.typeArguments; | 11616 TypeArgumentList innerList = argument.typeArguments; |
| 10461 expect(innerList, isNotNull); | 11617 expect(innerList, isNotNull); |
| 10462 expect(innerList.leftBracket, isNotNull); | 11618 expect(innerList.leftBracket, isNotNull); |
| 10463 expect(innerList.arguments, hasLength(1)); | 11619 expect(innerList.arguments, hasLength(1)); |
| 10464 expect(innerList.rightBracket, isNotNull); | 11620 expect(innerList.rightBracket, isNotNull); |
| 10465 | 11621 |
| 10466 TypeName innerArgument = innerList.arguments[0]; | 11622 TypeName innerArgument = innerList.arguments[0]; |
| 10467 expect(innerArgument, isNotNull); | 11623 expect(innerArgument, isNotNull); |
| 10468 | 11624 |
| 10469 TypeArgumentList innerInnerList = innerArgument.typeArguments; | 11625 TypeArgumentList innerInnerList = innerArgument.typeArguments; |
| 10470 expect(innerInnerList, isNotNull); | 11626 expect(innerInnerList, isNotNull); |
| 10471 expect(innerInnerList.leftBracket, isNotNull); | 11627 expect(innerInnerList.leftBracket, isNotNull); |
| 10472 expect(innerInnerList.arguments, hasLength(1)); | 11628 expect(innerInnerList.arguments, hasLength(1)); |
| 10473 expect(innerInnerList.rightBracket, isNotNull); | 11629 expect(innerInnerList.rightBracket, isNotNull); |
| 10474 expect(innerInnerList.rightBracket.precedingComments, isNotNull); | 11630 expect(innerInnerList.rightBracket.precedingComments, isNotNull); |
| 10475 } | 11631 } |
| 10476 | 11632 |
| 10477 void test_parseTypeArgumentList_single() { | 11633 void test_parseTypeArgumentList_single() { |
| 10478 TypeArgumentList argumentList = parse4("parseTypeArgumentList", "<int>"); | 11634 createParser('<int>'); |
| 11635 TypeArgumentList argumentList = parser.parseTypeArgumentList(); |
| 11636 expectNotNullIfNoErrors(argumentList); |
| 11637 listener.assertNoErrors(); |
| 10479 expect(argumentList.leftBracket, isNotNull); | 11638 expect(argumentList.leftBracket, isNotNull); |
| 10480 expect(argumentList.arguments, hasLength(1)); | 11639 expect(argumentList.arguments, hasLength(1)); |
| 10481 expect(argumentList.rightBracket, isNotNull); | 11640 expect(argumentList.rightBracket, isNotNull); |
| 10482 } | 11641 } |
| 10483 | 11642 |
| 10484 void test_parseTypeName_parameterized() { | 11643 void test_parseTypeName_parameterized() { |
| 10485 TypeName typeName = parse4("parseTypeName", "List<int>"); | 11644 createParser('List<int>'); |
| 11645 TypeName typeName = parser.parseTypeName(false); |
| 11646 expectNotNullIfNoErrors(typeName); |
| 11647 listener.assertNoErrors(); |
| 10486 expect(typeName.name, isNotNull); | 11648 expect(typeName.name, isNotNull); |
| 10487 expect(typeName.typeArguments, isNotNull); | 11649 expect(typeName.typeArguments, isNotNull); |
| 10488 expect(typeName.question, isNull); | 11650 expect(typeName.question, isNull); |
| 10489 } | 11651 } |
| 10490 | 11652 |
| 10491 void test_parseTypeName_parameterized_nullable() { | 11653 void test_parseTypeName_parameterized_nullable() { |
| 10492 enableNnbd = true; | 11654 enableNnbd = true; |
| 10493 TypeName typeName = parse4("parseTypeName", "List<int>?"); | 11655 createParser('List<int>?'); |
| 11656 TypeName typeName = parser.parseTypeName(false); |
| 11657 expectNotNullIfNoErrors(typeName); |
| 11658 listener.assertNoErrors(); |
| 10494 expect(typeName.name, isNotNull); | 11659 expect(typeName.name, isNotNull); |
| 10495 expect(typeName.typeArguments, isNotNull); | 11660 expect(typeName.typeArguments, isNotNull); |
| 10496 expect(typeName.question, isNotNull); | 11661 expect(typeName.question, isNotNull); |
| 10497 } | 11662 } |
| 10498 | 11663 |
| 10499 void test_parseTypeName_simple() { | 11664 void test_parseTypeName_simple() { |
| 10500 TypeName typeName = parse4("parseTypeName", "int"); | 11665 createParser('int'); |
| 11666 TypeName typeName = parser.parseTypeName(false); |
| 11667 expectNotNullIfNoErrors(typeName); |
| 11668 listener.assertNoErrors(); |
| 10501 expect(typeName.name, isNotNull); | 11669 expect(typeName.name, isNotNull); |
| 10502 expect(typeName.typeArguments, isNull); | 11670 expect(typeName.typeArguments, isNull); |
| 10503 expect(typeName.question, isNull); | 11671 expect(typeName.question, isNull); |
| 10504 } | 11672 } |
| 10505 | 11673 |
| 10506 void test_parseTypeName_simple_nullable() { | 11674 void test_parseTypeName_simple_nullable() { |
| 10507 enableNnbd = true; | 11675 enableNnbd = true; |
| 10508 TypeName typeName = parse4("parseTypeName", "String?"); | 11676 createParser('String?'); |
| 11677 TypeName typeName = parser.parseTypeName(false); |
| 11678 expectNotNullIfNoErrors(typeName); |
| 11679 listener.assertNoErrors(); |
| 10509 expect(typeName.name, isNotNull); | 11680 expect(typeName.name, isNotNull); |
| 10510 expect(typeName.typeArguments, isNull); | 11681 expect(typeName.typeArguments, isNull); |
| 10511 expect(typeName.question, isNotNull); | 11682 expect(typeName.question, isNotNull); |
| 10512 } | 11683 } |
| 10513 | 11684 |
| 10514 void test_parseTypeParameter_bounded() { | 11685 void test_parseTypeParameter_bounded() { |
| 10515 TypeParameter parameter = parse4("parseTypeParameter", "A extends B"); | 11686 createParser('A extends B'); |
| 11687 TypeParameter parameter = parser.parseTypeParameter(); |
| 11688 expectNotNullIfNoErrors(parameter); |
| 11689 listener.assertNoErrors(); |
| 10516 expect(parameter.bound, isNotNull); | 11690 expect(parameter.bound, isNotNull); |
| 10517 expect(parameter.extendsKeyword, isNotNull); | 11691 expect(parameter.extendsKeyword, isNotNull); |
| 10518 expect(parameter.name, isNotNull); | 11692 expect(parameter.name, isNotNull); |
| 10519 } | 11693 } |
| 10520 | 11694 |
| 10521 void test_parseTypeParameter_simple() { | 11695 void test_parseTypeParameter_simple() { |
| 10522 TypeParameter parameter = parse4("parseTypeParameter", "A"); | 11696 createParser('A'); |
| 11697 TypeParameter parameter = parser.parseTypeParameter(); |
| 11698 expectNotNullIfNoErrors(parameter); |
| 11699 listener.assertNoErrors(); |
| 10523 expect(parameter.bound, isNull); | 11700 expect(parameter.bound, isNull); |
| 10524 expect(parameter.extendsKeyword, isNull); | 11701 expect(parameter.extendsKeyword, isNull); |
| 10525 expect(parameter.name, isNotNull); | 11702 expect(parameter.name, isNotNull); |
| 10526 } | 11703 } |
| 10527 | 11704 |
| 10528 void test_parseTypeParameterList_multiple() { | 11705 void test_parseTypeParameterList_multiple() { |
| 10529 TypeParameterList parameterList = | 11706 createParser('<A, B extends C, D>'); |
| 10530 parse4("parseTypeParameterList", "<A, B extends C, D>"); | 11707 TypeParameterList parameterList = parser.parseTypeParameterList(); |
| 11708 expectNotNullIfNoErrors(parameterList); |
| 11709 listener.assertNoErrors(); |
| 10531 expect(parameterList.leftBracket, isNotNull); | 11710 expect(parameterList.leftBracket, isNotNull); |
| 10532 expect(parameterList.rightBracket, isNotNull); | 11711 expect(parameterList.rightBracket, isNotNull); |
| 10533 expect(parameterList.typeParameters, hasLength(3)); | 11712 expect(parameterList.typeParameters, hasLength(3)); |
| 10534 } | 11713 } |
| 10535 | 11714 |
| 10536 void test_parseTypeParameterList_parameterizedWithTrailingEquals() { | 11715 void test_parseTypeParameterList_parameterizedWithTrailingEquals() { |
| 10537 TypeParameterList parameterList = | 11716 createParser('<A extends B<E>>='); |
| 10538 parse4("parseTypeParameterList", "<A extends B<E>>="); | 11717 TypeParameterList parameterList = parser.parseTypeParameterList(); |
| 11718 expectNotNullIfNoErrors(parameterList); |
| 11719 listener.assertNoErrors(); |
| 10539 expect(parameterList.leftBracket, isNotNull); | 11720 expect(parameterList.leftBracket, isNotNull); |
| 10540 expect(parameterList.rightBracket, isNotNull); | 11721 expect(parameterList.rightBracket, isNotNull); |
| 10541 expect(parameterList.typeParameters, hasLength(1)); | 11722 expect(parameterList.typeParameters, hasLength(1)); |
| 10542 } | 11723 } |
| 10543 | 11724 |
| 10544 void test_parseTypeParameterList_single() { | 11725 void test_parseTypeParameterList_single() { |
| 10545 TypeParameterList parameterList = parse4("parseTypeParameterList", "<A>"); | 11726 createParser('<<A>'); |
| 11727 TypeParameterList parameterList = parser.parseTypeParameterList(); |
| 11728 expectNotNullIfNoErrors(parameterList); |
| 11729 listener.assertNoErrors(); |
| 10546 expect(parameterList.leftBracket, isNotNull); | 11730 expect(parameterList.leftBracket, isNotNull); |
| 10547 expect(parameterList.rightBracket, isNotNull); | 11731 expect(parameterList.rightBracket, isNotNull); |
| 10548 expect(parameterList.typeParameters, hasLength(1)); | 11732 expect(parameterList.typeParameters, hasLength(1)); |
| 10549 } | 11733 } |
| 10550 | 11734 |
| 10551 void test_parseTypeParameterList_withTrailingEquals() { | 11735 void test_parseTypeParameterList_withTrailingEquals() { |
| 10552 TypeParameterList parameterList = parse4("parseTypeParameterList", "<A>="); | 11736 createParser('<A>='); |
| 11737 TypeParameterList parameterList = parser.parseTypeParameterList(); |
| 11738 expectNotNullIfNoErrors(parameterList); |
| 11739 listener.assertNoErrors(); |
| 10553 expect(parameterList.leftBracket, isNotNull); | 11740 expect(parameterList.leftBracket, isNotNull); |
| 10554 expect(parameterList.rightBracket, isNotNull); | 11741 expect(parameterList.rightBracket, isNotNull); |
| 10555 expect(parameterList.typeParameters, hasLength(1)); | 11742 expect(parameterList.typeParameters, hasLength(1)); |
| 10556 } | 11743 } |
| 10557 | 11744 |
| 10558 void test_parseUnaryExpression_decrement_normal() { | 11745 void test_parseUnaryExpression_decrement_normal() { |
| 10559 PrefixExpression expression = parse4("parseUnaryExpression", "--x"); | 11746 createParser('--x'); |
| 11747 PrefixExpression expression = parser.parseUnaryExpression(); |
| 11748 expectNotNullIfNoErrors(expression); |
| 11749 listener.assertNoErrors(); |
| 10560 expect(expression.operator, isNotNull); | 11750 expect(expression.operator, isNotNull); |
| 10561 expect(expression.operator.type, TokenType.MINUS_MINUS); | 11751 expect(expression.operator.type, TokenType.MINUS_MINUS); |
| 10562 expect(expression.operand, isNotNull); | 11752 expect(expression.operand, isNotNull); |
| 10563 } | 11753 } |
| 10564 | 11754 |
| 10565 void test_parseUnaryExpression_decrement_super() { | 11755 void test_parseUnaryExpression_decrement_super() { |
| 10566 PrefixExpression expression = parse4("parseUnaryExpression", "--super"); | 11756 createParser('--super'); |
| 11757 PrefixExpression expression = parser.parseUnaryExpression(); |
| 11758 expectNotNullIfNoErrors(expression); |
| 11759 listener.assertNoErrors(); |
| 10567 expect(expression.operator, isNotNull); | 11760 expect(expression.operator, isNotNull); |
| 10568 expect(expression.operator.type, TokenType.MINUS); | 11761 expect(expression.operator.type, TokenType.MINUS); |
| 10569 Expression innerExpression = expression.operand; | 11762 Expression innerExpression = expression.operand; |
| 10570 expect(innerExpression, isNotNull); | 11763 expect(innerExpression, isNotNull); |
| 10571 expect(innerExpression is PrefixExpression, isTrue); | 11764 expect(innerExpression is PrefixExpression, isTrue); |
| 10572 PrefixExpression operand = innerExpression as PrefixExpression; | 11765 PrefixExpression operand = innerExpression as PrefixExpression; |
| 10573 expect(operand.operator, isNotNull); | 11766 expect(operand.operator, isNotNull); |
| 10574 expect(operand.operator.type, TokenType.MINUS); | 11767 expect(operand.operator.type, TokenType.MINUS); |
| 10575 expect(operand.operand, isNotNull); | 11768 expect(operand.operand, isNotNull); |
| 10576 } | 11769 } |
| 10577 | 11770 |
| 10578 void test_parseUnaryExpression_decrement_super_propertyAccess() { | 11771 void test_parseUnaryExpression_decrement_super_propertyAccess() { |
| 10579 PrefixExpression expression = parse4("parseUnaryExpression", "--super.x"); | 11772 createParser('--super.x'); |
| 11773 PrefixExpression expression = parser.parseUnaryExpression(); |
| 11774 expectNotNullIfNoErrors(expression); |
| 11775 listener.assertNoErrors(); |
| 10580 expect(expression.operator, isNotNull); | 11776 expect(expression.operator, isNotNull); |
| 10581 expect(expression.operator.type, TokenType.MINUS_MINUS); | 11777 expect(expression.operator.type, TokenType.MINUS_MINUS); |
| 10582 expect(expression.operand, isNotNull); | 11778 expect(expression.operand, isNotNull); |
| 10583 PropertyAccess operand = expression.operand as PropertyAccess; | 11779 PropertyAccess operand = expression.operand as PropertyAccess; |
| 10584 expect(operand.target is SuperExpression, isTrue); | 11780 expect(operand.target is SuperExpression, isTrue); |
| 10585 expect(operand.propertyName.name, "x"); | 11781 expect(operand.propertyName.name, "x"); |
| 10586 } | 11782 } |
| 10587 | 11783 |
| 10588 void test_parseUnaryExpression_decrement_super_withComment() { | 11784 void test_parseUnaryExpression_decrement_super_withComment() { |
| 10589 PrefixExpression expression = | 11785 createParser('/* 0 */ --super'); |
| 10590 parse4("parseUnaryExpression", "/* 0 */ --super"); | 11786 PrefixExpression expression = parser.parseUnaryExpression(); |
| 11787 expectNotNullIfNoErrors(expression); |
| 11788 listener.assertNoErrors(); |
| 10591 expect(expression.operator, isNotNull); | 11789 expect(expression.operator, isNotNull); |
| 10592 expect(expression.operator.type, TokenType.MINUS); | 11790 expect(expression.operator.type, TokenType.MINUS); |
| 10593 expect(expression.operator.precedingComments, isNotNull); | 11791 expect(expression.operator.precedingComments, isNotNull); |
| 10594 Expression innerExpression = expression.operand; | 11792 Expression innerExpression = expression.operand; |
| 10595 expect(innerExpression, isNotNull); | 11793 expect(innerExpression, isNotNull); |
| 10596 expect(innerExpression is PrefixExpression, isTrue); | 11794 expect(innerExpression is PrefixExpression, isTrue); |
| 10597 PrefixExpression operand = innerExpression as PrefixExpression; | 11795 PrefixExpression operand = innerExpression as PrefixExpression; |
| 10598 expect(operand.operator, isNotNull); | 11796 expect(operand.operator, isNotNull); |
| 10599 expect(operand.operator.type, TokenType.MINUS); | 11797 expect(operand.operator.type, TokenType.MINUS); |
| 10600 expect(operand.operand, isNotNull); | 11798 expect(operand.operand, isNotNull); |
| 10601 } | 11799 } |
| 10602 | 11800 |
| 10603 void test_parseUnaryExpression_increment_normal() { | 11801 void test_parseUnaryExpression_increment_normal() { |
| 10604 PrefixExpression expression = parse4("parseUnaryExpression", "++x"); | 11802 createParser('++x'); |
| 11803 PrefixExpression expression = parser.parseUnaryExpression(); |
| 11804 expectNotNullIfNoErrors(expression); |
| 11805 listener.assertNoErrors(); |
| 10605 expect(expression.operator, isNotNull); | 11806 expect(expression.operator, isNotNull); |
| 10606 expect(expression.operator.type, TokenType.PLUS_PLUS); | 11807 expect(expression.operator.type, TokenType.PLUS_PLUS); |
| 10607 expect(expression.operand, isNotNull); | 11808 expect(expression.operand, isNotNull); |
| 10608 } | 11809 } |
| 10609 | 11810 |
| 10610 void test_parseUnaryExpression_increment_super_index() { | 11811 void test_parseUnaryExpression_increment_super_index() { |
| 10611 PrefixExpression expression = parse4("parseUnaryExpression", "++super[0]"); | 11812 createParser('++super[0]'); |
| 11813 PrefixExpression expression = parser.parseUnaryExpression(); |
| 11814 expectNotNullIfNoErrors(expression); |
| 11815 listener.assertNoErrors(); |
| 10612 expect(expression.operator, isNotNull); | 11816 expect(expression.operator, isNotNull); |
| 10613 expect(expression.operator.type, TokenType.PLUS_PLUS); | 11817 expect(expression.operator.type, TokenType.PLUS_PLUS); |
| 10614 expect(expression.operand, isNotNull); | 11818 expect(expression.operand, isNotNull); |
| 10615 IndexExpression operand = expression.operand as IndexExpression; | 11819 IndexExpression operand = expression.operand as IndexExpression; |
| 10616 expect(operand.realTarget is SuperExpression, isTrue); | 11820 expect(operand.realTarget is SuperExpression, isTrue); |
| 10617 expect(operand.index is IntegerLiteral, isTrue); | 11821 expect(operand.index is IntegerLiteral, isTrue); |
| 10618 } | 11822 } |
| 10619 | 11823 |
| 10620 void test_parseUnaryExpression_increment_super_propertyAccess() { | 11824 void test_parseUnaryExpression_increment_super_propertyAccess() { |
| 10621 PrefixExpression expression = parse4("parseUnaryExpression", "++super.x"); | 11825 createParser('++super.x'); |
| 11826 PrefixExpression expression = parser.parseUnaryExpression(); |
| 11827 expectNotNullIfNoErrors(expression); |
| 11828 listener.assertNoErrors(); |
| 10622 expect(expression.operator, isNotNull); | 11829 expect(expression.operator, isNotNull); |
| 10623 expect(expression.operator.type, TokenType.PLUS_PLUS); | 11830 expect(expression.operator.type, TokenType.PLUS_PLUS); |
| 10624 expect(expression.operand, isNotNull); | 11831 expect(expression.operand, isNotNull); |
| 10625 PropertyAccess operand = expression.operand as PropertyAccess; | 11832 PropertyAccess operand = expression.operand as PropertyAccess; |
| 10626 expect(operand.target is SuperExpression, isTrue); | 11833 expect(operand.target is SuperExpression, isTrue); |
| 10627 expect(operand.propertyName.name, "x"); | 11834 expect(operand.propertyName.name, "x"); |
| 10628 } | 11835 } |
| 10629 | 11836 |
| 10630 void test_parseUnaryExpression_minus_normal() { | 11837 void test_parseUnaryExpression_minus_normal() { |
| 10631 PrefixExpression expression = parse4("parseUnaryExpression", "-x"); | 11838 createParser('-x'); |
| 11839 PrefixExpression expression = parser.parseUnaryExpression(); |
| 11840 expectNotNullIfNoErrors(expression); |
| 11841 listener.assertNoErrors(); |
| 10632 expect(expression.operator, isNotNull); | 11842 expect(expression.operator, isNotNull); |
| 10633 expect(expression.operator.type, TokenType.MINUS); | 11843 expect(expression.operator.type, TokenType.MINUS); |
| 10634 expect(expression.operand, isNotNull); | 11844 expect(expression.operand, isNotNull); |
| 10635 } | 11845 } |
| 10636 | 11846 |
| 10637 void test_parseUnaryExpression_minus_super() { | 11847 void test_parseUnaryExpression_minus_super() { |
| 10638 PrefixExpression expression = parse4("parseUnaryExpression", "-super"); | 11848 createParser('-super'); |
| 11849 PrefixExpression expression = parser.parseUnaryExpression(); |
| 11850 expectNotNullIfNoErrors(expression); |
| 11851 listener.assertNoErrors(); |
| 10639 expect(expression.operator, isNotNull); | 11852 expect(expression.operator, isNotNull); |
| 10640 expect(expression.operator.type, TokenType.MINUS); | 11853 expect(expression.operator.type, TokenType.MINUS); |
| 10641 expect(expression.operand, isNotNull); | 11854 expect(expression.operand, isNotNull); |
| 10642 } | 11855 } |
| 10643 | 11856 |
| 10644 void test_parseUnaryExpression_not_normal() { | 11857 void test_parseUnaryExpression_not_normal() { |
| 10645 PrefixExpression expression = parse4("parseUnaryExpression", "!x"); | 11858 createParser('!x'); |
| 11859 PrefixExpression expression = parser.parseUnaryExpression(); |
| 11860 expectNotNullIfNoErrors(expression); |
| 11861 listener.assertNoErrors(); |
| 10646 expect(expression.operator, isNotNull); | 11862 expect(expression.operator, isNotNull); |
| 10647 expect(expression.operator.type, TokenType.BANG); | 11863 expect(expression.operator.type, TokenType.BANG); |
| 10648 expect(expression.operand, isNotNull); | 11864 expect(expression.operand, isNotNull); |
| 10649 } | 11865 } |
| 10650 | 11866 |
| 10651 void test_parseUnaryExpression_not_super() { | 11867 void test_parseUnaryExpression_not_super() { |
| 10652 PrefixExpression expression = parse4("parseUnaryExpression", "!super"); | 11868 createParser('!super'); |
| 11869 PrefixExpression expression = parser.parseUnaryExpression(); |
| 11870 expectNotNullIfNoErrors(expression); |
| 11871 listener.assertNoErrors(); |
| 10653 expect(expression.operator, isNotNull); | 11872 expect(expression.operator, isNotNull); |
| 10654 expect(expression.operator.type, TokenType.BANG); | 11873 expect(expression.operator.type, TokenType.BANG); |
| 10655 expect(expression.operand, isNotNull); | 11874 expect(expression.operand, isNotNull); |
| 10656 } | 11875 } |
| 10657 | 11876 |
| 10658 void test_parseUnaryExpression_tilda_normal() { | 11877 void test_parseUnaryExpression_tilda_normal() { |
| 10659 PrefixExpression expression = parse4("parseUnaryExpression", "~x"); | 11878 createParser('~x'); |
| 11879 PrefixExpression expression = parser.parseUnaryExpression(); |
| 11880 expectNotNullIfNoErrors(expression); |
| 11881 listener.assertNoErrors(); |
| 10660 expect(expression.operator, isNotNull); | 11882 expect(expression.operator, isNotNull); |
| 10661 expect(expression.operator.type, TokenType.TILDE); | 11883 expect(expression.operator.type, TokenType.TILDE); |
| 10662 expect(expression.operand, isNotNull); | 11884 expect(expression.operand, isNotNull); |
| 10663 } | 11885 } |
| 10664 | 11886 |
| 10665 void test_parseUnaryExpression_tilda_super() { | 11887 void test_parseUnaryExpression_tilda_super() { |
| 10666 PrefixExpression expression = parse4("parseUnaryExpression", "~super"); | 11888 createParser('~super'); |
| 11889 PrefixExpression expression = parser.parseUnaryExpression(); |
| 11890 expectNotNullIfNoErrors(expression); |
| 11891 listener.assertNoErrors(); |
| 10667 expect(expression.operator, isNotNull); | 11892 expect(expression.operator, isNotNull); |
| 10668 expect(expression.operator.type, TokenType.TILDE); | 11893 expect(expression.operator.type, TokenType.TILDE); |
| 10669 expect(expression.operand, isNotNull); | 11894 expect(expression.operand, isNotNull); |
| 10670 } | 11895 } |
| 10671 | 11896 |
| 10672 void test_parseVariableDeclaration_equals() { | 11897 void test_parseVariableDeclaration_equals() { |
| 10673 VariableDeclaration declaration = | 11898 createParser('a = b'); |
| 10674 parse4("parseVariableDeclaration", "a = b"); | 11899 VariableDeclaration declaration = parser.parseVariableDeclaration(); |
| 11900 expectNotNullIfNoErrors(declaration); |
| 11901 listener.assertNoErrors(); |
| 10675 expect(declaration.name, isNotNull); | 11902 expect(declaration.name, isNotNull); |
| 10676 expect(declaration.equals, isNotNull); | 11903 expect(declaration.equals, isNotNull); |
| 10677 expect(declaration.initializer, isNotNull); | 11904 expect(declaration.initializer, isNotNull); |
| 10678 } | 11905 } |
| 10679 | 11906 |
| 10680 void test_parseVariableDeclaration_noEquals() { | 11907 void test_parseVariableDeclaration_noEquals() { |
| 10681 VariableDeclaration declaration = parse4("parseVariableDeclaration", "a"); | 11908 createParser('a'); |
| 11909 VariableDeclaration declaration = parser.parseVariableDeclaration(); |
| 11910 expectNotNullIfNoErrors(declaration); |
| 11911 listener.assertNoErrors(); |
| 10682 expect(declaration.name, isNotNull); | 11912 expect(declaration.name, isNotNull); |
| 10683 expect(declaration.equals, isNull); | 11913 expect(declaration.equals, isNull); |
| 10684 expect(declaration.initializer, isNull); | 11914 expect(declaration.initializer, isNull); |
| 10685 } | 11915 } |
| 10686 | 11916 |
| 10687 void test_parseVariableDeclarationListAfterMetadata_const_noType() { | 11917 void test_parseVariableDeclarationListAfterMetadata_const_noType() { |
| 10688 VariableDeclarationList declarationList = parse( | 11918 createParser('const a'); |
| 10689 "parseVariableDeclarationListAfterMetadata", | 11919 VariableDeclarationList declarationList = parser |
| 10690 <Object>[emptyCommentAndMetadata()], | 11920 .parseVariableDeclarationListAfterMetadata(emptyCommentAndMetadata()); |
| 10691 "const a"); | 11921 expectNotNullIfNoErrors(declarationList); |
| 11922 listener.assertNoErrors(); |
| 10692 expect(declarationList.keyword, isNotNull); | 11923 expect(declarationList.keyword, isNotNull); |
| 10693 expect(declarationList.type, isNull); | 11924 expect(declarationList.type, isNull); |
| 10694 expect(declarationList.variables, hasLength(1)); | 11925 expect(declarationList.variables, hasLength(1)); |
| 10695 } | 11926 } |
| 10696 | 11927 |
| 10697 void test_parseVariableDeclarationListAfterMetadata_const_type() { | 11928 void test_parseVariableDeclarationListAfterMetadata_const_type() { |
| 10698 VariableDeclarationList declarationList = parse( | 11929 createParser('const A a'); |
| 10699 "parseVariableDeclarationListAfterMetadata", | 11930 VariableDeclarationList declarationList = parser |
| 10700 <Object>[emptyCommentAndMetadata()], | 11931 .parseVariableDeclarationListAfterMetadata(emptyCommentAndMetadata()); |
| 10701 "const A a"); | 11932 expectNotNullIfNoErrors(declarationList); |
| 11933 listener.assertNoErrors(); |
| 10702 expect(declarationList.keyword, isNotNull); | 11934 expect(declarationList.keyword, isNotNull); |
| 10703 expect(declarationList.type, isNotNull); | 11935 expect(declarationList.type, isNotNull); |
| 10704 expect(declarationList.variables, hasLength(1)); | 11936 expect(declarationList.variables, hasLength(1)); |
| 10705 } | 11937 } |
| 10706 | 11938 |
| 10707 void test_parseVariableDeclarationListAfterMetadata_final_noType() { | 11939 void test_parseVariableDeclarationListAfterMetadata_final_noType() { |
| 10708 VariableDeclarationList declarationList = parse( | 11940 createParser('final a'); |
| 10709 "parseVariableDeclarationListAfterMetadata", | 11941 VariableDeclarationList declarationList = parser |
| 10710 <Object>[emptyCommentAndMetadata()], | 11942 .parseVariableDeclarationListAfterMetadata(emptyCommentAndMetadata()); |
| 10711 "final a"); | 11943 expectNotNullIfNoErrors(declarationList); |
| 11944 listener.assertNoErrors(); |
| 10712 expect(declarationList.keyword, isNotNull); | 11945 expect(declarationList.keyword, isNotNull); |
| 10713 expect(declarationList.type, isNull); | 11946 expect(declarationList.type, isNull); |
| 10714 expect(declarationList.variables, hasLength(1)); | 11947 expect(declarationList.variables, hasLength(1)); |
| 10715 } | 11948 } |
| 10716 | 11949 |
| 10717 void test_parseVariableDeclarationListAfterMetadata_final_type() { | 11950 void test_parseVariableDeclarationListAfterMetadata_final_type() { |
| 10718 VariableDeclarationList declarationList = parse( | 11951 createParser('final A a'); |
| 10719 "parseVariableDeclarationListAfterMetadata", | 11952 VariableDeclarationList declarationList = parser |
| 10720 <Object>[emptyCommentAndMetadata()], | 11953 .parseVariableDeclarationListAfterMetadata(emptyCommentAndMetadata()); |
| 10721 "final A a"); | 11954 expectNotNullIfNoErrors(declarationList); |
| 11955 listener.assertNoErrors(); |
| 10722 expect(declarationList.keyword, isNotNull); | 11956 expect(declarationList.keyword, isNotNull); |
| 10723 expect(declarationList.type, isNotNull); | 11957 expect(declarationList.type, isNotNull); |
| 10724 expect(declarationList.variables, hasLength(1)); | 11958 expect(declarationList.variables, hasLength(1)); |
| 10725 } | 11959 } |
| 10726 | 11960 |
| 10727 void test_parseVariableDeclarationListAfterMetadata_final_typeComment() { | 11961 void test_parseVariableDeclarationListAfterMetadata_final_typeComment() { |
| 10728 enableGenericMethodComments = true; | 11962 enableGenericMethodComments = true; |
| 10729 VariableDeclarationList decl = parse( | 11963 createParser('final/*=T*/ x'); |
| 10730 "parseVariableDeclarationListAfterMetadata", | 11964 VariableDeclarationList declarationList = parser |
| 10731 <Object>[emptyCommentAndMetadata()], | 11965 .parseVariableDeclarationListAfterMetadata(emptyCommentAndMetadata()); |
| 10732 "final/*=T*/ x"); | 11966 expectNotNullIfNoErrors(declarationList); |
| 10733 expect(decl.type.name.name, 'T'); | 11967 listener.assertNoErrors(); |
| 10734 expect(decl.isFinal, true); | 11968 expect(declarationList.type.name.name, 'T'); |
| 11969 expect(declarationList.isFinal, true); |
| 10735 } | 11970 } |
| 10736 | 11971 |
| 10737 void test_parseVariableDeclarationListAfterMetadata_type_multiple() { | 11972 void test_parseVariableDeclarationListAfterMetadata_type_multiple() { |
| 10738 VariableDeclarationList declarationList = parse( | 11973 createParser('A a, b, c'); |
| 10739 "parseVariableDeclarationListAfterMetadata", | 11974 VariableDeclarationList declarationList = parser |
| 10740 <Object>[emptyCommentAndMetadata()], | 11975 .parseVariableDeclarationListAfterMetadata(emptyCommentAndMetadata()); |
| 10741 "A a, b, c"); | 11976 expectNotNullIfNoErrors(declarationList); |
| 11977 listener.assertNoErrors(); |
| 10742 expect(declarationList.keyword, isNull); | 11978 expect(declarationList.keyword, isNull); |
| 10743 expect(declarationList.type, isNotNull); | 11979 expect(declarationList.type, isNotNull); |
| 10744 expect(declarationList.variables, hasLength(3)); | 11980 expect(declarationList.variables, hasLength(3)); |
| 10745 } | 11981 } |
| 10746 | 11982 |
| 10747 void test_parseVariableDeclarationListAfterMetadata_type_single() { | 11983 void test_parseVariableDeclarationListAfterMetadata_type_single() { |
| 10748 VariableDeclarationList declarationList = parse( | 11984 createParser('A a'); |
| 10749 "parseVariableDeclarationListAfterMetadata", | 11985 VariableDeclarationList declarationList = parser |
| 10750 <Object>[emptyCommentAndMetadata()], | 11986 .parseVariableDeclarationListAfterMetadata(emptyCommentAndMetadata()); |
| 10751 "A a"); | 11987 expectNotNullIfNoErrors(declarationList); |
| 11988 listener.assertNoErrors(); |
| 10752 expect(declarationList.keyword, isNull); | 11989 expect(declarationList.keyword, isNull); |
| 10753 expect(declarationList.type, isNotNull); | 11990 expect(declarationList.type, isNotNull); |
| 10754 expect(declarationList.variables, hasLength(1)); | 11991 expect(declarationList.variables, hasLength(1)); |
| 10755 } | 11992 } |
| 10756 | 11993 |
| 10757 void test_parseVariableDeclarationListAfterMetadata_var_multiple() { | 11994 void test_parseVariableDeclarationListAfterMetadata_var_multiple() { |
| 10758 VariableDeclarationList declarationList = parse( | 11995 createParser('var a, b, c'); |
| 10759 "parseVariableDeclarationListAfterMetadata", | 11996 VariableDeclarationList declarationList = parser |
| 10760 <Object>[emptyCommentAndMetadata()], | 11997 .parseVariableDeclarationListAfterMetadata(emptyCommentAndMetadata()); |
| 10761 "var a, b, c"); | 11998 expectNotNullIfNoErrors(declarationList); |
| 11999 listener.assertNoErrors(); |
| 10762 expect(declarationList.keyword, isNotNull); | 12000 expect(declarationList.keyword, isNotNull); |
| 10763 expect(declarationList.type, isNull); | 12001 expect(declarationList.type, isNull); |
| 10764 expect(declarationList.variables, hasLength(3)); | 12002 expect(declarationList.variables, hasLength(3)); |
| 10765 } | 12003 } |
| 10766 | 12004 |
| 10767 void test_parseVariableDeclarationListAfterMetadata_var_single() { | 12005 void test_parseVariableDeclarationListAfterMetadata_var_single() { |
| 10768 VariableDeclarationList declarationList = parse( | 12006 createParser('var a'); |
| 10769 "parseVariableDeclarationListAfterMetadata", | 12007 VariableDeclarationList declarationList = parser |
| 10770 <Object>[emptyCommentAndMetadata()], | 12008 .parseVariableDeclarationListAfterMetadata(emptyCommentAndMetadata()); |
| 10771 "var a"); | 12009 expectNotNullIfNoErrors(declarationList); |
| 12010 listener.assertNoErrors(); |
| 10772 expect(declarationList.keyword, isNotNull); | 12011 expect(declarationList.keyword, isNotNull); |
| 10773 expect(declarationList.type, isNull); | 12012 expect(declarationList.type, isNull); |
| 10774 expect(declarationList.variables, hasLength(1)); | 12013 expect(declarationList.variables, hasLength(1)); |
| 10775 } | 12014 } |
| 10776 | 12015 |
| 10777 void test_parseVariableDeclarationListAfterMetadata_var_typeComment() { | 12016 void test_parseVariableDeclarationListAfterMetadata_var_typeComment() { |
| 10778 enableGenericMethodComments = true; | 12017 enableGenericMethodComments = true; |
| 10779 VariableDeclarationList decl = parse( | 12018 createParser('var/*=T*/ x'); |
| 10780 "parseVariableDeclarationListAfterMetadata", | 12019 VariableDeclarationList declarationList = parser |
| 10781 <Object>[emptyCommentAndMetadata()], | 12020 .parseVariableDeclarationListAfterMetadata(emptyCommentAndMetadata()); |
| 10782 "var/*=T*/ x"); | 12021 expectNotNullIfNoErrors(declarationList); |
| 10783 expect(decl.type.name.name, 'T'); | 12022 listener.assertNoErrors(); |
| 10784 expect(decl.keyword, isNull); | 12023 expect(declarationList.type.name.name, 'T'); |
| 12024 expect(declarationList.keyword, isNull); |
| 10785 } | 12025 } |
| 10786 | 12026 |
| 10787 void test_parseVariableDeclarationListAfterType_type() { | 12027 void test_parseVariableDeclarationListAfterType_type() { |
| 10788 TypeName type = new TypeName(new SimpleIdentifier(null), null); | 12028 TypeName type = new TypeName(new SimpleIdentifier(null), null); |
| 10789 VariableDeclarationList declarationList = parse( | 12029 createParser('a'); |
| 10790 "parseVariableDeclarationListAfterType", | 12030 VariableDeclarationList declarationList = |
| 10791 <Object>[emptyCommentAndMetadata(), null, type], | 12031 parser.parseVariableDeclarationListAfterType( |
| 10792 "a"); | 12032 emptyCommentAndMetadata(), null, type); |
| 12033 expectNotNullIfNoErrors(declarationList); |
| 12034 listener.assertNoErrors(); |
| 10793 expect(declarationList.keyword, isNull); | 12035 expect(declarationList.keyword, isNull); |
| 10794 expect(declarationList.type, type); | 12036 expect(declarationList.type, type); |
| 10795 expect(declarationList.variables, hasLength(1)); | 12037 expect(declarationList.variables, hasLength(1)); |
| 10796 } | 12038 } |
| 10797 | 12039 |
| 10798 void test_parseVariableDeclarationListAfterType_var() { | 12040 void test_parseVariableDeclarationListAfterType_var() { |
| 10799 Token keyword = TokenFactory.tokenFromKeyword(Keyword.VAR); | 12041 Token keyword = TokenFactory.tokenFromKeyword(Keyword.VAR); |
| 10800 VariableDeclarationList declarationList = parse( | 12042 createParser('a, b, c'); |
| 10801 "parseVariableDeclarationListAfterType", | 12043 VariableDeclarationList declarationList = |
| 10802 <Object>[emptyCommentAndMetadata(), keyword, null], | 12044 parser.parseVariableDeclarationListAfterType( |
| 10803 "a, b, c"); | 12045 emptyCommentAndMetadata(), keyword, null); |
| 12046 expectNotNullIfNoErrors(declarationList); |
| 12047 listener.assertNoErrors(); |
| 10804 expect(declarationList.keyword, keyword); | 12048 expect(declarationList.keyword, keyword); |
| 10805 expect(declarationList.type, isNull); | 12049 expect(declarationList.type, isNull); |
| 10806 expect(declarationList.variables, hasLength(3)); | 12050 expect(declarationList.variables, hasLength(3)); |
| 10807 } | 12051 } |
| 10808 | 12052 |
| 10809 void test_parseVariableDeclarationStatementAfterMetadata_multiple() { | 12053 void test_parseVariableDeclarationStatementAfterMetadata_multiple() { |
| 10810 VariableDeclarationStatement statement = parse( | 12054 createParser('var x, y, z;'); |
| 10811 "parseVariableDeclarationStatementAfterMetadata", | 12055 VariableDeclarationStatement statement = |
| 10812 <Object>[emptyCommentAndMetadata()], | 12056 parser.parseVariableDeclarationStatementAfterMetadata( |
| 10813 "var x, y, z;"); | 12057 emptyCommentAndMetadata()); |
| 12058 expectNotNullIfNoErrors(statement); |
| 12059 listener.assertNoErrors(); |
| 10814 expect(statement.semicolon, isNotNull); | 12060 expect(statement.semicolon, isNotNull); |
| 10815 VariableDeclarationList variableList = statement.variables; | 12061 VariableDeclarationList variableList = statement.variables; |
| 10816 expect(variableList, isNotNull); | 12062 expect(variableList, isNotNull); |
| 10817 expect(variableList.variables, hasLength(3)); | 12063 expect(variableList.variables, hasLength(3)); |
| 10818 } | 12064 } |
| 10819 | 12065 |
| 10820 void test_parseVariableDeclarationStatementAfterMetadata_single() { | 12066 void test_parseVariableDeclarationStatementAfterMetadata_single() { |
| 10821 VariableDeclarationStatement statement = parse( | 12067 createParser('var x;'); |
| 10822 "parseVariableDeclarationStatementAfterMetadata", | 12068 VariableDeclarationStatement statement = |
| 10823 <Object>[emptyCommentAndMetadata()], | 12069 parser.parseVariableDeclarationStatementAfterMetadata( |
| 10824 "var x;"); | 12070 emptyCommentAndMetadata()); |
| 12071 expectNotNullIfNoErrors(statement); |
| 12072 listener.assertNoErrors(); |
| 10825 expect(statement.semicolon, isNotNull); | 12073 expect(statement.semicolon, isNotNull); |
| 10826 VariableDeclarationList variableList = statement.variables; | 12074 VariableDeclarationList variableList = statement.variables; |
| 10827 expect(variableList, isNotNull); | 12075 expect(variableList, isNotNull); |
| 10828 expect(variableList.variables, hasLength(1)); | 12076 expect(variableList.variables, hasLength(1)); |
| 10829 } | 12077 } |
| 10830 | 12078 |
| 10831 void test_parseWhileStatement() { | 12079 void test_parseWhileStatement() { |
| 10832 WhileStatement statement = parse4("parseWhileStatement", "while (x) {}"); | 12080 createParser('while (x) {}'); |
| 12081 WhileStatement statement = parser.parseWhileStatement(); |
| 12082 expectNotNullIfNoErrors(statement); |
| 12083 listener.assertNoErrors(); |
| 10833 expect(statement.whileKeyword, isNotNull); | 12084 expect(statement.whileKeyword, isNotNull); |
| 10834 expect(statement.leftParenthesis, isNotNull); | 12085 expect(statement.leftParenthesis, isNotNull); |
| 10835 expect(statement.condition, isNotNull); | 12086 expect(statement.condition, isNotNull); |
| 10836 expect(statement.rightParenthesis, isNotNull); | 12087 expect(statement.rightParenthesis, isNotNull); |
| 10837 expect(statement.body, isNotNull); | 12088 expect(statement.body, isNotNull); |
| 10838 } | 12089 } |
| 10839 | 12090 |
| 10840 void test_parseWithClause_multiple() { | 12091 void test_parseWithClause_multiple() { |
| 10841 WithClause clause = parse4("parseWithClause", "with A, B, C"); | 12092 createParser('with A, B, C'); |
| 12093 WithClause clause = parser.parseWithClause(); |
| 12094 expectNotNullIfNoErrors(clause); |
| 12095 listener.assertNoErrors(); |
| 10842 expect(clause.withKeyword, isNotNull); | 12096 expect(clause.withKeyword, isNotNull); |
| 10843 expect(clause.mixinTypes, hasLength(3)); | 12097 expect(clause.mixinTypes, hasLength(3)); |
| 10844 } | 12098 } |
| 10845 | 12099 |
| 10846 void test_parseWithClause_single() { | 12100 void test_parseWithClause_single() { |
| 10847 WithClause clause = parse4("parseWithClause", "with M"); | 12101 createParser('with M'); |
| 12102 WithClause clause = parser.parseWithClause(); |
| 12103 expectNotNullIfNoErrors(clause); |
| 12104 listener.assertNoErrors(); |
| 10848 expect(clause.withKeyword, isNotNull); | 12105 expect(clause.withKeyword, isNotNull); |
| 10849 expect(clause.mixinTypes, hasLength(1)); | 12106 expect(clause.mixinTypes, hasLength(1)); |
| 10850 } | 12107 } |
| 10851 | 12108 |
| 10852 void test_parseYieldStatement_each() { | 12109 void test_parseYieldStatement_each() { |
| 10853 YieldStatement statement = parse4("parseYieldStatement", "yield* x;"); | 12110 createParser('yield* x;'); |
| 12111 YieldStatement statement = parser.parseYieldStatement(); |
| 12112 expectNotNullIfNoErrors(statement); |
| 12113 listener.assertNoErrors(); |
| 10854 expect(statement.yieldKeyword, isNotNull); | 12114 expect(statement.yieldKeyword, isNotNull); |
| 10855 expect(statement.star, isNotNull); | 12115 expect(statement.star, isNotNull); |
| 10856 expect(statement.expression, isNotNull); | 12116 expect(statement.expression, isNotNull); |
| 10857 expect(statement.semicolon, isNotNull); | 12117 expect(statement.semicolon, isNotNull); |
| 10858 } | 12118 } |
| 10859 | 12119 |
| 10860 void test_parseYieldStatement_normal() { | 12120 void test_parseYieldStatement_normal() { |
| 10861 YieldStatement statement = parse4("parseYieldStatement", "yield x;"); | 12121 createParser('yield x;'); |
| 12122 YieldStatement statement = parser.parseYieldStatement(); |
| 12123 expectNotNullIfNoErrors(statement); |
| 12124 listener.assertNoErrors(); |
| 10862 expect(statement.yieldKeyword, isNotNull); | 12125 expect(statement.yieldKeyword, isNotNull); |
| 10863 expect(statement.star, isNull); | 12126 expect(statement.star, isNull); |
| 10864 expect(statement.expression, isNotNull); | 12127 expect(statement.expression, isNotNull); |
| 10865 expect(statement.semicolon, isNotNull); | 12128 expect(statement.semicolon, isNotNull); |
| 10866 } | 12129 } |
| 10867 | 12130 |
| 10868 void test_skipPrefixedIdentifier_invalid() { | 12131 void test_skipPrefixedIdentifier_invalid() { |
| 10869 Token following = _skip("skipPrefixedIdentifier", "+"); | 12132 createParser('+'); |
| 12133 Token following = parser.skipPrefixedIdentifier(parser.currentToken); |
| 10870 expect(following, isNull); | 12134 expect(following, isNull); |
| 10871 } | 12135 } |
| 10872 | 12136 |
| 10873 void test_skipPrefixedIdentifier_notPrefixed() { | 12137 void test_skipPrefixedIdentifier_notPrefixed() { |
| 10874 Token following = _skip("skipPrefixedIdentifier", "a +"); | 12138 createParser('a +'); |
| 12139 Token following = parser.skipPrefixedIdentifier(parser.currentToken); |
| 10875 expect(following, isNotNull); | 12140 expect(following, isNotNull); |
| 10876 expect(following.type, TokenType.PLUS); | 12141 expect(following.type, TokenType.PLUS); |
| 10877 } | 12142 } |
| 10878 | 12143 |
| 10879 void test_skipPrefixedIdentifier_prefixed() { | 12144 void test_skipPrefixedIdentifier_prefixed() { |
| 10880 Token following = _skip("skipPrefixedIdentifier", "a.b +"); | 12145 createParser('a.b +'); |
| 12146 Token following = parser.skipPrefixedIdentifier(parser.currentToken); |
| 10881 expect(following, isNotNull); | 12147 expect(following, isNotNull); |
| 10882 expect(following.type, TokenType.PLUS); | 12148 expect(following.type, TokenType.PLUS); |
| 10883 } | 12149 } |
| 10884 | 12150 |
| 10885 void test_skipReturnType_invalid() { | 12151 void test_skipReturnType_invalid() { |
| 10886 Token following = _skip("skipReturnType", "+"); | 12152 createParser('+'); |
| 12153 Token following = parser.skipReturnType(parser.currentToken); |
| 10887 expect(following, isNull); | 12154 expect(following, isNull); |
| 10888 } | 12155 } |
| 10889 | 12156 |
| 10890 void test_skipReturnType_type() { | 12157 void test_skipReturnType_type() { |
| 10891 Token following = _skip("skipReturnType", "C +"); | 12158 createParser('C +'); |
| 12159 Token following = parser.skipReturnType(parser.currentToken); |
| 10892 expect(following, isNotNull); | 12160 expect(following, isNotNull); |
| 10893 expect(following.type, TokenType.PLUS); | 12161 expect(following.type, TokenType.PLUS); |
| 10894 } | 12162 } |
| 10895 | 12163 |
| 10896 void test_skipReturnType_void() { | 12164 void test_skipReturnType_void() { |
| 10897 Token following = _skip("skipReturnType", "void +"); | 12165 createParser('void +'); |
| 12166 Token following = parser.skipReturnType(parser.currentToken); |
| 10898 expect(following, isNotNull); | 12167 expect(following, isNotNull); |
| 10899 expect(following.type, TokenType.PLUS); | 12168 expect(following.type, TokenType.PLUS); |
| 10900 } | 12169 } |
| 10901 | 12170 |
| 10902 void test_skipSimpleIdentifier_identifier() { | 12171 void test_skipSimpleIdentifier_identifier() { |
| 10903 Token following = _skip("skipSimpleIdentifier", "i +"); | 12172 createParser('i +'); |
| 12173 Token following = parser.skipSimpleIdentifier(parser.currentToken); |
| 10904 expect(following, isNotNull); | 12174 expect(following, isNotNull); |
| 10905 expect(following.type, TokenType.PLUS); | 12175 expect(following.type, TokenType.PLUS); |
| 10906 } | 12176 } |
| 10907 | 12177 |
| 10908 void test_skipSimpleIdentifier_invalid() { | 12178 void test_skipSimpleIdentifier_invalid() { |
| 10909 Token following = _skip("skipSimpleIdentifier", "9 +"); | 12179 createParser('9 +'); |
| 12180 Token following = parser.skipSimpleIdentifier(parser.currentToken); |
| 10910 expect(following, isNull); | 12181 expect(following, isNull); |
| 10911 } | 12182 } |
| 10912 | 12183 |
| 10913 void test_skipSimpleIdentifier_pseudoKeyword() { | 12184 void test_skipSimpleIdentifier_pseudoKeyword() { |
| 10914 Token following = _skip("skipSimpleIdentifier", "as +"); | 12185 createParser('as +'); |
| 12186 Token following = parser.skipSimpleIdentifier(parser.currentToken); |
| 10915 expect(following, isNotNull); | 12187 expect(following, isNotNull); |
| 10916 expect(following.type, TokenType.PLUS); | 12188 expect(following.type, TokenType.PLUS); |
| 10917 } | 12189 } |
| 10918 | 12190 |
| 10919 void test_skipStringLiteral_adjacent() { | 12191 void test_skipStringLiteral_adjacent() { |
| 10920 Token following = _skip("skipStringLiteral", "'a' 'b' +"); | 12192 createParser("'a' 'b' +"); |
| 12193 Token following = parser.skipStringLiteral(parser.currentToken); |
| 10921 expect(following, isNotNull); | 12194 expect(following, isNotNull); |
| 10922 expect(following.type, TokenType.PLUS); | 12195 expect(following.type, TokenType.PLUS); |
| 10923 } | 12196 } |
| 10924 | 12197 |
| 10925 void test_skipStringLiteral_interpolated() { | 12198 void test_skipStringLiteral_interpolated() { |
| 10926 Token following = _skip("skipStringLiteral", "'a\${b}c' +"); | 12199 createParser("'a\${b}c' +"); |
| 12200 Token following = parser.skipStringLiteral(parser.currentToken); |
| 10927 expect(following, isNotNull); | 12201 expect(following, isNotNull); |
| 10928 expect(following.type, TokenType.PLUS); | 12202 expect(following.type, TokenType.PLUS); |
| 10929 } | 12203 } |
| 10930 | 12204 |
| 10931 void test_skipStringLiteral_invalid() { | 12205 void test_skipStringLiteral_invalid() { |
| 10932 Token following = _skip("skipStringLiteral", "a"); | 12206 createParser('a'); |
| 12207 Token following = parser.skipStringLiteral(parser.currentToken); |
| 10933 expect(following, isNull); | 12208 expect(following, isNull); |
| 10934 } | 12209 } |
| 10935 | 12210 |
| 10936 void test_skipStringLiteral_single() { | 12211 void test_skipStringLiteral_single() { |
| 10937 Token following = _skip("skipStringLiteral", "'a' +"); | 12212 createParser("'a' +"); |
| 12213 Token following = parser.skipStringLiteral(parser.currentToken); |
| 10938 expect(following, isNotNull); | 12214 expect(following, isNotNull); |
| 10939 expect(following.type, TokenType.PLUS); | 12215 expect(following.type, TokenType.PLUS); |
| 10940 } | 12216 } |
| 10941 | 12217 |
| 10942 void test_skipTypeArgumentList_invalid() { | 12218 void test_skipTypeArgumentList_invalid() { |
| 10943 Token following = _skip("skipTypeArgumentList", "+"); | 12219 createParser('+'); |
| 12220 Token following = parser.skipTypeArgumentList(parser.currentToken); |
| 10944 expect(following, isNull); | 12221 expect(following, isNull); |
| 10945 } | 12222 } |
| 10946 | 12223 |
| 10947 void test_skipTypeArgumentList_multiple() { | 12224 void test_skipTypeArgumentList_multiple() { |
| 10948 Token following = _skip("skipTypeArgumentList", "<E, F, G> +"); | 12225 createParser('<E, F, G> +'); |
| 12226 Token following = parser.skipTypeArgumentList(parser.currentToken); |
| 10949 expect(following, isNotNull); | 12227 expect(following, isNotNull); |
| 10950 expect(following.type, TokenType.PLUS); | 12228 expect(following.type, TokenType.PLUS); |
| 10951 } | 12229 } |
| 10952 | 12230 |
| 10953 void test_skipTypeArgumentList_single() { | 12231 void test_skipTypeArgumentList_single() { |
| 10954 Token following = _skip("skipTypeArgumentList", "<E> +"); | 12232 createParser('<E> +'); |
| 12233 Token following = parser.skipTypeArgumentList(parser.currentToken); |
| 10955 expect(following, isNotNull); | 12234 expect(following, isNotNull); |
| 10956 expect(following.type, TokenType.PLUS); | 12235 expect(following.type, TokenType.PLUS); |
| 10957 } | 12236 } |
| 10958 | 12237 |
| 10959 void test_skipTypeName_invalid() { | 12238 void test_skipTypeName_invalid() { |
| 10960 Token following = _skip("skipTypeName", "+"); | 12239 createParser('+'); |
| 12240 Token following = parser.skipTypeName(parser.currentToken); |
| 10961 expect(following, isNull); | 12241 expect(following, isNull); |
| 10962 } | 12242 } |
| 10963 | 12243 |
| 10964 void test_skipTypeName_parameterized() { | 12244 void test_skipTypeName_parameterized() { |
| 10965 Token following = _skip("skipTypeName", "C<E<F<G>>> +"); | 12245 createParser('C<E<F<G>>> +'); |
| 12246 Token following = parser.skipTypeName(parser.currentToken); |
| 10966 expect(following, isNotNull); | 12247 expect(following, isNotNull); |
| 10967 expect(following.type, TokenType.PLUS); | 12248 expect(following.type, TokenType.PLUS); |
| 10968 } | 12249 } |
| 10969 | 12250 |
| 10970 void test_skipTypeName_simple() { | 12251 void test_skipTypeName_simple() { |
| 10971 Token following = _skip("skipTypeName", "C +"); | 12252 createParser('C +'); |
| 12253 Token following = parser.skipTypeName(parser.currentToken); |
| 10972 expect(following, isNotNull); | 12254 expect(following, isNotNull); |
| 10973 expect(following.type, TokenType.PLUS); | 12255 expect(following.type, TokenType.PLUS); |
| 10974 } | 12256 } |
| 10975 | 12257 |
| 10976 /** | 12258 /** |
| 10977 * Invoke the method [Parser.computeStringValue] with the given argument. | 12259 * Invoke the method [Parser.computeStringValue] with the given argument. |
| 10978 * | 12260 * |
| 10979 * @param lexeme the argument to the method | 12261 * @param lexeme the argument to the method |
| 10980 * @param first `true` if this is the first token in a string literal | 12262 * @param first `true` if this is the first token in a string literal |
| 10981 * @param last `true` if this is the last token in a string literal | 12263 * @param last `true` if this is the last token in a string literal |
| 10982 * @return the result of invoking the method | 12264 * @return the result of invoking the method |
| 10983 * @throws Exception if the method could not be invoked or throws an exception | 12265 * @throws Exception if the method could not be invoked or throws an exception |
| 10984 */ | 12266 */ |
| 10985 String _computeStringValue(String lexeme, bool first, bool last) { | 12267 String _computeStringValue(String lexeme, bool first, bool last) { |
| 10986 AnalysisErrorListener listener = | 12268 createParser(''); |
| 10987 new AnalysisErrorListener_SimpleParserTest_computeStringValue(); | 12269 String value = parser.computeStringValue(lexeme, first, last); |
| 10988 Parser parser = new Parser(null, listener); | 12270 listener.assertNoErrors(); |
| 10989 return invokeParserMethodImpl( | 12271 return value; |
| 10990 parser, "computeStringValue", <Object>[lexeme, first, last], null) | |
| 10991 as String; | |
| 10992 } | |
| 10993 | |
| 10994 /** | |
| 10995 * Invoke the method [Parser.createSyntheticIdentifier] with the parser set to
the token | |
| 10996 * stream produced by scanning the given source. | |
| 10997 * | |
| 10998 * @param source the source to be scanned to produce the token stream being te
sted | |
| 10999 * @return the result of invoking the method | |
| 11000 * @throws Exception if the method could not be invoked or throws an exception | |
| 11001 */ | |
| 11002 SimpleIdentifier _createSyntheticIdentifier() { | |
| 11003 GatheringErrorListener listener = new GatheringErrorListener(); | |
| 11004 return invokeParserMethod2("createSyntheticIdentifier", "", listener); | |
| 11005 } | |
| 11006 | |
| 11007 /** | |
| 11008 * Invoke the method [Parser.createSyntheticIdentifier] with the parser set to
the token | |
| 11009 * stream produced by scanning the given source. | |
| 11010 * | |
| 11011 * @param source the source to be scanned to produce the token stream being te
sted | |
| 11012 * @return the result of invoking the method | |
| 11013 * @throws Exception if the method could not be invoked or throws an exception | |
| 11014 */ | |
| 11015 SimpleStringLiteral _createSyntheticStringLiteral() { | |
| 11016 GatheringErrorListener listener = new GatheringErrorListener(); | |
| 11017 return invokeParserMethod2("createSyntheticStringLiteral", "", listener); | |
| 11018 } | 12272 } |
| 11019 | 12273 |
| 11020 void _expectDottedName(DottedName name, List<String> expectedComponents) { | 12274 void _expectDottedName(DottedName name, List<String> expectedComponents) { |
| 11021 int count = expectedComponents.length; | 12275 int count = expectedComponents.length; |
| 11022 NodeList<SimpleIdentifier> components = name.components; | 12276 NodeList<SimpleIdentifier> components = name.components; |
| 11023 expect(components, hasLength(count)); | 12277 expect(components, hasLength(count)); |
| 11024 for (int i = 0; i < count; i++) { | 12278 for (int i = 0; i < count; i++) { |
| 11025 SimpleIdentifier component = components[i]; | 12279 SimpleIdentifier component = components[i]; |
| 11026 expect(component, isNotNull); | 12280 expect(component, isNotNull); |
| 11027 expect(component.name, expectedComponents[i]); | 12281 expect(component.name, expectedComponents[i]); |
| 11028 } | 12282 } |
| 11029 } | 12283 } |
| 11030 | 12284 |
| 11031 /** | 12285 /** |
| 11032 * Invoke the method [Parser.isFunctionDeclaration] with the parser set to the
token | 12286 * Invoke the method [Parser.isFunctionDeclaration] with the parser set to the
token |
| 11033 * stream produced by scanning the given source. | 12287 * stream produced by scanning the given source. |
| 11034 * | 12288 * |
| 11035 * @param source the source to be scanned to produce the token stream being te
sted | 12289 * @param source the source to be scanned to produce the token stream being te
sted |
| 11036 * @return the result of invoking the method | 12290 * @return the result of invoking the method |
| 11037 * @throws Exception if the method could not be invoked or throws an exception | 12291 * @throws Exception if the method could not be invoked or throws an exception |
| 11038 */ | 12292 */ |
| 11039 bool _isFunctionDeclaration(String source) { | 12293 bool _isFunctionDeclaration(String source) { |
| 11040 GatheringErrorListener listener = new GatheringErrorListener(); | 12294 createParser(source); |
| 11041 return invokeParserMethod2("isFunctionDeclaration", source, listener) | 12295 bool result = parser.isFunctionDeclaration(); |
| 11042 as bool; | 12296 expectNotNullIfNoErrors(result); |
| 12297 return result; |
| 11043 } | 12298 } |
| 11044 | 12299 |
| 11045 /** | 12300 /** |
| 11046 * Invoke the method [Parser.isFunctionExpression] with the parser set to the
token stream | 12301 * Invoke the method [Parser.isFunctionExpression] with the parser set to the
token stream |
| 11047 * produced by scanning the given source. | 12302 * produced by scanning the given source. |
| 11048 * | 12303 * |
| 11049 * @param source the source to be scanned to produce the token stream being te
sted | 12304 * @param source the source to be scanned to produce the token stream being te
sted |
| 11050 * @return the result of invoking the method | 12305 * @return the result of invoking the method |
| 11051 * @throws Exception if the method could not be invoked or throws an exception | 12306 * @throws Exception if the method could not be invoked or throws an exception |
| 11052 */ | 12307 */ |
| 11053 bool _isFunctionExpression(String source) { | 12308 bool _isFunctionExpression(String source) { |
| 11054 GatheringErrorListener listener = new GatheringErrorListener(); | 12309 createParser(source); |
| 11055 // | 12310 return parser.isFunctionExpression(parser.currentToken); |
| 11056 // Scan the source. | |
| 11057 // | |
| 11058 Scanner scanner = | |
| 11059 new Scanner(null, new CharSequenceReader(source), listener); | |
| 11060 Token tokenStream = scanner.tokenize(); | |
| 11061 // | |
| 11062 // Parse the source. | |
| 11063 // | |
| 11064 Parser parser = new Parser(null, listener); | |
| 11065 return invokeParserMethodImpl( | |
| 11066 parser, "isFunctionExpression", <Object>[tokenStream], tokenStream) | |
| 11067 as bool; | |
| 11068 } | 12311 } |
| 11069 | 12312 |
| 11070 /** | 12313 /** |
| 11071 * Invoke the method [Parser.isInitializedVariableDeclaration] with the parser
set to the | 12314 * Invoke the method [Parser.isInitializedVariableDeclaration] with the parser
set to the |
| 11072 * token stream produced by scanning the given source. | 12315 * token stream produced by scanning the given source. |
| 11073 * | 12316 * |
| 11074 * @param source the source to be scanned to produce the token stream being te
sted | 12317 * @param source the source to be scanned to produce the token stream being te
sted |
| 11075 * @return the result of invoking the method | 12318 * @return the result of invoking the method |
| 11076 * @throws Exception if the method could not be invoked or throws an exception | 12319 * @throws Exception if the method could not be invoked or throws an exception |
| 11077 */ | 12320 */ |
| 11078 bool _isInitializedVariableDeclaration(String source) { | 12321 bool _isInitializedVariableDeclaration(String source) { |
| 11079 GatheringErrorListener listener = new GatheringErrorListener(); | 12322 createParser(source); |
| 11080 return invokeParserMethod2( | 12323 bool result = parser.isInitializedVariableDeclaration(); |
| 11081 "isInitializedVariableDeclaration", source, listener) as bool; | 12324 expectNotNullIfNoErrors(result); |
| 12325 return result; |
| 11082 } | 12326 } |
| 11083 | 12327 |
| 11084 /** | 12328 /** |
| 11085 * Invoke the method [Parser.isSwitchMember] with the parser set to the token
stream | 12329 * Invoke the method [Parser.isSwitchMember] with the parser set to the token
stream |
| 11086 * produced by scanning the given source. | 12330 * produced by scanning the given source. |
| 11087 * | 12331 * |
| 11088 * @param source the source to be scanned to produce the token stream being te
sted | 12332 * @param source the source to be scanned to produce the token stream being te
sted |
| 11089 * @return the result of invoking the method | 12333 * @return the result of invoking the method |
| 11090 * @throws Exception if the method could not be invoked or throws an exception | 12334 * @throws Exception if the method could not be invoked or throws an exception |
| 11091 */ | 12335 */ |
| 11092 bool _isSwitchMember(String source) { | 12336 bool _isSwitchMember(String source) { |
| 11093 GatheringErrorListener listener = new GatheringErrorListener(); | 12337 createParser(source); |
| 11094 return invokeParserMethod2("isSwitchMember", source, listener) as bool; | 12338 bool result = parser.isSwitchMember(); |
| 12339 expectNotNullIfNoErrors(result); |
| 12340 return result; |
| 11095 } | 12341 } |
| 11096 | 12342 |
| 11097 /** | 12343 /** |
| 11098 * Parse the given source as a compilation unit. | 12344 * Parse the given source as a compilation unit. |
| 11099 * | 12345 * |
| 11100 * @param source the source to be parsed | 12346 * @param source the source to be parsed |
| 11101 * @param errorCodes the error codes of the errors that are expected to be fou
nd | 12347 * @param errorCodes the error codes of the errors that are expected to be fou
nd |
| 11102 * @return the compilation unit that was parsed | 12348 * @return the compilation unit that was parsed |
| 11103 * @throws Exception if the source could not be parsed, if the compilation err
ors in the source do | 12349 * @throws Exception if the source could not be parsed, if the compilation err
ors in the source do |
| 11104 * not match those that are expected, or if the result would have be
en `null` | 12350 * not match those that are expected, or if the result would have be
en `null` |
| 11105 */ | 12351 */ |
| 11106 CompilationUnit _parseDirectives(String source, | 12352 CompilationUnit _parseDirectives(String source, |
| 11107 [List<ErrorCode> errorCodes = ErrorCode.EMPTY_LIST]) { | 12353 [List<ErrorCode> errorCodes = ErrorCode.EMPTY_LIST]) { |
| 11108 GatheringErrorListener listener = new GatheringErrorListener(); | 12354 createParser(source); |
| 11109 Scanner scanner = | 12355 CompilationUnit unit = parser.parseDirectives2(); |
| 11110 new Scanner(null, new CharSequenceReader(source), listener); | |
| 11111 listener.setLineInfo(new TestSource(), scanner.lineStarts); | |
| 11112 Token token = scanner.tokenize(); | |
| 11113 Parser parser = new Parser(null, listener); | |
| 11114 CompilationUnit unit = parser.parseDirectives(token); | |
| 11115 expect(unit, isNotNull); | 12356 expect(unit, isNotNull); |
| 11116 expect(unit.declarations, hasLength(0)); | 12357 expect(unit.declarations, hasLength(0)); |
| 11117 listener.assertErrorsWithCodes(errorCodes); | 12358 listener.assertErrorsWithCodes(errorCodes); |
| 11118 return unit; | 12359 return unit; |
| 11119 } | 12360 } |
| 11120 | |
| 11121 /** | |
| 11122 * Invoke a "skip" method in [Parser]. The method is assumed to take a token a
s it's | |
| 11123 * parameter and is given the first token in the scanned source. | |
| 11124 * | |
| 11125 * @param methodName the name of the method that should be invoked | |
| 11126 * @param source the source to be processed by the method | |
| 11127 * @return the result of invoking the method | |
| 11128 * @throws Exception if the method could not be invoked or throws an exception | |
| 11129 * @throws AssertionFailedError if the result is `null` | |
| 11130 */ | |
| 11131 Token _skip(String methodName, String source) { | |
| 11132 GatheringErrorListener listener = new GatheringErrorListener(); | |
| 11133 // | |
| 11134 // Scan the source. | |
| 11135 // | |
| 11136 Scanner scanner = | |
| 11137 new Scanner(null, new CharSequenceReader(source), listener); | |
| 11138 Token tokenStream = scanner.tokenize(); | |
| 11139 // | |
| 11140 // Parse the source. | |
| 11141 // | |
| 11142 Parser parser = new Parser(null, listener); | |
| 11143 return invokeParserMethodImpl( | |
| 11144 parser, methodName, <Object>[tokenStream], tokenStream) as Token; | |
| 11145 } | |
| 11146 } | 12361 } |
| OLD | NEW |