Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(353)

Side by Side Diff: pkg/analyzer/test/generated/parser_test.dart

Issue 2684703007: Eliminate emptyCommentAndMetadata() from parser tests. (Closed)
Patch Set: Add comments Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/standard_ast_factory.dart'; 8 import 'package:analyzer/dart/ast/standard_ast_factory.dart';
9 import 'package:analyzer/dart/ast/token.dart'; 9 import 'package:analyzer/dart/ast/token.dart';
10 import 'package:analyzer/dart/ast/visitor.dart'; 10 import 'package:analyzer/dart/ast/visitor.dart';
(...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 742
743 void test_classInClass_nonAbstract() { 743 void test_classInClass_nonAbstract() {
744 parseCompilationUnit( 744 parseCompilationUnit(
745 "class C { class B {} }", [ParserErrorCode.CLASS_IN_CLASS]); 745 "class C { class B {} }", [ParserErrorCode.CLASS_IN_CLASS]);
746 } 746 }
747 747
748 void test_classTypeAlias_abstractAfterEq() { 748 void test_classTypeAlias_abstractAfterEq() {
749 // This syntax has been removed from the language in favor of 749 // This syntax has been removed from the language in favor of
750 // "abstract class A = B with C;" (issue 18098). 750 // "abstract class A = B with C;" (issue 18098).
751 createParser('class A = abstract B with C;'); 751 createParser('class A = abstract B with C;');
752 CompilationUnitMember member = 752 CompilationUnitMember member = parseFullCompilationUnitMember();
753 parser.parseCompilationUnitMember(emptyCommentAndMetadata());
754 expectNotNullIfNoErrors(member); 753 expectNotNullIfNoErrors(member);
755 listener.assertErrorsWithCodes( 754 listener.assertErrorsWithCodes(
756 [ParserErrorCode.EXPECTED_TOKEN, ParserErrorCode.EXPECTED_TOKEN]); 755 [ParserErrorCode.EXPECTED_TOKEN, ParserErrorCode.EXPECTED_TOKEN]);
757 } 756 }
758 757
759 void test_colonInPlaceOfIn() { 758 void test_colonInPlaceOfIn() {
760 parseStatement( 759 parseStatement(
761 "for (var x : list) {}", [ParserErrorCode.COLON_IN_PLACE_OF_IN]); 760 "for (var x : list) {}", [ParserErrorCode.COLON_IN_PLACE_OF_IN]);
762 } 761 }
763 762
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
907 906
908 void test_covariantAndStatic() { 907 void test_covariantAndStatic() {
909 createParser('covariant static A f;'); 908 createParser('covariant static A f;');
910 ClassMember member = parser.parseClassMember('C'); 909 ClassMember member = parser.parseClassMember('C');
911 expectNotNullIfNoErrors(member); 910 expectNotNullIfNoErrors(member);
912 listener.assertErrorsWithCodes([ParserErrorCode.COVARIANT_AND_STATIC]); 911 listener.assertErrorsWithCodes([ParserErrorCode.COVARIANT_AND_STATIC]);
913 } 912 }
914 913
915 void test_covariantConstructor() { 914 void test_covariantConstructor() {
916 createParser('class C { covariant C(); }'); 915 createParser('class C { covariant C(); }');
917 ClassDeclaration member = 916 ClassDeclaration member = parseFullCompilationUnitMember();
918 parser.parseCompilationUnitMember(emptyCommentAndMetadata());
919 expectNotNullIfNoErrors(member); 917 expectNotNullIfNoErrors(member);
920 listener.assertErrorsWithCodes([ParserErrorCode.COVARIANT_CONSTRUCTOR]); 918 listener.assertErrorsWithCodes([ParserErrorCode.COVARIANT_CONSTRUCTOR]);
921 } 919 }
922 920
923 void test_covariantMember_getter_noReturnType() { 921 void test_covariantMember_getter_noReturnType() {
924 createParser('static covariant get x => 0;'); 922 createParser('static covariant get x => 0;');
925 ClassMember member = parser.parseClassMember('C'); 923 ClassMember member = parser.parseClassMember('C');
926 expectNotNullIfNoErrors(member); 924 expectNotNullIfNoErrors(member);
927 listener.assertErrorsWithCodes([ParserErrorCode.COVARIANT_MEMBER]); 925 listener.assertErrorsWithCodes([ParserErrorCode.COVARIANT_MEMBER]);
928 } 926 }
929 927
930 void test_covariantMember_getter_returnType() { 928 void test_covariantMember_getter_returnType() {
931 createParser('static covariant int get x => 0;'); 929 createParser('static covariant int get x => 0;');
932 ClassMember member = parser.parseClassMember('C'); 930 ClassMember member = parser.parseClassMember('C');
933 expectNotNullIfNoErrors(member); 931 expectNotNullIfNoErrors(member);
934 listener.assertErrorsWithCodes([ParserErrorCode.COVARIANT_MEMBER]); 932 listener.assertErrorsWithCodes([ParserErrorCode.COVARIANT_MEMBER]);
935 } 933 }
936 934
937 void test_covariantMember_method() { 935 void test_covariantMember_method() {
938 createParser('covariant int m() => 0;'); 936 createParser('covariant int m() => 0;');
939 ClassMember member = parser.parseClassMember('C'); 937 ClassMember member = parser.parseClassMember('C');
940 expectNotNullIfNoErrors(member); 938 expectNotNullIfNoErrors(member);
941 listener.assertErrorsWithCodes([ParserErrorCode.COVARIANT_MEMBER]); 939 listener.assertErrorsWithCodes([ParserErrorCode.COVARIANT_MEMBER]);
942 } 940 }
943 941
944 void test_covariantTopLevelDeclaration_class() { 942 void test_covariantTopLevelDeclaration_class() {
945 createParser('covariant class C {}'); 943 createParser('covariant class C {}');
946 ClassDeclaration member = 944 ClassDeclaration member = parseFullCompilationUnitMember();
947 parser.parseCompilationUnitMember(emptyCommentAndMetadata());
948 expectNotNullIfNoErrors(member); 945 expectNotNullIfNoErrors(member);
949 listener.assertErrorsWithCodes( 946 listener.assertErrorsWithCodes(
950 [ParserErrorCode.COVARIANT_TOP_LEVEL_DECLARATION]); 947 [ParserErrorCode.COVARIANT_TOP_LEVEL_DECLARATION]);
951 } 948 }
952 949
953 void test_covariantTopLevelDeclaration_enum() { 950 void test_covariantTopLevelDeclaration_enum() {
954 createParser('covariant enum E { v }'); 951 createParser('covariant enum E { v }');
955 EnumDeclaration member = 952 EnumDeclaration member = parseFullCompilationUnitMember();
956 parser.parseCompilationUnitMember(emptyCommentAndMetadata());
957 expectNotNullIfNoErrors(member); 953 expectNotNullIfNoErrors(member);
958 listener.assertErrorsWithCodes( 954 listener.assertErrorsWithCodes(
959 [ParserErrorCode.COVARIANT_TOP_LEVEL_DECLARATION]); 955 [ParserErrorCode.COVARIANT_TOP_LEVEL_DECLARATION]);
960 } 956 }
961 957
962 void test_covariantTopLevelDeclaration_typedef() { 958 void test_covariantTopLevelDeclaration_typedef() {
963 parseCompilationUnit("covariant typedef F();", 959 parseCompilationUnit("covariant typedef F();",
964 [ParserErrorCode.COVARIANT_TOP_LEVEL_DECLARATION]); 960 [ParserErrorCode.COVARIANT_TOP_LEVEL_DECLARATION]);
965 } 961 }
966 962
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
1049 void test_duplicateLabelInSwitchStatement() { 1045 void test_duplicateLabelInSwitchStatement() {
1050 createParser('switch (e) {l1: case 0: break; l1: case 1: break;}'); 1046 createParser('switch (e) {l1: case 0: break; l1: case 1: break;}');
1051 SwitchStatement statement = parser.parseSwitchStatement(); 1047 SwitchStatement statement = parser.parseSwitchStatement();
1052 expectNotNullIfNoErrors(statement); 1048 expectNotNullIfNoErrors(statement);
1053 listener.assertErrorsWithCodes( 1049 listener.assertErrorsWithCodes(
1054 [ParserErrorCode.DUPLICATE_LABEL_IN_SWITCH_STATEMENT]); 1050 [ParserErrorCode.DUPLICATE_LABEL_IN_SWITCH_STATEMENT]);
1055 } 1051 }
1056 1052
1057 void test_emptyEnumBody() { 1053 void test_emptyEnumBody() {
1058 createParser('enum E {}'); 1054 createParser('enum E {}');
1059 EnumDeclaration declaration = 1055 EnumDeclaration declaration = parseFullCompilationUnitMember();
1060 parser.parseEnumDeclaration(emptyCommentAndMetadata());
1061 expectNotNullIfNoErrors(declaration); 1056 expectNotNullIfNoErrors(declaration);
1062 listener.assertErrorsWithCodes([ParserErrorCode.EMPTY_ENUM_BODY]); 1057 listener.assertErrorsWithCodes([ParserErrorCode.EMPTY_ENUM_BODY]);
1063 } 1058 }
1064 1059
1065 void test_enumInClass() { 1060 void test_enumInClass() {
1066 parseCompilationUnit( 1061 parseCompilationUnit(
1067 r''' 1062 r'''
1068 class Foo { 1063 class Foo {
1069 enum Bar { 1064 enum Bar {
1070 Bar1, Bar2, Bar3 1065 Bar1, Bar2, Bar3
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1112 1107
1113 void test_expectedExecutable_inClass_afterVoid() { 1108 void test_expectedExecutable_inClass_afterVoid() {
1114 createParser('void 2 void'); 1109 createParser('void 2 void');
1115 ClassMember member = parser.parseClassMember('C'); 1110 ClassMember member = parser.parseClassMember('C');
1116 expectNotNullIfNoErrors(member); 1111 expectNotNullIfNoErrors(member);
1117 listener.assertErrorsWithCodes([ParserErrorCode.EXPECTED_EXECUTABLE]); 1112 listener.assertErrorsWithCodes([ParserErrorCode.EXPECTED_EXECUTABLE]);
1118 } 1113 }
1119 1114
1120 void test_expectedExecutable_topLevel_afterType() { 1115 void test_expectedExecutable_topLevel_afterType() {
1121 createParser('heart 2 heart'); 1116 createParser('heart 2 heart');
1122 CompilationUnitMember member = 1117 CompilationUnitMember member = parseFullCompilationUnitMember();
1123 parser.parseCompilationUnitMember(emptyCommentAndMetadata());
1124 expectNotNullIfNoErrors(member); 1118 expectNotNullIfNoErrors(member);
1125 listener.assertErrorsWithCodes([ParserErrorCode.EXPECTED_EXECUTABLE]); 1119 listener.assertErrorsWithCodes([ParserErrorCode.EXPECTED_EXECUTABLE]);
1126 } 1120 }
1127 1121
1128 void test_expectedExecutable_topLevel_afterVoid() { 1122 void test_expectedExecutable_topLevel_afterVoid() {
1129 createParser('void 2 void'); 1123 createParser('void 2 void');
1130 CompilationUnitMember member = 1124 CompilationUnitMember member = parseFullCompilationUnitMember();
1131 parser.parseCompilationUnitMember(emptyCommentAndMetadata());
1132 expectNotNullIfNoErrors(member); 1125 expectNotNullIfNoErrors(member);
1133 listener.assertErrorsWithCodes([ParserErrorCode.EXPECTED_EXECUTABLE]); 1126 listener.assertErrorsWithCodes([ParserErrorCode.EXPECTED_EXECUTABLE]);
1134 } 1127 }
1135 1128
1136 void test_expectedExecutable_topLevel_beforeType() { 1129 void test_expectedExecutable_topLevel_beforeType() {
1137 createParser('4 score'); 1130 createParser('4 score');
1138 CompilationUnitMember member = 1131 CompilationUnitMember member = parseFullCompilationUnitMember();
1139 parser.parseCompilationUnitMember(emptyCommentAndMetadata());
1140 expectNotNullIfNoErrors(member); 1132 expectNotNullIfNoErrors(member);
1141 listener.assertErrorsWithCodes([ParserErrorCode.EXPECTED_EXECUTABLE]); 1133 listener.assertErrorsWithCodes([ParserErrorCode.EXPECTED_EXECUTABLE]);
1142 } 1134 }
1143 1135
1144 void test_expectedExecutable_topLevel_eof() { 1136 void test_expectedExecutable_topLevel_eof() {
1145 createParser('x'); 1137 createParser('x');
1146 CompilationUnitMember member = 1138 CompilationUnitMember member = parseFullCompilationUnitMember();
1147 parser.parseCompilationUnitMember(emptyCommentAndMetadata());
1148 expectNotNullIfNoErrors(member); 1139 expectNotNullIfNoErrors(member);
1149 listener.assertErrors( 1140 listener.assertErrors(
1150 [new AnalysisError(null, 0, 1, ParserErrorCode.EXPECTED_EXECUTABLE)]); 1141 [new AnalysisError(null, 0, 1, ParserErrorCode.EXPECTED_EXECUTABLE)]);
1151 } 1142 }
1152 1143
1153 void test_expectedInterpolationIdentifier() { 1144 void test_expectedInterpolationIdentifier() {
1154 createParser("'\$x\$'"); 1145 createParser("'\$x\$'");
1155 StringLiteral literal = parser.parseStringLiteral(); 1146 StringLiteral literal = parser.parseStringLiteral();
1156 expectNotNullIfNoErrors(literal); 1147 expectNotNullIfNoErrors(literal);
1157 listener.assertErrorsWithCodes([ParserErrorCode.MISSING_IDENTIFIER]); 1148 listener.assertErrorsWithCodes([ParserErrorCode.MISSING_IDENTIFIER]);
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after
1928 void test_missingConstFinalVarOrType_topLevel() { 1919 void test_missingConstFinalVarOrType_topLevel() {
1929 createParser('a;'); 1920 createParser('a;');
1930 FinalConstVarOrType result = parser.parseFinalConstVarOrType(false); 1921 FinalConstVarOrType result = parser.parseFinalConstVarOrType(false);
1931 expectNotNullIfNoErrors(result); 1922 expectNotNullIfNoErrors(result);
1932 listener.assertErrorsWithCodes( 1923 listener.assertErrorsWithCodes(
1933 [ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE]); 1924 [ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE]);
1934 } 1925 }
1935 1926
1936 void test_missingEnumBody() { 1927 void test_missingEnumBody() {
1937 createParser('enum E;'); 1928 createParser('enum E;');
1938 EnumDeclaration declaration = 1929 EnumDeclaration declaration = parseFullCompilationUnitMember();
1939 parser.parseEnumDeclaration(emptyCommentAndMetadata());
1940 expectNotNullIfNoErrors(declaration); 1930 expectNotNullIfNoErrors(declaration);
1941 listener.assertErrorsWithCodes([ParserErrorCode.MISSING_ENUM_BODY]); 1931 listener.assertErrorsWithCodes([ParserErrorCode.MISSING_ENUM_BODY]);
1942 } 1932 }
1943 1933
1944 void test_missingExpressionInThrow_withCascade() { 1934 void test_missingExpressionInThrow_withCascade() {
1945 createParser('throw;'); 1935 createParser('throw;');
1946 ThrowExpression expression = parser.parseThrowExpression(); 1936 ThrowExpression expression = parser.parseThrowExpression();
1947 expectNotNullIfNoErrors(expression); 1937 expectNotNullIfNoErrors(expression);
1948 listener 1938 listener
1949 .assertErrorsWithCodes([ParserErrorCode.MISSING_EXPRESSION_IN_THROW]); 1939 .assertErrorsWithCodes([ParserErrorCode.MISSING_EXPRESSION_IN_THROW]);
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
2035 void test_missingIdentifier_beforeClosingCurly() { 2025 void test_missingIdentifier_beforeClosingCurly() {
2036 createParser('int}'); 2026 createParser('int}');
2037 ClassMember member = parser.parseClassMember('C'); 2027 ClassMember member = parser.parseClassMember('C');
2038 expectNotNullIfNoErrors(member); 2028 expectNotNullIfNoErrors(member);
2039 listener.assertErrorsWithCodes( 2029 listener.assertErrorsWithCodes(
2040 [ParserErrorCode.MISSING_IDENTIFIER, ParserErrorCode.EXPECTED_TOKEN]); 2030 [ParserErrorCode.MISSING_IDENTIFIER, ParserErrorCode.EXPECTED_TOKEN]);
2041 } 2031 }
2042 2032
2043 void test_missingIdentifier_inEnum() { 2033 void test_missingIdentifier_inEnum() {
2044 createParser('enum E {, TWO}'); 2034 createParser('enum E {, TWO}');
2045 EnumDeclaration declaration = 2035 EnumDeclaration declaration = parseFullCompilationUnitMember();
2046 parser.parseEnumDeclaration(emptyCommentAndMetadata());
2047 expectNotNullIfNoErrors(declaration); 2036 expectNotNullIfNoErrors(declaration);
2048 listener.assertErrorsWithCodes([ParserErrorCode.MISSING_IDENTIFIER]); 2037 listener.assertErrorsWithCodes([ParserErrorCode.MISSING_IDENTIFIER]);
2049 } 2038 }
2050 2039
2051 void test_missingIdentifier_inSymbol_afterPeriod() { 2040 void test_missingIdentifier_inSymbol_afterPeriod() {
2052 createParser('#a.'); 2041 createParser('#a.');
2053 SymbolLiteral literal = parser.parseSymbolLiteral(); 2042 SymbolLiteral literal = parser.parseSymbolLiteral();
2054 expectNotNullIfNoErrors(literal); 2043 expectNotNullIfNoErrors(literal);
2055 listener.assertErrorsWithCodes([ParserErrorCode.MISSING_IDENTIFIER]); 2044 listener.assertErrorsWithCodes([ParserErrorCode.MISSING_IDENTIFIER]);
2056 } 2045 }
(...skipping 15 matching lines...) Expand all
2072 2061
2073 void test_missingIdentifierForParameterGroup() { 2062 void test_missingIdentifierForParameterGroup() {
2074 createParser('(,)'); 2063 createParser('(,)');
2075 FormalParameterList list = parser.parseFormalParameterList(); 2064 FormalParameterList list = parser.parseFormalParameterList();
2076 expectNotNullIfNoErrors(list); 2065 expectNotNullIfNoErrors(list);
2077 listener.assertErrorsWithCodes([ParserErrorCode.MISSING_IDENTIFIER]); 2066 listener.assertErrorsWithCodes([ParserErrorCode.MISSING_IDENTIFIER]);
2078 } 2067 }
2079 2068
2080 void test_missingKeywordOperator() { 2069 void test_missingKeywordOperator() {
2081 createParser('+(x) {}'); 2070 createParser('+(x) {}');
2082 MethodDeclaration method = 2071 MethodDeclaration method = parser.parseClassMember('C');
2083 parser.parseOperator(emptyCommentAndMetadata(), null, null);
2084 expectNotNullIfNoErrors(method); 2072 expectNotNullIfNoErrors(method);
2085 listener.assertErrorsWithCodes([ParserErrorCode.MISSING_KEYWORD_OPERATOR]); 2073 listener.assertErrorsWithCodes([ParserErrorCode.MISSING_KEYWORD_OPERATOR]);
2086 } 2074 }
2087 2075
2088 void test_missingKeywordOperator_parseClassMember() { 2076 void test_missingKeywordOperator_parseClassMember() {
2089 createParser('+() {}'); 2077 createParser('+() {}');
2090 ClassMember member = parser.parseClassMember('C'); 2078 ClassMember member = parser.parseClassMember('C');
2091 expectNotNullIfNoErrors(member); 2079 expectNotNullIfNoErrors(member);
2092 listener.assertErrorsWithCodes([ParserErrorCode.MISSING_KEYWORD_OPERATOR]); 2080 listener.assertErrorsWithCodes([ParserErrorCode.MISSING_KEYWORD_OPERATOR]);
2093 } 2081 }
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
2604 SwitchStatement statement = parser.parseSwitchStatement(); 2592 SwitchStatement statement = parser.parseSwitchStatement();
2605 expectNotNullIfNoErrors(statement); 2593 expectNotNullIfNoErrors(statement);
2606 listener.assertErrorsWithCodes([ 2594 listener.assertErrorsWithCodes([
2607 ParserErrorCode.SWITCH_HAS_MULTIPLE_DEFAULT_CASES, 2595 ParserErrorCode.SWITCH_HAS_MULTIPLE_DEFAULT_CASES,
2608 ParserErrorCode.SWITCH_HAS_MULTIPLE_DEFAULT_CASES 2596 ParserErrorCode.SWITCH_HAS_MULTIPLE_DEFAULT_CASES
2609 ]); 2597 ]);
2610 } 2598 }
2611 2599
2612 void test_topLevel_getter() { 2600 void test_topLevel_getter() {
2613 createParser('get x => 7;'); 2601 createParser('get x => 7;');
2614 CompilationUnitMember member = 2602 CompilationUnitMember member = parseFullCompilationUnitMember();
2615 parser.parseCompilationUnitMember(emptyCommentAndMetadata());
2616 expectNotNullIfNoErrors(member); 2603 expectNotNullIfNoErrors(member);
2617 listener.assertNoErrors(); 2604 listener.assertNoErrors();
2618 expect(member, new isInstanceOf<FunctionDeclaration>()); 2605 expect(member, new isInstanceOf<FunctionDeclaration>());
2619 FunctionDeclaration function = member; 2606 FunctionDeclaration function = member;
2620 expect(function.functionExpression.parameters, isNull); 2607 expect(function.functionExpression.parameters, isNull);
2621 } 2608 }
2622 2609
2623 void test_topLevelOperator_withoutType() { 2610 void test_topLevelOperator_withoutType() {
2624 createParser('operator +(bool x, bool y) => x | y;'); 2611 createParser('operator +(bool x, bool y) => x | y;');
2625 CompilationUnitMember member = 2612 CompilationUnitMember member = parseFullCompilationUnitMember();
2626 parser.parseCompilationUnitMember(emptyCommentAndMetadata());
2627 expectNotNullIfNoErrors(member); 2613 expectNotNullIfNoErrors(member);
2628 listener.assertErrorsWithCodes([ParserErrorCode.TOP_LEVEL_OPERATOR]); 2614 listener.assertErrorsWithCodes([ParserErrorCode.TOP_LEVEL_OPERATOR]);
2629 } 2615 }
2630 2616
2631 void test_topLevelOperator_withType() { 2617 void test_topLevelOperator_withType() {
2632 createParser('bool operator +(bool x, bool y) => x | y;'); 2618 createParser('bool operator +(bool x, bool y) => x | y;');
2633 CompilationUnitMember member = 2619 CompilationUnitMember member = parseFullCompilationUnitMember();
2634 parser.parseCompilationUnitMember(emptyCommentAndMetadata());
2635 expectNotNullIfNoErrors(member); 2620 expectNotNullIfNoErrors(member);
2636 listener.assertErrorsWithCodes([ParserErrorCode.TOP_LEVEL_OPERATOR]); 2621 listener.assertErrorsWithCodes([ParserErrorCode.TOP_LEVEL_OPERATOR]);
2637 } 2622 }
2638 2623
2639 void test_topLevelOperator_withVoid() { 2624 void test_topLevelOperator_withVoid() {
2640 createParser('void operator +(bool x, bool y) => x | y;'); 2625 createParser('void operator +(bool x, bool y) => x | y;');
2641 CompilationUnitMember member = 2626 CompilationUnitMember member = parseFullCompilationUnitMember();
2642 parser.parseCompilationUnitMember(emptyCommentAndMetadata());
2643 expectNotNullIfNoErrors(member); 2627 expectNotNullIfNoErrors(member);
2644 listener.assertErrorsWithCodes([ParserErrorCode.TOP_LEVEL_OPERATOR]); 2628 listener.assertErrorsWithCodes([ParserErrorCode.TOP_LEVEL_OPERATOR]);
2645 } 2629 }
2646 2630
2647 void test_topLevelVariable_withMetadata() { 2631 void test_topLevelVariable_withMetadata() {
2648 parseCompilationUnit("String @A string;", [ 2632 parseCompilationUnit("String @A string;", [
2649 ParserErrorCode.MISSING_IDENTIFIER, 2633 ParserErrorCode.MISSING_IDENTIFIER,
2650 ParserErrorCode.EXPECTED_TOKEN, 2634 ParserErrorCode.EXPECTED_TOKEN,
2651 ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE 2635 ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE
2652 ]); 2636 ]);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
2689 parseExpression("f()++", [ParserErrorCode.UNEXPECTED_TOKEN]); 2673 parseExpression("f()++", [ParserErrorCode.UNEXPECTED_TOKEN]);
2690 } 2674 }
2691 2675
2692 void test_unexpectedToken_returnInExpressionFuntionBody() { 2676 void test_unexpectedToken_returnInExpressionFuntionBody() {
2693 parseCompilationUnit( 2677 parseCompilationUnit(
2694 "f() => return null;", [ParserErrorCode.UNEXPECTED_TOKEN]); 2678 "f() => return null;", [ParserErrorCode.UNEXPECTED_TOKEN]);
2695 } 2679 }
2696 2680
2697 void test_unexpectedToken_semicolonBetweenClassMembers() { 2681 void test_unexpectedToken_semicolonBetweenClassMembers() {
2698 createParser('class C { int x; ; int y;}'); 2682 createParser('class C { int x; ; int y;}');
2699 ClassDeclaration declaration = 2683 ClassDeclaration declaration = parseFullCompilationUnitMember();
2700 parser.parseClassDeclaration(emptyCommentAndMetadata(), null);
2701 expectNotNullIfNoErrors(declaration); 2684 expectNotNullIfNoErrors(declaration);
2702 listener.assertErrorsWithCodes([ParserErrorCode.UNEXPECTED_TOKEN]); 2685 listener.assertErrorsWithCodes([ParserErrorCode.UNEXPECTED_TOKEN]);
2703 } 2686 }
2704 2687
2705 void test_unexpectedToken_semicolonBetweenCompilationUnitMembers() { 2688 void test_unexpectedToken_semicolonBetweenCompilationUnitMembers() {
2706 parseCompilationUnit("int x; ; int y;", [ParserErrorCode.UNEXPECTED_TOKEN]); 2689 parseCompilationUnit("int x; ; int y;", [ParserErrorCode.UNEXPECTED_TOKEN]);
2707 } 2690 }
2708 2691
2709 void test_unterminatedString_at_eof() { 2692 void test_unterminatedString_at_eof() {
2710 // Although the "unterminated string" error message is produced by the 2693 // Although the "unterminated string" error message is produced by the
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
2863 void test_voidVariable_parseCompilationUnit_initializer() { 2846 void test_voidVariable_parseCompilationUnit_initializer() {
2864 parseCompilationUnit("void x = 0;", [ParserErrorCode.VOID_VARIABLE]); 2847 parseCompilationUnit("void x = 0;", [ParserErrorCode.VOID_VARIABLE]);
2865 } 2848 }
2866 2849
2867 void test_voidVariable_parseCompilationUnit_noInitializer() { 2850 void test_voidVariable_parseCompilationUnit_noInitializer() {
2868 parseCompilationUnit("void x;", [ParserErrorCode.VOID_VARIABLE]); 2851 parseCompilationUnit("void x;", [ParserErrorCode.VOID_VARIABLE]);
2869 } 2852 }
2870 2853
2871 void test_voidVariable_parseCompilationUnitMember_initializer() { 2854 void test_voidVariable_parseCompilationUnitMember_initializer() {
2872 createParser('void a = 0;'); 2855 createParser('void a = 0;');
2873 CompilationUnitMember member = 2856 CompilationUnitMember member = parseFullCompilationUnitMember();
2874 parser.parseCompilationUnitMember(emptyCommentAndMetadata());
2875 expectNotNullIfNoErrors(member); 2857 expectNotNullIfNoErrors(member);
2876 listener.assertErrorsWithCodes([ParserErrorCode.VOID_VARIABLE]); 2858 listener.assertErrorsWithCodes([ParserErrorCode.VOID_VARIABLE]);
2877 } 2859 }
2878 2860
2879 void test_voidVariable_parseCompilationUnitMember_noInitializer() { 2861 void test_voidVariable_parseCompilationUnitMember_noInitializer() {
2880 createParser('void a;'); 2862 createParser('void a;');
2881 CompilationUnitMember member = 2863 CompilationUnitMember member = parseFullCompilationUnitMember();
2882 parser.parseCompilationUnitMember(emptyCommentAndMetadata());
2883 expectNotNullIfNoErrors(member); 2864 expectNotNullIfNoErrors(member);
2884 listener.assertErrorsWithCodes([ParserErrorCode.VOID_VARIABLE]); 2865 listener.assertErrorsWithCodes([ParserErrorCode.VOID_VARIABLE]);
2885 } 2866 }
2886 2867
2887 void test_voidVariable_statement_initializer() { 2868 void test_voidVariable_statement_initializer() {
2888 parseStatement("void x = 0;", [ 2869 parseStatement("void x = 0;", [
2889 ParserErrorCode.VOID_VARIABLE, 2870 ParserErrorCode.VOID_VARIABLE,
2890 ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE 2871 ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE
2891 ]); 2872 ]);
2892 } 2873 }
2893 2874
2894 void test_voidVariable_statement_noInitializer() { 2875 void test_voidVariable_statement_noInitializer() {
2895 parseStatement("void x;", [ 2876 parseStatement("void x;", [
2896 ParserErrorCode.VOID_VARIABLE, 2877 ParserErrorCode.VOID_VARIABLE,
2897 ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE 2878 ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE
2898 ]); 2879 ]);
2899 } 2880 }
2900 2881
2901 void test_withBeforeExtends() { 2882 void test_withBeforeExtends() {
2902 parseCompilationUnit( 2883 parseCompilationUnit(
2903 "class A with B extends C {}", [ParserErrorCode.WITH_BEFORE_EXTENDS]); 2884 "class A with B extends C {}", [ParserErrorCode.WITH_BEFORE_EXTENDS]);
2904 } 2885 }
2905 2886
2906 void test_withWithoutExtends() { 2887 void test_withWithoutExtends() {
2907 createParser('class A with B, C {}'); 2888 createParser('class A with B, C {}');
2908 ClassDeclaration declaration = 2889 ClassDeclaration declaration = parseFullCompilationUnitMember();
2909 parser.parseClassDeclaration(emptyCommentAndMetadata(), null);
2910 expectNotNullIfNoErrors(declaration); 2890 expectNotNullIfNoErrors(declaration);
2911 listener.assertErrorsWithCodes([ParserErrorCode.WITH_WITHOUT_EXTENDS]); 2891 listener.assertErrorsWithCodes([ParserErrorCode.WITH_WITHOUT_EXTENDS]);
2912 } 2892 }
2913 2893
2914 void test_wrongSeparatorForPositionalParameter() { 2894 void test_wrongSeparatorForPositionalParameter() {
2915 createParser('(a, [b : 0])'); 2895 createParser('(a, [b : 0])');
2916 FormalParameterList list = parser.parseFormalParameterList(); 2896 FormalParameterList list = parser.parseFormalParameterList();
2917 expectNotNullIfNoErrors(list); 2897 expectNotNullIfNoErrors(list);
2918 listener.assertErrorsWithCodes( 2898 listener.assertErrorsWithCodes(
2919 [ParserErrorCode.WRONG_SEPARATOR_FOR_POSITIONAL_PARAMETER]); 2899 [ParserErrorCode.WRONG_SEPARATOR_FOR_POSITIONAL_PARAMETER]);
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
3049 // 3029 //
3050 parser = new Parser(source, listener); 3030 parser = new Parser(source, listener);
3051 parser.enableAssertInitializer = enableAssertInitializer; 3031 parser.enableAssertInitializer = enableAssertInitializer;
3052 parser.parseGenericMethodComments = enableGenericMethodComments; 3032 parser.parseGenericMethodComments = enableGenericMethodComments;
3053 parser.parseFunctionBodies = parseFunctionBodies; 3033 parser.parseFunctionBodies = parseFunctionBodies;
3054 parser.enableNnbd = enableNnbd; 3034 parser.enableNnbd = enableNnbd;
3055 parser.enableUriInPartOf = enableUriInPartOf; 3035 parser.enableUriInPartOf = enableUriInPartOf;
3056 parser.currentToken = tokenStream; 3036 parser.currentToken = tokenStream;
3057 } 3037 }
3058 3038
3059 /**
3060 * Return an empty CommentAndMetadata object that can be used for testing.
3061 *
3062 * @return an empty CommentAndMetadata object that can be used for testing
3063 */
3064 CommentAndMetadata emptyCommentAndMetadata() =>
3065 new CommentAndMetadata(null, null);
3066
3067 void expectNotNullIfNoErrors(Object result) { 3039 void expectNotNullIfNoErrors(Object result) {
3068 if (!listener.hasErrors) { 3040 if (!listener.hasErrors) {
3069 expect(result, isNotNull); 3041 expect(result, isNotNull);
3070 } 3042 }
3071 } 3043 }
3072 3044
3073 /** 3045 /**
3074 * Parse the given source as a compilation unit. 3046 * Parse the given source as a compilation unit.
3075 * 3047 *
3076 * @param source the source to be parsed 3048 * @param source the source to be parsed
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
3133 Expression parseExpression(String source, 3105 Expression parseExpression(String source,
3134 [List<ErrorCode> errorCodes = const <ErrorCode>[]]) { 3106 [List<ErrorCode> errorCodes = const <ErrorCode>[]]) {
3135 createParser(source); 3107 createParser(source);
3136 Expression expression = parser.parseExpression2(); 3108 Expression expression = parser.parseExpression2();
3137 expectNotNullIfNoErrors(expression); 3109 expectNotNullIfNoErrors(expression);
3138 listener.assertErrorsWithCodes(errorCodes); 3110 listener.assertErrorsWithCodes(errorCodes);
3139 return expression; 3111 return expression;
3140 } 3112 }
3141 3113
3142 /** 3114 /**
3115 * Parses a single top level member of a compilation unit (other than a
3116 * directive), including any comment and/or metadata that precedes it.
3117 */
3118 CompilationUnitMember parseFullCompilationUnitMember() =>
3119 parser.parseCompilationUnitMember(parser.parseCommentAndMetadata());
3120
3121 /**
3122 * Parses a single top level directive, including any comment and/or metadata
3123 * that precedes it.
3124 */
3125 Directive parseFullDirective() =>
3126 parser.parseDirective(parser.parseCommentAndMetadata());
3127
3128 /**
3129 * Parses a variable declaration list (equivalent to a variable declaration
3130 * statement, but without the final comma).
3131 */
3132 VariableDeclarationList parseFullVariableDeclarationList() =>
3133 parser.parseVariableDeclarationListAfterMetadata(
3134 parser.parseCommentAndMetadata());
3135
3136 /**
3143 * Parse the given [source] as a statement. The [errorCodes] are the error 3137 * Parse the given [source] as a statement. The [errorCodes] are the error
3144 * codes of the errors that are expected to be found. If 3138 * codes of the errors that are expected to be found. If
3145 * [enableLazyAssignmentOperators] is `true`, then lazy assignment operators 3139 * [enableLazyAssignmentOperators] is `true`, then lazy assignment operators
3146 * should be enabled. 3140 * should be enabled.
3147 */ 3141 */
3148 Statement parseStatement(String source, 3142 Statement parseStatement(String source,
3149 [List<ErrorCode> errorCodes = const <ErrorCode>[], 3143 [List<ErrorCode> errorCodes = const <ErrorCode>[],
3150 bool enableLazyAssignmentOperators]) { 3144 bool enableLazyAssignmentOperators]) {
3151 GatheringErrorListener listener = new GatheringErrorListener(); 3145 GatheringErrorListener listener = new GatheringErrorListener();
3152 Scanner scanner = 3146 Scanner scanner =
(...skipping 2593 matching lines...) Expand 10 before | Expand all | Expand 10 after
5746 expectNotNullIfNoErrors(expression); 5740 expectNotNullIfNoErrors(expression);
5747 listener.assertNoErrors(); 5741 listener.assertNoErrors();
5748 expect(expression, new isInstanceOf<PropertyAccess>()); 5742 expect(expression, new isInstanceOf<PropertyAccess>());
5749 PropertyAccess section = expression; 5743 PropertyAccess section = expression;
5750 expect(section.target, isNotNull); 5744 expect(section.target, isNotNull);
5751 expect(section.operator, isNotNull); 5745 expect(section.operator, isNotNull);
5752 expect(section.propertyName, isNotNull); 5746 expect(section.propertyName, isNotNull);
5753 } 5747 }
5754 5748
5755 void test_parseClassDeclaration_abstract() { 5749 void test_parseClassDeclaration_abstract() {
5756 createParser('class A {}'); 5750 createParser('abstract class A {}');
5757 CompilationUnitMember member = parser.parseClassDeclaration( 5751 CompilationUnitMember member = parseFullCompilationUnitMember();
5758 emptyCommentAndMetadata(),
5759 TokenFactory.tokenFromKeyword(Keyword.ABSTRACT));
5760 expectNotNullIfNoErrors(member); 5752 expectNotNullIfNoErrors(member);
5761 listener.assertNoErrors(); 5753 listener.assertNoErrors();
5762 expect(member, new isInstanceOf<ClassDeclaration>()); 5754 expect(member, new isInstanceOf<ClassDeclaration>());
5763 ClassDeclaration declaration = member; 5755 ClassDeclaration declaration = member;
5764 expect(declaration.documentationComment, isNull); 5756 expect(declaration.documentationComment, isNull);
5765 expect(declaration.abstractKeyword, isNotNull); 5757 expect(declaration.abstractKeyword, isNotNull);
5766 expect(declaration.extendsClause, isNull); 5758 expect(declaration.extendsClause, isNull);
5767 expect(declaration.implementsClause, isNull); 5759 expect(declaration.implementsClause, isNull);
5768 expect(declaration.classKeyword, isNotNull); 5760 expect(declaration.classKeyword, isNotNull);
5769 expect(declaration.leftBracket, isNotNull); 5761 expect(declaration.leftBracket, isNotNull);
5770 expect(declaration.name, isNotNull); 5762 expect(declaration.name, isNotNull);
5771 expect(declaration.members, hasLength(0)); 5763 expect(declaration.members, hasLength(0));
5772 expect(declaration.rightBracket, isNotNull); 5764 expect(declaration.rightBracket, isNotNull);
5773 expect(declaration.typeParameters, isNull); 5765 expect(declaration.typeParameters, isNull);
5774 } 5766 }
5775 5767
5776 void test_parseClassDeclaration_empty() { 5768 void test_parseClassDeclaration_empty() {
5777 createParser('class A {}'); 5769 createParser('class A {}');
5778 CompilationUnitMember member = 5770 CompilationUnitMember member = parseFullCompilationUnitMember();
5779 parser.parseClassDeclaration(emptyCommentAndMetadata(), null);
5780 expectNotNullIfNoErrors(member); 5771 expectNotNullIfNoErrors(member);
5781 listener.assertNoErrors(); 5772 listener.assertNoErrors();
5782 expect(member, new isInstanceOf<ClassDeclaration>()); 5773 expect(member, new isInstanceOf<ClassDeclaration>());
5783 ClassDeclaration declaration = member; 5774 ClassDeclaration declaration = member;
5784 expect(declaration.documentationComment, isNull); 5775 expect(declaration.documentationComment, isNull);
5785 expect(declaration.abstractKeyword, isNull); 5776 expect(declaration.abstractKeyword, isNull);
5786 expect(declaration.extendsClause, isNull); 5777 expect(declaration.extendsClause, isNull);
5787 expect(declaration.implementsClause, isNull); 5778 expect(declaration.implementsClause, isNull);
5788 expect(declaration.classKeyword, isNotNull); 5779 expect(declaration.classKeyword, isNotNull);
5789 expect(declaration.leftBracket, isNotNull); 5780 expect(declaration.leftBracket, isNotNull);
5790 expect(declaration.name, isNotNull); 5781 expect(declaration.name, isNotNull);
5791 expect(declaration.members, hasLength(0)); 5782 expect(declaration.members, hasLength(0));
5792 expect(declaration.rightBracket, isNotNull); 5783 expect(declaration.rightBracket, isNotNull);
5793 expect(declaration.typeParameters, isNull); 5784 expect(declaration.typeParameters, isNull);
5794 } 5785 }
5795 5786
5796 void test_parseClassDeclaration_extends() { 5787 void test_parseClassDeclaration_extends() {
5797 createParser('class A extends B {}'); 5788 createParser('class A extends B {}');
5798 CompilationUnitMember member = 5789 CompilationUnitMember member = parseFullCompilationUnitMember();
5799 parser.parseClassDeclaration(emptyCommentAndMetadata(), null);
5800 expectNotNullIfNoErrors(member); 5790 expectNotNullIfNoErrors(member);
5801 listener.assertNoErrors(); 5791 listener.assertNoErrors();
5802 expect(member, new isInstanceOf<ClassDeclaration>()); 5792 expect(member, new isInstanceOf<ClassDeclaration>());
5803 ClassDeclaration declaration = member; 5793 ClassDeclaration declaration = member;
5804 expect(declaration.documentationComment, isNull); 5794 expect(declaration.documentationComment, isNull);
5805 expect(declaration.abstractKeyword, isNull); 5795 expect(declaration.abstractKeyword, isNull);
5806 expect(declaration.extendsClause, isNotNull); 5796 expect(declaration.extendsClause, isNotNull);
5807 expect(declaration.implementsClause, isNull); 5797 expect(declaration.implementsClause, isNull);
5808 expect(declaration.classKeyword, isNotNull); 5798 expect(declaration.classKeyword, isNotNull);
5809 expect(declaration.leftBracket, isNotNull); 5799 expect(declaration.leftBracket, isNotNull);
5810 expect(declaration.name, isNotNull); 5800 expect(declaration.name, isNotNull);
5811 expect(declaration.members, hasLength(0)); 5801 expect(declaration.members, hasLength(0));
5812 expect(declaration.rightBracket, isNotNull); 5802 expect(declaration.rightBracket, isNotNull);
5813 expect(declaration.typeParameters, isNull); 5803 expect(declaration.typeParameters, isNull);
5814 } 5804 }
5815 5805
5816 void test_parseClassDeclaration_extendsAndImplements() { 5806 void test_parseClassDeclaration_extendsAndImplements() {
5817 createParser('class A extends B implements C {}'); 5807 createParser('class A extends B implements C {}');
5818 CompilationUnitMember member = 5808 CompilationUnitMember member = parseFullCompilationUnitMember();
5819 parser.parseClassDeclaration(emptyCommentAndMetadata(), null);
5820 expectNotNullIfNoErrors(member); 5809 expectNotNullIfNoErrors(member);
5821 listener.assertNoErrors(); 5810 listener.assertNoErrors();
5822 expect(member, new isInstanceOf<ClassDeclaration>()); 5811 expect(member, new isInstanceOf<ClassDeclaration>());
5823 ClassDeclaration declaration = member; 5812 ClassDeclaration declaration = member;
5824 expect(declaration.documentationComment, isNull); 5813 expect(declaration.documentationComment, isNull);
5825 expect(declaration.abstractKeyword, isNull); 5814 expect(declaration.abstractKeyword, isNull);
5826 expect(declaration.extendsClause, isNotNull); 5815 expect(declaration.extendsClause, isNotNull);
5827 expect(declaration.implementsClause, isNotNull); 5816 expect(declaration.implementsClause, isNotNull);
5828 expect(declaration.classKeyword, isNotNull); 5817 expect(declaration.classKeyword, isNotNull);
5829 expect(declaration.leftBracket, isNotNull); 5818 expect(declaration.leftBracket, isNotNull);
5830 expect(declaration.name, isNotNull); 5819 expect(declaration.name, isNotNull);
5831 expect(declaration.members, hasLength(0)); 5820 expect(declaration.members, hasLength(0));
5832 expect(declaration.rightBracket, isNotNull); 5821 expect(declaration.rightBracket, isNotNull);
5833 expect(declaration.typeParameters, isNull); 5822 expect(declaration.typeParameters, isNull);
5834 } 5823 }
5835 5824
5836 void test_parseClassDeclaration_extendsAndWith() { 5825 void test_parseClassDeclaration_extendsAndWith() {
5837 createParser('class A extends B with C {}'); 5826 createParser('class A extends B with C {}');
5838 CompilationUnitMember member = 5827 CompilationUnitMember member = parseFullCompilationUnitMember();
5839 parser.parseClassDeclaration(emptyCommentAndMetadata(), null);
5840 expectNotNullIfNoErrors(member); 5828 expectNotNullIfNoErrors(member);
5841 listener.assertNoErrors(); 5829 listener.assertNoErrors();
5842 expect(member, new isInstanceOf<ClassDeclaration>()); 5830 expect(member, new isInstanceOf<ClassDeclaration>());
5843 ClassDeclaration declaration = member; 5831 ClassDeclaration declaration = member;
5844 expect(declaration.documentationComment, isNull); 5832 expect(declaration.documentationComment, isNull);
5845 expect(declaration.abstractKeyword, isNull); 5833 expect(declaration.abstractKeyword, isNull);
5846 expect(declaration.classKeyword, isNotNull); 5834 expect(declaration.classKeyword, isNotNull);
5847 expect(declaration.name, isNotNull); 5835 expect(declaration.name, isNotNull);
5848 expect(declaration.typeParameters, isNull); 5836 expect(declaration.typeParameters, isNull);
5849 expect(declaration.extendsClause, isNotNull); 5837 expect(declaration.extendsClause, isNotNull);
5850 expect(declaration.withClause, isNotNull); 5838 expect(declaration.withClause, isNotNull);
5851 expect(declaration.implementsClause, isNull); 5839 expect(declaration.implementsClause, isNull);
5852 expect(declaration.leftBracket, isNotNull); 5840 expect(declaration.leftBracket, isNotNull);
5853 expect(declaration.members, hasLength(0)); 5841 expect(declaration.members, hasLength(0));
5854 expect(declaration.rightBracket, isNotNull); 5842 expect(declaration.rightBracket, isNotNull);
5855 } 5843 }
5856 5844
5857 void test_parseClassDeclaration_extendsAndWithAndImplements() { 5845 void test_parseClassDeclaration_extendsAndWithAndImplements() {
5858 createParser('class A extends B with C implements D {}'); 5846 createParser('class A extends B with C implements D {}');
5859 CompilationUnitMember member = 5847 CompilationUnitMember member = parseFullCompilationUnitMember();
5860 parser.parseClassDeclaration(emptyCommentAndMetadata(), null);
5861 expectNotNullIfNoErrors(member); 5848 expectNotNullIfNoErrors(member);
5862 listener.assertNoErrors(); 5849 listener.assertNoErrors();
5863 expect(member, new isInstanceOf<ClassDeclaration>()); 5850 expect(member, new isInstanceOf<ClassDeclaration>());
5864 ClassDeclaration declaration = member; 5851 ClassDeclaration declaration = member;
5865 expect(declaration.documentationComment, isNull); 5852 expect(declaration.documentationComment, isNull);
5866 expect(declaration.abstractKeyword, isNull); 5853 expect(declaration.abstractKeyword, isNull);
5867 expect(declaration.classKeyword, isNotNull); 5854 expect(declaration.classKeyword, isNotNull);
5868 expect(declaration.name, isNotNull); 5855 expect(declaration.name, isNotNull);
5869 expect(declaration.typeParameters, isNull); 5856 expect(declaration.typeParameters, isNull);
5870 expect(declaration.extendsClause, isNotNull); 5857 expect(declaration.extendsClause, isNotNull);
5871 expect(declaration.withClause, isNotNull); 5858 expect(declaration.withClause, isNotNull);
5872 expect(declaration.implementsClause, isNotNull); 5859 expect(declaration.implementsClause, isNotNull);
5873 expect(declaration.leftBracket, isNotNull); 5860 expect(declaration.leftBracket, isNotNull);
5874 expect(declaration.members, hasLength(0)); 5861 expect(declaration.members, hasLength(0));
5875 expect(declaration.rightBracket, isNotNull); 5862 expect(declaration.rightBracket, isNotNull);
5876 } 5863 }
5877 5864
5878 void test_parseClassDeclaration_implements() { 5865 void test_parseClassDeclaration_implements() {
5879 createParser('class A implements C {}'); 5866 createParser('class A implements C {}');
5880 CompilationUnitMember member = 5867 CompilationUnitMember member = parseFullCompilationUnitMember();
5881 parser.parseClassDeclaration(emptyCommentAndMetadata(), null);
5882 expectNotNullIfNoErrors(member); 5868 expectNotNullIfNoErrors(member);
5883 listener.assertNoErrors(); 5869 listener.assertNoErrors();
5884 expect(member, new isInstanceOf<ClassDeclaration>()); 5870 expect(member, new isInstanceOf<ClassDeclaration>());
5885 ClassDeclaration declaration = member; 5871 ClassDeclaration declaration = member;
5886 expect(declaration.documentationComment, isNull); 5872 expect(declaration.documentationComment, isNull);
5887 expect(declaration.abstractKeyword, isNull); 5873 expect(declaration.abstractKeyword, isNull);
5888 expect(declaration.extendsClause, isNull); 5874 expect(declaration.extendsClause, isNull);
5889 expect(declaration.implementsClause, isNotNull); 5875 expect(declaration.implementsClause, isNotNull);
5890 expect(declaration.classKeyword, isNotNull); 5876 expect(declaration.classKeyword, isNotNull);
5891 expect(declaration.leftBracket, isNotNull); 5877 expect(declaration.leftBracket, isNotNull);
5892 expect(declaration.name, isNotNull); 5878 expect(declaration.name, isNotNull);
5893 expect(declaration.members, hasLength(0)); 5879 expect(declaration.members, hasLength(0));
5894 expect(declaration.rightBracket, isNotNull); 5880 expect(declaration.rightBracket, isNotNull);
5895 expect(declaration.typeParameters, isNull); 5881 expect(declaration.typeParameters, isNull);
5896 } 5882 }
5897 5883
5898 void test_parseClassDeclaration_native() { 5884 void test_parseClassDeclaration_native() {
5899 createParser('class A native "nativeValue" {}'); 5885 createParser('class A native "nativeValue" {}');
5900 CompilationUnitMember member = 5886 CompilationUnitMember member = parseFullCompilationUnitMember();
5901 parser.parseClassDeclaration(emptyCommentAndMetadata(), null);
5902 expectNotNullIfNoErrors(member); 5887 expectNotNullIfNoErrors(member);
5903 listener.assertNoErrors(); 5888 listener.assertNoErrors();
5904 expect(member, new isInstanceOf<ClassDeclaration>()); 5889 expect(member, new isInstanceOf<ClassDeclaration>());
5905 ClassDeclaration declaration = member; 5890 ClassDeclaration declaration = member;
5906 NativeClause nativeClause = declaration.nativeClause; 5891 NativeClause nativeClause = declaration.nativeClause;
5907 expect(nativeClause, isNotNull); 5892 expect(nativeClause, isNotNull);
5908 expect(nativeClause.nativeKeyword, isNotNull); 5893 expect(nativeClause.nativeKeyword, isNotNull);
5909 expect(nativeClause.name.stringValue, "nativeValue"); 5894 expect(nativeClause.name.stringValue, "nativeValue");
5910 expect(nativeClause.beginToken, same(nativeClause.nativeKeyword)); 5895 expect(nativeClause.beginToken, same(nativeClause.nativeKeyword));
5911 expect(nativeClause.endToken, same(nativeClause.name.endToken)); 5896 expect(nativeClause.endToken, same(nativeClause.name.endToken));
5912 } 5897 }
5913 5898
5914 void test_parseClassDeclaration_nonEmpty() { 5899 void test_parseClassDeclaration_nonEmpty() {
5915 createParser('class A {var f;}'); 5900 createParser('class A {var f;}');
5916 CompilationUnitMember member = 5901 CompilationUnitMember member = parseFullCompilationUnitMember();
5917 parser.parseClassDeclaration(emptyCommentAndMetadata(), null);
5918 expectNotNullIfNoErrors(member); 5902 expectNotNullIfNoErrors(member);
5919 listener.assertNoErrors(); 5903 listener.assertNoErrors();
5920 expect(member, new isInstanceOf<ClassDeclaration>()); 5904 expect(member, new isInstanceOf<ClassDeclaration>());
5921 ClassDeclaration declaration = member; 5905 ClassDeclaration declaration = member;
5922 expect(declaration.documentationComment, isNull); 5906 expect(declaration.documentationComment, isNull);
5923 expect(declaration.abstractKeyword, isNull); 5907 expect(declaration.abstractKeyword, isNull);
5924 expect(declaration.extendsClause, isNull); 5908 expect(declaration.extendsClause, isNull);
5925 expect(declaration.implementsClause, isNull); 5909 expect(declaration.implementsClause, isNull);
5926 expect(declaration.classKeyword, isNotNull); 5910 expect(declaration.classKeyword, isNotNull);
5927 expect(declaration.leftBracket, isNotNull); 5911 expect(declaration.leftBracket, isNotNull);
5928 expect(declaration.name, isNotNull); 5912 expect(declaration.name, isNotNull);
5929 expect(declaration.members, hasLength(1)); 5913 expect(declaration.members, hasLength(1));
5930 expect(declaration.rightBracket, isNotNull); 5914 expect(declaration.rightBracket, isNotNull);
5931 expect(declaration.typeParameters, isNull); 5915 expect(declaration.typeParameters, isNull);
5932 } 5916 }
5933 5917
5934 void test_parseClassDeclaration_typeAlias_implementsC() { 5918 void test_parseClassDeclaration_typeAlias_implementsC() {
5935 createParser('class A = Object with B implements C;'); 5919 createParser('class A = Object with B implements C;');
5936 CompilationUnitMember member = 5920 CompilationUnitMember member = parseFullCompilationUnitMember();
5937 parser.parseClassDeclaration(emptyCommentAndMetadata(), null);
5938 expectNotNullIfNoErrors(member); 5921 expectNotNullIfNoErrors(member);
5939 listener.assertNoErrors(); 5922 listener.assertNoErrors();
5940 expect(member, new isInstanceOf<ClassTypeAlias>()); 5923 expect(member, new isInstanceOf<ClassTypeAlias>());
5941 ClassTypeAlias typeAlias = member; 5924 ClassTypeAlias typeAlias = member;
5942 expect(typeAlias.typedefKeyword, isNotNull); 5925 expect(typeAlias.typedefKeyword, isNotNull);
5943 expect(typeAlias.name, isNotNull); 5926 expect(typeAlias.name, isNotNull);
5944 expect(typeAlias.typeParameters, isNull); 5927 expect(typeAlias.typeParameters, isNull);
5945 expect(typeAlias.withClause, isNotNull); 5928 expect(typeAlias.withClause, isNotNull);
5946 expect(typeAlias.implementsClause, isNotNull); 5929 expect(typeAlias.implementsClause, isNotNull);
5947 expect(typeAlias.implementsClause.implementsKeyword, isNotNull); 5930 expect(typeAlias.implementsClause.implementsKeyword, isNotNull);
5948 expect(typeAlias.implementsClause.interfaces.length, 1); 5931 expect(typeAlias.implementsClause.interfaces.length, 1);
5949 expect(typeAlias.semicolon, isNotNull); 5932 expect(typeAlias.semicolon, isNotNull);
5950 } 5933 }
5951 5934
5952 void test_parseClassDeclaration_typeAlias_withB() { 5935 void test_parseClassDeclaration_typeAlias_withB() {
5953 createParser('class A = Object with B;'); 5936 createParser('class A = Object with B;');
5954 CompilationUnitMember member = 5937 CompilationUnitMember member = parseFullCompilationUnitMember();
5955 parser.parseClassDeclaration(emptyCommentAndMetadata(), null);
5956 expectNotNullIfNoErrors(member); 5938 expectNotNullIfNoErrors(member);
5957 listener.assertNoErrors(); 5939 listener.assertNoErrors();
5958 expect(member, new isInstanceOf<ClassTypeAlias>()); 5940 expect(member, new isInstanceOf<ClassTypeAlias>());
5959 ClassTypeAlias typeAlias = member; 5941 ClassTypeAlias typeAlias = member;
5960 expect(typeAlias.typedefKeyword, isNotNull); 5942 expect(typeAlias.typedefKeyword, isNotNull);
5961 expect(typeAlias.name, isNotNull); 5943 expect(typeAlias.name, isNotNull);
5962 expect(typeAlias.typeParameters, isNull); 5944 expect(typeAlias.typeParameters, isNull);
5963 expect(typeAlias.withClause, isNotNull); 5945 expect(typeAlias.withClause, isNotNull);
5964 expect(typeAlias.withClause.withKeyword, isNotNull); 5946 expect(typeAlias.withClause.withKeyword, isNotNull);
5965 expect(typeAlias.withClause.mixinTypes.length, 1); 5947 expect(typeAlias.withClause.mixinTypes.length, 1);
5966 expect(typeAlias.implementsClause, isNull); 5948 expect(typeAlias.implementsClause, isNull);
5967 expect(typeAlias.semicolon, isNotNull); 5949 expect(typeAlias.semicolon, isNotNull);
5968 } 5950 }
5969 5951
5970 void test_parseClassDeclaration_typeParameters() { 5952 void test_parseClassDeclaration_typeParameters() {
5971 createParser('class A<B> {}'); 5953 createParser('class A<B> {}');
5972 CompilationUnitMember member = 5954 CompilationUnitMember member = parseFullCompilationUnitMember();
5973 parser.parseClassDeclaration(emptyCommentAndMetadata(), null);
5974 expectNotNullIfNoErrors(member); 5955 expectNotNullIfNoErrors(member);
5975 listener.assertNoErrors(); 5956 listener.assertNoErrors();
5976 expect(member, new isInstanceOf<ClassDeclaration>()); 5957 expect(member, new isInstanceOf<ClassDeclaration>());
5977 ClassDeclaration declaration = member; 5958 ClassDeclaration declaration = member;
5978 expect(declaration.documentationComment, isNull); 5959 expect(declaration.documentationComment, isNull);
5979 expect(declaration.abstractKeyword, isNull); 5960 expect(declaration.abstractKeyword, isNull);
5980 expect(declaration.extendsClause, isNull); 5961 expect(declaration.extendsClause, isNull);
5981 expect(declaration.implementsClause, isNull); 5962 expect(declaration.implementsClause, isNull);
5982 expect(declaration.classKeyword, isNotNull); 5963 expect(declaration.classKeyword, isNotNull);
5983 expect(declaration.leftBracket, isNotNull); 5964 expect(declaration.leftBracket, isNotNull);
(...skipping 1430 matching lines...) Expand 10 before | Expand all | Expand 10 after
7414 CompilationUnit unit = parser.parseCompilationUnit2(); 7395 CompilationUnit unit = parser.parseCompilationUnit2();
7415 expectNotNullIfNoErrors(unit); 7396 expectNotNullIfNoErrors(unit);
7416 listener.assertNoErrors(); 7397 listener.assertNoErrors();
7417 expect(unit.scriptTag, isNull); 7398 expect(unit.scriptTag, isNull);
7418 expect(unit.directives, hasLength(0)); 7399 expect(unit.directives, hasLength(0));
7419 expect(unit.declarations, hasLength(1)); 7400 expect(unit.declarations, hasLength(1));
7420 } 7401 }
7421 7402
7422 void test_parseCompilationUnitMember_abstractAsPrefix() { 7403 void test_parseCompilationUnitMember_abstractAsPrefix() {
7423 createParser('abstract.A _abstract = new abstract.A();'); 7404 createParser('abstract.A _abstract = new abstract.A();');
7424 CompilationUnitMember member = 7405 CompilationUnitMember member = parseFullCompilationUnitMember();
7425 parser.parseCompilationUnitMember(emptyCommentAndMetadata());
7426 expectNotNullIfNoErrors(member); 7406 expectNotNullIfNoErrors(member);
7427 listener.assertNoErrors(); 7407 listener.assertNoErrors();
7428 expect(member, new isInstanceOf<TopLevelVariableDeclaration>()); 7408 expect(member, new isInstanceOf<TopLevelVariableDeclaration>());
7429 TopLevelVariableDeclaration declaration = member; 7409 TopLevelVariableDeclaration declaration = member;
7430 expect(declaration.semicolon, isNotNull); 7410 expect(declaration.semicolon, isNotNull);
7431 expect(declaration.variables, isNotNull); 7411 expect(declaration.variables, isNotNull);
7432 } 7412 }
7433 7413
7434 void test_parseCompilationUnitMember_class() { 7414 void test_parseCompilationUnitMember_class() {
7435 createParser('class A {}'); 7415 createParser('class A {}');
7436 CompilationUnitMember member = 7416 CompilationUnitMember member = parseFullCompilationUnitMember();
7437 parser.parseCompilationUnitMember(emptyCommentAndMetadata());
7438 expectNotNullIfNoErrors(member); 7417 expectNotNullIfNoErrors(member);
7439 listener.assertNoErrors(); 7418 listener.assertNoErrors();
7440 expect(member, new isInstanceOf<ClassDeclaration>()); 7419 expect(member, new isInstanceOf<ClassDeclaration>());
7441 ClassDeclaration declaration = member; 7420 ClassDeclaration declaration = member;
7442 expect(declaration.name.name, "A"); 7421 expect(declaration.name.name, "A");
7443 expect(declaration.members, hasLength(0)); 7422 expect(declaration.members, hasLength(0));
7444 } 7423 }
7445 7424
7446 void test_parseCompilationUnitMember_classTypeAlias() { 7425 void test_parseCompilationUnitMember_classTypeAlias() {
7447 createParser('abstract class A = B with C;'); 7426 createParser('abstract class A = B with C;');
7448 CompilationUnitMember member = 7427 CompilationUnitMember member = parseFullCompilationUnitMember();
7449 parser.parseCompilationUnitMember(emptyCommentAndMetadata());
7450 expectNotNullIfNoErrors(member); 7428 expectNotNullIfNoErrors(member);
7451 listener.assertNoErrors(); 7429 listener.assertNoErrors();
7452 expect(member, new isInstanceOf<ClassTypeAlias>()); 7430 expect(member, new isInstanceOf<ClassTypeAlias>());
7453 ClassTypeAlias declaration = member; 7431 ClassTypeAlias declaration = member;
7454 expect(declaration.name.name, "A"); 7432 expect(declaration.name.name, "A");
7455 expect(declaration.abstractKeyword, isNotNull); 7433 expect(declaration.abstractKeyword, isNotNull);
7456 } 7434 }
7457 7435
7458 void test_parseCompilationUnitMember_constVariable() { 7436 void test_parseCompilationUnitMember_constVariable() {
7459 createParser('const int x = 0;'); 7437 createParser('const int x = 0;');
7460 CompilationUnitMember member = 7438 CompilationUnitMember member = parseFullCompilationUnitMember();
7461 parser.parseCompilationUnitMember(emptyCommentAndMetadata());
7462 expectNotNullIfNoErrors(member); 7439 expectNotNullIfNoErrors(member);
7463 listener.assertNoErrors(); 7440 listener.assertNoErrors();
7464 expect(member, new isInstanceOf<TopLevelVariableDeclaration>()); 7441 expect(member, new isInstanceOf<TopLevelVariableDeclaration>());
7465 TopLevelVariableDeclaration declaration = member; 7442 TopLevelVariableDeclaration declaration = member;
7466 expect(declaration.semicolon, isNotNull); 7443 expect(declaration.semicolon, isNotNull);
7467 expect(declaration.variables, isNotNull); 7444 expect(declaration.variables, isNotNull);
7468 } 7445 }
7469 7446
7470 void test_parseCompilationUnitMember_finalVariable() { 7447 void test_parseCompilationUnitMember_finalVariable() {
7471 createParser('final x = 0;'); 7448 createParser('final x = 0;');
7472 CompilationUnitMember member = 7449 CompilationUnitMember member = parseFullCompilationUnitMember();
7473 parser.parseCompilationUnitMember(emptyCommentAndMetadata());
7474 expectNotNullIfNoErrors(member); 7450 expectNotNullIfNoErrors(member);
7475 listener.assertNoErrors(); 7451 listener.assertNoErrors();
7476 expect(member, new isInstanceOf<TopLevelVariableDeclaration>()); 7452 expect(member, new isInstanceOf<TopLevelVariableDeclaration>());
7477 TopLevelVariableDeclaration declaration = member; 7453 TopLevelVariableDeclaration declaration = member;
7478 expect(declaration.semicolon, isNotNull); 7454 expect(declaration.semicolon, isNotNull);
7479 expect(declaration.variables, isNotNull); 7455 expect(declaration.variables, isNotNull);
7480 } 7456 }
7481 7457
7482 void test_parseCompilationUnitMember_function_external_noType() { 7458 void test_parseCompilationUnitMember_function_external_noType() {
7483 createParser('external f();'); 7459 createParser('external f();');
7484 CompilationUnitMember member = 7460 CompilationUnitMember member = parseFullCompilationUnitMember();
7485 parser.parseCompilationUnitMember(emptyCommentAndMetadata());
7486 expectNotNullIfNoErrors(member); 7461 expectNotNullIfNoErrors(member);
7487 listener.assertNoErrors(); 7462 listener.assertNoErrors();
7488 expect(member, new isInstanceOf<FunctionDeclaration>()); 7463 expect(member, new isInstanceOf<FunctionDeclaration>());
7489 FunctionDeclaration declaration = member; 7464 FunctionDeclaration declaration = member;
7490 expect(declaration.externalKeyword, isNotNull); 7465 expect(declaration.externalKeyword, isNotNull);
7491 expect(declaration.functionExpression, isNotNull); 7466 expect(declaration.functionExpression, isNotNull);
7492 expect(declaration.propertyKeyword, isNull); 7467 expect(declaration.propertyKeyword, isNull);
7493 } 7468 }
7494 7469
7495 void test_parseCompilationUnitMember_function_external_type() { 7470 void test_parseCompilationUnitMember_function_external_type() {
7496 createParser('external int f();'); 7471 createParser('external int f();');
7497 CompilationUnitMember member = 7472 CompilationUnitMember member = parseFullCompilationUnitMember();
7498 parser.parseCompilationUnitMember(emptyCommentAndMetadata());
7499 expectNotNullIfNoErrors(member); 7473 expectNotNullIfNoErrors(member);
7500 listener.assertNoErrors(); 7474 listener.assertNoErrors();
7501 expect(member, new isInstanceOf<FunctionDeclaration>()); 7475 expect(member, new isInstanceOf<FunctionDeclaration>());
7502 FunctionDeclaration declaration = member; 7476 FunctionDeclaration declaration = member;
7503 expect(declaration.externalKeyword, isNotNull); 7477 expect(declaration.externalKeyword, isNotNull);
7504 expect(declaration.functionExpression, isNotNull); 7478 expect(declaration.functionExpression, isNotNull);
7505 expect(declaration.propertyKeyword, isNull); 7479 expect(declaration.propertyKeyword, isNull);
7506 } 7480 }
7507 7481
7508 void test_parseCompilationUnitMember_function_generic_noReturnType() { 7482 void test_parseCompilationUnitMember_function_generic_noReturnType() {
7509 createParser('f<E>() {}'); 7483 createParser('f<E>() {}');
7510 CompilationUnitMember member = 7484 CompilationUnitMember member = parseFullCompilationUnitMember();
7511 parser.parseCompilationUnitMember(emptyCommentAndMetadata());
7512 expectNotNullIfNoErrors(member); 7485 expectNotNullIfNoErrors(member);
7513 listener.assertNoErrors(); 7486 listener.assertNoErrors();
7514 expect(member, new isInstanceOf<FunctionDeclaration>()); 7487 expect(member, new isInstanceOf<FunctionDeclaration>());
7515 FunctionDeclaration declaration = member; 7488 FunctionDeclaration declaration = member;
7516 expect(declaration.returnType, isNull); 7489 expect(declaration.returnType, isNull);
7517 expect(declaration.functionExpression.typeParameters, isNotNull); 7490 expect(declaration.functionExpression.typeParameters, isNotNull);
7518 } 7491 }
7519 7492
7520 void 7493 void
7521 test_parseCompilationUnitMember_function_generic_noReturnType_annotated() { 7494 test_parseCompilationUnitMember_function_generic_noReturnType_annotated() {
7522 createParser('f<@a E>() {}'); 7495 createParser('f<@a E>() {}');
7523 CompilationUnitMember member = 7496 CompilationUnitMember member = parseFullCompilationUnitMember();
7524 parser.parseCompilationUnitMember(emptyCommentAndMetadata());
7525 expectNotNullIfNoErrors(member); 7497 expectNotNullIfNoErrors(member);
7526 listener.assertNoErrors(); 7498 listener.assertNoErrors();
7527 expect(member, new isInstanceOf<FunctionDeclaration>()); 7499 expect(member, new isInstanceOf<FunctionDeclaration>());
7528 FunctionDeclaration declaration = member; 7500 FunctionDeclaration declaration = member;
7529 expect(declaration.returnType, isNull); 7501 expect(declaration.returnType, isNull);
7530 expect(declaration.functionExpression.typeParameters, isNotNull); 7502 expect(declaration.functionExpression.typeParameters, isNotNull);
7531 } 7503 }
7532 7504
7533 void test_parseCompilationUnitMember_function_generic_returnType() { 7505 void test_parseCompilationUnitMember_function_generic_returnType() {
7534 createParser('E f<E>() {}'); 7506 createParser('E f<E>() {}');
7535 CompilationUnitMember member = 7507 CompilationUnitMember member = parseFullCompilationUnitMember();
7536 parser.parseCompilationUnitMember(emptyCommentAndMetadata());
7537 expectNotNullIfNoErrors(member); 7508 expectNotNullIfNoErrors(member);
7538 listener.assertNoErrors(); 7509 listener.assertNoErrors();
7539 expect(member, new isInstanceOf<FunctionDeclaration>()); 7510 expect(member, new isInstanceOf<FunctionDeclaration>());
7540 FunctionDeclaration declaration = member; 7511 FunctionDeclaration declaration = member;
7541 expect(declaration.returnType, isNotNull); 7512 expect(declaration.returnType, isNotNull);
7542 expect(declaration.functionExpression.typeParameters, isNotNull); 7513 expect(declaration.functionExpression.typeParameters, isNotNull);
7543 } 7514 }
7544 7515
7545 void test_parseCompilationUnitMember_function_generic_void() { 7516 void test_parseCompilationUnitMember_function_generic_void() {
7546 createParser('void f<T>(T t) {}'); 7517 createParser('void f<T>(T t) {}');
7547 CompilationUnitMember member = 7518 CompilationUnitMember member = parseFullCompilationUnitMember();
7548 parser.parseCompilationUnitMember(emptyCommentAndMetadata());
7549 expectNotNullIfNoErrors(member); 7519 expectNotNullIfNoErrors(member);
7550 listener.assertNoErrors(); 7520 listener.assertNoErrors();
7551 expect(member, new isInstanceOf<FunctionDeclaration>()); 7521 expect(member, new isInstanceOf<FunctionDeclaration>());
7552 FunctionDeclaration declaration = member; 7522 FunctionDeclaration declaration = member;
7553 expect(declaration.functionExpression, isNotNull); 7523 expect(declaration.functionExpression, isNotNull);
7554 expect(declaration.propertyKeyword, isNull); 7524 expect(declaration.propertyKeyword, isNull);
7555 } 7525 }
7556 7526
7557 void test_parseCompilationUnitMember_function_noType() { 7527 void test_parseCompilationUnitMember_function_noType() {
7558 createParser('f() {}'); 7528 createParser('f() {}');
7559 CompilationUnitMember member = 7529 CompilationUnitMember member = parseFullCompilationUnitMember();
7560 parser.parseCompilationUnitMember(emptyCommentAndMetadata());
7561 expectNotNullIfNoErrors(member); 7530 expectNotNullIfNoErrors(member);
7562 listener.assertNoErrors(); 7531 listener.assertNoErrors();
7563 expect(member, new isInstanceOf<FunctionDeclaration>()); 7532 expect(member, new isInstanceOf<FunctionDeclaration>());
7564 FunctionDeclaration declaration = member; 7533 FunctionDeclaration declaration = member;
7565 expect(declaration.functionExpression, isNotNull); 7534 expect(declaration.functionExpression, isNotNull);
7566 expect(declaration.propertyKeyword, isNull); 7535 expect(declaration.propertyKeyword, isNull);
7567 } 7536 }
7568 7537
7569 void test_parseCompilationUnitMember_function_type() { 7538 void test_parseCompilationUnitMember_function_type() {
7570 createParser('int f() {}'); 7539 createParser('int f() {}');
7571 CompilationUnitMember member = 7540 CompilationUnitMember member = parseFullCompilationUnitMember();
7572 parser.parseCompilationUnitMember(emptyCommentAndMetadata());
7573 expectNotNullIfNoErrors(member); 7541 expectNotNullIfNoErrors(member);
7574 listener.assertNoErrors(); 7542 listener.assertNoErrors();
7575 expect(member, new isInstanceOf<FunctionDeclaration>()); 7543 expect(member, new isInstanceOf<FunctionDeclaration>());
7576 FunctionDeclaration declaration = member; 7544 FunctionDeclaration declaration = member;
7577 expect(declaration.functionExpression, isNotNull); 7545 expect(declaration.functionExpression, isNotNull);
7578 expect(declaration.propertyKeyword, isNull); 7546 expect(declaration.propertyKeyword, isNull);
7579 } 7547 }
7580 7548
7581 void test_parseCompilationUnitMember_function_void() { 7549 void test_parseCompilationUnitMember_function_void() {
7582 createParser('void f() {}'); 7550 createParser('void f() {}');
7583 CompilationUnitMember member = 7551 CompilationUnitMember member = parseFullCompilationUnitMember();
7584 parser.parseCompilationUnitMember(emptyCommentAndMetadata());
7585 expectNotNullIfNoErrors(member); 7552 expectNotNullIfNoErrors(member);
7586 listener.assertNoErrors(); 7553 listener.assertNoErrors();
7587 expect(member, new isInstanceOf<FunctionDeclaration>()); 7554 expect(member, new isInstanceOf<FunctionDeclaration>());
7588 FunctionDeclaration declaration = member; 7555 FunctionDeclaration declaration = member;
7589 expect(declaration.returnType, isNotNull); 7556 expect(declaration.returnType, isNotNull);
7590 } 7557 }
7591 7558
7592 void test_parseCompilationUnitMember_getter_external_noType() { 7559 void test_parseCompilationUnitMember_getter_external_noType() {
7593 createParser('external get p;'); 7560 createParser('external get p;');
7594 CompilationUnitMember member = 7561 CompilationUnitMember member = parseFullCompilationUnitMember();
7595 parser.parseCompilationUnitMember(emptyCommentAndMetadata());
7596 expectNotNullIfNoErrors(member); 7562 expectNotNullIfNoErrors(member);
7597 listener.assertNoErrors(); 7563 listener.assertNoErrors();
7598 expect(member, new isInstanceOf<FunctionDeclaration>()); 7564 expect(member, new isInstanceOf<FunctionDeclaration>());
7599 FunctionDeclaration declaration = member; 7565 FunctionDeclaration declaration = member;
7600 expect(declaration.externalKeyword, isNotNull); 7566 expect(declaration.externalKeyword, isNotNull);
7601 expect(declaration.functionExpression, isNotNull); 7567 expect(declaration.functionExpression, isNotNull);
7602 expect(declaration.propertyKeyword, isNotNull); 7568 expect(declaration.propertyKeyword, isNotNull);
7603 } 7569 }
7604 7570
7605 void test_parseCompilationUnitMember_getter_external_type() { 7571 void test_parseCompilationUnitMember_getter_external_type() {
7606 createParser('external int get p;'); 7572 createParser('external int get p;');
7607 CompilationUnitMember member = 7573 CompilationUnitMember member = parseFullCompilationUnitMember();
7608 parser.parseCompilationUnitMember(emptyCommentAndMetadata());
7609 expectNotNullIfNoErrors(member); 7574 expectNotNullIfNoErrors(member);
7610 listener.assertNoErrors(); 7575 listener.assertNoErrors();
7611 expect(member, new isInstanceOf<FunctionDeclaration>()); 7576 expect(member, new isInstanceOf<FunctionDeclaration>());
7612 FunctionDeclaration declaration = member; 7577 FunctionDeclaration declaration = member;
7613 expect(declaration.externalKeyword, isNotNull); 7578 expect(declaration.externalKeyword, isNotNull);
7614 expect(declaration.functionExpression, isNotNull); 7579 expect(declaration.functionExpression, isNotNull);
7615 expect(declaration.propertyKeyword, isNotNull); 7580 expect(declaration.propertyKeyword, isNotNull);
7616 } 7581 }
7617 7582
7618 void test_parseCompilationUnitMember_getter_noType() { 7583 void test_parseCompilationUnitMember_getter_noType() {
7619 createParser('get p => 0;'); 7584 createParser('get p => 0;');
7620 CompilationUnitMember member = 7585 CompilationUnitMember member = parseFullCompilationUnitMember();
7621 parser.parseCompilationUnitMember(emptyCommentAndMetadata());
7622 expectNotNullIfNoErrors(member); 7586 expectNotNullIfNoErrors(member);
7623 listener.assertNoErrors(); 7587 listener.assertNoErrors();
7624 expect(member, new isInstanceOf<FunctionDeclaration>()); 7588 expect(member, new isInstanceOf<FunctionDeclaration>());
7625 FunctionDeclaration declaration = member; 7589 FunctionDeclaration declaration = member;
7626 expect(declaration.functionExpression, isNotNull); 7590 expect(declaration.functionExpression, isNotNull);
7627 expect(declaration.propertyKeyword, isNotNull); 7591 expect(declaration.propertyKeyword, isNotNull);
7628 } 7592 }
7629 7593
7630 void test_parseCompilationUnitMember_getter_type() { 7594 void test_parseCompilationUnitMember_getter_type() {
7631 createParser('int get p => 0;'); 7595 createParser('int get p => 0;');
7632 CompilationUnitMember member = 7596 CompilationUnitMember member = parseFullCompilationUnitMember();
7633 parser.parseCompilationUnitMember(emptyCommentAndMetadata());
7634 expectNotNullIfNoErrors(member); 7597 expectNotNullIfNoErrors(member);
7635 listener.assertNoErrors(); 7598 listener.assertNoErrors();
7636 expect(member, new isInstanceOf<FunctionDeclaration>()); 7599 expect(member, new isInstanceOf<FunctionDeclaration>());
7637 FunctionDeclaration declaration = member; 7600 FunctionDeclaration declaration = member;
7638 expect(declaration.functionExpression, isNotNull); 7601 expect(declaration.functionExpression, isNotNull);
7639 expect(declaration.propertyKeyword, isNotNull); 7602 expect(declaration.propertyKeyword, isNotNull);
7640 } 7603 }
7641 7604
7642 void test_parseCompilationUnitMember_setter_external_noType() { 7605 void test_parseCompilationUnitMember_setter_external_noType() {
7643 createParser('external set p(v);'); 7606 createParser('external set p(v);');
7644 CompilationUnitMember member = 7607 CompilationUnitMember member = parseFullCompilationUnitMember();
7645 parser.parseCompilationUnitMember(emptyCommentAndMetadata());
7646 expectNotNullIfNoErrors(member); 7608 expectNotNullIfNoErrors(member);
7647 listener.assertNoErrors(); 7609 listener.assertNoErrors();
7648 expect(member, new isInstanceOf<FunctionDeclaration>()); 7610 expect(member, new isInstanceOf<FunctionDeclaration>());
7649 FunctionDeclaration declaration = member; 7611 FunctionDeclaration declaration = member;
7650 expect(declaration.externalKeyword, isNotNull); 7612 expect(declaration.externalKeyword, isNotNull);
7651 expect(declaration.functionExpression, isNotNull); 7613 expect(declaration.functionExpression, isNotNull);
7652 expect(declaration.propertyKeyword, isNotNull); 7614 expect(declaration.propertyKeyword, isNotNull);
7653 } 7615 }
7654 7616
7655 void test_parseCompilationUnitMember_setter_external_type() { 7617 void test_parseCompilationUnitMember_setter_external_type() {
7656 createParser('external void set p(int v);'); 7618 createParser('external void set p(int v);');
7657 CompilationUnitMember member = 7619 CompilationUnitMember member = parseFullCompilationUnitMember();
7658 parser.parseCompilationUnitMember(emptyCommentAndMetadata());
7659 expectNotNullIfNoErrors(member); 7620 expectNotNullIfNoErrors(member);
7660 listener.assertNoErrors(); 7621 listener.assertNoErrors();
7661 expect(member, new isInstanceOf<FunctionDeclaration>()); 7622 expect(member, new isInstanceOf<FunctionDeclaration>());
7662 FunctionDeclaration declaration = member; 7623 FunctionDeclaration declaration = member;
7663 expect(declaration.externalKeyword, isNotNull); 7624 expect(declaration.externalKeyword, isNotNull);
7664 expect(declaration.functionExpression, isNotNull); 7625 expect(declaration.functionExpression, isNotNull);
7665 expect(declaration.propertyKeyword, isNotNull); 7626 expect(declaration.propertyKeyword, isNotNull);
7666 } 7627 }
7667 7628
7668 void test_parseCompilationUnitMember_setter_noType() { 7629 void test_parseCompilationUnitMember_setter_noType() {
7669 createParser('set p(v) {}'); 7630 createParser('set p(v) {}');
7670 CompilationUnitMember member = 7631 CompilationUnitMember member = parseFullCompilationUnitMember();
7671 parser.parseCompilationUnitMember(emptyCommentAndMetadata());
7672 expectNotNullIfNoErrors(member); 7632 expectNotNullIfNoErrors(member);
7673 listener.assertNoErrors(); 7633 listener.assertNoErrors();
7674 expect(member, new isInstanceOf<FunctionDeclaration>()); 7634 expect(member, new isInstanceOf<FunctionDeclaration>());
7675 FunctionDeclaration declaration = member; 7635 FunctionDeclaration declaration = member;
7676 expect(declaration.functionExpression, isNotNull); 7636 expect(declaration.functionExpression, isNotNull);
7677 expect(declaration.propertyKeyword, isNotNull); 7637 expect(declaration.propertyKeyword, isNotNull);
7678 } 7638 }
7679 7639
7680 void test_parseCompilationUnitMember_setter_type() { 7640 void test_parseCompilationUnitMember_setter_type() {
7681 createParser('void set p(int v) {}'); 7641 createParser('void set p(int v) {}');
7682 CompilationUnitMember member = 7642 CompilationUnitMember member = parseFullCompilationUnitMember();
7683 parser.parseCompilationUnitMember(emptyCommentAndMetadata());
7684 expectNotNullIfNoErrors(member); 7643 expectNotNullIfNoErrors(member);
7685 listener.assertNoErrors(); 7644 listener.assertNoErrors();
7686 expect(member, new isInstanceOf<FunctionDeclaration>()); 7645 expect(member, new isInstanceOf<FunctionDeclaration>());
7687 FunctionDeclaration declaration = member; 7646 FunctionDeclaration declaration = member;
7688 expect(declaration.functionExpression, isNotNull); 7647 expect(declaration.functionExpression, isNotNull);
7689 expect(declaration.propertyKeyword, isNotNull); 7648 expect(declaration.propertyKeyword, isNotNull);
7690 expect(declaration.returnType, isNotNull); 7649 expect(declaration.returnType, isNotNull);
7691 } 7650 }
7692 7651
7693 void test_parseCompilationUnitMember_typeAlias_abstract() { 7652 void test_parseCompilationUnitMember_typeAlias_abstract() {
7694 createParser('abstract class C = S with M;'); 7653 createParser('abstract class C = S with M;');
7695 CompilationUnitMember member = 7654 CompilationUnitMember member = parseFullCompilationUnitMember();
7696 parser.parseCompilationUnitMember(emptyCommentAndMetadata());
7697 expectNotNullIfNoErrors(member); 7655 expectNotNullIfNoErrors(member);
7698 listener.assertNoErrors(); 7656 listener.assertNoErrors();
7699 expect(member, new isInstanceOf<ClassTypeAlias>()); 7657 expect(member, new isInstanceOf<ClassTypeAlias>());
7700 ClassTypeAlias typeAlias = member; 7658 ClassTypeAlias typeAlias = member;
7701 expect(typeAlias.typedefKeyword, isNotNull); 7659 expect(typeAlias.typedefKeyword, isNotNull);
7702 expect(typeAlias.name.name, "C"); 7660 expect(typeAlias.name.name, "C");
7703 expect(typeAlias.typeParameters, isNull); 7661 expect(typeAlias.typeParameters, isNull);
7704 expect(typeAlias.equals, isNotNull); 7662 expect(typeAlias.equals, isNotNull);
7705 expect(typeAlias.abstractKeyword, isNotNull); 7663 expect(typeAlias.abstractKeyword, isNotNull);
7706 expect(typeAlias.superclass.name.name, "S"); 7664 expect(typeAlias.superclass.name.name, "S");
7707 expect(typeAlias.withClause, isNotNull); 7665 expect(typeAlias.withClause, isNotNull);
7708 expect(typeAlias.implementsClause, isNull); 7666 expect(typeAlias.implementsClause, isNull);
7709 expect(typeAlias.semicolon, isNotNull); 7667 expect(typeAlias.semicolon, isNotNull);
7710 } 7668 }
7711 7669
7712 void test_parseCompilationUnitMember_typeAlias_generic() { 7670 void test_parseCompilationUnitMember_typeAlias_generic() {
7713 createParser('class C<E> = S<E> with M<E> implements I<E>;'); 7671 createParser('class C<E> = S<E> with M<E> implements I<E>;');
7714 CompilationUnitMember member = 7672 CompilationUnitMember member = parseFullCompilationUnitMember();
7715 parser.parseCompilationUnitMember(emptyCommentAndMetadata());
7716 expectNotNullIfNoErrors(member); 7673 expectNotNullIfNoErrors(member);
7717 listener.assertNoErrors(); 7674 listener.assertNoErrors();
7718 expect(member, new isInstanceOf<ClassTypeAlias>()); 7675 expect(member, new isInstanceOf<ClassTypeAlias>());
7719 ClassTypeAlias typeAlias = member; 7676 ClassTypeAlias typeAlias = member;
7720 expect(typeAlias.typedefKeyword, isNotNull); 7677 expect(typeAlias.typedefKeyword, isNotNull);
7721 expect(typeAlias.name.name, "C"); 7678 expect(typeAlias.name.name, "C");
7722 expect(typeAlias.typeParameters.typeParameters, hasLength(1)); 7679 expect(typeAlias.typeParameters.typeParameters, hasLength(1));
7723 expect(typeAlias.equals, isNotNull); 7680 expect(typeAlias.equals, isNotNull);
7724 expect(typeAlias.abstractKeyword, isNull); 7681 expect(typeAlias.abstractKeyword, isNull);
7725 expect(typeAlias.superclass.name.name, "S"); 7682 expect(typeAlias.superclass.name.name, "S");
7726 expect(typeAlias.withClause, isNotNull); 7683 expect(typeAlias.withClause, isNotNull);
7727 expect(typeAlias.implementsClause, isNotNull); 7684 expect(typeAlias.implementsClause, isNotNull);
7728 expect(typeAlias.semicolon, isNotNull); 7685 expect(typeAlias.semicolon, isNotNull);
7729 } 7686 }
7730 7687
7731 void test_parseCompilationUnitMember_typeAlias_implements() { 7688 void test_parseCompilationUnitMember_typeAlias_implements() {
7732 createParser('class C = S with M implements I;'); 7689 createParser('class C = S with M implements I;');
7733 CompilationUnitMember member = 7690 CompilationUnitMember member = parseFullCompilationUnitMember();
7734 parser.parseCompilationUnitMember(emptyCommentAndMetadata());
7735 expectNotNullIfNoErrors(member); 7691 expectNotNullIfNoErrors(member);
7736 listener.assertNoErrors(); 7692 listener.assertNoErrors();
7737 expect(member, new isInstanceOf<ClassTypeAlias>()); 7693 expect(member, new isInstanceOf<ClassTypeAlias>());
7738 ClassTypeAlias typeAlias = member; 7694 ClassTypeAlias typeAlias = member;
7739 expect(typeAlias.typedefKeyword, isNotNull); 7695 expect(typeAlias.typedefKeyword, isNotNull);
7740 expect(typeAlias.name.name, "C"); 7696 expect(typeAlias.name.name, "C");
7741 expect(typeAlias.typeParameters, isNull); 7697 expect(typeAlias.typeParameters, isNull);
7742 expect(typeAlias.equals, isNotNull); 7698 expect(typeAlias.equals, isNotNull);
7743 expect(typeAlias.abstractKeyword, isNull); 7699 expect(typeAlias.abstractKeyword, isNull);
7744 expect(typeAlias.superclass.name.name, "S"); 7700 expect(typeAlias.superclass.name.name, "S");
7745 expect(typeAlias.withClause, isNotNull); 7701 expect(typeAlias.withClause, isNotNull);
7746 expect(typeAlias.implementsClause, isNotNull); 7702 expect(typeAlias.implementsClause, isNotNull);
7747 expect(typeAlias.semicolon, isNotNull); 7703 expect(typeAlias.semicolon, isNotNull);
7748 } 7704 }
7749 7705
7750 void test_parseCompilationUnitMember_typeAlias_noImplements() { 7706 void test_parseCompilationUnitMember_typeAlias_noImplements() {
7751 createParser('class C = S with M;'); 7707 createParser('class C = S with M;');
7752 CompilationUnitMember member = 7708 CompilationUnitMember member = parseFullCompilationUnitMember();
7753 parser.parseCompilationUnitMember(emptyCommentAndMetadata());
7754 expectNotNullIfNoErrors(member); 7709 expectNotNullIfNoErrors(member);
7755 listener.assertNoErrors(); 7710 listener.assertNoErrors();
7756 expect(member, new isInstanceOf<ClassTypeAlias>()); 7711 expect(member, new isInstanceOf<ClassTypeAlias>());
7757 ClassTypeAlias typeAlias = member; 7712 ClassTypeAlias typeAlias = member;
7758 expect(typeAlias.typedefKeyword, isNotNull); 7713 expect(typeAlias.typedefKeyword, isNotNull);
7759 expect(typeAlias.name.name, "C"); 7714 expect(typeAlias.name.name, "C");
7760 expect(typeAlias.typeParameters, isNull); 7715 expect(typeAlias.typeParameters, isNull);
7761 expect(typeAlias.equals, isNotNull); 7716 expect(typeAlias.equals, isNotNull);
7762 expect(typeAlias.abstractKeyword, isNull); 7717 expect(typeAlias.abstractKeyword, isNull);
7763 expect(typeAlias.superclass.name.name, "S"); 7718 expect(typeAlias.superclass.name.name, "S");
7764 expect(typeAlias.withClause, isNotNull); 7719 expect(typeAlias.withClause, isNotNull);
7765 expect(typeAlias.implementsClause, isNull); 7720 expect(typeAlias.implementsClause, isNull);
7766 expect(typeAlias.semicolon, isNotNull); 7721 expect(typeAlias.semicolon, isNotNull);
7767 } 7722 }
7768 7723
7769 void test_parseCompilationUnitMember_typedef() { 7724 void test_parseCompilationUnitMember_typedef() {
7770 createParser('typedef F();'); 7725 createParser('typedef F();');
7771 CompilationUnitMember member = 7726 CompilationUnitMember member = parseFullCompilationUnitMember();
7772 parser.parseCompilationUnitMember(emptyCommentAndMetadata());
7773 expectNotNullIfNoErrors(member); 7727 expectNotNullIfNoErrors(member);
7774 listener.assertNoErrors(); 7728 listener.assertNoErrors();
7775 expect(member, new isInstanceOf<FunctionTypeAlias>()); 7729 expect(member, new isInstanceOf<FunctionTypeAlias>());
7776 FunctionTypeAlias typeAlias = member; 7730 FunctionTypeAlias typeAlias = member;
7777 expect(typeAlias.name.name, "F"); 7731 expect(typeAlias.name.name, "F");
7778 expect(typeAlias.parameters.parameters, hasLength(0)); 7732 expect(typeAlias.parameters.parameters, hasLength(0));
7779 } 7733 }
7780 7734
7781 void test_parseCompilationUnitMember_variable() { 7735 void test_parseCompilationUnitMember_variable() {
7782 createParser('var x = 0;'); 7736 createParser('var x = 0;');
7783 CompilationUnitMember member = 7737 CompilationUnitMember member = parseFullCompilationUnitMember();
7784 parser.parseCompilationUnitMember(emptyCommentAndMetadata());
7785 expectNotNullIfNoErrors(member); 7738 expectNotNullIfNoErrors(member);
7786 listener.assertNoErrors(); 7739 listener.assertNoErrors();
7787 expect(member, new isInstanceOf<TopLevelVariableDeclaration>()); 7740 expect(member, new isInstanceOf<TopLevelVariableDeclaration>());
7788 TopLevelVariableDeclaration declaration = member; 7741 TopLevelVariableDeclaration declaration = member;
7789 expect(declaration.semicolon, isNotNull); 7742 expect(declaration.semicolon, isNotNull);
7790 expect(declaration.variables, isNotNull); 7743 expect(declaration.variables, isNotNull);
7791 } 7744 }
7792 7745
7793 void test_parseCompilationUnitMember_variableGet() { 7746 void test_parseCompilationUnitMember_variableGet() {
7794 createParser('String get = null;'); 7747 createParser('String get = null;');
7795 CompilationUnitMember member = 7748 CompilationUnitMember member = parseFullCompilationUnitMember();
7796 parser.parseCompilationUnitMember(emptyCommentAndMetadata());
7797 expectNotNullIfNoErrors(member); 7749 expectNotNullIfNoErrors(member);
7798 listener.assertNoErrors(); 7750 listener.assertNoErrors();
7799 expect(member, new isInstanceOf<TopLevelVariableDeclaration>()); 7751 expect(member, new isInstanceOf<TopLevelVariableDeclaration>());
7800 TopLevelVariableDeclaration declaration = member; 7752 TopLevelVariableDeclaration declaration = member;
7801 expect(declaration.semicolon, isNotNull); 7753 expect(declaration.semicolon, isNotNull);
7802 expect(declaration.variables, isNotNull); 7754 expect(declaration.variables, isNotNull);
7803 } 7755 }
7804 7756
7805 void test_parseCompilationUnitMember_variableSet() { 7757 void test_parseCompilationUnitMember_variableSet() {
7806 createParser('String set = null;'); 7758 createParser('String set = null;');
7807 CompilationUnitMember member = 7759 CompilationUnitMember member = parseFullCompilationUnitMember();
7808 parser.parseCompilationUnitMember(emptyCommentAndMetadata());
7809 expectNotNullIfNoErrors(member); 7760 expectNotNullIfNoErrors(member);
7810 listener.assertNoErrors(); 7761 listener.assertNoErrors();
7811 expect(member, new isInstanceOf<TopLevelVariableDeclaration>()); 7762 expect(member, new isInstanceOf<TopLevelVariableDeclaration>());
7812 TopLevelVariableDeclaration declaration = member; 7763 TopLevelVariableDeclaration declaration = member;
7813 expect(declaration.semicolon, isNotNull); 7764 expect(declaration.semicolon, isNotNull);
7814 expect(declaration.variables, isNotNull); 7765 expect(declaration.variables, isNotNull);
7815 } 7766 }
7816 7767
7817 void test_parseConditionalExpression() { 7768 void test_parseConditionalExpression() {
7818 createParser('x ? y : z'); 7769 createParser('x ? y : z');
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
8105 ContinueStatement statement = parser.parseContinueStatement(); 8056 ContinueStatement statement = parser.parseContinueStatement();
8106 expectNotNullIfNoErrors(statement); 8057 expectNotNullIfNoErrors(statement);
8107 listener.assertErrorsWithCodes([ParserErrorCode.CONTINUE_OUTSIDE_OF_LOOP]); 8058 listener.assertErrorsWithCodes([ParserErrorCode.CONTINUE_OUTSIDE_OF_LOOP]);
8108 expect(statement.continueKeyword, isNotNull); 8059 expect(statement.continueKeyword, isNotNull);
8109 expect(statement.label, isNull); 8060 expect(statement.label, isNull);
8110 expect(statement.semicolon, isNotNull); 8061 expect(statement.semicolon, isNotNull);
8111 } 8062 }
8112 8063
8113 void test_parseDirective_export() { 8064 void test_parseDirective_export() {
8114 createParser("export 'lib/lib.dart';"); 8065 createParser("export 'lib/lib.dart';");
8115 Directive directive = parser.parseDirective(emptyCommentAndMetadata()); 8066 Directive directive = parseFullDirective();
8116 expectNotNullIfNoErrors(directive); 8067 expectNotNullIfNoErrors(directive);
8117 listener.assertNoErrors(); 8068 listener.assertNoErrors();
8118 expect(directive, new isInstanceOf<ExportDirective>()); 8069 expect(directive, new isInstanceOf<ExportDirective>());
8119 ExportDirective exportDirective = directive; 8070 ExportDirective exportDirective = directive;
8120 expect(exportDirective.keyword, isNotNull); 8071 expect(exportDirective.keyword, isNotNull);
8121 expect(exportDirective.uri, isNotNull); 8072 expect(exportDirective.uri, isNotNull);
8122 expect(exportDirective.combinators, hasLength(0)); 8073 expect(exportDirective.combinators, hasLength(0));
8123 expect(exportDirective.semicolon, isNotNull); 8074 expect(exportDirective.semicolon, isNotNull);
8124 } 8075 }
8125 8076
8126 void test_parseDirective_import() { 8077 void test_parseDirective_import() {
8127 createParser("import 'lib/lib.dart';"); 8078 createParser("import 'lib/lib.dart';");
8128 Directive directive = parser.parseDirective(emptyCommentAndMetadata()); 8079 Directive directive = parseFullDirective();
8129 expectNotNullIfNoErrors(directive); 8080 expectNotNullIfNoErrors(directive);
8130 listener.assertNoErrors(); 8081 listener.assertNoErrors();
8131 expect(directive, new isInstanceOf<ImportDirective>()); 8082 expect(directive, new isInstanceOf<ImportDirective>());
8132 ImportDirective importDirective = directive; 8083 ImportDirective importDirective = directive;
8133 expect(importDirective.keyword, isNotNull); 8084 expect(importDirective.keyword, isNotNull);
8134 expect(importDirective.uri, isNotNull); 8085 expect(importDirective.uri, isNotNull);
8135 expect(importDirective.asKeyword, isNull); 8086 expect(importDirective.asKeyword, isNull);
8136 expect(importDirective.prefix, isNull); 8087 expect(importDirective.prefix, isNull);
8137 expect(importDirective.combinators, hasLength(0)); 8088 expect(importDirective.combinators, hasLength(0));
8138 expect(importDirective.semicolon, isNotNull); 8089 expect(importDirective.semicolon, isNotNull);
8139 } 8090 }
8140 8091
8141 void test_parseDirective_library() { 8092 void test_parseDirective_library() {
8142 createParser("library l;"); 8093 createParser("library l;");
8143 Directive directive = parser.parseDirective(emptyCommentAndMetadata()); 8094 Directive directive = parseFullDirective();
8144 expectNotNullIfNoErrors(directive); 8095 expectNotNullIfNoErrors(directive);
8145 listener.assertNoErrors(); 8096 listener.assertNoErrors();
8146 expect(directive, new isInstanceOf<LibraryDirective>()); 8097 expect(directive, new isInstanceOf<LibraryDirective>());
8147 LibraryDirective libraryDirective = directive; 8098 LibraryDirective libraryDirective = directive;
8148 expect(libraryDirective.libraryKeyword, isNotNull); 8099 expect(libraryDirective.libraryKeyword, isNotNull);
8149 expect(libraryDirective.name, isNotNull); 8100 expect(libraryDirective.name, isNotNull);
8150 expect(libraryDirective.semicolon, isNotNull); 8101 expect(libraryDirective.semicolon, isNotNull);
8151 } 8102 }
8152 8103
8153 void test_parseDirective_part() { 8104 void test_parseDirective_part() {
8154 createParser("part 'lib/lib.dart';"); 8105 createParser("part 'lib/lib.dart';");
8155 Directive directive = parser.parseDirective(emptyCommentAndMetadata()); 8106 Directive directive = parseFullDirective();
8156 expectNotNullIfNoErrors(directive); 8107 expectNotNullIfNoErrors(directive);
8157 listener.assertNoErrors(); 8108 listener.assertNoErrors();
8158 expect(directive, new isInstanceOf<PartDirective>()); 8109 expect(directive, new isInstanceOf<PartDirective>());
8159 PartDirective partDirective = directive; 8110 PartDirective partDirective = directive;
8160 expect(partDirective.partKeyword, isNotNull); 8111 expect(partDirective.partKeyword, isNotNull);
8161 expect(partDirective.uri, isNotNull); 8112 expect(partDirective.uri, isNotNull);
8162 expect(partDirective.semicolon, isNotNull); 8113 expect(partDirective.semicolon, isNotNull);
8163 } 8114 }
8164 8115
8165 void test_parseDirective_partOf() { 8116 void test_parseDirective_partOf() {
8166 createParser("part of l;"); 8117 createParser("part of l;");
8167 Directive directive = parser.parseDirective(emptyCommentAndMetadata()); 8118 Directive directive = parseFullDirective();
8168 expectNotNullIfNoErrors(directive); 8119 expectNotNullIfNoErrors(directive);
8169 listener.assertNoErrors(); 8120 listener.assertNoErrors();
8170 expect(directive, new isInstanceOf<PartOfDirective>()); 8121 expect(directive, new isInstanceOf<PartOfDirective>());
8171 PartOfDirective partOfDirective = directive; 8122 PartOfDirective partOfDirective = directive;
8172 expect(partOfDirective.partKeyword, isNotNull); 8123 expect(partOfDirective.partKeyword, isNotNull);
8173 expect(partOfDirective.ofKeyword, isNotNull); 8124 expect(partOfDirective.ofKeyword, isNotNull);
8174 expect(partOfDirective.libraryName, isNotNull); 8125 expect(partOfDirective.libraryName, isNotNull);
8175 expect(partOfDirective.semicolon, isNotNull); 8126 expect(partOfDirective.semicolon, isNotNull);
8176 } 8127 }
8177 8128
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
8290 void test_parseEmptyStatement() { 8241 void test_parseEmptyStatement() {
8291 createParser(';'); 8242 createParser(';');
8292 EmptyStatement statement = parser.parseEmptyStatement(); 8243 EmptyStatement statement = parser.parseEmptyStatement();
8293 expectNotNullIfNoErrors(statement); 8244 expectNotNullIfNoErrors(statement);
8294 listener.assertNoErrors(); 8245 listener.assertNoErrors();
8295 expect(statement.semicolon, isNotNull); 8246 expect(statement.semicolon, isNotNull);
8296 } 8247 }
8297 8248
8298 void test_parseEnumDeclaration_one() { 8249 void test_parseEnumDeclaration_one() {
8299 createParser("enum E {ONE}"); 8250 createParser("enum E {ONE}");
8300 EnumDeclaration declaration = 8251 EnumDeclaration declaration = parseFullCompilationUnitMember();
8301 parser.parseEnumDeclaration(emptyCommentAndMetadata());
8302 expectNotNullIfNoErrors(declaration); 8252 expectNotNullIfNoErrors(declaration);
8303 listener.assertNoErrors(); 8253 listener.assertNoErrors();
8304 expect(declaration.documentationComment, isNull); 8254 expect(declaration.documentationComment, isNull);
8305 expect(declaration.enumKeyword, isNotNull); 8255 expect(declaration.enumKeyword, isNotNull);
8306 expect(declaration.leftBracket, isNotNull); 8256 expect(declaration.leftBracket, isNotNull);
8307 expect(declaration.name, isNotNull); 8257 expect(declaration.name, isNotNull);
8308 expect(declaration.constants, hasLength(1)); 8258 expect(declaration.constants, hasLength(1));
8309 expect(declaration.rightBracket, isNotNull); 8259 expect(declaration.rightBracket, isNotNull);
8310 } 8260 }
8311 8261
8312 void test_parseEnumDeclaration_trailingComma() { 8262 void test_parseEnumDeclaration_trailingComma() {
8313 createParser("enum E {ONE,}"); 8263 createParser("enum E {ONE,}");
8314 EnumDeclaration declaration = 8264 EnumDeclaration declaration = parseFullCompilationUnitMember();
8315 parser.parseEnumDeclaration(emptyCommentAndMetadata());
8316 expectNotNullIfNoErrors(declaration); 8265 expectNotNullIfNoErrors(declaration);
8317 listener.assertNoErrors(); 8266 listener.assertNoErrors();
8318 expect(declaration.documentationComment, isNull); 8267 expect(declaration.documentationComment, isNull);
8319 expect(declaration.enumKeyword, isNotNull); 8268 expect(declaration.enumKeyword, isNotNull);
8320 expect(declaration.leftBracket, isNotNull); 8269 expect(declaration.leftBracket, isNotNull);
8321 expect(declaration.name, isNotNull); 8270 expect(declaration.name, isNotNull);
8322 expect(declaration.constants, hasLength(1)); 8271 expect(declaration.constants, hasLength(1));
8323 expect(declaration.rightBracket, isNotNull); 8272 expect(declaration.rightBracket, isNotNull);
8324 } 8273 }
8325 8274
8326 void test_parseEnumDeclaration_two() { 8275 void test_parseEnumDeclaration_two() {
8327 createParser("enum E {ONE, TWO}"); 8276 createParser("enum E {ONE, TWO}");
8328 EnumDeclaration declaration = 8277 EnumDeclaration declaration = parseFullCompilationUnitMember();
8329 parser.parseEnumDeclaration(emptyCommentAndMetadata());
8330 expectNotNullIfNoErrors(declaration); 8278 expectNotNullIfNoErrors(declaration);
8331 listener.assertNoErrors(); 8279 listener.assertNoErrors();
8332 expect(declaration.documentationComment, isNull); 8280 expect(declaration.documentationComment, isNull);
8333 expect(declaration.enumKeyword, isNotNull); 8281 expect(declaration.enumKeyword, isNotNull);
8334 expect(declaration.leftBracket, isNotNull); 8282 expect(declaration.leftBracket, isNotNull);
8335 expect(declaration.name, isNotNull); 8283 expect(declaration.name, isNotNull);
8336 expect(declaration.constants, hasLength(2)); 8284 expect(declaration.constants, hasLength(2));
8337 expect(declaration.rightBracket, isNotNull); 8285 expect(declaration.rightBracket, isNotNull);
8338 } 8286 }
8339 8287
(...skipping 14 matching lines...) Expand all
8354 expectNotNullIfNoErrors(expression); 8302 expectNotNullIfNoErrors(expression);
8355 listener.assertNoErrors(); 8303 listener.assertNoErrors();
8356 expect(expression.leftOperand, new isInstanceOf<SuperExpression>()); 8304 expect(expression.leftOperand, new isInstanceOf<SuperExpression>());
8357 expect(expression.operator, isNotNull); 8305 expect(expression.operator, isNotNull);
8358 expect(expression.operator.type, TokenType.EQ_EQ); 8306 expect(expression.operator.type, TokenType.EQ_EQ);
8359 expect(expression.rightOperand, isNotNull); 8307 expect(expression.rightOperand, isNotNull);
8360 } 8308 }
8361 8309
8362 void test_parseExportDirective_configuration_multiple() { 8310 void test_parseExportDirective_configuration_multiple() {
8363 createParser("export 'lib/lib.dart' if (a) 'b.dart' if (c) 'd.dart';"); 8311 createParser("export 'lib/lib.dart' if (a) 'b.dart' if (c) 'd.dart';");
8364 ExportDirective directive = 8312 ExportDirective directive = parseFullDirective();
8365 parser.parseExportDirective(emptyCommentAndMetadata());
8366 expectNotNullIfNoErrors(directive); 8313 expectNotNullIfNoErrors(directive);
8367 listener.assertNoErrors(); 8314 listener.assertNoErrors();
8368 expect(directive.keyword, isNotNull); 8315 expect(directive.keyword, isNotNull);
8369 expect(directive.uri, isNotNull); 8316 expect(directive.uri, isNotNull);
8370 expect(directive.configurations, hasLength(2)); 8317 expect(directive.configurations, hasLength(2));
8371 _expectDottedName(directive.configurations[0].name, ['a']); 8318 _expectDottedName(directive.configurations[0].name, ['a']);
8372 _expectDottedName(directive.configurations[1].name, ['c']); 8319 _expectDottedName(directive.configurations[1].name, ['c']);
8373 expect(directive.combinators, hasLength(0)); 8320 expect(directive.combinators, hasLength(0));
8374 expect(directive.semicolon, isNotNull); 8321 expect(directive.semicolon, isNotNull);
8375 } 8322 }
8376 8323
8377 void test_parseExportDirective_configuration_single() { 8324 void test_parseExportDirective_configuration_single() {
8378 createParser("export 'lib/lib.dart' if (a.b == 'c.dart') '';"); 8325 createParser("export 'lib/lib.dart' if (a.b == 'c.dart') '';");
8379 ExportDirective directive = 8326 ExportDirective directive = parseFullDirective();
8380 parser.parseExportDirective(emptyCommentAndMetadata());
8381 expectNotNullIfNoErrors(directive); 8327 expectNotNullIfNoErrors(directive);
8382 listener.assertNoErrors(); 8328 listener.assertNoErrors();
8383 expect(directive.keyword, isNotNull); 8329 expect(directive.keyword, isNotNull);
8384 expect(directive.uri, isNotNull); 8330 expect(directive.uri, isNotNull);
8385 expect(directive.configurations, hasLength(1)); 8331 expect(directive.configurations, hasLength(1));
8386 _expectDottedName(directive.configurations[0].name, ['a', 'b']); 8332 _expectDottedName(directive.configurations[0].name, ['a', 'b']);
8387 expect(directive.combinators, hasLength(0)); 8333 expect(directive.combinators, hasLength(0));
8388 expect(directive.semicolon, isNotNull); 8334 expect(directive.semicolon, isNotNull);
8389 } 8335 }
8390 8336
8391 void test_parseExportDirective_hide() { 8337 void test_parseExportDirective_hide() {
8392 createParser("export 'lib/lib.dart' hide A, B;"); 8338 createParser("export 'lib/lib.dart' hide A, B;");
8393 ExportDirective directive = 8339 ExportDirective directive = parseFullDirective();
8394 parser.parseExportDirective(emptyCommentAndMetadata());
8395 expectNotNullIfNoErrors(directive); 8340 expectNotNullIfNoErrors(directive);
8396 listener.assertNoErrors(); 8341 listener.assertNoErrors();
8397 expect(directive.keyword, isNotNull); 8342 expect(directive.keyword, isNotNull);
8398 expect(directive.uri, isNotNull); 8343 expect(directive.uri, isNotNull);
8399 expect(directive.combinators, hasLength(1)); 8344 expect(directive.combinators, hasLength(1));
8400 expect(directive.semicolon, isNotNull); 8345 expect(directive.semicolon, isNotNull);
8401 } 8346 }
8402 8347
8403 void test_parseExportDirective_hide_show() { 8348 void test_parseExportDirective_hide_show() {
8404 createParser("export 'lib/lib.dart' hide A show B;"); 8349 createParser("export 'lib/lib.dart' hide A show B;");
8405 ExportDirective directive = 8350 ExportDirective directive = parseFullDirective();
8406 parser.parseExportDirective(emptyCommentAndMetadata());
8407 expectNotNullIfNoErrors(directive); 8351 expectNotNullIfNoErrors(directive);
8408 listener.assertNoErrors(); 8352 listener.assertNoErrors();
8409 expect(directive.keyword, isNotNull); 8353 expect(directive.keyword, isNotNull);
8410 expect(directive.uri, isNotNull); 8354 expect(directive.uri, isNotNull);
8411 expect(directive.combinators, hasLength(2)); 8355 expect(directive.combinators, hasLength(2));
8412 expect(directive.semicolon, isNotNull); 8356 expect(directive.semicolon, isNotNull);
8413 } 8357 }
8414 8358
8415 void test_parseExportDirective_noCombinator() { 8359 void test_parseExportDirective_noCombinator() {
8416 createParser("export 'lib/lib.dart';"); 8360 createParser("export 'lib/lib.dart';");
8417 ExportDirective directive = 8361 ExportDirective directive = parseFullDirective();
8418 parser.parseExportDirective(emptyCommentAndMetadata());
8419 expectNotNullIfNoErrors(directive); 8362 expectNotNullIfNoErrors(directive);
8420 listener.assertNoErrors(); 8363 listener.assertNoErrors();
8421 expect(directive.keyword, isNotNull); 8364 expect(directive.keyword, isNotNull);
8422 expect(directive.uri, isNotNull); 8365 expect(directive.uri, isNotNull);
8423 expect(directive.combinators, hasLength(0)); 8366 expect(directive.combinators, hasLength(0));
8424 expect(directive.semicolon, isNotNull); 8367 expect(directive.semicolon, isNotNull);
8425 } 8368 }
8426 8369
8427 void test_parseExportDirective_show() { 8370 void test_parseExportDirective_show() {
8428 createParser("export 'lib/lib.dart' show A, B;"); 8371 createParser("export 'lib/lib.dart' show A, B;");
8429 ExportDirective directive = 8372 ExportDirective directive = parseFullDirective();
8430 parser.parseExportDirective(emptyCommentAndMetadata());
8431 expectNotNullIfNoErrors(directive); 8373 expectNotNullIfNoErrors(directive);
8432 listener.assertNoErrors(); 8374 listener.assertNoErrors();
8433 expect(directive.keyword, isNotNull); 8375 expect(directive.keyword, isNotNull);
8434 expect(directive.uri, isNotNull); 8376 expect(directive.uri, isNotNull);
8435 expect(directive.combinators, hasLength(1)); 8377 expect(directive.combinators, hasLength(1));
8436 expect(directive.semicolon, isNotNull); 8378 expect(directive.semicolon, isNotNull);
8437 } 8379 }
8438 8380
8439 void test_parseExportDirective_show_hide() { 8381 void test_parseExportDirective_show_hide() {
8440 createParser("export 'lib/lib.dart' show B hide A;"); 8382 createParser("export 'lib/lib.dart' show B hide A;");
8441 ExportDirective directive = 8383 ExportDirective directive = parseFullDirective();
8442 parser.parseExportDirective(emptyCommentAndMetadata());
8443 expectNotNullIfNoErrors(directive); 8384 expectNotNullIfNoErrors(directive);
8444 listener.assertNoErrors(); 8385 listener.assertNoErrors();
8445 expect(directive.keyword, isNotNull); 8386 expect(directive.keyword, isNotNull);
8446 expect(directive.uri, isNotNull); 8387 expect(directive.uri, isNotNull);
8447 expect(directive.combinators, hasLength(2)); 8388 expect(directive.combinators, hasLength(2));
8448 expect(directive.semicolon, isNotNull); 8389 expect(directive.semicolon, isNotNull);
8449 } 8390 }
8450 8391
8451 void test_parseExpression_assign() { 8392 void test_parseExpression_assign() {
8452 // TODO(brianwilkerson) Implement more tests for this method. 8393 // TODO(brianwilkerson) Implement more tests for this method.
(...skipping 1725 matching lines...) Expand 10 before | Expand all | Expand 10 after
10178 listener.assertNoErrors(); 10119 listener.assertNoErrors();
10179 expect(expression.body, isNotNull); 10120 expect(expression.body, isNotNull);
10180 expect(expression.typeParameters, isNotNull); 10121 expect(expression.typeParameters, isNotNull);
10181 expect(expression.parameters, isNotNull); 10122 expect(expression.parameters, isNotNull);
10182 expect((expression.body as ExpressionFunctionBody).semicolon, isNull); 10123 expect((expression.body as ExpressionFunctionBody).semicolon, isNull);
10183 } 10124 }
10184 10125
10185 @failingTest 10126 @failingTest
10186 void test_parseGenericTypeAlias_noTypeParameters() { 10127 void test_parseGenericTypeAlias_noTypeParameters() {
10187 createParser('F = int Function(int);'); 10128 createParser('F = int Function(int);');
10188 GenericTypeAlias alias = 10129 GenericTypeAlias alias = parseFullCompilationUnitMember();
10189 parser.parseGenericTypeAlias(emptyCommentAndMetadata(), null);
10190 expectNotNullIfNoErrors(alias); 10130 expectNotNullIfNoErrors(alias);
10191 listener.assertNoErrors(); 10131 listener.assertNoErrors();
10192 expect(alias.name, isNotNull); 10132 expect(alias.name, isNotNull);
10193 expect(alias.name.name, 'F'); 10133 expect(alias.name.name, 'F');
10194 expect(alias.typeParameters, isNull); 10134 expect(alias.typeParameters, isNull);
10195 expect(alias.equals, isNotNull); 10135 expect(alias.equals, isNotNull);
10196 expect(alias.functionType, isNotNull); 10136 expect(alias.functionType, isNotNull);
10197 expect(alias.semicolon, isNotNull); 10137 expect(alias.semicolon, isNotNull);
10198 } 10138 }
10199 10139
10200 @failingTest 10140 @failingTest
10201 void test_parseGenericTypeAlias_typeParameters() { 10141 void test_parseGenericTypeAlias_typeParameters() {
10202 createParser('F<T> = T Function(T);'); 10142 createParser('F<T> = T Function(T);');
10203 GenericTypeAlias alias = 10143 GenericTypeAlias alias = parseFullCompilationUnitMember();
10204 parser.parseGenericTypeAlias(emptyCommentAndMetadata(), null);
10205 expectNotNullIfNoErrors(alias); 10144 expectNotNullIfNoErrors(alias);
10206 listener.assertNoErrors(); 10145 listener.assertNoErrors();
10207 expect(alias.name, isNotNull); 10146 expect(alias.name, isNotNull);
10208 expect(alias.name.name, 'F'); 10147 expect(alias.name.name, 'F');
10209 expect(alias.typeParameters, isNotNull); 10148 expect(alias.typeParameters, isNotNull);
10210 expect(alias.equals, isNotNull); 10149 expect(alias.equals, isNotNull);
10211 expect(alias.functionType, isNotNull); 10150 expect(alias.functionType, isNotNull);
10212 expect(alias.semicolon, isNotNull); 10151 expect(alias.semicolon, isNotNull);
10213 } 10152 }
10214 10153
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
10339 createParser('implements A'); 10278 createParser('implements A');
10340 ImplementsClause clause = parser.parseImplementsClause(); 10279 ImplementsClause clause = parser.parseImplementsClause();
10341 expectNotNullIfNoErrors(clause); 10280 expectNotNullIfNoErrors(clause);
10342 listener.assertNoErrors(); 10281 listener.assertNoErrors();
10343 expect(clause.interfaces, hasLength(1)); 10282 expect(clause.interfaces, hasLength(1));
10344 expect(clause.implementsKeyword, isNotNull); 10283 expect(clause.implementsKeyword, isNotNull);
10345 } 10284 }
10346 10285
10347 void test_parseImportDirective_configuration_multiple() { 10286 void test_parseImportDirective_configuration_multiple() {
10348 createParser("import 'lib/lib.dart' if (a) 'b.dart' if (c) 'd.dart';"); 10287 createParser("import 'lib/lib.dart' if (a) 'b.dart' if (c) 'd.dart';");
10349 ImportDirective directive = 10288 ImportDirective directive = parseFullDirective();
10350 parser.parseImportDirective(emptyCommentAndMetadata());
10351 expectNotNullIfNoErrors(directive); 10289 expectNotNullIfNoErrors(directive);
10352 listener.assertNoErrors(); 10290 listener.assertNoErrors();
10353 expect(directive.keyword, isNotNull); 10291 expect(directive.keyword, isNotNull);
10354 expect(directive.uri, isNotNull); 10292 expect(directive.uri, isNotNull);
10355 expect(directive.configurations, hasLength(2)); 10293 expect(directive.configurations, hasLength(2));
10356 _expectDottedName(directive.configurations[0].name, ['a']); 10294 _expectDottedName(directive.configurations[0].name, ['a']);
10357 _expectDottedName(directive.configurations[1].name, ['c']); 10295 _expectDottedName(directive.configurations[1].name, ['c']);
10358 expect(directive.deferredKeyword, isNull); 10296 expect(directive.deferredKeyword, isNull);
10359 expect(directive.asKeyword, isNull); 10297 expect(directive.asKeyword, isNull);
10360 expect(directive.prefix, isNull); 10298 expect(directive.prefix, isNull);
10361 expect(directive.combinators, hasLength(0)); 10299 expect(directive.combinators, hasLength(0));
10362 expect(directive.semicolon, isNotNull); 10300 expect(directive.semicolon, isNotNull);
10363 } 10301 }
10364 10302
10365 void test_parseImportDirective_configuration_single() { 10303 void test_parseImportDirective_configuration_single() {
10366 createParser("import 'lib/lib.dart' if (a.b == 'c.dart') '';"); 10304 createParser("import 'lib/lib.dart' if (a.b == 'c.dart') '';");
10367 ImportDirective directive = 10305 ImportDirective directive = parseFullDirective();
10368 parser.parseImportDirective(emptyCommentAndMetadata());
10369 expectNotNullIfNoErrors(directive); 10306 expectNotNullIfNoErrors(directive);
10370 listener.assertNoErrors(); 10307 listener.assertNoErrors();
10371 expect(directive.keyword, isNotNull); 10308 expect(directive.keyword, isNotNull);
10372 expect(directive.uri, isNotNull); 10309 expect(directive.uri, isNotNull);
10373 expect(directive.configurations, hasLength(1)); 10310 expect(directive.configurations, hasLength(1));
10374 _expectDottedName(directive.configurations[0].name, ['a', 'b']); 10311 _expectDottedName(directive.configurations[0].name, ['a', 'b']);
10375 expect(directive.deferredKeyword, isNull); 10312 expect(directive.deferredKeyword, isNull);
10376 expect(directive.asKeyword, isNull); 10313 expect(directive.asKeyword, isNull);
10377 expect(directive.prefix, isNull); 10314 expect(directive.prefix, isNull);
10378 expect(directive.combinators, hasLength(0)); 10315 expect(directive.combinators, hasLength(0));
10379 expect(directive.semicolon, isNotNull); 10316 expect(directive.semicolon, isNotNull);
10380 } 10317 }
10381 10318
10382 void test_parseImportDirective_deferred() { 10319 void test_parseImportDirective_deferred() {
10383 createParser("import 'lib/lib.dart' deferred as a;"); 10320 createParser("import 'lib/lib.dart' deferred as a;");
10384 ImportDirective directive = 10321 ImportDirective directive = parseFullDirective();
10385 parser.parseImportDirective(emptyCommentAndMetadata());
10386 expectNotNullIfNoErrors(directive); 10322 expectNotNullIfNoErrors(directive);
10387 listener.assertNoErrors(); 10323 listener.assertNoErrors();
10388 expect(directive.keyword, isNotNull); 10324 expect(directive.keyword, isNotNull);
10389 expect(directive.uri, isNotNull); 10325 expect(directive.uri, isNotNull);
10390 expect(directive.deferredKeyword, isNotNull); 10326 expect(directive.deferredKeyword, isNotNull);
10391 expect(directive.asKeyword, isNotNull); 10327 expect(directive.asKeyword, isNotNull);
10392 expect(directive.prefix, isNotNull); 10328 expect(directive.prefix, isNotNull);
10393 expect(directive.combinators, hasLength(0)); 10329 expect(directive.combinators, hasLength(0));
10394 expect(directive.semicolon, isNotNull); 10330 expect(directive.semicolon, isNotNull);
10395 } 10331 }
10396 10332
10397 void test_parseImportDirective_hide() { 10333 void test_parseImportDirective_hide() {
10398 createParser("import 'lib/lib.dart' hide A, B;"); 10334 createParser("import 'lib/lib.dart' hide A, B;");
10399 ImportDirective directive = 10335 ImportDirective directive = parseFullDirective();
10400 parser.parseImportDirective(emptyCommentAndMetadata());
10401 expectNotNullIfNoErrors(directive); 10336 expectNotNullIfNoErrors(directive);
10402 listener.assertNoErrors(); 10337 listener.assertNoErrors();
10403 expect(directive.keyword, isNotNull); 10338 expect(directive.keyword, isNotNull);
10404 expect(directive.uri, isNotNull); 10339 expect(directive.uri, isNotNull);
10405 expect(directive.deferredKeyword, isNull); 10340 expect(directive.deferredKeyword, isNull);
10406 expect(directive.asKeyword, isNull); 10341 expect(directive.asKeyword, isNull);
10407 expect(directive.prefix, isNull); 10342 expect(directive.prefix, isNull);
10408 expect(directive.combinators, hasLength(1)); 10343 expect(directive.combinators, hasLength(1));
10409 expect(directive.semicolon, isNotNull); 10344 expect(directive.semicolon, isNotNull);
10410 } 10345 }
10411 10346
10412 void test_parseImportDirective_noCombinator() { 10347 void test_parseImportDirective_noCombinator() {
10413 createParser("import 'lib/lib.dart';"); 10348 createParser("import 'lib/lib.dart';");
10414 ImportDirective directive = 10349 ImportDirective directive = parseFullDirective();
10415 parser.parseImportDirective(emptyCommentAndMetadata());
10416 expectNotNullIfNoErrors(directive); 10350 expectNotNullIfNoErrors(directive);
10417 listener.assertNoErrors(); 10351 listener.assertNoErrors();
10418 expect(directive.keyword, isNotNull); 10352 expect(directive.keyword, isNotNull);
10419 expect(directive.uri, isNotNull); 10353 expect(directive.uri, isNotNull);
10420 expect(directive.deferredKeyword, isNull); 10354 expect(directive.deferredKeyword, isNull);
10421 expect(directive.asKeyword, isNull); 10355 expect(directive.asKeyword, isNull);
10422 expect(directive.prefix, isNull); 10356 expect(directive.prefix, isNull);
10423 expect(directive.combinators, hasLength(0)); 10357 expect(directive.combinators, hasLength(0));
10424 expect(directive.semicolon, isNotNull); 10358 expect(directive.semicolon, isNotNull);
10425 } 10359 }
10426 10360
10427 void test_parseImportDirective_prefix() { 10361 void test_parseImportDirective_prefix() {
10428 createParser("import 'lib/lib.dart' as a;"); 10362 createParser("import 'lib/lib.dart' as a;");
10429 ImportDirective directive = 10363 ImportDirective directive = parseFullDirective();
10430 parser.parseImportDirective(emptyCommentAndMetadata());
10431 expectNotNullIfNoErrors(directive); 10364 expectNotNullIfNoErrors(directive);
10432 listener.assertNoErrors(); 10365 listener.assertNoErrors();
10433 expect(directive.keyword, isNotNull); 10366 expect(directive.keyword, isNotNull);
10434 expect(directive.uri, isNotNull); 10367 expect(directive.uri, isNotNull);
10435 expect(directive.deferredKeyword, isNull); 10368 expect(directive.deferredKeyword, isNull);
10436 expect(directive.asKeyword, isNotNull); 10369 expect(directive.asKeyword, isNotNull);
10437 expect(directive.prefix, isNotNull); 10370 expect(directive.prefix, isNotNull);
10438 expect(directive.combinators, hasLength(0)); 10371 expect(directive.combinators, hasLength(0));
10439 expect(directive.semicolon, isNotNull); 10372 expect(directive.semicolon, isNotNull);
10440 } 10373 }
10441 10374
10442 void test_parseImportDirective_prefix_hide_show() { 10375 void test_parseImportDirective_prefix_hide_show() {
10443 createParser("import 'lib/lib.dart' as a hide A show B;"); 10376 createParser("import 'lib/lib.dart' as a hide A show B;");
10444 ImportDirective directive = 10377 ImportDirective directive = parseFullDirective();
10445 parser.parseImportDirective(emptyCommentAndMetadata());
10446 expectNotNullIfNoErrors(directive); 10378 expectNotNullIfNoErrors(directive);
10447 listener.assertNoErrors(); 10379 listener.assertNoErrors();
10448 expect(directive.keyword, isNotNull); 10380 expect(directive.keyword, isNotNull);
10449 expect(directive.uri, isNotNull); 10381 expect(directive.uri, isNotNull);
10450 expect(directive.deferredKeyword, isNull); 10382 expect(directive.deferredKeyword, isNull);
10451 expect(directive.asKeyword, isNotNull); 10383 expect(directive.asKeyword, isNotNull);
10452 expect(directive.prefix, isNotNull); 10384 expect(directive.prefix, isNotNull);
10453 expect(directive.combinators, hasLength(2)); 10385 expect(directive.combinators, hasLength(2));
10454 expect(directive.semicolon, isNotNull); 10386 expect(directive.semicolon, isNotNull);
10455 } 10387 }
10456 10388
10457 void test_parseImportDirective_prefix_show_hide() { 10389 void test_parseImportDirective_prefix_show_hide() {
10458 createParser("import 'lib/lib.dart' as a show B hide A;"); 10390 createParser("import 'lib/lib.dart' as a show B hide A;");
10459 ImportDirective directive = 10391 ImportDirective directive = parseFullDirective();
10460 parser.parseImportDirective(emptyCommentAndMetadata());
10461 expectNotNullIfNoErrors(directive); 10392 expectNotNullIfNoErrors(directive);
10462 listener.assertNoErrors(); 10393 listener.assertNoErrors();
10463 expect(directive.keyword, isNotNull); 10394 expect(directive.keyword, isNotNull);
10464 expect(directive.uri, isNotNull); 10395 expect(directive.uri, isNotNull);
10465 expect(directive.deferredKeyword, isNull); 10396 expect(directive.deferredKeyword, isNull);
10466 expect(directive.asKeyword, isNotNull); 10397 expect(directive.asKeyword, isNotNull);
10467 expect(directive.prefix, isNotNull); 10398 expect(directive.prefix, isNotNull);
10468 expect(directive.combinators, hasLength(2)); 10399 expect(directive.combinators, hasLength(2));
10469 expect(directive.semicolon, isNotNull); 10400 expect(directive.semicolon, isNotNull);
10470 } 10401 }
10471 10402
10472 void test_parseImportDirective_show() { 10403 void test_parseImportDirective_show() {
10473 createParser("import 'lib/lib.dart' show A, B;"); 10404 createParser("import 'lib/lib.dart' show A, B;");
10474 ImportDirective directive = 10405 ImportDirective directive = parseFullDirective();
10475 parser.parseImportDirective(emptyCommentAndMetadata());
10476 expectNotNullIfNoErrors(directive); 10406 expectNotNullIfNoErrors(directive);
10477 listener.assertNoErrors(); 10407 listener.assertNoErrors();
10478 expect(directive.keyword, isNotNull); 10408 expect(directive.keyword, isNotNull);
10479 expect(directive.uri, isNotNull); 10409 expect(directive.uri, isNotNull);
10480 expect(directive.deferredKeyword, isNull); 10410 expect(directive.deferredKeyword, isNull);
10481 expect(directive.asKeyword, isNull); 10411 expect(directive.asKeyword, isNull);
10482 expect(directive.prefix, isNull); 10412 expect(directive.prefix, isNull);
10483 expect(directive.combinators, hasLength(1)); 10413 expect(directive.combinators, hasLength(1));
10484 expect(directive.semicolon, isNotNull); 10414 expect(directive.semicolon, isNotNull);
10485 } 10415 }
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
10763 expect(name.period, isNull); 10693 expect(name.period, isNull);
10764 expect(name.name, isNull); 10694 expect(name.name, isNull);
10765 expect(expression.argumentList, isNotNull); 10695 expect(expression.argumentList, isNotNull);
10766 NodeList<TypeAnnotation> arguments = type.typeArguments.arguments; 10696 NodeList<TypeAnnotation> arguments = type.typeArguments.arguments;
10767 expect(arguments, hasLength(1)); 10697 expect(arguments, hasLength(1));
10768 expect((arguments[0] as TypeName).question, isNotNull); 10698 expect((arguments[0] as TypeName).question, isNotNull);
10769 } 10699 }
10770 10700
10771 void test_parseLibraryDirective() { 10701 void test_parseLibraryDirective() {
10772 createParser('library l;'); 10702 createParser('library l;');
10773 LibraryDirective directive = 10703 LibraryDirective directive = parseFullDirective();
10774 parser.parseLibraryDirective(emptyCommentAndMetadata());
10775 expectNotNullIfNoErrors(directive); 10704 expectNotNullIfNoErrors(directive);
10776 listener.assertNoErrors(); 10705 listener.assertNoErrors();
10777 expect(directive.libraryKeyword, isNotNull); 10706 expect(directive.libraryKeyword, isNotNull);
10778 expect(directive.name, isNotNull); 10707 expect(directive.name, isNotNull);
10779 expect(directive.semicolon, isNotNull); 10708 expect(directive.semicolon, isNotNull);
10780 } 10709 }
10781 10710
10782 void test_parseLibraryIdentifier_multiple() { 10711 void test_parseLibraryIdentifier_multiple() {
10783 String name = "a.b.c"; 10712 String name = "a.b.c";
10784 createParser(name); 10713 createParser(name);
(...skipping 965 matching lines...) Expand 10 before | Expand all | Expand 10 after
11750 expect(method.propertyKeyword, isNull); 11679 expect(method.propertyKeyword, isNull);
11751 expect(method.returnType, returnType); 11680 expect(method.returnType, returnType);
11752 } 11681 }
11753 11682
11754 void test_parseOptionalReturnType() { 11683 void test_parseOptionalReturnType() {
11755 // TODO(brianwilkerson) Implement tests for this method. 11684 // TODO(brianwilkerson) Implement tests for this method.
11756 } 11685 }
11757 11686
11758 void test_parsePartDirective() { 11687 void test_parsePartDirective() {
11759 createParser("part 'lib/lib.dart';"); 11688 createParser("part 'lib/lib.dart';");
11760 PartDirective directive = 11689 PartDirective directive = parseFullDirective();
11761 parser.parsePartOrPartOfDirective(emptyCommentAndMetadata());
11762 expectNotNullIfNoErrors(directive); 11690 expectNotNullIfNoErrors(directive);
11763 listener.assertNoErrors(); 11691 listener.assertNoErrors();
11764 expect(directive.partKeyword, isNotNull); 11692 expect(directive.partKeyword, isNotNull);
11765 expect(directive.uri, isNotNull); 11693 expect(directive.uri, isNotNull);
11766 expect(directive.semicolon, isNotNull); 11694 expect(directive.semicolon, isNotNull);
11767 } 11695 }
11768 11696
11769 void test_parsePartOfDirective_name() { 11697 void test_parsePartOfDirective_name() {
11770 enableUriInPartOf = true; 11698 enableUriInPartOf = true;
11771 createParser("part of l;"); 11699 createParser("part of l;");
11772 PartOfDirective directive = 11700 PartOfDirective directive = parseFullDirective();
11773 parser.parsePartOrPartOfDirective(emptyCommentAndMetadata());
11774 expect(directive.partKeyword, isNotNull); 11701 expect(directive.partKeyword, isNotNull);
11775 expect(directive.ofKeyword, isNotNull); 11702 expect(directive.ofKeyword, isNotNull);
11776 expect(directive.libraryName, isNotNull); 11703 expect(directive.libraryName, isNotNull);
11777 expect(directive.uri, isNull); 11704 expect(directive.uri, isNull);
11778 expect(directive.semicolon, isNotNull); 11705 expect(directive.semicolon, isNotNull);
11779 } 11706 }
11780 11707
11781 void test_parsePartOfDirective_uri() { 11708 void test_parsePartOfDirective_uri() {
11782 enableUriInPartOf = true; 11709 enableUriInPartOf = true;
11783 createParser("part of 'lib.dart';"); 11710 createParser("part of 'lib.dart';");
11784 PartOfDirective directive = 11711 PartOfDirective directive = parseFullDirective();
11785 parser.parsePartOrPartOfDirective(emptyCommentAndMetadata());
11786 expect(directive.partKeyword, isNotNull); 11712 expect(directive.partKeyword, isNotNull);
11787 expect(directive.ofKeyword, isNotNull); 11713 expect(directive.ofKeyword, isNotNull);
11788 expect(directive.libraryName, isNull); 11714 expect(directive.libraryName, isNull);
11789 expect(directive.uri, isNotNull); 11715 expect(directive.uri, isNotNull);
11790 expect(directive.semicolon, isNotNull); 11716 expect(directive.semicolon, isNotNull);
11791 } 11717 }
11792 11718
11793 void test_parsePostfixExpression_decrement() { 11719 void test_parsePostfixExpression_decrement() {
11794 createParser('i--'); 11720 createParser('i--');
11795 Expression expression = parser.parsePostfixExpression(); 11721 Expression expression = parser.parsePostfixExpression();
(...skipping 1462 matching lines...) Expand 10 before | Expand all | Expand 10 after
13258 expect(clause.exceptionParameter, isNotNull); 13184 expect(clause.exceptionParameter, isNotNull);
13259 expect(clause.comma, isNotNull); 13185 expect(clause.comma, isNotNull);
13260 expect(clause.stackTraceParameter, isNotNull); 13186 expect(clause.stackTraceParameter, isNotNull);
13261 expect(clause.body, isNotNull); 13187 expect(clause.body, isNotNull);
13262 expect(statement.finallyKeyword, isNotNull); 13188 expect(statement.finallyKeyword, isNotNull);
13263 expect(statement.finallyBlock, isNotNull); 13189 expect(statement.finallyBlock, isNotNull);
13264 } 13190 }
13265 13191
13266 void test_parseTypeAlias_function_noParameters() { 13192 void test_parseTypeAlias_function_noParameters() {
13267 createParser('typedef bool F();'); 13193 createParser('typedef bool F();');
13268 FunctionTypeAlias typeAlias = 13194 FunctionTypeAlias typeAlias = parseFullCompilationUnitMember();
13269 parser.parseTypeAlias(emptyCommentAndMetadata());
13270 expectNotNullIfNoErrors(typeAlias); 13195 expectNotNullIfNoErrors(typeAlias);
13271 listener.assertNoErrors(); 13196 listener.assertNoErrors();
13272 expect(typeAlias.typedefKeyword, isNotNull); 13197 expect(typeAlias.typedefKeyword, isNotNull);
13273 expect(typeAlias.name, isNotNull); 13198 expect(typeAlias.name, isNotNull);
13274 expect(typeAlias.parameters, isNotNull); 13199 expect(typeAlias.parameters, isNotNull);
13275 expect(typeAlias.returnType, isNotNull); 13200 expect(typeAlias.returnType, isNotNull);
13276 expect(typeAlias.semicolon, isNotNull); 13201 expect(typeAlias.semicolon, isNotNull);
13277 expect(typeAlias.typeParameters, isNull); 13202 expect(typeAlias.typeParameters, isNull);
13278 } 13203 }
13279 13204
13280 void test_parseTypeAlias_function_noReturnType() { 13205 void test_parseTypeAlias_function_noReturnType() {
13281 createParser('typedef F();'); 13206 createParser('typedef F();');
13282 FunctionTypeAlias typeAlias = 13207 FunctionTypeAlias typeAlias = parseFullCompilationUnitMember();
13283 parser.parseTypeAlias(emptyCommentAndMetadata());
13284 expectNotNullIfNoErrors(typeAlias); 13208 expectNotNullIfNoErrors(typeAlias);
13285 listener.assertNoErrors(); 13209 listener.assertNoErrors();
13286 expect(typeAlias.typedefKeyword, isNotNull); 13210 expect(typeAlias.typedefKeyword, isNotNull);
13287 expect(typeAlias.name, isNotNull); 13211 expect(typeAlias.name, isNotNull);
13288 expect(typeAlias.parameters, isNotNull); 13212 expect(typeAlias.parameters, isNotNull);
13289 expect(typeAlias.returnType, isNull); 13213 expect(typeAlias.returnType, isNull);
13290 expect(typeAlias.semicolon, isNotNull); 13214 expect(typeAlias.semicolon, isNotNull);
13291 expect(typeAlias.typeParameters, isNull); 13215 expect(typeAlias.typeParameters, isNull);
13292 } 13216 }
13293 13217
13294 void test_parseTypeAlias_function_parameterizedReturnType() { 13218 void test_parseTypeAlias_function_parameterizedReturnType() {
13295 createParser('typedef A<B> F();'); 13219 createParser('typedef A<B> F();');
13296 FunctionTypeAlias typeAlias = 13220 FunctionTypeAlias typeAlias = parseFullCompilationUnitMember();
13297 parser.parseTypeAlias(emptyCommentAndMetadata());
13298 expectNotNullIfNoErrors(typeAlias); 13221 expectNotNullIfNoErrors(typeAlias);
13299 listener.assertNoErrors(); 13222 listener.assertNoErrors();
13300 expect(typeAlias.typedefKeyword, isNotNull); 13223 expect(typeAlias.typedefKeyword, isNotNull);
13301 expect(typeAlias.name, isNotNull); 13224 expect(typeAlias.name, isNotNull);
13302 expect(typeAlias.parameters, isNotNull); 13225 expect(typeAlias.parameters, isNotNull);
13303 expect(typeAlias.returnType, isNotNull); 13226 expect(typeAlias.returnType, isNotNull);
13304 expect(typeAlias.semicolon, isNotNull); 13227 expect(typeAlias.semicolon, isNotNull);
13305 expect(typeAlias.typeParameters, isNull); 13228 expect(typeAlias.typeParameters, isNull);
13306 } 13229 }
13307 13230
13308 void test_parseTypeAlias_function_parameters() { 13231 void test_parseTypeAlias_function_parameters() {
13309 createParser('typedef bool F(Object value);'); 13232 createParser('typedef bool F(Object value);');
13310 FunctionTypeAlias typeAlias = 13233 FunctionTypeAlias typeAlias = parseFullCompilationUnitMember();
13311 parser.parseTypeAlias(emptyCommentAndMetadata());
13312 expectNotNullIfNoErrors(typeAlias); 13234 expectNotNullIfNoErrors(typeAlias);
13313 listener.assertNoErrors(); 13235 listener.assertNoErrors();
13314 expect(typeAlias.typedefKeyword, isNotNull); 13236 expect(typeAlias.typedefKeyword, isNotNull);
13315 expect(typeAlias.name, isNotNull); 13237 expect(typeAlias.name, isNotNull);
13316 expect(typeAlias.parameters, isNotNull); 13238 expect(typeAlias.parameters, isNotNull);
13317 expect(typeAlias.returnType, isNotNull); 13239 expect(typeAlias.returnType, isNotNull);
13318 expect(typeAlias.semicolon, isNotNull); 13240 expect(typeAlias.semicolon, isNotNull);
13319 expect(typeAlias.typeParameters, isNull); 13241 expect(typeAlias.typeParameters, isNull);
13320 } 13242 }
13321 13243
13322 void test_parseTypeAlias_function_typeParameters() { 13244 void test_parseTypeAlias_function_typeParameters() {
13323 createParser('typedef bool F<E>();'); 13245 createParser('typedef bool F<E>();');
13324 FunctionTypeAlias typeAlias = 13246 FunctionTypeAlias typeAlias = parseFullCompilationUnitMember();
13325 parser.parseTypeAlias(emptyCommentAndMetadata());
13326 expectNotNullIfNoErrors(typeAlias); 13247 expectNotNullIfNoErrors(typeAlias);
13327 listener.assertNoErrors(); 13248 listener.assertNoErrors();
13328 expect(typeAlias.typedefKeyword, isNotNull); 13249 expect(typeAlias.typedefKeyword, isNotNull);
13329 expect(typeAlias.name, isNotNull); 13250 expect(typeAlias.name, isNotNull);
13330 expect(typeAlias.parameters, isNotNull); 13251 expect(typeAlias.parameters, isNotNull);
13331 expect(typeAlias.returnType, isNotNull); 13252 expect(typeAlias.returnType, isNotNull);
13332 expect(typeAlias.semicolon, isNotNull); 13253 expect(typeAlias.semicolon, isNotNull);
13333 expect(typeAlias.typeParameters, isNotNull); 13254 expect(typeAlias.typeParameters, isNotNull);
13334 } 13255 }
13335 13256
13336 void test_parseTypeAlias_function_voidReturnType() { 13257 void test_parseTypeAlias_function_voidReturnType() {
13337 createParser('typedef void F();'); 13258 createParser('typedef void F();');
13338 FunctionTypeAlias typeAlias = 13259 FunctionTypeAlias typeAlias = parseFullCompilationUnitMember();
13339 parser.parseTypeAlias(emptyCommentAndMetadata());
13340 expectNotNullIfNoErrors(typeAlias); 13260 expectNotNullIfNoErrors(typeAlias);
13341 listener.assertNoErrors(); 13261 listener.assertNoErrors();
13342 expect(typeAlias.typedefKeyword, isNotNull); 13262 expect(typeAlias.typedefKeyword, isNotNull);
13343 expect(typeAlias.name, isNotNull); 13263 expect(typeAlias.name, isNotNull);
13344 expect(typeAlias.parameters, isNotNull); 13264 expect(typeAlias.parameters, isNotNull);
13345 expect(typeAlias.returnType, isNotNull); 13265 expect(typeAlias.returnType, isNotNull);
13346 expect(typeAlias.semicolon, isNotNull); 13266 expect(typeAlias.semicolon, isNotNull);
13347 expect(typeAlias.typeParameters, isNull); 13267 expect(typeAlias.typeParameters, isNull);
13348 } 13268 }
13349 13269
13350 @failingTest 13270 @failingTest
13351 void test_parseTypeAlias_genericFunction_noParameters() { 13271 void test_parseTypeAlias_genericFunction_noParameters() {
13352 createParser('typedef F = bool Function();'); 13272 createParser('typedef F = bool Function();');
13353 GenericTypeAlias typeAlias = 13273 GenericTypeAlias typeAlias = parseFullCompilationUnitMember();
13354 parser.parseTypeAlias(emptyCommentAndMetadata());
13355 expectNotNullIfNoErrors(typeAlias); 13274 expectNotNullIfNoErrors(typeAlias);
13356 listener.assertNoErrors(); 13275 listener.assertNoErrors();
13357 expect(typeAlias.typedefKeyword, isNotNull); 13276 expect(typeAlias.typedefKeyword, isNotNull);
13358 expect(typeAlias.name, isNotNull); 13277 expect(typeAlias.name, isNotNull);
13359 expect(typeAlias.typeParameters, isNull); 13278 expect(typeAlias.typeParameters, isNull);
13360 expect(typeAlias.semicolon, isNotNull); 13279 expect(typeAlias.semicolon, isNotNull);
13361 GenericFunctionType functionType = typeAlias.functionType; 13280 GenericFunctionType functionType = typeAlias.functionType;
13362 expect(functionType, isNotNull); 13281 expect(functionType, isNotNull);
13363 expect(functionType.parameters, isNotNull); 13282 expect(functionType.parameters, isNotNull);
13364 expect(functionType.returnType, isNotNull); 13283 expect(functionType.returnType, isNotNull);
13365 expect(functionType.typeParameters, isNull); 13284 expect(functionType.typeParameters, isNull);
13366 } 13285 }
13367 13286
13368 @failingTest 13287 @failingTest
13369 void test_parseTypeAlias_genericFunction_noReturnType() { 13288 void test_parseTypeAlias_genericFunction_noReturnType() {
13370 createParser('typedef F = Function();'); 13289 createParser('typedef F = Function();');
13371 GenericTypeAlias typeAlias = 13290 GenericTypeAlias typeAlias = parseFullCompilationUnitMember();
13372 parser.parseTypeAlias(emptyCommentAndMetadata());
13373 expectNotNullIfNoErrors(typeAlias); 13291 expectNotNullIfNoErrors(typeAlias);
13374 listener.assertNoErrors(); 13292 listener.assertNoErrors();
13375 expect(typeAlias.typedefKeyword, isNotNull); 13293 expect(typeAlias.typedefKeyword, isNotNull);
13376 expect(typeAlias.name, isNotNull); 13294 expect(typeAlias.name, isNotNull);
13377 expect(typeAlias.typeParameters, isNull); 13295 expect(typeAlias.typeParameters, isNull);
13378 expect(typeAlias.semicolon, isNotNull); 13296 expect(typeAlias.semicolon, isNotNull);
13379 GenericFunctionType functionType = typeAlias.functionType; 13297 GenericFunctionType functionType = typeAlias.functionType;
13380 expect(functionType, isNotNull); 13298 expect(functionType, isNotNull);
13381 expect(functionType.parameters, isNotNull); 13299 expect(functionType.parameters, isNotNull);
13382 expect(functionType.returnType, isNull); 13300 expect(functionType.returnType, isNull);
13383 expect(functionType.typeParameters, isNull); 13301 expect(functionType.typeParameters, isNull);
13384 } 13302 }
13385 13303
13386 @failingTest 13304 @failingTest
13387 void test_parseTypeAlias_genericFunction_parameterizedReturnType() { 13305 void test_parseTypeAlias_genericFunction_parameterizedReturnType() {
13388 createParser('typedef F = A<B> Function();'); 13306 createParser('typedef F = A<B> Function();');
13389 GenericTypeAlias typeAlias = 13307 GenericTypeAlias typeAlias = parseFullCompilationUnitMember();
13390 parser.parseTypeAlias(emptyCommentAndMetadata());
13391 expectNotNullIfNoErrors(typeAlias); 13308 expectNotNullIfNoErrors(typeAlias);
13392 listener.assertNoErrors(); 13309 listener.assertNoErrors();
13393 expect(typeAlias.typedefKeyword, isNotNull); 13310 expect(typeAlias.typedefKeyword, isNotNull);
13394 expect(typeAlias.name, isNotNull); 13311 expect(typeAlias.name, isNotNull);
13395 expect(typeAlias.typeParameters, isNull); 13312 expect(typeAlias.typeParameters, isNull);
13396 expect(typeAlias.semicolon, isNotNull); 13313 expect(typeAlias.semicolon, isNotNull);
13397 GenericFunctionType functionType = typeAlias.functionType; 13314 GenericFunctionType functionType = typeAlias.functionType;
13398 expect(functionType, isNotNull); 13315 expect(functionType, isNotNull);
13399 expect(functionType.parameters, isNotNull); 13316 expect(functionType.parameters, isNotNull);
13400 expect(functionType.returnType, isNotNull); 13317 expect(functionType.returnType, isNotNull);
13401 expect(functionType.typeParameters, isNull); 13318 expect(functionType.typeParameters, isNull);
13402 } 13319 }
13403 13320
13404 @failingTest 13321 @failingTest
13405 void test_parseTypeAlias_genericFunction_parameters() { 13322 void test_parseTypeAlias_genericFunction_parameters() {
13406 createParser('typedef F = bool Function(Object value);'); 13323 createParser('typedef F = bool Function(Object value);');
13407 GenericTypeAlias typeAlias = 13324 GenericTypeAlias typeAlias = parseFullCompilationUnitMember();
13408 parser.parseTypeAlias(emptyCommentAndMetadata());
13409 expectNotNullIfNoErrors(typeAlias); 13325 expectNotNullIfNoErrors(typeAlias);
13410 listener.assertNoErrors(); 13326 listener.assertNoErrors();
13411 expect(typeAlias.typedefKeyword, isNotNull); 13327 expect(typeAlias.typedefKeyword, isNotNull);
13412 expect(typeAlias.name, isNotNull); 13328 expect(typeAlias.name, isNotNull);
13413 expect(typeAlias.typeParameters, isNull); 13329 expect(typeAlias.typeParameters, isNull);
13414 expect(typeAlias.semicolon, isNotNull); 13330 expect(typeAlias.semicolon, isNotNull);
13415 GenericFunctionType functionType = typeAlias.functionType; 13331 GenericFunctionType functionType = typeAlias.functionType;
13416 expect(functionType, isNotNull); 13332 expect(functionType, isNotNull);
13417 expect(functionType.parameters, isNotNull); 13333 expect(functionType.parameters, isNotNull);
13418 expect(functionType.returnType, isNotNull); 13334 expect(functionType.returnType, isNotNull);
13419 expect(functionType.typeParameters, isNull); 13335 expect(functionType.typeParameters, isNull);
13420 } 13336 }
13421 13337
13422 @failingTest 13338 @failingTest
13423 void test_parseTypeAlias_genericFunction_typeParameters() { 13339 void test_parseTypeAlias_genericFunction_typeParameters() {
13424 createParser('typedef F = bool Function<E>();'); 13340 createParser('typedef F = bool Function<E>();');
13425 GenericTypeAlias typeAlias = 13341 GenericTypeAlias typeAlias = parseFullCompilationUnitMember();
13426 parser.parseTypeAlias(emptyCommentAndMetadata());
13427 expectNotNullIfNoErrors(typeAlias); 13342 expectNotNullIfNoErrors(typeAlias);
13428 listener.assertNoErrors(); 13343 listener.assertNoErrors();
13429 expect(typeAlias.typedefKeyword, isNotNull); 13344 expect(typeAlias.typedefKeyword, isNotNull);
13430 expect(typeAlias.name, isNotNull); 13345 expect(typeAlias.name, isNotNull);
13431 expect(typeAlias.typeParameters, isNull); 13346 expect(typeAlias.typeParameters, isNull);
13432 expect(typeAlias.semicolon, isNotNull); 13347 expect(typeAlias.semicolon, isNotNull);
13433 GenericFunctionType functionType = typeAlias.functionType; 13348 GenericFunctionType functionType = typeAlias.functionType;
13434 expect(functionType, isNotNull); 13349 expect(functionType, isNotNull);
13435 expect(functionType.parameters, isNotNull); 13350 expect(functionType.parameters, isNotNull);
13436 expect(functionType.returnType, isNotNull); 13351 expect(functionType.returnType, isNotNull);
13437 expect(functionType.typeParameters, isNotNull); 13352 expect(functionType.typeParameters, isNotNull);
13438 } 13353 }
13439 13354
13440 @failingTest 13355 @failingTest
13441 void test_parseTypeAlias_genericFunction_typeParameters_noParameters() { 13356 void test_parseTypeAlias_genericFunction_typeParameters_noParameters() {
13442 createParser('typedef F<T> = bool Function();'); 13357 createParser('typedef F<T> = bool Function();');
13443 GenericTypeAlias typeAlias = 13358 GenericTypeAlias typeAlias = parseFullCompilationUnitMember();
13444 parser.parseTypeAlias(emptyCommentAndMetadata());
13445 expectNotNullIfNoErrors(typeAlias); 13359 expectNotNullIfNoErrors(typeAlias);
13446 listener.assertNoErrors(); 13360 listener.assertNoErrors();
13447 expect(typeAlias.typedefKeyword, isNotNull); 13361 expect(typeAlias.typedefKeyword, isNotNull);
13448 expect(typeAlias.name, isNotNull); 13362 expect(typeAlias.name, isNotNull);
13449 expect(typeAlias.typeParameters, isNotNull); 13363 expect(typeAlias.typeParameters, isNotNull);
13450 expect(typeAlias.semicolon, isNotNull); 13364 expect(typeAlias.semicolon, isNotNull);
13451 GenericFunctionType functionType = typeAlias.functionType; 13365 GenericFunctionType functionType = typeAlias.functionType;
13452 expect(functionType, isNotNull); 13366 expect(functionType, isNotNull);
13453 expect(functionType.parameters, isNotNull); 13367 expect(functionType.parameters, isNotNull);
13454 expect(functionType.returnType, isNotNull); 13368 expect(functionType.returnType, isNotNull);
13455 expect(functionType.typeParameters, isNull); 13369 expect(functionType.typeParameters, isNull);
13456 } 13370 }
13457 13371
13458 @failingTest 13372 @failingTest
13459 void test_parseTypeAlias_genericFunction_typeParameters_noReturnType() { 13373 void test_parseTypeAlias_genericFunction_typeParameters_noReturnType() {
13460 createParser('typedef F<T> = Function();'); 13374 createParser('typedef F<T> = Function();');
13461 GenericTypeAlias typeAlias = 13375 GenericTypeAlias typeAlias = parseFullCompilationUnitMember();
13462 parser.parseTypeAlias(emptyCommentAndMetadata());
13463 expectNotNullIfNoErrors(typeAlias); 13376 expectNotNullIfNoErrors(typeAlias);
13464 listener.assertNoErrors(); 13377 listener.assertNoErrors();
13465 expect(typeAlias.typedefKeyword, isNotNull); 13378 expect(typeAlias.typedefKeyword, isNotNull);
13466 expect(typeAlias.name, isNotNull); 13379 expect(typeAlias.name, isNotNull);
13467 expect(typeAlias.typeParameters, isNotNull); 13380 expect(typeAlias.typeParameters, isNotNull);
13468 expect(typeAlias.semicolon, isNotNull); 13381 expect(typeAlias.semicolon, isNotNull);
13469 GenericFunctionType functionType = typeAlias.functionType; 13382 GenericFunctionType functionType = typeAlias.functionType;
13470 expect(functionType, isNotNull); 13383 expect(functionType, isNotNull);
13471 expect(functionType.parameters, isNotNull); 13384 expect(functionType.parameters, isNotNull);
13472 expect(functionType.returnType, isNull); 13385 expect(functionType.returnType, isNull);
13473 expect(functionType.typeParameters, isNull); 13386 expect(functionType.typeParameters, isNull);
13474 } 13387 }
13475 13388
13476 @failingTest 13389 @failingTest
13477 void 13390 void
13478 test_parseTypeAlias_genericFunction_typeParameters_parameterizedReturnType () { 13391 test_parseTypeAlias_genericFunction_typeParameters_parameterizedReturnType () {
13479 createParser('typedef F<T> = A<B> Function();'); 13392 createParser('typedef F<T> = A<B> Function();');
13480 GenericTypeAlias typeAlias = 13393 GenericTypeAlias typeAlias = parseFullCompilationUnitMember();
13481 parser.parseTypeAlias(emptyCommentAndMetadata());
13482 expectNotNullIfNoErrors(typeAlias); 13394 expectNotNullIfNoErrors(typeAlias);
13483 listener.assertNoErrors(); 13395 listener.assertNoErrors();
13484 expect(typeAlias.typedefKeyword, isNotNull); 13396 expect(typeAlias.typedefKeyword, isNotNull);
13485 expect(typeAlias.name, isNotNull); 13397 expect(typeAlias.name, isNotNull);
13486 expect(typeAlias.typeParameters, isNotNull); 13398 expect(typeAlias.typeParameters, isNotNull);
13487 expect(typeAlias.semicolon, isNotNull); 13399 expect(typeAlias.semicolon, isNotNull);
13488 GenericFunctionType functionType = typeAlias.functionType; 13400 GenericFunctionType functionType = typeAlias.functionType;
13489 expect(functionType, isNotNull); 13401 expect(functionType, isNotNull);
13490 expect(functionType.parameters, isNotNull); 13402 expect(functionType.parameters, isNotNull);
13491 expect(functionType.returnType, isNotNull); 13403 expect(functionType.returnType, isNotNull);
13492 expect(functionType.typeParameters, isNull); 13404 expect(functionType.typeParameters, isNull);
13493 } 13405 }
13494 13406
13495 @failingTest 13407 @failingTest
13496 void test_parseTypeAlias_genericFunction_typeParameters_parameters() { 13408 void test_parseTypeAlias_genericFunction_typeParameters_parameters() {
13497 createParser('typedef F<T> = bool Function(Object value);'); 13409 createParser('typedef F<T> = bool Function(Object value);');
13498 GenericTypeAlias typeAlias = 13410 GenericTypeAlias typeAlias = parseFullCompilationUnitMember();
13499 parser.parseTypeAlias(emptyCommentAndMetadata());
13500 expectNotNullIfNoErrors(typeAlias); 13411 expectNotNullIfNoErrors(typeAlias);
13501 listener.assertNoErrors(); 13412 listener.assertNoErrors();
13502 expect(typeAlias.typedefKeyword, isNotNull); 13413 expect(typeAlias.typedefKeyword, isNotNull);
13503 expect(typeAlias.name, isNotNull); 13414 expect(typeAlias.name, isNotNull);
13504 expect(typeAlias.typeParameters, isNotNull); 13415 expect(typeAlias.typeParameters, isNotNull);
13505 expect(typeAlias.semicolon, isNotNull); 13416 expect(typeAlias.semicolon, isNotNull);
13506 GenericFunctionType functionType = typeAlias.functionType; 13417 GenericFunctionType functionType = typeAlias.functionType;
13507 expect(functionType, isNotNull); 13418 expect(functionType, isNotNull);
13508 expect(functionType.parameters, isNotNull); 13419 expect(functionType.parameters, isNotNull);
13509 expect(functionType.returnType, isNotNull); 13420 expect(functionType.returnType, isNotNull);
13510 expect(functionType.typeParameters, isNull); 13421 expect(functionType.typeParameters, isNull);
13511 } 13422 }
13512 13423
13513 @failingTest 13424 @failingTest
13514 void test_parseTypeAlias_genericFunction_typeParameters_typeParameters() { 13425 void test_parseTypeAlias_genericFunction_typeParameters_typeParameters() {
13515 createParser('typedef F<T> = bool Function<E>();'); 13426 createParser('typedef F<T> = bool Function<E>();');
13516 GenericTypeAlias typeAlias = 13427 GenericTypeAlias typeAlias = parseFullCompilationUnitMember();
13517 parser.parseTypeAlias(emptyCommentAndMetadata());
13518 expectNotNullIfNoErrors(typeAlias); 13428 expectNotNullIfNoErrors(typeAlias);
13519 listener.assertNoErrors(); 13429 listener.assertNoErrors();
13520 expect(typeAlias.typedefKeyword, isNotNull); 13430 expect(typeAlias.typedefKeyword, isNotNull);
13521 expect(typeAlias.name, isNotNull); 13431 expect(typeAlias.name, isNotNull);
13522 expect(typeAlias.typeParameters, isNotNull); 13432 expect(typeAlias.typeParameters, isNotNull);
13523 expect(typeAlias.semicolon, isNotNull); 13433 expect(typeAlias.semicolon, isNotNull);
13524 GenericFunctionType functionType = typeAlias.functionType; 13434 GenericFunctionType functionType = typeAlias.functionType;
13525 expect(functionType, isNotNull); 13435 expect(functionType, isNotNull);
13526 expect(functionType.parameters, isNotNull); 13436 expect(functionType.parameters, isNotNull);
13527 expect(functionType.returnType, isNotNull); 13437 expect(functionType.returnType, isNotNull);
13528 expect(functionType.typeParameters, isNotNull); 13438 expect(functionType.typeParameters, isNotNull);
13529 } 13439 }
13530 13440
13531 @failingTest 13441 @failingTest
13532 void test_parseTypeAlias_genericFunction_typeParameters_voidReturnType() { 13442 void test_parseTypeAlias_genericFunction_typeParameters_voidReturnType() {
13533 createParser('typedef F<T> = void Function();'); 13443 createParser('typedef F<T> = void Function();');
13534 GenericTypeAlias typeAlias = 13444 GenericTypeAlias typeAlias = parseFullCompilationUnitMember();
13535 parser.parseTypeAlias(emptyCommentAndMetadata());
13536 expectNotNullIfNoErrors(typeAlias); 13445 expectNotNullIfNoErrors(typeAlias);
13537 listener.assertNoErrors(); 13446 listener.assertNoErrors();
13538 expect(typeAlias.typedefKeyword, isNotNull); 13447 expect(typeAlias.typedefKeyword, isNotNull);
13539 expect(typeAlias.name, isNotNull); 13448 expect(typeAlias.name, isNotNull);
13540 expect(typeAlias.typeParameters, isNotNull); 13449 expect(typeAlias.typeParameters, isNotNull);
13541 expect(typeAlias.semicolon, isNotNull); 13450 expect(typeAlias.semicolon, isNotNull);
13542 GenericFunctionType functionType = typeAlias.functionType; 13451 GenericFunctionType functionType = typeAlias.functionType;
13543 expect(functionType, isNotNull); 13452 expect(functionType, isNotNull);
13544 expect(functionType.parameters, isNotNull); 13453 expect(functionType.parameters, isNotNull);
13545 expect(functionType.returnType, isNotNull); 13454 expect(functionType.returnType, isNotNull);
13546 expect(functionType.typeParameters, isNull); 13455 expect(functionType.typeParameters, isNull);
13547 } 13456 }
13548 13457
13549 @failingTest 13458 @failingTest
13550 void test_parseTypeAlias_genericFunction_voidReturnType() { 13459 void test_parseTypeAlias_genericFunction_voidReturnType() {
13551 createParser('typedef F = void Function();'); 13460 createParser('typedef F = void Function();');
13552 GenericTypeAlias typeAlias = 13461 GenericTypeAlias typeAlias = parseFullCompilationUnitMember();
13553 parser.parseTypeAlias(emptyCommentAndMetadata());
13554 expectNotNullIfNoErrors(typeAlias); 13462 expectNotNullIfNoErrors(typeAlias);
13555 listener.assertNoErrors(); 13463 listener.assertNoErrors();
13556 expect(typeAlias.typedefKeyword, isNotNull); 13464 expect(typeAlias.typedefKeyword, isNotNull);
13557 expect(typeAlias.name, isNotNull); 13465 expect(typeAlias.name, isNotNull);
13558 expect(typeAlias.typeParameters, isNull); 13466 expect(typeAlias.typeParameters, isNull);
13559 expect(typeAlias.semicolon, isNotNull); 13467 expect(typeAlias.semicolon, isNotNull);
13560 GenericFunctionType functionType = typeAlias.functionType; 13468 GenericFunctionType functionType = typeAlias.functionType;
13561 expect(functionType, isNotNull); 13469 expect(functionType, isNotNull);
13562 expect(functionType.parameters, isNotNull); 13470 expect(functionType.parameters, isNotNull);
13563 expect(functionType.returnType, isNotNull); 13471 expect(functionType.returnType, isNotNull);
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after
14164 VariableDeclaration declaration = parser.parseVariableDeclaration(); 14072 VariableDeclaration declaration = parser.parseVariableDeclaration();
14165 expectNotNullIfNoErrors(declaration); 14073 expectNotNullIfNoErrors(declaration);
14166 listener.assertNoErrors(); 14074 listener.assertNoErrors();
14167 expect(declaration.name, isNotNull); 14075 expect(declaration.name, isNotNull);
14168 expect(declaration.equals, isNull); 14076 expect(declaration.equals, isNull);
14169 expect(declaration.initializer, isNull); 14077 expect(declaration.initializer, isNull);
14170 } 14078 }
14171 14079
14172 void test_parseVariableDeclarationListAfterMetadata_const_noType() { 14080 void test_parseVariableDeclarationListAfterMetadata_const_noType() {
14173 createParser('const a'); 14081 createParser('const a');
14174 VariableDeclarationList declarationList = parser 14082 VariableDeclarationList declarationList =
14175 .parseVariableDeclarationListAfterMetadata(emptyCommentAndMetadata()); 14083 parseFullVariableDeclarationList();
14176 expectNotNullIfNoErrors(declarationList); 14084 expectNotNullIfNoErrors(declarationList);
14177 listener.assertNoErrors(); 14085 listener.assertNoErrors();
14178 expect(declarationList.keyword, isNotNull); 14086 expect(declarationList.keyword, isNotNull);
14179 expect(declarationList.type, isNull); 14087 expect(declarationList.type, isNull);
14180 expect(declarationList.variables, hasLength(1)); 14088 expect(declarationList.variables, hasLength(1));
14181 } 14089 }
14182 14090
14183 void test_parseVariableDeclarationListAfterMetadata_const_type() { 14091 void test_parseVariableDeclarationListAfterMetadata_const_type() {
14184 createParser('const A a'); 14092 createParser('const A a');
14185 VariableDeclarationList declarationList = parser 14093 VariableDeclarationList declarationList =
14186 .parseVariableDeclarationListAfterMetadata(emptyCommentAndMetadata()); 14094 parseFullVariableDeclarationList();
14187 expectNotNullIfNoErrors(declarationList); 14095 expectNotNullIfNoErrors(declarationList);
14188 listener.assertNoErrors(); 14096 listener.assertNoErrors();
14189 expect(declarationList.keyword, isNotNull); 14097 expect(declarationList.keyword, isNotNull);
14190 expect(declarationList.type, isNotNull); 14098 expect(declarationList.type, isNotNull);
14191 expect(declarationList.variables, hasLength(1)); 14099 expect(declarationList.variables, hasLength(1));
14192 } 14100 }
14193 14101
14194 void test_parseVariableDeclarationListAfterMetadata_final_noType() { 14102 void test_parseVariableDeclarationListAfterMetadata_final_noType() {
14195 createParser('final a'); 14103 createParser('final a');
14196 VariableDeclarationList declarationList = parser 14104 VariableDeclarationList declarationList =
14197 .parseVariableDeclarationListAfterMetadata(emptyCommentAndMetadata()); 14105 parseFullVariableDeclarationList();
14198 expectNotNullIfNoErrors(declarationList); 14106 expectNotNullIfNoErrors(declarationList);
14199 listener.assertNoErrors(); 14107 listener.assertNoErrors();
14200 expect(declarationList.keyword, isNotNull); 14108 expect(declarationList.keyword, isNotNull);
14201 expect(declarationList.type, isNull); 14109 expect(declarationList.type, isNull);
14202 expect(declarationList.variables, hasLength(1)); 14110 expect(declarationList.variables, hasLength(1));
14203 } 14111 }
14204 14112
14205 void test_parseVariableDeclarationListAfterMetadata_final_type() { 14113 void test_parseVariableDeclarationListAfterMetadata_final_type() {
14206 createParser('final A a'); 14114 createParser('final A a');
14207 VariableDeclarationList declarationList = parser 14115 VariableDeclarationList declarationList =
14208 .parseVariableDeclarationListAfterMetadata(emptyCommentAndMetadata()); 14116 parseFullVariableDeclarationList();
14209 expectNotNullIfNoErrors(declarationList); 14117 expectNotNullIfNoErrors(declarationList);
14210 listener.assertNoErrors(); 14118 listener.assertNoErrors();
14211 expect(declarationList.keyword, isNotNull); 14119 expect(declarationList.keyword, isNotNull);
14212 expect(declarationList.type, isNotNull); 14120 expect(declarationList.type, isNotNull);
14213 expect(declarationList.variables, hasLength(1)); 14121 expect(declarationList.variables, hasLength(1));
14214 } 14122 }
14215 14123
14216 void test_parseVariableDeclarationListAfterMetadata_final_typeComment() { 14124 void test_parseVariableDeclarationListAfterMetadata_final_typeComment() {
14217 enableGenericMethodComments = true; 14125 enableGenericMethodComments = true;
14218 createParser('final/*=T*/ x'); 14126 createParser('final/*=T*/ x');
14219 VariableDeclarationList declarationList = parser 14127 VariableDeclarationList declarationList =
14220 .parseVariableDeclarationListAfterMetadata(emptyCommentAndMetadata()); 14128 parseFullVariableDeclarationList();
14221 expectNotNullIfNoErrors(declarationList); 14129 expectNotNullIfNoErrors(declarationList);
14222 listener.assertNoErrors(); 14130 listener.assertNoErrors();
14223 expect((declarationList.type as TypeName).name.name, 'T'); 14131 expect((declarationList.type as TypeName).name.name, 'T');
14224 expect(declarationList.isFinal, true); 14132 expect(declarationList.isFinal, true);
14225 } 14133 }
14226 14134
14227 void test_parseVariableDeclarationListAfterMetadata_type_multiple() { 14135 void test_parseVariableDeclarationListAfterMetadata_type_multiple() {
14228 createParser('A a, b, c'); 14136 createParser('A a, b, c');
14229 VariableDeclarationList declarationList = parser 14137 VariableDeclarationList declarationList =
14230 .parseVariableDeclarationListAfterMetadata(emptyCommentAndMetadata()); 14138 parseFullVariableDeclarationList();
14231 expectNotNullIfNoErrors(declarationList); 14139 expectNotNullIfNoErrors(declarationList);
14232 listener.assertNoErrors(); 14140 listener.assertNoErrors();
14233 expect(declarationList.keyword, isNull); 14141 expect(declarationList.keyword, isNull);
14234 expect(declarationList.type, isNotNull); 14142 expect(declarationList.type, isNotNull);
14235 expect(declarationList.variables, hasLength(3)); 14143 expect(declarationList.variables, hasLength(3));
14236 } 14144 }
14237 14145
14238 void test_parseVariableDeclarationListAfterMetadata_type_single() { 14146 void test_parseVariableDeclarationListAfterMetadata_type_single() {
14239 createParser('A a'); 14147 createParser('A a');
14240 VariableDeclarationList declarationList = parser 14148 VariableDeclarationList declarationList =
14241 .parseVariableDeclarationListAfterMetadata(emptyCommentAndMetadata()); 14149 parseFullVariableDeclarationList();
14242 expectNotNullIfNoErrors(declarationList); 14150 expectNotNullIfNoErrors(declarationList);
14243 listener.assertNoErrors(); 14151 listener.assertNoErrors();
14244 expect(declarationList.keyword, isNull); 14152 expect(declarationList.keyword, isNull);
14245 expect(declarationList.type, isNotNull); 14153 expect(declarationList.type, isNotNull);
14246 expect(declarationList.variables, hasLength(1)); 14154 expect(declarationList.variables, hasLength(1));
14247 } 14155 }
14248 14156
14249 void test_parseVariableDeclarationListAfterMetadata_var_multiple() { 14157 void test_parseVariableDeclarationListAfterMetadata_var_multiple() {
14250 createParser('var a, b, c'); 14158 createParser('var a, b, c');
14251 VariableDeclarationList declarationList = parser 14159 VariableDeclarationList declarationList =
14252 .parseVariableDeclarationListAfterMetadata(emptyCommentAndMetadata()); 14160 parseFullVariableDeclarationList();
14253 expectNotNullIfNoErrors(declarationList); 14161 expectNotNullIfNoErrors(declarationList);
14254 listener.assertNoErrors(); 14162 listener.assertNoErrors();
14255 expect(declarationList.keyword, isNotNull); 14163 expect(declarationList.keyword, isNotNull);
14256 expect(declarationList.type, isNull); 14164 expect(declarationList.type, isNull);
14257 expect(declarationList.variables, hasLength(3)); 14165 expect(declarationList.variables, hasLength(3));
14258 } 14166 }
14259 14167
14260 void test_parseVariableDeclarationListAfterMetadata_var_single() { 14168 void test_parseVariableDeclarationListAfterMetadata_var_single() {
14261 createParser('var a'); 14169 createParser('var a');
14262 VariableDeclarationList declarationList = parser 14170 VariableDeclarationList declarationList =
14263 .parseVariableDeclarationListAfterMetadata(emptyCommentAndMetadata()); 14171 parseFullVariableDeclarationList();
14264 expectNotNullIfNoErrors(declarationList); 14172 expectNotNullIfNoErrors(declarationList);
14265 listener.assertNoErrors(); 14173 listener.assertNoErrors();
14266 expect(declarationList.keyword, isNotNull); 14174 expect(declarationList.keyword, isNotNull);
14267 expect(declarationList.type, isNull); 14175 expect(declarationList.type, isNull);
14268 expect(declarationList.variables, hasLength(1)); 14176 expect(declarationList.variables, hasLength(1));
14269 } 14177 }
14270 14178
14271 void test_parseVariableDeclarationListAfterMetadata_var_typeComment() { 14179 void test_parseVariableDeclarationListAfterMetadata_var_typeComment() {
14272 enableGenericMethodComments = true; 14180 enableGenericMethodComments = true;
14273 createParser('var/*=T*/ x'); 14181 createParser('var/*=T*/ x');
14274 VariableDeclarationList declarationList = parser 14182 VariableDeclarationList declarationList =
14275 .parseVariableDeclarationListAfterMetadata(emptyCommentAndMetadata()); 14183 parseFullVariableDeclarationList();
14276 expectNotNullIfNoErrors(declarationList); 14184 expectNotNullIfNoErrors(declarationList);
14277 listener.assertNoErrors(); 14185 listener.assertNoErrors();
14278 expect((declarationList.type as TypeName).name.name, 'T'); 14186 expect((declarationList.type as TypeName).name.name, 'T');
14279 expect(declarationList.keyword, isNull); 14187 expect(declarationList.keyword, isNull);
14280 } 14188 }
14281 14189
14282 void test_parseVariableDeclarationListAfterType_type() { 14190 void test_parseVariableDeclarationListAfterType_type() {
14283 TypeName type = 14191 createParser('T a');
14284 astFactory.typeName(astFactory.simpleIdentifier(null), null);
14285 createParser('a');
14286 VariableDeclarationList declarationList = 14192 VariableDeclarationList declarationList =
14287 parser.parseVariableDeclarationListAfterType( 14193 parseFullVariableDeclarationList();
14288 emptyCommentAndMetadata(), null, type);
14289 expectNotNullIfNoErrors(declarationList); 14194 expectNotNullIfNoErrors(declarationList);
14290 listener.assertNoErrors(); 14195 listener.assertNoErrors();
14291 expect(declarationList.keyword, isNull); 14196 expect(declarationList.keyword, isNull);
14292 expect(declarationList.type, type); 14197 expect((declarationList.type as TypeName).name.name, 'T');
14293 expect(declarationList.variables, hasLength(1)); 14198 expect(declarationList.variables, hasLength(1));
14294 } 14199 }
14295 14200
14296 void test_parseVariableDeclarationListAfterType_var() { 14201 void test_parseVariableDeclarationListAfterType_var() {
14297 Token keyword = TokenFactory.tokenFromKeyword(Keyword.VAR); 14202 createParser('var a, b, c');
14298 createParser('a, b, c');
14299 VariableDeclarationList declarationList = 14203 VariableDeclarationList declarationList =
14300 parser.parseVariableDeclarationListAfterType( 14204 parseFullVariableDeclarationList();
14301 emptyCommentAndMetadata(), keyword, null);
14302 expectNotNullIfNoErrors(declarationList); 14205 expectNotNullIfNoErrors(declarationList);
14303 listener.assertNoErrors(); 14206 listener.assertNoErrors();
14304 expect(declarationList.keyword, keyword); 14207 expect(declarationList.keyword.lexeme, 'var');
14305 expect(declarationList.type, isNull); 14208 expect(declarationList.type, isNull);
14306 expect(declarationList.variables, hasLength(3)); 14209 expect(declarationList.variables, hasLength(3));
14307 } 14210 }
14308 14211
14309 void test_parseVariableDeclarationStatementAfterMetadata_multiple() { 14212 void test_parseVariableDeclarationStatementAfterMetadata_multiple() {
14310 createParser('var x, y, z;'); 14213 createParser('var x, y, z;');
14311 VariableDeclarationStatement statement = 14214 VariableDeclarationStatement statement = parser.parseStatement2();
14312 parser.parseVariableDeclarationStatementAfterMetadata(
14313 emptyCommentAndMetadata());
14314 expectNotNullIfNoErrors(statement); 14215 expectNotNullIfNoErrors(statement);
14315 listener.assertNoErrors(); 14216 listener.assertNoErrors();
14316 expect(statement.semicolon, isNotNull); 14217 expect(statement.semicolon, isNotNull);
14317 VariableDeclarationList variableList = statement.variables; 14218 VariableDeclarationList variableList = statement.variables;
14318 expect(variableList, isNotNull); 14219 expect(variableList, isNotNull);
14319 expect(variableList.variables, hasLength(3)); 14220 expect(variableList.variables, hasLength(3));
14320 } 14221 }
14321 14222
14322 void test_parseVariableDeclarationStatementAfterMetadata_single() { 14223 void test_parseVariableDeclarationStatementAfterMetadata_single() {
14323 createParser('var x;'); 14224 createParser('var x;');
14324 VariableDeclarationStatement statement = 14225 VariableDeclarationStatement statement = parser.parseStatement2();
14325 parser.parseVariableDeclarationStatementAfterMetadata(
14326 emptyCommentAndMetadata());
14327 expectNotNullIfNoErrors(statement); 14226 expectNotNullIfNoErrors(statement);
14328 listener.assertNoErrors(); 14227 listener.assertNoErrors();
14329 expect(statement.semicolon, isNotNull); 14228 expect(statement.semicolon, isNotNull);
14330 VariableDeclarationList variableList = statement.variables; 14229 VariableDeclarationList variableList = statement.variables;
14331 expect(variableList, isNotNull); 14230 expect(variableList, isNotNull);
14332 expect(variableList.variables, hasLength(1)); 14231 expect(variableList.variables, hasLength(1));
14333 } 14232 }
14334 14233
14335 void test_parseWhileStatement() { 14234 void test_parseWhileStatement() {
14336 createParser('while (x) {}'); 14235 createParser('while (x) {}');
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
14608 CompilationUnit _parseDirectives(String source, 14507 CompilationUnit _parseDirectives(String source,
14609 [List<ErrorCode> errorCodes = const <ErrorCode>[]]) { 14508 [List<ErrorCode> errorCodes = const <ErrorCode>[]]) {
14610 createParser(source); 14509 createParser(source);
14611 CompilationUnit unit = parser.parseDirectives2(); 14510 CompilationUnit unit = parser.parseDirectives2();
14612 expect(unit, isNotNull); 14511 expect(unit, isNotNull);
14613 expect(unit.declarations, hasLength(0)); 14512 expect(unit.declarations, hasLength(0));
14614 listener.assertErrorsWithCodes(errorCodes); 14513 listener.assertErrorsWithCodes(errorCodes);
14615 return unit; 14514 return unit;
14616 } 14515 }
14617 } 14516 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698