OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library analyzer.test.generated.parser_test; | 5 library analyzer.test.generated.parser_test; |
6 | 6 |
7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
8 import 'package:analyzer/dart/ast/token.dart'; | 8 import 'package:analyzer/dart/ast/token.dart'; |
9 import 'package:analyzer/dart/ast/visitor.dart'; | 9 import 'package:analyzer/dart/ast/visitor.dart'; |
10 import 'package:analyzer/error/error.dart'; | 10 import 'package:analyzer/error/error.dart'; |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 expect(argumentList4.arguments, hasLength(1)); | 194 expect(argumentList4.arguments, hasLength(1)); |
195 } | 195 } |
196 | 196 |
197 void test_assignableExpression_arguments_normal_chain_typeArgumentComments() { | 197 void test_assignableExpression_arguments_normal_chain_typeArgumentComments() { |
198 enableGenericMethodComments = true; | 198 enableGenericMethodComments = true; |
199 _validate_assignableExpression_arguments_normal_chain_typeArguments( | 199 _validate_assignableExpression_arguments_normal_chain_typeArguments( |
200 "a/*<E>*/(b)/*<F>*/(c).d/*<G>*/(e).f"); | 200 "a/*<E>*/(b)/*<F>*/(c).d/*<G>*/(e).f"); |
201 } | 201 } |
202 | 202 |
203 void test_assignableExpression_arguments_normal_chain_typeArguments() { | 203 void test_assignableExpression_arguments_normal_chain_typeArguments() { |
204 enableGenericMethods = true; | |
205 _validate_assignableExpression_arguments_normal_chain_typeArguments( | 204 _validate_assignableExpression_arguments_normal_chain_typeArguments( |
206 "a<E>(b)<F>(c).d<G>(e).f"); | 205 "a<E>(b)<F>(c).d<G>(e).f"); |
207 } | 206 } |
208 | 207 |
209 void test_assignmentExpression_compound() { | 208 void test_assignmentExpression_compound() { |
210 AssignmentExpression expression = parseExpression("x = y = 0"); | 209 AssignmentExpression expression = parseExpression("x = y = 0"); |
211 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 210 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
212 SimpleIdentifier, expression.leftHandSide); | 211 SimpleIdentifier, expression.leftHandSide); |
213 EngineTestCase.assertInstanceOf((obj) => obj is AssignmentExpression, | 212 EngineTestCase.assertInstanceOf((obj) => obj is AssignmentExpression, |
214 AssignmentExpression, expression.rightHandSide); | 213 AssignmentExpression, expression.rightHandSide); |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 BinaryExpression, expression.rightOperand); | 524 BinaryExpression, expression.rightOperand); |
526 } | 525 } |
527 | 526 |
528 void test_shiftExpression_super() { | 527 void test_shiftExpression_super() { |
529 BinaryExpression expression = parseExpression("super >> 4 << 3"); | 528 BinaryExpression expression = parseExpression("super >> 4 << 3"); |
530 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | 529 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, |
531 BinaryExpression, expression.leftOperand); | 530 BinaryExpression, expression.leftOperand); |
532 } | 531 } |
533 | 532 |
534 void test_topLevelFunction_nestedGenericFunction() { | 533 void test_topLevelFunction_nestedGenericFunction() { |
535 enableGenericMethods = true; | |
536 parseCompilationUnitWithOptions(''' | 534 parseCompilationUnitWithOptions(''' |
537 void f() { | 535 void f() { |
538 void g<T>() { | 536 void g<T>() { |
539 } | 537 } |
540 } | 538 } |
541 '''); | 539 '''); |
542 } | 540 } |
543 | 541 |
544 void _validate_assignableExpression_arguments_normal_chain_typeArguments( | 542 void _validate_assignableExpression_arguments_normal_chain_typeArguments( |
545 String code) { | 543 String code) { |
(...skipping 1130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1676 expect(member, new isInstanceOf<MethodDeclaration>()); | 1674 expect(member, new isInstanceOf<MethodDeclaration>()); |
1677 MethodDeclaration method = member; | 1675 MethodDeclaration method = member; |
1678 expect(method.typeParameters.toString(), '<E, hello>', | 1676 expect(method.typeParameters.toString(), '<E, hello>', |
1679 reason: 'parser recovers what it can'); | 1677 reason: 'parser recovers what it can'); |
1680 } | 1678 } |
1681 | 1679 |
1682 void test_method_invalidTypeParameterExtends() { | 1680 void test_method_invalidTypeParameterExtends() { |
1683 // Regression test for https://github.com/dart-lang/sdk/issues/25739. | 1681 // Regression test for https://github.com/dart-lang/sdk/issues/25739. |
1684 | 1682 |
1685 // TODO(jmesserly): ideally we'd be better at parser recovery here. | 1683 // TODO(jmesserly): ideally we'd be better at parser recovery here. |
1686 enableGenericMethods = true; | |
1687 createParser('f<E>(E extends num p);'); | 1684 createParser('f<E>(E extends num p);'); |
1688 ClassMember member = parser.parseClassMember('C'); | 1685 ClassMember member = parser.parseClassMember('C'); |
1689 expectNotNullIfNoErrors(member); | 1686 expectNotNullIfNoErrors(member); |
1690 listener.assertErrorsWithCodes([ | 1687 listener.assertErrorsWithCodes([ |
1691 ParserErrorCode.MISSING_IDENTIFIER, // `extends` is a keyword | 1688 ParserErrorCode.MISSING_IDENTIFIER, // `extends` is a keyword |
1692 ParserErrorCode.EXPECTED_TOKEN, // comma | 1689 ParserErrorCode.EXPECTED_TOKEN, // comma |
1693 ParserErrorCode.EXPECTED_TOKEN, // close paren | 1690 ParserErrorCode.EXPECTED_TOKEN, // close paren |
1694 ParserErrorCode.MISSING_FUNCTION_BODY | 1691 ParserErrorCode.MISSING_FUNCTION_BODY |
1695 ]); | 1692 ]); |
1696 expect(member, new isInstanceOf<MethodDeclaration>()); | 1693 expect(member, new isInstanceOf<MethodDeclaration>()); |
(...skipping 25 matching lines...) Expand all Loading... |
1722 MethodDeclaration method = member; | 1719 MethodDeclaration method = member; |
1723 expect(method.parameters.toString(), '(E extends, extends)', | 1720 expect(method.parameters.toString(), '(E extends, extends)', |
1724 reason: 'parser recovers what it can'); | 1721 reason: 'parser recovers what it can'); |
1725 } | 1722 } |
1726 | 1723 |
1727 void test_method_invalidTypeParameters() { | 1724 void test_method_invalidTypeParameters() { |
1728 // TODO(jmesserly): ideally we'd be better at parser recovery here. | 1725 // TODO(jmesserly): ideally we'd be better at parser recovery here. |
1729 // It doesn't try to advance past the invalid token `!` to find the | 1726 // It doesn't try to advance past the invalid token `!` to find the |
1730 // valid `>`. If it did we'd get less cascading errors, at least for this | 1727 // valid `>`. If it did we'd get less cascading errors, at least for this |
1731 // particular example. | 1728 // particular example. |
1732 enableGenericMethods = true; | |
1733 createParser('void m<E, hello!>() {}'); | 1729 createParser('void m<E, hello!>() {}'); |
1734 ClassMember member = parser.parseClassMember('C'); | 1730 ClassMember member = parser.parseClassMember('C'); |
1735 expectNotNullIfNoErrors(member); | 1731 expectNotNullIfNoErrors(member); |
1736 listener.assertErrorsWithCodes([ | 1732 listener.assertErrorsWithCodes([ |
1737 ParserErrorCode.EXPECTED_TOKEN /*>*/, | 1733 ParserErrorCode.EXPECTED_TOKEN /*>*/, |
1738 ParserErrorCode.MISSING_IDENTIFIER, | 1734 ParserErrorCode.MISSING_IDENTIFIER, |
1739 ParserErrorCode.EXPECTED_TOKEN /*(*/, | 1735 ParserErrorCode.EXPECTED_TOKEN /*(*/, |
1740 ParserErrorCode.EXPECTED_TOKEN /*)*/, | 1736 ParserErrorCode.EXPECTED_TOKEN /*)*/, |
1741 ParserErrorCode.MISSING_FUNCTION_BODY | 1737 ParserErrorCode.MISSING_FUNCTION_BODY |
1742 ]); | 1738 ]); |
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2262 MethodInvocation methodInvocation = parser.parseCascadeSection(); | 2258 MethodInvocation methodInvocation = parser.parseCascadeSection(); |
2263 expectNotNullIfNoErrors(methodInvocation); | 2259 expectNotNullIfNoErrors(methodInvocation); |
2264 listener.assertErrorsWithCodes([ParserErrorCode.MISSING_IDENTIFIER]); | 2260 listener.assertErrorsWithCodes([ParserErrorCode.MISSING_IDENTIFIER]); |
2265 expect(methodInvocation.target, isNull); | 2261 expect(methodInvocation.target, isNull); |
2266 expect(methodInvocation.methodName.name, ""); | 2262 expect(methodInvocation.methodName.name, ""); |
2267 expect(methodInvocation.typeArguments, isNull); | 2263 expect(methodInvocation.typeArguments, isNull); |
2268 expect(methodInvocation.argumentList.arguments, hasLength(0)); | 2264 expect(methodInvocation.argumentList.arguments, hasLength(0)); |
2269 } | 2265 } |
2270 | 2266 |
2271 void test_parseCascadeSection_missingIdentifier_typeArguments() { | 2267 void test_parseCascadeSection_missingIdentifier_typeArguments() { |
2272 enableGenericMethods = true; | |
2273 createParser('..<E>()'); | 2268 createParser('..<E>()'); |
2274 MethodInvocation methodInvocation = parser.parseCascadeSection(); | 2269 MethodInvocation methodInvocation = parser.parseCascadeSection(); |
2275 expectNotNullIfNoErrors(methodInvocation); | 2270 expectNotNullIfNoErrors(methodInvocation); |
2276 listener.assertErrorsWithCodes([ParserErrorCode.MISSING_IDENTIFIER]); | 2271 listener.assertErrorsWithCodes([ParserErrorCode.MISSING_IDENTIFIER]); |
2277 expect(methodInvocation.target, isNull); | 2272 expect(methodInvocation.target, isNull); |
2278 expect(methodInvocation.methodName.name, ""); | 2273 expect(methodInvocation.methodName.name, ""); |
2279 expect(methodInvocation.typeArguments, isNotNull); | 2274 expect(methodInvocation.typeArguments, isNotNull); |
2280 expect(methodInvocation.argumentList.arguments, hasLength(0)); | 2275 expect(methodInvocation.argumentList.arguments, hasLength(0)); |
2281 } | 2276 } |
2282 | 2277 |
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2834 * list of a constructor. | 2829 * list of a constructor. |
2835 */ | 2830 */ |
2836 bool enableAssertInitializer = false; | 2831 bool enableAssertInitializer = false; |
2837 | 2832 |
2838 /** | 2833 /** |
2839 * A flag indicating whether parser is to parse async. | 2834 * A flag indicating whether parser is to parse async. |
2840 */ | 2835 */ |
2841 bool parseAsync = true; | 2836 bool parseAsync = true; |
2842 | 2837 |
2843 /** | 2838 /** |
2844 * A flag indicating whether generic method support should be enabled for a | |
2845 * specific test. | |
2846 */ | |
2847 bool enableGenericMethods = false; | |
2848 | |
2849 /** | |
2850 * Whether generic method comments should be enabled for the test. | 2839 * Whether generic method comments should be enabled for the test. |
2851 */ | 2840 */ |
2852 bool enableGenericMethodComments = false; | 2841 bool enableGenericMethodComments = false; |
2853 | 2842 |
2854 /** | 2843 /** |
2855 * A flag indicating whether lazy assignment operators should be enabled for | 2844 * A flag indicating whether lazy assignment operators should be enabled for |
2856 * the test. | 2845 * the test. |
2857 */ | 2846 */ |
2858 bool enableLazyAssignmentOperators = false; | 2847 bool enableLazyAssignmentOperators = false; |
2859 | 2848 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2903 Scanner scanner = new Scanner(source, reader, listener); | 2892 Scanner scanner = new Scanner(source, reader, listener); |
2904 scanner.scanGenericMethodComments = enableGenericMethodComments; | 2893 scanner.scanGenericMethodComments = enableGenericMethodComments; |
2905 scanner.scanLazyAssignmentOperators = enableLazyAssignmentOperators; | 2894 scanner.scanLazyAssignmentOperators = enableLazyAssignmentOperators; |
2906 Token tokenStream = scanner.tokenize(); | 2895 Token tokenStream = scanner.tokenize(); |
2907 listener.setLineInfo(source, scanner.lineStarts); | 2896 listener.setLineInfo(source, scanner.lineStarts); |
2908 // | 2897 // |
2909 // Create and initialize the parser. | 2898 // Create and initialize the parser. |
2910 // | 2899 // |
2911 parser = new Parser(source, listener); | 2900 parser = new Parser(source, listener); |
2912 parser.enableAssertInitializer = enableAssertInitializer; | 2901 parser.enableAssertInitializer = enableAssertInitializer; |
2913 parser.parseGenericMethods = enableGenericMethods; | |
2914 parser.parseGenericMethodComments = enableGenericMethodComments; | 2902 parser.parseGenericMethodComments = enableGenericMethodComments; |
2915 parser.parseFunctionBodies = parseFunctionBodies; | 2903 parser.parseFunctionBodies = parseFunctionBodies; |
2916 parser.enableNnbd = enableNnbd; | 2904 parser.enableNnbd = enableNnbd; |
2917 parser.currentToken = tokenStream; | 2905 parser.currentToken = tokenStream; |
2918 } | 2906 } |
2919 | 2907 |
2920 /** | 2908 /** |
2921 * Return an empty CommentAndMetadata object that can be used for testing. | 2909 * Return an empty CommentAndMetadata object that can be used for testing. |
2922 * | 2910 * |
2923 * @return an empty CommentAndMetadata object that can be used for testing | 2911 * @return an empty CommentAndMetadata object that can be used for testing |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2989 CompilationUnit unit = parser.parseCompilationUnit(token); | 2977 CompilationUnit unit = parser.parseCompilationUnit(token); |
2990 expect(unit, isNotNull); | 2978 expect(unit, isNotNull); |
2991 listener.assertErrorsWithCodes(errorCodes); | 2979 listener.assertErrorsWithCodes(errorCodes); |
2992 return unit; | 2980 return unit; |
2993 } | 2981 } |
2994 | 2982 |
2995 /** | 2983 /** |
2996 * Parse the given [code] as a compilation unit. | 2984 * Parse the given [code] as a compilation unit. |
2997 */ | 2985 */ |
2998 static CompilationUnit parseCompilationUnit2(String code, | 2986 static CompilationUnit parseCompilationUnit2(String code, |
2999 {AnalysisErrorListener listener, bool parseGenericMethods: false}) { | 2987 {AnalysisErrorListener listener}) { |
3000 listener ??= AnalysisErrorListener.NULL_LISTENER; | 2988 listener ??= AnalysisErrorListener.NULL_LISTENER; |
3001 Scanner scanner = new Scanner(null, new CharSequenceReader(code), listener); | 2989 Scanner scanner = new Scanner(null, new CharSequenceReader(code), listener); |
3002 Token token = scanner.tokenize(); | 2990 Token token = scanner.tokenize(); |
3003 Parser parser = new Parser(null, listener); | 2991 Parser parser = new Parser(null, listener); |
3004 parser.parseGenericMethods = parseGenericMethods; | |
3005 CompilationUnit unit = parser.parseCompilationUnit(token); | 2992 CompilationUnit unit = parser.parseCompilationUnit(token); |
3006 unit.lineInfo = new LineInfo(scanner.lineStarts); | 2993 unit.lineInfo = new LineInfo(scanner.lineStarts); |
3007 return unit; | 2994 return unit; |
3008 } | 2995 } |
3009 | 2996 |
3010 /** | 2997 /** |
3011 * Parse the given [source] as a statement. The [errorCodes] are the error | 2998 * Parse the given [source] as a statement. The [errorCodes] are the error |
3012 * codes of the errors that are expected to be found. If | 2999 * codes of the errors that are expected to be found. If |
3013 * [enableLazyAssignmentOperators] is `true`, then lazy assignment operators | 3000 * [enableLazyAssignmentOperators] is `true`, then lazy assignment operators |
3014 * should be enabled. | 3001 * should be enabled. |
(...skipping 1405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4420 | 4407 |
4421 void test_isFunctionDeclaration_nameButNoReturn_block() { | 4408 void test_isFunctionDeclaration_nameButNoReturn_block() { |
4422 expect(_isFunctionDeclaration("f() {}"), isTrue); | 4409 expect(_isFunctionDeclaration("f() {}"), isTrue); |
4423 } | 4410 } |
4424 | 4411 |
4425 void test_isFunctionDeclaration_nameButNoReturn_expression() { | 4412 void test_isFunctionDeclaration_nameButNoReturn_expression() { |
4426 expect(_isFunctionDeclaration("f() => e"), isTrue); | 4413 expect(_isFunctionDeclaration("f() => e"), isTrue); |
4427 } | 4414 } |
4428 | 4415 |
4429 void test_isFunctionDeclaration_nameButNoReturn_typeParameters_block() { | 4416 void test_isFunctionDeclaration_nameButNoReturn_typeParameters_block() { |
4430 enableGenericMethods = true; | |
4431 expect(_isFunctionDeclaration("f<E>() {}"), isTrue); | 4417 expect(_isFunctionDeclaration("f<E>() {}"), isTrue); |
4432 } | 4418 } |
4433 | 4419 |
4434 void test_isFunctionDeclaration_nameButNoReturn_typeParameters_expression() { | 4420 void test_isFunctionDeclaration_nameButNoReturn_typeParameters_expression() { |
4435 enableGenericMethods = true; | |
4436 expect(_isFunctionDeclaration("f<E>() => e"), isTrue); | 4421 expect(_isFunctionDeclaration("f<E>() => e"), isTrue); |
4437 } | 4422 } |
4438 | 4423 |
4439 void test_isFunctionDeclaration_normalReturn_block() { | 4424 void test_isFunctionDeclaration_normalReturn_block() { |
4440 expect(_isFunctionDeclaration("C f() {}"), isTrue); | 4425 expect(_isFunctionDeclaration("C f() {}"), isTrue); |
4441 } | 4426 } |
4442 | 4427 |
4443 void test_isFunctionDeclaration_normalReturn_expression() { | 4428 void test_isFunctionDeclaration_normalReturn_expression() { |
4444 expect(_isFunctionDeclaration("C f() => e"), isTrue); | 4429 expect(_isFunctionDeclaration("C f() => e"), isTrue); |
4445 } | 4430 } |
4446 | 4431 |
4447 void test_isFunctionDeclaration_normalReturn_typeParameters_block() { | 4432 void test_isFunctionDeclaration_normalReturn_typeParameters_block() { |
4448 enableGenericMethods = true; | |
4449 expect(_isFunctionDeclaration("C f<E>() {}"), isTrue); | 4433 expect(_isFunctionDeclaration("C f<E>() {}"), isTrue); |
4450 } | 4434 } |
4451 | 4435 |
4452 void test_isFunctionDeclaration_normalReturn_typeParameters_expression() { | 4436 void test_isFunctionDeclaration_normalReturn_typeParameters_expression() { |
4453 enableGenericMethods = true; | |
4454 expect(_isFunctionDeclaration("C f<E>() => e"), isTrue); | 4437 expect(_isFunctionDeclaration("C f<E>() => e"), isTrue); |
4455 } | 4438 } |
4456 | 4439 |
4457 void test_isFunctionDeclaration_voidReturn_block() { | 4440 void test_isFunctionDeclaration_voidReturn_block() { |
4458 expect(_isFunctionDeclaration("void f() {}"), isTrue); | 4441 expect(_isFunctionDeclaration("void f() {}"), isTrue); |
4459 } | 4442 } |
4460 | 4443 |
4461 void test_isFunctionDeclaration_voidReturn_expression() { | 4444 void test_isFunctionDeclaration_voidReturn_expression() { |
4462 expect(_isFunctionDeclaration("void f() => e"), isTrue); | 4445 expect(_isFunctionDeclaration("void f() => e"), isTrue); |
4463 } | 4446 } |
4464 | 4447 |
4465 void test_isFunctionDeclaration_voidReturn_typeParameters_block() { | 4448 void test_isFunctionDeclaration_voidReturn_typeParameters_block() { |
4466 enableGenericMethods = true; | |
4467 expect(_isFunctionDeclaration("void f<E>() {}"), isTrue); | 4449 expect(_isFunctionDeclaration("void f<E>() {}"), isTrue); |
4468 } | 4450 } |
4469 | 4451 |
4470 void test_isFunctionDeclaration_voidReturn_typeParameters_expression() { | 4452 void test_isFunctionDeclaration_voidReturn_typeParameters_expression() { |
4471 enableGenericMethods = true; | |
4472 expect(_isFunctionDeclaration("void f<E>() => e"), isTrue); | 4453 expect(_isFunctionDeclaration("void f<E>() => e"), isTrue); |
4473 } | 4454 } |
4474 | 4455 |
4475 void test_isFunctionExpression_false_noBody() { | 4456 void test_isFunctionExpression_false_noBody() { |
4476 expect(_isFunctionExpression("f();"), isFalse); | 4457 expect(_isFunctionExpression("f();"), isFalse); |
4477 } | 4458 } |
4478 | 4459 |
4479 void test_isFunctionExpression_false_notParameters() { | 4460 void test_isFunctionExpression_false_notParameters() { |
4480 expect(_isFunctionExpression("(a + b) {"), isFalse); | 4461 expect(_isFunctionExpression("(a + b) {"), isFalse); |
4481 } | 4462 } |
4482 | 4463 |
4483 void test_isFunctionExpression_noParameters_block() { | 4464 void test_isFunctionExpression_noParameters_block() { |
4484 expect(_isFunctionExpression("() {}"), isTrue); | 4465 expect(_isFunctionExpression("() {}"), isTrue); |
4485 } | 4466 } |
4486 | 4467 |
4487 void test_isFunctionExpression_noParameters_expression() { | 4468 void test_isFunctionExpression_noParameters_expression() { |
4488 expect(_isFunctionExpression("() => e"), isTrue); | 4469 expect(_isFunctionExpression("() => e"), isTrue); |
4489 } | 4470 } |
4490 | 4471 |
4491 void test_isFunctionExpression_noParameters_typeParameters_block() { | 4472 void test_isFunctionExpression_noParameters_typeParameters_block() { |
4492 enableGenericMethods = true; | |
4493 expect(_isFunctionExpression("<E>() {}"), isTrue); | 4473 expect(_isFunctionExpression("<E>() {}"), isTrue); |
4494 } | 4474 } |
4495 | 4475 |
4496 void test_isFunctionExpression_noParameters_typeParameters_expression() { | 4476 void test_isFunctionExpression_noParameters_typeParameters_expression() { |
4497 enableGenericMethods = true; | |
4498 expect(_isFunctionExpression("<E>() => e"), isTrue); | 4477 expect(_isFunctionExpression("<E>() => e"), isTrue); |
4499 } | 4478 } |
4500 | 4479 |
4501 void test_isFunctionExpression_parameter_final() { | 4480 void test_isFunctionExpression_parameter_final() { |
4502 expect(_isFunctionExpression("(final a) {}"), isTrue); | 4481 expect(_isFunctionExpression("(final a) {}"), isTrue); |
4503 expect(_isFunctionExpression("(final a, b) {}"), isTrue); | 4482 expect(_isFunctionExpression("(final a, b) {}"), isTrue); |
4504 expect(_isFunctionExpression("(final a, final b) {}"), isTrue); | 4483 expect(_isFunctionExpression("(final a, final b) {}"), isTrue); |
4505 } | 4484 } |
4506 | 4485 |
4507 void test_isFunctionExpression_parameter_final_typed() { | 4486 void test_isFunctionExpression_parameter_final_typed() { |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4866 expect(invocation.function, isNotNull); | 4845 expect(invocation.function, isNotNull); |
4867 expect(invocation.typeArguments, isNotNull); | 4846 expect(invocation.typeArguments, isNotNull); |
4868 ArgumentList argumentList = invocation.argumentList; | 4847 ArgumentList argumentList = invocation.argumentList; |
4869 expect(argumentList, isNotNull); | 4848 expect(argumentList, isNotNull); |
4870 expect(argumentList.arguments, hasLength(1)); | 4849 expect(argumentList.arguments, hasLength(1)); |
4871 expect(propertyAccess.operator, isNotNull); | 4850 expect(propertyAccess.operator, isNotNull); |
4872 expect(propertyAccess.propertyName, isNotNull); | 4851 expect(propertyAccess.propertyName, isNotNull); |
4873 } | 4852 } |
4874 | 4853 |
4875 void test_parseAssignableExpression_expression_args_dot_typeParameters() { | 4854 void test_parseAssignableExpression_expression_args_dot_typeParameters() { |
4876 enableGenericMethods = true; | |
4877 createParser('(x)<F>(y).z'); | 4855 createParser('(x)<F>(y).z'); |
4878 Expression expression = parser.parseAssignableExpression(false); | 4856 Expression expression = parser.parseAssignableExpression(false); |
4879 expectNotNullIfNoErrors(expression); | 4857 expectNotNullIfNoErrors(expression); |
4880 listener.assertNoErrors(); | 4858 listener.assertNoErrors(); |
4881 expect(expression, new isInstanceOf<PropertyAccess>()); | 4859 expect(expression, new isInstanceOf<PropertyAccess>()); |
4882 PropertyAccess propertyAccess = expression; | 4860 PropertyAccess propertyAccess = expression; |
4883 FunctionExpressionInvocation invocation = | 4861 FunctionExpressionInvocation invocation = |
4884 propertyAccess.target as FunctionExpressionInvocation; | 4862 propertyAccess.target as FunctionExpressionInvocation; |
4885 expect(invocation.function, isNotNull); | 4863 expect(invocation.function, isNotNull); |
4886 expect(invocation.typeArguments, isNotNull); | 4864 expect(invocation.typeArguments, isNotNull); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4968 expect(invocation.methodName.name, "x"); | 4946 expect(invocation.methodName.name, "x"); |
4969 expect(invocation.typeArguments, isNotNull); | 4947 expect(invocation.typeArguments, isNotNull); |
4970 ArgumentList argumentList = invocation.argumentList; | 4948 ArgumentList argumentList = invocation.argumentList; |
4971 expect(argumentList, isNotNull); | 4949 expect(argumentList, isNotNull); |
4972 expect(argumentList.arguments, hasLength(1)); | 4950 expect(argumentList.arguments, hasLength(1)); |
4973 expect(propertyAccess.operator, isNotNull); | 4951 expect(propertyAccess.operator, isNotNull); |
4974 expect(propertyAccess.propertyName, isNotNull); | 4952 expect(propertyAccess.propertyName, isNotNull); |
4975 } | 4953 } |
4976 | 4954 |
4977 void test_parseAssignableExpression_identifier_args_dot_typeParameters() { | 4955 void test_parseAssignableExpression_identifier_args_dot_typeParameters() { |
4978 enableGenericMethods = true; | |
4979 createParser('x<E>(y).z'); | 4956 createParser('x<E>(y).z'); |
4980 Expression expression = parser.parseAssignableExpression(false); | 4957 Expression expression = parser.parseAssignableExpression(false); |
4981 expectNotNullIfNoErrors(expression); | 4958 expectNotNullIfNoErrors(expression); |
4982 listener.assertNoErrors(); | 4959 listener.assertNoErrors(); |
4983 expect(expression, new isInstanceOf<PropertyAccess>()); | 4960 expect(expression, new isInstanceOf<PropertyAccess>()); |
4984 PropertyAccess propertyAccess = expression; | 4961 PropertyAccess propertyAccess = expression; |
4985 MethodInvocation invocation = propertyAccess.target as MethodInvocation; | 4962 MethodInvocation invocation = propertyAccess.target as MethodInvocation; |
4986 expect(invocation.methodName.name, "x"); | 4963 expect(invocation.methodName.name, "x"); |
4987 expect(invocation.typeArguments, isNotNull); | 4964 expect(invocation.typeArguments, isNotNull); |
4988 ArgumentList argumentList = invocation.argumentList; | 4965 ArgumentList argumentList = invocation.argumentList; |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5321 expectNotNullIfNoErrors(expression); | 5298 expectNotNullIfNoErrors(expression); |
5322 listener.assertNoErrors(); | 5299 listener.assertNoErrors(); |
5323 expect(expression, new isInstanceOf<FunctionExpressionInvocation>()); | 5300 expect(expression, new isInstanceOf<FunctionExpressionInvocation>()); |
5324 FunctionExpressionInvocation section = expression; | 5301 FunctionExpressionInvocation section = expression; |
5325 expect(section.function, new isInstanceOf<IndexExpression>()); | 5302 expect(section.function, new isInstanceOf<IndexExpression>()); |
5326 expect(section.typeArguments, isNotNull); | 5303 expect(section.typeArguments, isNotNull); |
5327 expect(section.argumentList, isNotNull); | 5304 expect(section.argumentList, isNotNull); |
5328 } | 5305 } |
5329 | 5306 |
5330 void test_parseCascadeSection_ia_typeArguments() { | 5307 void test_parseCascadeSection_ia_typeArguments() { |
5331 enableGenericMethods = true; | |
5332 createParser('..[i]<E>(b)'); | 5308 createParser('..[i]<E>(b)'); |
5333 Expression expression = parser.parseCascadeSection(); | 5309 Expression expression = parser.parseCascadeSection(); |
5334 expectNotNullIfNoErrors(expression); | 5310 expectNotNullIfNoErrors(expression); |
5335 listener.assertNoErrors(); | 5311 listener.assertNoErrors(); |
5336 expect(expression, new isInstanceOf<FunctionExpressionInvocation>()); | 5312 expect(expression, new isInstanceOf<FunctionExpressionInvocation>()); |
5337 FunctionExpressionInvocation section = expression; | 5313 FunctionExpressionInvocation section = expression; |
5338 expect(section.function, new isInstanceOf<IndexExpression>()); | 5314 expect(section.function, new isInstanceOf<IndexExpression>()); |
5339 expect(section.typeArguments, isNotNull); | 5315 expect(section.typeArguments, isNotNull); |
5340 expect(section.argumentList, isNotNull); | 5316 expect(section.argumentList, isNotNull); |
5341 } | 5317 } |
(...skipping 23 matching lines...) Expand all Loading... |
5365 MethodInvocation section = expression; | 5341 MethodInvocation section = expression; |
5366 expect(section.target, new isInstanceOf<MethodInvocation>()); | 5342 expect(section.target, new isInstanceOf<MethodInvocation>()); |
5367 expect(section.operator, isNotNull); | 5343 expect(section.operator, isNotNull); |
5368 expect(section.methodName, isNotNull); | 5344 expect(section.methodName, isNotNull); |
5369 expect(section.typeArguments, isNotNull); | 5345 expect(section.typeArguments, isNotNull); |
5370 expect(section.argumentList, isNotNull); | 5346 expect(section.argumentList, isNotNull); |
5371 expect(section.argumentList.arguments, hasLength(1)); | 5347 expect(section.argumentList.arguments, hasLength(1)); |
5372 } | 5348 } |
5373 | 5349 |
5374 void test_parseCascadeSection_ii_typeArguments() { | 5350 void test_parseCascadeSection_ii_typeArguments() { |
5375 enableGenericMethods = true; | |
5376 createParser('..a<E>(b).c<F>(d)'); | 5351 createParser('..a<E>(b).c<F>(d)'); |
5377 Expression expression = parser.parseCascadeSection(); | 5352 Expression expression = parser.parseCascadeSection(); |
5378 expectNotNullIfNoErrors(expression); | 5353 expectNotNullIfNoErrors(expression); |
5379 listener.assertNoErrors(); | 5354 listener.assertNoErrors(); |
5380 expect(expression, new isInstanceOf<MethodInvocation>()); | 5355 expect(expression, new isInstanceOf<MethodInvocation>()); |
5381 MethodInvocation section = expression; | 5356 MethodInvocation section = expression; |
5382 expect(section.target, new isInstanceOf<MethodInvocation>()); | 5357 expect(section.target, new isInstanceOf<MethodInvocation>()); |
5383 expect(section.operator, isNotNull); | 5358 expect(section.operator, isNotNull); |
5384 expect(section.methodName, isNotNull); | 5359 expect(section.methodName, isNotNull); |
5385 expect(section.typeArguments, isNotNull); | 5360 expect(section.typeArguments, isNotNull); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5435 expect(expression, new isInstanceOf<AssignmentExpression>()); | 5410 expect(expression, new isInstanceOf<AssignmentExpression>()); |
5436 AssignmentExpression section = expression; | 5411 AssignmentExpression section = expression; |
5437 expect(section.leftHandSide, isNotNull); | 5412 expect(section.leftHandSide, isNotNull); |
5438 expect(section.operator, isNotNull); | 5413 expect(section.operator, isNotNull); |
5439 Expression rhs = section.rightHandSide; | 5414 Expression rhs = section.rightHandSide; |
5440 EngineTestCase.assertInstanceOf( | 5415 EngineTestCase.assertInstanceOf( |
5441 (obj) => obj is IntegerLiteral, IntegerLiteral, rhs); | 5416 (obj) => obj is IntegerLiteral, IntegerLiteral, rhs); |
5442 } | 5417 } |
5443 | 5418 |
5444 void test_parseCascadeSection_p_assign_withCascade_typeArguments() { | 5419 void test_parseCascadeSection_p_assign_withCascade_typeArguments() { |
5445 enableGenericMethods = true; | |
5446 createParser('..a = 3..m<E>()'); | 5420 createParser('..a = 3..m<E>()'); |
5447 Expression expression = parser.parseCascadeSection(); | 5421 Expression expression = parser.parseCascadeSection(); |
5448 expectNotNullIfNoErrors(expression); | 5422 expectNotNullIfNoErrors(expression); |
5449 listener.assertNoErrors(); | 5423 listener.assertNoErrors(); |
5450 expect(expression, new isInstanceOf<AssignmentExpression>()); | 5424 expect(expression, new isInstanceOf<AssignmentExpression>()); |
5451 AssignmentExpression section = expression; | 5425 AssignmentExpression section = expression; |
5452 expect(section.leftHandSide, isNotNull); | 5426 expect(section.leftHandSide, isNotNull); |
5453 expect(section.operator, isNotNull); | 5427 expect(section.operator, isNotNull); |
5454 Expression rhs = section.rightHandSide; | 5428 Expression rhs = section.rightHandSide; |
5455 EngineTestCase.assertInstanceOf( | 5429 EngineTestCase.assertInstanceOf( |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5493 MethodInvocation section = expression; | 5467 MethodInvocation section = expression; |
5494 expect(section.target, isNull); | 5468 expect(section.target, isNull); |
5495 expect(section.operator, isNotNull); | 5469 expect(section.operator, isNotNull); |
5496 expect(section.methodName, isNotNull); | 5470 expect(section.methodName, isNotNull); |
5497 expect(section.typeArguments, isNotNull); | 5471 expect(section.typeArguments, isNotNull); |
5498 expect(section.argumentList, isNotNull); | 5472 expect(section.argumentList, isNotNull); |
5499 expect(section.argumentList.arguments, hasLength(1)); | 5473 expect(section.argumentList.arguments, hasLength(1)); |
5500 } | 5474 } |
5501 | 5475 |
5502 void test_parseCascadeSection_pa_typeArguments() { | 5476 void test_parseCascadeSection_pa_typeArguments() { |
5503 enableGenericMethods = true; | |
5504 createParser('..a<E>(b)'); | 5477 createParser('..a<E>(b)'); |
5505 Expression expression = parser.parseCascadeSection(); | 5478 Expression expression = parser.parseCascadeSection(); |
5506 expectNotNullIfNoErrors(expression); | 5479 expectNotNullIfNoErrors(expression); |
5507 listener.assertNoErrors(); | 5480 listener.assertNoErrors(); |
5508 expect(expression, new isInstanceOf<MethodInvocation>()); | 5481 expect(expression, new isInstanceOf<MethodInvocation>()); |
5509 MethodInvocation section = expression; | 5482 MethodInvocation section = expression; |
5510 expect(section.target, isNull); | 5483 expect(section.target, isNull); |
5511 expect(section.operator, isNotNull); | 5484 expect(section.operator, isNotNull); |
5512 expect(section.methodName, isNotNull); | 5485 expect(section.methodName, isNotNull); |
5513 expect(section.typeArguments, isNotNull); | 5486 expect(section.typeArguments, isNotNull); |
(...skipping 22 matching lines...) Expand all Loading... |
5536 listener.assertNoErrors(); | 5509 listener.assertNoErrors(); |
5537 expect(expression, new isInstanceOf<FunctionExpressionInvocation>()); | 5510 expect(expression, new isInstanceOf<FunctionExpressionInvocation>()); |
5538 FunctionExpressionInvocation section = expression; | 5511 FunctionExpressionInvocation section = expression; |
5539 expect(section.function, new isInstanceOf<MethodInvocation>()); | 5512 expect(section.function, new isInstanceOf<MethodInvocation>()); |
5540 expect(section.typeArguments, isNotNull); | 5513 expect(section.typeArguments, isNotNull); |
5541 expect(section.argumentList, isNotNull); | 5514 expect(section.argumentList, isNotNull); |
5542 expect(section.argumentList.arguments, hasLength(1)); | 5515 expect(section.argumentList.arguments, hasLength(1)); |
5543 } | 5516 } |
5544 | 5517 |
5545 void test_parseCascadeSection_paa_typeArguments() { | 5518 void test_parseCascadeSection_paa_typeArguments() { |
5546 enableGenericMethods = true; | |
5547 createParser('..a<E>(b)<F>(c)'); | 5519 createParser('..a<E>(b)<F>(c)'); |
5548 Expression expression = parser.parseCascadeSection(); | 5520 Expression expression = parser.parseCascadeSection(); |
5549 expectNotNullIfNoErrors(expression); | 5521 expectNotNullIfNoErrors(expression); |
5550 listener.assertNoErrors(); | 5522 listener.assertNoErrors(); |
5551 expect(expression, new isInstanceOf<FunctionExpressionInvocation>()); | 5523 expect(expression, new isInstanceOf<FunctionExpressionInvocation>()); |
5552 FunctionExpressionInvocation section = expression; | 5524 FunctionExpressionInvocation section = expression; |
5553 expect(section.function, new isInstanceOf<MethodInvocation>()); | 5525 expect(section.function, new isInstanceOf<MethodInvocation>()); |
5554 expect(section.typeArguments, isNotNull); | 5526 expect(section.typeArguments, isNotNull); |
5555 expect(section.argumentList, isNotNull); | 5527 expect(section.argumentList, isNotNull); |
5556 expect(section.argumentList.arguments, hasLength(1)); | 5528 expect(section.argumentList.arguments, hasLength(1)); |
(...skipping 20 matching lines...) Expand all Loading... |
5577 listener.assertNoErrors(); | 5549 listener.assertNoErrors(); |
5578 expect(expression, new isInstanceOf<FunctionExpressionInvocation>()); | 5550 expect(expression, new isInstanceOf<FunctionExpressionInvocation>()); |
5579 FunctionExpressionInvocation section = expression; | 5551 FunctionExpressionInvocation section = expression; |
5580 expect(section.function, new isInstanceOf<MethodInvocation>()); | 5552 expect(section.function, new isInstanceOf<MethodInvocation>()); |
5581 expect(section.typeArguments, isNotNull); | 5553 expect(section.typeArguments, isNotNull); |
5582 expect(section.argumentList, isNotNull); | 5554 expect(section.argumentList, isNotNull); |
5583 expect(section.argumentList.arguments, hasLength(1)); | 5555 expect(section.argumentList.arguments, hasLength(1)); |
5584 } | 5556 } |
5585 | 5557 |
5586 void test_parseCascadeSection_paapaa_typeArguments() { | 5558 void test_parseCascadeSection_paapaa_typeArguments() { |
5587 enableGenericMethods = true; | |
5588 createParser('..a<E>(b)<F>(c).d<G>(e)<H>(f)'); | 5559 createParser('..a<E>(b)<F>(c).d<G>(e)<H>(f)'); |
5589 Expression expression = parser.parseCascadeSection(); | 5560 Expression expression = parser.parseCascadeSection(); |
5590 expectNotNullIfNoErrors(expression); | 5561 expectNotNullIfNoErrors(expression); |
5591 listener.assertNoErrors(); | 5562 listener.assertNoErrors(); |
5592 expect(expression, new isInstanceOf<FunctionExpressionInvocation>()); | 5563 expect(expression, new isInstanceOf<FunctionExpressionInvocation>()); |
5593 FunctionExpressionInvocation section = expression; | 5564 FunctionExpressionInvocation section = expression; |
5594 expect(section.function, new isInstanceOf<MethodInvocation>()); | 5565 expect(section.function, new isInstanceOf<MethodInvocation>()); |
5595 expect(section.typeArguments, isNotNull); | 5566 expect(section.typeArguments, isNotNull); |
5596 expect(section.argumentList, isNotNull); | 5567 expect(section.argumentList, isNotNull); |
5597 expect(section.argumentList.arguments, hasLength(1)); | 5568 expect(section.argumentList.arguments, hasLength(1)); |
(...skipping 18 matching lines...) Expand all Loading... |
5616 expectNotNullIfNoErrors(expression); | 5587 expectNotNullIfNoErrors(expression); |
5617 listener.assertNoErrors(); | 5588 listener.assertNoErrors(); |
5618 expect(expression, new isInstanceOf<PropertyAccess>()); | 5589 expect(expression, new isInstanceOf<PropertyAccess>()); |
5619 PropertyAccess section = expression; | 5590 PropertyAccess section = expression; |
5620 expect(section.target, isNotNull); | 5591 expect(section.target, isNotNull); |
5621 expect(section.operator, isNotNull); | 5592 expect(section.operator, isNotNull); |
5622 expect(section.propertyName, isNotNull); | 5593 expect(section.propertyName, isNotNull); |
5623 } | 5594 } |
5624 | 5595 |
5625 void test_parseCascadeSection_pap_typeArguments() { | 5596 void test_parseCascadeSection_pap_typeArguments() { |
5626 enableGenericMethods = true; | |
5627 createParser('..a<E>(b).c'); | 5597 createParser('..a<E>(b).c'); |
5628 Expression expression = parser.parseCascadeSection(); | 5598 Expression expression = parser.parseCascadeSection(); |
5629 expectNotNullIfNoErrors(expression); | 5599 expectNotNullIfNoErrors(expression); |
5630 listener.assertNoErrors(); | 5600 listener.assertNoErrors(); |
5631 expect(expression, new isInstanceOf<PropertyAccess>()); | 5601 expect(expression, new isInstanceOf<PropertyAccess>()); |
5632 PropertyAccess section = expression; | 5602 PropertyAccess section = expression; |
5633 expect(section.target, isNotNull); | 5603 expect(section.target, isNotNull); |
5634 expect(section.operator, isNotNull); | 5604 expect(section.operator, isNotNull); |
5635 expect(section.propertyName, isNotNull); | 5605 expect(section.propertyName, isNotNull); |
5636 } | 5606 } |
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6117 expect(method.propertyKeyword, isNull); | 6087 expect(method.propertyKeyword, isNull); |
6118 expect(method.returnType, isNotNull); | 6088 expect(method.returnType, isNotNull); |
6119 expect(method.name, isNotNull); | 6089 expect(method.name, isNotNull); |
6120 expect(method.operatorKeyword, isNull); | 6090 expect(method.operatorKeyword, isNull); |
6121 expect(method.typeParameters, isNotNull); | 6091 expect(method.typeParameters, isNotNull); |
6122 expect(method.parameters, isNotNull); | 6092 expect(method.parameters, isNotNull); |
6123 expect(method.body, isNotNull); | 6093 expect(method.body, isNotNull); |
6124 } | 6094 } |
6125 | 6095 |
6126 void test_parseClassMember_method_generic_noReturnType() { | 6096 void test_parseClassMember_method_generic_noReturnType() { |
6127 enableGenericMethods = true; | |
6128 createParser('m<T>() {}'); | 6097 createParser('m<T>() {}'); |
6129 ClassMember member = parser.parseClassMember('C'); | 6098 ClassMember member = parser.parseClassMember('C'); |
6130 expectNotNullIfNoErrors(member); | 6099 expectNotNullIfNoErrors(member); |
6131 listener.assertNoErrors(); | 6100 listener.assertNoErrors(); |
6132 expect(member, new isInstanceOf<MethodDeclaration>()); | 6101 expect(member, new isInstanceOf<MethodDeclaration>()); |
6133 MethodDeclaration method = member; | 6102 MethodDeclaration method = member; |
6134 expect(method.documentationComment, isNull); | 6103 expect(method.documentationComment, isNull); |
6135 expect(method.externalKeyword, isNull); | 6104 expect(method.externalKeyword, isNull); |
6136 expect(method.modifierKeyword, isNull); | 6105 expect(method.modifierKeyword, isNull); |
6137 expect(method.propertyKeyword, isNull); | 6106 expect(method.propertyKeyword, isNull); |
6138 expect(method.returnType, isNull); | 6107 expect(method.returnType, isNull); |
6139 expect(method.name, isNotNull); | 6108 expect(method.name, isNotNull); |
6140 expect(method.operatorKeyword, isNull); | 6109 expect(method.operatorKeyword, isNull); |
6141 expect(method.typeParameters, isNotNull); | 6110 expect(method.typeParameters, isNotNull); |
6142 expect(method.parameters, isNotNull); | 6111 expect(method.parameters, isNotNull); |
6143 expect(method.body, isNotNull); | 6112 expect(method.body, isNotNull); |
6144 } | 6113 } |
6145 | 6114 |
6146 void test_parseClassMember_method_generic_returnType() { | 6115 void test_parseClassMember_method_generic_returnType() { |
6147 enableGenericMethods = true; | |
6148 createParser('T m<T>() {}'); | 6116 createParser('T m<T>() {}'); |
6149 ClassMember member = parser.parseClassMember('C'); | 6117 ClassMember member = parser.parseClassMember('C'); |
6150 expectNotNullIfNoErrors(member); | 6118 expectNotNullIfNoErrors(member); |
6151 listener.assertNoErrors(); | 6119 listener.assertNoErrors(); |
6152 expect(member, new isInstanceOf<MethodDeclaration>()); | 6120 expect(member, new isInstanceOf<MethodDeclaration>()); |
6153 MethodDeclaration method = member; | 6121 MethodDeclaration method = member; |
6154 expect(method.documentationComment, isNull); | 6122 expect(method.documentationComment, isNull); |
6155 expect(method.externalKeyword, isNull); | 6123 expect(method.externalKeyword, isNull); |
6156 expect(method.modifierKeyword, isNull); | 6124 expect(method.modifierKeyword, isNull); |
6157 expect(method.propertyKeyword, isNull); | 6125 expect(method.propertyKeyword, isNull); |
6158 expect(method.returnType, isNotNull); | 6126 expect(method.returnType, isNotNull); |
6159 expect(method.name, isNotNull); | 6127 expect(method.name, isNotNull); |
6160 expect(method.operatorKeyword, isNull); | 6128 expect(method.operatorKeyword, isNull); |
6161 expect(method.typeParameters, isNotNull); | 6129 expect(method.typeParameters, isNotNull); |
6162 expect(method.parameters, isNotNull); | 6130 expect(method.parameters, isNotNull); |
6163 expect(method.body, isNotNull); | 6131 expect(method.body, isNotNull); |
6164 } | 6132 } |
6165 | 6133 |
6166 void test_parseClassMember_method_generic_void() { | 6134 void test_parseClassMember_method_generic_void() { |
6167 enableGenericMethods = true; | |
6168 createParser('void m<T>() {}'); | 6135 createParser('void m<T>() {}'); |
6169 ClassMember member = parser.parseClassMember('C'); | 6136 ClassMember member = parser.parseClassMember('C'); |
6170 expectNotNullIfNoErrors(member); | 6137 expectNotNullIfNoErrors(member); |
6171 listener.assertNoErrors(); | 6138 listener.assertNoErrors(); |
6172 expect(member, new isInstanceOf<MethodDeclaration>()); | 6139 expect(member, new isInstanceOf<MethodDeclaration>()); |
6173 MethodDeclaration method = member; | 6140 MethodDeclaration method = member; |
6174 expect(method.documentationComment, isNull); | 6141 expect(method.documentationComment, isNull); |
6175 expect(method.externalKeyword, isNull); | 6142 expect(method.externalKeyword, isNull); |
6176 expect(method.modifierKeyword, isNull); | 6143 expect(method.modifierKeyword, isNull); |
6177 expect(method.propertyKeyword, isNull); | 6144 expect(method.propertyKeyword, isNull); |
(...skipping 1169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7347 expectNotNullIfNoErrors(member); | 7314 expectNotNullIfNoErrors(member); |
7348 listener.assertNoErrors(); | 7315 listener.assertNoErrors(); |
7349 expect(member, new isInstanceOf<FunctionDeclaration>()); | 7316 expect(member, new isInstanceOf<FunctionDeclaration>()); |
7350 FunctionDeclaration declaration = member; | 7317 FunctionDeclaration declaration = member; |
7351 expect(declaration.externalKeyword, isNotNull); | 7318 expect(declaration.externalKeyword, isNotNull); |
7352 expect(declaration.functionExpression, isNotNull); | 7319 expect(declaration.functionExpression, isNotNull); |
7353 expect(declaration.propertyKeyword, isNull); | 7320 expect(declaration.propertyKeyword, isNull); |
7354 } | 7321 } |
7355 | 7322 |
7356 void test_parseCompilationUnitMember_function_generic_noReturnType() { | 7323 void test_parseCompilationUnitMember_function_generic_noReturnType() { |
7357 enableGenericMethods = true; | |
7358 createParser('f<E>() {}'); | 7324 createParser('f<E>() {}'); |
7359 CompilationUnitMember member = | 7325 CompilationUnitMember member = |
7360 parser.parseCompilationUnitMember(emptyCommentAndMetadata()); | 7326 parser.parseCompilationUnitMember(emptyCommentAndMetadata()); |
7361 expectNotNullIfNoErrors(member); | 7327 expectNotNullIfNoErrors(member); |
7362 listener.assertNoErrors(); | 7328 listener.assertNoErrors(); |
7363 expect(member, new isInstanceOf<FunctionDeclaration>()); | 7329 expect(member, new isInstanceOf<FunctionDeclaration>()); |
7364 FunctionDeclaration declaration = member; | 7330 FunctionDeclaration declaration = member; |
7365 expect(declaration.returnType, isNull); | 7331 expect(declaration.returnType, isNull); |
7366 expect(declaration.functionExpression.typeParameters, isNotNull); | 7332 expect(declaration.functionExpression.typeParameters, isNotNull); |
7367 } | 7333 } |
7368 | 7334 |
7369 void | 7335 void |
7370 test_parseCompilationUnitMember_function_generic_noReturnType_annotated()
{ | 7336 test_parseCompilationUnitMember_function_generic_noReturnType_annotated()
{ |
7371 enableGenericMethods = true; | |
7372 createParser('f<@a E>() {}'); | 7337 createParser('f<@a E>() {}'); |
7373 CompilationUnitMember member = | 7338 CompilationUnitMember member = |
7374 parser.parseCompilationUnitMember(emptyCommentAndMetadata()); | 7339 parser.parseCompilationUnitMember(emptyCommentAndMetadata()); |
7375 expectNotNullIfNoErrors(member); | 7340 expectNotNullIfNoErrors(member); |
7376 listener.assertNoErrors(); | 7341 listener.assertNoErrors(); |
7377 expect(member, new isInstanceOf<FunctionDeclaration>()); | 7342 expect(member, new isInstanceOf<FunctionDeclaration>()); |
7378 FunctionDeclaration declaration = member; | 7343 FunctionDeclaration declaration = member; |
7379 expect(declaration.returnType, isNull); | 7344 expect(declaration.returnType, isNull); |
7380 expect(declaration.functionExpression.typeParameters, isNotNull); | 7345 expect(declaration.functionExpression.typeParameters, isNotNull); |
7381 } | 7346 } |
7382 | 7347 |
7383 void test_parseCompilationUnitMember_function_generic_returnType() { | 7348 void test_parseCompilationUnitMember_function_generic_returnType() { |
7384 enableGenericMethods = true; | |
7385 createParser('E f<E>() {}'); | 7349 createParser('E f<E>() {}'); |
7386 CompilationUnitMember member = | 7350 CompilationUnitMember member = |
7387 parser.parseCompilationUnitMember(emptyCommentAndMetadata()); | 7351 parser.parseCompilationUnitMember(emptyCommentAndMetadata()); |
7388 expectNotNullIfNoErrors(member); | 7352 expectNotNullIfNoErrors(member); |
7389 listener.assertNoErrors(); | 7353 listener.assertNoErrors(); |
7390 expect(member, new isInstanceOf<FunctionDeclaration>()); | 7354 expect(member, new isInstanceOf<FunctionDeclaration>()); |
7391 FunctionDeclaration declaration = member; | 7355 FunctionDeclaration declaration = member; |
7392 expect(declaration.returnType, isNotNull); | 7356 expect(declaration.returnType, isNotNull); |
7393 expect(declaration.functionExpression.typeParameters, isNotNull); | 7357 expect(declaration.functionExpression.typeParameters, isNotNull); |
7394 } | 7358 } |
7395 | 7359 |
7396 void test_parseCompilationUnitMember_function_generic_void() { | 7360 void test_parseCompilationUnitMember_function_generic_void() { |
7397 enableGenericMethods = true; | |
7398 createParser('void f<T>(T t) {}'); | 7361 createParser('void f<T>(T t) {}'); |
7399 CompilationUnitMember member = | 7362 CompilationUnitMember member = |
7400 parser.parseCompilationUnitMember(emptyCommentAndMetadata()); | 7363 parser.parseCompilationUnitMember(emptyCommentAndMetadata()); |
7401 expectNotNullIfNoErrors(member); | 7364 expectNotNullIfNoErrors(member); |
7402 listener.assertNoErrors(); | 7365 listener.assertNoErrors(); |
7403 expect(member, new isInstanceOf<FunctionDeclaration>()); | 7366 expect(member, new isInstanceOf<FunctionDeclaration>()); |
7404 FunctionDeclaration declaration = member; | 7367 FunctionDeclaration declaration = member; |
7405 expect(declaration.functionExpression, isNotNull); | 7368 expect(declaration.functionExpression, isNotNull); |
7406 expect(declaration.propertyKeyword, isNull); | 7369 expect(declaration.propertyKeyword, isNull); |
7407 } | 7370 } |
(...skipping 998 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8406 Expression expression = parseExpression('super.m/*<E>*/()'); | 8369 Expression expression = parseExpression('super.m/*<E>*/()'); |
8407 expect(expression, new isInstanceOf<MethodInvocation>()); | 8370 expect(expression, new isInstanceOf<MethodInvocation>()); |
8408 MethodInvocation invocation = expression; | 8371 MethodInvocation invocation = expression; |
8409 expect(invocation.target, isNotNull); | 8372 expect(invocation.target, isNotNull); |
8410 expect(invocation.methodName, isNotNull); | 8373 expect(invocation.methodName, isNotNull); |
8411 expect(invocation.typeArguments, isNotNull); | 8374 expect(invocation.typeArguments, isNotNull); |
8412 expect(invocation.argumentList, isNotNull); | 8375 expect(invocation.argumentList, isNotNull); |
8413 } | 8376 } |
8414 | 8377 |
8415 void test_parseExpression_superMethodInvocation_typeArguments() { | 8378 void test_parseExpression_superMethodInvocation_typeArguments() { |
8416 enableGenericMethods = true; | |
8417 Expression expression = parseExpression('super.m<E>()'); | 8379 Expression expression = parseExpression('super.m<E>()'); |
8418 expect(expression, new isInstanceOf<MethodInvocation>()); | 8380 expect(expression, new isInstanceOf<MethodInvocation>()); |
8419 MethodInvocation invocation = expression; | 8381 MethodInvocation invocation = expression; |
8420 expect(invocation.target, isNotNull); | 8382 expect(invocation.target, isNotNull); |
8421 expect(invocation.methodName, isNotNull); | 8383 expect(invocation.methodName, isNotNull); |
8422 expect(invocation.typeArguments, isNotNull); | 8384 expect(invocation.typeArguments, isNotNull); |
8423 expect(invocation.argumentList, isNotNull); | 8385 expect(invocation.argumentList, isNotNull); |
8424 } | 8386 } |
8425 | 8387 |
8426 void test_parseExpressionList_multiple() { | 8388 void test_parseExpressionList_multiple() { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8489 expect(expression, new isInstanceOf<MethodInvocation>()); | 8451 expect(expression, new isInstanceOf<MethodInvocation>()); |
8490 MethodInvocation invocation = expression; | 8452 MethodInvocation invocation = expression; |
8491 expect(invocation.target, isNotNull); | 8453 expect(invocation.target, isNotNull); |
8492 expect(invocation.methodName, isNotNull); | 8454 expect(invocation.methodName, isNotNull); |
8493 expect(invocation.typeArguments, isNotNull); | 8455 expect(invocation.typeArguments, isNotNull); |
8494 expect(invocation.argumentList, isNotNull); | 8456 expect(invocation.argumentList, isNotNull); |
8495 } | 8457 } |
8496 | 8458 |
8497 void | 8459 void |
8498 test_parseExpressionWithoutCascade_superMethodInvocation_typeArguments() { | 8460 test_parseExpressionWithoutCascade_superMethodInvocation_typeArguments() { |
8499 enableGenericMethods = true; | |
8500 createParser('super.m<E>()'); | 8461 createParser('super.m<E>()'); |
8501 Expression expression = parser.parseExpressionWithoutCascade(); | 8462 Expression expression = parser.parseExpressionWithoutCascade(); |
8502 expectNotNullIfNoErrors(expression); | 8463 expectNotNullIfNoErrors(expression); |
8503 listener.assertNoErrors(); | 8464 listener.assertNoErrors(); |
8504 expect(expression, new isInstanceOf<MethodInvocation>()); | 8465 expect(expression, new isInstanceOf<MethodInvocation>()); |
8505 MethodInvocation invocation = expression; | 8466 MethodInvocation invocation = expression; |
8506 expect(invocation.target, isNotNull); | 8467 expect(invocation.target, isNotNull); |
8507 expect(invocation.methodName, isNotNull); | 8468 expect(invocation.methodName, isNotNull); |
8508 expect(invocation.typeArguments, isNotNull); | 8469 expect(invocation.typeArguments, isNotNull); |
8509 expect(invocation.argumentList, isNotNull); | 8470 expect(invocation.argumentList, isNotNull); |
(...skipping 952 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9462 expect(declaration.name, isNotNull); | 9423 expect(declaration.name, isNotNull); |
9463 FunctionExpression expression = declaration.functionExpression; | 9424 FunctionExpression expression = declaration.functionExpression; |
9464 expect(expression, isNotNull); | 9425 expect(expression, isNotNull); |
9465 expect(expression.body, isNotNull); | 9426 expect(expression.body, isNotNull); |
9466 expect(expression.typeParameters, isNull); | 9427 expect(expression.typeParameters, isNull); |
9467 expect(expression.parameters, isNotNull); | 9428 expect(expression.parameters, isNotNull); |
9468 expect(declaration.propertyKeyword, isNull); | 9429 expect(declaration.propertyKeyword, isNull); |
9469 } | 9430 } |
9470 | 9431 |
9471 void test_parseFunctionDeclaration_functionWithTypeParameters() { | 9432 void test_parseFunctionDeclaration_functionWithTypeParameters() { |
9472 enableGenericMethods = true; | |
9473 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); | 9433 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); |
9474 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); | 9434 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); |
9475 createParser('f<E>() {}'); | 9435 createParser('f<E>() {}'); |
9476 FunctionDeclaration declaration = parser.parseFunctionDeclaration( | 9436 FunctionDeclaration declaration = parser.parseFunctionDeclaration( |
9477 commentAndMetadata(comment), null, returnType); | 9437 commentAndMetadata(comment), null, returnType); |
9478 expectNotNullIfNoErrors(declaration); | 9438 expectNotNullIfNoErrors(declaration); |
9479 listener.assertNoErrors(); | 9439 listener.assertNoErrors(); |
9480 expect(declaration.documentationComment, comment); | 9440 expect(declaration.documentationComment, comment); |
9481 expect(declaration.returnType, returnType); | 9441 expect(declaration.returnType, returnType); |
9482 expect(declaration.name, isNotNull); | 9442 expect(declaration.name, isNotNull); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9564 listener.assertNoErrors(); | 9524 listener.assertNoErrors(); |
9565 FunctionDeclaration f = statement.functionDeclaration; | 9525 FunctionDeclaration f = statement.functionDeclaration; |
9566 expect(f, isNotNull); | 9526 expect(f, isNotNull); |
9567 expect(f.functionExpression.typeParameters, isNotNull); | 9527 expect(f.functionExpression.typeParameters, isNotNull); |
9568 expect(f.returnType, isNotNull); | 9528 expect(f.returnType, isNotNull); |
9569 SimpleFormalParameter p = f.functionExpression.parameters.parameters[0]; | 9529 SimpleFormalParameter p = f.functionExpression.parameters.parameters[0]; |
9570 expect(p.type, isNotNull); | 9530 expect(p.type, isNotNull); |
9571 } | 9531 } |
9572 | 9532 |
9573 void test_parseFunctionDeclarationStatement_typeParameters() { | 9533 void test_parseFunctionDeclarationStatement_typeParameters() { |
9574 enableGenericMethods = true; | |
9575 createParser('E f<E>(E p) => p * 2;'); | 9534 createParser('E f<E>(E p) => p * 2;'); |
9576 FunctionDeclarationStatement statement = | 9535 FunctionDeclarationStatement statement = |
9577 parser.parseFunctionDeclarationStatement(); | 9536 parser.parseFunctionDeclarationStatement(); |
9578 expectNotNullIfNoErrors(statement); | 9537 expectNotNullIfNoErrors(statement); |
9579 listener.assertNoErrors(); | 9538 listener.assertNoErrors(); |
9580 expect(statement.functionDeclaration, isNotNull); | 9539 expect(statement.functionDeclaration, isNotNull); |
9581 expect(statement.functionDeclaration.functionExpression.typeParameters, | 9540 expect(statement.functionDeclaration.functionExpression.typeParameters, |
9582 isNotNull); | 9541 isNotNull); |
9583 } | 9542 } |
9584 | 9543 |
(...skipping 16 matching lines...) Expand all Loading... |
9601 listener.assertNoErrors(); | 9560 listener.assertNoErrors(); |
9602 expect(expression.body, isNotNull); | 9561 expect(expression.body, isNotNull); |
9603 expect(expression.typeParameters, isNotNull); | 9562 expect(expression.typeParameters, isNotNull); |
9604 expect(expression.parameters, isNotNull); | 9563 expect(expression.parameters, isNotNull); |
9605 expect((expression.body as ExpressionFunctionBody).semicolon, isNull); | 9564 expect((expression.body as ExpressionFunctionBody).semicolon, isNull); |
9606 SimpleFormalParameter p = expression.parameters.parameters[0]; | 9565 SimpleFormalParameter p = expression.parameters.parameters[0]; |
9607 expect(p.type, isNotNull); | 9566 expect(p.type, isNotNull); |
9608 } | 9567 } |
9609 | 9568 |
9610 void test_parseFunctionExpression_typeParameters() { | 9569 void test_parseFunctionExpression_typeParameters() { |
9611 enableGenericMethods = true; | |
9612 createParser('<E>(E i) => i++'); | 9570 createParser('<E>(E i) => i++'); |
9613 FunctionExpression expression = parser.parseFunctionExpression(); | 9571 FunctionExpression expression = parser.parseFunctionExpression(); |
9614 expectNotNullIfNoErrors(expression); | 9572 expectNotNullIfNoErrors(expression); |
9615 listener.assertNoErrors(); | 9573 listener.assertNoErrors(); |
9616 expect(expression.body, isNotNull); | 9574 expect(expression.body, isNotNull); |
9617 expect(expression.typeParameters, isNotNull); | 9575 expect(expression.typeParameters, isNotNull); |
9618 expect(expression.parameters, isNotNull); | 9576 expect(expression.parameters, isNotNull); |
9619 expect((expression.body as ExpressionFunctionBody).semicolon, isNull); | 9577 expect((expression.body as ExpressionFunctionBody).semicolon, isNull); |
9620 } | 9578 } |
9621 | 9579 |
(...skipping 1223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10845 listener.assertNoErrors(); | 10803 listener.assertNoErrors(); |
10846 expect(parameter, new isInstanceOf<FunctionTypedFormalParameter>()); | 10804 expect(parameter, new isInstanceOf<FunctionTypedFormalParameter>()); |
10847 FunctionTypedFormalParameter functionParameter = parameter; | 10805 FunctionTypedFormalParameter functionParameter = parameter; |
10848 expect(functionParameter.returnType, isNull); | 10806 expect(functionParameter.returnType, isNull); |
10849 expect(functionParameter.identifier, isNotNull); | 10807 expect(functionParameter.identifier, isNotNull); |
10850 expect(functionParameter.typeParameters, isNotNull); | 10808 expect(functionParameter.typeParameters, isNotNull); |
10851 expect(functionParameter.parameters, isNotNull); | 10809 expect(functionParameter.parameters, isNotNull); |
10852 } | 10810 } |
10853 | 10811 |
10854 void test_parseNormalFormalParameter_function_noType_typeParameters() { | 10812 void test_parseNormalFormalParameter_function_noType_typeParameters() { |
10855 enableGenericMethods = true; | |
10856 createParser('a<E>())'); | 10813 createParser('a<E>())'); |
10857 NormalFormalParameter parameter = parser.parseNormalFormalParameter(); | 10814 NormalFormalParameter parameter = parser.parseNormalFormalParameter(); |
10858 expectNotNullIfNoErrors(parameter); | 10815 expectNotNullIfNoErrors(parameter); |
10859 listener.assertNoErrors(); | 10816 listener.assertNoErrors(); |
10860 expect(parameter, new isInstanceOf<FunctionTypedFormalParameter>()); | 10817 expect(parameter, new isInstanceOf<FunctionTypedFormalParameter>()); |
10861 FunctionTypedFormalParameter functionParameter = parameter; | 10818 FunctionTypedFormalParameter functionParameter = parameter; |
10862 expect(functionParameter.returnType, isNull); | 10819 expect(functionParameter.returnType, isNull); |
10863 expect(functionParameter.identifier, isNotNull); | 10820 expect(functionParameter.identifier, isNotNull); |
10864 expect(functionParameter.typeParameters, isNotNull); | 10821 expect(functionParameter.typeParameters, isNotNull); |
10865 expect(functionParameter.parameters, isNotNull); | 10822 expect(functionParameter.parameters, isNotNull); |
10866 expect(functionParameter.question, isNull); | 10823 expect(functionParameter.question, isNull); |
10867 expect(functionParameter.question, isNull); | 10824 expect(functionParameter.question, isNull); |
10868 } | 10825 } |
10869 | 10826 |
10870 void | 10827 void |
10871 test_parseNormalFormalParameter_function_noType_typeParameters_nullable()
{ | 10828 test_parseNormalFormalParameter_function_noType_typeParameters_nullable()
{ |
10872 enableGenericMethods = true; | |
10873 enableNnbd = true; | 10829 enableNnbd = true; |
10874 createParser('a<E>()?)'); | 10830 createParser('a<E>()?)'); |
10875 NormalFormalParameter parameter = parser.parseNormalFormalParameter(); | 10831 NormalFormalParameter parameter = parser.parseNormalFormalParameter(); |
10876 expectNotNullIfNoErrors(parameter); | 10832 expectNotNullIfNoErrors(parameter); |
10877 listener.assertNoErrors(); | 10833 listener.assertNoErrors(); |
10878 expect(parameter, new isInstanceOf<FunctionTypedFormalParameter>()); | 10834 expect(parameter, new isInstanceOf<FunctionTypedFormalParameter>()); |
10879 FunctionTypedFormalParameter functionParameter = parameter; | 10835 FunctionTypedFormalParameter functionParameter = parameter; |
10880 expect(functionParameter.returnType, isNull); | 10836 expect(functionParameter.returnType, isNull); |
10881 expect(functionParameter.identifier, isNotNull); | 10837 expect(functionParameter.identifier, isNotNull); |
10882 expect(functionParameter.typeParameters, isNotNull); | 10838 expect(functionParameter.typeParameters, isNotNull); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10922 expect(parameter, new isInstanceOf<FunctionTypedFormalParameter>()); | 10878 expect(parameter, new isInstanceOf<FunctionTypedFormalParameter>()); |
10923 FunctionTypedFormalParameter functionParameter = parameter; | 10879 FunctionTypedFormalParameter functionParameter = parameter; |
10924 expect(functionParameter.returnType, isNotNull); | 10880 expect(functionParameter.returnType, isNotNull); |
10925 expect(functionParameter.identifier, isNotNull); | 10881 expect(functionParameter.identifier, isNotNull); |
10926 expect(functionParameter.typeParameters, isNotNull); | 10882 expect(functionParameter.typeParameters, isNotNull); |
10927 expect(functionParameter.parameters, isNotNull); | 10883 expect(functionParameter.parameters, isNotNull); |
10928 expect(functionParameter.question, isNull); | 10884 expect(functionParameter.question, isNull); |
10929 } | 10885 } |
10930 | 10886 |
10931 void test_parseNormalFormalParameter_function_type_typeParameters() { | 10887 void test_parseNormalFormalParameter_function_type_typeParameters() { |
10932 enableGenericMethods = true; | |
10933 createParser('A a<E>())'); | 10888 createParser('A a<E>())'); |
10934 NormalFormalParameter parameter = parser.parseNormalFormalParameter(); | 10889 NormalFormalParameter parameter = parser.parseNormalFormalParameter(); |
10935 expectNotNullIfNoErrors(parameter); | 10890 expectNotNullIfNoErrors(parameter); |
10936 listener.assertNoErrors(); | 10891 listener.assertNoErrors(); |
10937 expect(parameter, new isInstanceOf<FunctionTypedFormalParameter>()); | 10892 expect(parameter, new isInstanceOf<FunctionTypedFormalParameter>()); |
10938 FunctionTypedFormalParameter functionParameter = parameter; | 10893 FunctionTypedFormalParameter functionParameter = parameter; |
10939 expect(functionParameter.returnType, isNotNull); | 10894 expect(functionParameter.returnType, isNotNull); |
10940 expect(functionParameter.identifier, isNotNull); | 10895 expect(functionParameter.identifier, isNotNull); |
10941 expect(functionParameter.typeParameters, isNotNull); | 10896 expect(functionParameter.typeParameters, isNotNull); |
10942 expect(functionParameter.parameters, isNotNull); | 10897 expect(functionParameter.parameters, isNotNull); |
10943 expect(functionParameter.question, isNull); | 10898 expect(functionParameter.question, isNull); |
10944 } | 10899 } |
10945 | 10900 |
10946 void test_parseNormalFormalParameter_function_type_typeParameters_nullable() { | 10901 void test_parseNormalFormalParameter_function_type_typeParameters_nullable() { |
10947 enableGenericMethods = true; | |
10948 enableNnbd = true; | 10902 enableNnbd = true; |
10949 createParser('A a<E>()?)'); | 10903 createParser('A a<E>()?)'); |
10950 NormalFormalParameter parameter = parser.parseNormalFormalParameter(); | 10904 NormalFormalParameter parameter = parser.parseNormalFormalParameter(); |
10951 expectNotNullIfNoErrors(parameter); | 10905 expectNotNullIfNoErrors(parameter); |
10952 listener.assertNoErrors(); | 10906 listener.assertNoErrors(); |
10953 expect(parameter, new isInstanceOf<FunctionTypedFormalParameter>()); | 10907 expect(parameter, new isInstanceOf<FunctionTypedFormalParameter>()); |
10954 FunctionTypedFormalParameter functionParameter = parameter; | 10908 FunctionTypedFormalParameter functionParameter = parameter; |
10955 expect(functionParameter.returnType, isNotNull); | 10909 expect(functionParameter.returnType, isNotNull); |
10956 expect(functionParameter.identifier, isNotNull); | 10910 expect(functionParameter.identifier, isNotNull); |
10957 expect(functionParameter.typeParameters, isNotNull); | 10911 expect(functionParameter.typeParameters, isNotNull); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10997 expect(parameter, new isInstanceOf<FunctionTypedFormalParameter>()); | 10951 expect(parameter, new isInstanceOf<FunctionTypedFormalParameter>()); |
10998 FunctionTypedFormalParameter functionParameter = parameter; | 10952 FunctionTypedFormalParameter functionParameter = parameter; |
10999 expect(functionParameter.returnType, isNotNull); | 10953 expect(functionParameter.returnType, isNotNull); |
11000 expect(functionParameter.identifier, isNotNull); | 10954 expect(functionParameter.identifier, isNotNull); |
11001 expect(functionParameter.typeParameters, isNotNull); | 10955 expect(functionParameter.typeParameters, isNotNull); |
11002 expect(functionParameter.parameters, isNotNull); | 10956 expect(functionParameter.parameters, isNotNull); |
11003 expect(functionParameter.question, isNull); | 10957 expect(functionParameter.question, isNull); |
11004 } | 10958 } |
11005 | 10959 |
11006 void test_parseNormalFormalParameter_function_void_typeParameters() { | 10960 void test_parseNormalFormalParameter_function_void_typeParameters() { |
11007 enableGenericMethods = true; | |
11008 createParser('void a<E>())'); | 10961 createParser('void a<E>())'); |
11009 NormalFormalParameter parameter = parser.parseNormalFormalParameter(); | 10962 NormalFormalParameter parameter = parser.parseNormalFormalParameter(); |
11010 expectNotNullIfNoErrors(parameter); | 10963 expectNotNullIfNoErrors(parameter); |
11011 listener.assertNoErrors(); | 10964 listener.assertNoErrors(); |
11012 expect(parameter, new isInstanceOf<FunctionTypedFormalParameter>()); | 10965 expect(parameter, new isInstanceOf<FunctionTypedFormalParameter>()); |
11013 FunctionTypedFormalParameter functionParameter = parameter; | 10966 FunctionTypedFormalParameter functionParameter = parameter; |
11014 expect(functionParameter.returnType, isNotNull); | 10967 expect(functionParameter.returnType, isNotNull); |
11015 expect(functionParameter.identifier, isNotNull); | 10968 expect(functionParameter.identifier, isNotNull); |
11016 expect(functionParameter.typeParameters, isNotNull); | 10969 expect(functionParameter.typeParameters, isNotNull); |
11017 expect(functionParameter.parameters, isNotNull); | 10970 expect(functionParameter.parameters, isNotNull); |
11018 expect(functionParameter.question, isNull); | 10971 expect(functionParameter.question, isNull); |
11019 } | 10972 } |
11020 | 10973 |
11021 void test_parseNormalFormalParameter_function_void_typeParameters_nullable() { | 10974 void test_parseNormalFormalParameter_function_void_typeParameters_nullable() { |
11022 enableGenericMethods = true; | |
11023 enableNnbd = true; | 10975 enableNnbd = true; |
11024 createParser('void a<E>()?)'); | 10976 createParser('void a<E>()?)'); |
11025 NormalFormalParameter parameter = parser.parseNormalFormalParameter(); | 10977 NormalFormalParameter parameter = parser.parseNormalFormalParameter(); |
11026 expectNotNullIfNoErrors(parameter); | 10978 expectNotNullIfNoErrors(parameter); |
11027 listener.assertNoErrors(); | 10979 listener.assertNoErrors(); |
11028 expect(parameter, new isInstanceOf<FunctionTypedFormalParameter>()); | 10980 expect(parameter, new isInstanceOf<FunctionTypedFormalParameter>()); |
11029 FunctionTypedFormalParameter functionParameter = parameter; | 10981 FunctionTypedFormalParameter functionParameter = parameter; |
11030 expect(functionParameter.returnType, isNotNull); | 10982 expect(functionParameter.returnType, isNotNull); |
11031 expect(functionParameter.identifier, isNotNull); | 10983 expect(functionParameter.identifier, isNotNull); |
11032 expect(functionParameter.typeParameters, isNotNull); | 10984 expect(functionParameter.typeParameters, isNotNull); |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11227 MethodInvocation methodInvocation = expression; | 11179 MethodInvocation methodInvocation = expression; |
11228 expect(methodInvocation.target, isNotNull); | 11180 expect(methodInvocation.target, isNotNull); |
11229 expect(methodInvocation.operator.type, TokenType.QUESTION_PERIOD); | 11181 expect(methodInvocation.operator.type, TokenType.QUESTION_PERIOD); |
11230 expect(methodInvocation.methodName, isNotNull); | 11182 expect(methodInvocation.methodName, isNotNull); |
11231 expect(methodInvocation.typeArguments, isNotNull); | 11183 expect(methodInvocation.typeArguments, isNotNull); |
11232 expect(methodInvocation.argumentList, isNotNull); | 11184 expect(methodInvocation.argumentList, isNotNull); |
11233 } | 11185 } |
11234 | 11186 |
11235 void | 11187 void |
11236 test_parsePostfixExpression_none_methodInvocation_question_dot_typeArgumen
ts() { | 11188 test_parsePostfixExpression_none_methodInvocation_question_dot_typeArgumen
ts() { |
11237 enableGenericMethods = true; | |
11238 createParser('a?.m<E>()'); | 11189 createParser('a?.m<E>()'); |
11239 Expression expression = parser.parsePostfixExpression(); | 11190 Expression expression = parser.parsePostfixExpression(); |
11240 expectNotNullIfNoErrors(expression); | 11191 expectNotNullIfNoErrors(expression); |
11241 listener.assertNoErrors(); | 11192 listener.assertNoErrors(); |
11242 expect(expression, new isInstanceOf<MethodInvocation>()); | 11193 expect(expression, new isInstanceOf<MethodInvocation>()); |
11243 MethodInvocation methodInvocation = expression; | 11194 MethodInvocation methodInvocation = expression; |
11244 expect(methodInvocation.target, isNotNull); | 11195 expect(methodInvocation.target, isNotNull); |
11245 expect(methodInvocation.operator.type, TokenType.QUESTION_PERIOD); | 11196 expect(methodInvocation.operator.type, TokenType.QUESTION_PERIOD); |
11246 expect(methodInvocation.methodName, isNotNull); | 11197 expect(methodInvocation.methodName, isNotNull); |
11247 expect(methodInvocation.typeArguments, isNotNull); | 11198 expect(methodInvocation.typeArguments, isNotNull); |
(...skipping 10 matching lines...) Expand all Loading... |
11258 expect(expression, new isInstanceOf<MethodInvocation>()); | 11209 expect(expression, new isInstanceOf<MethodInvocation>()); |
11259 MethodInvocation methodInvocation = expression; | 11210 MethodInvocation methodInvocation = expression; |
11260 expect(methodInvocation.target, isNotNull); | 11211 expect(methodInvocation.target, isNotNull); |
11261 expect(methodInvocation.operator.type, TokenType.PERIOD); | 11212 expect(methodInvocation.operator.type, TokenType.PERIOD); |
11262 expect(methodInvocation.methodName, isNotNull); | 11213 expect(methodInvocation.methodName, isNotNull); |
11263 expect(methodInvocation.typeArguments, isNotNull); | 11214 expect(methodInvocation.typeArguments, isNotNull); |
11264 expect(methodInvocation.argumentList, isNotNull); | 11215 expect(methodInvocation.argumentList, isNotNull); |
11265 } | 11216 } |
11266 | 11217 |
11267 void test_parsePostfixExpression_none_methodInvocation_typeArguments() { | 11218 void test_parsePostfixExpression_none_methodInvocation_typeArguments() { |
11268 enableGenericMethods = true; | |
11269 createParser('a.m<E>()'); | 11219 createParser('a.m<E>()'); |
11270 Expression expression = parser.parsePostfixExpression(); | 11220 Expression expression = parser.parsePostfixExpression(); |
11271 expectNotNullIfNoErrors(expression); | 11221 expectNotNullIfNoErrors(expression); |
11272 listener.assertNoErrors(); | 11222 listener.assertNoErrors(); |
11273 expect(expression, new isInstanceOf<MethodInvocation>()); | 11223 expect(expression, new isInstanceOf<MethodInvocation>()); |
11274 MethodInvocation methodInvocation = expression; | 11224 MethodInvocation methodInvocation = expression; |
11275 expect(methodInvocation.target, isNotNull); | 11225 expect(methodInvocation.target, isNotNull); |
11276 expect(methodInvocation.operator.type, TokenType.PERIOD); | 11226 expect(methodInvocation.operator.type, TokenType.PERIOD); |
11277 expect(methodInvocation.methodName, isNotNull); | 11227 expect(methodInvocation.methodName, isNotNull); |
11278 expect(methodInvocation.typeArguments, isNotNull); | 11228 expect(methodInvocation.typeArguments, isNotNull); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11362 Expression expression = parser.parsePrimaryExpression(); | 11312 Expression expression = parser.parsePrimaryExpression(); |
11363 expectNotNullIfNoErrors(expression); | 11313 expectNotNullIfNoErrors(expression); |
11364 listener.assertNoErrors(); | 11314 listener.assertNoErrors(); |
11365 expect(expression, new isInstanceOf<FunctionExpression>()); | 11315 expect(expression, new isInstanceOf<FunctionExpression>()); |
11366 FunctionExpression functionExpression = expression; | 11316 FunctionExpression functionExpression = expression; |
11367 expect(functionExpression.parameters, isNotNull); | 11317 expect(functionExpression.parameters, isNotNull); |
11368 expect(functionExpression.body, isNotNull); | 11318 expect(functionExpression.body, isNotNull); |
11369 } | 11319 } |
11370 | 11320 |
11371 void test_parsePrimaryExpression_genericFunctionExpression() { | 11321 void test_parsePrimaryExpression_genericFunctionExpression() { |
11372 enableGenericMethods = true; | |
11373 createParser('<X, Y>(Map<X, Y> m, X x) => m[x]'); | 11322 createParser('<X, Y>(Map<X, Y> m, X x) => m[x]'); |
11374 Expression expression = parser.parsePrimaryExpression(); | 11323 Expression expression = parser.parsePrimaryExpression(); |
11375 expectNotNullIfNoErrors(expression); | 11324 expectNotNullIfNoErrors(expression); |
11376 listener.assertNoErrors(); | 11325 listener.assertNoErrors(); |
11377 expect(expression, new isInstanceOf<FunctionExpression>()); | 11326 expect(expression, new isInstanceOf<FunctionExpression>()); |
11378 FunctionExpression function = expression; | 11327 FunctionExpression function = expression; |
11379 expect(function.typeParameters, isNotNull); | 11328 expect(function.typeParameters, isNotNull); |
11380 } | 11329 } |
11381 | 11330 |
11382 void test_parsePrimaryExpression_hex() { | 11331 void test_parsePrimaryExpression_hex() { |
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11877 listener.assertNoErrors(); | 11826 listener.assertNoErrors(); |
11878 expect(statement, new isInstanceOf<FunctionDeclarationStatement>()); | 11827 expect(statement, new isInstanceOf<FunctionDeclarationStatement>()); |
11879 FunctionDeclarationStatement declaration = statement; | 11828 FunctionDeclarationStatement declaration = statement; |
11880 expect(declaration.functionDeclaration, isNotNull); | 11829 expect(declaration.functionDeclaration, isNotNull); |
11881 expect(declaration.functionDeclaration.functionExpression.typeParameters, | 11830 expect(declaration.functionDeclaration.functionExpression.typeParameters, |
11882 isNotNull); | 11831 isNotNull); |
11883 } | 11832 } |
11884 | 11833 |
11885 @failingTest | 11834 @failingTest |
11886 void test_parseStatement_functionDeclaration_noReturnType_typeParameters() { | 11835 void test_parseStatement_functionDeclaration_noReturnType_typeParameters() { |
11887 enableGenericMethods = true; | |
11888 createParser('f<E>(a, b) {};'); | 11836 createParser('f<E>(a, b) {};'); |
11889 Statement statement = parser.parseStatement2(); | 11837 Statement statement = parser.parseStatement2(); |
11890 expectNotNullIfNoErrors(statement); | 11838 expectNotNullIfNoErrors(statement); |
11891 listener.assertNoErrors(); | 11839 listener.assertNoErrors(); |
11892 expect(statement, new isInstanceOf<FunctionDeclarationStatement>()); | 11840 expect(statement, new isInstanceOf<FunctionDeclarationStatement>()); |
11893 FunctionDeclarationStatement declaration = statement; | 11841 FunctionDeclarationStatement declaration = statement; |
11894 expect(declaration.functionDeclaration, isNotNull); | 11842 expect(declaration.functionDeclaration, isNotNull); |
11895 } | 11843 } |
11896 | 11844 |
11897 void test_parseStatement_functionDeclaration_returnType() { | 11845 void test_parseStatement_functionDeclaration_returnType() { |
11898 // TODO(brianwilkerson) Implement more tests for this method. | 11846 // TODO(brianwilkerson) Implement more tests for this method. |
11899 createParser('int f(a, b) {};'); | 11847 createParser('int f(a, b) {};'); |
11900 Statement statement = parser.parseStatement2(); | 11848 Statement statement = parser.parseStatement2(); |
11901 expectNotNullIfNoErrors(statement); | 11849 expectNotNullIfNoErrors(statement); |
11902 listener.assertNoErrors(); | 11850 listener.assertNoErrors(); |
11903 expect(statement, new isInstanceOf<FunctionDeclarationStatement>()); | 11851 expect(statement, new isInstanceOf<FunctionDeclarationStatement>()); |
11904 FunctionDeclarationStatement declaration = statement; | 11852 FunctionDeclarationStatement declaration = statement; |
11905 expect(declaration.functionDeclaration, isNotNull); | 11853 expect(declaration.functionDeclaration, isNotNull); |
11906 } | 11854 } |
11907 | 11855 |
11908 void test_parseStatement_functionDeclaration_returnType_typeParameters() { | 11856 void test_parseStatement_functionDeclaration_returnType_typeParameters() { |
11909 enableGenericMethods = true; | |
11910 createParser('int f<E>(a, b) {};'); | 11857 createParser('int f<E>(a, b) {};'); |
11911 Statement statement = parser.parseStatement2(); | 11858 Statement statement = parser.parseStatement2(); |
11912 expectNotNullIfNoErrors(statement); | 11859 expectNotNullIfNoErrors(statement); |
11913 listener.assertNoErrors(); | 11860 listener.assertNoErrors(); |
11914 expect(statement, new isInstanceOf<FunctionDeclarationStatement>()); | 11861 expect(statement, new isInstanceOf<FunctionDeclarationStatement>()); |
11915 FunctionDeclarationStatement declaration = statement; | 11862 FunctionDeclarationStatement declaration = statement; |
11916 expect(declaration.functionDeclaration, isNotNull); | 11863 expect(declaration.functionDeclaration, isNotNull); |
11917 } | 11864 } |
11918 | 11865 |
11919 void test_parseStatement_mulipleLabels() { | 11866 void test_parseStatement_mulipleLabels() { |
(...skipping 1554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13474 CompilationUnit _parseDirectives(String source, | 13421 CompilationUnit _parseDirectives(String source, |
13475 [List<ErrorCode> errorCodes = const <ErrorCode>[]]) { | 13422 [List<ErrorCode> errorCodes = const <ErrorCode>[]]) { |
13476 createParser(source); | 13423 createParser(source); |
13477 CompilationUnit unit = parser.parseDirectives2(); | 13424 CompilationUnit unit = parser.parseDirectives2(); |
13478 expect(unit, isNotNull); | 13425 expect(unit, isNotNull); |
13479 expect(unit.declarations, hasLength(0)); | 13426 expect(unit.declarations, hasLength(0)); |
13480 listener.assertErrorsWithCodes(errorCodes); | 13427 listener.assertErrorsWithCodes(errorCodes); |
13481 return unit; | 13428 return unit; |
13482 } | 13429 } |
13483 } | 13430 } |
OLD | NEW |