| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library analyzer.test.generated.parser_test; | 5 library analyzer.test.generated.parser_test; |
| 6 | 6 |
| 7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
| 8 import 'package:analyzer/dart/ast/token.dart'; | 8 import 'package:analyzer/dart/ast/token.dart'; |
| 9 import 'package:analyzer/dart/ast/visitor.dart'; | 9 import 'package:analyzer/dart/ast/visitor.dart'; |
| 10 import 'package:analyzer/src/dart/ast/token.dart'; | 10 import 'package:analyzer/src/dart/ast/token.dart'; |
| (...skipping 1198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1209 void test_externalSetterWithBody() { | 1209 void test_externalSetterWithBody() { |
| 1210 parse3("parseClassMember", <Object>["C"], "external set x(int value) {}", | 1210 parse3("parseClassMember", <Object>["C"], "external set x(int value) {}", |
| 1211 [ParserErrorCode.EXTERNAL_SETTER_WITH_BODY]); | 1211 [ParserErrorCode.EXTERNAL_SETTER_WITH_BODY]); |
| 1212 } | 1212 } |
| 1213 | 1213 |
| 1214 void test_externalTypedef() { | 1214 void test_externalTypedef() { |
| 1215 ParserTestCase.parseCompilationUnit( | 1215 ParserTestCase.parseCompilationUnit( |
| 1216 "external typedef F();", [ParserErrorCode.EXTERNAL_TYPEDEF]); | 1216 "external typedef F();", [ParserErrorCode.EXTERNAL_TYPEDEF]); |
| 1217 } | 1217 } |
| 1218 | 1218 |
| 1219 void test_extraCommaInParameterList() { |
| 1220 parseTrailingCommas = true; |
| 1221 parse4("parseFormalParameterList", "(int a, , int b)", |
| 1222 [ParserErrorCode.MISSING_IDENTIFIER, ParserErrorCode.EXPECTED_TOKEN]); |
| 1223 parseTrailingCommas = false; |
| 1224 parse4("parseFormalParameterList", "(int a, , int b)", |
| 1225 [ParserErrorCode.MISSING_IDENTIFIER, ParserErrorCode.EXPECTED_TOKEN]); |
| 1226 } |
| 1227 |
| 1228 void test_extraCommaTrailingNamedParameterGroup() { |
| 1229 parseTrailingCommas = true; |
| 1230 parse4("parseFormalParameterList", "({int b},)", [ |
| 1231 ParserErrorCode.MISSING_IDENTIFIER, |
| 1232 ParserErrorCode.NORMAL_BEFORE_OPTIONAL_PARAMETERS |
| 1233 ]); |
| 1234 parseTrailingCommas = false; |
| 1235 parse4("parseFormalParameterList", "({int b},)", [ |
| 1236 ParserErrorCode.MISSING_IDENTIFIER, |
| 1237 ParserErrorCode.NORMAL_BEFORE_OPTIONAL_PARAMETERS |
| 1238 ]); |
| 1239 } |
| 1240 |
| 1241 void test_extraCommaTrailingPositionalParameterGroup() { |
| 1242 parseTrailingCommas = true; |
| 1243 parse4("parseFormalParameterList", "([int b],)", [ |
| 1244 ParserErrorCode.MISSING_IDENTIFIER, |
| 1245 ParserErrorCode.NORMAL_BEFORE_OPTIONAL_PARAMETERS |
| 1246 ]); |
| 1247 parseTrailingCommas = false; |
| 1248 parse4("parseFormalParameterList", "([int b],)", [ |
| 1249 ParserErrorCode.MISSING_IDENTIFIER, |
| 1250 ParserErrorCode.NORMAL_BEFORE_OPTIONAL_PARAMETERS |
| 1251 ]); |
| 1252 } |
| 1253 |
| 1254 void test_extraTrailingCommaInParameterList() { |
| 1255 parseTrailingCommas = true; |
| 1256 parse4("parseFormalParameterList", "(a,,)", |
| 1257 [ParserErrorCode.MISSING_IDENTIFIER]); |
| 1258 parseTrailingCommas = false; |
| 1259 parse4("parseFormalParameterList", "(a,,)", |
| 1260 [ParserErrorCode.MISSING_IDENTIFIER, ParserErrorCode.EXPECTED_TOKEN]); |
| 1261 } |
| 1262 |
| 1219 void test_factoryTopLevelDeclaration_class() { | 1263 void test_factoryTopLevelDeclaration_class() { |
| 1220 ParserTestCase.parseCompilationUnit( | 1264 ParserTestCase.parseCompilationUnit( |
| 1221 "factory class C {}", [ParserErrorCode.FACTORY_TOP_LEVEL_DECLARATION]); | 1265 "factory class C {}", [ParserErrorCode.FACTORY_TOP_LEVEL_DECLARATION]); |
| 1222 } | 1266 } |
| 1223 | 1267 |
| 1224 void test_factoryTopLevelDeclaration_typedef() { | 1268 void test_factoryTopLevelDeclaration_typedef() { |
| 1225 ParserTestCase.parseCompilationUnit("factory typedef F();", | 1269 ParserTestCase.parseCompilationUnit("factory typedef F();", |
| 1226 [ParserErrorCode.FACTORY_TOP_LEVEL_DECLARATION]); | 1270 [ParserErrorCode.FACTORY_TOP_LEVEL_DECLARATION]); |
| 1227 } | 1271 } |
| 1228 | 1272 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1315 void test_illegalAssignmentToNonAssignable_postfix_minusMinus_literal() { | 1359 void test_illegalAssignmentToNonAssignable_postfix_minusMinus_literal() { |
| 1316 parseExpression( | 1360 parseExpression( |
| 1317 "0--", [ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE]); | 1361 "0--", [ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE]); |
| 1318 } | 1362 } |
| 1319 | 1363 |
| 1320 void test_illegalAssignmentToNonAssignable_postfix_plusPlus_literal() { | 1364 void test_illegalAssignmentToNonAssignable_postfix_plusPlus_literal() { |
| 1321 parseExpression( | 1365 parseExpression( |
| 1322 "0++", [ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE]); | 1366 "0++", [ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE]); |
| 1323 } | 1367 } |
| 1324 | 1368 |
| 1325 void test_illegalAssignmentToNonAssignable_postfix_plusPlus_parethesized() { | 1369 void test_illegalAssignmentToNonAssignable_postfix_plusPlus_parenthesized() { |
| 1326 parseExpression( | 1370 parseExpression( |
| 1327 "(x)++", [ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE]); | 1371 "(x)++", [ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE]); |
| 1328 } | 1372 } |
| 1329 | 1373 |
| 1330 void test_illegalAssignmentToNonAssignable_primarySelectorPostfix() { | 1374 void test_illegalAssignmentToNonAssignable_primarySelectorPostfix() { |
| 1331 parseExpression( | 1375 parseExpression( |
| 1332 "x(y)(z)++", [ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE]); | 1376 "x(y)(z)++", [ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE]); |
| 1333 } | 1377 } |
| 1334 | 1378 |
| 1335 void test_illegalAssignmentToNonAssignable_superAssigned() { | 1379 void test_illegalAssignmentToNonAssignable_superAssigned() { |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1708 void test_missingIdentifier_inSymbol_first() { | 1752 void test_missingIdentifier_inSymbol_first() { |
| 1709 parse4("parseSymbolLiteral", "#", [ParserErrorCode.MISSING_IDENTIFIER]); | 1753 parse4("parseSymbolLiteral", "#", [ParserErrorCode.MISSING_IDENTIFIER]); |
| 1710 } | 1754 } |
| 1711 | 1755 |
| 1712 void test_missingIdentifier_number() { | 1756 void test_missingIdentifier_number() { |
| 1713 SimpleIdentifier expression = parse4( | 1757 SimpleIdentifier expression = parse4( |
| 1714 "parseSimpleIdentifier", "1", [ParserErrorCode.MISSING_IDENTIFIER]); | 1758 "parseSimpleIdentifier", "1", [ParserErrorCode.MISSING_IDENTIFIER]); |
| 1715 expect(expression.isSynthetic, isTrue); | 1759 expect(expression.isSynthetic, isTrue); |
| 1716 } | 1760 } |
| 1717 | 1761 |
| 1762 void test_missingIdentifierForParameterGroup() { |
| 1763 parseTrailingCommas = true; |
| 1764 parse4("parseFormalParameterList", "(,)", |
| 1765 [ParserErrorCode.MISSING_IDENTIFIER]); |
| 1766 } |
| 1767 |
| 1718 void test_missingKeywordOperator() { | 1768 void test_missingKeywordOperator() { |
| 1719 parse3("parseOperator", <Object>[emptyCommentAndMetadata(), null, null], | 1769 parse3("parseOperator", <Object>[emptyCommentAndMetadata(), null, null], |
| 1720 "+(x) {}", [ParserErrorCode.MISSING_KEYWORD_OPERATOR]); | 1770 "+(x) {}", [ParserErrorCode.MISSING_KEYWORD_OPERATOR]); |
| 1721 } | 1771 } |
| 1722 | 1772 |
| 1723 void test_missingKeywordOperator_parseClassMember() { | 1773 void test_missingKeywordOperator_parseClassMember() { |
| 1724 parse3("parseClassMember", <Object>["C"], "+() {}", | 1774 parse3("parseClassMember", <Object>["C"], "+() {}", |
| 1725 [ParserErrorCode.MISSING_KEYWORD_OPERATOR]); | 1775 [ParserErrorCode.MISSING_KEYWORD_OPERATOR]); |
| 1726 } | 1776 } |
| 1727 | 1777 |
| (...skipping 1042 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2770 * specific test. | 2820 * specific test. |
| 2771 */ | 2821 */ |
| 2772 bool enableGenericMethods = false; | 2822 bool enableGenericMethods = false; |
| 2773 | 2823 |
| 2774 /** | 2824 /** |
| 2775 * Whether generic method comments should be enabled for the test. | 2825 * Whether generic method comments should be enabled for the test. |
| 2776 */ | 2826 */ |
| 2777 bool enableGenericMethodComments = false; | 2827 bool enableGenericMethodComments = false; |
| 2778 | 2828 |
| 2779 /** | 2829 /** |
| 2830 * A flag indicating whether parsing trailing commas in parameter and argument |
| 2831 * lists should be enabled for this test. |
| 2832 */ |
| 2833 bool parseTrailingCommas = false; |
| 2834 |
| 2835 /** |
| 2780 * Return a CommentAndMetadata object with the given values that can be used f
or testing. | 2836 * Return a CommentAndMetadata object with the given values that can be used f
or testing. |
| 2781 * | 2837 * |
| 2782 * @param comment the comment to be wrapped in the object | 2838 * @param comment the comment to be wrapped in the object |
| 2783 * @param annotations the annotations to be wrapped in the object | 2839 * @param annotations the annotations to be wrapped in the object |
| 2784 * @return a CommentAndMetadata object that can be used for testing | 2840 * @return a CommentAndMetadata object that can be used for testing |
| 2785 */ | 2841 */ |
| 2786 CommentAndMetadata commentAndMetadata(Comment comment, | 2842 CommentAndMetadata commentAndMetadata(Comment comment, |
| 2787 [List<Annotation> annotations]) { | 2843 [List<Annotation> annotations]) { |
| 2788 return new CommentAndMetadata(comment, annotations); | 2844 return new CommentAndMetadata(comment, annotations); |
| 2789 } | 2845 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2823 Token tokenStream = scanner.tokenize(); | 2879 Token tokenStream = scanner.tokenize(); |
| 2824 listener.setLineInfo(new TestSource(), scanner.lineStarts); | 2880 listener.setLineInfo(new TestSource(), scanner.lineStarts); |
| 2825 // | 2881 // |
| 2826 // Parse the source. | 2882 // Parse the source. |
| 2827 // | 2883 // |
| 2828 Parser parser = createParser(listener); | 2884 Parser parser = createParser(listener); |
| 2829 parser.parseAsync = parseAsync; | 2885 parser.parseAsync = parseAsync; |
| 2830 parser.parseGenericMethods = enableGenericMethods; | 2886 parser.parseGenericMethods = enableGenericMethods; |
| 2831 parser.parseGenericMethodComments = enableGenericMethodComments; | 2887 parser.parseGenericMethodComments = enableGenericMethodComments; |
| 2832 parser.parseFunctionBodies = parseFunctionBodies; | 2888 parser.parseFunctionBodies = parseFunctionBodies; |
| 2889 parser.parseTrailingCommas = parseTrailingCommas; |
| 2833 Object result = | 2890 Object result = |
| 2834 invokeParserMethodImpl(parser, methodName, objects, tokenStream); | 2891 invokeParserMethodImpl(parser, methodName, objects, tokenStream); |
| 2835 // | 2892 // |
| 2836 // Partially test the results. | 2893 // Partially test the results. |
| 2837 // | 2894 // |
| 2838 if (!listener.hasErrors) { | 2895 if (!listener.hasErrors) { |
| 2839 expect(result, isNotNull); | 2896 expect(result, isNotNull); |
| 2840 } | 2897 } |
| 2841 return result; | 2898 return result; |
| 2842 } | 2899 } |
| (...skipping 1905 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4748 NodeList<Expression> arguments = argumentList.arguments; | 4805 NodeList<Expression> arguments = argumentList.arguments; |
| 4749 expect(arguments, hasLength(3)); | 4806 expect(arguments, hasLength(3)); |
| 4750 } | 4807 } |
| 4751 | 4808 |
| 4752 void test_parseArgumentList_onlyNamed() { | 4809 void test_parseArgumentList_onlyNamed() { |
| 4753 ArgumentList argumentList = parse4("parseArgumentList", "(x: x, y: y)"); | 4810 ArgumentList argumentList = parse4("parseArgumentList", "(x: x, y: y)"); |
| 4754 NodeList<Expression> arguments = argumentList.arguments; | 4811 NodeList<Expression> arguments = argumentList.arguments; |
| 4755 expect(arguments, hasLength(2)); | 4812 expect(arguments, hasLength(2)); |
| 4756 } | 4813 } |
| 4757 | 4814 |
| 4815 void test_parseArgumentList_trailing_comma() { |
| 4816 parseTrailingCommas = true; |
| 4817 ArgumentList argumentList = parse4("parseArgumentList", "(x, y, z,)"); |
| 4818 NodeList<Expression> arguments = argumentList.arguments; |
| 4819 expect(arguments, hasLength(3)); |
| 4820 } |
| 4821 |
| 4758 void test_parseAssertStatement() { | 4822 void test_parseAssertStatement() { |
| 4759 AssertStatement statement = parse4("parseAssertStatement", "assert (x);"); | 4823 AssertStatement statement = parse4("parseAssertStatement", "assert (x);"); |
| 4760 expect(statement.assertKeyword, isNotNull); | 4824 expect(statement.assertKeyword, isNotNull); |
| 4761 expect(statement.leftParenthesis, isNotNull); | 4825 expect(statement.leftParenthesis, isNotNull); |
| 4762 expect(statement.condition, isNotNull); | 4826 expect(statement.condition, isNotNull); |
| 4763 expect(statement.comma, isNull); | 4827 expect(statement.comma, isNull); |
| 4764 expect(statement.message, isNull); | 4828 expect(statement.message, isNull); |
| 4765 expect(statement.rightParenthesis, isNotNull); | 4829 expect(statement.rightParenthesis, isNotNull); |
| 4766 expect(statement.semicolon, isNotNull); | 4830 expect(statement.semicolon, isNotNull); |
| 4767 } | 4831 } |
| (...skipping 1162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5930 expect(method.modifierKeyword, isNull); | 5994 expect(method.modifierKeyword, isNull); |
| 5931 expect(method.propertyKeyword, isNull); | 5995 expect(method.propertyKeyword, isNull); |
| 5932 expect(method.returnType, isNotNull); | 5996 expect(method.returnType, isNotNull); |
| 5933 expect(method.name, isNotNull); | 5997 expect(method.name, isNotNull); |
| 5934 expect(method.operatorKeyword, isNull); | 5998 expect(method.operatorKeyword, isNull); |
| 5935 expect(method.typeParameters, isNull); | 5999 expect(method.typeParameters, isNull); |
| 5936 expect(method.parameters, isNotNull); | 6000 expect(method.parameters, isNotNull); |
| 5937 expect(method.body, isNotNull); | 6001 expect(method.body, isNotNull); |
| 5938 } | 6002 } |
| 5939 | 6003 |
| 6004 void test_parseClassMember_method_trailing_commas() { |
| 6005 parseTrailingCommas = true; |
| 6006 MethodDeclaration method = |
| 6007 parse("parseClassMember", <Object>["C"], "void f(int x, int y,) {}"); |
| 6008 expect(method.documentationComment, isNull); |
| 6009 expect(method.externalKeyword, isNull); |
| 6010 expect(method.modifierKeyword, isNull); |
| 6011 expect(method.propertyKeyword, isNull); |
| 6012 expect(method.returnType, isNotNull); |
| 6013 expect(method.name, isNotNull); |
| 6014 expect(method.operatorKeyword, isNull); |
| 6015 expect(method.typeParameters, isNull); |
| 6016 expect(method.parameters, isNotNull); |
| 6017 expect(method.body, isNotNull); |
| 6018 } |
| 6019 |
| 5940 void test_parseClassMember_operator_index() { | 6020 void test_parseClassMember_operator_index() { |
| 5941 MethodDeclaration method = | 6021 MethodDeclaration method = |
| 5942 parse("parseClassMember", <Object>["C"], "int operator [](int i) {}"); | 6022 parse("parseClassMember", <Object>["C"], "int operator [](int i) {}"); |
| 5943 expect(method.documentationComment, isNull); | 6023 expect(method.documentationComment, isNull); |
| 5944 expect(method.externalKeyword, isNull); | 6024 expect(method.externalKeyword, isNull); |
| 5945 expect(method.modifierKeyword, isNull); | 6025 expect(method.modifierKeyword, isNull); |
| 5946 expect(method.propertyKeyword, isNull); | 6026 expect(method.propertyKeyword, isNull); |
| 5947 expect(method.returnType, isNotNull); | 6027 expect(method.returnType, isNotNull); |
| 5948 expect(method.name, isNotNull); | 6028 expect(method.name, isNotNull); |
| 5949 expect(method.operatorKeyword, isNotNull); | 6029 expect(method.operatorKeyword, isNotNull); |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6320 expect(reference.identifier.isSynthetic, isTrue); | 6400 expect(reference.identifier.isSynthetic, isTrue); |
| 6321 expect(reference.identifier.name, ""); | 6401 expect(reference.identifier.name, ""); |
| 6322 // Should end with EOF token. | 6402 // Should end with EOF token. |
| 6323 Token nextToken = referenceToken.next; | 6403 Token nextToken = referenceToken.next; |
| 6324 expect(nextToken, isNotNull); | 6404 expect(nextToken, isNotNull); |
| 6325 expect(nextToken.type, TokenType.EOF); | 6405 expect(nextToken.type, TokenType.EOF); |
| 6326 } | 6406 } |
| 6327 | 6407 |
| 6328 void test_parseCommentReferences_notClosed_withIdentifier() { | 6408 void test_parseCommentReferences_notClosed_withIdentifier() { |
| 6329 DocumentationCommentToken docToken = new DocumentationCommentToken( | 6409 DocumentationCommentToken docToken = new DocumentationCommentToken( |
| 6330 TokenType.MULTI_LINE_COMMENT, "/** [namePrefix some text", 5); | 6410 TokenType.MULTI_LINE_COMMENT, "/** [namePrefix some text", 5); |
| 6331 List<CommentReference> references = | 6411 List<CommentReference> references = parse( |
| 6332 parse("parseCommentReferences", <Object>[<DocumentationCommentToken>[ | 6412 "parseCommentReferences", |
| 6333 docToken | 6413 <Object>[ |
| 6334 ]], "") | 6414 <DocumentationCommentToken>[docToken] |
| 6335 as List<CommentReference>; | 6415 ], |
| 6416 "") as List<CommentReference>; |
| 6336 expect(docToken.references, hasLength(1)); | 6417 expect(docToken.references, hasLength(1)); |
| 6337 expect(references, hasLength(1)); | 6418 expect(references, hasLength(1)); |
| 6338 Token referenceToken = docToken.references[0]; | 6419 Token referenceToken = docToken.references[0]; |
| 6339 CommentReference reference = references[0]; | 6420 CommentReference reference = references[0]; |
| 6340 expect(reference, isNotNull); | 6421 expect(reference, isNotNull); |
| 6341 expect(referenceToken, same(reference.beginToken)); | 6422 expect(referenceToken, same(reference.beginToken)); |
| 6342 expect(reference.identifier, isNotNull); | 6423 expect(reference.identifier, isNotNull); |
| 6343 expect(reference.identifier.isSynthetic, isFalse); | 6424 expect(reference.identifier.isSynthetic, isFalse); |
| 6344 expect(reference.identifier.name, "namePrefix"); | 6425 expect(reference.identifier.name, "namePrefix"); |
| 6345 // Should end with EOF token. | 6426 // Should end with EOF token. |
| (...skipping 1424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7770 void test_parseFormalParameterList_named_single() { | 7851 void test_parseFormalParameterList_named_single() { |
| 7771 FormalParameterList parameterList = | 7852 FormalParameterList parameterList = |
| 7772 parse4("parseFormalParameterList", "({A a})"); | 7853 parse4("parseFormalParameterList", "({A a})"); |
| 7773 expect(parameterList.leftParenthesis, isNotNull); | 7854 expect(parameterList.leftParenthesis, isNotNull); |
| 7774 expect(parameterList.leftDelimiter, isNotNull); | 7855 expect(parameterList.leftDelimiter, isNotNull); |
| 7775 expect(parameterList.parameters, hasLength(1)); | 7856 expect(parameterList.parameters, hasLength(1)); |
| 7776 expect(parameterList.rightDelimiter, isNotNull); | 7857 expect(parameterList.rightDelimiter, isNotNull); |
| 7777 expect(parameterList.rightParenthesis, isNotNull); | 7858 expect(parameterList.rightParenthesis, isNotNull); |
| 7778 } | 7859 } |
| 7779 | 7860 |
| 7861 void test_parseFormalParameterList_named_trailing_comma() { |
| 7862 parseTrailingCommas = true; |
| 7863 FormalParameterList parameterList = |
| 7864 parse4("parseFormalParameterList", "(A a, {B b,})"); |
| 7865 expect(parameterList.leftParenthesis, isNotNull); |
| 7866 expect(parameterList.leftDelimiter, isNotNull); |
| 7867 expect(parameterList.parameters, hasLength(2)); |
| 7868 expect(parameterList.rightDelimiter, isNotNull); |
| 7869 expect(parameterList.rightParenthesis, isNotNull); |
| 7870 } |
| 7871 |
| 7780 void test_parseFormalParameterList_normal_multiple() { | 7872 void test_parseFormalParameterList_normal_multiple() { |
| 7781 FormalParameterList parameterList = | 7873 FormalParameterList parameterList = |
| 7782 parse4("parseFormalParameterList", "(A a, B b, C c)"); | 7874 parse4("parseFormalParameterList", "(A a, B b, C c)"); |
| 7783 expect(parameterList.leftParenthesis, isNotNull); | 7875 expect(parameterList.leftParenthesis, isNotNull); |
| 7784 expect(parameterList.leftDelimiter, isNull); | 7876 expect(parameterList.leftDelimiter, isNull); |
| 7785 expect(parameterList.parameters, hasLength(3)); | 7877 expect(parameterList.parameters, hasLength(3)); |
| 7786 expect(parameterList.rightDelimiter, isNull); | 7878 expect(parameterList.rightDelimiter, isNull); |
| 7787 expect(parameterList.rightParenthesis, isNotNull); | 7879 expect(parameterList.rightParenthesis, isNotNull); |
| 7788 } | 7880 } |
| 7789 | 7881 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 7810 void test_parseFormalParameterList_normal_single() { | 7902 void test_parseFormalParameterList_normal_single() { |
| 7811 FormalParameterList parameterList = | 7903 FormalParameterList parameterList = |
| 7812 parse4("parseFormalParameterList", "(A a)"); | 7904 parse4("parseFormalParameterList", "(A a)"); |
| 7813 expect(parameterList.leftParenthesis, isNotNull); | 7905 expect(parameterList.leftParenthesis, isNotNull); |
| 7814 expect(parameterList.leftDelimiter, isNull); | 7906 expect(parameterList.leftDelimiter, isNull); |
| 7815 expect(parameterList.parameters, hasLength(1)); | 7907 expect(parameterList.parameters, hasLength(1)); |
| 7816 expect(parameterList.rightDelimiter, isNull); | 7908 expect(parameterList.rightDelimiter, isNull); |
| 7817 expect(parameterList.rightParenthesis, isNotNull); | 7909 expect(parameterList.rightParenthesis, isNotNull); |
| 7818 } | 7910 } |
| 7819 | 7911 |
| 7912 void test_parseFormalParameterList_normal_single_trailing_comma() { |
| 7913 parseTrailingCommas = true; |
| 7914 FormalParameterList parameterList = |
| 7915 parse4("parseFormalParameterList", "(A a,)"); |
| 7916 expect(parameterList.leftParenthesis, isNotNull); |
| 7917 expect(parameterList.leftDelimiter, isNull); |
| 7918 expect(parameterList.parameters, hasLength(1)); |
| 7919 expect(parameterList.rightDelimiter, isNull); |
| 7920 expect(parameterList.rightParenthesis, isNotNull); |
| 7921 } |
| 7922 |
| 7820 void test_parseFormalParameterList_positional_multiple() { | 7923 void test_parseFormalParameterList_positional_multiple() { |
| 7821 FormalParameterList parameterList = | 7924 FormalParameterList parameterList = |
| 7822 parse4("parseFormalParameterList", "([A a = null, B b, C c = null])"); | 7925 parse4("parseFormalParameterList", "([A a = null, B b, C c = null])"); |
| 7823 expect(parameterList.leftParenthesis, isNotNull); | 7926 expect(parameterList.leftParenthesis, isNotNull); |
| 7824 expect(parameterList.leftDelimiter, isNotNull); | 7927 expect(parameterList.leftDelimiter, isNotNull); |
| 7825 expect(parameterList.parameters, hasLength(3)); | 7928 expect(parameterList.parameters, hasLength(3)); |
| 7826 expect(parameterList.rightDelimiter, isNotNull); | 7929 expect(parameterList.rightDelimiter, isNotNull); |
| 7827 expect(parameterList.rightParenthesis, isNotNull); | 7930 expect(parameterList.rightParenthesis, isNotNull); |
| 7828 } | 7931 } |
| 7829 | 7932 |
| 7830 void test_parseFormalParameterList_positional_single() { | 7933 void test_parseFormalParameterList_positional_single() { |
| 7831 FormalParameterList parameterList = | 7934 FormalParameterList parameterList = |
| 7832 parse4("parseFormalParameterList", "([A a = null])"); | 7935 parse4("parseFormalParameterList", "([A a = null])"); |
| 7833 expect(parameterList.leftParenthesis, isNotNull); | 7936 expect(parameterList.leftParenthesis, isNotNull); |
| 7834 expect(parameterList.leftDelimiter, isNotNull); | 7937 expect(parameterList.leftDelimiter, isNotNull); |
| 7835 expect(parameterList.parameters, hasLength(1)); | 7938 expect(parameterList.parameters, hasLength(1)); |
| 7836 expect(parameterList.rightDelimiter, isNotNull); | 7939 expect(parameterList.rightDelimiter, isNotNull); |
| 7837 expect(parameterList.rightParenthesis, isNotNull); | 7940 expect(parameterList.rightParenthesis, isNotNull); |
| 7838 } | 7941 } |
| 7839 | 7942 |
| 7943 void test_parseFormalParameterList_positional_trailing_comma() { |
| 7944 parseTrailingCommas = true; |
| 7945 FormalParameterList parameterList = |
| 7946 parse4("parseFormalParameterList", "(A a, [B b,])"); |
| 7947 expect(parameterList.leftParenthesis, isNotNull); |
| 7948 expect(parameterList.leftDelimiter, isNotNull); |
| 7949 expect(parameterList.parameters, hasLength(2)); |
| 7950 expect(parameterList.rightDelimiter, isNotNull); |
| 7951 expect(parameterList.rightParenthesis, isNotNull); |
| 7952 } |
| 7953 |
| 7840 void test_parseFormalParameterList_prefixedType() { | 7954 void test_parseFormalParameterList_prefixedType() { |
| 7841 FormalParameterList parameterList = | 7955 FormalParameterList parameterList = |
| 7842 parse4("parseFormalParameterList", "(io.File f)"); | 7956 parse4("parseFormalParameterList", "(io.File f)"); |
| 7843 expect(parameterList.leftParenthesis, isNotNull); | 7957 expect(parameterList.leftParenthesis, isNotNull); |
| 7844 expect(parameterList.leftDelimiter, isNull); | 7958 expect(parameterList.leftDelimiter, isNull); |
| 7845 expect(parameterList.parameters, hasLength(1)); | 7959 expect(parameterList.parameters, hasLength(1)); |
| 7846 expect(parameterList.parameters[0].toSource(), 'io.File f'); | 7960 expect(parameterList.parameters[0].toSource(), 'io.File f'); |
| 7847 expect(parameterList.rightDelimiter, isNull); | 7961 expect(parameterList.rightDelimiter, isNull); |
| 7848 expect(parameterList.rightParenthesis, isNotNull); | 7962 expect(parameterList.rightParenthesis, isNotNull); |
| 7849 } | 7963 } |
| (...skipping 3342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11192 new Scanner(null, new CharSequenceReader(source), listener); | 11306 new Scanner(null, new CharSequenceReader(source), listener); |
| 11193 Token tokenStream = scanner.tokenize(); | 11307 Token tokenStream = scanner.tokenize(); |
| 11194 // | 11308 // |
| 11195 // Parse the source. | 11309 // Parse the source. |
| 11196 // | 11310 // |
| 11197 Parser parser = new Parser(null, listener); | 11311 Parser parser = new Parser(null, listener); |
| 11198 return invokeParserMethodImpl( | 11312 return invokeParserMethodImpl( |
| 11199 parser, methodName, <Object>[tokenStream], tokenStream) as Token; | 11313 parser, methodName, <Object>[tokenStream], tokenStream) as Token; |
| 11200 } | 11314 } |
| 11201 } | 11315 } |
| OLD | NEW |