| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library analyzer.test.generated.parser_test; | 5 library analyzer.test.generated.parser_test; |
| 6 | 6 |
| 7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
| 8 import 'package:analyzer/dart/ast/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'; |
| 11 import 'package:analyzer/error/error.dart'; | 11 import 'package:analyzer/error/error.dart'; |
| 12 import 'package:analyzer/error/listener.dart'; | 12 import 'package:analyzer/error/listener.dart'; |
| 13 import 'package:analyzer/src/dart/ast/token.dart'; | 13 import 'package:analyzer/src/dart/ast/token.dart'; |
| 14 import 'package:analyzer/src/dart/scanner/reader.dart'; | 14 import 'package:analyzer/src/dart/scanner/reader.dart'; |
| 15 import 'package:analyzer/src/dart/scanner/scanner.dart'; | 15 import 'package:analyzer/src/dart/scanner/scanner.dart'; |
| 16 import 'package:analyzer/src/generated/parser.dart'; | 16 import 'package:analyzer/src/generated/parser.dart'; |
| 17 import 'package:analyzer/src/generated/source.dart'; | 17 import 'package:analyzer/src/generated/source.dart'; |
| 18 import 'package:analyzer/src/generated/testing/ast_test_factory.dart'; | |
| 19 import 'package:analyzer/src/generated/testing/token_factory.dart'; | 18 import 'package:analyzer/src/generated/testing/token_factory.dart'; |
| 20 import 'package:analyzer/src/generated/utilities_dart.dart'; | 19 import 'package:analyzer/src/generated/utilities_dart.dart'; |
| 21 import 'package:test/test.dart'; | 20 import 'package:test/test.dart'; |
| 22 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 21 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| 23 | 22 |
| 24 import 'test_support.dart'; | 23 import 'test_support.dart'; |
| 25 | 24 |
| 26 main() { | 25 main() { |
| 27 defineReflectiveSuite(() { | 26 defineReflectiveSuite(() { |
| 28 defineReflectiveTests(ClassMemberParserTest); | 27 defineReflectiveTests(ClassMemberParserTest); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 /** | 71 /** |
| 73 * Asserts that no errors occurred during parsing. | 72 * Asserts that no errors occurred during parsing. |
| 74 */ | 73 */ |
| 75 void assertNoErrors(); | 74 void assertNoErrors(); |
| 76 | 75 |
| 77 /** | 76 /** |
| 78 * Prepares to parse using tokens scanned from the given [content] string. | 77 * Prepares to parse using tokens scanned from the given [content] string. |
| 79 */ | 78 */ |
| 80 void createParser(String content); | 79 void createParser(String content); |
| 81 | 80 |
| 81 Expression parseAdditiveExpression(String code); |
| 82 |
| 83 Expression parseAssignableExpression(String code, bool primaryAllowed); |
| 84 |
| 85 Expression parseAssignableSelector( |
| 86 String code, Expression prefix, bool optional, |
| 87 {bool allowConditional: true}); |
| 88 |
| 89 AwaitExpression parseAwaitExpression(String code); |
| 90 |
| 91 Expression parseBitwiseAndExpression(String code); |
| 92 |
| 93 Expression parseBitwiseOrExpression(String code); |
| 94 |
| 95 Expression parseBitwiseXorExpression(String code); |
| 96 |
| 97 Expression parseCascadeSection(String code); |
| 98 |
| 82 CompilationUnit parseCompilationUnit(String source, | 99 CompilationUnit parseCompilationUnit(String source, |
| 83 [List<ErrorCode> errorCodes = const <ErrorCode>[]]); | 100 [List<ErrorCode> errorCodes = const <ErrorCode>[]]); |
| 84 | 101 |
| 85 /// TODO(paulberry): merge with [parseCompilationUnit] | 102 /// TODO(paulberry): merge with [parseCompilationUnit] |
| 86 CompilationUnit parseCompilationUnitWithOptions(String source, | 103 CompilationUnit parseCompilationUnitWithOptions(String source, |
| 87 [List<ErrorCode> errorCodes = const <ErrorCode>[]]); | 104 [List<ErrorCode> errorCodes = const <ErrorCode>[]]); |
| 88 | 105 |
| 106 ConditionalExpression parseConditionalExpression(String code); |
| 107 |
| 108 Expression parseConstExpression(String code); |
| 109 |
| 89 /** | 110 /** |
| 90 * Parse the given source as a compilation unit. | 111 * Parse the given source as a compilation unit. |
| 91 * | 112 * |
| 92 * @param source the source to be parsed | 113 * @param source the source to be parsed |
| 93 * @param errorCodes the error codes of the errors that are expected to be fou
nd | 114 * @param errorCodes the error codes of the errors that are expected to be fou
nd |
| 94 * @return the compilation unit that was parsed | 115 * @return the compilation unit that was parsed |
| 95 * @throws Exception if the source could not be parsed, if the compilation err
ors in the source do | 116 * @throws Exception if the source could not be parsed, if the compilation err
ors in the source do |
| 96 * not match those that are expected, or if the result would have be
en `null` | 117 * not match those that are expected, or if the result would have be
en `null` |
| 97 */ | 118 */ |
| 98 CompilationUnit parseDirectives(String source, | 119 CompilationUnit parseDirectives(String source, |
| 99 [List<ErrorCode> errorCodes = const <ErrorCode>[]]); | 120 [List<ErrorCode> errorCodes = const <ErrorCode>[]]); |
| 100 | 121 |
| 122 BinaryExpression parseEqualityExpression(String code); |
| 123 |
| 101 Expression parseExpression(String source, | 124 Expression parseExpression(String source, |
| 102 [List<ErrorCode> errorCodes = const <ErrorCode>[]]); | 125 [List<ErrorCode> errorCodes = const <ErrorCode>[]]); |
| 103 | 126 |
| 127 List<Expression> parseExpressionList(String code); |
| 128 |
| 129 Expression parseExpressionWithoutCascade(String code); |
| 130 |
| 104 FormalParameter parseFormalParameter(String code, ParameterKind kind, | 131 FormalParameter parseFormalParameter(String code, ParameterKind kind, |
| 105 {List<ErrorCode> errorCodes: const <ErrorCode>[]}); | 132 {List<ErrorCode> errorCodes: const <ErrorCode>[]}); |
| 106 | 133 |
| 107 FormalParameterList parseFormalParameterList(String code, | 134 FormalParameterList parseFormalParameterList(String code, |
| 108 {bool inFunctionType: false, | 135 {bool inFunctionType: false, |
| 109 List<ErrorCode> errorCodes: const <ErrorCode>[]}); | 136 List<ErrorCode> errorCodes: const <ErrorCode>[]}); |
| 110 | 137 |
| 111 /** | 138 /** |
| 112 * Parses a single top level member of a compilation unit (other than a | 139 * Parses a single top level member of a compilation unit (other than a |
| 113 * directive), including any comment and/or metadata that precedes it. | 140 * directive), including any comment and/or metadata that precedes it. |
| 114 */ | 141 */ |
| 115 CompilationUnitMember parseFullCompilationUnitMember(); | 142 CompilationUnitMember parseFullCompilationUnitMember(); |
| 116 | 143 |
| 117 /** | 144 /** |
| 118 * Parses a single top level directive, including any comment and/or metadata | 145 * Parses a single top level directive, including any comment and/or metadata |
| 119 * that precedes it. | 146 * that precedes it. |
| 120 */ | 147 */ |
| 121 Directive parseFullDirective(); | 148 Directive parseFullDirective(); |
| 122 | 149 |
| 150 FunctionExpression parseFunctionExpression(String code); |
| 151 |
| 152 InstanceCreationExpression parseInstanceCreationExpression( |
| 153 String code, Token newToken); |
| 154 |
| 155 ListLiteral parseListLiteral( |
| 156 Token token, String typeArgumentsCode, String code); |
| 157 |
| 158 TypedLiteral parseListOrMapLiteral(Token modifier, String code); |
| 159 |
| 160 Expression parseLogicalAndExpression(String code); |
| 161 |
| 162 Expression parseLogicalOrExpression(String code); |
| 163 |
| 164 MapLiteral parseMapLiteral( |
| 165 Token token, String typeArgumentsCode, String code); |
| 166 |
| 167 MapLiteralEntry parseMapLiteralEntry(String code); |
| 168 |
| 169 Expression parseMultiplicativeExpression(String code); |
| 170 |
| 171 InstanceCreationExpression parseNewExpression(String code); |
| 172 |
| 123 NormalFormalParameter parseNormalFormalParameter(String code, | 173 NormalFormalParameter parseNormalFormalParameter(String code, |
| 124 {bool inFunctionType: false}); | 174 {bool inFunctionType: false}); |
| 125 | 175 |
| 176 Expression parsePostfixExpression(String code); |
| 177 |
| 178 Identifier parsePrefixedIdentifier(String code); |
| 179 |
| 180 Expression parsePrimaryExpression(String code); |
| 181 |
| 182 Expression parseRelationalExpression(String code); |
| 183 |
| 184 RethrowExpression parseRethrowExpression(String code); |
| 185 |
| 186 BinaryExpression parseShiftExpression(String code); |
| 187 |
| 188 SimpleIdentifier parseSimpleIdentifier(String code); |
| 189 |
| 126 Statement parseStatement(String source, | 190 Statement parseStatement(String source, |
| 127 [List<ErrorCode> errorCodes = const <ErrorCode>[], | 191 [List<ErrorCode> errorCodes = const <ErrorCode>[], |
| 128 bool enableLazyAssignmentOperators]); | 192 bool enableLazyAssignmentOperators]); |
| 193 |
| 194 Expression parseStringLiteral(String code); |
| 195 |
| 196 SuperConstructorInvocation parseSuperConstructorInvocation(String code); |
| 197 |
| 198 SymbolLiteral parseSymbolLiteral(String code); |
| 199 |
| 200 Expression parseThrowExpression(String code); |
| 201 |
| 202 Expression parseThrowExpressionWithoutCascade(String code); |
| 203 |
| 204 PrefixExpression parseUnaryExpression(String code); |
| 129 } | 205 } |
| 130 | 206 |
| 131 /** | 207 /** |
| 132 * Instances of the class `AstValidator` are used to validate the correct constr
uction of an | 208 * Instances of the class `AstValidator` are used to validate the correct constr
uction of an |
| 133 * AST structure. | 209 * AST structure. |
| 134 */ | 210 */ |
| 135 class AstValidator extends UnifyingAstVisitor<Object> { | 211 class AstValidator extends UnifyingAstVisitor<Object> { |
| 136 /** | 212 /** |
| 137 * A list containing the errors found while traversing the AST structure. | 213 * A list containing the errors found while traversing the AST structure. |
| 138 */ | 214 */ |
| (...skipping 2048 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2187 } | 2263 } |
| 2188 | 2264 |
| 2189 @failingTest | 2265 @failingTest |
| 2190 void test_expectedListOrMapLiteral() { | 2266 void test_expectedListOrMapLiteral() { |
| 2191 // It isn't clear that this test can ever pass. The parser is currently | 2267 // It isn't clear that this test can ever pass. The parser is currently |
| 2192 // create a synthetic list literal in this case, but isSynthetic() isn't | 2268 // create a synthetic list literal in this case, but isSynthetic() isn't |
| 2193 // overridden for ListLiteral. The problem is that the synthetic list | 2269 // overridden for ListLiteral. The problem is that the synthetic list |
| 2194 // literals that are being created are not always zero length (because they | 2270 // literals that are being created are not always zero length (because they |
| 2195 // could have type parameters), which violates the contract of | 2271 // could have type parameters), which violates the contract of |
| 2196 // isSynthetic(). | 2272 // isSynthetic(). |
| 2197 createParser('1'); | 2273 TypedLiteral literal = parseListOrMapLiteral(null, '1'); |
| 2198 TypedLiteral literal = parser.parseListOrMapLiteral(null); | |
| 2199 expectNotNullIfNoErrors(literal); | 2274 expectNotNullIfNoErrors(literal); |
| 2200 listener | 2275 listener |
| 2201 .assertErrorsWithCodes([ParserErrorCode.EXPECTED_LIST_OR_MAP_LITERAL]); | 2276 .assertErrorsWithCodes([ParserErrorCode.EXPECTED_LIST_OR_MAP_LITERAL]); |
| 2202 expect(literal.isSynthetic, isTrue); | 2277 expect(literal.isSynthetic, isTrue); |
| 2203 } | 2278 } |
| 2204 | 2279 |
| 2205 void test_expectedStringLiteral() { | 2280 void test_expectedStringLiteral() { |
| 2206 createParser('1'); | 2281 createParser('1'); |
| 2207 StringLiteral literal = parser.parseStringLiteral(); | 2282 StringLiteral literal = parser.parseStringLiteral(); |
| 2208 expectNotNullIfNoErrors(literal); | 2283 expectNotNullIfNoErrors(literal); |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2686 } | 2761 } |
| 2687 | 2762 |
| 2688 void test_invalidOperator() { | 2763 void test_invalidOperator() { |
| 2689 createParser('void operator ===(x) {}'); | 2764 createParser('void operator ===(x) {}'); |
| 2690 ClassMember member = parser.parseClassMember('C'); | 2765 ClassMember member = parser.parseClassMember('C'); |
| 2691 expectNotNullIfNoErrors(member); | 2766 expectNotNullIfNoErrors(member); |
| 2692 listener.assertErrorsWithCodes([ParserErrorCode.INVALID_OPERATOR]); | 2767 listener.assertErrorsWithCodes([ParserErrorCode.INVALID_OPERATOR]); |
| 2693 } | 2768 } |
| 2694 | 2769 |
| 2695 void test_invalidOperatorAfterSuper_assignableExpression() { | 2770 void test_invalidOperatorAfterSuper_assignableExpression() { |
| 2696 createParser('super?.v'); | 2771 Expression expression = parseAssignableExpression('super?.v', false); |
| 2697 Expression expression = parser.parseAssignableExpression(false); | |
| 2698 expectNotNullIfNoErrors(expression); | 2772 expectNotNullIfNoErrors(expression); |
| 2699 listener | 2773 listener |
| 2700 .assertErrorsWithCodes([ParserErrorCode.INVALID_OPERATOR_FOR_SUPER]); | 2774 .assertErrorsWithCodes([ParserErrorCode.INVALID_OPERATOR_FOR_SUPER]); |
| 2701 } | 2775 } |
| 2702 | 2776 |
| 2703 void test_invalidOperatorAfterSuper_primaryExpression() { | 2777 void test_invalidOperatorAfterSuper_primaryExpression() { |
| 2704 createParser('super?.v'); | 2778 Expression expression = parsePrimaryExpression('super?.v'); |
| 2705 Expression expression = parser.parsePrimaryExpression(); | |
| 2706 expectNotNullIfNoErrors(expression); | 2779 expectNotNullIfNoErrors(expression); |
| 2707 listener | 2780 listener |
| 2708 .assertErrorsWithCodes([ParserErrorCode.INVALID_OPERATOR_FOR_SUPER]); | 2781 .assertErrorsWithCodes([ParserErrorCode.INVALID_OPERATOR_FOR_SUPER]); |
| 2709 } | 2782 } |
| 2710 | 2783 |
| 2711 void test_invalidOperatorForSuper() { | 2784 void test_invalidOperatorForSuper() { |
| 2712 createParser('++super'); | 2785 createParser('++super'); |
| 2713 Expression expression = parser.parseUnaryExpression(); | 2786 Expression expression = parser.parseUnaryExpression(); |
| 2714 expectNotNullIfNoErrors(expression); | 2787 expectNotNullIfNoErrors(expression); |
| 2715 listener | 2788 listener |
| 2716 .assertErrorsWithCodes([ParserErrorCode.INVALID_OPERATOR_FOR_SUPER]); | 2789 .assertErrorsWithCodes([ParserErrorCode.INVALID_OPERATOR_FOR_SUPER]); |
| 2717 } | 2790 } |
| 2718 | 2791 |
| 2719 void test_invalidStarAfterAsync() { | 2792 void test_invalidStarAfterAsync() { |
| 2720 createParser('async* => 0;'); | 2793 createParser('async* => 0;'); |
| 2721 FunctionBody functionBody = parser.parseFunctionBody(false, null, false); | 2794 FunctionBody functionBody = parser.parseFunctionBody(false, null, false); |
| 2722 expectNotNullIfNoErrors(functionBody); | 2795 expectNotNullIfNoErrors(functionBody); |
| 2723 listener.assertErrorsWithCodes([ParserErrorCode.INVALID_STAR_AFTER_ASYNC]); | 2796 listener.assertErrorsWithCodes([ParserErrorCode.INVALID_STAR_AFTER_ASYNC]); |
| 2724 } | 2797 } |
| 2725 | 2798 |
| 2726 void test_invalidSync() { | 2799 void test_invalidSync() { |
| 2727 createParser('sync* => 0;'); | 2800 createParser('sync* => 0;'); |
| 2728 FunctionBody functionBody = parser.parseFunctionBody(false, null, false); | 2801 FunctionBody functionBody = parser.parseFunctionBody(false, null, false); |
| 2729 expectNotNullIfNoErrors(functionBody); | 2802 expectNotNullIfNoErrors(functionBody); |
| 2730 listener.assertErrorsWithCodes([ParserErrorCode.INVALID_SYNC]); | 2803 listener.assertErrorsWithCodes([ParserErrorCode.INVALID_SYNC]); |
| 2731 } | 2804 } |
| 2732 | 2805 |
| 2733 void test_invalidUnicodeEscape_incomplete_noDigits() { | 2806 void test_invalidUnicodeEscape_incomplete_noDigits() { |
| 2734 createParser("'\\u{'"); | 2807 Expression expression = parseStringLiteral("'\\u{'"); |
| 2735 Expression expression = parser.parseStringLiteral(); | |
| 2736 expectNotNullIfNoErrors(expression); | 2808 expectNotNullIfNoErrors(expression); |
| 2737 listener.assertErrorsWithCodes([ParserErrorCode.INVALID_UNICODE_ESCAPE]); | 2809 listener.assertErrorsWithCodes([ParserErrorCode.INVALID_UNICODE_ESCAPE]); |
| 2738 } | 2810 } |
| 2739 | 2811 |
| 2740 void test_invalidUnicodeEscape_incomplete_someDigits() { | 2812 void test_invalidUnicodeEscape_incomplete_someDigits() { |
| 2741 createParser("'\\u{0A'"); | 2813 Expression expression = parseStringLiteral("'\\u{0A'"); |
| 2742 Expression expression = parser.parseStringLiteral(); | |
| 2743 expectNotNullIfNoErrors(expression); | 2814 expectNotNullIfNoErrors(expression); |
| 2744 listener.assertErrorsWithCodes([ParserErrorCode.INVALID_UNICODE_ESCAPE]); | 2815 listener.assertErrorsWithCodes([ParserErrorCode.INVALID_UNICODE_ESCAPE]); |
| 2745 } | 2816 } |
| 2746 | 2817 |
| 2747 void test_invalidUnicodeEscape_invalidDigit() { | 2818 void test_invalidUnicodeEscape_invalidDigit() { |
| 2748 createParser("'\\u0 a'"); | 2819 Expression expression = parseStringLiteral("'\\u0 a'"); |
| 2749 Expression expression = parser.parseStringLiteral(); | |
| 2750 expectNotNullIfNoErrors(expression); | 2820 expectNotNullIfNoErrors(expression); |
| 2751 listener.assertErrorsWithCodes([ParserErrorCode.INVALID_UNICODE_ESCAPE]); | 2821 listener.assertErrorsWithCodes([ParserErrorCode.INVALID_UNICODE_ESCAPE]); |
| 2752 } | 2822 } |
| 2753 | 2823 |
| 2754 void test_invalidUnicodeEscape_tooFewDigits_fixed() { | 2824 void test_invalidUnicodeEscape_tooFewDigits_fixed() { |
| 2755 createParser("'\\u04'"); | 2825 Expression expression = parseStringLiteral("'\\u04'"); |
| 2756 Expression expression = parser.parseStringLiteral(); | |
| 2757 expectNotNullIfNoErrors(expression); | 2826 expectNotNullIfNoErrors(expression); |
| 2758 listener.assertErrorsWithCodes([ParserErrorCode.INVALID_UNICODE_ESCAPE]); | 2827 listener.assertErrorsWithCodes([ParserErrorCode.INVALID_UNICODE_ESCAPE]); |
| 2759 } | 2828 } |
| 2760 | 2829 |
| 2761 void test_invalidUnicodeEscape_tooFewDigits_variable() { | 2830 void test_invalidUnicodeEscape_tooFewDigits_variable() { |
| 2762 createParser("'\\u{}'"); | 2831 Expression expression = parseStringLiteral("'\\u{}'"); |
| 2763 Expression expression = parser.parseStringLiteral(); | |
| 2764 expectNotNullIfNoErrors(expression); | 2832 expectNotNullIfNoErrors(expression); |
| 2765 listener.assertErrorsWithCodes([ParserErrorCode.INVALID_UNICODE_ESCAPE]); | 2833 listener.assertErrorsWithCodes([ParserErrorCode.INVALID_UNICODE_ESCAPE]); |
| 2766 } | 2834 } |
| 2767 | 2835 |
| 2768 void test_invalidUnicodeEscape_tooManyDigits_variable() { | 2836 void test_invalidUnicodeEscape_tooManyDigits_variable() { |
| 2769 createParser("'\\u{12345678}'"); | 2837 Expression expression = parseStringLiteral("'\\u{12345678}'"); |
| 2770 Expression expression = parser.parseStringLiteral(); | |
| 2771 expectNotNullIfNoErrors(expression); | 2838 expectNotNullIfNoErrors(expression); |
| 2772 listener.assertErrorsWithCodes([ | 2839 listener.assertErrorsWithCodes([ |
| 2773 ParserErrorCode.INVALID_UNICODE_ESCAPE, | 2840 ParserErrorCode.INVALID_UNICODE_ESCAPE, |
| 2774 ParserErrorCode.INVALID_CODE_POINT | 2841 ParserErrorCode.INVALID_CODE_POINT |
| 2775 ]); | 2842 ]); |
| 2776 } | 2843 } |
| 2777 | 2844 |
| 2778 void test_libraryDirectiveNotFirst() { | 2845 void test_libraryDirectiveNotFirst() { |
| 2779 parseCompilationUnit("import 'x.dart'; library l;", | 2846 parseCompilationUnit("import 'x.dart'; library l;", |
| 2780 [ParserErrorCode.LIBRARY_DIRECTIVE_NOT_FIRST]); | 2847 [ParserErrorCode.LIBRARY_DIRECTIVE_NOT_FIRST]); |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3065 } | 3132 } |
| 3066 | 3133 |
| 3067 void test_missingIdentifier_inEnum() { | 3134 void test_missingIdentifier_inEnum() { |
| 3068 createParser('enum E {, TWO}'); | 3135 createParser('enum E {, TWO}'); |
| 3069 EnumDeclaration declaration = parseFullCompilationUnitMember(); | 3136 EnumDeclaration declaration = parseFullCompilationUnitMember(); |
| 3070 expectNotNullIfNoErrors(declaration); | 3137 expectNotNullIfNoErrors(declaration); |
| 3071 listener.assertErrorsWithCodes([ParserErrorCode.MISSING_IDENTIFIER]); | 3138 listener.assertErrorsWithCodes([ParserErrorCode.MISSING_IDENTIFIER]); |
| 3072 } | 3139 } |
| 3073 | 3140 |
| 3074 void test_missingIdentifier_inSymbol_afterPeriod() { | 3141 void test_missingIdentifier_inSymbol_afterPeriod() { |
| 3075 createParser('#a.'); | 3142 SymbolLiteral literal = parseSymbolLiteral('#a.'); |
| 3076 SymbolLiteral literal = parser.parseSymbolLiteral(); | |
| 3077 expectNotNullIfNoErrors(literal); | 3143 expectNotNullIfNoErrors(literal); |
| 3078 listener.assertErrorsWithCodes([ParserErrorCode.MISSING_IDENTIFIER]); | 3144 listener.assertErrorsWithCodes([ParserErrorCode.MISSING_IDENTIFIER]); |
| 3079 } | 3145 } |
| 3080 | 3146 |
| 3081 void test_missingIdentifier_inSymbol_first() { | 3147 void test_missingIdentifier_inSymbol_first() { |
| 3082 createParser('#'); | 3148 SymbolLiteral literal = parseSymbolLiteral('#'); |
| 3083 SymbolLiteral literal = parser.parseSymbolLiteral(); | |
| 3084 expectNotNullIfNoErrors(literal); | 3149 expectNotNullIfNoErrors(literal); |
| 3085 listener.assertErrorsWithCodes([ParserErrorCode.MISSING_IDENTIFIER]); | 3150 listener.assertErrorsWithCodes([ParserErrorCode.MISSING_IDENTIFIER]); |
| 3086 } | 3151 } |
| 3087 | 3152 |
| 3088 void test_missingIdentifier_number() { | 3153 void test_missingIdentifier_number() { |
| 3089 createParser('1'); | 3154 createParser('1'); |
| 3090 SimpleIdentifier expression = parser.parseSimpleIdentifier(); | 3155 SimpleIdentifier expression = parser.parseSimpleIdentifier(); |
| 3091 expectNotNullIfNoErrors(expression); | 3156 expectNotNullIfNoErrors(expression); |
| 3092 listener.assertErrorsWithCodes([ParserErrorCode.MISSING_IDENTIFIER]); | 3157 listener.assertErrorsWithCodes([ParserErrorCode.MISSING_IDENTIFIER]); |
| 3093 expect(expression.isSynthetic, isTrue); | 3158 expect(expression.isSynthetic, isTrue); |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3309 [ParserErrorCode.MULTIPLE_VARIABLES_IN_FOR_EACH]); | 3374 [ParserErrorCode.MULTIPLE_VARIABLES_IN_FOR_EACH]); |
| 3310 } | 3375 } |
| 3311 | 3376 |
| 3312 void test_multipleWithClauses() { | 3377 void test_multipleWithClauses() { |
| 3313 parseCompilationUnit("class A extends B with C with D {}", | 3378 parseCompilationUnit("class A extends B with C with D {}", |
| 3314 [ParserErrorCode.MULTIPLE_WITH_CLAUSES]); | 3379 [ParserErrorCode.MULTIPLE_WITH_CLAUSES]); |
| 3315 } | 3380 } |
| 3316 | 3381 |
| 3317 @failingTest | 3382 @failingTest |
| 3318 void test_namedFunctionExpression() { | 3383 void test_namedFunctionExpression() { |
| 3319 createParser('f() {}'); | 3384 Expression expression = parsePrimaryExpression('f() {}'); |
| 3320 Expression expression = parser.parsePrimaryExpression(); | |
| 3321 expectNotNullIfNoErrors(expression); | 3385 expectNotNullIfNoErrors(expression); |
| 3322 listener.assertErrorsWithCodes([ParserErrorCode.NAMED_FUNCTION_EXPRESSION]); | 3386 listener.assertErrorsWithCodes([ParserErrorCode.NAMED_FUNCTION_EXPRESSION]); |
| 3323 expect(expression, new isInstanceOf<FunctionExpression>()); | 3387 expect(expression, new isInstanceOf<FunctionExpression>()); |
| 3324 } | 3388 } |
| 3325 | 3389 |
| 3326 void test_namedParameterOutsideGroup() { | 3390 void test_namedParameterOutsideGroup() { |
| 3327 createParser('(a, b : 0)'); | 3391 createParser('(a, b : 0)'); |
| 3328 FormalParameterList list = parser.parseFormalParameterList(); | 3392 FormalParameterList list = parser.parseFormalParameterList(); |
| 3329 expectNotNullIfNoErrors(list); | 3393 expectNotNullIfNoErrors(list); |
| 3330 listener | 3394 listener |
| (...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3949 [ParserErrorCode.WRONG_TERMINATOR_FOR_PARAMETER_GROUP]); | 4013 [ParserErrorCode.WRONG_TERMINATOR_FOR_PARAMETER_GROUP]); |
| 3950 } | 4014 } |
| 3951 } | 4015 } |
| 3952 | 4016 |
| 3953 @reflectiveTest | 4017 @reflectiveTest |
| 3954 class ExpressionParserTest extends ParserTestCase | 4018 class ExpressionParserTest extends ParserTestCase |
| 3955 with ExpressionParserTestMixin {} | 4019 with ExpressionParserTestMixin {} |
| 3956 | 4020 |
| 3957 abstract class ExpressionParserTestMixin implements AbstractParserTestCase { | 4021 abstract class ExpressionParserTestMixin implements AbstractParserTestCase { |
| 3958 void test_parseAdditiveExpression_normal() { | 4022 void test_parseAdditiveExpression_normal() { |
| 3959 createParser('x + y'); | 4023 Expression expression = parseAdditiveExpression('x + y'); |
| 3960 Expression expression = parser.parseAdditiveExpression(); | |
| 3961 expect(expression, isNotNull); | 4024 expect(expression, isNotNull); |
| 3962 assertNoErrors(); | 4025 assertNoErrors(); |
| 3963 expect(expression, new isInstanceOf<BinaryExpression>()); | 4026 expect(expression, new isInstanceOf<BinaryExpression>()); |
| 3964 BinaryExpression binaryExpression = expression; | 4027 BinaryExpression binaryExpression = expression; |
| 3965 expect(binaryExpression.leftOperand, isNotNull); | 4028 expect(binaryExpression.leftOperand, isNotNull); |
| 3966 expect(binaryExpression.operator, isNotNull); | 4029 expect(binaryExpression.operator, isNotNull); |
| 3967 expect(binaryExpression.operator.type, TokenType.PLUS); | 4030 expect(binaryExpression.operator.type, TokenType.PLUS); |
| 3968 expect(binaryExpression.rightOperand, isNotNull); | 4031 expect(binaryExpression.rightOperand, isNotNull); |
| 3969 } | 4032 } |
| 3970 | 4033 |
| 3971 void test_parseAdditiveExpression_super() { | 4034 void test_parseAdditiveExpression_super() { |
| 3972 createParser('super + y'); | 4035 Expression expression = parseAdditiveExpression('super + y'); |
| 3973 Expression expression = parser.parseAdditiveExpression(); | |
| 3974 expect(expression, isNotNull); | 4036 expect(expression, isNotNull); |
| 3975 assertNoErrors(); | 4037 assertNoErrors(); |
| 3976 expect(expression, new isInstanceOf<BinaryExpression>()); | 4038 expect(expression, new isInstanceOf<BinaryExpression>()); |
| 3977 BinaryExpression binaryExpression = expression; | 4039 BinaryExpression binaryExpression = expression; |
| 3978 expect(binaryExpression.leftOperand, new isInstanceOf<SuperExpression>()); | 4040 expect(binaryExpression.leftOperand, new isInstanceOf<SuperExpression>()); |
| 3979 expect(binaryExpression.operator, isNotNull); | 4041 expect(binaryExpression.operator, isNotNull); |
| 3980 expect(binaryExpression.operator.type, TokenType.PLUS); | 4042 expect(binaryExpression.operator.type, TokenType.PLUS); |
| 3981 expect(binaryExpression.rightOperand, isNotNull); | 4043 expect(binaryExpression.rightOperand, isNotNull); |
| 3982 } | 4044 } |
| 3983 | 4045 |
| 3984 void test_parseAssignableExpression_expression_args_dot() { | 4046 void test_parseAssignableExpression_expression_args_dot() { |
| 3985 createParser('(x)(y).z'); | 4047 Expression expression = parseAssignableExpression('(x)(y).z', false); |
| 3986 Expression expression = parser.parseAssignableExpression(false); | |
| 3987 expect(expression, isNotNull); | 4048 expect(expression, isNotNull); |
| 3988 assertNoErrors(); | 4049 assertNoErrors(); |
| 3989 expect(expression, new isInstanceOf<PropertyAccess>()); | 4050 expect(expression, new isInstanceOf<PropertyAccess>()); |
| 3990 PropertyAccess propertyAccess = expression; | 4051 PropertyAccess propertyAccess = expression; |
| 3991 FunctionExpressionInvocation invocation = | 4052 FunctionExpressionInvocation invocation = |
| 3992 propertyAccess.target as FunctionExpressionInvocation; | 4053 propertyAccess.target as FunctionExpressionInvocation; |
| 3993 expect(invocation.function, isNotNull); | 4054 expect(invocation.function, isNotNull); |
| 3994 expect(invocation.typeArguments, isNull); | 4055 expect(invocation.typeArguments, isNull); |
| 3995 ArgumentList argumentList = invocation.argumentList; | 4056 ArgumentList argumentList = invocation.argumentList; |
| 3996 expect(argumentList, isNotNull); | 4057 expect(argumentList, isNotNull); |
| 3997 expect(argumentList.arguments, hasLength(1)); | 4058 expect(argumentList.arguments, hasLength(1)); |
| 3998 expect(propertyAccess.operator, isNotNull); | 4059 expect(propertyAccess.operator, isNotNull); |
| 3999 expect(propertyAccess.propertyName, isNotNull); | 4060 expect(propertyAccess.propertyName, isNotNull); |
| 4000 } | 4061 } |
| 4001 | 4062 |
| 4002 void | 4063 void |
| 4003 test_parseAssignableExpression_expression_args_dot_typeParameterComments()
{ | 4064 test_parseAssignableExpression_expression_args_dot_typeParameterComments()
{ |
| 4004 enableGenericMethodComments = true; | 4065 enableGenericMethodComments = true; |
| 4005 createParser('(x)/*<F>*/(y).z'); | 4066 Expression expression = parseAssignableExpression('(x)/*<F>*/(y).z', false); |
| 4006 Expression expression = parser.parseAssignableExpression(false); | |
| 4007 expect(expression, isNotNull); | 4067 expect(expression, isNotNull); |
| 4008 assertNoErrors(); | 4068 assertNoErrors(); |
| 4009 expect(expression, new isInstanceOf<PropertyAccess>()); | 4069 expect(expression, new isInstanceOf<PropertyAccess>()); |
| 4010 PropertyAccess propertyAccess = expression; | 4070 PropertyAccess propertyAccess = expression; |
| 4011 FunctionExpressionInvocation invocation = | 4071 FunctionExpressionInvocation invocation = |
| 4012 propertyAccess.target as FunctionExpressionInvocation; | 4072 propertyAccess.target as FunctionExpressionInvocation; |
| 4013 expect(invocation.function, isNotNull); | 4073 expect(invocation.function, isNotNull); |
| 4014 expect(invocation.typeArguments, isNotNull); | 4074 expect(invocation.typeArguments, isNotNull); |
| 4015 ArgumentList argumentList = invocation.argumentList; | 4075 ArgumentList argumentList = invocation.argumentList; |
| 4016 expect(argumentList, isNotNull); | 4076 expect(argumentList, isNotNull); |
| 4017 expect(argumentList.arguments, hasLength(1)); | 4077 expect(argumentList.arguments, hasLength(1)); |
| 4018 expect(propertyAccess.operator, isNotNull); | 4078 expect(propertyAccess.operator, isNotNull); |
| 4019 expect(propertyAccess.propertyName, isNotNull); | 4079 expect(propertyAccess.propertyName, isNotNull); |
| 4020 } | 4080 } |
| 4021 | 4081 |
| 4022 void test_parseAssignableExpression_expression_args_dot_typeParameters() { | 4082 void test_parseAssignableExpression_expression_args_dot_typeParameters() { |
| 4023 createParser('(x)<F>(y).z'); | 4083 Expression expression = parseAssignableExpression('(x)<F>(y).z', false); |
| 4024 Expression expression = parser.parseAssignableExpression(false); | |
| 4025 expect(expression, isNotNull); | 4084 expect(expression, isNotNull); |
| 4026 assertNoErrors(); | 4085 assertNoErrors(); |
| 4027 expect(expression, new isInstanceOf<PropertyAccess>()); | 4086 expect(expression, new isInstanceOf<PropertyAccess>()); |
| 4028 PropertyAccess propertyAccess = expression; | 4087 PropertyAccess propertyAccess = expression; |
| 4029 FunctionExpressionInvocation invocation = | 4088 FunctionExpressionInvocation invocation = |
| 4030 propertyAccess.target as FunctionExpressionInvocation; | 4089 propertyAccess.target as FunctionExpressionInvocation; |
| 4031 expect(invocation.function, isNotNull); | 4090 expect(invocation.function, isNotNull); |
| 4032 expect(invocation.typeArguments, isNotNull); | 4091 expect(invocation.typeArguments, isNotNull); |
| 4033 ArgumentList argumentList = invocation.argumentList; | 4092 ArgumentList argumentList = invocation.argumentList; |
| 4034 expect(argumentList, isNotNull); | 4093 expect(argumentList, isNotNull); |
| 4035 expect(argumentList.arguments, hasLength(1)); | 4094 expect(argumentList.arguments, hasLength(1)); |
| 4036 expect(propertyAccess.operator, isNotNull); | 4095 expect(propertyAccess.operator, isNotNull); |
| 4037 expect(propertyAccess.propertyName, isNotNull); | 4096 expect(propertyAccess.propertyName, isNotNull); |
| 4038 } | 4097 } |
| 4039 | 4098 |
| 4040 void test_parseAssignableExpression_expression_dot() { | 4099 void test_parseAssignableExpression_expression_dot() { |
| 4041 createParser('(x).y'); | 4100 Expression expression = parseAssignableExpression('(x).y', false); |
| 4042 Expression expression = parser.parseAssignableExpression(false); | |
| 4043 expect(expression, isNotNull); | 4101 expect(expression, isNotNull); |
| 4044 assertNoErrors(); | 4102 assertNoErrors(); |
| 4045 expect(expression, new isInstanceOf<PropertyAccess>()); | 4103 expect(expression, new isInstanceOf<PropertyAccess>()); |
| 4046 PropertyAccess propertyAccess = expression; | 4104 PropertyAccess propertyAccess = expression; |
| 4047 expect(propertyAccess.target, isNotNull); | 4105 expect(propertyAccess.target, isNotNull); |
| 4048 expect(propertyAccess.operator.type, TokenType.PERIOD); | 4106 expect(propertyAccess.operator.type, TokenType.PERIOD); |
| 4049 expect(propertyAccess.propertyName, isNotNull); | 4107 expect(propertyAccess.propertyName, isNotNull); |
| 4050 } | 4108 } |
| 4051 | 4109 |
| 4052 void test_parseAssignableExpression_expression_index() { | 4110 void test_parseAssignableExpression_expression_index() { |
| 4053 createParser('(x)[y]'); | 4111 Expression expression = parseAssignableExpression('(x)[y]', false); |
| 4054 Expression expression = parser.parseAssignableExpression(false); | |
| 4055 expect(expression, isNotNull); | 4112 expect(expression, isNotNull); |
| 4056 assertNoErrors(); | 4113 assertNoErrors(); |
| 4057 expect(expression, new isInstanceOf<IndexExpression>()); | 4114 expect(expression, new isInstanceOf<IndexExpression>()); |
| 4058 IndexExpression indexExpression = expression; | 4115 IndexExpression indexExpression = expression; |
| 4059 expect(indexExpression.target, isNotNull); | 4116 expect(indexExpression.target, isNotNull); |
| 4060 expect(indexExpression.leftBracket, isNotNull); | 4117 expect(indexExpression.leftBracket, isNotNull); |
| 4061 expect(indexExpression.index, isNotNull); | 4118 expect(indexExpression.index, isNotNull); |
| 4062 expect(indexExpression.rightBracket, isNotNull); | 4119 expect(indexExpression.rightBracket, isNotNull); |
| 4063 } | 4120 } |
| 4064 | 4121 |
| 4065 void test_parseAssignableExpression_expression_question_dot() { | 4122 void test_parseAssignableExpression_expression_question_dot() { |
| 4066 createParser('(x)?.y'); | 4123 Expression expression = parseAssignableExpression('(x)?.y', false); |
| 4067 Expression expression = parser.parseAssignableExpression(false); | |
| 4068 expect(expression, isNotNull); | 4124 expect(expression, isNotNull); |
| 4069 assertNoErrors(); | 4125 assertNoErrors(); |
| 4070 expect(expression, new isInstanceOf<PropertyAccess>()); | 4126 expect(expression, new isInstanceOf<PropertyAccess>()); |
| 4071 PropertyAccess propertyAccess = expression; | 4127 PropertyAccess propertyAccess = expression; |
| 4072 expect(propertyAccess.target, isNotNull); | 4128 expect(propertyAccess.target, isNotNull); |
| 4073 expect(propertyAccess.operator.type, TokenType.QUESTION_PERIOD); | 4129 expect(propertyAccess.operator.type, TokenType.QUESTION_PERIOD); |
| 4074 expect(propertyAccess.propertyName, isNotNull); | 4130 expect(propertyAccess.propertyName, isNotNull); |
| 4075 } | 4131 } |
| 4076 | 4132 |
| 4077 void test_parseAssignableExpression_identifier() { | 4133 void test_parseAssignableExpression_identifier() { |
| 4078 createParser('x'); | 4134 Expression expression = parseAssignableExpression('x', false); |
| 4079 Expression expression = parser.parseAssignableExpression(false); | |
| 4080 expect(expression, isNotNull); | 4135 expect(expression, isNotNull); |
| 4081 assertNoErrors(); | 4136 assertNoErrors(); |
| 4082 expect(expression, new isInstanceOf<SimpleIdentifier>()); | 4137 expect(expression, new isInstanceOf<SimpleIdentifier>()); |
| 4083 SimpleIdentifier identifier = expression; | 4138 SimpleIdentifier identifier = expression; |
| 4084 expect(identifier, isNotNull); | 4139 expect(identifier, isNotNull); |
| 4085 } | 4140 } |
| 4086 | 4141 |
| 4087 void test_parseAssignableExpression_identifier_args_dot() { | 4142 void test_parseAssignableExpression_identifier_args_dot() { |
| 4088 createParser('x(y).z'); | 4143 Expression expression = parseAssignableExpression('x(y).z', false); |
| 4089 Expression expression = parser.parseAssignableExpression(false); | |
| 4090 expect(expression, isNotNull); | 4144 expect(expression, isNotNull); |
| 4091 assertNoErrors(); | 4145 assertNoErrors(); |
| 4092 expect(expression, new isInstanceOf<PropertyAccess>()); | 4146 expect(expression, new isInstanceOf<PropertyAccess>()); |
| 4093 PropertyAccess propertyAccess = expression; | 4147 PropertyAccess propertyAccess = expression; |
| 4094 MethodInvocation invocation = propertyAccess.target as MethodInvocation; | 4148 MethodInvocation invocation = propertyAccess.target as MethodInvocation; |
| 4095 expect(invocation.methodName.name, "x"); | 4149 expect(invocation.methodName.name, "x"); |
| 4096 expect(invocation.typeArguments, isNull); | 4150 expect(invocation.typeArguments, isNull); |
| 4097 ArgumentList argumentList = invocation.argumentList; | 4151 ArgumentList argumentList = invocation.argumentList; |
| 4098 expect(argumentList, isNotNull); | 4152 expect(argumentList, isNotNull); |
| 4099 expect(argumentList.arguments, hasLength(1)); | 4153 expect(argumentList.arguments, hasLength(1)); |
| 4100 expect(propertyAccess.operator, isNotNull); | 4154 expect(propertyAccess.operator, isNotNull); |
| 4101 expect(propertyAccess.propertyName, isNotNull); | 4155 expect(propertyAccess.propertyName, isNotNull); |
| 4102 } | 4156 } |
| 4103 | 4157 |
| 4104 void | 4158 void |
| 4105 test_parseAssignableExpression_identifier_args_dot_typeParameterComments()
{ | 4159 test_parseAssignableExpression_identifier_args_dot_typeParameterComments()
{ |
| 4106 enableGenericMethodComments = true; | 4160 enableGenericMethodComments = true; |
| 4107 createParser('x/*<E>*/(y).z'); | 4161 Expression expression = parseAssignableExpression('x/*<E>*/(y).z', false); |
| 4108 Expression expression = parser.parseAssignableExpression(false); | |
| 4109 expect(expression, isNotNull); | 4162 expect(expression, isNotNull); |
| 4110 assertNoErrors(); | 4163 assertNoErrors(); |
| 4111 expect(expression, new isInstanceOf<PropertyAccess>()); | 4164 expect(expression, new isInstanceOf<PropertyAccess>()); |
| 4112 PropertyAccess propertyAccess = expression; | 4165 PropertyAccess propertyAccess = expression; |
| 4113 MethodInvocation invocation = propertyAccess.target as MethodInvocation; | 4166 MethodInvocation invocation = propertyAccess.target as MethodInvocation; |
| 4114 expect(invocation.methodName.name, "x"); | 4167 expect(invocation.methodName.name, "x"); |
| 4115 expect(invocation.typeArguments, isNotNull); | 4168 expect(invocation.typeArguments, isNotNull); |
| 4116 ArgumentList argumentList = invocation.argumentList; | 4169 ArgumentList argumentList = invocation.argumentList; |
| 4117 expect(argumentList, isNotNull); | 4170 expect(argumentList, isNotNull); |
| 4118 expect(argumentList.arguments, hasLength(1)); | 4171 expect(argumentList.arguments, hasLength(1)); |
| 4119 expect(propertyAccess.operator, isNotNull); | 4172 expect(propertyAccess.operator, isNotNull); |
| 4120 expect(propertyAccess.propertyName, isNotNull); | 4173 expect(propertyAccess.propertyName, isNotNull); |
| 4121 } | 4174 } |
| 4122 | 4175 |
| 4123 void test_parseAssignableExpression_identifier_args_dot_typeParameters() { | 4176 void test_parseAssignableExpression_identifier_args_dot_typeParameters() { |
| 4124 createParser('x<E>(y).z'); | 4177 Expression expression = parseAssignableExpression('x<E>(y).z', false); |
| 4125 Expression expression = parser.parseAssignableExpression(false); | |
| 4126 expect(expression, isNotNull); | 4178 expect(expression, isNotNull); |
| 4127 assertNoErrors(); | 4179 assertNoErrors(); |
| 4128 expect(expression, new isInstanceOf<PropertyAccess>()); | 4180 expect(expression, new isInstanceOf<PropertyAccess>()); |
| 4129 PropertyAccess propertyAccess = expression; | 4181 PropertyAccess propertyAccess = expression; |
| 4130 MethodInvocation invocation = propertyAccess.target as MethodInvocation; | 4182 MethodInvocation invocation = propertyAccess.target as MethodInvocation; |
| 4131 expect(invocation.methodName.name, "x"); | 4183 expect(invocation.methodName.name, "x"); |
| 4132 expect(invocation.typeArguments, isNotNull); | 4184 expect(invocation.typeArguments, isNotNull); |
| 4133 ArgumentList argumentList = invocation.argumentList; | 4185 ArgumentList argumentList = invocation.argumentList; |
| 4134 expect(argumentList, isNotNull); | 4186 expect(argumentList, isNotNull); |
| 4135 expect(argumentList.arguments, hasLength(1)); | 4187 expect(argumentList.arguments, hasLength(1)); |
| 4136 expect(propertyAccess.operator, isNotNull); | 4188 expect(propertyAccess.operator, isNotNull); |
| 4137 expect(propertyAccess.propertyName, isNotNull); | 4189 expect(propertyAccess.propertyName, isNotNull); |
| 4138 } | 4190 } |
| 4139 | 4191 |
| 4140 void test_parseAssignableExpression_identifier_dot() { | 4192 void test_parseAssignableExpression_identifier_dot() { |
| 4141 createParser('x.y'); | 4193 Expression expression = parseAssignableExpression('x.y', false); |
| 4142 Expression expression = parser.parseAssignableExpression(false); | |
| 4143 expect(expression, isNotNull); | 4194 expect(expression, isNotNull); |
| 4144 assertNoErrors(); | 4195 assertNoErrors(); |
| 4145 expect(expression, new isInstanceOf<PropertyAccess>()); | 4196 expect(expression, new isInstanceOf<PropertyAccess>()); |
| 4146 PropertyAccess propertyAccess = expression; | 4197 PropertyAccess propertyAccess = expression; |
| 4147 expect(propertyAccess.target, isNotNull); | 4198 expect(propertyAccess.target, isNotNull); |
| 4148 expect(propertyAccess.operator, isNotNull); | 4199 expect(propertyAccess.operator, isNotNull); |
| 4149 expect(propertyAccess.operator.type, TokenType.PERIOD); | 4200 expect(propertyAccess.operator.type, TokenType.PERIOD); |
| 4150 expect(propertyAccess.propertyName, isNotNull); | 4201 expect(propertyAccess.propertyName, isNotNull); |
| 4151 } | 4202 } |
| 4152 | 4203 |
| 4153 void test_parseAssignableExpression_identifier_index() { | 4204 void test_parseAssignableExpression_identifier_index() { |
| 4154 createParser('x[y]'); | 4205 Expression expression = parseAssignableExpression('x[y]', false); |
| 4155 Expression expression = parser.parseAssignableExpression(false); | |
| 4156 expect(expression, isNotNull); | 4206 expect(expression, isNotNull); |
| 4157 assertNoErrors(); | 4207 assertNoErrors(); |
| 4158 expect(expression, new isInstanceOf<IndexExpression>()); | 4208 expect(expression, new isInstanceOf<IndexExpression>()); |
| 4159 IndexExpression indexExpression = expression; | 4209 IndexExpression indexExpression = expression; |
| 4160 expect(indexExpression.target, isNotNull); | 4210 expect(indexExpression.target, isNotNull); |
| 4161 expect(indexExpression.leftBracket, isNotNull); | 4211 expect(indexExpression.leftBracket, isNotNull); |
| 4162 expect(indexExpression.index, isNotNull); | 4212 expect(indexExpression.index, isNotNull); |
| 4163 expect(indexExpression.rightBracket, isNotNull); | 4213 expect(indexExpression.rightBracket, isNotNull); |
| 4164 } | 4214 } |
| 4165 | 4215 |
| 4166 void test_parseAssignableExpression_identifier_question_dot() { | 4216 void test_parseAssignableExpression_identifier_question_dot() { |
| 4167 createParser('x?.y'); | 4217 Expression expression = parseAssignableExpression('x?.y', false); |
| 4168 Expression expression = parser.parseAssignableExpression(false); | |
| 4169 expect(expression, isNotNull); | 4218 expect(expression, isNotNull); |
| 4170 assertNoErrors(); | 4219 assertNoErrors(); |
| 4171 expect(expression, new isInstanceOf<PropertyAccess>()); | 4220 expect(expression, new isInstanceOf<PropertyAccess>()); |
| 4172 PropertyAccess propertyAccess = expression; | 4221 PropertyAccess propertyAccess = expression; |
| 4173 expect(propertyAccess.target, isNotNull); | 4222 expect(propertyAccess.target, isNotNull); |
| 4174 expect(propertyAccess.operator.type, TokenType.QUESTION_PERIOD); | 4223 expect(propertyAccess.operator.type, TokenType.QUESTION_PERIOD); |
| 4175 expect(propertyAccess.propertyName, isNotNull); | 4224 expect(propertyAccess.propertyName, isNotNull); |
| 4176 } | 4225 } |
| 4177 | 4226 |
| 4178 void test_parseAssignableExpression_super_dot() { | 4227 void test_parseAssignableExpression_super_dot() { |
| 4179 createParser('super.y'); | 4228 Expression expression = parseAssignableExpression('super.y', false); |
| 4180 Expression expression = parser.parseAssignableExpression(false); | |
| 4181 expect(expression, isNotNull); | 4229 expect(expression, isNotNull); |
| 4182 assertNoErrors(); | 4230 assertNoErrors(); |
| 4183 expect(expression, new isInstanceOf<PropertyAccess>()); | 4231 expect(expression, new isInstanceOf<PropertyAccess>()); |
| 4184 PropertyAccess propertyAccess = expression; | 4232 PropertyAccess propertyAccess = expression; |
| 4185 EngineTestCase.assertInstanceOf((obj) => obj is SuperExpression, | 4233 EngineTestCase.assertInstanceOf((obj) => obj is SuperExpression, |
| 4186 SuperExpression, propertyAccess.target); | 4234 SuperExpression, propertyAccess.target); |
| 4187 expect(propertyAccess.operator, isNotNull); | 4235 expect(propertyAccess.operator, isNotNull); |
| 4188 expect(propertyAccess.propertyName, isNotNull); | 4236 expect(propertyAccess.propertyName, isNotNull); |
| 4189 } | 4237 } |
| 4190 | 4238 |
| 4191 void test_parseAssignableExpression_super_index() { | 4239 void test_parseAssignableExpression_super_index() { |
| 4192 createParser('super[y]'); | 4240 Expression expression = parseAssignableExpression('super[y]', false); |
| 4193 Expression expression = parser.parseAssignableExpression(false); | |
| 4194 expect(expression, isNotNull); | 4241 expect(expression, isNotNull); |
| 4195 assertNoErrors(); | 4242 assertNoErrors(); |
| 4196 expect(expression, new isInstanceOf<IndexExpression>()); | 4243 expect(expression, new isInstanceOf<IndexExpression>()); |
| 4197 IndexExpression indexExpression = expression; | 4244 IndexExpression indexExpression = expression; |
| 4198 expect(indexExpression.target, new isInstanceOf<SuperExpression>()); | 4245 expect(indexExpression.target, new isInstanceOf<SuperExpression>()); |
| 4199 expect(indexExpression.leftBracket, isNotNull); | 4246 expect(indexExpression.leftBracket, isNotNull); |
| 4200 expect(indexExpression.index, isNotNull); | 4247 expect(indexExpression.index, isNotNull); |
| 4201 expect(indexExpression.rightBracket, isNotNull); | 4248 expect(indexExpression.rightBracket, isNotNull); |
| 4202 } | 4249 } |
| 4203 | 4250 |
| 4204 void test_parseAssignableSelector_dot() { | 4251 void test_parseAssignableSelector_dot() { |
| 4205 createParser('.x'); | 4252 Expression expression = parseAssignableSelector('.x', null, true); |
| 4206 Expression expression = parser.parseAssignableSelector(null, true); | |
| 4207 expect(expression, isNotNull); | 4253 expect(expression, isNotNull); |
| 4208 assertNoErrors(); | 4254 assertNoErrors(); |
| 4209 expect(expression, new isInstanceOf<PropertyAccess>()); | 4255 expect(expression, new isInstanceOf<PropertyAccess>()); |
| 4210 PropertyAccess propertyAccess = expression; | 4256 PropertyAccess propertyAccess = expression; |
| 4211 expect(propertyAccess.operator.type, TokenType.PERIOD); | 4257 expect(propertyAccess.operator.type, TokenType.PERIOD); |
| 4212 expect(propertyAccess.propertyName, isNotNull); | 4258 expect(propertyAccess.propertyName, isNotNull); |
| 4213 } | 4259 } |
| 4214 | 4260 |
| 4215 void test_parseAssignableSelector_index() { | 4261 void test_parseAssignableSelector_index() { |
| 4216 createParser('[x]'); | 4262 Expression expression = parseAssignableSelector('[x]', null, true); |
| 4217 Expression expression = parser.parseAssignableSelector(null, true); | |
| 4218 expect(expression, isNotNull); | 4263 expect(expression, isNotNull); |
| 4219 assertNoErrors(); | 4264 assertNoErrors(); |
| 4220 expect(expression, new isInstanceOf<IndexExpression>()); | 4265 expect(expression, new isInstanceOf<IndexExpression>()); |
| 4221 IndexExpression indexExpression = expression; | 4266 IndexExpression indexExpression = expression; |
| 4222 expect(indexExpression.leftBracket, isNotNull); | 4267 expect(indexExpression.leftBracket, isNotNull); |
| 4223 expect(indexExpression.index, isNotNull); | 4268 expect(indexExpression.index, isNotNull); |
| 4224 expect(indexExpression.rightBracket, isNotNull); | 4269 expect(indexExpression.rightBracket, isNotNull); |
| 4225 } | 4270 } |
| 4226 | 4271 |
| 4227 void test_parseAssignableSelector_none() { | 4272 void test_parseAssignableSelector_none() { |
| 4228 createParser(';'); | |
| 4229 Expression expression = | 4273 Expression expression = |
| 4230 parser.parseAssignableSelector(astFactory.simpleIdentifier(null), true); | 4274 parseAssignableSelector(';', astFactory.simpleIdentifier(null), true); |
| 4231 expect(expression, isNotNull); | 4275 expect(expression, isNotNull); |
| 4232 assertNoErrors(); | 4276 assertNoErrors(); |
| 4233 expect(expression, new isInstanceOf<SimpleIdentifier>()); | 4277 expect(expression, new isInstanceOf<SimpleIdentifier>()); |
| 4234 SimpleIdentifier identifier = expression; | 4278 SimpleIdentifier identifier = expression; |
| 4235 expect(identifier, isNotNull); | 4279 expect(identifier, isNotNull); |
| 4236 } | 4280 } |
| 4237 | 4281 |
| 4238 void test_parseAssignableSelector_question_dot() { | 4282 void test_parseAssignableSelector_question_dot() { |
| 4239 createParser('?.x'); | 4283 Expression expression = parseAssignableSelector('?.x', null, true); |
| 4240 Expression expression = parser.parseAssignableSelector(null, true); | |
| 4241 expect(expression, isNotNull); | 4284 expect(expression, isNotNull); |
| 4242 assertNoErrors(); | 4285 assertNoErrors(); |
| 4243 expect(expression, new isInstanceOf<PropertyAccess>()); | 4286 expect(expression, new isInstanceOf<PropertyAccess>()); |
| 4244 PropertyAccess propertyAccess = expression; | 4287 PropertyAccess propertyAccess = expression; |
| 4245 expect(propertyAccess.operator.type, TokenType.QUESTION_PERIOD); | 4288 expect(propertyAccess.operator.type, TokenType.QUESTION_PERIOD); |
| 4246 expect(propertyAccess.propertyName, isNotNull); | 4289 expect(propertyAccess.propertyName, isNotNull); |
| 4247 } | 4290 } |
| 4248 | 4291 |
| 4249 void test_parseAwaitExpression() { | 4292 void test_parseAwaitExpression() { |
| 4250 createParser('await x;'); | 4293 AwaitExpression expression = parseAwaitExpression('await x;'); |
| 4251 AwaitExpression expression = parser.parseAwaitExpression(); | |
| 4252 expect(expression, isNotNull); | 4294 expect(expression, isNotNull); |
| 4253 assertNoErrors(); | 4295 assertNoErrors(); |
| 4254 expect(expression.awaitKeyword, isNotNull); | 4296 expect(expression.awaitKeyword, isNotNull); |
| 4255 expect(expression.expression, isNotNull); | 4297 expect(expression.expression, isNotNull); |
| 4256 } | 4298 } |
| 4257 | 4299 |
| 4258 void test_parseBitwiseAndExpression_normal() { | 4300 void test_parseBitwiseAndExpression_normal() { |
| 4259 createParser('x & y'); | 4301 Expression expression = parseBitwiseAndExpression('x & y'); |
| 4260 Expression expression = parser.parseBitwiseAndExpression(); | |
| 4261 expect(expression, isNotNull); | 4302 expect(expression, isNotNull); |
| 4262 assertNoErrors(); | 4303 assertNoErrors(); |
| 4263 expect(expression, new isInstanceOf<BinaryExpression>()); | 4304 expect(expression, new isInstanceOf<BinaryExpression>()); |
| 4264 BinaryExpression binaryExpression = expression; | 4305 BinaryExpression binaryExpression = expression; |
| 4265 expect(binaryExpression.leftOperand, isNotNull); | 4306 expect(binaryExpression.leftOperand, isNotNull); |
| 4266 expect(binaryExpression.operator, isNotNull); | 4307 expect(binaryExpression.operator, isNotNull); |
| 4267 expect(binaryExpression.operator.type, TokenType.AMPERSAND); | 4308 expect(binaryExpression.operator.type, TokenType.AMPERSAND); |
| 4268 expect(binaryExpression.rightOperand, isNotNull); | 4309 expect(binaryExpression.rightOperand, isNotNull); |
| 4269 } | 4310 } |
| 4270 | 4311 |
| 4271 void test_parseBitwiseAndExpression_super() { | 4312 void test_parseBitwiseAndExpression_super() { |
| 4272 createParser('super & y'); | 4313 Expression expression = parseBitwiseAndExpression('super & y'); |
| 4273 Expression expression = parser.parseBitwiseAndExpression(); | |
| 4274 expect(expression, isNotNull); | 4314 expect(expression, isNotNull); |
| 4275 assertNoErrors(); | 4315 assertNoErrors(); |
| 4276 expect(expression, new isInstanceOf<BinaryExpression>()); | 4316 expect(expression, new isInstanceOf<BinaryExpression>()); |
| 4277 BinaryExpression binaryExpression = expression; | 4317 BinaryExpression binaryExpression = expression; |
| 4278 expect(binaryExpression.leftOperand, new isInstanceOf<SuperExpression>()); | 4318 expect(binaryExpression.leftOperand, new isInstanceOf<SuperExpression>()); |
| 4279 expect(binaryExpression.operator, isNotNull); | 4319 expect(binaryExpression.operator, isNotNull); |
| 4280 expect(binaryExpression.operator.type, TokenType.AMPERSAND); | 4320 expect(binaryExpression.operator.type, TokenType.AMPERSAND); |
| 4281 expect(binaryExpression.rightOperand, isNotNull); | 4321 expect(binaryExpression.rightOperand, isNotNull); |
| 4282 } | 4322 } |
| 4283 | 4323 |
| 4284 void test_parseBitwiseOrExpression_normal() { | 4324 void test_parseBitwiseOrExpression_normal() { |
| 4285 createParser('x | y'); | 4325 Expression expression = parseBitwiseOrExpression('x | y'); |
| 4286 Expression expression = parser.parseBitwiseOrExpression(); | |
| 4287 expect(expression, isNotNull); | 4326 expect(expression, isNotNull); |
| 4288 assertNoErrors(); | 4327 assertNoErrors(); |
| 4289 expect(expression, new isInstanceOf<BinaryExpression>()); | 4328 expect(expression, new isInstanceOf<BinaryExpression>()); |
| 4290 BinaryExpression binaryExpression = expression; | 4329 BinaryExpression binaryExpression = expression; |
| 4291 expect(binaryExpression.leftOperand, isNotNull); | 4330 expect(binaryExpression.leftOperand, isNotNull); |
| 4292 expect(binaryExpression.operator, isNotNull); | 4331 expect(binaryExpression.operator, isNotNull); |
| 4293 expect(binaryExpression.operator.type, TokenType.BAR); | 4332 expect(binaryExpression.operator.type, TokenType.BAR); |
| 4294 expect(binaryExpression.rightOperand, isNotNull); | 4333 expect(binaryExpression.rightOperand, isNotNull); |
| 4295 } | 4334 } |
| 4296 | 4335 |
| 4297 void test_parseBitwiseOrExpression_super() { | 4336 void test_parseBitwiseOrExpression_super() { |
| 4298 createParser('super | y'); | 4337 Expression expression = parseBitwiseOrExpression('super | y'); |
| 4299 Expression expression = parser.parseBitwiseOrExpression(); | |
| 4300 expect(expression, isNotNull); | 4338 expect(expression, isNotNull); |
| 4301 assertNoErrors(); | 4339 assertNoErrors(); |
| 4302 expect(expression, new isInstanceOf<BinaryExpression>()); | 4340 expect(expression, new isInstanceOf<BinaryExpression>()); |
| 4303 BinaryExpression binaryExpression = expression; | 4341 BinaryExpression binaryExpression = expression; |
| 4304 expect(binaryExpression.leftOperand, new isInstanceOf<SuperExpression>()); | 4342 expect(binaryExpression.leftOperand, new isInstanceOf<SuperExpression>()); |
| 4305 expect(binaryExpression.operator, isNotNull); | 4343 expect(binaryExpression.operator, isNotNull); |
| 4306 expect(binaryExpression.operator.type, TokenType.BAR); | 4344 expect(binaryExpression.operator.type, TokenType.BAR); |
| 4307 expect(binaryExpression.rightOperand, isNotNull); | 4345 expect(binaryExpression.rightOperand, isNotNull); |
| 4308 } | 4346 } |
| 4309 | 4347 |
| 4310 void test_parseBitwiseXorExpression_normal() { | 4348 void test_parseBitwiseXorExpression_normal() { |
| 4311 createParser('x ^ y'); | 4349 Expression expression = parseBitwiseXorExpression('x ^ y'); |
| 4312 Expression expression = parser.parseBitwiseXorExpression(); | |
| 4313 expect(expression, isNotNull); | 4350 expect(expression, isNotNull); |
| 4314 assertNoErrors(); | 4351 assertNoErrors(); |
| 4315 expect(expression, new isInstanceOf<BinaryExpression>()); | 4352 expect(expression, new isInstanceOf<BinaryExpression>()); |
| 4316 BinaryExpression binaryExpression = expression; | 4353 BinaryExpression binaryExpression = expression; |
| 4317 expect(binaryExpression.leftOperand, isNotNull); | 4354 expect(binaryExpression.leftOperand, isNotNull); |
| 4318 expect(binaryExpression.operator, isNotNull); | 4355 expect(binaryExpression.operator, isNotNull); |
| 4319 expect(binaryExpression.operator.type, TokenType.CARET); | 4356 expect(binaryExpression.operator.type, TokenType.CARET); |
| 4320 expect(binaryExpression.rightOperand, isNotNull); | 4357 expect(binaryExpression.rightOperand, isNotNull); |
| 4321 } | 4358 } |
| 4322 | 4359 |
| 4323 void test_parseBitwiseXorExpression_super() { | 4360 void test_parseBitwiseXorExpression_super() { |
| 4324 createParser('super ^ y'); | 4361 Expression expression = parseBitwiseXorExpression('super ^ y'); |
| 4325 Expression expression = parser.parseBitwiseXorExpression(); | |
| 4326 expect(expression, isNotNull); | 4362 expect(expression, isNotNull); |
| 4327 assertNoErrors(); | 4363 assertNoErrors(); |
| 4328 expect(expression, new isInstanceOf<BinaryExpression>()); | 4364 expect(expression, new isInstanceOf<BinaryExpression>()); |
| 4329 BinaryExpression binaryExpression = expression; | 4365 BinaryExpression binaryExpression = expression; |
| 4330 expect(binaryExpression.leftOperand, new isInstanceOf<SuperExpression>()); | 4366 expect(binaryExpression.leftOperand, new isInstanceOf<SuperExpression>()); |
| 4331 expect(binaryExpression.operator, isNotNull); | 4367 expect(binaryExpression.operator, isNotNull); |
| 4332 expect(binaryExpression.operator.type, TokenType.CARET); | 4368 expect(binaryExpression.operator.type, TokenType.CARET); |
| 4333 expect(binaryExpression.rightOperand, isNotNull); | 4369 expect(binaryExpression.rightOperand, isNotNull); |
| 4334 } | 4370 } |
| 4335 | 4371 |
| 4336 void test_parseCascadeSection_i() { | 4372 void test_parseCascadeSection_i() { |
| 4337 createParser('..[i]'); | 4373 Expression expression = parseCascadeSection('..[i]'); |
| 4338 Expression expression = parser.parseCascadeSection(); | |
| 4339 expect(expression, isNotNull); | 4374 expect(expression, isNotNull); |
| 4340 assertNoErrors(); | 4375 assertNoErrors(); |
| 4341 expect(expression, new isInstanceOf<IndexExpression>()); | 4376 expect(expression, new isInstanceOf<IndexExpression>()); |
| 4342 IndexExpression section = expression; | 4377 IndexExpression section = expression; |
| 4343 expect(section.target, isNull); | 4378 expect(section.target, isNull); |
| 4344 expect(section.leftBracket, isNotNull); | 4379 expect(section.leftBracket, isNotNull); |
| 4345 expect(section.index, isNotNull); | 4380 expect(section.index, isNotNull); |
| 4346 expect(section.rightBracket, isNotNull); | 4381 expect(section.rightBracket, isNotNull); |
| 4347 } | 4382 } |
| 4348 | 4383 |
| 4349 void test_parseCascadeSection_ia() { | 4384 void test_parseCascadeSection_ia() { |
| 4350 createParser('..[i](b)'); | 4385 Expression expression = parseCascadeSection('..[i](b)'); |
| 4351 Expression expression = parser.parseCascadeSection(); | |
| 4352 expect(expression, isNotNull); | 4386 expect(expression, isNotNull); |
| 4353 assertNoErrors(); | 4387 assertNoErrors(); |
| 4354 expect(expression, new isInstanceOf<FunctionExpressionInvocation>()); | 4388 expect(expression, new isInstanceOf<FunctionExpressionInvocation>()); |
| 4355 FunctionExpressionInvocation section = expression; | 4389 FunctionExpressionInvocation section = expression; |
| 4356 expect(section.function, new isInstanceOf<IndexExpression>()); | 4390 expect(section.function, new isInstanceOf<IndexExpression>()); |
| 4357 expect(section.typeArguments, isNull); | 4391 expect(section.typeArguments, isNull); |
| 4358 expect(section.argumentList, isNotNull); | 4392 expect(section.argumentList, isNotNull); |
| 4359 } | 4393 } |
| 4360 | 4394 |
| 4361 void test_parseCascadeSection_ia_typeArgumentComments() { | 4395 void test_parseCascadeSection_ia_typeArgumentComments() { |
| 4362 enableGenericMethodComments = true; | 4396 enableGenericMethodComments = true; |
| 4363 createParser('..[i]/*<E>*/(b)'); | 4397 Expression expression = parseCascadeSection('..[i]/*<E>*/(b)'); |
| 4364 Expression expression = parser.parseCascadeSection(); | |
| 4365 expect(expression, isNotNull); | 4398 expect(expression, isNotNull); |
| 4366 assertNoErrors(); | 4399 assertNoErrors(); |
| 4367 expect(expression, new isInstanceOf<FunctionExpressionInvocation>()); | 4400 expect(expression, new isInstanceOf<FunctionExpressionInvocation>()); |
| 4368 FunctionExpressionInvocation section = expression; | 4401 FunctionExpressionInvocation section = expression; |
| 4369 expect(section.function, new isInstanceOf<IndexExpression>()); | 4402 expect(section.function, new isInstanceOf<IndexExpression>()); |
| 4370 expect(section.typeArguments, isNotNull); | 4403 expect(section.typeArguments, isNotNull); |
| 4371 expect(section.argumentList, isNotNull); | 4404 expect(section.argumentList, isNotNull); |
| 4372 } | 4405 } |
| 4373 | 4406 |
| 4374 void test_parseCascadeSection_ia_typeArguments() { | 4407 void test_parseCascadeSection_ia_typeArguments() { |
| 4375 createParser('..[i]<E>(b)'); | 4408 Expression expression = parseCascadeSection('..[i]<E>(b)'); |
| 4376 Expression expression = parser.parseCascadeSection(); | |
| 4377 expect(expression, isNotNull); | 4409 expect(expression, isNotNull); |
| 4378 assertNoErrors(); | 4410 assertNoErrors(); |
| 4379 expect(expression, new isInstanceOf<FunctionExpressionInvocation>()); | 4411 expect(expression, new isInstanceOf<FunctionExpressionInvocation>()); |
| 4380 FunctionExpressionInvocation section = expression; | 4412 FunctionExpressionInvocation section = expression; |
| 4381 expect(section.function, new isInstanceOf<IndexExpression>()); | 4413 expect(section.function, new isInstanceOf<IndexExpression>()); |
| 4382 expect(section.typeArguments, isNotNull); | 4414 expect(section.typeArguments, isNotNull); |
| 4383 expect(section.argumentList, isNotNull); | 4415 expect(section.argumentList, isNotNull); |
| 4384 } | 4416 } |
| 4385 | 4417 |
| 4386 void test_parseCascadeSection_ii() { | 4418 void test_parseCascadeSection_ii() { |
| 4387 createParser('..a(b).c(d)'); | 4419 Expression expression = parseCascadeSection('..a(b).c(d)'); |
| 4388 Expression expression = parser.parseCascadeSection(); | |
| 4389 expect(expression, isNotNull); | 4420 expect(expression, isNotNull); |
| 4390 assertNoErrors(); | 4421 assertNoErrors(); |
| 4391 expect(expression, new isInstanceOf<MethodInvocation>()); | 4422 expect(expression, new isInstanceOf<MethodInvocation>()); |
| 4392 MethodInvocation section = expression; | 4423 MethodInvocation section = expression; |
| 4393 expect(section.target, new isInstanceOf<MethodInvocation>()); | 4424 expect(section.target, new isInstanceOf<MethodInvocation>()); |
| 4394 expect(section.operator, isNotNull); | 4425 expect(section.operator, isNotNull); |
| 4395 expect(section.methodName, isNotNull); | 4426 expect(section.methodName, isNotNull); |
| 4396 expect(section.typeArguments, isNull); | 4427 expect(section.typeArguments, isNull); |
| 4397 expect(section.argumentList, isNotNull); | 4428 expect(section.argumentList, isNotNull); |
| 4398 expect(section.argumentList.arguments, hasLength(1)); | 4429 expect(section.argumentList.arguments, hasLength(1)); |
| 4399 } | 4430 } |
| 4400 | 4431 |
| 4401 void test_parseCascadeSection_ii_typeArgumentComments() { | 4432 void test_parseCascadeSection_ii_typeArgumentComments() { |
| 4402 enableGenericMethodComments = true; | 4433 enableGenericMethodComments = true; |
| 4403 createParser('..a/*<E>*/(b).c/*<F>*/(d)'); | 4434 Expression expression = parseCascadeSection('..a/*<E>*/(b).c/*<F>*/(d)'); |
| 4404 Expression expression = parser.parseCascadeSection(); | |
| 4405 expect(expression, isNotNull); | 4435 expect(expression, isNotNull); |
| 4406 assertNoErrors(); | 4436 assertNoErrors(); |
| 4407 expect(expression, new isInstanceOf<MethodInvocation>()); | 4437 expect(expression, new isInstanceOf<MethodInvocation>()); |
| 4408 MethodInvocation section = expression; | 4438 MethodInvocation section = expression; |
| 4409 expect(section.target, new isInstanceOf<MethodInvocation>()); | 4439 expect(section.target, new isInstanceOf<MethodInvocation>()); |
| 4410 expect(section.operator, isNotNull); | 4440 expect(section.operator, isNotNull); |
| 4411 expect(section.methodName, isNotNull); | 4441 expect(section.methodName, isNotNull); |
| 4412 expect(section.typeArguments, isNotNull); | 4442 expect(section.typeArguments, isNotNull); |
| 4413 expect(section.argumentList, isNotNull); | 4443 expect(section.argumentList, isNotNull); |
| 4414 expect(section.argumentList.arguments, hasLength(1)); | 4444 expect(section.argumentList.arguments, hasLength(1)); |
| 4415 } | 4445 } |
| 4416 | 4446 |
| 4417 void test_parseCascadeSection_ii_typeArguments() { | 4447 void test_parseCascadeSection_ii_typeArguments() { |
| 4418 createParser('..a<E>(b).c<F>(d)'); | 4448 Expression expression = parseCascadeSection('..a<E>(b).c<F>(d)'); |
| 4419 Expression expression = parser.parseCascadeSection(); | |
| 4420 expect(expression, isNotNull); | 4449 expect(expression, isNotNull); |
| 4421 assertNoErrors(); | 4450 assertNoErrors(); |
| 4422 expect(expression, new isInstanceOf<MethodInvocation>()); | 4451 expect(expression, new isInstanceOf<MethodInvocation>()); |
| 4423 MethodInvocation section = expression; | 4452 MethodInvocation section = expression; |
| 4424 expect(section.target, new isInstanceOf<MethodInvocation>()); | 4453 expect(section.target, new isInstanceOf<MethodInvocation>()); |
| 4425 expect(section.operator, isNotNull); | 4454 expect(section.operator, isNotNull); |
| 4426 expect(section.methodName, isNotNull); | 4455 expect(section.methodName, isNotNull); |
| 4427 expect(section.typeArguments, isNotNull); | 4456 expect(section.typeArguments, isNotNull); |
| 4428 expect(section.argumentList, isNotNull); | 4457 expect(section.argumentList, isNotNull); |
| 4429 expect(section.argumentList.arguments, hasLength(1)); | 4458 expect(section.argumentList.arguments, hasLength(1)); |
| 4430 } | 4459 } |
| 4431 | 4460 |
| 4432 void test_parseCascadeSection_p() { | 4461 void test_parseCascadeSection_p() { |
| 4433 createParser('..a'); | 4462 Expression expression = parseCascadeSection('..a'); |
| 4434 Expression expression = parser.parseCascadeSection(); | |
| 4435 expect(expression, isNotNull); | 4463 expect(expression, isNotNull); |
| 4436 assertNoErrors(); | 4464 assertNoErrors(); |
| 4437 expect(expression, new isInstanceOf<PropertyAccess>()); | 4465 expect(expression, new isInstanceOf<PropertyAccess>()); |
| 4438 PropertyAccess section = expression; | 4466 PropertyAccess section = expression; |
| 4439 expect(section.target, isNull); | 4467 expect(section.target, isNull); |
| 4440 expect(section.operator, isNotNull); | 4468 expect(section.operator, isNotNull); |
| 4441 expect(section.propertyName, isNotNull); | 4469 expect(section.propertyName, isNotNull); |
| 4442 } | 4470 } |
| 4443 | 4471 |
| 4444 void test_parseCascadeSection_p_assign() { | 4472 void test_parseCascadeSection_p_assign() { |
| 4445 createParser('..a = 3'); | 4473 Expression expression = parseCascadeSection('..a = 3'); |
| 4446 Expression expression = parser.parseCascadeSection(); | |
| 4447 expect(expression, isNotNull); | 4474 expect(expression, isNotNull); |
| 4448 assertNoErrors(); | 4475 assertNoErrors(); |
| 4449 expect(expression, new isInstanceOf<AssignmentExpression>()); | 4476 expect(expression, new isInstanceOf<AssignmentExpression>()); |
| 4450 AssignmentExpression section = expression; | 4477 AssignmentExpression section = expression; |
| 4451 expect(section.leftHandSide, isNotNull); | 4478 expect(section.leftHandSide, isNotNull); |
| 4452 expect(section.operator, isNotNull); | 4479 expect(section.operator, isNotNull); |
| 4453 Expression rhs = section.rightHandSide; | 4480 Expression rhs = section.rightHandSide; |
| 4454 expect(rhs, isNotNull); | 4481 expect(rhs, isNotNull); |
| 4455 } | 4482 } |
| 4456 | 4483 |
| 4457 void test_parseCascadeSection_p_assign_withCascade() { | 4484 void test_parseCascadeSection_p_assign_withCascade() { |
| 4458 createParser('..a = 3..m()'); | 4485 Expression expression = parseCascadeSection('..a = 3..m()'); |
| 4459 Expression expression = parser.parseCascadeSection(); | |
| 4460 expect(expression, isNotNull); | 4486 expect(expression, isNotNull); |
| 4461 assertNoErrors(); | 4487 assertNoErrors(); |
| 4462 expect(expression, new isInstanceOf<AssignmentExpression>()); | 4488 expect(expression, new isInstanceOf<AssignmentExpression>()); |
| 4463 AssignmentExpression section = expression; | 4489 AssignmentExpression section = expression; |
| 4464 expect(section.leftHandSide, isNotNull); | 4490 expect(section.leftHandSide, isNotNull); |
| 4465 expect(section.operator, isNotNull); | 4491 expect(section.operator, isNotNull); |
| 4466 Expression rhs = section.rightHandSide; | 4492 Expression rhs = section.rightHandSide; |
| 4467 EngineTestCase.assertInstanceOf( | 4493 EngineTestCase.assertInstanceOf( |
| 4468 (obj) => obj is IntegerLiteral, IntegerLiteral, rhs); | 4494 (obj) => obj is IntegerLiteral, IntegerLiteral, rhs); |
| 4469 } | 4495 } |
| 4470 | 4496 |
| 4471 void test_parseCascadeSection_p_assign_withCascade_typeArgumentComments() { | 4497 void test_parseCascadeSection_p_assign_withCascade_typeArgumentComments() { |
| 4472 enableGenericMethodComments = true; | 4498 enableGenericMethodComments = true; |
| 4473 createParser('..a = 3..m/*<E>*/()'); | 4499 Expression expression = parseCascadeSection('..a = 3..m/*<E>*/()'); |
| 4474 Expression expression = parser.parseCascadeSection(); | |
| 4475 expect(expression, isNotNull); | 4500 expect(expression, isNotNull); |
| 4476 assertNoErrors(); | 4501 assertNoErrors(); |
| 4477 expect(expression, new isInstanceOf<AssignmentExpression>()); | 4502 expect(expression, new isInstanceOf<AssignmentExpression>()); |
| 4478 AssignmentExpression section = expression; | 4503 AssignmentExpression section = expression; |
| 4479 expect(section.leftHandSide, isNotNull); | 4504 expect(section.leftHandSide, isNotNull); |
| 4480 expect(section.operator, isNotNull); | 4505 expect(section.operator, isNotNull); |
| 4481 Expression rhs = section.rightHandSide; | 4506 Expression rhs = section.rightHandSide; |
| 4482 EngineTestCase.assertInstanceOf( | 4507 EngineTestCase.assertInstanceOf( |
| 4483 (obj) => obj is IntegerLiteral, IntegerLiteral, rhs); | 4508 (obj) => obj is IntegerLiteral, IntegerLiteral, rhs); |
| 4484 } | 4509 } |
| 4485 | 4510 |
| 4486 void test_parseCascadeSection_p_assign_withCascade_typeArguments() { | 4511 void test_parseCascadeSection_p_assign_withCascade_typeArguments() { |
| 4487 createParser('..a = 3..m<E>()'); | 4512 Expression expression = parseCascadeSection('..a = 3..m<E>()'); |
| 4488 Expression expression = parser.parseCascadeSection(); | |
| 4489 expect(expression, isNotNull); | 4513 expect(expression, isNotNull); |
| 4490 assertNoErrors(); | 4514 assertNoErrors(); |
| 4491 expect(expression, new isInstanceOf<AssignmentExpression>()); | 4515 expect(expression, new isInstanceOf<AssignmentExpression>()); |
| 4492 AssignmentExpression section = expression; | 4516 AssignmentExpression section = expression; |
| 4493 expect(section.leftHandSide, isNotNull); | 4517 expect(section.leftHandSide, isNotNull); |
| 4494 expect(section.operator, isNotNull); | 4518 expect(section.operator, isNotNull); |
| 4495 Expression rhs = section.rightHandSide; | 4519 Expression rhs = section.rightHandSide; |
| 4496 EngineTestCase.assertInstanceOf( | 4520 EngineTestCase.assertInstanceOf( |
| 4497 (obj) => obj is IntegerLiteral, IntegerLiteral, rhs); | 4521 (obj) => obj is IntegerLiteral, IntegerLiteral, rhs); |
| 4498 } | 4522 } |
| 4499 | 4523 |
| 4500 void test_parseCascadeSection_p_builtIn() { | 4524 void test_parseCascadeSection_p_builtIn() { |
| 4501 createParser('..as'); | 4525 Expression expression = parseCascadeSection('..as'); |
| 4502 Expression expression = parser.parseCascadeSection(); | |
| 4503 expect(expression, isNotNull); | 4526 expect(expression, isNotNull); |
| 4504 assertNoErrors(); | 4527 assertNoErrors(); |
| 4505 expect(expression, new isInstanceOf<PropertyAccess>()); | 4528 expect(expression, new isInstanceOf<PropertyAccess>()); |
| 4506 PropertyAccess section = expression; | 4529 PropertyAccess section = expression; |
| 4507 expect(section.target, isNull); | 4530 expect(section.target, isNull); |
| 4508 expect(section.operator, isNotNull); | 4531 expect(section.operator, isNotNull); |
| 4509 expect(section.propertyName, isNotNull); | 4532 expect(section.propertyName, isNotNull); |
| 4510 } | 4533 } |
| 4511 | 4534 |
| 4512 void test_parseCascadeSection_pa() { | 4535 void test_parseCascadeSection_pa() { |
| 4513 createParser('..a(b)'); | 4536 Expression expression = parseCascadeSection('..a(b)'); |
| 4514 Expression expression = parser.parseCascadeSection(); | |
| 4515 expect(expression, isNotNull); | 4537 expect(expression, isNotNull); |
| 4516 assertNoErrors(); | 4538 assertNoErrors(); |
| 4517 expect(expression, new isInstanceOf<MethodInvocation>()); | 4539 expect(expression, new isInstanceOf<MethodInvocation>()); |
| 4518 MethodInvocation section = expression; | 4540 MethodInvocation section = expression; |
| 4519 expect(section.target, isNull); | 4541 expect(section.target, isNull); |
| 4520 expect(section.operator, isNotNull); | 4542 expect(section.operator, isNotNull); |
| 4521 expect(section.methodName, isNotNull); | 4543 expect(section.methodName, isNotNull); |
| 4522 expect(section.typeArguments, isNull); | 4544 expect(section.typeArguments, isNull); |
| 4523 expect(section.argumentList, isNotNull); | 4545 expect(section.argumentList, isNotNull); |
| 4524 expect(section.argumentList.arguments, hasLength(1)); | 4546 expect(section.argumentList.arguments, hasLength(1)); |
| 4525 } | 4547 } |
| 4526 | 4548 |
| 4527 void test_parseCascadeSection_pa_typeArgumentComments() { | 4549 void test_parseCascadeSection_pa_typeArgumentComments() { |
| 4528 enableGenericMethodComments = true; | 4550 enableGenericMethodComments = true; |
| 4529 createParser('..a/*<E>*/(b)'); | 4551 Expression expression = parseCascadeSection('..a/*<E>*/(b)'); |
| 4530 Expression expression = parser.parseCascadeSection(); | |
| 4531 expect(expression, isNotNull); | 4552 expect(expression, isNotNull); |
| 4532 assertNoErrors(); | 4553 assertNoErrors(); |
| 4533 expect(expression, new isInstanceOf<MethodInvocation>()); | 4554 expect(expression, new isInstanceOf<MethodInvocation>()); |
| 4534 MethodInvocation section = expression; | 4555 MethodInvocation section = expression; |
| 4535 expect(section.target, isNull); | 4556 expect(section.target, isNull); |
| 4536 expect(section.operator, isNotNull); | 4557 expect(section.operator, isNotNull); |
| 4537 expect(section.methodName, isNotNull); | 4558 expect(section.methodName, isNotNull); |
| 4538 expect(section.typeArguments, isNotNull); | 4559 expect(section.typeArguments, isNotNull); |
| 4539 expect(section.argumentList, isNotNull); | 4560 expect(section.argumentList, isNotNull); |
| 4540 expect(section.argumentList.arguments, hasLength(1)); | 4561 expect(section.argumentList.arguments, hasLength(1)); |
| 4541 } | 4562 } |
| 4542 | 4563 |
| 4543 void test_parseCascadeSection_pa_typeArguments() { | 4564 void test_parseCascadeSection_pa_typeArguments() { |
| 4544 createParser('..a<E>(b)'); | 4565 Expression expression = parseCascadeSection('..a<E>(b)'); |
| 4545 Expression expression = parser.parseCascadeSection(); | |
| 4546 expect(expression, isNotNull); | 4566 expect(expression, isNotNull); |
| 4547 assertNoErrors(); | 4567 assertNoErrors(); |
| 4548 expect(expression, new isInstanceOf<MethodInvocation>()); | 4568 expect(expression, new isInstanceOf<MethodInvocation>()); |
| 4549 MethodInvocation section = expression; | 4569 MethodInvocation section = expression; |
| 4550 expect(section.target, isNull); | 4570 expect(section.target, isNull); |
| 4551 expect(section.operator, isNotNull); | 4571 expect(section.operator, isNotNull); |
| 4552 expect(section.methodName, isNotNull); | 4572 expect(section.methodName, isNotNull); |
| 4553 expect(section.typeArguments, isNotNull); | 4573 expect(section.typeArguments, isNotNull); |
| 4554 expect(section.argumentList, isNotNull); | 4574 expect(section.argumentList, isNotNull); |
| 4555 expect(section.argumentList.arguments, hasLength(1)); | 4575 expect(section.argumentList.arguments, hasLength(1)); |
| 4556 } | 4576 } |
| 4557 | 4577 |
| 4558 void test_parseCascadeSection_paa() { | 4578 void test_parseCascadeSection_paa() { |
| 4559 createParser('..a(b)(c)'); | 4579 Expression expression = parseCascadeSection('..a(b)(c)'); |
| 4560 Expression expression = parser.parseCascadeSection(); | |
| 4561 expect(expression, isNotNull); | 4580 expect(expression, isNotNull); |
| 4562 assertNoErrors(); | 4581 assertNoErrors(); |
| 4563 expect(expression, new isInstanceOf<FunctionExpressionInvocation>()); | 4582 expect(expression, new isInstanceOf<FunctionExpressionInvocation>()); |
| 4564 FunctionExpressionInvocation section = expression; | 4583 FunctionExpressionInvocation section = expression; |
| 4565 expect(section.function, new isInstanceOf<MethodInvocation>()); | 4584 expect(section.function, new isInstanceOf<MethodInvocation>()); |
| 4566 expect(section.typeArguments, isNull); | 4585 expect(section.typeArguments, isNull); |
| 4567 expect(section.argumentList, isNotNull); | 4586 expect(section.argumentList, isNotNull); |
| 4568 expect(section.argumentList.arguments, hasLength(1)); | 4587 expect(section.argumentList.arguments, hasLength(1)); |
| 4569 } | 4588 } |
| 4570 | 4589 |
| 4571 void test_parseCascadeSection_paa_typeArgumentComments() { | 4590 void test_parseCascadeSection_paa_typeArgumentComments() { |
| 4572 enableGenericMethodComments = true; | 4591 enableGenericMethodComments = true; |
| 4573 createParser('..a/*<E>*/(b)/*<F>*/(c)'); | 4592 Expression expression = parseCascadeSection('..a/*<E>*/(b)/*<F>*/(c)'); |
| 4574 Expression expression = parser.parseCascadeSection(); | |
| 4575 expect(expression, isNotNull); | 4593 expect(expression, isNotNull); |
| 4576 assertNoErrors(); | 4594 assertNoErrors(); |
| 4577 expect(expression, new isInstanceOf<FunctionExpressionInvocation>()); | 4595 expect(expression, new isInstanceOf<FunctionExpressionInvocation>()); |
| 4578 FunctionExpressionInvocation section = expression; | 4596 FunctionExpressionInvocation section = expression; |
| 4579 expect(section.function, new isInstanceOf<MethodInvocation>()); | 4597 expect(section.function, new isInstanceOf<MethodInvocation>()); |
| 4580 expect(section.typeArguments, isNotNull); | 4598 expect(section.typeArguments, isNotNull); |
| 4581 expect(section.argumentList, isNotNull); | 4599 expect(section.argumentList, isNotNull); |
| 4582 expect(section.argumentList.arguments, hasLength(1)); | 4600 expect(section.argumentList.arguments, hasLength(1)); |
| 4583 } | 4601 } |
| 4584 | 4602 |
| 4585 void test_parseCascadeSection_paa_typeArguments() { | 4603 void test_parseCascadeSection_paa_typeArguments() { |
| 4586 createParser('..a<E>(b)<F>(c)'); | 4604 Expression expression = parseCascadeSection('..a<E>(b)<F>(c)'); |
| 4587 Expression expression = parser.parseCascadeSection(); | |
| 4588 expect(expression, isNotNull); | 4605 expect(expression, isNotNull); |
| 4589 assertNoErrors(); | 4606 assertNoErrors(); |
| 4590 expect(expression, new isInstanceOf<FunctionExpressionInvocation>()); | 4607 expect(expression, new isInstanceOf<FunctionExpressionInvocation>()); |
| 4591 FunctionExpressionInvocation section = expression; | 4608 FunctionExpressionInvocation section = expression; |
| 4592 expect(section.function, new isInstanceOf<MethodInvocation>()); | 4609 expect(section.function, new isInstanceOf<MethodInvocation>()); |
| 4593 expect(section.typeArguments, isNotNull); | 4610 expect(section.typeArguments, isNotNull); |
| 4594 expect(section.argumentList, isNotNull); | 4611 expect(section.argumentList, isNotNull); |
| 4595 expect(section.argumentList.arguments, hasLength(1)); | 4612 expect(section.argumentList.arguments, hasLength(1)); |
| 4596 } | 4613 } |
| 4597 | 4614 |
| 4598 void test_parseCascadeSection_paapaa() { | 4615 void test_parseCascadeSection_paapaa() { |
| 4599 createParser('..a(b)(c).d(e)(f)'); | 4616 Expression expression = parseCascadeSection('..a(b)(c).d(e)(f)'); |
| 4600 Expression expression = parser.parseCascadeSection(); | |
| 4601 expect(expression, isNotNull); | 4617 expect(expression, isNotNull); |
| 4602 assertNoErrors(); | 4618 assertNoErrors(); |
| 4603 expect(expression, new isInstanceOf<FunctionExpressionInvocation>()); | 4619 expect(expression, new isInstanceOf<FunctionExpressionInvocation>()); |
| 4604 FunctionExpressionInvocation section = expression; | 4620 FunctionExpressionInvocation section = expression; |
| 4605 expect(section.function, new isInstanceOf<MethodInvocation>()); | 4621 expect(section.function, new isInstanceOf<MethodInvocation>()); |
| 4606 expect(section.typeArguments, isNull); | 4622 expect(section.typeArguments, isNull); |
| 4607 expect(section.argumentList, isNotNull); | 4623 expect(section.argumentList, isNotNull); |
| 4608 expect(section.argumentList.arguments, hasLength(1)); | 4624 expect(section.argumentList.arguments, hasLength(1)); |
| 4609 } | 4625 } |
| 4610 | 4626 |
| 4611 void test_parseCascadeSection_paapaa_typeArgumentComments() { | 4627 void test_parseCascadeSection_paapaa_typeArgumentComments() { |
| 4612 enableGenericMethodComments = true; | 4628 enableGenericMethodComments = true; |
| 4613 createParser('..a/*<E>*/(b)/*<F>*/(c).d/*<G>*/(e)/*<H>*/(f)'); | 4629 Expression expression = |
| 4614 Expression expression = parser.parseCascadeSection(); | 4630 parseCascadeSection('..a/*<E>*/(b)/*<F>*/(c).d/*<G>*/(e)/*<H>*/(f)'); |
| 4615 expect(expression, isNotNull); | 4631 expect(expression, isNotNull); |
| 4616 assertNoErrors(); | 4632 assertNoErrors(); |
| 4617 expect(expression, new isInstanceOf<FunctionExpressionInvocation>()); | 4633 expect(expression, new isInstanceOf<FunctionExpressionInvocation>()); |
| 4618 FunctionExpressionInvocation section = expression; | 4634 FunctionExpressionInvocation section = expression; |
| 4619 expect(section.function, new isInstanceOf<MethodInvocation>()); | 4635 expect(section.function, new isInstanceOf<MethodInvocation>()); |
| 4620 expect(section.typeArguments, isNotNull); | 4636 expect(section.typeArguments, isNotNull); |
| 4621 expect(section.argumentList, isNotNull); | 4637 expect(section.argumentList, isNotNull); |
| 4622 expect(section.argumentList.arguments, hasLength(1)); | 4638 expect(section.argumentList.arguments, hasLength(1)); |
| 4623 } | 4639 } |
| 4624 | 4640 |
| 4625 void test_parseCascadeSection_paapaa_typeArguments() { | 4641 void test_parseCascadeSection_paapaa_typeArguments() { |
| 4626 createParser('..a<E>(b)<F>(c).d<G>(e)<H>(f)'); | 4642 Expression expression = |
| 4627 Expression expression = parser.parseCascadeSection(); | 4643 parseCascadeSection('..a<E>(b)<F>(c).d<G>(e)<H>(f)'); |
| 4628 expect(expression, isNotNull); | 4644 expect(expression, isNotNull); |
| 4629 assertNoErrors(); | 4645 assertNoErrors(); |
| 4630 expect(expression, new isInstanceOf<FunctionExpressionInvocation>()); | 4646 expect(expression, new isInstanceOf<FunctionExpressionInvocation>()); |
| 4631 FunctionExpressionInvocation section = expression; | 4647 FunctionExpressionInvocation section = expression; |
| 4632 expect(section.function, new isInstanceOf<MethodInvocation>()); | 4648 expect(section.function, new isInstanceOf<MethodInvocation>()); |
| 4633 expect(section.typeArguments, isNotNull); | 4649 expect(section.typeArguments, isNotNull); |
| 4634 expect(section.argumentList, isNotNull); | 4650 expect(section.argumentList, isNotNull); |
| 4635 expect(section.argumentList.arguments, hasLength(1)); | 4651 expect(section.argumentList.arguments, hasLength(1)); |
| 4636 } | 4652 } |
| 4637 | 4653 |
| 4638 void test_parseCascadeSection_pap() { | 4654 void test_parseCascadeSection_pap() { |
| 4639 createParser('..a(b).c'); | 4655 Expression expression = parseCascadeSection('..a(b).c'); |
| 4640 Expression expression = parser.parseCascadeSection(); | |
| 4641 expect(expression, isNotNull); | 4656 expect(expression, isNotNull); |
| 4642 assertNoErrors(); | 4657 assertNoErrors(); |
| 4643 expect(expression, new isInstanceOf<PropertyAccess>()); | 4658 expect(expression, new isInstanceOf<PropertyAccess>()); |
| 4644 PropertyAccess section = expression; | 4659 PropertyAccess section = expression; |
| 4645 expect(section.target, isNotNull); | 4660 expect(section.target, isNotNull); |
| 4646 expect(section.operator, isNotNull); | 4661 expect(section.operator, isNotNull); |
| 4647 expect(section.propertyName, isNotNull); | 4662 expect(section.propertyName, isNotNull); |
| 4648 } | 4663 } |
| 4649 | 4664 |
| 4650 void test_parseCascadeSection_pap_typeArgumentComments() { | 4665 void test_parseCascadeSection_pap_typeArgumentComments() { |
| 4651 enableGenericMethodComments = true; | 4666 enableGenericMethodComments = true; |
| 4652 createParser('..a/*<E>*/(b).c'); | 4667 Expression expression = parseCascadeSection('..a/*<E>*/(b).c'); |
| 4653 Expression expression = parser.parseCascadeSection(); | |
| 4654 expect(expression, isNotNull); | 4668 expect(expression, isNotNull); |
| 4655 assertNoErrors(); | 4669 assertNoErrors(); |
| 4656 expect(expression, new isInstanceOf<PropertyAccess>()); | 4670 expect(expression, new isInstanceOf<PropertyAccess>()); |
| 4657 PropertyAccess section = expression; | 4671 PropertyAccess section = expression; |
| 4658 expect(section.target, isNotNull); | 4672 expect(section.target, isNotNull); |
| 4659 expect(section.operator, isNotNull); | 4673 expect(section.operator, isNotNull); |
| 4660 expect(section.propertyName, isNotNull); | 4674 expect(section.propertyName, isNotNull); |
| 4661 } | 4675 } |
| 4662 | 4676 |
| 4663 void test_parseCascadeSection_pap_typeArguments() { | 4677 void test_parseCascadeSection_pap_typeArguments() { |
| 4664 createParser('..a<E>(b).c'); | 4678 Expression expression = parseCascadeSection('..a<E>(b).c'); |
| 4665 Expression expression = parser.parseCascadeSection(); | |
| 4666 expect(expression, isNotNull); | 4679 expect(expression, isNotNull); |
| 4667 assertNoErrors(); | 4680 assertNoErrors(); |
| 4668 expect(expression, new isInstanceOf<PropertyAccess>()); | 4681 expect(expression, new isInstanceOf<PropertyAccess>()); |
| 4669 PropertyAccess section = expression; | 4682 PropertyAccess section = expression; |
| 4670 expect(section.target, isNotNull); | 4683 expect(section.target, isNotNull); |
| 4671 expect(section.operator, isNotNull); | 4684 expect(section.operator, isNotNull); |
| 4672 expect(section.propertyName, isNotNull); | 4685 expect(section.propertyName, isNotNull); |
| 4673 } | 4686 } |
| 4674 | 4687 |
| 4675 void test_parseConditionalExpression() { | 4688 void test_parseConditionalExpression() { |
| 4676 createParser('x ? y : z'); | 4689 ConditionalExpression expression = parseConditionalExpression('x ? y : z'); |
| 4677 ConditionalExpression expression = parser.parseConditionalExpression(); | |
| 4678 expect(expression, isNotNull); | 4690 expect(expression, isNotNull); |
| 4679 assertNoErrors(); | 4691 assertNoErrors(); |
| 4680 expect(expression.condition, isNotNull); | 4692 expect(expression.condition, isNotNull); |
| 4681 expect(expression.question, isNotNull); | 4693 expect(expression.question, isNotNull); |
| 4682 expect(expression.thenExpression, isNotNull); | 4694 expect(expression.thenExpression, isNotNull); |
| 4683 expect(expression.colon, isNotNull); | 4695 expect(expression.colon, isNotNull); |
| 4684 expect(expression.elseExpression, isNotNull); | 4696 expect(expression.elseExpression, isNotNull); |
| 4685 } | 4697 } |
| 4686 | 4698 |
| 4687 void test_parseConstExpression_instanceCreation() { | 4699 void test_parseConstExpression_instanceCreation() { |
| 4688 createParser('const A()'); | 4700 Expression expression = parseConstExpression('const A()'); |
| 4689 Expression expression = parser.parseConstExpression(); | |
| 4690 expect(expression, isNotNull); | 4701 expect(expression, isNotNull); |
| 4691 assertNoErrors(); | 4702 assertNoErrors(); |
| 4692 expect(expression, new isInstanceOf<InstanceCreationExpression>()); | 4703 expect(expression, new isInstanceOf<InstanceCreationExpression>()); |
| 4693 InstanceCreationExpression instanceCreation = expression; | 4704 InstanceCreationExpression instanceCreation = expression; |
| 4694 expect(instanceCreation.keyword, isNotNull); | 4705 expect(instanceCreation.keyword, isNotNull); |
| 4695 ConstructorName name = instanceCreation.constructorName; | 4706 ConstructorName name = instanceCreation.constructorName; |
| 4696 expect(name, isNotNull); | 4707 expect(name, isNotNull); |
| 4697 expect(name.type, isNotNull); | 4708 expect(name.type, isNotNull); |
| 4698 expect(name.period, isNull); | 4709 expect(name.period, isNull); |
| 4699 expect(name.name, isNull); | 4710 expect(name.name, isNull); |
| 4700 expect(instanceCreation.argumentList, isNotNull); | 4711 expect(instanceCreation.argumentList, isNotNull); |
| 4701 } | 4712 } |
| 4702 | 4713 |
| 4703 void test_parseConstExpression_listLiteral_typed() { | 4714 void test_parseConstExpression_listLiteral_typed() { |
| 4704 createParser('const <A> []'); | 4715 Expression expression = parseConstExpression('const <A> []'); |
| 4705 Expression expression = parser.parseConstExpression(); | |
| 4706 expect(expression, isNotNull); | 4716 expect(expression, isNotNull); |
| 4707 assertNoErrors(); | 4717 assertNoErrors(); |
| 4708 expect(expression, new isInstanceOf<ListLiteral>()); | 4718 expect(expression, new isInstanceOf<ListLiteral>()); |
| 4709 ListLiteral literal = expression; | 4719 ListLiteral literal = expression; |
| 4710 expect(literal.constKeyword, isNotNull); | 4720 expect(literal.constKeyword, isNotNull); |
| 4711 expect(literal.typeArguments, isNotNull); | 4721 expect(literal.typeArguments, isNotNull); |
| 4712 expect(literal.leftBracket, isNotNull); | 4722 expect(literal.leftBracket, isNotNull); |
| 4713 expect(literal.elements, hasLength(0)); | 4723 expect(literal.elements, hasLength(0)); |
| 4714 expect(literal.rightBracket, isNotNull); | 4724 expect(literal.rightBracket, isNotNull); |
| 4715 } | 4725 } |
| 4716 | 4726 |
| 4717 void test_parseConstExpression_listLiteral_typed_genericComment() { | 4727 void test_parseConstExpression_listLiteral_typed_genericComment() { |
| 4718 enableGenericMethodComments = true; | 4728 enableGenericMethodComments = true; |
| 4719 createParser('const /*<A>*/ []'); | 4729 Expression expression = parseConstExpression('const /*<A>*/ []'); |
| 4720 Expression expression = parser.parseConstExpression(); | |
| 4721 expect(expression, isNotNull); | 4730 expect(expression, isNotNull); |
| 4722 assertNoErrors(); | 4731 assertNoErrors(); |
| 4723 expect(expression, new isInstanceOf<ListLiteral>()); | 4732 expect(expression, new isInstanceOf<ListLiteral>()); |
| 4724 ListLiteral literal = expression; | 4733 ListLiteral literal = expression; |
| 4725 expect(literal.constKeyword, isNotNull); | 4734 expect(literal.constKeyword, isNotNull); |
| 4726 expect(literal.typeArguments, isNotNull); | 4735 expect(literal.typeArguments, isNotNull); |
| 4727 expect(literal.leftBracket, isNotNull); | 4736 expect(literal.leftBracket, isNotNull); |
| 4728 expect(literal.elements, hasLength(0)); | 4737 expect(literal.elements, hasLength(0)); |
| 4729 expect(literal.rightBracket, isNotNull); | 4738 expect(literal.rightBracket, isNotNull); |
| 4730 } | 4739 } |
| 4731 | 4740 |
| 4732 void test_parseConstExpression_listLiteral_untyped() { | 4741 void test_parseConstExpression_listLiteral_untyped() { |
| 4733 createParser('const []'); | 4742 Expression expression = parseConstExpression('const []'); |
| 4734 Expression expression = parser.parseConstExpression(); | |
| 4735 expect(expression, isNotNull); | 4743 expect(expression, isNotNull); |
| 4736 assertNoErrors(); | 4744 assertNoErrors(); |
| 4737 expect(expression, new isInstanceOf<ListLiteral>()); | 4745 expect(expression, new isInstanceOf<ListLiteral>()); |
| 4738 ListLiteral literal = expression; | 4746 ListLiteral literal = expression; |
| 4739 expect(literal.constKeyword, isNotNull); | 4747 expect(literal.constKeyword, isNotNull); |
| 4740 expect(literal.typeArguments, isNull); | 4748 expect(literal.typeArguments, isNull); |
| 4741 expect(literal.leftBracket, isNotNull); | 4749 expect(literal.leftBracket, isNotNull); |
| 4742 expect(literal.elements, hasLength(0)); | 4750 expect(literal.elements, hasLength(0)); |
| 4743 expect(literal.rightBracket, isNotNull); | 4751 expect(literal.rightBracket, isNotNull); |
| 4744 } | 4752 } |
| 4745 | 4753 |
| 4746 void test_parseConstExpression_mapLiteral_typed() { | 4754 void test_parseConstExpression_mapLiteral_typed() { |
| 4747 createParser('const <A, B> {}'); | 4755 Expression expression = parseConstExpression('const <A, B> {}'); |
| 4748 Expression expression = parser.parseConstExpression(); | |
| 4749 expect(expression, isNotNull); | 4756 expect(expression, isNotNull); |
| 4750 assertNoErrors(); | 4757 assertNoErrors(); |
| 4751 expect(expression, new isInstanceOf<MapLiteral>()); | 4758 expect(expression, new isInstanceOf<MapLiteral>()); |
| 4752 MapLiteral literal = expression; | 4759 MapLiteral literal = expression; |
| 4753 expect(literal.leftBracket, isNotNull); | 4760 expect(literal.leftBracket, isNotNull); |
| 4754 expect(literal.entries, hasLength(0)); | 4761 expect(literal.entries, hasLength(0)); |
| 4755 expect(literal.rightBracket, isNotNull); | 4762 expect(literal.rightBracket, isNotNull); |
| 4756 expect(literal.typeArguments, isNotNull); | 4763 expect(literal.typeArguments, isNotNull); |
| 4757 } | 4764 } |
| 4758 | 4765 |
| 4759 void test_parseConstExpression_mapLiteral_typed_genericComment() { | 4766 void test_parseConstExpression_mapLiteral_typed_genericComment() { |
| 4760 enableGenericMethodComments = true; | 4767 enableGenericMethodComments = true; |
| 4761 createParser('const /*<A, B>*/ {}'); | 4768 Expression expression = parseConstExpression('const /*<A, B>*/ {}'); |
| 4762 Expression expression = parser.parseConstExpression(); | |
| 4763 expect(expression, isNotNull); | 4769 expect(expression, isNotNull); |
| 4764 assertNoErrors(); | 4770 assertNoErrors(); |
| 4765 expect(expression, new isInstanceOf<MapLiteral>()); | 4771 expect(expression, new isInstanceOf<MapLiteral>()); |
| 4766 MapLiteral literal = expression; | 4772 MapLiteral literal = expression; |
| 4767 expect(literal.leftBracket, isNotNull); | 4773 expect(literal.leftBracket, isNotNull); |
| 4768 expect(literal.entries, hasLength(0)); | 4774 expect(literal.entries, hasLength(0)); |
| 4769 expect(literal.rightBracket, isNotNull); | 4775 expect(literal.rightBracket, isNotNull); |
| 4770 expect(literal.typeArguments, isNotNull); | 4776 expect(literal.typeArguments, isNotNull); |
| 4771 } | 4777 } |
| 4772 | 4778 |
| 4773 void test_parseConstExpression_mapLiteral_untyped() { | 4779 void test_parseConstExpression_mapLiteral_untyped() { |
| 4774 createParser('const {}'); | 4780 Expression expression = parseConstExpression('const {}'); |
| 4775 Expression expression = parser.parseConstExpression(); | |
| 4776 expect(expression, isNotNull); | 4781 expect(expression, isNotNull); |
| 4777 assertNoErrors(); | 4782 assertNoErrors(); |
| 4778 expect(expression, new isInstanceOf<MapLiteral>()); | 4783 expect(expression, new isInstanceOf<MapLiteral>()); |
| 4779 MapLiteral literal = expression; | 4784 MapLiteral literal = expression; |
| 4780 expect(literal.leftBracket, isNotNull); | 4785 expect(literal.leftBracket, isNotNull); |
| 4781 expect(literal.entries, hasLength(0)); | 4786 expect(literal.entries, hasLength(0)); |
| 4782 expect(literal.rightBracket, isNotNull); | 4787 expect(literal.rightBracket, isNotNull); |
| 4783 expect(literal.typeArguments, isNull); | 4788 expect(literal.typeArguments, isNull); |
| 4784 } | 4789 } |
| 4785 | 4790 |
| 4786 void test_parseEqualityExpression_normal() { | 4791 void test_parseEqualityExpression_normal() { |
| 4787 createParser('x == y'); | 4792 BinaryExpression expression = parseEqualityExpression('x == y'); |
| 4788 BinaryExpression expression = parser.parseEqualityExpression(); | |
| 4789 expect(expression, isNotNull); | 4793 expect(expression, isNotNull); |
| 4790 assertNoErrors(); | 4794 assertNoErrors(); |
| 4791 expect(expression.leftOperand, isNotNull); | 4795 expect(expression.leftOperand, isNotNull); |
| 4792 expect(expression.operator, isNotNull); | 4796 expect(expression.operator, isNotNull); |
| 4793 expect(expression.operator.type, TokenType.EQ_EQ); | 4797 expect(expression.operator.type, TokenType.EQ_EQ); |
| 4794 expect(expression.rightOperand, isNotNull); | 4798 expect(expression.rightOperand, isNotNull); |
| 4795 } | 4799 } |
| 4796 | 4800 |
| 4797 void test_parseEqualityExpression_super() { | 4801 void test_parseEqualityExpression_super() { |
| 4798 createParser('super == y'); | 4802 BinaryExpression expression = parseEqualityExpression('super == y'); |
| 4799 BinaryExpression expression = parser.parseEqualityExpression(); | |
| 4800 expect(expression, isNotNull); | 4803 expect(expression, isNotNull); |
| 4801 assertNoErrors(); | 4804 assertNoErrors(); |
| 4802 expect(expression.leftOperand, new isInstanceOf<SuperExpression>()); | 4805 expect(expression.leftOperand, new isInstanceOf<SuperExpression>()); |
| 4803 expect(expression.operator, isNotNull); | 4806 expect(expression.operator, isNotNull); |
| 4804 expect(expression.operator.type, TokenType.EQ_EQ); | 4807 expect(expression.operator.type, TokenType.EQ_EQ); |
| 4805 expect(expression.rightOperand, isNotNull); | 4808 expect(expression.rightOperand, isNotNull); |
| 4806 } | 4809 } |
| 4807 | 4810 |
| 4808 void test_parseExpression_assign() { | 4811 void test_parseExpression_assign() { |
| 4809 // TODO(brianwilkerson) Implement more tests for this method. | 4812 // TODO(brianwilkerson) Implement more tests for this method. |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4926 Expression expression = parseExpression('super.m<E>()'); | 4929 Expression expression = parseExpression('super.m<E>()'); |
| 4927 expect(expression, new isInstanceOf<MethodInvocation>()); | 4930 expect(expression, new isInstanceOf<MethodInvocation>()); |
| 4928 MethodInvocation invocation = expression; | 4931 MethodInvocation invocation = expression; |
| 4929 expect(invocation.target, isNotNull); | 4932 expect(invocation.target, isNotNull); |
| 4930 expect(invocation.methodName, isNotNull); | 4933 expect(invocation.methodName, isNotNull); |
| 4931 expect(invocation.typeArguments, isNotNull); | 4934 expect(invocation.typeArguments, isNotNull); |
| 4932 expect(invocation.argumentList, isNotNull); | 4935 expect(invocation.argumentList, isNotNull); |
| 4933 } | 4936 } |
| 4934 | 4937 |
| 4935 void test_parseExpressionList_multiple() { | 4938 void test_parseExpressionList_multiple() { |
| 4936 createParser('1, 2, 3'); | 4939 List<Expression> result = parseExpressionList('1, 2, 3'); |
| 4937 List<Expression> result = parser.parseExpressionList(); | |
| 4938 expect(result, isNotNull); | 4940 expect(result, isNotNull); |
| 4939 assertNoErrors(); | 4941 assertNoErrors(); |
| 4940 expect(result, hasLength(3)); | 4942 expect(result, hasLength(3)); |
| 4941 } | 4943 } |
| 4942 | 4944 |
| 4943 void test_parseExpressionList_single() { | 4945 void test_parseExpressionList_single() { |
| 4944 createParser('1'); | 4946 List<Expression> result = parseExpressionList('1'); |
| 4945 List<Expression> result = parser.parseExpressionList(); | |
| 4946 expect(result, isNotNull); | 4947 expect(result, isNotNull); |
| 4947 assertNoErrors(); | 4948 assertNoErrors(); |
| 4948 expect(result, hasLength(1)); | 4949 expect(result, hasLength(1)); |
| 4949 } | 4950 } |
| 4950 | 4951 |
| 4951 void test_parseExpressionWithoutCascade_assign() { | 4952 void test_parseExpressionWithoutCascade_assign() { |
| 4952 // TODO(brianwilkerson) Implement more tests for this method. | 4953 // TODO(brianwilkerson) Implement more tests for this method. |
| 4953 createParser('x = y'); | 4954 Expression expression = parseExpressionWithoutCascade('x = y'); |
| 4954 Expression expression = parser.parseExpressionWithoutCascade(); | |
| 4955 expect(expression, isNotNull); | 4955 expect(expression, isNotNull); |
| 4956 assertNoErrors(); | 4956 assertNoErrors(); |
| 4957 expect(expression, new isInstanceOf<AssignmentExpression>()); | 4957 expect(expression, new isInstanceOf<AssignmentExpression>()); |
| 4958 AssignmentExpression assignmentExpression = expression; | 4958 AssignmentExpression assignmentExpression = expression; |
| 4959 expect(assignmentExpression.leftHandSide, isNotNull); | 4959 expect(assignmentExpression.leftHandSide, isNotNull); |
| 4960 expect(assignmentExpression.operator, isNotNull); | 4960 expect(assignmentExpression.operator, isNotNull); |
| 4961 expect(assignmentExpression.operator.type, TokenType.EQ); | 4961 expect(assignmentExpression.operator.type, TokenType.EQ); |
| 4962 expect(assignmentExpression.rightHandSide, isNotNull); | 4962 expect(assignmentExpression.rightHandSide, isNotNull); |
| 4963 } | 4963 } |
| 4964 | 4964 |
| 4965 void test_parseExpressionWithoutCascade_comparison() { | 4965 void test_parseExpressionWithoutCascade_comparison() { |
| 4966 createParser('--a.b == c'); | 4966 Expression expression = parseExpressionWithoutCascade('--a.b == c'); |
| 4967 Expression expression = parser.parseExpressionWithoutCascade(); | |
| 4968 expect(expression, isNotNull); | 4967 expect(expression, isNotNull); |
| 4969 assertNoErrors(); | 4968 assertNoErrors(); |
| 4970 expect(expression, new isInstanceOf<BinaryExpression>()); | 4969 expect(expression, new isInstanceOf<BinaryExpression>()); |
| 4971 BinaryExpression binaryExpression = expression; | 4970 BinaryExpression binaryExpression = expression; |
| 4972 expect(binaryExpression.leftOperand, isNotNull); | 4971 expect(binaryExpression.leftOperand, isNotNull); |
| 4973 expect(binaryExpression.operator, isNotNull); | 4972 expect(binaryExpression.operator, isNotNull); |
| 4974 expect(binaryExpression.operator.type, TokenType.EQ_EQ); | 4973 expect(binaryExpression.operator.type, TokenType.EQ_EQ); |
| 4975 expect(binaryExpression.rightOperand, isNotNull); | 4974 expect(binaryExpression.rightOperand, isNotNull); |
| 4976 } | 4975 } |
| 4977 | 4976 |
| 4978 void test_parseExpressionWithoutCascade_superMethodInvocation() { | 4977 void test_parseExpressionWithoutCascade_superMethodInvocation() { |
| 4979 createParser('super.m()'); | 4978 Expression expression = parseExpressionWithoutCascade('super.m()'); |
| 4980 Expression expression = parser.parseExpressionWithoutCascade(); | |
| 4981 expect(expression, isNotNull); | 4979 expect(expression, isNotNull); |
| 4982 assertNoErrors(); | 4980 assertNoErrors(); |
| 4983 expect(expression, new isInstanceOf<MethodInvocation>()); | 4981 expect(expression, new isInstanceOf<MethodInvocation>()); |
| 4984 MethodInvocation invocation = expression; | 4982 MethodInvocation invocation = expression; |
| 4985 expect(invocation.target, isNotNull); | 4983 expect(invocation.target, isNotNull); |
| 4986 expect(invocation.methodName, isNotNull); | 4984 expect(invocation.methodName, isNotNull); |
| 4987 expect(invocation.typeArguments, isNull); | 4985 expect(invocation.typeArguments, isNull); |
| 4988 expect(invocation.argumentList, isNotNull); | 4986 expect(invocation.argumentList, isNotNull); |
| 4989 } | 4987 } |
| 4990 | 4988 |
| 4991 void | 4989 void |
| 4992 test_parseExpressionWithoutCascade_superMethodInvocation_typeArgumentComme
nts() { | 4990 test_parseExpressionWithoutCascade_superMethodInvocation_typeArgumentComme
nts() { |
| 4993 enableGenericMethodComments = true; | 4991 enableGenericMethodComments = true; |
| 4994 createParser('super.m/*<E>*/()'); | 4992 Expression expression = parseExpressionWithoutCascade('super.m/*<E>*/()'); |
| 4995 Expression expression = parser.parseExpressionWithoutCascade(); | |
| 4996 expect(expression, isNotNull); | 4993 expect(expression, isNotNull); |
| 4997 assertNoErrors(); | 4994 assertNoErrors(); |
| 4998 expect(expression, new isInstanceOf<MethodInvocation>()); | 4995 expect(expression, new isInstanceOf<MethodInvocation>()); |
| 4999 MethodInvocation invocation = expression; | 4996 MethodInvocation invocation = expression; |
| 5000 expect(invocation.target, isNotNull); | 4997 expect(invocation.target, isNotNull); |
| 5001 expect(invocation.methodName, isNotNull); | 4998 expect(invocation.methodName, isNotNull); |
| 5002 expect(invocation.typeArguments, isNotNull); | 4999 expect(invocation.typeArguments, isNotNull); |
| 5003 expect(invocation.argumentList, isNotNull); | 5000 expect(invocation.argumentList, isNotNull); |
| 5004 } | 5001 } |
| 5005 | 5002 |
| 5006 void | 5003 void |
| 5007 test_parseExpressionWithoutCascade_superMethodInvocation_typeArguments() { | 5004 test_parseExpressionWithoutCascade_superMethodInvocation_typeArguments() { |
| 5008 createParser('super.m<E>()'); | 5005 Expression expression = parseExpressionWithoutCascade('super.m<E>()'); |
| 5009 Expression expression = parser.parseExpressionWithoutCascade(); | |
| 5010 expect(expression, isNotNull); | 5006 expect(expression, isNotNull); |
| 5011 assertNoErrors(); | 5007 assertNoErrors(); |
| 5012 expect(expression, new isInstanceOf<MethodInvocation>()); | 5008 expect(expression, new isInstanceOf<MethodInvocation>()); |
| 5013 MethodInvocation invocation = expression; | 5009 MethodInvocation invocation = expression; |
| 5014 expect(invocation.target, isNotNull); | 5010 expect(invocation.target, isNotNull); |
| 5015 expect(invocation.methodName, isNotNull); | 5011 expect(invocation.methodName, isNotNull); |
| 5016 expect(invocation.typeArguments, isNotNull); | 5012 expect(invocation.typeArguments, isNotNull); |
| 5017 expect(invocation.argumentList, isNotNull); | 5013 expect(invocation.argumentList, isNotNull); |
| 5018 } | 5014 } |
| 5019 | 5015 |
| 5020 void test_parseFunctionExpression_body_inExpression() { | 5016 void test_parseFunctionExpression_body_inExpression() { |
| 5021 createParser('(int i) => i++'); | 5017 FunctionExpression expression = parseFunctionExpression('(int i) => i++'); |
| 5022 FunctionExpression expression = parser.parseFunctionExpression(); | |
| 5023 expect(expression, isNotNull); | 5018 expect(expression, isNotNull); |
| 5024 assertNoErrors(); | 5019 assertNoErrors(); |
| 5025 expect(expression.body, isNotNull); | 5020 expect(expression.body, isNotNull); |
| 5026 expect(expression.typeParameters, isNull); | 5021 expect(expression.typeParameters, isNull); |
| 5027 expect(expression.parameters, isNotNull); | 5022 expect(expression.parameters, isNotNull); |
| 5028 expect((expression.body as ExpressionFunctionBody).semicolon, isNull); | 5023 expect((expression.body as ExpressionFunctionBody).semicolon, isNull); |
| 5029 } | 5024 } |
| 5030 | 5025 |
| 5031 void test_parseFunctionExpression_typeParameterComments() { | 5026 void test_parseFunctionExpression_typeParameterComments() { |
| 5032 enableGenericMethodComments = true; | 5027 enableGenericMethodComments = true; |
| 5033 createParser('/*<E>*/(/*=E*/ i) => i++'); | 5028 FunctionExpression expression = |
| 5034 FunctionExpression expression = parser.parseFunctionExpression(); | 5029 parseFunctionExpression('/*<E>*/(/*=E*/ i) => i++'); |
| 5035 expect(expression, isNotNull); | 5030 expect(expression, isNotNull); |
| 5036 assertNoErrors(); | 5031 assertNoErrors(); |
| 5037 expect(expression.body, isNotNull); | 5032 expect(expression.body, isNotNull); |
| 5038 expect(expression.typeParameters, isNotNull); | 5033 expect(expression.typeParameters, isNotNull); |
| 5039 expect(expression.parameters, isNotNull); | 5034 expect(expression.parameters, isNotNull); |
| 5040 expect((expression.body as ExpressionFunctionBody).semicolon, isNull); | 5035 expect((expression.body as ExpressionFunctionBody).semicolon, isNull); |
| 5041 SimpleFormalParameter p = expression.parameters.parameters[0]; | 5036 SimpleFormalParameter p = expression.parameters.parameters[0]; |
| 5042 expect(p.type, isNotNull); | 5037 expect(p.type, isNotNull); |
| 5043 } | 5038 } |
| 5044 | 5039 |
| 5045 void test_parseFunctionExpression_typeParameters() { | 5040 void test_parseFunctionExpression_typeParameters() { |
| 5046 createParser('<E>(E i) => i++'); | 5041 FunctionExpression expression = parseFunctionExpression('<E>(E i) => i++'); |
| 5047 FunctionExpression expression = parser.parseFunctionExpression(); | |
| 5048 expect(expression, isNotNull); | 5042 expect(expression, isNotNull); |
| 5049 assertNoErrors(); | 5043 assertNoErrors(); |
| 5050 expect(expression.body, isNotNull); | 5044 expect(expression.body, isNotNull); |
| 5051 expect(expression.typeParameters, isNotNull); | 5045 expect(expression.typeParameters, isNotNull); |
| 5052 expect(expression.parameters, isNotNull); | 5046 expect(expression.parameters, isNotNull); |
| 5053 expect((expression.body as ExpressionFunctionBody).semicolon, isNull); | 5047 expect((expression.body as ExpressionFunctionBody).semicolon, isNull); |
| 5054 } | 5048 } |
| 5055 | 5049 |
| 5056 void test_parseInstanceCreationExpression_qualifiedType() { | 5050 void test_parseInstanceCreationExpression_qualifiedType() { |
| 5057 Token token = TokenFactory.tokenFromKeyword(Keyword.NEW); | 5051 Token token = TokenFactory.tokenFromKeyword(Keyword.NEW); |
| 5058 createParser('A.B()'); | |
| 5059 InstanceCreationExpression expression = | 5052 InstanceCreationExpression expression = |
| 5060 parser.parseInstanceCreationExpression(token); | 5053 parseInstanceCreationExpression('A.B()', token); |
| 5061 expect(expression, isNotNull); | 5054 expect(expression, isNotNull); |
| 5062 assertNoErrors(); | 5055 assertNoErrors(); |
| 5063 expect(expression.keyword, token); | 5056 expect(expression.keyword, token); |
| 5064 ConstructorName name = expression.constructorName; | 5057 ConstructorName name = expression.constructorName; |
| 5065 expect(name, isNotNull); | 5058 expect(name, isNotNull); |
| 5066 TypeName type = name.type; | 5059 TypeName type = name.type; |
| 5067 expect(type, isNotNull); | 5060 expect(type, isNotNull); |
| 5068 expect(type.typeArguments, isNull); | 5061 expect(type.typeArguments, isNull); |
| 5069 expect(name.period, isNull); | 5062 expect(name.period, isNull); |
| 5070 expect(name.name, isNull); | 5063 expect(name.name, isNull); |
| 5071 expect(expression.argumentList, isNotNull); | 5064 expect(expression.argumentList, isNotNull); |
| 5072 } | 5065 } |
| 5073 | 5066 |
| 5074 void test_parseInstanceCreationExpression_qualifiedType_named() { | 5067 void test_parseInstanceCreationExpression_qualifiedType_named() { |
| 5075 Token token = TokenFactory.tokenFromKeyword(Keyword.NEW); | 5068 Token token = TokenFactory.tokenFromKeyword(Keyword.NEW); |
| 5076 createParser('A.B.c()'); | |
| 5077 InstanceCreationExpression expression = | 5069 InstanceCreationExpression expression = |
| 5078 parser.parseInstanceCreationExpression(token); | 5070 parseInstanceCreationExpression('A.B.c()', token); |
| 5079 expect(expression, isNotNull); | 5071 expect(expression, isNotNull); |
| 5080 assertNoErrors(); | 5072 assertNoErrors(); |
| 5081 expect(expression.keyword, token); | 5073 expect(expression.keyword, token); |
| 5082 ConstructorName name = expression.constructorName; | 5074 ConstructorName name = expression.constructorName; |
| 5083 expect(name, isNotNull); | 5075 expect(name, isNotNull); |
| 5084 TypeName type = name.type; | 5076 TypeName type = name.type; |
| 5085 expect(type, isNotNull); | 5077 expect(type, isNotNull); |
| 5086 expect(type.typeArguments, isNull); | 5078 expect(type.typeArguments, isNull); |
| 5087 expect(name.period, isNotNull); | 5079 expect(name.period, isNotNull); |
| 5088 expect(name.name, isNotNull); | 5080 expect(name.name, isNotNull); |
| 5089 expect(expression.argumentList, isNotNull); | 5081 expect(expression.argumentList, isNotNull); |
| 5090 } | 5082 } |
| 5091 | 5083 |
| 5092 void | 5084 void |
| 5093 test_parseInstanceCreationExpression_qualifiedType_named_typeParameterComm
ent() { | 5085 test_parseInstanceCreationExpression_qualifiedType_named_typeParameterComm
ent() { |
| 5094 enableGenericMethodComments = true; | 5086 enableGenericMethodComments = true; |
| 5095 Token token = TokenFactory.tokenFromKeyword(Keyword.NEW); | 5087 Token token = TokenFactory.tokenFromKeyword(Keyword.NEW); |
| 5096 createParser('A.B/*<E>*/.c()'); | |
| 5097 InstanceCreationExpression expression = | 5088 InstanceCreationExpression expression = |
| 5098 parser.parseInstanceCreationExpression(token); | 5089 parseInstanceCreationExpression('A.B/*<E>*/.c()', token); |
| 5099 expect(expression, isNotNull); | 5090 expect(expression, isNotNull); |
| 5100 assertNoErrors(); | 5091 assertNoErrors(); |
| 5101 expect(expression.keyword, token); | 5092 expect(expression.keyword, token); |
| 5102 ConstructorName name = expression.constructorName; | 5093 ConstructorName name = expression.constructorName; |
| 5103 expect(name, isNotNull); | 5094 expect(name, isNotNull); |
| 5104 TypeName type = name.type; | 5095 TypeName type = name.type; |
| 5105 expect(type, isNotNull); | 5096 expect(type, isNotNull); |
| 5106 expect(type.typeArguments.arguments, hasLength(1)); | 5097 expect(type.typeArguments.arguments, hasLength(1)); |
| 5107 expect(name.period, isNotNull); | 5098 expect(name.period, isNotNull); |
| 5108 expect(name.name, isNotNull); | 5099 expect(name.name, isNotNull); |
| 5109 expect(expression.argumentList, isNotNull); | 5100 expect(expression.argumentList, isNotNull); |
| 5110 } | 5101 } |
| 5111 | 5102 |
| 5112 void | 5103 void |
| 5113 test_parseInstanceCreationExpression_qualifiedType_named_typeParameters()
{ | 5104 test_parseInstanceCreationExpression_qualifiedType_named_typeParameters()
{ |
| 5114 Token token = TokenFactory.tokenFromKeyword(Keyword.NEW); | 5105 Token token = TokenFactory.tokenFromKeyword(Keyword.NEW); |
| 5115 createParser('A.B<E>.c()'); | |
| 5116 InstanceCreationExpression expression = | 5106 InstanceCreationExpression expression = |
| 5117 parser.parseInstanceCreationExpression(token); | 5107 parseInstanceCreationExpression('A.B<E>.c()', token); |
| 5118 expect(expression, isNotNull); | 5108 expect(expression, isNotNull); |
| 5119 assertNoErrors(); | 5109 assertNoErrors(); |
| 5120 expect(expression.keyword, token); | 5110 expect(expression.keyword, token); |
| 5121 ConstructorName name = expression.constructorName; | 5111 ConstructorName name = expression.constructorName; |
| 5122 expect(name, isNotNull); | 5112 expect(name, isNotNull); |
| 5123 TypeName type = name.type; | 5113 TypeName type = name.type; |
| 5124 expect(type, isNotNull); | 5114 expect(type, isNotNull); |
| 5125 expect(type.typeArguments.arguments, hasLength(1)); | 5115 expect(type.typeArguments.arguments, hasLength(1)); |
| 5126 expect(name.period, isNotNull); | 5116 expect(name.period, isNotNull); |
| 5127 expect(name.name, isNotNull); | 5117 expect(name.name, isNotNull); |
| 5128 expect(expression.argumentList, isNotNull); | 5118 expect(expression.argumentList, isNotNull); |
| 5129 } | 5119 } |
| 5130 | 5120 |
| 5131 void | 5121 void |
| 5132 test_parseInstanceCreationExpression_qualifiedType_typeParameterComment()
{ | 5122 test_parseInstanceCreationExpression_qualifiedType_typeParameterComment()
{ |
| 5133 enableGenericMethodComments = true; | 5123 enableGenericMethodComments = true; |
| 5134 Token token = TokenFactory.tokenFromKeyword(Keyword.NEW); | 5124 Token token = TokenFactory.tokenFromKeyword(Keyword.NEW); |
| 5135 createParser('A.B/*<E>*/()'); | |
| 5136 InstanceCreationExpression expression = | 5125 InstanceCreationExpression expression = |
| 5137 parser.parseInstanceCreationExpression(token); | 5126 parseInstanceCreationExpression('A.B/*<E>*/()', token); |
| 5138 expect(expression, isNotNull); | 5127 expect(expression, isNotNull); |
| 5139 assertNoErrors(); | 5128 assertNoErrors(); |
| 5140 expect(expression.keyword, token); | 5129 expect(expression.keyword, token); |
| 5141 ConstructorName name = expression.constructorName; | 5130 ConstructorName name = expression.constructorName; |
| 5142 expect(name, isNotNull); | 5131 expect(name, isNotNull); |
| 5143 TypeName type = name.type; | 5132 TypeName type = name.type; |
| 5144 expect(type, isNotNull); | 5133 expect(type, isNotNull); |
| 5145 expect(type.typeArguments.arguments, hasLength(1)); | 5134 expect(type.typeArguments.arguments, hasLength(1)); |
| 5146 expect(name.period, isNull); | 5135 expect(name.period, isNull); |
| 5147 expect(name.name, isNull); | 5136 expect(name.name, isNull); |
| 5148 expect(expression.argumentList, isNotNull); | 5137 expect(expression.argumentList, isNotNull); |
| 5149 } | 5138 } |
| 5150 | 5139 |
| 5151 void test_parseInstanceCreationExpression_qualifiedType_typeParameters() { | 5140 void test_parseInstanceCreationExpression_qualifiedType_typeParameters() { |
| 5152 Token token = TokenFactory.tokenFromKeyword(Keyword.NEW); | 5141 Token token = TokenFactory.tokenFromKeyword(Keyword.NEW); |
| 5153 createParser('A.B<E>()'); | |
| 5154 InstanceCreationExpression expression = | 5142 InstanceCreationExpression expression = |
| 5155 parser.parseInstanceCreationExpression(token); | 5143 parseInstanceCreationExpression('A.B<E>()', token); |
| 5156 expect(expression, isNotNull); | 5144 expect(expression, isNotNull); |
| 5157 assertNoErrors(); | 5145 assertNoErrors(); |
| 5158 expect(expression.keyword, token); | 5146 expect(expression.keyword, token); |
| 5159 ConstructorName name = expression.constructorName; | 5147 ConstructorName name = expression.constructorName; |
| 5160 expect(name, isNotNull); | 5148 expect(name, isNotNull); |
| 5161 TypeName type = name.type; | 5149 TypeName type = name.type; |
| 5162 expect(type, isNotNull); | 5150 expect(type, isNotNull); |
| 5163 expect(type.typeArguments.arguments, hasLength(1)); | 5151 expect(type.typeArguments.arguments, hasLength(1)); |
| 5164 expect(name.period, isNull); | 5152 expect(name.period, isNull); |
| 5165 expect(name.name, isNull); | 5153 expect(name.name, isNull); |
| 5166 expect(expression.argumentList, isNotNull); | 5154 expect(expression.argumentList, isNotNull); |
| 5167 } | 5155 } |
| 5168 | 5156 |
| 5169 void test_parseInstanceCreationExpression_type() { | 5157 void test_parseInstanceCreationExpression_type() { |
| 5170 Token token = TokenFactory.tokenFromKeyword(Keyword.NEW); | 5158 Token token = TokenFactory.tokenFromKeyword(Keyword.NEW); |
| 5171 createParser('A()'); | |
| 5172 InstanceCreationExpression expression = | 5159 InstanceCreationExpression expression = |
| 5173 parser.parseInstanceCreationExpression(token); | 5160 parseInstanceCreationExpression('A()', token); |
| 5174 expect(expression, isNotNull); | 5161 expect(expression, isNotNull); |
| 5175 assertNoErrors(); | 5162 assertNoErrors(); |
| 5176 expect(expression.keyword, token); | 5163 expect(expression.keyword, token); |
| 5177 ConstructorName name = expression.constructorName; | 5164 ConstructorName name = expression.constructorName; |
| 5178 expect(name, isNotNull); | 5165 expect(name, isNotNull); |
| 5179 TypeName type = name.type; | 5166 TypeName type = name.type; |
| 5180 expect(type, isNotNull); | 5167 expect(type, isNotNull); |
| 5181 expect(type.typeArguments, isNull); | 5168 expect(type.typeArguments, isNull); |
| 5182 expect(name.period, isNull); | 5169 expect(name.period, isNull); |
| 5183 expect(name.name, isNull); | 5170 expect(name.name, isNull); |
| 5184 expect(expression.argumentList, isNotNull); | 5171 expect(expression.argumentList, isNotNull); |
| 5185 } | 5172 } |
| 5186 | 5173 |
| 5187 void test_parseInstanceCreationExpression_type_named() { | 5174 void test_parseInstanceCreationExpression_type_named() { |
| 5188 enableGenericMethodComments = true; | 5175 enableGenericMethodComments = true; |
| 5189 Token token = TokenFactory.tokenFromKeyword(Keyword.NEW); | 5176 Token token = TokenFactory.tokenFromKeyword(Keyword.NEW); |
| 5190 createParser('A.c()'); | |
| 5191 InstanceCreationExpression expression = | 5177 InstanceCreationExpression expression = |
| 5192 parser.parseInstanceCreationExpression(token); | 5178 parseInstanceCreationExpression('A.c()', token); |
| 5193 expect(expression, isNotNull); | 5179 expect(expression, isNotNull); |
| 5194 assertNoErrors(); | 5180 assertNoErrors(); |
| 5195 expect(expression.keyword, token); | 5181 expect(expression.keyword, token); |
| 5196 ConstructorName name = expression.constructorName; | 5182 ConstructorName name = expression.constructorName; |
| 5197 expect(name, isNotNull); | 5183 expect(name, isNotNull); |
| 5198 TypeName type = name.type; | 5184 TypeName type = name.type; |
| 5199 expect(type, isNotNull); | 5185 expect(type, isNotNull); |
| 5200 expect(type.typeArguments, isNull); | 5186 expect(type.typeArguments, isNull); |
| 5201 expect(name.period, isNull); | 5187 expect(name.period, isNull); |
| 5202 expect(name.name, isNull); | 5188 expect(name.name, isNull); |
| 5203 expect(expression.argumentList, isNotNull); | 5189 expect(expression.argumentList, isNotNull); |
| 5204 } | 5190 } |
| 5205 | 5191 |
| 5206 void test_parseInstanceCreationExpression_type_named_typeParameterComment() { | 5192 void test_parseInstanceCreationExpression_type_named_typeParameterComment() { |
| 5207 enableGenericMethodComments = true; | 5193 enableGenericMethodComments = true; |
| 5208 Token token = TokenFactory.tokenFromKeyword(Keyword.NEW); | 5194 Token token = TokenFactory.tokenFromKeyword(Keyword.NEW); |
| 5209 createParser('A/*<B>*/.c()'); | |
| 5210 InstanceCreationExpression expression = | 5195 InstanceCreationExpression expression = |
| 5211 parser.parseInstanceCreationExpression(token); | 5196 parseInstanceCreationExpression('A/*<B>*/.c()', token); |
| 5212 expect(expression, isNotNull); | 5197 expect(expression, isNotNull); |
| 5213 assertNoErrors(); | 5198 assertNoErrors(); |
| 5214 expect(expression.keyword, token); | 5199 expect(expression.keyword, token); |
| 5215 ConstructorName name = expression.constructorName; | 5200 ConstructorName name = expression.constructorName; |
| 5216 expect(name, isNotNull); | 5201 expect(name, isNotNull); |
| 5217 TypeName type = name.type; | 5202 TypeName type = name.type; |
| 5218 expect(type, isNotNull); | 5203 expect(type, isNotNull); |
| 5219 expect(type.typeArguments.arguments, hasLength(1)); | 5204 expect(type.typeArguments.arguments, hasLength(1)); |
| 5220 expect(name.period, isNotNull); | 5205 expect(name.period, isNotNull); |
| 5221 expect(name.name, isNotNull); | 5206 expect(name.name, isNotNull); |
| 5222 expect(expression.argumentList, isNotNull); | 5207 expect(expression.argumentList, isNotNull); |
| 5223 } | 5208 } |
| 5224 | 5209 |
| 5225 void test_parseInstanceCreationExpression_type_named_typeParameters() { | 5210 void test_parseInstanceCreationExpression_type_named_typeParameters() { |
| 5226 Token token = TokenFactory.tokenFromKeyword(Keyword.NEW); | 5211 Token token = TokenFactory.tokenFromKeyword(Keyword.NEW); |
| 5227 createParser('A<B>.c()'); | |
| 5228 InstanceCreationExpression expression = | 5212 InstanceCreationExpression expression = |
| 5229 parser.parseInstanceCreationExpression(token); | 5213 parseInstanceCreationExpression('A<B>.c()', token); |
| 5230 expect(expression, isNotNull); | 5214 expect(expression, isNotNull); |
| 5231 assertNoErrors(); | 5215 assertNoErrors(); |
| 5232 expect(expression.keyword, token); | 5216 expect(expression.keyword, token); |
| 5233 ConstructorName name = expression.constructorName; | 5217 ConstructorName name = expression.constructorName; |
| 5234 expect(name, isNotNull); | 5218 expect(name, isNotNull); |
| 5235 TypeName type = name.type; | 5219 TypeName type = name.type; |
| 5236 expect(type, isNotNull); | 5220 expect(type, isNotNull); |
| 5237 expect(type.typeArguments.arguments, hasLength(1)); | 5221 expect(type.typeArguments.arguments, hasLength(1)); |
| 5238 expect(name.period, isNotNull); | 5222 expect(name.period, isNotNull); |
| 5239 expect(name.name, isNotNull); | 5223 expect(name.name, isNotNull); |
| 5240 expect(expression.argumentList, isNotNull); | 5224 expect(expression.argumentList, isNotNull); |
| 5241 } | 5225 } |
| 5242 | 5226 |
| 5243 void test_parseInstanceCreationExpression_type_typeParameterComment() { | 5227 void test_parseInstanceCreationExpression_type_typeParameterComment() { |
| 5244 enableGenericMethodComments = true; | 5228 enableGenericMethodComments = true; |
| 5245 Token token = TokenFactory.tokenFromKeyword(Keyword.NEW); | 5229 Token token = TokenFactory.tokenFromKeyword(Keyword.NEW); |
| 5246 createParser('A/*<B>*/()'); | |
| 5247 InstanceCreationExpression expression = | 5230 InstanceCreationExpression expression = |
| 5248 parser.parseInstanceCreationExpression(token); | 5231 parseInstanceCreationExpression('A/*<B>*/()', token); |
| 5249 expect(expression, isNotNull); | 5232 expect(expression, isNotNull); |
| 5250 assertNoErrors(); | 5233 assertNoErrors(); |
| 5251 expect(expression.keyword, token); | 5234 expect(expression.keyword, token); |
| 5252 ConstructorName name = expression.constructorName; | 5235 ConstructorName name = expression.constructorName; |
| 5253 expect(name, isNotNull); | 5236 expect(name, isNotNull); |
| 5254 TypeName type = name.type; | 5237 TypeName type = name.type; |
| 5255 expect(type, isNotNull); | 5238 expect(type, isNotNull); |
| 5256 expect(type.typeArguments.arguments, hasLength(1)); | 5239 expect(type.typeArguments.arguments, hasLength(1)); |
| 5257 expect(name.period, isNull); | 5240 expect(name.period, isNull); |
| 5258 expect(name.name, isNull); | 5241 expect(name.name, isNull); |
| 5259 expect(expression.argumentList, isNotNull); | 5242 expect(expression.argumentList, isNotNull); |
| 5260 } | 5243 } |
| 5261 | 5244 |
| 5262 void test_parseInstanceCreationExpression_type_typeParameters() { | 5245 void test_parseInstanceCreationExpression_type_typeParameters() { |
| 5263 Token token = TokenFactory.tokenFromKeyword(Keyword.NEW); | 5246 Token token = TokenFactory.tokenFromKeyword(Keyword.NEW); |
| 5264 createParser('A<B>()'); | |
| 5265 InstanceCreationExpression expression = | 5247 InstanceCreationExpression expression = |
| 5266 parser.parseInstanceCreationExpression(token); | 5248 parseInstanceCreationExpression('A<B>()', token); |
| 5267 expect(expression, isNotNull); | 5249 expect(expression, isNotNull); |
| 5268 assertNoErrors(); | 5250 assertNoErrors(); |
| 5269 expect(expression.keyword, token); | 5251 expect(expression.keyword, token); |
| 5270 ConstructorName name = expression.constructorName; | 5252 ConstructorName name = expression.constructorName; |
| 5271 expect(name, isNotNull); | 5253 expect(name, isNotNull); |
| 5272 TypeName type = name.type; | 5254 TypeName type = name.type; |
| 5273 expect(type, isNotNull); | 5255 expect(type, isNotNull); |
| 5274 expect(type.typeArguments.arguments, hasLength(1)); | 5256 expect(type.typeArguments.arguments, hasLength(1)); |
| 5275 expect(name.period, isNull); | 5257 expect(name.period, isNull); |
| 5276 expect(name.name, isNull); | 5258 expect(name.name, isNull); |
| 5277 expect(expression.argumentList, isNotNull); | 5259 expect(expression.argumentList, isNotNull); |
| 5278 } | 5260 } |
| 5279 | 5261 |
| 5280 void test_parseInstanceCreationExpression_type_typeParameters_nullable() { | 5262 void test_parseInstanceCreationExpression_type_typeParameters_nullable() { |
| 5281 enableNnbd = true; | 5263 enableNnbd = true; |
| 5282 Token token = TokenFactory.tokenFromKeyword(Keyword.NEW); | 5264 Token token = TokenFactory.tokenFromKeyword(Keyword.NEW); |
| 5283 createParser('A<B?>()'); | |
| 5284 InstanceCreationExpression expression = | 5265 InstanceCreationExpression expression = |
| 5285 parser.parseInstanceCreationExpression(token); | 5266 parseInstanceCreationExpression('A<B?>()', token); |
| 5286 expect(expression, isNotNull); | 5267 expect(expression, isNotNull); |
| 5287 assertNoErrors(); | 5268 assertNoErrors(); |
| 5288 expect(expression.keyword, token); | 5269 expect(expression.keyword, token); |
| 5289 ConstructorName name = expression.constructorName; | 5270 ConstructorName name = expression.constructorName; |
| 5290 expect(name, isNotNull); | 5271 expect(name, isNotNull); |
| 5291 TypeName type = name.type; | 5272 TypeName type = name.type; |
| 5292 expect(type, isNotNull); | 5273 expect(type, isNotNull); |
| 5293 expect(name.period, isNull); | 5274 expect(name.period, isNull); |
| 5294 expect(name.name, isNull); | 5275 expect(name.name, isNull); |
| 5295 expect(expression.argumentList, isNotNull); | 5276 expect(expression.argumentList, isNotNull); |
| 5296 NodeList<TypeAnnotation> arguments = type.typeArguments.arguments; | 5277 NodeList<TypeAnnotation> arguments = type.typeArguments.arguments; |
| 5297 expect(arguments, hasLength(1)); | 5278 expect(arguments, hasLength(1)); |
| 5298 expect((arguments[0] as TypeName).question, isNotNull); | 5279 expect((arguments[0] as TypeName).question, isNotNull); |
| 5299 } | 5280 } |
| 5300 | 5281 |
| 5301 void test_parseListLiteral_empty_oneToken() { | 5282 void test_parseListLiteral_empty_oneToken() { |
| 5302 Token token = TokenFactory.tokenFromKeyword(Keyword.CONST); | 5283 Token token = TokenFactory.tokenFromKeyword(Keyword.CONST); |
| 5303 TypeArgumentList typeArguments = null; | 5284 ListLiteral literal = parseListLiteral(token, null, '[]'); |
| 5304 createParser('[]'); | |
| 5305 ListLiteral literal = parser.parseListLiteral(token, typeArguments); | |
| 5306 expect(literal, isNotNull); | 5285 expect(literal, isNotNull); |
| 5307 assertNoErrors(); | 5286 assertNoErrors(); |
| 5308 expect(literal.constKeyword, token); | 5287 expect(literal.constKeyword, token); |
| 5309 expect(literal.typeArguments, typeArguments); | 5288 expect(literal.typeArguments, isNull); |
| 5310 expect(literal.leftBracket, isNotNull); | 5289 expect(literal.leftBracket, isNotNull); |
| 5311 expect(literal.elements, hasLength(0)); | 5290 expect(literal.elements, hasLength(0)); |
| 5312 expect(literal.rightBracket, isNotNull); | 5291 expect(literal.rightBracket, isNotNull); |
| 5313 } | 5292 } |
| 5314 | 5293 |
| 5315 void test_parseListLiteral_empty_oneToken_withComment() { | 5294 void test_parseListLiteral_empty_oneToken_withComment() { |
| 5316 Token token = null; | 5295 ListLiteral literal = parseListLiteral(null, null, '/* 0 */ []'); |
| 5317 TypeArgumentList typeArguments = null; | |
| 5318 createParser('/* 0 */ []'); | |
| 5319 ListLiteral literal = parser.parseListLiteral(token, typeArguments); | |
| 5320 expect(literal, isNotNull); | 5296 expect(literal, isNotNull); |
| 5321 assertNoErrors(); | 5297 assertNoErrors(); |
| 5322 expect(literal.constKeyword, token); | 5298 expect(literal.constKeyword, isNull); |
| 5323 expect(literal.typeArguments, typeArguments); | 5299 expect(literal.typeArguments, isNull); |
| 5324 Token leftBracket = literal.leftBracket; | 5300 Token leftBracket = literal.leftBracket; |
| 5325 expect(leftBracket, isNotNull); | 5301 expect(leftBracket, isNotNull); |
| 5326 expect(leftBracket.precedingComments, isNotNull); | 5302 expect(leftBracket.precedingComments, isNotNull); |
| 5327 expect(literal.elements, hasLength(0)); | 5303 expect(literal.elements, hasLength(0)); |
| 5328 expect(literal.rightBracket, isNotNull); | 5304 expect(literal.rightBracket, isNotNull); |
| 5329 } | 5305 } |
| 5330 | 5306 |
| 5331 void test_parseListLiteral_empty_twoTokens() { | 5307 void test_parseListLiteral_empty_twoTokens() { |
| 5332 Token token = TokenFactory.tokenFromKeyword(Keyword.CONST); | 5308 Token token = TokenFactory.tokenFromKeyword(Keyword.CONST); |
| 5333 TypeArgumentList typeArguments = null; | 5309 ListLiteral literal = parseListLiteral(token, null, '[ ]'); |
| 5334 createParser('[ ]'); | |
| 5335 ListLiteral literal = parser.parseListLiteral(token, typeArguments); | |
| 5336 expect(literal, isNotNull); | 5310 expect(literal, isNotNull); |
| 5337 assertNoErrors(); | 5311 assertNoErrors(); |
| 5338 expect(literal.constKeyword, token); | 5312 expect(literal.constKeyword, token); |
| 5339 expect(literal.typeArguments, typeArguments); | 5313 expect(literal.typeArguments, isNull); |
| 5340 expect(literal.leftBracket, isNotNull); | 5314 expect(literal.leftBracket, isNotNull); |
| 5341 expect(literal.elements, hasLength(0)); | 5315 expect(literal.elements, hasLength(0)); |
| 5342 expect(literal.rightBracket, isNotNull); | 5316 expect(literal.rightBracket, isNotNull); |
| 5343 } | 5317 } |
| 5344 | 5318 |
| 5345 void test_parseListLiteral_multiple() { | 5319 void test_parseListLiteral_multiple() { |
| 5346 createParser('[1, 2, 3]'); | 5320 ListLiteral literal = parseListLiteral(null, null, '[1, 2, 3]'); |
| 5347 ListLiteral literal = parser.parseListLiteral(null, null); | |
| 5348 expect(literal, isNotNull); | 5321 expect(literal, isNotNull); |
| 5349 assertNoErrors(); | 5322 assertNoErrors(); |
| 5350 expect(literal.constKeyword, isNull); | 5323 expect(literal.constKeyword, isNull); |
| 5351 expect(literal.typeArguments, isNull); | 5324 expect(literal.typeArguments, isNull); |
| 5352 expect(literal.leftBracket, isNotNull); | 5325 expect(literal.leftBracket, isNotNull); |
| 5353 expect(literal.elements, hasLength(3)); | 5326 expect(literal.elements, hasLength(3)); |
| 5354 expect(literal.rightBracket, isNotNull); | 5327 expect(literal.rightBracket, isNotNull); |
| 5355 } | 5328 } |
| 5356 | 5329 |
| 5357 void test_parseListLiteral_single() { | 5330 void test_parseListLiteral_single() { |
| 5358 createParser('[1]'); | 5331 ListLiteral literal = parseListLiteral(null, null, '[1]'); |
| 5359 ListLiteral literal = parser.parseListLiteral(null, null); | |
| 5360 expect(literal, isNotNull); | 5332 expect(literal, isNotNull); |
| 5361 assertNoErrors(); | 5333 assertNoErrors(); |
| 5362 expect(literal.constKeyword, isNull); | 5334 expect(literal.constKeyword, isNull); |
| 5363 expect(literal.typeArguments, isNull); | 5335 expect(literal.typeArguments, isNull); |
| 5364 expect(literal.leftBracket, isNotNull); | 5336 expect(literal.leftBracket, isNotNull); |
| 5365 expect(literal.elements, hasLength(1)); | 5337 expect(literal.elements, hasLength(1)); |
| 5366 expect(literal.rightBracket, isNotNull); | 5338 expect(literal.rightBracket, isNotNull); |
| 5367 } | 5339 } |
| 5368 | 5340 |
| 5341 void test_parseListLiteral_single_withTypeArgument() { |
| 5342 ListLiteral literal = parseListLiteral(null, '<int>', '[1]'); |
| 5343 expect(literal, isNotNull); |
| 5344 assertNoErrors(); |
| 5345 expect(literal.constKeyword, isNull); |
| 5346 expect(literal.typeArguments, isNotNull); |
| 5347 expect(literal.leftBracket, isNotNull); |
| 5348 expect(literal.elements, hasLength(1)); |
| 5349 expect(literal.rightBracket, isNotNull); |
| 5350 } |
| 5351 |
| 5369 void test_parseListOrMapLiteral_list_noType() { | 5352 void test_parseListOrMapLiteral_list_noType() { |
| 5370 createParser('[1]'); | 5353 TypedLiteral literal = parseListOrMapLiteral(null, '[1]'); |
| 5371 TypedLiteral literal = parser.parseListOrMapLiteral(null); | |
| 5372 expect(literal, isNotNull); | 5354 expect(literal, isNotNull); |
| 5373 assertNoErrors(); | 5355 assertNoErrors(); |
| 5374 expect(literal, new isInstanceOf<ListLiteral>()); | 5356 expect(literal, new isInstanceOf<ListLiteral>()); |
| 5375 ListLiteral listLiteral = literal; | 5357 ListLiteral listLiteral = literal; |
| 5376 expect(listLiteral.constKeyword, isNull); | 5358 expect(listLiteral.constKeyword, isNull); |
| 5377 expect(listLiteral.typeArguments, isNull); | 5359 expect(listLiteral.typeArguments, isNull); |
| 5378 expect(listLiteral.leftBracket, isNotNull); | 5360 expect(listLiteral.leftBracket, isNotNull); |
| 5379 expect(listLiteral.elements, hasLength(1)); | 5361 expect(listLiteral.elements, hasLength(1)); |
| 5380 expect(listLiteral.rightBracket, isNotNull); | 5362 expect(listLiteral.rightBracket, isNotNull); |
| 5381 } | 5363 } |
| 5382 | 5364 |
| 5383 void test_parseListOrMapLiteral_list_type() { | 5365 void test_parseListOrMapLiteral_list_type() { |
| 5384 createParser('<int> [1]'); | 5366 TypedLiteral literal = parseListOrMapLiteral(null, '<int> [1]'); |
| 5385 TypedLiteral literal = parser.parseListOrMapLiteral(null); | |
| 5386 expect(literal, isNotNull); | 5367 expect(literal, isNotNull); |
| 5387 assertNoErrors(); | 5368 assertNoErrors(); |
| 5388 expect(literal, new isInstanceOf<ListLiteral>()); | 5369 expect(literal, new isInstanceOf<ListLiteral>()); |
| 5389 ListLiteral listLiteral = literal; | 5370 ListLiteral listLiteral = literal; |
| 5390 expect(listLiteral.constKeyword, isNull); | 5371 expect(listLiteral.constKeyword, isNull); |
| 5391 expect(listLiteral.typeArguments, isNotNull); | 5372 expect(listLiteral.typeArguments, isNotNull); |
| 5392 expect(listLiteral.leftBracket, isNotNull); | 5373 expect(listLiteral.leftBracket, isNotNull); |
| 5393 expect(listLiteral.elements, hasLength(1)); | 5374 expect(listLiteral.elements, hasLength(1)); |
| 5394 expect(listLiteral.rightBracket, isNotNull); | 5375 expect(listLiteral.rightBracket, isNotNull); |
| 5395 } | 5376 } |
| 5396 | 5377 |
| 5397 void test_parseListOrMapLiteral_map_noType() { | 5378 void test_parseListOrMapLiteral_map_noType() { |
| 5398 createParser("{'1' : 1}"); | 5379 TypedLiteral literal = parseListOrMapLiteral(null, "{'1' : 1}"); |
| 5399 TypedLiteral literal = parser.parseListOrMapLiteral(null); | |
| 5400 expect(literal, isNotNull); | 5380 expect(literal, isNotNull); |
| 5401 assertNoErrors(); | 5381 assertNoErrors(); |
| 5402 expect(literal, new isInstanceOf<MapLiteral>()); | 5382 expect(literal, new isInstanceOf<MapLiteral>()); |
| 5403 MapLiteral mapLiteral = literal; | 5383 MapLiteral mapLiteral = literal; |
| 5404 expect(mapLiteral.constKeyword, isNull); | 5384 expect(mapLiteral.constKeyword, isNull); |
| 5405 expect(mapLiteral.typeArguments, isNull); | 5385 expect(mapLiteral.typeArguments, isNull); |
| 5406 expect(mapLiteral.leftBracket, isNotNull); | 5386 expect(mapLiteral.leftBracket, isNotNull); |
| 5407 expect(mapLiteral.entries, hasLength(1)); | 5387 expect(mapLiteral.entries, hasLength(1)); |
| 5408 expect(mapLiteral.rightBracket, isNotNull); | 5388 expect(mapLiteral.rightBracket, isNotNull); |
| 5409 } | 5389 } |
| 5410 | 5390 |
| 5411 void test_parseListOrMapLiteral_map_type() { | 5391 void test_parseListOrMapLiteral_map_type() { |
| 5412 createParser("<String, int> {'1' : 1}"); | 5392 TypedLiteral literal = |
| 5413 TypedLiteral literal = parser.parseListOrMapLiteral(null); | 5393 parseListOrMapLiteral(null, "<String, int> {'1' : 1}"); |
| 5414 expect(literal, isNotNull); | 5394 expect(literal, isNotNull); |
| 5415 assertNoErrors(); | 5395 assertNoErrors(); |
| 5416 expect(literal, new isInstanceOf<MapLiteral>()); | 5396 expect(literal, new isInstanceOf<MapLiteral>()); |
| 5417 MapLiteral mapLiteral = literal; | 5397 MapLiteral mapLiteral = literal; |
| 5418 expect(mapLiteral.constKeyword, isNull); | 5398 expect(mapLiteral.constKeyword, isNull); |
| 5419 expect(mapLiteral.typeArguments, isNotNull); | 5399 expect(mapLiteral.typeArguments, isNotNull); |
| 5420 expect(mapLiteral.leftBracket, isNotNull); | 5400 expect(mapLiteral.leftBracket, isNotNull); |
| 5421 expect(mapLiteral.entries, hasLength(1)); | 5401 expect(mapLiteral.entries, hasLength(1)); |
| 5422 expect(mapLiteral.rightBracket, isNotNull); | 5402 expect(mapLiteral.rightBracket, isNotNull); |
| 5423 } | 5403 } |
| 5424 | 5404 |
| 5425 void test_parseLogicalAndExpression() { | 5405 void test_parseLogicalAndExpression() { |
| 5426 createParser('x && y'); | 5406 Expression expression = parseLogicalAndExpression('x && y'); |
| 5427 Expression expression = parser.parseLogicalAndExpression(); | |
| 5428 expect(expression, isNotNull); | 5407 expect(expression, isNotNull); |
| 5429 assertNoErrors(); | 5408 assertNoErrors(); |
| 5430 expect(expression, new isInstanceOf<BinaryExpression>()); | 5409 expect(expression, new isInstanceOf<BinaryExpression>()); |
| 5431 BinaryExpression binaryExpression = expression; | 5410 BinaryExpression binaryExpression = expression; |
| 5432 expect(binaryExpression.leftOperand, isNotNull); | 5411 expect(binaryExpression.leftOperand, isNotNull); |
| 5433 expect(binaryExpression.operator, isNotNull); | 5412 expect(binaryExpression.operator, isNotNull); |
| 5434 expect(binaryExpression.operator.type, TokenType.AMPERSAND_AMPERSAND); | 5413 expect(binaryExpression.operator.type, TokenType.AMPERSAND_AMPERSAND); |
| 5435 expect(binaryExpression.rightOperand, isNotNull); | 5414 expect(binaryExpression.rightOperand, isNotNull); |
| 5436 } | 5415 } |
| 5437 | 5416 |
| 5438 void test_parseLogicalOrExpression() { | 5417 void test_parseLogicalOrExpression() { |
| 5439 createParser('x || y'); | 5418 Expression expression = parseLogicalOrExpression('x || y'); |
| 5440 Expression expression = parser.parseLogicalOrExpression(); | |
| 5441 expect(expression, isNotNull); | 5419 expect(expression, isNotNull); |
| 5442 assertNoErrors(); | 5420 assertNoErrors(); |
| 5443 expect(expression, new isInstanceOf<BinaryExpression>()); | 5421 expect(expression, new isInstanceOf<BinaryExpression>()); |
| 5444 BinaryExpression binaryExpression = expression; | 5422 BinaryExpression binaryExpression = expression; |
| 5445 expect(binaryExpression.leftOperand, isNotNull); | 5423 expect(binaryExpression.leftOperand, isNotNull); |
| 5446 expect(binaryExpression.operator, isNotNull); | 5424 expect(binaryExpression.operator, isNotNull); |
| 5447 expect(binaryExpression.operator.type, TokenType.BAR_BAR); | 5425 expect(binaryExpression.operator.type, TokenType.BAR_BAR); |
| 5448 expect(binaryExpression.rightOperand, isNotNull); | 5426 expect(binaryExpression.rightOperand, isNotNull); |
| 5449 } | 5427 } |
| 5450 | 5428 |
| 5451 void test_parseMapLiteral_empty() { | 5429 void test_parseMapLiteral_empty() { |
| 5452 Token token = TokenFactory.tokenFromKeyword(Keyword.CONST); | 5430 Token token = TokenFactory.tokenFromKeyword(Keyword.CONST); |
| 5453 TypeArgumentList typeArguments = AstTestFactory.typeArgumentList( | 5431 MapLiteral literal = parseMapLiteral(token, '<String, int>', '{}'); |
| 5454 [AstTestFactory.typeName4("String"), AstTestFactory.typeName4("int")]); | |
| 5455 createParser('{}'); | |
| 5456 MapLiteral literal = parser.parseMapLiteral(token, typeArguments); | |
| 5457 expect(literal, isNotNull); | 5432 expect(literal, isNotNull); |
| 5458 assertNoErrors(); | 5433 assertNoErrors(); |
| 5459 expect(literal.constKeyword, token); | 5434 expect(literal.constKeyword, token); |
| 5460 expect(literal.typeArguments, typeArguments); | 5435 expect(literal.typeArguments, isNotNull); |
| 5461 expect(literal.leftBracket, isNotNull); | 5436 expect(literal.leftBracket, isNotNull); |
| 5462 expect(literal.entries, hasLength(0)); | 5437 expect(literal.entries, hasLength(0)); |
| 5463 expect(literal.rightBracket, isNotNull); | 5438 expect(literal.rightBracket, isNotNull); |
| 5464 } | 5439 } |
| 5465 | 5440 |
| 5466 void test_parseMapLiteral_multiple() { | 5441 void test_parseMapLiteral_multiple() { |
| 5467 createParser("{'a' : b, 'x' : y}"); | 5442 MapLiteral literal = parseMapLiteral(null, null, "{'a' : b, 'x' : y}"); |
| 5468 MapLiteral literal = parser.parseMapLiteral(null, null); | |
| 5469 expect(literal, isNotNull); | 5443 expect(literal, isNotNull); |
| 5470 assertNoErrors(); | 5444 assertNoErrors(); |
| 5471 expect(literal.leftBracket, isNotNull); | 5445 expect(literal.leftBracket, isNotNull); |
| 5472 expect(literal.entries, hasLength(2)); | 5446 expect(literal.entries, hasLength(2)); |
| 5473 expect(literal.rightBracket, isNotNull); | 5447 expect(literal.rightBracket, isNotNull); |
| 5474 } | 5448 } |
| 5475 | 5449 |
| 5476 void test_parseMapLiteral_single() { | 5450 void test_parseMapLiteral_single() { |
| 5477 createParser("{'x' : y}"); | 5451 MapLiteral literal = parseMapLiteral(null, null, "{'x' : y}"); |
| 5478 MapLiteral literal = parser.parseMapLiteral(null, null); | |
| 5479 expect(literal, isNotNull); | 5452 expect(literal, isNotNull); |
| 5480 assertNoErrors(); | 5453 assertNoErrors(); |
| 5481 expect(literal.leftBracket, isNotNull); | 5454 expect(literal.leftBracket, isNotNull); |
| 5482 expect(literal.entries, hasLength(1)); | 5455 expect(literal.entries, hasLength(1)); |
| 5483 expect(literal.rightBracket, isNotNull); | 5456 expect(literal.rightBracket, isNotNull); |
| 5484 } | 5457 } |
| 5485 | 5458 |
| 5486 void test_parseMapLiteralEntry_complex() { | 5459 void test_parseMapLiteralEntry_complex() { |
| 5487 createParser('2 + 2 : y'); | 5460 MapLiteralEntry entry = parseMapLiteralEntry('2 + 2 : y'); |
| 5488 MapLiteralEntry entry = parser.parseMapLiteralEntry(); | |
| 5489 expect(entry, isNotNull); | 5461 expect(entry, isNotNull); |
| 5490 assertNoErrors(); | 5462 assertNoErrors(); |
| 5491 expect(entry.key, isNotNull); | 5463 expect(entry.key, isNotNull); |
| 5492 expect(entry.separator, isNotNull); | 5464 expect(entry.separator, isNotNull); |
| 5493 expect(entry.value, isNotNull); | 5465 expect(entry.value, isNotNull); |
| 5494 } | 5466 } |
| 5495 | 5467 |
| 5496 void test_parseMapLiteralEntry_int() { | 5468 void test_parseMapLiteralEntry_int() { |
| 5497 createParser('0 : y'); | 5469 MapLiteralEntry entry = parseMapLiteralEntry('0 : y'); |
| 5498 MapLiteralEntry entry = parser.parseMapLiteralEntry(); | |
| 5499 expect(entry, isNotNull); | 5470 expect(entry, isNotNull); |
| 5500 assertNoErrors(); | 5471 assertNoErrors(); |
| 5501 expect(entry.key, isNotNull); | 5472 expect(entry.key, isNotNull); |
| 5502 expect(entry.separator, isNotNull); | 5473 expect(entry.separator, isNotNull); |
| 5503 expect(entry.value, isNotNull); | 5474 expect(entry.value, isNotNull); |
| 5504 } | 5475 } |
| 5505 | 5476 |
| 5506 void test_parseMapLiteralEntry_string() { | 5477 void test_parseMapLiteralEntry_string() { |
| 5507 createParser("'x' : y"); | 5478 MapLiteralEntry entry = parseMapLiteralEntry("'x' : y"); |
| 5508 MapLiteralEntry entry = parser.parseMapLiteralEntry(); | |
| 5509 expect(entry, isNotNull); | 5479 expect(entry, isNotNull); |
| 5510 assertNoErrors(); | 5480 assertNoErrors(); |
| 5511 expect(entry.key, isNotNull); | 5481 expect(entry.key, isNotNull); |
| 5512 expect(entry.separator, isNotNull); | 5482 expect(entry.separator, isNotNull); |
| 5513 expect(entry.value, isNotNull); | 5483 expect(entry.value, isNotNull); |
| 5514 } | 5484 } |
| 5515 | 5485 |
| 5516 void test_parseMultiplicativeExpression_normal() { | 5486 void test_parseMultiplicativeExpression_normal() { |
| 5517 createParser('x * y'); | 5487 Expression expression = parseMultiplicativeExpression('x * y'); |
| 5518 Expression expression = parser.parseMultiplicativeExpression(); | |
| 5519 expect(expression, isNotNull); | 5488 expect(expression, isNotNull); |
| 5520 assertNoErrors(); | 5489 assertNoErrors(); |
| 5521 expect(expression, new isInstanceOf<BinaryExpression>()); | 5490 expect(expression, new isInstanceOf<BinaryExpression>()); |
| 5522 BinaryExpression binaryExpression = expression; | 5491 BinaryExpression binaryExpression = expression; |
| 5523 expect(binaryExpression.leftOperand, isNotNull); | 5492 expect(binaryExpression.leftOperand, isNotNull); |
| 5524 expect(binaryExpression.operator, isNotNull); | 5493 expect(binaryExpression.operator, isNotNull); |
| 5525 expect(binaryExpression.operator.type, TokenType.STAR); | 5494 expect(binaryExpression.operator.type, TokenType.STAR); |
| 5526 expect(binaryExpression.rightOperand, isNotNull); | 5495 expect(binaryExpression.rightOperand, isNotNull); |
| 5527 } | 5496 } |
| 5528 | 5497 |
| 5529 void test_parseMultiplicativeExpression_super() { | 5498 void test_parseMultiplicativeExpression_super() { |
| 5530 createParser('super * y'); | 5499 Expression expression = parseMultiplicativeExpression('super * y'); |
| 5531 Expression expression = parser.parseMultiplicativeExpression(); | |
| 5532 expect(expression, isNotNull); | 5500 expect(expression, isNotNull); |
| 5533 assertNoErrors(); | 5501 assertNoErrors(); |
| 5534 expect(expression, new isInstanceOf<BinaryExpression>()); | 5502 expect(expression, new isInstanceOf<BinaryExpression>()); |
| 5535 BinaryExpression binaryExpression = expression; | 5503 BinaryExpression binaryExpression = expression; |
| 5536 expect(binaryExpression.leftOperand, new isInstanceOf<SuperExpression>()); | 5504 expect(binaryExpression.leftOperand, new isInstanceOf<SuperExpression>()); |
| 5537 expect(binaryExpression.operator, isNotNull); | 5505 expect(binaryExpression.operator, isNotNull); |
| 5538 expect(binaryExpression.operator.type, TokenType.STAR); | 5506 expect(binaryExpression.operator.type, TokenType.STAR); |
| 5539 expect(binaryExpression.rightOperand, isNotNull); | 5507 expect(binaryExpression.rightOperand, isNotNull); |
| 5540 } | 5508 } |
| 5541 | 5509 |
| 5542 void test_parseNewExpression() { | 5510 void test_parseNewExpression() { |
| 5543 createParser('new A()'); | 5511 InstanceCreationExpression expression = parseNewExpression('new A()'); |
| 5544 InstanceCreationExpression expression = parser.parseNewExpression(); | |
| 5545 expect(expression, isNotNull); | 5512 expect(expression, isNotNull); |
| 5546 assertNoErrors(); | 5513 assertNoErrors(); |
| 5547 expect(expression.keyword, isNotNull); | 5514 expect(expression.keyword, isNotNull); |
| 5548 ConstructorName name = expression.constructorName; | 5515 ConstructorName name = expression.constructorName; |
| 5549 expect(name, isNotNull); | 5516 expect(name, isNotNull); |
| 5550 expect(name.type, isNotNull); | 5517 expect(name.type, isNotNull); |
| 5551 expect(name.period, isNull); | 5518 expect(name.period, isNull); |
| 5552 expect(name.name, isNull); | 5519 expect(name.name, isNull); |
| 5553 expect(expression.argumentList, isNotNull); | 5520 expect(expression.argumentList, isNotNull); |
| 5554 } | 5521 } |
| 5555 | 5522 |
| 5556 void test_parsePostfixExpression_decrement() { | 5523 void test_parsePostfixExpression_decrement() { |
| 5557 createParser('i--'); | 5524 Expression expression = parsePostfixExpression('i--'); |
| 5558 Expression expression = parser.parsePostfixExpression(); | |
| 5559 expect(expression, isNotNull); | 5525 expect(expression, isNotNull); |
| 5560 assertNoErrors(); | 5526 assertNoErrors(); |
| 5561 expect(expression, new isInstanceOf<PostfixExpression>()); | 5527 expect(expression, new isInstanceOf<PostfixExpression>()); |
| 5562 PostfixExpression postfixExpression = expression; | 5528 PostfixExpression postfixExpression = expression; |
| 5563 expect(postfixExpression.operand, isNotNull); | 5529 expect(postfixExpression.operand, isNotNull); |
| 5564 expect(postfixExpression.operator, isNotNull); | 5530 expect(postfixExpression.operator, isNotNull); |
| 5565 expect(postfixExpression.operator.type, TokenType.MINUS_MINUS); | 5531 expect(postfixExpression.operator.type, TokenType.MINUS_MINUS); |
| 5566 } | 5532 } |
| 5567 | 5533 |
| 5568 void test_parsePostfixExpression_increment() { | 5534 void test_parsePostfixExpression_increment() { |
| 5569 createParser('i++'); | 5535 Expression expression = parsePostfixExpression('i++'); |
| 5570 Expression expression = parser.parsePostfixExpression(); | |
| 5571 expect(expression, isNotNull); | 5536 expect(expression, isNotNull); |
| 5572 assertNoErrors(); | 5537 assertNoErrors(); |
| 5573 expect(expression, new isInstanceOf<PostfixExpression>()); | 5538 expect(expression, new isInstanceOf<PostfixExpression>()); |
| 5574 PostfixExpression postfixExpression = expression; | 5539 PostfixExpression postfixExpression = expression; |
| 5575 expect(postfixExpression.operand, isNotNull); | 5540 expect(postfixExpression.operand, isNotNull); |
| 5576 expect(postfixExpression.operator, isNotNull); | 5541 expect(postfixExpression.operator, isNotNull); |
| 5577 expect(postfixExpression.operator.type, TokenType.PLUS_PLUS); | 5542 expect(postfixExpression.operator.type, TokenType.PLUS_PLUS); |
| 5578 } | 5543 } |
| 5579 | 5544 |
| 5580 void test_parsePostfixExpression_none_indexExpression() { | 5545 void test_parsePostfixExpression_none_indexExpression() { |
| 5581 createParser('a[0]'); | 5546 Expression expression = parsePostfixExpression('a[0]'); |
| 5582 Expression expression = parser.parsePostfixExpression(); | |
| 5583 expect(expression, isNotNull); | 5547 expect(expression, isNotNull); |
| 5584 assertNoErrors(); | 5548 assertNoErrors(); |
| 5585 expect(expression, new isInstanceOf<IndexExpression>()); | 5549 expect(expression, new isInstanceOf<IndexExpression>()); |
| 5586 IndexExpression indexExpression = expression; | 5550 IndexExpression indexExpression = expression; |
| 5587 expect(indexExpression.target, isNotNull); | 5551 expect(indexExpression.target, isNotNull); |
| 5588 expect(indexExpression.index, isNotNull); | 5552 expect(indexExpression.index, isNotNull); |
| 5589 } | 5553 } |
| 5590 | 5554 |
| 5591 void test_parsePostfixExpression_none_methodInvocation() { | 5555 void test_parsePostfixExpression_none_methodInvocation() { |
| 5592 createParser('a.m()'); | 5556 Expression expression = parsePostfixExpression('a.m()'); |
| 5593 Expression expression = parser.parsePostfixExpression(); | |
| 5594 expect(expression, isNotNull); | 5557 expect(expression, isNotNull); |
| 5595 assertNoErrors(); | 5558 assertNoErrors(); |
| 5596 expect(expression, new isInstanceOf<MethodInvocation>()); | 5559 expect(expression, new isInstanceOf<MethodInvocation>()); |
| 5597 MethodInvocation methodInvocation = expression; | 5560 MethodInvocation methodInvocation = expression; |
| 5598 expect(methodInvocation.target, isNotNull); | 5561 expect(methodInvocation.target, isNotNull); |
| 5599 expect(methodInvocation.operator.type, TokenType.PERIOD); | 5562 expect(methodInvocation.operator.type, TokenType.PERIOD); |
| 5600 expect(methodInvocation.methodName, isNotNull); | 5563 expect(methodInvocation.methodName, isNotNull); |
| 5601 expect(methodInvocation.typeArguments, isNull); | 5564 expect(methodInvocation.typeArguments, isNull); |
| 5602 expect(methodInvocation.argumentList, isNotNull); | 5565 expect(methodInvocation.argumentList, isNotNull); |
| 5603 } | 5566 } |
| 5604 | 5567 |
| 5605 void test_parsePostfixExpression_none_methodInvocation_question_dot() { | 5568 void test_parsePostfixExpression_none_methodInvocation_question_dot() { |
| 5606 createParser('a?.m()'); | 5569 Expression expression = parsePostfixExpression('a?.m()'); |
| 5607 Expression expression = parser.parsePostfixExpression(); | |
| 5608 expect(expression, isNotNull); | 5570 expect(expression, isNotNull); |
| 5609 assertNoErrors(); | 5571 assertNoErrors(); |
| 5610 expect(expression, new isInstanceOf<MethodInvocation>()); | 5572 expect(expression, new isInstanceOf<MethodInvocation>()); |
| 5611 MethodInvocation methodInvocation = expression; | 5573 MethodInvocation methodInvocation = expression; |
| 5612 expect(methodInvocation.target, isNotNull); | 5574 expect(methodInvocation.target, isNotNull); |
| 5613 expect(methodInvocation.operator.type, TokenType.QUESTION_PERIOD); | 5575 expect(methodInvocation.operator.type, TokenType.QUESTION_PERIOD); |
| 5614 expect(methodInvocation.methodName, isNotNull); | 5576 expect(methodInvocation.methodName, isNotNull); |
| 5615 expect(methodInvocation.typeArguments, isNull); | 5577 expect(methodInvocation.typeArguments, isNull); |
| 5616 expect(methodInvocation.argumentList, isNotNull); | 5578 expect(methodInvocation.argumentList, isNotNull); |
| 5617 } | 5579 } |
| 5618 | 5580 |
| 5619 void | 5581 void |
| 5620 test_parsePostfixExpression_none_methodInvocation_question_dot_typeArgumen
tComments() { | 5582 test_parsePostfixExpression_none_methodInvocation_question_dot_typeArgumen
tComments() { |
| 5621 enableGenericMethodComments = true; | 5583 enableGenericMethodComments = true; |
| 5622 createParser('a?.m/*<E>*/()'); | 5584 Expression expression = parsePostfixExpression('a?.m/*<E>*/()'); |
| 5623 Expression expression = parser.parsePostfixExpression(); | |
| 5624 expect(expression, isNotNull); | 5585 expect(expression, isNotNull); |
| 5625 assertNoErrors(); | 5586 assertNoErrors(); |
| 5626 expect(expression, new isInstanceOf<MethodInvocation>()); | 5587 expect(expression, new isInstanceOf<MethodInvocation>()); |
| 5627 MethodInvocation methodInvocation = expression; | 5588 MethodInvocation methodInvocation = expression; |
| 5628 expect(methodInvocation.target, isNotNull); | 5589 expect(methodInvocation.target, isNotNull); |
| 5629 expect(methodInvocation.operator.type, TokenType.QUESTION_PERIOD); | 5590 expect(methodInvocation.operator.type, TokenType.QUESTION_PERIOD); |
| 5630 expect(methodInvocation.methodName, isNotNull); | 5591 expect(methodInvocation.methodName, isNotNull); |
| 5631 expect(methodInvocation.typeArguments, isNotNull); | 5592 expect(methodInvocation.typeArguments, isNotNull); |
| 5632 expect(methodInvocation.argumentList, isNotNull); | 5593 expect(methodInvocation.argumentList, isNotNull); |
| 5633 } | 5594 } |
| 5634 | 5595 |
| 5635 void | 5596 void |
| 5636 test_parsePostfixExpression_none_methodInvocation_question_dot_typeArgumen
ts() { | 5597 test_parsePostfixExpression_none_methodInvocation_question_dot_typeArgumen
ts() { |
| 5637 createParser('a?.m<E>()'); | 5598 Expression expression = parsePostfixExpression('a?.m<E>()'); |
| 5638 Expression expression = parser.parsePostfixExpression(); | |
| 5639 expect(expression, isNotNull); | 5599 expect(expression, isNotNull); |
| 5640 assertNoErrors(); | 5600 assertNoErrors(); |
| 5641 expect(expression, new isInstanceOf<MethodInvocation>()); | 5601 expect(expression, new isInstanceOf<MethodInvocation>()); |
| 5642 MethodInvocation methodInvocation = expression; | 5602 MethodInvocation methodInvocation = expression; |
| 5643 expect(methodInvocation.target, isNotNull); | 5603 expect(methodInvocation.target, isNotNull); |
| 5644 expect(methodInvocation.operator.type, TokenType.QUESTION_PERIOD); | 5604 expect(methodInvocation.operator.type, TokenType.QUESTION_PERIOD); |
| 5645 expect(methodInvocation.methodName, isNotNull); | 5605 expect(methodInvocation.methodName, isNotNull); |
| 5646 expect(methodInvocation.typeArguments, isNotNull); | 5606 expect(methodInvocation.typeArguments, isNotNull); |
| 5647 expect(methodInvocation.argumentList, isNotNull); | 5607 expect(methodInvocation.argumentList, isNotNull); |
| 5648 } | 5608 } |
| 5649 | 5609 |
| 5650 void | 5610 void |
| 5651 test_parsePostfixExpression_none_methodInvocation_typeArgumentComments() { | 5611 test_parsePostfixExpression_none_methodInvocation_typeArgumentComments() { |
| 5652 enableGenericMethodComments = true; | 5612 enableGenericMethodComments = true; |
| 5653 createParser('a.m/*<E>*/()'); | 5613 Expression expression = parsePostfixExpression('a.m/*<E>*/()'); |
| 5654 Expression expression = parser.parsePostfixExpression(); | |
| 5655 expect(expression, isNotNull); | 5614 expect(expression, isNotNull); |
| 5656 assertNoErrors(); | 5615 assertNoErrors(); |
| 5657 expect(expression, new isInstanceOf<MethodInvocation>()); | 5616 expect(expression, new isInstanceOf<MethodInvocation>()); |
| 5658 MethodInvocation methodInvocation = expression; | 5617 MethodInvocation methodInvocation = expression; |
| 5659 expect(methodInvocation.target, isNotNull); | 5618 expect(methodInvocation.target, isNotNull); |
| 5660 expect(methodInvocation.operator.type, TokenType.PERIOD); | 5619 expect(methodInvocation.operator.type, TokenType.PERIOD); |
| 5661 expect(methodInvocation.methodName, isNotNull); | 5620 expect(methodInvocation.methodName, isNotNull); |
| 5662 expect(methodInvocation.typeArguments, isNotNull); | 5621 expect(methodInvocation.typeArguments, isNotNull); |
| 5663 expect(methodInvocation.argumentList, isNotNull); | 5622 expect(methodInvocation.argumentList, isNotNull); |
| 5664 } | 5623 } |
| 5665 | 5624 |
| 5666 void test_parsePostfixExpression_none_methodInvocation_typeArguments() { | 5625 void test_parsePostfixExpression_none_methodInvocation_typeArguments() { |
| 5667 createParser('a.m<E>()'); | 5626 Expression expression = parsePostfixExpression('a.m<E>()'); |
| 5668 Expression expression = parser.parsePostfixExpression(); | |
| 5669 expect(expression, isNotNull); | 5627 expect(expression, isNotNull); |
| 5670 assertNoErrors(); | 5628 assertNoErrors(); |
| 5671 expect(expression, new isInstanceOf<MethodInvocation>()); | 5629 expect(expression, new isInstanceOf<MethodInvocation>()); |
| 5672 MethodInvocation methodInvocation = expression; | 5630 MethodInvocation methodInvocation = expression; |
| 5673 expect(methodInvocation.target, isNotNull); | 5631 expect(methodInvocation.target, isNotNull); |
| 5674 expect(methodInvocation.operator.type, TokenType.PERIOD); | 5632 expect(methodInvocation.operator.type, TokenType.PERIOD); |
| 5675 expect(methodInvocation.methodName, isNotNull); | 5633 expect(methodInvocation.methodName, isNotNull); |
| 5676 expect(methodInvocation.typeArguments, isNotNull); | 5634 expect(methodInvocation.typeArguments, isNotNull); |
| 5677 expect(methodInvocation.argumentList, isNotNull); | 5635 expect(methodInvocation.argumentList, isNotNull); |
| 5678 } | 5636 } |
| 5679 | 5637 |
| 5680 void test_parsePostfixExpression_none_propertyAccess() { | 5638 void test_parsePostfixExpression_none_propertyAccess() { |
| 5681 createParser('a.b'); | 5639 Expression expression = parsePostfixExpression('a.b'); |
| 5682 Expression expression = parser.parsePostfixExpression(); | |
| 5683 expect(expression, isNotNull); | 5640 expect(expression, isNotNull); |
| 5684 assertNoErrors(); | 5641 assertNoErrors(); |
| 5685 expect(expression, new isInstanceOf<PrefixedIdentifier>()); | 5642 expect(expression, new isInstanceOf<PrefixedIdentifier>()); |
| 5686 PrefixedIdentifier identifier = expression; | 5643 PrefixedIdentifier identifier = expression; |
| 5687 expect(identifier.prefix, isNotNull); | 5644 expect(identifier.prefix, isNotNull); |
| 5688 expect(identifier.identifier, isNotNull); | 5645 expect(identifier.identifier, isNotNull); |
| 5689 } | 5646 } |
| 5690 | 5647 |
| 5691 void test_parsePrefixedIdentifier_noPrefix() { | 5648 void test_parsePrefixedIdentifier_noPrefix() { |
| 5692 String lexeme = "bar"; | 5649 String lexeme = "bar"; |
| 5693 createParser(lexeme); | 5650 Identifier identifier = parsePrefixedIdentifier(lexeme); |
| 5694 Identifier identifier = parser.parsePrefixedIdentifier(); | |
| 5695 expect(identifier, isNotNull); | 5651 expect(identifier, isNotNull); |
| 5696 assertNoErrors(); | 5652 assertNoErrors(); |
| 5697 expect(identifier, new isInstanceOf<SimpleIdentifier>()); | 5653 expect(identifier, new isInstanceOf<SimpleIdentifier>()); |
| 5698 SimpleIdentifier simpleIdentifier = identifier; | 5654 SimpleIdentifier simpleIdentifier = identifier; |
| 5699 expect(simpleIdentifier.token, isNotNull); | 5655 expect(simpleIdentifier.token, isNotNull); |
| 5700 expect(simpleIdentifier.name, lexeme); | 5656 expect(simpleIdentifier.name, lexeme); |
| 5701 } | 5657 } |
| 5702 | 5658 |
| 5703 void test_parsePrefixedIdentifier_prefix() { | 5659 void test_parsePrefixedIdentifier_prefix() { |
| 5704 String lexeme = "foo.bar"; | 5660 String lexeme = "foo.bar"; |
| 5705 createParser(lexeme); | 5661 Identifier identifier = parsePrefixedIdentifier(lexeme); |
| 5706 Identifier identifier = parser.parsePrefixedIdentifier(); | |
| 5707 expect(identifier, isNotNull); | 5662 expect(identifier, isNotNull); |
| 5708 assertNoErrors(); | 5663 assertNoErrors(); |
| 5709 expect(identifier, new isInstanceOf<PrefixedIdentifier>()); | 5664 expect(identifier, new isInstanceOf<PrefixedIdentifier>()); |
| 5710 PrefixedIdentifier prefixedIdentifier = identifier; | 5665 PrefixedIdentifier prefixedIdentifier = identifier; |
| 5711 expect(prefixedIdentifier.prefix.name, "foo"); | 5666 expect(prefixedIdentifier.prefix.name, "foo"); |
| 5712 expect(prefixedIdentifier.period, isNotNull); | 5667 expect(prefixedIdentifier.period, isNotNull); |
| 5713 expect(prefixedIdentifier.identifier.name, "bar"); | 5668 expect(prefixedIdentifier.identifier.name, "bar"); |
| 5714 } | 5669 } |
| 5715 | 5670 |
| 5716 void test_parsePrimaryExpression_const() { | 5671 void test_parsePrimaryExpression_const() { |
| 5717 createParser('const A()'); | 5672 Expression expression = parsePrimaryExpression('const A()'); |
| 5718 Expression expression = parser.parsePrimaryExpression(); | |
| 5719 expect(expression, isNotNull); | 5673 expect(expression, isNotNull); |
| 5720 assertNoErrors(); | 5674 assertNoErrors(); |
| 5721 expect(expression, isNotNull); | 5675 expect(expression, isNotNull); |
| 5722 } | 5676 } |
| 5723 | 5677 |
| 5724 void test_parsePrimaryExpression_double() { | 5678 void test_parsePrimaryExpression_double() { |
| 5725 String doubleLiteral = "3.2e4"; | 5679 String doubleLiteral = "3.2e4"; |
| 5726 createParser(doubleLiteral); | 5680 Expression expression = parsePrimaryExpression(doubleLiteral); |
| 5727 Expression expression = parser.parsePrimaryExpression(); | |
| 5728 expect(expression, isNotNull); | 5681 expect(expression, isNotNull); |
| 5729 assertNoErrors(); | 5682 assertNoErrors(); |
| 5730 expect(expression, new isInstanceOf<DoubleLiteral>()); | 5683 expect(expression, new isInstanceOf<DoubleLiteral>()); |
| 5731 DoubleLiteral literal = expression; | 5684 DoubleLiteral literal = expression; |
| 5732 expect(literal.literal, isNotNull); | 5685 expect(literal.literal, isNotNull); |
| 5733 expect(literal.value, double.parse(doubleLiteral)); | 5686 expect(literal.value, double.parse(doubleLiteral)); |
| 5734 } | 5687 } |
| 5735 | 5688 |
| 5736 void test_parsePrimaryExpression_false() { | 5689 void test_parsePrimaryExpression_false() { |
| 5737 createParser('false'); | 5690 Expression expression = parsePrimaryExpression('false'); |
| 5738 Expression expression = parser.parsePrimaryExpression(); | |
| 5739 expect(expression, isNotNull); | 5691 expect(expression, isNotNull); |
| 5740 assertNoErrors(); | 5692 assertNoErrors(); |
| 5741 expect(expression, new isInstanceOf<BooleanLiteral>()); | 5693 expect(expression, new isInstanceOf<BooleanLiteral>()); |
| 5742 BooleanLiteral literal = expression; | 5694 BooleanLiteral literal = expression; |
| 5743 expect(literal.literal, isNotNull); | 5695 expect(literal.literal, isNotNull); |
| 5744 expect(literal.value, isFalse); | 5696 expect(literal.value, isFalse); |
| 5745 } | 5697 } |
| 5746 | 5698 |
| 5747 void test_parsePrimaryExpression_function_arguments() { | 5699 void test_parsePrimaryExpression_function_arguments() { |
| 5748 createParser('(int i) => i + 1'); | 5700 Expression expression = parsePrimaryExpression('(int i) => i + 1'); |
| 5749 Expression expression = parser.parsePrimaryExpression(); | |
| 5750 expect(expression, isNotNull); | 5701 expect(expression, isNotNull); |
| 5751 assertNoErrors(); | 5702 assertNoErrors(); |
| 5752 expect(expression, new isInstanceOf<FunctionExpression>()); | 5703 expect(expression, new isInstanceOf<FunctionExpression>()); |
| 5753 FunctionExpression functionExpression = expression; | 5704 FunctionExpression functionExpression = expression; |
| 5754 expect(functionExpression.parameters, isNotNull); | 5705 expect(functionExpression.parameters, isNotNull); |
| 5755 expect(functionExpression.body, isNotNull); | 5706 expect(functionExpression.body, isNotNull); |
| 5756 } | 5707 } |
| 5757 | 5708 |
| 5758 void test_parsePrimaryExpression_function_noArguments() { | 5709 void test_parsePrimaryExpression_function_noArguments() { |
| 5759 createParser('() => 42'); | 5710 Expression expression = parsePrimaryExpression('() => 42'); |
| 5760 Expression expression = parser.parsePrimaryExpression(); | |
| 5761 expect(expression, isNotNull); | 5711 expect(expression, isNotNull); |
| 5762 assertNoErrors(); | 5712 assertNoErrors(); |
| 5763 expect(expression, new isInstanceOf<FunctionExpression>()); | 5713 expect(expression, new isInstanceOf<FunctionExpression>()); |
| 5764 FunctionExpression functionExpression = expression; | 5714 FunctionExpression functionExpression = expression; |
| 5765 expect(functionExpression.parameters, isNotNull); | 5715 expect(functionExpression.parameters, isNotNull); |
| 5766 expect(functionExpression.body, isNotNull); | 5716 expect(functionExpression.body, isNotNull); |
| 5767 } | 5717 } |
| 5768 | 5718 |
| 5769 void test_parsePrimaryExpression_genericFunctionExpression() { | 5719 void test_parsePrimaryExpression_genericFunctionExpression() { |
| 5770 createParser('<X, Y>(Map<X, Y> m, X x) => m[x]'); | 5720 Expression expression = |
| 5771 Expression expression = parser.parsePrimaryExpression(); | 5721 parsePrimaryExpression('<X, Y>(Map<X, Y> m, X x) => m[x]'); |
| 5772 expect(expression, isNotNull); | 5722 expect(expression, isNotNull); |
| 5773 assertNoErrors(); | 5723 assertNoErrors(); |
| 5774 expect(expression, new isInstanceOf<FunctionExpression>()); | 5724 expect(expression, new isInstanceOf<FunctionExpression>()); |
| 5775 FunctionExpression function = expression; | 5725 FunctionExpression function = expression; |
| 5776 expect(function.typeParameters, isNotNull); | 5726 expect(function.typeParameters, isNotNull); |
| 5777 } | 5727 } |
| 5778 | 5728 |
| 5779 void test_parsePrimaryExpression_hex() { | 5729 void test_parsePrimaryExpression_hex() { |
| 5780 String hexLiteral = "3F"; | 5730 String hexLiteral = "3F"; |
| 5781 createParser('0x$hexLiteral'); | 5731 Expression expression = parsePrimaryExpression('0x$hexLiteral'); |
| 5782 Expression expression = parser.parsePrimaryExpression(); | |
| 5783 expect(expression, isNotNull); | 5732 expect(expression, isNotNull); |
| 5784 assertNoErrors(); | 5733 assertNoErrors(); |
| 5785 expect(expression, new isInstanceOf<IntegerLiteral>()); | 5734 expect(expression, new isInstanceOf<IntegerLiteral>()); |
| 5786 IntegerLiteral literal = expression; | 5735 IntegerLiteral literal = expression; |
| 5787 expect(literal.literal, isNotNull); | 5736 expect(literal.literal, isNotNull); |
| 5788 expect(literal.value, int.parse(hexLiteral, radix: 16)); | 5737 expect(literal.value, int.parse(hexLiteral, radix: 16)); |
| 5789 } | 5738 } |
| 5790 | 5739 |
| 5791 void test_parsePrimaryExpression_identifier() { | 5740 void test_parsePrimaryExpression_identifier() { |
| 5792 createParser('a'); | 5741 Expression expression = parsePrimaryExpression('a'); |
| 5793 Expression expression = parser.parsePrimaryExpression(); | |
| 5794 expect(expression, isNotNull); | 5742 expect(expression, isNotNull); |
| 5795 assertNoErrors(); | 5743 assertNoErrors(); |
| 5796 expect(expression, new isInstanceOf<SimpleIdentifier>()); | 5744 expect(expression, new isInstanceOf<SimpleIdentifier>()); |
| 5797 SimpleIdentifier identifier = expression; | 5745 SimpleIdentifier identifier = expression; |
| 5798 expect(identifier, isNotNull); | 5746 expect(identifier, isNotNull); |
| 5799 } | 5747 } |
| 5800 | 5748 |
| 5801 void test_parsePrimaryExpression_int() { | 5749 void test_parsePrimaryExpression_int() { |
| 5802 String intLiteral = "472"; | 5750 String intLiteral = "472"; |
| 5803 createParser(intLiteral); | 5751 Expression expression = parsePrimaryExpression(intLiteral); |
| 5804 Expression expression = parser.parsePrimaryExpression(); | |
| 5805 expect(expression, isNotNull); | 5752 expect(expression, isNotNull); |
| 5806 assertNoErrors(); | 5753 assertNoErrors(); |
| 5807 expect(expression, new isInstanceOf<IntegerLiteral>()); | 5754 expect(expression, new isInstanceOf<IntegerLiteral>()); |
| 5808 IntegerLiteral literal = expression; | 5755 IntegerLiteral literal = expression; |
| 5809 expect(literal.literal, isNotNull); | 5756 expect(literal.literal, isNotNull); |
| 5810 expect(literal.value, int.parse(intLiteral)); | 5757 expect(literal.value, int.parse(intLiteral)); |
| 5811 } | 5758 } |
| 5812 | 5759 |
| 5813 void test_parsePrimaryExpression_listLiteral() { | 5760 void test_parsePrimaryExpression_listLiteral() { |
| 5814 createParser('[ ]'); | 5761 Expression expression = parsePrimaryExpression('[ ]'); |
| 5815 Expression expression = parser.parsePrimaryExpression(); | |
| 5816 expect(expression, isNotNull); | 5762 expect(expression, isNotNull); |
| 5817 assertNoErrors(); | 5763 assertNoErrors(); |
| 5818 expect(expression, new isInstanceOf<ListLiteral>()); | 5764 expect(expression, new isInstanceOf<ListLiteral>()); |
| 5819 ListLiteral literal = expression; | 5765 ListLiteral literal = expression; |
| 5820 expect(literal, isNotNull); | 5766 expect(literal, isNotNull); |
| 5821 } | 5767 } |
| 5822 | 5768 |
| 5823 void test_parsePrimaryExpression_listLiteral_index() { | 5769 void test_parsePrimaryExpression_listLiteral_index() { |
| 5824 createParser('[]'); | 5770 Expression expression = parsePrimaryExpression('[]'); |
| 5825 Expression expression = parser.parsePrimaryExpression(); | |
| 5826 expect(expression, isNotNull); | 5771 expect(expression, isNotNull); |
| 5827 assertNoErrors(); | 5772 assertNoErrors(); |
| 5828 expect(expression, new isInstanceOf<ListLiteral>()); | 5773 expect(expression, new isInstanceOf<ListLiteral>()); |
| 5829 ListLiteral literal = expression; | 5774 ListLiteral literal = expression; |
| 5830 expect(literal, isNotNull); | 5775 expect(literal, isNotNull); |
| 5831 } | 5776 } |
| 5832 | 5777 |
| 5833 void test_parsePrimaryExpression_listLiteral_typed() { | 5778 void test_parsePrimaryExpression_listLiteral_typed() { |
| 5834 createParser('<A>[ ]'); | 5779 Expression expression = parsePrimaryExpression('<A>[ ]'); |
| 5835 Expression expression = parser.parsePrimaryExpression(); | |
| 5836 expect(expression, isNotNull); | 5780 expect(expression, isNotNull); |
| 5837 assertNoErrors(); | 5781 assertNoErrors(); |
| 5838 expect(expression, new isInstanceOf<ListLiteral>()); | 5782 expect(expression, new isInstanceOf<ListLiteral>()); |
| 5839 ListLiteral literal = expression; | 5783 ListLiteral literal = expression; |
| 5840 expect(literal.typeArguments, isNotNull); | 5784 expect(literal.typeArguments, isNotNull); |
| 5841 expect(literal.typeArguments.arguments, hasLength(1)); | 5785 expect(literal.typeArguments.arguments, hasLength(1)); |
| 5842 } | 5786 } |
| 5843 | 5787 |
| 5844 void test_parsePrimaryExpression_listLiteral_typed_genericComment() { | 5788 void test_parsePrimaryExpression_listLiteral_typed_genericComment() { |
| 5845 enableGenericMethodComments = true; | 5789 enableGenericMethodComments = true; |
| 5846 createParser('/*<A>*/[ ]'); | 5790 Expression expression = parsePrimaryExpression('/*<A>*/[ ]'); |
| 5847 Expression expression = parser.parsePrimaryExpression(); | |
| 5848 expect(expression, isNotNull); | 5791 expect(expression, isNotNull); |
| 5849 assertNoErrors(); | 5792 assertNoErrors(); |
| 5850 expect(expression, new isInstanceOf<ListLiteral>()); | 5793 expect(expression, new isInstanceOf<ListLiteral>()); |
| 5851 ListLiteral literal = expression; | 5794 ListLiteral literal = expression; |
| 5852 expect(literal.typeArguments, isNotNull); | 5795 expect(literal.typeArguments, isNotNull); |
| 5853 expect(literal.typeArguments.arguments, hasLength(1)); | 5796 expect(literal.typeArguments.arguments, hasLength(1)); |
| 5854 } | 5797 } |
| 5855 | 5798 |
| 5856 void test_parsePrimaryExpression_mapLiteral() { | 5799 void test_parsePrimaryExpression_mapLiteral() { |
| 5857 createParser('{}'); | 5800 Expression expression = parsePrimaryExpression('{}'); |
| 5858 Expression expression = parser.parsePrimaryExpression(); | |
| 5859 expect(expression, isNotNull); | 5801 expect(expression, isNotNull); |
| 5860 assertNoErrors(); | 5802 assertNoErrors(); |
| 5861 expect(expression, new isInstanceOf<MapLiteral>()); | 5803 expect(expression, new isInstanceOf<MapLiteral>()); |
| 5862 MapLiteral literal = expression; | 5804 MapLiteral literal = expression; |
| 5863 expect(literal.typeArguments, isNull); | 5805 expect(literal.typeArguments, isNull); |
| 5864 expect(literal, isNotNull); | 5806 expect(literal, isNotNull); |
| 5865 } | 5807 } |
| 5866 | 5808 |
| 5867 void test_parsePrimaryExpression_mapLiteral_typed() { | 5809 void test_parsePrimaryExpression_mapLiteral_typed() { |
| 5868 createParser('<A, B>{}'); | 5810 Expression expression = parsePrimaryExpression('<A, B>{}'); |
| 5869 Expression expression = parser.parsePrimaryExpression(); | |
| 5870 expect(expression, isNotNull); | 5811 expect(expression, isNotNull); |
| 5871 assertNoErrors(); | 5812 assertNoErrors(); |
| 5872 expect(expression, new isInstanceOf<MapLiteral>()); | 5813 expect(expression, new isInstanceOf<MapLiteral>()); |
| 5873 MapLiteral literal = expression; | 5814 MapLiteral literal = expression; |
| 5874 expect(literal.typeArguments, isNotNull); | 5815 expect(literal.typeArguments, isNotNull); |
| 5875 expect(literal.typeArguments.arguments, hasLength(2)); | 5816 expect(literal.typeArguments.arguments, hasLength(2)); |
| 5876 } | 5817 } |
| 5877 | 5818 |
| 5878 void test_parsePrimaryExpression_mapLiteral_typed_genericComment() { | 5819 void test_parsePrimaryExpression_mapLiteral_typed_genericComment() { |
| 5879 enableGenericMethodComments = true; | 5820 enableGenericMethodComments = true; |
| 5880 createParser('/*<A, B>*/{}'); | 5821 Expression expression = parsePrimaryExpression('/*<A, B>*/{}'); |
| 5881 Expression expression = parser.parsePrimaryExpression(); | |
| 5882 expect(expression, isNotNull); | 5822 expect(expression, isNotNull); |
| 5883 assertNoErrors(); | 5823 assertNoErrors(); |
| 5884 expect(expression, new isInstanceOf<MapLiteral>()); | 5824 expect(expression, new isInstanceOf<MapLiteral>()); |
| 5885 MapLiteral literal = expression; | 5825 MapLiteral literal = expression; |
| 5886 expect(literal.typeArguments, isNotNull); | 5826 expect(literal.typeArguments, isNotNull); |
| 5887 expect(literal.typeArguments.arguments, hasLength(2)); | 5827 expect(literal.typeArguments.arguments, hasLength(2)); |
| 5888 } | 5828 } |
| 5889 | 5829 |
| 5890 void test_parsePrimaryExpression_new() { | 5830 void test_parsePrimaryExpression_new() { |
| 5891 createParser('new A()'); | 5831 Expression expression = parsePrimaryExpression('new A()'); |
| 5892 Expression expression = parser.parsePrimaryExpression(); | |
| 5893 expect(expression, isNotNull); | 5832 expect(expression, isNotNull); |
| 5894 assertNoErrors(); | 5833 assertNoErrors(); |
| 5895 expect(expression, new isInstanceOf<InstanceCreationExpression>()); | 5834 expect(expression, new isInstanceOf<InstanceCreationExpression>()); |
| 5896 InstanceCreationExpression creation = expression; | 5835 InstanceCreationExpression creation = expression; |
| 5897 expect(creation, isNotNull); | 5836 expect(creation, isNotNull); |
| 5898 } | 5837 } |
| 5899 | 5838 |
| 5900 void test_parsePrimaryExpression_null() { | 5839 void test_parsePrimaryExpression_null() { |
| 5901 createParser('null'); | 5840 Expression expression = parsePrimaryExpression('null'); |
| 5902 Expression expression = parser.parsePrimaryExpression(); | |
| 5903 expect(expression, isNotNull); | 5841 expect(expression, isNotNull); |
| 5904 assertNoErrors(); | 5842 assertNoErrors(); |
| 5905 expect(expression, new isInstanceOf<NullLiteral>()); | 5843 expect(expression, new isInstanceOf<NullLiteral>()); |
| 5906 NullLiteral literal = expression; | 5844 NullLiteral literal = expression; |
| 5907 expect(literal.literal, isNotNull); | 5845 expect(literal.literal, isNotNull); |
| 5908 } | 5846 } |
| 5909 | 5847 |
| 5910 void test_parsePrimaryExpression_parenthesized() { | 5848 void test_parsePrimaryExpression_parenthesized() { |
| 5911 createParser('(x)'); | 5849 Expression expression = parsePrimaryExpression('(x)'); |
| 5912 Expression expression = parser.parsePrimaryExpression(); | |
| 5913 expect(expression, isNotNull); | 5850 expect(expression, isNotNull); |
| 5914 assertNoErrors(); | 5851 assertNoErrors(); |
| 5915 expect(expression, new isInstanceOf<ParenthesizedExpression>()); | 5852 expect(expression, new isInstanceOf<ParenthesizedExpression>()); |
| 5916 ParenthesizedExpression parens = expression; | 5853 ParenthesizedExpression parens = expression; |
| 5917 expect(parens, isNotNull); | 5854 expect(parens, isNotNull); |
| 5918 } | 5855 } |
| 5919 | 5856 |
| 5920 void test_parsePrimaryExpression_string() { | 5857 void test_parsePrimaryExpression_string() { |
| 5921 createParser('"string"'); | 5858 Expression expression = parsePrimaryExpression('"string"'); |
| 5922 Expression expression = parser.parsePrimaryExpression(); | |
| 5923 expect(expression, isNotNull); | 5859 expect(expression, isNotNull); |
| 5924 assertNoErrors(); | 5860 assertNoErrors(); |
| 5925 expect(expression, new isInstanceOf<SimpleStringLiteral>()); | 5861 expect(expression, new isInstanceOf<SimpleStringLiteral>()); |
| 5926 SimpleStringLiteral literal = expression; | 5862 SimpleStringLiteral literal = expression; |
| 5927 expect(literal.isMultiline, isFalse); | 5863 expect(literal.isMultiline, isFalse); |
| 5928 expect(literal.isRaw, isFalse); | 5864 expect(literal.isRaw, isFalse); |
| 5929 expect(literal.value, "string"); | 5865 expect(literal.value, "string"); |
| 5930 } | 5866 } |
| 5931 | 5867 |
| 5932 void test_parsePrimaryExpression_string_multiline() { | 5868 void test_parsePrimaryExpression_string_multiline() { |
| 5933 createParser("'''string'''"); | 5869 Expression expression = parsePrimaryExpression("'''string'''"); |
| 5934 Expression expression = parser.parsePrimaryExpression(); | |
| 5935 expect(expression, isNotNull); | 5870 expect(expression, isNotNull); |
| 5936 assertNoErrors(); | 5871 assertNoErrors(); |
| 5937 expect(expression, new isInstanceOf<SimpleStringLiteral>()); | 5872 expect(expression, new isInstanceOf<SimpleStringLiteral>()); |
| 5938 SimpleStringLiteral literal = expression; | 5873 SimpleStringLiteral literal = expression; |
| 5939 expect(literal.isMultiline, isTrue); | 5874 expect(literal.isMultiline, isTrue); |
| 5940 expect(literal.isRaw, isFalse); | 5875 expect(literal.isRaw, isFalse); |
| 5941 expect(literal.value, "string"); | 5876 expect(literal.value, "string"); |
| 5942 } | 5877 } |
| 5943 | 5878 |
| 5944 void test_parsePrimaryExpression_string_raw() { | 5879 void test_parsePrimaryExpression_string_raw() { |
| 5945 createParser("r'string'"); | 5880 Expression expression = parsePrimaryExpression("r'string'"); |
| 5946 Expression expression = parser.parsePrimaryExpression(); | |
| 5947 expect(expression, isNotNull); | 5881 expect(expression, isNotNull); |
| 5948 assertNoErrors(); | 5882 assertNoErrors(); |
| 5949 expect(expression, new isInstanceOf<SimpleStringLiteral>()); | 5883 expect(expression, new isInstanceOf<SimpleStringLiteral>()); |
| 5950 SimpleStringLiteral literal = expression; | 5884 SimpleStringLiteral literal = expression; |
| 5951 expect(literal.isMultiline, isFalse); | 5885 expect(literal.isMultiline, isFalse); |
| 5952 expect(literal.isRaw, isTrue); | 5886 expect(literal.isRaw, isTrue); |
| 5953 expect(literal.value, "string"); | 5887 expect(literal.value, "string"); |
| 5954 } | 5888 } |
| 5955 | 5889 |
| 5956 void test_parsePrimaryExpression_super() { | 5890 void test_parsePrimaryExpression_super() { |
| 5957 createParser('super.x'); | 5891 Expression expression = parsePrimaryExpression('super.x'); |
| 5958 Expression expression = parser.parsePrimaryExpression(); | |
| 5959 expect(expression, isNotNull); | 5892 expect(expression, isNotNull); |
| 5960 assertNoErrors(); | 5893 assertNoErrors(); |
| 5961 expect(expression, new isInstanceOf<PropertyAccess>()); | 5894 expect(expression, new isInstanceOf<PropertyAccess>()); |
| 5962 PropertyAccess propertyAccess = expression; | 5895 PropertyAccess propertyAccess = expression; |
| 5963 expect(propertyAccess.target is SuperExpression, isTrue); | 5896 expect(propertyAccess.target is SuperExpression, isTrue); |
| 5964 expect(propertyAccess.operator, isNotNull); | 5897 expect(propertyAccess.operator, isNotNull); |
| 5965 expect(propertyAccess.operator.type, TokenType.PERIOD); | 5898 expect(propertyAccess.operator.type, TokenType.PERIOD); |
| 5966 expect(propertyAccess.propertyName, isNotNull); | 5899 expect(propertyAccess.propertyName, isNotNull); |
| 5967 } | 5900 } |
| 5968 | 5901 |
| 5969 void test_parsePrimaryExpression_this() { | 5902 void test_parsePrimaryExpression_this() { |
| 5970 createParser('this'); | 5903 Expression expression = parsePrimaryExpression('this'); |
| 5971 Expression expression = parser.parsePrimaryExpression(); | |
| 5972 expect(expression, isNotNull); | 5904 expect(expression, isNotNull); |
| 5973 assertNoErrors(); | 5905 assertNoErrors(); |
| 5974 expect(expression, new isInstanceOf<ThisExpression>()); | 5906 expect(expression, new isInstanceOf<ThisExpression>()); |
| 5975 ThisExpression thisExpression = expression; | 5907 ThisExpression thisExpression = expression; |
| 5976 expect(thisExpression.thisKeyword, isNotNull); | 5908 expect(thisExpression.thisKeyword, isNotNull); |
| 5977 } | 5909 } |
| 5978 | 5910 |
| 5979 void test_parsePrimaryExpression_true() { | 5911 void test_parsePrimaryExpression_true() { |
| 5980 createParser('true'); | 5912 Expression expression = parsePrimaryExpression('true'); |
| 5981 Expression expression = parser.parsePrimaryExpression(); | |
| 5982 expect(expression, isNotNull); | 5913 expect(expression, isNotNull); |
| 5983 assertNoErrors(); | 5914 assertNoErrors(); |
| 5984 expect(expression, new isInstanceOf<BooleanLiteral>()); | 5915 expect(expression, new isInstanceOf<BooleanLiteral>()); |
| 5985 BooleanLiteral literal = expression; | 5916 BooleanLiteral literal = expression; |
| 5986 expect(literal.literal, isNotNull); | 5917 expect(literal.literal, isNotNull); |
| 5987 expect(literal.value, isTrue); | 5918 expect(literal.value, isTrue); |
| 5988 } | 5919 } |
| 5989 | 5920 |
| 5990 void test_parseRelationalExpression_as_functionType_noReturnType() { | 5921 void test_parseRelationalExpression_as_functionType_noReturnType() { |
| 5991 createParser('x as Function(int)'); | 5922 Expression expression = parseRelationalExpression('x as Function(int)'); |
| 5992 Expression expression = parser.parseRelationalExpression(); | |
| 5993 expect(expression, isNotNull); | 5923 expect(expression, isNotNull); |
| 5994 assertNoErrors(); | 5924 assertNoErrors(); |
| 5995 expect(expression, new isInstanceOf<AsExpression>()); | 5925 expect(expression, new isInstanceOf<AsExpression>()); |
| 5996 AsExpression asExpression = expression; | 5926 AsExpression asExpression = expression; |
| 5997 expect(asExpression.expression, isNotNull); | 5927 expect(asExpression.expression, isNotNull); |
| 5998 expect(asExpression.asOperator, isNotNull); | 5928 expect(asExpression.asOperator, isNotNull); |
| 5999 expect(asExpression.type, new isInstanceOf<GenericFunctionType>()); | 5929 expect(asExpression.type, new isInstanceOf<GenericFunctionType>()); |
| 6000 } | 5930 } |
| 6001 | 5931 |
| 6002 void test_parseRelationalExpression_as_functionType_returnType() { | 5932 void test_parseRelationalExpression_as_functionType_returnType() { |
| 6003 createParser('x as String Function(int)'); | 5933 Expression expression = |
| 6004 Expression expression = parser.parseRelationalExpression(); | 5934 parseRelationalExpression('x as String Function(int)'); |
| 6005 expect(expression, isNotNull); | 5935 expect(expression, isNotNull); |
| 6006 assertNoErrors(); | 5936 assertNoErrors(); |
| 6007 expect(expression, new isInstanceOf<AsExpression>()); | 5937 expect(expression, new isInstanceOf<AsExpression>()); |
| 6008 AsExpression asExpression = expression; | 5938 AsExpression asExpression = expression; |
| 6009 expect(asExpression.expression, isNotNull); | 5939 expect(asExpression.expression, isNotNull); |
| 6010 expect(asExpression.asOperator, isNotNull); | 5940 expect(asExpression.asOperator, isNotNull); |
| 6011 expect(asExpression.type, new isInstanceOf<GenericFunctionType>()); | 5941 expect(asExpression.type, new isInstanceOf<GenericFunctionType>()); |
| 6012 } | 5942 } |
| 6013 | 5943 |
| 6014 void test_parseRelationalExpression_as_generic() { | 5944 void test_parseRelationalExpression_as_generic() { |
| 6015 createParser('x as C<D>'); | 5945 Expression expression = parseRelationalExpression('x as C<D>'); |
| 6016 Expression expression = parser.parseRelationalExpression(); | |
| 6017 expect(expression, isNotNull); | 5946 expect(expression, isNotNull); |
| 6018 assertNoErrors(); | 5947 assertNoErrors(); |
| 6019 expect(expression, new isInstanceOf<AsExpression>()); | 5948 expect(expression, new isInstanceOf<AsExpression>()); |
| 6020 AsExpression asExpression = expression; | 5949 AsExpression asExpression = expression; |
| 6021 expect(asExpression.expression, isNotNull); | 5950 expect(asExpression.expression, isNotNull); |
| 6022 expect(asExpression.asOperator, isNotNull); | 5951 expect(asExpression.asOperator, isNotNull); |
| 6023 expect(asExpression.type, new isInstanceOf<TypeName>()); | 5952 expect(asExpression.type, new isInstanceOf<TypeName>()); |
| 6024 } | 5953 } |
| 6025 | 5954 |
| 6026 void test_parseRelationalExpression_as_nullable() { | 5955 void test_parseRelationalExpression_as_nullable() { |
| 6027 enableNnbd = true; | 5956 enableNnbd = true; |
| 6028 createParser('x as Y?)'); | 5957 Expression expression = parseRelationalExpression('x as Y?)'); |
| 6029 Expression expression = parser.parseRelationalExpression(); | |
| 6030 expect(expression, isNotNull); | 5958 expect(expression, isNotNull); |
| 6031 assertNoErrors(); | 5959 assertNoErrors(); |
| 6032 expect(expression, new isInstanceOf<AsExpression>()); | 5960 expect(expression, new isInstanceOf<AsExpression>()); |
| 6033 AsExpression asExpression = expression; | 5961 AsExpression asExpression = expression; |
| 6034 expect(asExpression.expression, isNotNull); | 5962 expect(asExpression.expression, isNotNull); |
| 6035 expect(asExpression.asOperator, isNotNull); | 5963 expect(asExpression.asOperator, isNotNull); |
| 6036 expect(asExpression.type, new isInstanceOf<TypeName>()); | 5964 expect(asExpression.type, new isInstanceOf<TypeName>()); |
| 6037 } | 5965 } |
| 6038 | 5966 |
| 6039 void test_parseRelationalExpression_as_simple() { | 5967 void test_parseRelationalExpression_as_simple() { |
| 6040 createParser('x as Y'); | 5968 Expression expression = parseRelationalExpression('x as Y'); |
| 6041 Expression expression = parser.parseRelationalExpression(); | |
| 6042 expect(expression, isNotNull); | 5969 expect(expression, isNotNull); |
| 6043 assertNoErrors(); | 5970 assertNoErrors(); |
| 6044 expect(expression, new isInstanceOf<AsExpression>()); | 5971 expect(expression, new isInstanceOf<AsExpression>()); |
| 6045 AsExpression asExpression = expression; | 5972 AsExpression asExpression = expression; |
| 6046 expect(asExpression.expression, isNotNull); | 5973 expect(asExpression.expression, isNotNull); |
| 6047 expect(asExpression.asOperator, isNotNull); | 5974 expect(asExpression.asOperator, isNotNull); |
| 6048 expect(asExpression.type, new isInstanceOf<TypeName>()); | 5975 expect(asExpression.type, new isInstanceOf<TypeName>()); |
| 6049 } | 5976 } |
| 6050 | 5977 |
| 6051 void test_parseRelationalExpression_as_simple_function() { | 5978 void test_parseRelationalExpression_as_simple_function() { |
| 6052 createParser('x as Function'); | 5979 Expression expression = parseRelationalExpression('x as Function'); |
| 6053 Expression expression = parser.parseRelationalExpression(); | |
| 6054 expect(expression, isNotNull); | 5980 expect(expression, isNotNull); |
| 6055 assertNoErrors(); | 5981 assertNoErrors(); |
| 6056 expect(expression, new isInstanceOf<AsExpression>()); | 5982 expect(expression, new isInstanceOf<AsExpression>()); |
| 6057 AsExpression asExpression = expression; | 5983 AsExpression asExpression = expression; |
| 6058 expect(asExpression.expression, isNotNull); | 5984 expect(asExpression.expression, isNotNull); |
| 6059 expect(asExpression.asOperator, isNotNull); | 5985 expect(asExpression.asOperator, isNotNull); |
| 6060 expect(asExpression.type, new isInstanceOf<TypeName>()); | 5986 expect(asExpression.type, new isInstanceOf<TypeName>()); |
| 6061 } | 5987 } |
| 6062 | 5988 |
| 6063 void test_parseRelationalExpression_is() { | 5989 void test_parseRelationalExpression_is() { |
| 6064 createParser('x is y'); | 5990 Expression expression = parseRelationalExpression('x is y'); |
| 6065 Expression expression = parser.parseRelationalExpression(); | |
| 6066 expect(expression, isNotNull); | 5991 expect(expression, isNotNull); |
| 6067 assertNoErrors(); | 5992 assertNoErrors(); |
| 6068 expect(expression, new isInstanceOf<IsExpression>()); | 5993 expect(expression, new isInstanceOf<IsExpression>()); |
| 6069 IsExpression isExpression = expression; | 5994 IsExpression isExpression = expression; |
| 6070 expect(isExpression.expression, isNotNull); | 5995 expect(isExpression.expression, isNotNull); |
| 6071 expect(isExpression.isOperator, isNotNull); | 5996 expect(isExpression.isOperator, isNotNull); |
| 6072 expect(isExpression.notOperator, isNull); | 5997 expect(isExpression.notOperator, isNull); |
| 6073 expect(isExpression.type, isNotNull); | 5998 expect(isExpression.type, isNotNull); |
| 6074 } | 5999 } |
| 6075 | 6000 |
| 6076 void test_parseRelationalExpression_is_nullable() { | 6001 void test_parseRelationalExpression_is_nullable() { |
| 6077 enableNnbd = true; | 6002 enableNnbd = true; |
| 6078 createParser('x is y?)'); | 6003 Expression expression = parseRelationalExpression('x is y?)'); |
| 6079 Expression expression = parser.parseRelationalExpression(); | |
| 6080 expect(expression, isNotNull); | 6004 expect(expression, isNotNull); |
| 6081 assertNoErrors(); | 6005 assertNoErrors(); |
| 6082 expect(expression, new isInstanceOf<IsExpression>()); | 6006 expect(expression, new isInstanceOf<IsExpression>()); |
| 6083 IsExpression isExpression = expression; | 6007 IsExpression isExpression = expression; |
| 6084 expect(isExpression.expression, isNotNull); | 6008 expect(isExpression.expression, isNotNull); |
| 6085 expect(isExpression.isOperator, isNotNull); | 6009 expect(isExpression.isOperator, isNotNull); |
| 6086 expect(isExpression.notOperator, isNull); | 6010 expect(isExpression.notOperator, isNull); |
| 6087 expect(isExpression.type, isNotNull); | 6011 expect(isExpression.type, isNotNull); |
| 6088 } | 6012 } |
| 6089 | 6013 |
| 6090 void test_parseRelationalExpression_isNot() { | 6014 void test_parseRelationalExpression_isNot() { |
| 6091 createParser('x is! y'); | 6015 Expression expression = parseRelationalExpression('x is! y'); |
| 6092 Expression expression = parser.parseRelationalExpression(); | |
| 6093 expect(expression, isNotNull); | 6016 expect(expression, isNotNull); |
| 6094 assertNoErrors(); | 6017 assertNoErrors(); |
| 6095 expect(expression, new isInstanceOf<IsExpression>()); | 6018 expect(expression, new isInstanceOf<IsExpression>()); |
| 6096 IsExpression isExpression = expression; | 6019 IsExpression isExpression = expression; |
| 6097 expect(isExpression.expression, isNotNull); | 6020 expect(isExpression.expression, isNotNull); |
| 6098 expect(isExpression.isOperator, isNotNull); | 6021 expect(isExpression.isOperator, isNotNull); |
| 6099 expect(isExpression.notOperator, isNotNull); | 6022 expect(isExpression.notOperator, isNotNull); |
| 6100 expect(isExpression.type, isNotNull); | 6023 expect(isExpression.type, isNotNull); |
| 6101 } | 6024 } |
| 6102 | 6025 |
| 6103 void test_parseRelationalExpression_normal() { | 6026 void test_parseRelationalExpression_normal() { |
| 6104 createParser('x < y'); | 6027 Expression expression = parseRelationalExpression('x < y'); |
| 6105 Expression expression = parser.parseRelationalExpression(); | |
| 6106 expect(expression, isNotNull); | 6028 expect(expression, isNotNull); |
| 6107 assertNoErrors(); | 6029 assertNoErrors(); |
| 6108 expect(expression, new isInstanceOf<BinaryExpression>()); | 6030 expect(expression, new isInstanceOf<BinaryExpression>()); |
| 6109 BinaryExpression binaryExpression = expression; | 6031 BinaryExpression binaryExpression = expression; |
| 6110 expect(binaryExpression.leftOperand, isNotNull); | 6032 expect(binaryExpression.leftOperand, isNotNull); |
| 6111 expect(binaryExpression.operator, isNotNull); | 6033 expect(binaryExpression.operator, isNotNull); |
| 6112 expect(binaryExpression.operator.type, TokenType.LT); | 6034 expect(binaryExpression.operator.type, TokenType.LT); |
| 6113 expect(binaryExpression.rightOperand, isNotNull); | 6035 expect(binaryExpression.rightOperand, isNotNull); |
| 6114 } | 6036 } |
| 6115 | 6037 |
| 6116 void test_parseRelationalExpression_super() { | 6038 void test_parseRelationalExpression_super() { |
| 6117 createParser('super < y'); | 6039 Expression expression = parseRelationalExpression('super < y'); |
| 6118 Expression expression = parser.parseRelationalExpression(); | |
| 6119 expect(expression, isNotNull); | 6040 expect(expression, isNotNull); |
| 6120 assertNoErrors(); | 6041 assertNoErrors(); |
| 6121 expect(expression, new isInstanceOf<BinaryExpression>()); | 6042 expect(expression, new isInstanceOf<BinaryExpression>()); |
| 6122 BinaryExpression binaryExpression = expression; | 6043 BinaryExpression binaryExpression = expression; |
| 6123 expect(binaryExpression.leftOperand, isNotNull); | 6044 expect(binaryExpression.leftOperand, isNotNull); |
| 6124 expect(binaryExpression.operator, isNotNull); | 6045 expect(binaryExpression.operator, isNotNull); |
| 6125 expect(binaryExpression.operator.type, TokenType.LT); | 6046 expect(binaryExpression.operator.type, TokenType.LT); |
| 6126 expect(binaryExpression.rightOperand, isNotNull); | 6047 expect(binaryExpression.rightOperand, isNotNull); |
| 6127 } | 6048 } |
| 6128 | 6049 |
| 6129 void test_parseRethrowExpression() { | 6050 void test_parseRethrowExpression() { |
| 6130 createParser('rethrow;'); | 6051 RethrowExpression expression = parseRethrowExpression('rethrow'); |
| 6131 RethrowExpression expression = parser.parseRethrowExpression(); | |
| 6132 expect(expression, isNotNull); | 6052 expect(expression, isNotNull); |
| 6133 assertNoErrors(); | 6053 assertNoErrors(); |
| 6134 expect(expression.rethrowKeyword, isNotNull); | 6054 expect(expression.rethrowKeyword, isNotNull); |
| 6135 } | 6055 } |
| 6136 | 6056 |
| 6137 void test_parseShiftExpression_normal() { | 6057 void test_parseShiftExpression_normal() { |
| 6138 createParser('x << y'); | 6058 BinaryExpression expression = parseShiftExpression('x << y'); |
| 6139 BinaryExpression expression = parser.parseShiftExpression(); | |
| 6140 expect(expression, isNotNull); | 6059 expect(expression, isNotNull); |
| 6141 assertNoErrors(); | 6060 assertNoErrors(); |
| 6142 expect(expression.leftOperand, isNotNull); | 6061 expect(expression.leftOperand, isNotNull); |
| 6143 expect(expression.operator, isNotNull); | 6062 expect(expression.operator, isNotNull); |
| 6144 expect(expression.operator.type, TokenType.LT_LT); | 6063 expect(expression.operator.type, TokenType.LT_LT); |
| 6145 expect(expression.rightOperand, isNotNull); | 6064 expect(expression.rightOperand, isNotNull); |
| 6146 } | 6065 } |
| 6147 | 6066 |
| 6148 void test_parseShiftExpression_super() { | 6067 void test_parseShiftExpression_super() { |
| 6149 createParser('super << y'); | 6068 BinaryExpression expression = parseShiftExpression('super << y'); |
| 6150 BinaryExpression expression = parser.parseShiftExpression(); | |
| 6151 expect(expression, isNotNull); | 6069 expect(expression, isNotNull); |
| 6152 assertNoErrors(); | 6070 assertNoErrors(); |
| 6153 expect(expression.leftOperand, isNotNull); | 6071 expect(expression.leftOperand, isNotNull); |
| 6154 expect(expression.operator, isNotNull); | 6072 expect(expression.operator, isNotNull); |
| 6155 expect(expression.operator.type, TokenType.LT_LT); | 6073 expect(expression.operator.type, TokenType.LT_LT); |
| 6156 expect(expression.rightOperand, isNotNull); | 6074 expect(expression.rightOperand, isNotNull); |
| 6157 } | 6075 } |
| 6158 | 6076 |
| 6159 void test_parseSimpleIdentifier1_normalIdentifier() { | 6077 void test_parseSimpleIdentifier1_normalIdentifier() { |
| 6160 // TODO(brianwilkerson) Implement tests for this method. | 6078 // TODO(brianwilkerson) Implement tests for this method. |
| 6161 } | 6079 } |
| 6162 | 6080 |
| 6163 void test_parseSimpleIdentifier_builtInIdentifier() { | 6081 void test_parseSimpleIdentifier_builtInIdentifier() { |
| 6164 String lexeme = "as"; | 6082 String lexeme = "as"; |
| 6165 createParser(lexeme); | 6083 SimpleIdentifier identifier = parseSimpleIdentifier(lexeme); |
| 6166 SimpleIdentifier identifier = parser.parseSimpleIdentifier(); | |
| 6167 expect(identifier, isNotNull); | 6084 expect(identifier, isNotNull); |
| 6168 assertNoErrors(); | 6085 assertNoErrors(); |
| 6169 expect(identifier.token, isNotNull); | 6086 expect(identifier.token, isNotNull); |
| 6170 expect(identifier.name, lexeme); | 6087 expect(identifier.name, lexeme); |
| 6171 } | 6088 } |
| 6172 | 6089 |
| 6173 void test_parseSimpleIdentifier_normalIdentifier() { | 6090 void test_parseSimpleIdentifier_normalIdentifier() { |
| 6174 String lexeme = "foo"; | 6091 String lexeme = "foo"; |
| 6175 createParser(lexeme); | 6092 SimpleIdentifier identifier = parseSimpleIdentifier(lexeme); |
| 6176 SimpleIdentifier identifier = parser.parseSimpleIdentifier(); | |
| 6177 expect(identifier, isNotNull); | 6093 expect(identifier, isNotNull); |
| 6178 assertNoErrors(); | 6094 assertNoErrors(); |
| 6179 expect(identifier.token, isNotNull); | 6095 expect(identifier.token, isNotNull); |
| 6180 expect(identifier.name, lexeme); | 6096 expect(identifier.name, lexeme); |
| 6181 } | 6097 } |
| 6182 | 6098 |
| 6183 void test_parseStringLiteral_adjacent() { | 6099 void test_parseStringLiteral_adjacent() { |
| 6184 createParser("'a' 'b'"); | 6100 Expression expression = parseStringLiteral("'a' 'b'"); |
| 6185 Expression expression = parser.parseStringLiteral(); | |
| 6186 expect(expression, isNotNull); | 6101 expect(expression, isNotNull); |
| 6187 assertNoErrors(); | 6102 assertNoErrors(); |
| 6188 expect(expression, new isInstanceOf<AdjacentStrings>()); | 6103 expect(expression, new isInstanceOf<AdjacentStrings>()); |
| 6189 AdjacentStrings literal = expression; | 6104 AdjacentStrings literal = expression; |
| 6190 NodeList<StringLiteral> strings = literal.strings; | 6105 NodeList<StringLiteral> strings = literal.strings; |
| 6191 expect(strings, hasLength(2)); | 6106 expect(strings, hasLength(2)); |
| 6192 StringLiteral firstString = strings[0]; | 6107 StringLiteral firstString = strings[0]; |
| 6193 StringLiteral secondString = strings[1]; | 6108 StringLiteral secondString = strings[1]; |
| 6194 expect((firstString as SimpleStringLiteral).value, "a"); | 6109 expect((firstString as SimpleStringLiteral).value, "a"); |
| 6195 expect((secondString as SimpleStringLiteral).value, "b"); | 6110 expect((secondString as SimpleStringLiteral).value, "b"); |
| 6196 } | 6111 } |
| 6197 | 6112 |
| 6198 void test_parseStringLiteral_endsWithInterpolation() { | 6113 void test_parseStringLiteral_endsWithInterpolation() { |
| 6199 createParser(r"'x$y'"); | 6114 Expression expression = parseStringLiteral(r"'x$y'"); |
| 6200 Expression expression = parser.parseStringLiteral(); | |
| 6201 expect(expression, isNotNull); | 6115 expect(expression, isNotNull); |
| 6202 assertNoErrors(); | 6116 assertNoErrors(); |
| 6203 expect(expression, new isInstanceOf<StringInterpolation>()); | 6117 expect(expression, new isInstanceOf<StringInterpolation>()); |
| 6204 StringInterpolation interpolation = expression; | 6118 StringInterpolation interpolation = expression; |
| 6205 expect(interpolation.elements, hasLength(3)); | 6119 expect(interpolation.elements, hasLength(3)); |
| 6206 expect(interpolation.elements[0], new isInstanceOf<InterpolationString>()); | 6120 expect(interpolation.elements[0], new isInstanceOf<InterpolationString>()); |
| 6207 InterpolationString element0 = interpolation.elements[0]; | 6121 InterpolationString element0 = interpolation.elements[0]; |
| 6208 expect(element0.value, 'x'); | 6122 expect(element0.value, 'x'); |
| 6209 expect( | 6123 expect( |
| 6210 interpolation.elements[1], new isInstanceOf<InterpolationExpression>()); | 6124 interpolation.elements[1], new isInstanceOf<InterpolationExpression>()); |
| 6211 InterpolationExpression element1 = interpolation.elements[1]; | 6125 InterpolationExpression element1 = interpolation.elements[1]; |
| 6212 expect(element1.expression, new isInstanceOf<SimpleIdentifier>()); | 6126 expect(element1.expression, new isInstanceOf<SimpleIdentifier>()); |
| 6213 expect(interpolation.elements[2], new isInstanceOf<InterpolationString>()); | 6127 expect(interpolation.elements[2], new isInstanceOf<InterpolationString>()); |
| 6214 InterpolationString element2 = interpolation.elements[2]; | 6128 InterpolationString element2 = interpolation.elements[2]; |
| 6215 expect(element2.value, ''); | 6129 expect(element2.value, ''); |
| 6216 } | 6130 } |
| 6217 | 6131 |
| 6218 void test_parseStringLiteral_interpolated() { | 6132 void test_parseStringLiteral_interpolated() { |
| 6219 createParser("'a \${b} c \$this d'"); | 6133 Expression expression = parseStringLiteral("'a \${b} c \$this d'"); |
| 6220 Expression expression = parser.parseStringLiteral(); | |
| 6221 expect(expression, isNotNull); | 6134 expect(expression, isNotNull); |
| 6222 assertNoErrors(); | 6135 assertNoErrors(); |
| 6223 expect(expression, new isInstanceOf<StringInterpolation>()); | 6136 expect(expression, new isInstanceOf<StringInterpolation>()); |
| 6224 StringInterpolation literal = expression; | 6137 StringInterpolation literal = expression; |
| 6225 NodeList<InterpolationElement> elements = literal.elements; | 6138 NodeList<InterpolationElement> elements = literal.elements; |
| 6226 expect(elements, hasLength(5)); | 6139 expect(elements, hasLength(5)); |
| 6227 expect(elements[0] is InterpolationString, isTrue); | 6140 expect(elements[0] is InterpolationString, isTrue); |
| 6228 expect(elements[1] is InterpolationExpression, isTrue); | 6141 expect(elements[1] is InterpolationExpression, isTrue); |
| 6229 expect(elements[2] is InterpolationString, isTrue); | 6142 expect(elements[2] is InterpolationString, isTrue); |
| 6230 expect(elements[3] is InterpolationExpression, isTrue); | 6143 expect(elements[3] is InterpolationExpression, isTrue); |
| 6231 expect(elements[4] is InterpolationString, isTrue); | 6144 expect(elements[4] is InterpolationString, isTrue); |
| 6232 } | 6145 } |
| 6233 | 6146 |
| 6234 void test_parseStringLiteral_multiline_encodedSpace() { | 6147 void test_parseStringLiteral_multiline_encodedSpace() { |
| 6235 createParser("'''\\x20\na'''"); | 6148 Expression expression = parseStringLiteral("'''\\x20\na'''"); |
| 6236 Expression expression = parser.parseStringLiteral(); | |
| 6237 expect(expression, isNotNull); | 6149 expect(expression, isNotNull); |
| 6238 assertNoErrors(); | 6150 assertNoErrors(); |
| 6239 expect(expression, new isInstanceOf<SimpleStringLiteral>()); | 6151 expect(expression, new isInstanceOf<SimpleStringLiteral>()); |
| 6240 SimpleStringLiteral literal = expression; | 6152 SimpleStringLiteral literal = expression; |
| 6241 expect(literal.literal, isNotNull); | 6153 expect(literal.literal, isNotNull); |
| 6242 expect(literal.value, " \na"); | 6154 expect(literal.value, " \na"); |
| 6243 } | 6155 } |
| 6244 | 6156 |
| 6245 void test_parseStringLiteral_multiline_endsWithInterpolation() { | 6157 void test_parseStringLiteral_multiline_endsWithInterpolation() { |
| 6246 createParser(r"'''x$y'''"); | 6158 Expression expression = parseStringLiteral(r"'''x$y'''"); |
| 6247 Expression expression = parser.parseStringLiteral(); | |
| 6248 expect(expression, isNotNull); | 6159 expect(expression, isNotNull); |
| 6249 assertNoErrors(); | 6160 assertNoErrors(); |
| 6250 expect(expression, new isInstanceOf<StringInterpolation>()); | 6161 expect(expression, new isInstanceOf<StringInterpolation>()); |
| 6251 StringInterpolation interpolation = expression; | 6162 StringInterpolation interpolation = expression; |
| 6252 expect(interpolation.elements, hasLength(3)); | 6163 expect(interpolation.elements, hasLength(3)); |
| 6253 expect(interpolation.elements[0], new isInstanceOf<InterpolationString>()); | 6164 expect(interpolation.elements[0], new isInstanceOf<InterpolationString>()); |
| 6254 InterpolationString element0 = interpolation.elements[0]; | 6165 InterpolationString element0 = interpolation.elements[0]; |
| 6255 expect(element0.value, 'x'); | 6166 expect(element0.value, 'x'); |
| 6256 expect( | 6167 expect( |
| 6257 interpolation.elements[1], new isInstanceOf<InterpolationExpression>()); | 6168 interpolation.elements[1], new isInstanceOf<InterpolationExpression>()); |
| 6258 InterpolationExpression element1 = interpolation.elements[1]; | 6169 InterpolationExpression element1 = interpolation.elements[1]; |
| 6259 expect(element1.expression, new isInstanceOf<SimpleIdentifier>()); | 6170 expect(element1.expression, new isInstanceOf<SimpleIdentifier>()); |
| 6260 expect(interpolation.elements[2], new isInstanceOf<InterpolationString>()); | 6171 expect(interpolation.elements[2], new isInstanceOf<InterpolationString>()); |
| 6261 InterpolationString element2 = interpolation.elements[2]; | 6172 InterpolationString element2 = interpolation.elements[2]; |
| 6262 expect(element2.value, ''); | 6173 expect(element2.value, ''); |
| 6263 } | 6174 } |
| 6264 | 6175 |
| 6265 void test_parseStringLiteral_multiline_escapedBackslash() { | 6176 void test_parseStringLiteral_multiline_escapedBackslash() { |
| 6266 createParser("'''\\\\\na'''"); | 6177 Expression expression = parseStringLiteral("'''\\\\\na'''"); |
| 6267 Expression expression = parser.parseStringLiteral(); | |
| 6268 expect(expression, isNotNull); | 6178 expect(expression, isNotNull); |
| 6269 assertNoErrors(); | 6179 assertNoErrors(); |
| 6270 expect(expression, new isInstanceOf<SimpleStringLiteral>()); | 6180 expect(expression, new isInstanceOf<SimpleStringLiteral>()); |
| 6271 SimpleStringLiteral literal = expression; | 6181 SimpleStringLiteral literal = expression; |
| 6272 expect(literal.literal, isNotNull); | 6182 expect(literal.literal, isNotNull); |
| 6273 expect(literal.value, "\\\na"); | 6183 expect(literal.value, "\\\na"); |
| 6274 } | 6184 } |
| 6275 | 6185 |
| 6276 void test_parseStringLiteral_multiline_escapedBackslash_raw() { | 6186 void test_parseStringLiteral_multiline_escapedBackslash_raw() { |
| 6277 createParser("r'''\\\\\na'''"); | 6187 Expression expression = parseStringLiteral("r'''\\\\\na'''"); |
| 6278 Expression expression = parser.parseStringLiteral(); | |
| 6279 expect(expression, isNotNull); | 6188 expect(expression, isNotNull); |
| 6280 assertNoErrors(); | 6189 assertNoErrors(); |
| 6281 expect(expression, new isInstanceOf<SimpleStringLiteral>()); | 6190 expect(expression, new isInstanceOf<SimpleStringLiteral>()); |
| 6282 SimpleStringLiteral literal = expression; | 6191 SimpleStringLiteral literal = expression; |
| 6283 expect(literal.literal, isNotNull); | 6192 expect(literal.literal, isNotNull); |
| 6284 expect(literal.value, "\\\\\na"); | 6193 expect(literal.value, "\\\\\na"); |
| 6285 } | 6194 } |
| 6286 | 6195 |
| 6287 void test_parseStringLiteral_multiline_escapedEolMarker() { | 6196 void test_parseStringLiteral_multiline_escapedEolMarker() { |
| 6288 createParser("'''\\\na'''"); | 6197 Expression expression = parseStringLiteral("'''\\\na'''"); |
| 6289 Expression expression = parser.parseStringLiteral(); | |
| 6290 expect(expression, isNotNull); | 6198 expect(expression, isNotNull); |
| 6291 assertNoErrors(); | 6199 assertNoErrors(); |
| 6292 expect(expression, new isInstanceOf<SimpleStringLiteral>()); | 6200 expect(expression, new isInstanceOf<SimpleStringLiteral>()); |
| 6293 SimpleStringLiteral literal = expression; | 6201 SimpleStringLiteral literal = expression; |
| 6294 expect(literal.literal, isNotNull); | 6202 expect(literal.literal, isNotNull); |
| 6295 expect(literal.value, "a"); | 6203 expect(literal.value, "a"); |
| 6296 } | 6204 } |
| 6297 | 6205 |
| 6298 void test_parseStringLiteral_multiline_escapedEolMarker_raw() { | 6206 void test_parseStringLiteral_multiline_escapedEolMarker_raw() { |
| 6299 createParser("r'''\\\na'''"); | 6207 Expression expression = parseStringLiteral("r'''\\\na'''"); |
| 6300 Expression expression = parser.parseStringLiteral(); | |
| 6301 expect(expression, isNotNull); | 6208 expect(expression, isNotNull); |
| 6302 assertNoErrors(); | 6209 assertNoErrors(); |
| 6303 expect(expression, new isInstanceOf<SimpleStringLiteral>()); | 6210 expect(expression, new isInstanceOf<SimpleStringLiteral>()); |
| 6304 SimpleStringLiteral literal = expression; | 6211 SimpleStringLiteral literal = expression; |
| 6305 expect(literal.literal, isNotNull); | 6212 expect(literal.literal, isNotNull); |
| 6306 expect(literal.value, "a"); | 6213 expect(literal.value, "a"); |
| 6307 } | 6214 } |
| 6308 | 6215 |
| 6309 void test_parseStringLiteral_multiline_escapedSpaceAndEolMarker() { | 6216 void test_parseStringLiteral_multiline_escapedSpaceAndEolMarker() { |
| 6310 createParser("'''\\ \\\na'''"); | 6217 Expression expression = parseStringLiteral("'''\\ \\\na'''"); |
| 6311 Expression expression = parser.parseStringLiteral(); | |
| 6312 expect(expression, isNotNull); | 6218 expect(expression, isNotNull); |
| 6313 assertNoErrors(); | 6219 assertNoErrors(); |
| 6314 expect(expression, new isInstanceOf<SimpleStringLiteral>()); | 6220 expect(expression, new isInstanceOf<SimpleStringLiteral>()); |
| 6315 SimpleStringLiteral literal = expression; | 6221 SimpleStringLiteral literal = expression; |
| 6316 expect(literal.literal, isNotNull); | 6222 expect(literal.literal, isNotNull); |
| 6317 expect(literal.value, "a"); | 6223 expect(literal.value, "a"); |
| 6318 } | 6224 } |
| 6319 | 6225 |
| 6320 void test_parseStringLiteral_multiline_escapedSpaceAndEolMarker_raw() { | 6226 void test_parseStringLiteral_multiline_escapedSpaceAndEolMarker_raw() { |
| 6321 createParser("r'''\\ \\\na'''"); | 6227 Expression expression = parseStringLiteral("r'''\\ \\\na'''"); |
| 6322 Expression expression = parser.parseStringLiteral(); | |
| 6323 expect(expression, isNotNull); | 6228 expect(expression, isNotNull); |
| 6324 assertNoErrors(); | 6229 assertNoErrors(); |
| 6325 expect(expression, new isInstanceOf<SimpleStringLiteral>()); | 6230 expect(expression, new isInstanceOf<SimpleStringLiteral>()); |
| 6326 SimpleStringLiteral literal = expression; | 6231 SimpleStringLiteral literal = expression; |
| 6327 expect(literal.literal, isNotNull); | 6232 expect(literal.literal, isNotNull); |
| 6328 expect(literal.value, "a"); | 6233 expect(literal.value, "a"); |
| 6329 } | 6234 } |
| 6330 | 6235 |
| 6331 void test_parseStringLiteral_multiline_escapedTab() { | 6236 void test_parseStringLiteral_multiline_escapedTab() { |
| 6332 createParser("'''\\t\na'''"); | 6237 Expression expression = parseStringLiteral("'''\\t\na'''"); |
| 6333 Expression expression = parser.parseStringLiteral(); | |
| 6334 expect(expression, isNotNull); | 6238 expect(expression, isNotNull); |
| 6335 assertNoErrors(); | 6239 assertNoErrors(); |
| 6336 expect(expression, new isInstanceOf<SimpleStringLiteral>()); | 6240 expect(expression, new isInstanceOf<SimpleStringLiteral>()); |
| 6337 SimpleStringLiteral literal = expression; | 6241 SimpleStringLiteral literal = expression; |
| 6338 expect(literal.literal, isNotNull); | 6242 expect(literal.literal, isNotNull); |
| 6339 expect(literal.value, "\t\na"); | 6243 expect(literal.value, "\t\na"); |
| 6340 } | 6244 } |
| 6341 | 6245 |
| 6342 void test_parseStringLiteral_multiline_escapedTab_raw() { | 6246 void test_parseStringLiteral_multiline_escapedTab_raw() { |
| 6343 createParser("r'''\\t\na'''"); | 6247 Expression expression = parseStringLiteral("r'''\\t\na'''"); |
| 6344 Expression expression = parser.parseStringLiteral(); | |
| 6345 expect(expression, isNotNull); | 6248 expect(expression, isNotNull); |
| 6346 assertNoErrors(); | 6249 assertNoErrors(); |
| 6347 expect(expression, new isInstanceOf<SimpleStringLiteral>()); | 6250 expect(expression, new isInstanceOf<SimpleStringLiteral>()); |
| 6348 SimpleStringLiteral literal = expression; | 6251 SimpleStringLiteral literal = expression; |
| 6349 expect(literal.literal, isNotNull); | 6252 expect(literal.literal, isNotNull); |
| 6350 expect(literal.value, "\\t\na"); | 6253 expect(literal.value, "\\t\na"); |
| 6351 } | 6254 } |
| 6352 | 6255 |
| 6353 void test_parseStringLiteral_multiline_quoteAfterInterpolation() { | 6256 void test_parseStringLiteral_multiline_quoteAfterInterpolation() { |
| 6354 createParser(r"""'''$x'y'''"""); | 6257 Expression expression = parseStringLiteral(r"""'''$x'y'''"""); |
| 6355 Expression expression = parser.parseStringLiteral(); | |
| 6356 expect(expression, isNotNull); | 6258 expect(expression, isNotNull); |
| 6357 assertNoErrors(); | 6259 assertNoErrors(); |
| 6358 expect(expression, new isInstanceOf<StringInterpolation>()); | 6260 expect(expression, new isInstanceOf<StringInterpolation>()); |
| 6359 StringInterpolation interpolation = expression; | 6261 StringInterpolation interpolation = expression; |
| 6360 expect(interpolation.elements, hasLength(3)); | 6262 expect(interpolation.elements, hasLength(3)); |
| 6361 expect(interpolation.elements[0], new isInstanceOf<InterpolationString>()); | 6263 expect(interpolation.elements[0], new isInstanceOf<InterpolationString>()); |
| 6362 InterpolationString element0 = interpolation.elements[0]; | 6264 InterpolationString element0 = interpolation.elements[0]; |
| 6363 expect(element0.value, ''); | 6265 expect(element0.value, ''); |
| 6364 expect( | 6266 expect( |
| 6365 interpolation.elements[1], new isInstanceOf<InterpolationExpression>()); | 6267 interpolation.elements[1], new isInstanceOf<InterpolationExpression>()); |
| 6366 InterpolationExpression element1 = interpolation.elements[1]; | 6268 InterpolationExpression element1 = interpolation.elements[1]; |
| 6367 expect(element1.expression, new isInstanceOf<SimpleIdentifier>()); | 6269 expect(element1.expression, new isInstanceOf<SimpleIdentifier>()); |
| 6368 expect(interpolation.elements[2], new isInstanceOf<InterpolationString>()); | 6270 expect(interpolation.elements[2], new isInstanceOf<InterpolationString>()); |
| 6369 InterpolationString element2 = interpolation.elements[2]; | 6271 InterpolationString element2 = interpolation.elements[2]; |
| 6370 expect(element2.value, "'y"); | 6272 expect(element2.value, "'y"); |
| 6371 } | 6273 } |
| 6372 | 6274 |
| 6373 void test_parseStringLiteral_multiline_startsWithInterpolation() { | 6275 void test_parseStringLiteral_multiline_startsWithInterpolation() { |
| 6374 createParser(r"'''${x}y'''"); | 6276 Expression expression = parseStringLiteral(r"'''${x}y'''"); |
| 6375 Expression expression = parser.parseStringLiteral(); | |
| 6376 expect(expression, isNotNull); | 6277 expect(expression, isNotNull); |
| 6377 assertNoErrors(); | 6278 assertNoErrors(); |
| 6378 expect(expression, new isInstanceOf<StringInterpolation>()); | 6279 expect(expression, new isInstanceOf<StringInterpolation>()); |
| 6379 StringInterpolation interpolation = expression; | 6280 StringInterpolation interpolation = expression; |
| 6380 expect(interpolation.elements, hasLength(3)); | 6281 expect(interpolation.elements, hasLength(3)); |
| 6381 expect(interpolation.elements[0], new isInstanceOf<InterpolationString>()); | 6282 expect(interpolation.elements[0], new isInstanceOf<InterpolationString>()); |
| 6382 InterpolationString element0 = interpolation.elements[0]; | 6283 InterpolationString element0 = interpolation.elements[0]; |
| 6383 expect(element0.value, ''); | 6284 expect(element0.value, ''); |
| 6384 expect( | 6285 expect( |
| 6385 interpolation.elements[1], new isInstanceOf<InterpolationExpression>()); | 6286 interpolation.elements[1], new isInstanceOf<InterpolationExpression>()); |
| 6386 InterpolationExpression element1 = interpolation.elements[1]; | 6287 InterpolationExpression element1 = interpolation.elements[1]; |
| 6387 expect(element1.expression, new isInstanceOf<SimpleIdentifier>()); | 6288 expect(element1.expression, new isInstanceOf<SimpleIdentifier>()); |
| 6388 expect(interpolation.elements[2], new isInstanceOf<InterpolationString>()); | 6289 expect(interpolation.elements[2], new isInstanceOf<InterpolationString>()); |
| 6389 InterpolationString element2 = interpolation.elements[2]; | 6290 InterpolationString element2 = interpolation.elements[2]; |
| 6390 expect(element2.value, 'y'); | 6291 expect(element2.value, 'y'); |
| 6391 } | 6292 } |
| 6392 | 6293 |
| 6393 void test_parseStringLiteral_multiline_twoSpaces() { | 6294 void test_parseStringLiteral_multiline_twoSpaces() { |
| 6394 createParser("''' \na'''"); | 6295 Expression expression = parseStringLiteral("''' \na'''"); |
| 6395 Expression expression = parser.parseStringLiteral(); | |
| 6396 expect(expression, isNotNull); | 6296 expect(expression, isNotNull); |
| 6397 assertNoErrors(); | 6297 assertNoErrors(); |
| 6398 expect(expression, new isInstanceOf<SimpleStringLiteral>()); | 6298 expect(expression, new isInstanceOf<SimpleStringLiteral>()); |
| 6399 SimpleStringLiteral literal = expression; | 6299 SimpleStringLiteral literal = expression; |
| 6400 expect(literal.literal, isNotNull); | 6300 expect(literal.literal, isNotNull); |
| 6401 expect(literal.value, "a"); | 6301 expect(literal.value, "a"); |
| 6402 } | 6302 } |
| 6403 | 6303 |
| 6404 void test_parseStringLiteral_multiline_twoSpaces_raw() { | 6304 void test_parseStringLiteral_multiline_twoSpaces_raw() { |
| 6405 createParser("r''' \na'''"); | 6305 Expression expression = parseStringLiteral("r''' \na'''"); |
| 6406 Expression expression = parser.parseStringLiteral(); | |
| 6407 expect(expression, isNotNull); | 6306 expect(expression, isNotNull); |
| 6408 assertNoErrors(); | 6307 assertNoErrors(); |
| 6409 expect(expression, new isInstanceOf<SimpleStringLiteral>()); | 6308 expect(expression, new isInstanceOf<SimpleStringLiteral>()); |
| 6410 SimpleStringLiteral literal = expression; | 6309 SimpleStringLiteral literal = expression; |
| 6411 expect(literal.literal, isNotNull); | 6310 expect(literal.literal, isNotNull); |
| 6412 expect(literal.value, "a"); | 6311 expect(literal.value, "a"); |
| 6413 } | 6312 } |
| 6414 | 6313 |
| 6415 void test_parseStringLiteral_multiline_untrimmed() { | 6314 void test_parseStringLiteral_multiline_untrimmed() { |
| 6416 createParser("''' a\nb'''"); | 6315 Expression expression = parseStringLiteral("''' a\nb'''"); |
| 6417 Expression expression = parser.parseStringLiteral(); | |
| 6418 expect(expression, isNotNull); | 6316 expect(expression, isNotNull); |
| 6419 assertNoErrors(); | 6317 assertNoErrors(); |
| 6420 expect(expression, new isInstanceOf<SimpleStringLiteral>()); | 6318 expect(expression, new isInstanceOf<SimpleStringLiteral>()); |
| 6421 SimpleStringLiteral literal = expression; | 6319 SimpleStringLiteral literal = expression; |
| 6422 expect(literal.literal, isNotNull); | 6320 expect(literal.literal, isNotNull); |
| 6423 expect(literal.value, " a\nb"); | 6321 expect(literal.value, " a\nb"); |
| 6424 } | 6322 } |
| 6425 | 6323 |
| 6426 void test_parseStringLiteral_quoteAfterInterpolation() { | 6324 void test_parseStringLiteral_quoteAfterInterpolation() { |
| 6427 createParser(r"""'$x"'"""); | 6325 Expression expression = parseStringLiteral(r"""'$x"'"""); |
| 6428 Expression expression = parser.parseStringLiteral(); | |
| 6429 expect(expression, isNotNull); | 6326 expect(expression, isNotNull); |
| 6430 assertNoErrors(); | 6327 assertNoErrors(); |
| 6431 expect(expression, new isInstanceOf<StringInterpolation>()); | 6328 expect(expression, new isInstanceOf<StringInterpolation>()); |
| 6432 StringInterpolation interpolation = expression; | 6329 StringInterpolation interpolation = expression; |
| 6433 expect(interpolation.elements, hasLength(3)); | 6330 expect(interpolation.elements, hasLength(3)); |
| 6434 expect(interpolation.elements[0], new isInstanceOf<InterpolationString>()); | 6331 expect(interpolation.elements[0], new isInstanceOf<InterpolationString>()); |
| 6435 InterpolationString element0 = interpolation.elements[0]; | 6332 InterpolationString element0 = interpolation.elements[0]; |
| 6436 expect(element0.value, ''); | 6333 expect(element0.value, ''); |
| 6437 expect( | 6334 expect( |
| 6438 interpolation.elements[1], new isInstanceOf<InterpolationExpression>()); | 6335 interpolation.elements[1], new isInstanceOf<InterpolationExpression>()); |
| 6439 InterpolationExpression element1 = interpolation.elements[1]; | 6336 InterpolationExpression element1 = interpolation.elements[1]; |
| 6440 expect(element1.expression, new isInstanceOf<SimpleIdentifier>()); | 6337 expect(element1.expression, new isInstanceOf<SimpleIdentifier>()); |
| 6441 expect(interpolation.elements[2], new isInstanceOf<InterpolationString>()); | 6338 expect(interpolation.elements[2], new isInstanceOf<InterpolationString>()); |
| 6442 InterpolationString element2 = interpolation.elements[2]; | 6339 InterpolationString element2 = interpolation.elements[2]; |
| 6443 expect(element2.value, '"'); | 6340 expect(element2.value, '"'); |
| 6444 } | 6341 } |
| 6445 | 6342 |
| 6446 void test_parseStringLiteral_single() { | 6343 void test_parseStringLiteral_single() { |
| 6447 createParser("'a'"); | 6344 Expression expression = parseStringLiteral("'a'"); |
| 6448 Expression expression = parser.parseStringLiteral(); | |
| 6449 expect(expression, isNotNull); | 6345 expect(expression, isNotNull); |
| 6450 assertNoErrors(); | 6346 assertNoErrors(); |
| 6451 expect(expression, new isInstanceOf<SimpleStringLiteral>()); | 6347 expect(expression, new isInstanceOf<SimpleStringLiteral>()); |
| 6452 SimpleStringLiteral literal = expression; | 6348 SimpleStringLiteral literal = expression; |
| 6453 expect(literal.literal, isNotNull); | 6349 expect(literal.literal, isNotNull); |
| 6454 expect(literal.value, "a"); | 6350 expect(literal.value, "a"); |
| 6455 } | 6351 } |
| 6456 | 6352 |
| 6457 void test_parseStringLiteral_startsWithInterpolation() { | 6353 void test_parseStringLiteral_startsWithInterpolation() { |
| 6458 createParser(r"'${x}y'"); | 6354 Expression expression = parseStringLiteral(r"'${x}y'"); |
| 6459 Expression expression = parser.parseStringLiteral(); | |
| 6460 expect(expression, isNotNull); | 6355 expect(expression, isNotNull); |
| 6461 assertNoErrors(); | 6356 assertNoErrors(); |
| 6462 expect(expression, new isInstanceOf<StringInterpolation>()); | 6357 expect(expression, new isInstanceOf<StringInterpolation>()); |
| 6463 StringInterpolation interpolation = expression; | 6358 StringInterpolation interpolation = expression; |
| 6464 expect(interpolation.elements, hasLength(3)); | 6359 expect(interpolation.elements, hasLength(3)); |
| 6465 expect(interpolation.elements[0], new isInstanceOf<InterpolationString>()); | 6360 expect(interpolation.elements[0], new isInstanceOf<InterpolationString>()); |
| 6466 InterpolationString element0 = interpolation.elements[0]; | 6361 InterpolationString element0 = interpolation.elements[0]; |
| 6467 expect(element0.value, ''); | 6362 expect(element0.value, ''); |
| 6468 expect( | 6363 expect( |
| 6469 interpolation.elements[1], new isInstanceOf<InterpolationExpression>()); | 6364 interpolation.elements[1], new isInstanceOf<InterpolationExpression>()); |
| 6470 InterpolationExpression element1 = interpolation.elements[1]; | 6365 InterpolationExpression element1 = interpolation.elements[1]; |
| 6471 expect(element1.expression, new isInstanceOf<SimpleIdentifier>()); | 6366 expect(element1.expression, new isInstanceOf<SimpleIdentifier>()); |
| 6472 expect(interpolation.elements[2], new isInstanceOf<InterpolationString>()); | 6367 expect(interpolation.elements[2], new isInstanceOf<InterpolationString>()); |
| 6473 InterpolationString element2 = interpolation.elements[2]; | 6368 InterpolationString element2 = interpolation.elements[2]; |
| 6474 expect(element2.value, 'y'); | 6369 expect(element2.value, 'y'); |
| 6475 } | 6370 } |
| 6476 | 6371 |
| 6477 void test_parseSuperConstructorInvocation_named() { | 6372 void test_parseSuperConstructorInvocation_named() { |
| 6478 createParser('super.a()'); | |
| 6479 SuperConstructorInvocation invocation = | 6373 SuperConstructorInvocation invocation = |
| 6480 parser.parseSuperConstructorInvocation(); | 6374 parseSuperConstructorInvocation('super.a()'); |
| 6481 expect(invocation, isNotNull); | 6375 expect(invocation, isNotNull); |
| 6482 assertNoErrors(); | 6376 assertNoErrors(); |
| 6483 expect(invocation.argumentList, isNotNull); | 6377 expect(invocation.argumentList, isNotNull); |
| 6484 expect(invocation.constructorName, isNotNull); | 6378 expect(invocation.constructorName, isNotNull); |
| 6485 expect(invocation.superKeyword, isNotNull); | 6379 expect(invocation.superKeyword, isNotNull); |
| 6486 expect(invocation.period, isNotNull); | 6380 expect(invocation.period, isNotNull); |
| 6487 } | 6381 } |
| 6488 | 6382 |
| 6489 void test_parseSuperConstructorInvocation_unnamed() { | 6383 void test_parseSuperConstructorInvocation_unnamed() { |
| 6490 createParser('super()'); | |
| 6491 SuperConstructorInvocation invocation = | 6384 SuperConstructorInvocation invocation = |
| 6492 parser.parseSuperConstructorInvocation(); | 6385 parseSuperConstructorInvocation('super()'); |
| 6493 expect(invocation, isNotNull); | 6386 expect(invocation, isNotNull); |
| 6494 assertNoErrors(); | 6387 assertNoErrors(); |
| 6495 expect(invocation.argumentList, isNotNull); | 6388 expect(invocation.argumentList, isNotNull); |
| 6496 expect(invocation.constructorName, isNull); | 6389 expect(invocation.constructorName, isNull); |
| 6497 expect(invocation.superKeyword, isNotNull); | 6390 expect(invocation.superKeyword, isNotNull); |
| 6498 expect(invocation.period, isNull); | 6391 expect(invocation.period, isNull); |
| 6499 } | 6392 } |
| 6500 | 6393 |
| 6501 void test_parseSymbolLiteral_builtInIdentifier() { | 6394 void test_parseSymbolLiteral_builtInIdentifier() { |
| 6502 createParser('#dynamic.static.abstract'); | 6395 SymbolLiteral literal = parseSymbolLiteral('#dynamic.static.abstract'); |
| 6503 SymbolLiteral literal = parser.parseSymbolLiteral(); | |
| 6504 expect(literal, isNotNull); | 6396 expect(literal, isNotNull); |
| 6505 assertNoErrors(); | 6397 assertNoErrors(); |
| 6506 expect(literal.poundSign, isNotNull); | 6398 expect(literal.poundSign, isNotNull); |
| 6507 List<Token> components = literal.components; | 6399 List<Token> components = literal.components; |
| 6508 expect(components, hasLength(3)); | 6400 expect(components, hasLength(3)); |
| 6509 expect(components[0].lexeme, "dynamic"); | 6401 expect(components[0].lexeme, "dynamic"); |
| 6510 expect(components[1].lexeme, "static"); | 6402 expect(components[1].lexeme, "static"); |
| 6511 expect(components[2].lexeme, "abstract"); | 6403 expect(components[2].lexeme, "abstract"); |
| 6512 } | 6404 } |
| 6513 | 6405 |
| 6514 void test_parseSymbolLiteral_multiple() { | 6406 void test_parseSymbolLiteral_multiple() { |
| 6515 createParser('#a.b.c'); | 6407 SymbolLiteral literal = parseSymbolLiteral('#a.b.c'); |
| 6516 SymbolLiteral literal = parser.parseSymbolLiteral(); | |
| 6517 expect(literal, isNotNull); | 6408 expect(literal, isNotNull); |
| 6518 assertNoErrors(); | 6409 assertNoErrors(); |
| 6519 expect(literal.poundSign, isNotNull); | 6410 expect(literal.poundSign, isNotNull); |
| 6520 List<Token> components = literal.components; | 6411 List<Token> components = literal.components; |
| 6521 expect(components, hasLength(3)); | 6412 expect(components, hasLength(3)); |
| 6522 expect(components[0].lexeme, "a"); | 6413 expect(components[0].lexeme, "a"); |
| 6523 expect(components[1].lexeme, "b"); | 6414 expect(components[1].lexeme, "b"); |
| 6524 expect(components[2].lexeme, "c"); | 6415 expect(components[2].lexeme, "c"); |
| 6525 } | 6416 } |
| 6526 | 6417 |
| 6527 void test_parseSymbolLiteral_operator() { | 6418 void test_parseSymbolLiteral_operator() { |
| 6528 createParser('#=='); | 6419 SymbolLiteral literal = parseSymbolLiteral('#=='); |
| 6529 SymbolLiteral literal = parser.parseSymbolLiteral(); | |
| 6530 expect(literal, isNotNull); | 6420 expect(literal, isNotNull); |
| 6531 assertNoErrors(); | 6421 assertNoErrors(); |
| 6532 expect(literal.poundSign, isNotNull); | 6422 expect(literal.poundSign, isNotNull); |
| 6533 List<Token> components = literal.components; | 6423 List<Token> components = literal.components; |
| 6534 expect(components, hasLength(1)); | 6424 expect(components, hasLength(1)); |
| 6535 expect(components[0].lexeme, "=="); | 6425 expect(components[0].lexeme, "=="); |
| 6536 } | 6426 } |
| 6537 | 6427 |
| 6538 void test_parseSymbolLiteral_single() { | 6428 void test_parseSymbolLiteral_single() { |
| 6539 createParser('#a'); | 6429 SymbolLiteral literal = parseSymbolLiteral('#a'); |
| 6540 SymbolLiteral literal = parser.parseSymbolLiteral(); | |
| 6541 expect(literal, isNotNull); | 6430 expect(literal, isNotNull); |
| 6542 assertNoErrors(); | 6431 assertNoErrors(); |
| 6543 expect(literal.poundSign, isNotNull); | 6432 expect(literal.poundSign, isNotNull); |
| 6544 List<Token> components = literal.components; | 6433 List<Token> components = literal.components; |
| 6545 expect(components, hasLength(1)); | 6434 expect(components, hasLength(1)); |
| 6546 expect(components[0].lexeme, "a"); | 6435 expect(components[0].lexeme, "a"); |
| 6547 } | 6436 } |
| 6548 | 6437 |
| 6549 void test_parseSymbolLiteral_void() { | 6438 void test_parseSymbolLiteral_void() { |
| 6550 createParser('#void'); | 6439 SymbolLiteral literal = parseSymbolLiteral('#void'); |
| 6551 SymbolLiteral literal = parser.parseSymbolLiteral(); | |
| 6552 expect(literal, isNotNull); | 6440 expect(literal, isNotNull); |
| 6553 assertNoErrors(); | 6441 assertNoErrors(); |
| 6554 expect(literal.poundSign, isNotNull); | 6442 expect(literal.poundSign, isNotNull); |
| 6555 List<Token> components = literal.components; | 6443 List<Token> components = literal.components; |
| 6556 expect(components, hasLength(1)); | 6444 expect(components, hasLength(1)); |
| 6557 expect(components[0].lexeme, "void"); | 6445 expect(components[0].lexeme, "void"); |
| 6558 } | 6446 } |
| 6559 | 6447 |
| 6560 void test_parseThrowExpression() { | 6448 void test_parseThrowExpression() { |
| 6561 createParser('throw x;'); | 6449 Expression expression = parseThrowExpression('throw x'); |
| 6562 Expression expression = parser.parseThrowExpression(); | |
| 6563 expect(expression, isNotNull); | 6450 expect(expression, isNotNull); |
| 6564 assertNoErrors(); | 6451 assertNoErrors(); |
| 6565 expect(expression, new isInstanceOf<ThrowExpression>()); | 6452 expect(expression, new isInstanceOf<ThrowExpression>()); |
| 6566 ThrowExpression throwExpression = expression; | 6453 ThrowExpression throwExpression = expression; |
| 6567 expect(throwExpression.throwKeyword, isNotNull); | 6454 expect(throwExpression.throwKeyword, isNotNull); |
| 6568 expect(throwExpression.expression, isNotNull); | 6455 expect(throwExpression.expression, isNotNull); |
| 6569 } | 6456 } |
| 6570 | 6457 |
| 6571 void test_parseThrowExpressionWithoutCascade() { | 6458 void test_parseThrowExpressionWithoutCascade() { |
| 6572 createParser('throw x;'); | 6459 Expression expression = parseThrowExpressionWithoutCascade('throw x'); |
| 6573 Expression expression = parser.parseThrowExpressionWithoutCascade(); | |
| 6574 expect(expression, isNotNull); | 6460 expect(expression, isNotNull); |
| 6575 assertNoErrors(); | 6461 assertNoErrors(); |
| 6576 expect(expression, new isInstanceOf<ThrowExpression>()); | 6462 expect(expression, new isInstanceOf<ThrowExpression>()); |
| 6577 ThrowExpression throwExpression = expression; | 6463 ThrowExpression throwExpression = expression; |
| 6578 expect(throwExpression.throwKeyword, isNotNull); | 6464 expect(throwExpression.throwKeyword, isNotNull); |
| 6579 expect(throwExpression.expression, isNotNull); | 6465 expect(throwExpression.expression, isNotNull); |
| 6580 } | 6466 } |
| 6581 | 6467 |
| 6582 void test_parseUnaryExpression_decrement_normal() { | 6468 void test_parseUnaryExpression_decrement_normal() { |
| 6583 createParser('--x'); | 6469 PrefixExpression expression = parseUnaryExpression('--x'); |
| 6584 PrefixExpression expression = parser.parseUnaryExpression(); | |
| 6585 expect(expression, isNotNull); | 6470 expect(expression, isNotNull); |
| 6586 assertNoErrors(); | 6471 assertNoErrors(); |
| 6587 expect(expression.operator, isNotNull); | 6472 expect(expression.operator, isNotNull); |
| 6588 expect(expression.operator.type, TokenType.MINUS_MINUS); | 6473 expect(expression.operator.type, TokenType.MINUS_MINUS); |
| 6589 expect(expression.operand, isNotNull); | 6474 expect(expression.operand, isNotNull); |
| 6590 } | 6475 } |
| 6591 | 6476 |
| 6592 void test_parseUnaryExpression_decrement_super() { | 6477 void test_parseUnaryExpression_decrement_super() { |
| 6593 createParser('--super'); | 6478 PrefixExpression expression = parseUnaryExpression('--super'); |
| 6594 PrefixExpression expression = parser.parseUnaryExpression(); | |
| 6595 expect(expression, isNotNull); | 6479 expect(expression, isNotNull); |
| 6596 assertNoErrors(); | 6480 assertNoErrors(); |
| 6597 expect(expression.operator, isNotNull); | 6481 expect(expression.operator, isNotNull); |
| 6598 expect(expression.operator.type, TokenType.MINUS); | 6482 expect(expression.operator.type, TokenType.MINUS); |
| 6599 Expression innerExpression = expression.operand; | 6483 Expression innerExpression = expression.operand; |
| 6600 expect(innerExpression, isNotNull); | 6484 expect(innerExpression, isNotNull); |
| 6601 expect(innerExpression is PrefixExpression, isTrue); | 6485 expect(innerExpression is PrefixExpression, isTrue); |
| 6602 PrefixExpression operand = innerExpression as PrefixExpression; | 6486 PrefixExpression operand = innerExpression as PrefixExpression; |
| 6603 expect(operand.operator, isNotNull); | 6487 expect(operand.operator, isNotNull); |
| 6604 expect(operand.operator.type, TokenType.MINUS); | 6488 expect(operand.operator.type, TokenType.MINUS); |
| 6605 expect(operand.operand, isNotNull); | 6489 expect(operand.operand, isNotNull); |
| 6606 } | 6490 } |
| 6607 | 6491 |
| 6608 void test_parseUnaryExpression_decrement_super_propertyAccess() { | 6492 void test_parseUnaryExpression_decrement_super_propertyAccess() { |
| 6609 createParser('--super.x'); | 6493 PrefixExpression expression = parseUnaryExpression('--super.x'); |
| 6610 PrefixExpression expression = parser.parseUnaryExpression(); | |
| 6611 expect(expression, isNotNull); | 6494 expect(expression, isNotNull); |
| 6612 assertNoErrors(); | 6495 assertNoErrors(); |
| 6613 expect(expression.operator, isNotNull); | 6496 expect(expression.operator, isNotNull); |
| 6614 expect(expression.operator.type, TokenType.MINUS_MINUS); | 6497 expect(expression.operator.type, TokenType.MINUS_MINUS); |
| 6615 expect(expression.operand, isNotNull); | 6498 expect(expression.operand, isNotNull); |
| 6616 PropertyAccess operand = expression.operand as PropertyAccess; | 6499 PropertyAccess operand = expression.operand as PropertyAccess; |
| 6617 expect(operand.target is SuperExpression, isTrue); | 6500 expect(operand.target is SuperExpression, isTrue); |
| 6618 expect(operand.propertyName.name, "x"); | 6501 expect(operand.propertyName.name, "x"); |
| 6619 } | 6502 } |
| 6620 | 6503 |
| 6621 void test_parseUnaryExpression_decrement_super_withComment() { | 6504 void test_parseUnaryExpression_decrement_super_withComment() { |
| 6622 createParser('/* 0 */ --super'); | 6505 PrefixExpression expression = parseUnaryExpression('/* 0 */ --super'); |
| 6623 PrefixExpression expression = parser.parseUnaryExpression(); | |
| 6624 expect(expression, isNotNull); | 6506 expect(expression, isNotNull); |
| 6625 assertNoErrors(); | 6507 assertNoErrors(); |
| 6626 expect(expression.operator, isNotNull); | 6508 expect(expression.operator, isNotNull); |
| 6627 expect(expression.operator.type, TokenType.MINUS); | 6509 expect(expression.operator.type, TokenType.MINUS); |
| 6628 expect(expression.operator.precedingComments, isNotNull); | 6510 expect(expression.operator.precedingComments, isNotNull); |
| 6629 Expression innerExpression = expression.operand; | 6511 Expression innerExpression = expression.operand; |
| 6630 expect(innerExpression, isNotNull); | 6512 expect(innerExpression, isNotNull); |
| 6631 expect(innerExpression is PrefixExpression, isTrue); | 6513 expect(innerExpression is PrefixExpression, isTrue); |
| 6632 PrefixExpression operand = innerExpression as PrefixExpression; | 6514 PrefixExpression operand = innerExpression as PrefixExpression; |
| 6633 expect(operand.operator, isNotNull); | 6515 expect(operand.operator, isNotNull); |
| 6634 expect(operand.operator.type, TokenType.MINUS); | 6516 expect(operand.operator.type, TokenType.MINUS); |
| 6635 expect(operand.operand, isNotNull); | 6517 expect(operand.operand, isNotNull); |
| 6636 } | 6518 } |
| 6637 | 6519 |
| 6638 void test_parseUnaryExpression_increment_normal() { | 6520 void test_parseUnaryExpression_increment_normal() { |
| 6639 createParser('++x'); | 6521 PrefixExpression expression = parseUnaryExpression('++x'); |
| 6640 PrefixExpression expression = parser.parseUnaryExpression(); | |
| 6641 expect(expression, isNotNull); | 6522 expect(expression, isNotNull); |
| 6642 assertNoErrors(); | 6523 assertNoErrors(); |
| 6643 expect(expression.operator, isNotNull); | 6524 expect(expression.operator, isNotNull); |
| 6644 expect(expression.operator.type, TokenType.PLUS_PLUS); | 6525 expect(expression.operator.type, TokenType.PLUS_PLUS); |
| 6645 expect(expression.operand, isNotNull); | 6526 expect(expression.operand, isNotNull); |
| 6646 } | 6527 } |
| 6647 | 6528 |
| 6648 void test_parseUnaryExpression_increment_super_index() { | 6529 void test_parseUnaryExpression_increment_super_index() { |
| 6649 createParser('++super[0]'); | 6530 PrefixExpression expression = parseUnaryExpression('++super[0]'); |
| 6650 PrefixExpression expression = parser.parseUnaryExpression(); | |
| 6651 expect(expression, isNotNull); | 6531 expect(expression, isNotNull); |
| 6652 assertNoErrors(); | 6532 assertNoErrors(); |
| 6653 expect(expression.operator, isNotNull); | 6533 expect(expression.operator, isNotNull); |
| 6654 expect(expression.operator.type, TokenType.PLUS_PLUS); | 6534 expect(expression.operator.type, TokenType.PLUS_PLUS); |
| 6655 expect(expression.operand, isNotNull); | 6535 expect(expression.operand, isNotNull); |
| 6656 IndexExpression operand = expression.operand as IndexExpression; | 6536 IndexExpression operand = expression.operand as IndexExpression; |
| 6657 expect(operand.realTarget is SuperExpression, isTrue); | 6537 expect(operand.realTarget is SuperExpression, isTrue); |
| 6658 expect(operand.index is IntegerLiteral, isTrue); | 6538 expect(operand.index is IntegerLiteral, isTrue); |
| 6659 } | 6539 } |
| 6660 | 6540 |
| 6661 void test_parseUnaryExpression_increment_super_propertyAccess() { | 6541 void test_parseUnaryExpression_increment_super_propertyAccess() { |
| 6662 createParser('++super.x'); | 6542 PrefixExpression expression = parseUnaryExpression('++super.x'); |
| 6663 PrefixExpression expression = parser.parseUnaryExpression(); | |
| 6664 expect(expression, isNotNull); | 6543 expect(expression, isNotNull); |
| 6665 assertNoErrors(); | 6544 assertNoErrors(); |
| 6666 expect(expression.operator, isNotNull); | 6545 expect(expression.operator, isNotNull); |
| 6667 expect(expression.operator.type, TokenType.PLUS_PLUS); | 6546 expect(expression.operator.type, TokenType.PLUS_PLUS); |
| 6668 expect(expression.operand, isNotNull); | 6547 expect(expression.operand, isNotNull); |
| 6669 PropertyAccess operand = expression.operand as PropertyAccess; | 6548 PropertyAccess operand = expression.operand as PropertyAccess; |
| 6670 expect(operand.target is SuperExpression, isTrue); | 6549 expect(operand.target is SuperExpression, isTrue); |
| 6671 expect(operand.propertyName.name, "x"); | 6550 expect(operand.propertyName.name, "x"); |
| 6672 } | 6551 } |
| 6673 | 6552 |
| 6674 void test_parseUnaryExpression_minus_normal() { | 6553 void test_parseUnaryExpression_minus_normal() { |
| 6675 createParser('-x'); | 6554 PrefixExpression expression = parseUnaryExpression('-x'); |
| 6676 PrefixExpression expression = parser.parseUnaryExpression(); | |
| 6677 expect(expression, isNotNull); | 6555 expect(expression, isNotNull); |
| 6678 assertNoErrors(); | 6556 assertNoErrors(); |
| 6679 expect(expression.operator, isNotNull); | 6557 expect(expression.operator, isNotNull); |
| 6680 expect(expression.operator.type, TokenType.MINUS); | 6558 expect(expression.operator.type, TokenType.MINUS); |
| 6681 expect(expression.operand, isNotNull); | 6559 expect(expression.operand, isNotNull); |
| 6682 } | 6560 } |
| 6683 | 6561 |
| 6684 void test_parseUnaryExpression_minus_super() { | 6562 void test_parseUnaryExpression_minus_super() { |
| 6685 createParser('-super'); | 6563 PrefixExpression expression = parseUnaryExpression('-super'); |
| 6686 PrefixExpression expression = parser.parseUnaryExpression(); | |
| 6687 expect(expression, isNotNull); | 6564 expect(expression, isNotNull); |
| 6688 assertNoErrors(); | 6565 assertNoErrors(); |
| 6689 expect(expression.operator, isNotNull); | 6566 expect(expression.operator, isNotNull); |
| 6690 expect(expression.operator.type, TokenType.MINUS); | 6567 expect(expression.operator.type, TokenType.MINUS); |
| 6691 expect(expression.operand, isNotNull); | 6568 expect(expression.operand, isNotNull); |
| 6692 } | 6569 } |
| 6693 | 6570 |
| 6694 void test_parseUnaryExpression_not_normal() { | 6571 void test_parseUnaryExpression_not_normal() { |
| 6695 createParser('!x'); | 6572 PrefixExpression expression = parseUnaryExpression('!x'); |
| 6696 PrefixExpression expression = parser.parseUnaryExpression(); | |
| 6697 expect(expression, isNotNull); | 6573 expect(expression, isNotNull); |
| 6698 assertNoErrors(); | 6574 assertNoErrors(); |
| 6699 expect(expression.operator, isNotNull); | 6575 expect(expression.operator, isNotNull); |
| 6700 expect(expression.operator.type, TokenType.BANG); | 6576 expect(expression.operator.type, TokenType.BANG); |
| 6701 expect(expression.operand, isNotNull); | 6577 expect(expression.operand, isNotNull); |
| 6702 } | 6578 } |
| 6703 | 6579 |
| 6704 void test_parseUnaryExpression_not_super() { | 6580 void test_parseUnaryExpression_not_super() { |
| 6705 createParser('!super'); | 6581 PrefixExpression expression = parseUnaryExpression('!super'); |
| 6706 PrefixExpression expression = parser.parseUnaryExpression(); | |
| 6707 expect(expression, isNotNull); | 6582 expect(expression, isNotNull); |
| 6708 assertNoErrors(); | 6583 assertNoErrors(); |
| 6709 expect(expression.operator, isNotNull); | 6584 expect(expression.operator, isNotNull); |
| 6710 expect(expression.operator.type, TokenType.BANG); | 6585 expect(expression.operator.type, TokenType.BANG); |
| 6711 expect(expression.operand, isNotNull); | 6586 expect(expression.operand, isNotNull); |
| 6712 } | 6587 } |
| 6713 | 6588 |
| 6714 void test_parseUnaryExpression_tilda_normal() { | 6589 void test_parseUnaryExpression_tilda_normal() { |
| 6715 createParser('~x'); | 6590 PrefixExpression expression = parseUnaryExpression('~x'); |
| 6716 PrefixExpression expression = parser.parseUnaryExpression(); | |
| 6717 expect(expression, isNotNull); | 6591 expect(expression, isNotNull); |
| 6718 assertNoErrors(); | 6592 assertNoErrors(); |
| 6719 expect(expression.operator, isNotNull); | 6593 expect(expression.operator, isNotNull); |
| 6720 expect(expression.operator.type, TokenType.TILDE); | 6594 expect(expression.operator.type, TokenType.TILDE); |
| 6721 expect(expression.operand, isNotNull); | 6595 expect(expression.operand, isNotNull); |
| 6722 } | 6596 } |
| 6723 | 6597 |
| 6724 void test_parseUnaryExpression_tilda_super() { | 6598 void test_parseUnaryExpression_tilda_super() { |
| 6725 createParser('~super'); | 6599 PrefixExpression expression = parseUnaryExpression('~super'); |
| 6726 PrefixExpression expression = parser.parseUnaryExpression(); | |
| 6727 expect(expression, isNotNull); | 6600 expect(expression, isNotNull); |
| 6728 assertNoErrors(); | 6601 assertNoErrors(); |
| 6729 expect(expression.operator, isNotNull); | 6602 expect(expression.operator, isNotNull); |
| 6730 expect(expression.operator.type, TokenType.TILDE); | 6603 expect(expression.operator.type, TokenType.TILDE); |
| 6731 expect(expression.operand, isNotNull); | 6604 expect(expression.operand, isNotNull); |
| 6732 } | 6605 } |
| 6733 } | 6606 } |
| 6734 | 6607 |
| 6735 /** | 6608 /** |
| 6736 * Tests of the analyzer parser based on [FormalParameterParserTestMixin]. | 6609 * Tests of the analyzer parser based on [FormalParameterParserTestMixin]. |
| (...skipping 1241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7978 parser.enableUriInPartOf = enableUriInPartOf; | 7851 parser.enableUriInPartOf = enableUriInPartOf; |
| 7979 parser.currentToken = tokenStream; | 7852 parser.currentToken = tokenStream; |
| 7980 } | 7853 } |
| 7981 | 7854 |
| 7982 void expectNotNullIfNoErrors(Object result) { | 7855 void expectNotNullIfNoErrors(Object result) { |
| 7983 if (!listener.hasErrors) { | 7856 if (!listener.hasErrors) { |
| 7984 expect(result, isNotNull); | 7857 expect(result, isNotNull); |
| 7985 } | 7858 } |
| 7986 } | 7859 } |
| 7987 | 7860 |
| 7861 @override |
| 7862 Expression parseAdditiveExpression(String code) { |
| 7863 createParser(code); |
| 7864 return parser.parseAdditiveExpression(); |
| 7865 } |
| 7866 |
| 7867 @override |
| 7868 Expression parseAssignableExpression(String code, bool primaryAllowed) { |
| 7869 createParser(code); |
| 7870 return parser.parseAssignableExpression(primaryAllowed); |
| 7871 } |
| 7872 |
| 7873 @override |
| 7874 Expression parseAssignableSelector( |
| 7875 String code, Expression prefix, bool optional, |
| 7876 {bool allowConditional: true}) { |
| 7877 createParser(code); |
| 7878 return parser.parseAssignableSelector(prefix, optional, |
| 7879 allowConditional: allowConditional); |
| 7880 } |
| 7881 |
| 7882 @override |
| 7883 AwaitExpression parseAwaitExpression(String code) { |
| 7884 createParser(code); |
| 7885 return parser.parseAwaitExpression(); |
| 7886 } |
| 7887 |
| 7888 @override |
| 7889 Expression parseBitwiseAndExpression(String code) { |
| 7890 createParser(code); |
| 7891 return parser.parseBitwiseAndExpression(); |
| 7892 } |
| 7893 |
| 7894 @override |
| 7895 Expression parseBitwiseOrExpression(String code) { |
| 7896 createParser(code); |
| 7897 return parser.parseBitwiseOrExpression(); |
| 7898 } |
| 7899 |
| 7900 @override |
| 7901 Expression parseBitwiseXorExpression(String code) { |
| 7902 createParser(code); |
| 7903 return parser.parseBitwiseXorExpression(); |
| 7904 } |
| 7905 |
| 7906 @override |
| 7907 Expression parseCascadeSection(String code) { |
| 7908 createParser(code); |
| 7909 return parser.parseCascadeSection(); |
| 7910 } |
| 7911 |
| 7988 /** | 7912 /** |
| 7989 * Parse the given source as a compilation unit. | 7913 * Parse the given source as a compilation unit. |
| 7990 * | 7914 * |
| 7991 * @param source the source to be parsed | 7915 * @param source the source to be parsed |
| 7992 * @param errorCodes the error codes of the errors that are expected to be fou
nd | 7916 * @param errorCodes the error codes of the errors that are expected to be fou
nd |
| 7993 * @return the compilation unit that was parsed | 7917 * @return the compilation unit that was parsed |
| 7994 * @throws Exception if the source could not be parsed, if the compilation err
ors in the source do | 7918 * @throws Exception if the source could not be parsed, if the compilation err
ors in the source do |
| 7995 * not match those that are expected, or if the result would have be
en `null` | 7919 * not match those that are expected, or if the result would have be
en `null` |
| 7996 */ | 7920 */ |
| 7997 CompilationUnit parseCompilationUnit(String source, | 7921 CompilationUnit parseCompilationUnit(String source, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8030 CompilationUnit parseCompilationUnitWithOptions(String source, | 7954 CompilationUnit parseCompilationUnitWithOptions(String source, |
| 8031 [List<ErrorCode> errorCodes = const <ErrorCode>[]]) { | 7955 [List<ErrorCode> errorCodes = const <ErrorCode>[]]) { |
| 8032 createParser(source); | 7956 createParser(source); |
| 8033 CompilationUnit unit = parser.parseCompilationUnit2(); | 7957 CompilationUnit unit = parser.parseCompilationUnit2(); |
| 8034 expect(unit, isNotNull); | 7958 expect(unit, isNotNull); |
| 8035 listener.assertErrorsWithCodes(errorCodes); | 7959 listener.assertErrorsWithCodes(errorCodes); |
| 8036 return unit; | 7960 return unit; |
| 8037 } | 7961 } |
| 8038 | 7962 |
| 8039 @override | 7963 @override |
| 7964 ConditionalExpression parseConditionalExpression(String code) { |
| 7965 createParser(code); |
| 7966 return parser.parseConditionalExpression(); |
| 7967 } |
| 7968 |
| 7969 @override |
| 7970 Expression parseConstExpression(String code) { |
| 7971 createParser(code); |
| 7972 return parser.parseConstExpression(); |
| 7973 } |
| 7974 |
| 7975 @override |
| 8040 CompilationUnit parseDirectives(String source, | 7976 CompilationUnit parseDirectives(String source, |
| 8041 [List<ErrorCode> errorCodes = const <ErrorCode>[]]) { | 7977 [List<ErrorCode> errorCodes = const <ErrorCode>[]]) { |
| 8042 createParser(source); | 7978 createParser(source); |
| 8043 CompilationUnit unit = parser.parseDirectives2(); | 7979 CompilationUnit unit = parser.parseDirectives2(); |
| 8044 expect(unit, isNotNull); | 7980 expect(unit, isNotNull); |
| 8045 expect(unit.declarations, hasLength(0)); | 7981 expect(unit.declarations, hasLength(0)); |
| 8046 listener.assertErrorsWithCodes(errorCodes); | 7982 listener.assertErrorsWithCodes(errorCodes); |
| 8047 return unit; | 7983 return unit; |
| 8048 } | 7984 } |
| 8049 | 7985 |
| 7986 @override |
| 7987 BinaryExpression parseEqualityExpression(String code) { |
| 7988 createParser(code); |
| 7989 return parser.parseEqualityExpression(); |
| 7990 } |
| 7991 |
| 8050 /** | 7992 /** |
| 8051 * Parse the given source as an expression. | 7993 * Parse the given source as an expression. |
| 8052 * | 7994 * |
| 8053 * @param source the source to be parsed | 7995 * @param source the source to be parsed |
| 8054 * @param errorCodes the error codes of the errors that are expected to be fou
nd | 7996 * @param errorCodes the error codes of the errors that are expected to be fou
nd |
| 8055 * @return the expression that was parsed | 7997 * @return the expression that was parsed |
| 8056 * @throws Exception if the source could not be parsed, if the compilation err
ors in the source do | 7998 * @throws Exception if the source could not be parsed, if the compilation err
ors in the source do |
| 8057 * not match those that are expected, or if the result would have be
en `null` | 7999 * not match those that are expected, or if the result would have be
en `null` |
| 8058 */ | 8000 */ |
| 8059 Expression parseExpression(String source, | 8001 Expression parseExpression(String source, |
| 8060 [List<ErrorCode> errorCodes = const <ErrorCode>[]]) { | 8002 [List<ErrorCode> errorCodes = const <ErrorCode>[]]) { |
| 8061 createParser(source); | 8003 createParser(source); |
| 8062 Expression expression = parser.parseExpression2(); | 8004 Expression expression = parser.parseExpression2(); |
| 8063 expectNotNullIfNoErrors(expression); | 8005 expectNotNullIfNoErrors(expression); |
| 8064 listener.assertErrorsWithCodes(errorCodes); | 8006 listener.assertErrorsWithCodes(errorCodes); |
| 8065 return expression; | 8007 return expression; |
| 8066 } | 8008 } |
| 8067 | 8009 |
| 8068 @override | 8010 @override |
| 8011 List<Expression> parseExpressionList(String code) { |
| 8012 createParser(code); |
| 8013 return parser.parseExpressionList(); |
| 8014 } |
| 8015 |
| 8016 @override |
| 8017 Expression parseExpressionWithoutCascade(String code) { |
| 8018 createParser(code); |
| 8019 return parser.parseExpressionWithoutCascade(); |
| 8020 } |
| 8021 |
| 8022 @override |
| 8069 FormalParameter parseFormalParameter(String code, ParameterKind kind, | 8023 FormalParameter parseFormalParameter(String code, ParameterKind kind, |
| 8070 {List<ErrorCode> errorCodes: const <ErrorCode>[]}) { | 8024 {List<ErrorCode> errorCodes: const <ErrorCode>[]}) { |
| 8071 createParser(code); | 8025 createParser(code); |
| 8072 FormalParameter parameter = parser.parseFormalParameter(kind); | 8026 FormalParameter parameter = parser.parseFormalParameter(kind); |
| 8073 assertErrorsWithCodes(errorCodes); | 8027 assertErrorsWithCodes(errorCodes); |
| 8074 return parameter; | 8028 return parameter; |
| 8075 } | 8029 } |
| 8076 | 8030 |
| 8077 @override | 8031 @override |
| 8078 FormalParameterList parseFormalParameterList(String code, | 8032 FormalParameterList parseFormalParameterList(String code, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 8098 | 8052 |
| 8099 /** | 8053 /** |
| 8100 * Parses a variable declaration list (equivalent to a variable declaration | 8054 * Parses a variable declaration list (equivalent to a variable declaration |
| 8101 * statement, but without the final comma). | 8055 * statement, but without the final comma). |
| 8102 */ | 8056 */ |
| 8103 VariableDeclarationList parseFullVariableDeclarationList() => | 8057 VariableDeclarationList parseFullVariableDeclarationList() => |
| 8104 parser.parseVariableDeclarationListAfterMetadata( | 8058 parser.parseVariableDeclarationListAfterMetadata( |
| 8105 parser.parseCommentAndMetadata()); | 8059 parser.parseCommentAndMetadata()); |
| 8106 | 8060 |
| 8107 @override | 8061 @override |
| 8062 FunctionExpression parseFunctionExpression(String code) { |
| 8063 createParser(code); |
| 8064 return parser.parseFunctionExpression(); |
| 8065 } |
| 8066 |
| 8067 @override |
| 8068 InstanceCreationExpression parseInstanceCreationExpression( |
| 8069 String code, Token newToken) { |
| 8070 createParser(code); |
| 8071 return parser.parseInstanceCreationExpression(newToken); |
| 8072 } |
| 8073 |
| 8074 @override |
| 8075 ListLiteral parseListLiteral( |
| 8076 Token token, String typeArgumentsCode, String code) { |
| 8077 TypeArgumentList typeArguments; |
| 8078 if (typeArgumentsCode != null) { |
| 8079 createParser(typeArgumentsCode); |
| 8080 typeArguments = parser.parseTypeArgumentList(); |
| 8081 } |
| 8082 createParser(code); |
| 8083 return parser.parseListLiteral(token, typeArguments); |
| 8084 } |
| 8085 |
| 8086 @override |
| 8087 TypedLiteral parseListOrMapLiteral(Token modifier, String code) { |
| 8088 createParser(code); |
| 8089 return parser.parseListOrMapLiteral(modifier); |
| 8090 } |
| 8091 |
| 8092 @override |
| 8093 Expression parseLogicalAndExpression(String code) { |
| 8094 createParser(code); |
| 8095 return parser.parseLogicalAndExpression(); |
| 8096 } |
| 8097 |
| 8098 @override |
| 8099 Expression parseLogicalOrExpression(String code) { |
| 8100 createParser(code); |
| 8101 return parser.parseLogicalOrExpression(); |
| 8102 } |
| 8103 |
| 8104 @override |
| 8105 MapLiteral parseMapLiteral( |
| 8106 Token token, String typeArgumentsCode, String code) { |
| 8107 TypeArgumentList typeArguments; |
| 8108 if (typeArgumentsCode != null) { |
| 8109 createParser(typeArgumentsCode); |
| 8110 typeArguments = parser.parseTypeArgumentList(); |
| 8111 } |
| 8112 createParser(code); |
| 8113 return parser.parseMapLiteral(token, typeArguments); |
| 8114 } |
| 8115 |
| 8116 @override |
| 8117 MapLiteralEntry parseMapLiteralEntry(String code) { |
| 8118 createParser(code); |
| 8119 return parser.parseMapLiteralEntry(); |
| 8120 } |
| 8121 |
| 8122 @override |
| 8123 Expression parseMultiplicativeExpression(String code) { |
| 8124 createParser(code); |
| 8125 return parser.parseMultiplicativeExpression(); |
| 8126 } |
| 8127 |
| 8128 @override |
| 8129 InstanceCreationExpression parseNewExpression(String code) { |
| 8130 createParser(code); |
| 8131 return parser.parseNewExpression(); |
| 8132 } |
| 8133 |
| 8134 @override |
| 8108 NormalFormalParameter parseNormalFormalParameter(String code, | 8135 NormalFormalParameter parseNormalFormalParameter(String code, |
| 8109 {bool inFunctionType: false, | 8136 {bool inFunctionType: false, |
| 8110 List<ErrorCode> errorCodes: const <ErrorCode>[]}) { | 8137 List<ErrorCode> errorCodes: const <ErrorCode>[]}) { |
| 8111 createParser(code); | 8138 createParser(code); |
| 8112 FormalParameter parameter = | 8139 FormalParameter parameter = |
| 8113 parser.parseNormalFormalParameter(inFunctionType: inFunctionType); | 8140 parser.parseNormalFormalParameter(inFunctionType: inFunctionType); |
| 8114 assertErrorsWithCodes(errorCodes); | 8141 assertErrorsWithCodes(errorCodes); |
| 8115 return parameter; | 8142 return parameter; |
| 8116 } | 8143 } |
| 8117 | 8144 |
| 8145 @override |
| 8146 Expression parsePostfixExpression(String code) { |
| 8147 createParser(code); |
| 8148 return parser.parsePostfixExpression(); |
| 8149 } |
| 8150 |
| 8151 @override |
| 8152 Identifier parsePrefixedIdentifier(String code) { |
| 8153 createParser(code); |
| 8154 return parser.parsePrefixedIdentifier(); |
| 8155 } |
| 8156 |
| 8157 @override |
| 8158 Expression parsePrimaryExpression(String code) { |
| 8159 createParser(code); |
| 8160 return parser.parsePrimaryExpression(); |
| 8161 } |
| 8162 |
| 8163 @override |
| 8164 Expression parseRelationalExpression(String code) { |
| 8165 createParser(code); |
| 8166 return parser.parseRelationalExpression(); |
| 8167 } |
| 8168 |
| 8169 @override |
| 8170 RethrowExpression parseRethrowExpression(String code) { |
| 8171 createParser(code); |
| 8172 return parser.parseRethrowExpression(); |
| 8173 } |
| 8174 |
| 8175 @override |
| 8176 BinaryExpression parseShiftExpression(String code) { |
| 8177 createParser(code); |
| 8178 return parser.parseShiftExpression(); |
| 8179 } |
| 8180 |
| 8181 @override |
| 8182 SimpleIdentifier parseSimpleIdentifier(String code) { |
| 8183 createParser(code); |
| 8184 return parser.parseSimpleIdentifier(); |
| 8185 } |
| 8186 |
| 8118 /** | 8187 /** |
| 8119 * Parse the given [source] as a statement. The [errorCodes] are the error | 8188 * Parse the given [source] as a statement. The [errorCodes] are the error |
| 8120 * codes of the errors that are expected to be found. If | 8189 * codes of the errors that are expected to be found. If |
| 8121 * [enableLazyAssignmentOperators] is `true`, then lazy assignment operators | 8190 * [enableLazyAssignmentOperators] is `true`, then lazy assignment operators |
| 8122 * should be enabled. | 8191 * should be enabled. |
| 8123 */ | 8192 */ |
| 8124 Statement parseStatement(String source, | 8193 Statement parseStatement(String source, |
| 8125 [List<ErrorCode> errorCodes = const <ErrorCode>[], | 8194 [List<ErrorCode> errorCodes = const <ErrorCode>[], |
| 8126 bool enableLazyAssignmentOperators]) { | 8195 bool enableLazyAssignmentOperators]) { |
| 8127 GatheringErrorListener listener = new GatheringErrorListener(); | 8196 GatheringErrorListener listener = new GatheringErrorListener(); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 8156 listener.setLineInfo(new TestSource(), scanner.lineStarts); | 8225 listener.setLineInfo(new TestSource(), scanner.lineStarts); |
| 8157 Token token = scanner.tokenize(); | 8226 Token token = scanner.tokenize(); |
| 8158 Parser parser = new Parser(null, listener); | 8227 Parser parser = new Parser(null, listener); |
| 8159 List<Statement> statements = parser.parseStatements(token); | 8228 List<Statement> statements = parser.parseStatements(token); |
| 8160 expect(statements, hasLength(expectedCount)); | 8229 expect(statements, hasLength(expectedCount)); |
| 8161 listener.assertErrorsWithCodes(errorCodes); | 8230 listener.assertErrorsWithCodes(errorCodes); |
| 8162 return statements; | 8231 return statements; |
| 8163 } | 8232 } |
| 8164 | 8233 |
| 8165 @override | 8234 @override |
| 8235 Expression parseStringLiteral(String code) { |
| 8236 createParser(code); |
| 8237 return parser.parseStringLiteral(); |
| 8238 } |
| 8239 |
| 8240 @override |
| 8241 SuperConstructorInvocation parseSuperConstructorInvocation(String code) { |
| 8242 createParser(code); |
| 8243 return parser.parseSuperConstructorInvocation(); |
| 8244 } |
| 8245 |
| 8246 @override |
| 8247 SymbolLiteral parseSymbolLiteral(String code) { |
| 8248 createParser(code); |
| 8249 return parser.parseSymbolLiteral(); |
| 8250 } |
| 8251 |
| 8252 @override |
| 8253 Expression parseThrowExpression(String code) { |
| 8254 createParser(code); |
| 8255 return parser.parseThrowExpression(); |
| 8256 } |
| 8257 |
| 8258 @override |
| 8259 Expression parseThrowExpressionWithoutCascade(String code) { |
| 8260 createParser(code); |
| 8261 return parser.parseThrowExpressionWithoutCascade(); |
| 8262 } |
| 8263 |
| 8264 @override |
| 8265 PrefixExpression parseUnaryExpression(String code) { |
| 8266 createParser(code); |
| 8267 return parser.parseUnaryExpression(); |
| 8268 } |
| 8269 |
| 8270 @override |
| 8166 void setUp() { | 8271 void setUp() { |
| 8167 super.setUp(); | 8272 super.setUp(); |
| 8168 parseFunctionBodies = true; | 8273 parseFunctionBodies = true; |
| 8169 } | 8274 } |
| 8170 } | 8275 } |
| 8171 | 8276 |
| 8172 /** | 8277 /** |
| 8173 * Helper methods that aid in parser tests. | 8278 * Helper methods that aid in parser tests. |
| 8174 * | 8279 * |
| 8175 * Intended to be mixed in to parser test case classes. | 8280 * Intended to be mixed in to parser test case classes. |
| (...skipping 1086 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9262 void test_prefixExpression_missing_operand_minus() { | 9367 void test_prefixExpression_missing_operand_minus() { |
| 9263 PrefixExpression expression = | 9368 PrefixExpression expression = |
| 9264 parseExpression("-", [ParserErrorCode.MISSING_IDENTIFIER]); | 9369 parseExpression("-", [ParserErrorCode.MISSING_IDENTIFIER]); |
| 9265 EngineTestCase.assertInstanceOf( | 9370 EngineTestCase.assertInstanceOf( |
| 9266 (obj) => obj is SimpleIdentifier, SimpleIdentifier, expression.operand); | 9371 (obj) => obj is SimpleIdentifier, SimpleIdentifier, expression.operand); |
| 9267 expect(expression.operand.isSynthetic, isTrue); | 9372 expect(expression.operand.isSynthetic, isTrue); |
| 9268 expect(expression.operator.type, TokenType.MINUS); | 9373 expect(expression.operator.type, TokenType.MINUS); |
| 9269 } | 9374 } |
| 9270 | 9375 |
| 9271 void test_primaryExpression_argumentDefinitionTest() { | 9376 void test_primaryExpression_argumentDefinitionTest() { |
| 9272 createParser('?a'); | 9377 Expression expression = parsePrimaryExpression('?a'); |
| 9273 Expression expression = parser.parsePrimaryExpression(); | |
| 9274 expectNotNullIfNoErrors(expression); | 9378 expectNotNullIfNoErrors(expression); |
| 9275 listener.assertErrorsWithCodes([ParserErrorCode.UNEXPECTED_TOKEN]); | 9379 listener.assertErrorsWithCodes([ParserErrorCode.UNEXPECTED_TOKEN]); |
| 9276 expect(expression, new isInstanceOf<SimpleIdentifier>()); | 9380 expect(expression, new isInstanceOf<SimpleIdentifier>()); |
| 9277 } | 9381 } |
| 9278 | 9382 |
| 9279 void test_relationalExpression_missing_LHS() { | 9383 void test_relationalExpression_missing_LHS() { |
| 9280 IsExpression expression = | 9384 IsExpression expression = |
| 9281 parseExpression("is y", [ParserErrorCode.MISSING_IDENTIFIER]); | 9385 parseExpression("is y", [ParserErrorCode.MISSING_IDENTIFIER]); |
| 9282 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 9386 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
| 9283 SimpleIdentifier, expression.expression); | 9387 SimpleIdentifier, expression.expression); |
| (...skipping 5341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14625 expect(typeAlias.name, isNotNull); | 14729 expect(typeAlias.name, isNotNull); |
| 14626 expect(typeAlias.typeParameters, isNull); | 14730 expect(typeAlias.typeParameters, isNull); |
| 14627 expect(typeAlias.semicolon, isNotNull); | 14731 expect(typeAlias.semicolon, isNotNull); |
| 14628 GenericFunctionType functionType = typeAlias.functionType; | 14732 GenericFunctionType functionType = typeAlias.functionType; |
| 14629 expect(functionType, isNotNull); | 14733 expect(functionType, isNotNull); |
| 14630 expect(functionType.parameters, isNotNull); | 14734 expect(functionType.parameters, isNotNull); |
| 14631 expect(functionType.returnType, isNotNull); | 14735 expect(functionType.returnType, isNotNull); |
| 14632 expect(functionType.typeParameters, isNull); | 14736 expect(functionType.typeParameters, isNull); |
| 14633 } | 14737 } |
| 14634 } | 14738 } |
| OLD | NEW |