| 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 engine.parser_test; | 5 library engine.parser_test; |
| 6 | 6 |
| 7 import 'package:analyzer/src/generated/ast.dart'; | 7 import 'package:analyzer/src/generated/ast.dart'; |
| 8 import 'package:analyzer/src/generated/element.dart'; | 8 import 'package:analyzer/src/generated/element.dart'; |
| 9 import 'package:analyzer/src/generated/engine.dart'; | 9 import 'package:analyzer/src/generated/engine.dart'; |
| 10 import 'package:analyzer/src/generated/error.dart'; | 10 import 'package:analyzer/src/generated/error.dart'; |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 void test_assignableExpression_arguments_normal_chain() { | 166 void test_assignableExpression_arguments_normal_chain() { |
| 167 PropertyAccess propertyAccess1 = parseExpression("a(b)(c).d(e).f"); | 167 PropertyAccess propertyAccess1 = parseExpression("a(b)(c).d(e).f"); |
| 168 expect(propertyAccess1.propertyName.name, "f"); | 168 expect(propertyAccess1.propertyName.name, "f"); |
| 169 // | 169 // |
| 170 // a(b)(c).d(e) | 170 // a(b)(c).d(e) |
| 171 // | 171 // |
| 172 MethodInvocation invocation2 = EngineTestCase.assertInstanceOf( | 172 MethodInvocation invocation2 = EngineTestCase.assertInstanceOf( |
| 173 (obj) => obj is MethodInvocation, MethodInvocation, | 173 (obj) => obj is MethodInvocation, MethodInvocation, |
| 174 propertyAccess1.target); | 174 propertyAccess1.target); |
| 175 expect(invocation2.methodName.name, "d"); | 175 expect(invocation2.methodName.name, "d"); |
| 176 expect(invocation2.typeArguments, isNull); |
| 176 ArgumentList argumentList2 = invocation2.argumentList; | 177 ArgumentList argumentList2 = invocation2.argumentList; |
| 177 expect(argumentList2, isNotNull); | 178 expect(argumentList2, isNotNull); |
| 178 expect(argumentList2.arguments, hasLength(1)); | 179 expect(argumentList2.arguments, hasLength(1)); |
| 179 // | 180 // |
| 180 // a(b)(c) | 181 // a(b)(c) |
| 181 // | 182 // |
| 182 FunctionExpressionInvocation invocation3 = EngineTestCase.assertInstanceOf( | 183 FunctionExpressionInvocation invocation3 = EngineTestCase.assertInstanceOf( |
| 183 (obj) => obj is FunctionExpressionInvocation, | 184 (obj) => obj is FunctionExpressionInvocation, |
| 184 FunctionExpressionInvocation, invocation2.target); | 185 FunctionExpressionInvocation, invocation2.target); |
| 186 expect(invocation3.typeArguments, isNull); |
| 185 ArgumentList argumentList3 = invocation3.argumentList; | 187 ArgumentList argumentList3 = invocation3.argumentList; |
| 186 expect(argumentList3, isNotNull); | 188 expect(argumentList3, isNotNull); |
| 187 expect(argumentList3.arguments, hasLength(1)); | 189 expect(argumentList3.arguments, hasLength(1)); |
| 188 // | 190 // |
| 189 // a(b) | 191 // a(b) |
| 190 // | 192 // |
| 191 MethodInvocation invocation4 = EngineTestCase.assertInstanceOf( | 193 MethodInvocation invocation4 = EngineTestCase.assertInstanceOf( |
| 192 (obj) => obj is MethodInvocation, MethodInvocation, | 194 (obj) => obj is MethodInvocation, MethodInvocation, |
| 193 invocation3.function); | 195 invocation3.function); |
| 194 expect(invocation4.methodName.name, "a"); | 196 expect(invocation4.methodName.name, "a"); |
| 197 expect(invocation4.typeArguments, isNull); |
| 195 ArgumentList argumentList4 = invocation4.argumentList; | 198 ArgumentList argumentList4 = invocation4.argumentList; |
| 196 expect(argumentList4, isNotNull); | 199 expect(argumentList4, isNotNull); |
| 197 expect(argumentList4.arguments, hasLength(1)); | 200 expect(argumentList4.arguments, hasLength(1)); |
| 201 } |
| 202 |
| 203 void test_assignableExpression_arguments_normal_chain_typeArguments() { |
| 204 enableGenericMethods = true; |
| 205 PropertyAccess propertyAccess1 = parseExpression("a<E>(b)<F>(c).d<G>(e).f"); |
| 206 expect(propertyAccess1.propertyName.name, "f"); |
| 207 // |
| 208 // a<E>(b)<F>(c).d>G?(e) |
| 209 // |
| 210 MethodInvocation invocation2 = EngineTestCase.assertInstanceOf( |
| 211 (obj) => obj is MethodInvocation, MethodInvocation, |
| 212 propertyAccess1.target); |
| 213 expect(invocation2.methodName.name, "d"); |
| 214 expect(invocation2.typeArguments, isNotNull); |
| 215 ArgumentList argumentList2 = invocation2.argumentList; |
| 216 expect(argumentList2, isNotNull); |
| 217 expect(argumentList2.arguments, hasLength(1)); |
| 218 // |
| 219 // a<E>(b)<F>(c) |
| 220 // |
| 221 FunctionExpressionInvocation invocation3 = EngineTestCase.assertInstanceOf( |
| 222 (obj) => obj is FunctionExpressionInvocation, |
| 223 FunctionExpressionInvocation, invocation2.target); |
| 224 expect(invocation3.typeArguments, isNotNull); |
| 225 ArgumentList argumentList3 = invocation3.argumentList; |
| 226 expect(argumentList3, isNotNull); |
| 227 expect(argumentList3.arguments, hasLength(1)); |
| 228 // |
| 229 // a(b) |
| 230 // |
| 231 MethodInvocation invocation4 = EngineTestCase.assertInstanceOf( |
| 232 (obj) => obj is MethodInvocation, MethodInvocation, |
| 233 invocation3.function); |
| 234 expect(invocation4.methodName.name, "a"); |
| 235 expect(invocation4.typeArguments, isNotNull); |
| 236 ArgumentList argumentList4 = invocation4.argumentList; |
| 237 expect(argumentList4, isNotNull); |
| 238 expect(argumentList4.arguments, hasLength(1)); |
| 198 } | 239 } |
| 199 | 240 |
| 200 void test_assignmentExpression_compound() { | 241 void test_assignmentExpression_compound() { |
| 201 AssignmentExpression expression = parseExpression("x = y = 0"); | 242 AssignmentExpression expression = parseExpression("x = y = 0"); |
| 202 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 243 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
| 203 SimpleIdentifier, expression.leftHandSide); | 244 SimpleIdentifier, expression.leftHandSide); |
| 204 EngineTestCase.assertInstanceOf((obj) => obj is AssignmentExpression, | 245 EngineTestCase.assertInstanceOf((obj) => obj is AssignmentExpression, |
| 205 AssignmentExpression, expression.rightHandSide); | 246 AssignmentExpression, expression.rightHandSide); |
| 206 } | 247 } |
| 207 | 248 |
| (...skipping 1535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1743 void test_optionalAfterNormalParameters_positional() { | 1784 void test_optionalAfterNormalParameters_positional() { |
| 1744 ParserTestCase.parseCompilationUnit( | 1785 ParserTestCase.parseCompilationUnit( |
| 1745 "f([a], b) {}", [ParserErrorCode.NORMAL_BEFORE_OPTIONAL_PARAMETERS]); | 1786 "f([a], b) {}", [ParserErrorCode.NORMAL_BEFORE_OPTIONAL_PARAMETERS]); |
| 1746 } | 1787 } |
| 1747 | 1788 |
| 1748 void test_parseCascadeSection_missingIdentifier() { | 1789 void test_parseCascadeSection_missingIdentifier() { |
| 1749 MethodInvocation methodInvocation = parse4( | 1790 MethodInvocation methodInvocation = parse4( |
| 1750 "parseCascadeSection", "..()", [ParserErrorCode.MISSING_IDENTIFIER]); | 1791 "parseCascadeSection", "..()", [ParserErrorCode.MISSING_IDENTIFIER]); |
| 1751 expect(methodInvocation.target, isNull); | 1792 expect(methodInvocation.target, isNull); |
| 1752 expect(methodInvocation.methodName.name, ""); | 1793 expect(methodInvocation.methodName.name, ""); |
| 1794 expect(methodInvocation.typeArguments, isNull); |
| 1753 expect(methodInvocation.argumentList.arguments, hasLength(0)); | 1795 expect(methodInvocation.argumentList.arguments, hasLength(0)); |
| 1754 } | 1796 } |
| 1755 | 1797 |
| 1798 void test_parseCascadeSection_missingIdentifier_typeArguments() { |
| 1799 enableGenericMethods = true; |
| 1800 MethodInvocation methodInvocation = parse4( |
| 1801 "parseCascadeSection", "..<E>()", [ParserErrorCode.MISSING_IDENTIFIER]); |
| 1802 expect(methodInvocation.target, isNull); |
| 1803 expect(methodInvocation.methodName.name, ""); |
| 1804 expect(methodInvocation.typeArguments, isNotNull); |
| 1805 expect(methodInvocation.argumentList.arguments, hasLength(0)); |
| 1806 } |
| 1807 |
| 1756 void test_positionalAfterNamedArgument() { | 1808 void test_positionalAfterNamedArgument() { |
| 1757 parse4("parseArgumentList", "(x: 1, 2)", | 1809 parse4("parseArgumentList", "(x: 1, 2)", |
| 1758 [ParserErrorCode.POSITIONAL_AFTER_NAMED_ARGUMENT]); | 1810 [ParserErrorCode.POSITIONAL_AFTER_NAMED_ARGUMENT]); |
| 1759 } | 1811 } |
| 1760 | 1812 |
| 1761 void test_positionalParameterOutsideGroup() { | 1813 void test_positionalParameterOutsideGroup() { |
| 1762 parse4("parseFormalParameterList", "(a, b = 0)", | 1814 parse4("parseFormalParameterList", "(a, b = 0)", |
| 1763 [ParserErrorCode.POSITIONAL_PARAMETER_OUTSIDE_GROUP]); | 1815 [ParserErrorCode.POSITIONAL_PARAMETER_OUTSIDE_GROUP]); |
| 1764 } | 1816 } |
| 1765 | 1817 |
| (...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2521 * An empty list of objects used as arguments to zero-argument methods. | 2573 * An empty list of objects used as arguments to zero-argument methods. |
| 2522 */ | 2574 */ |
| 2523 static const List<Object> _EMPTY_ARGUMENTS = const <Object>[]; | 2575 static const List<Object> _EMPTY_ARGUMENTS = const <Object>[]; |
| 2524 | 2576 |
| 2525 /** | 2577 /** |
| 2526 * A flag indicating whether parser is to parse function bodies. | 2578 * A flag indicating whether parser is to parse function bodies. |
| 2527 */ | 2579 */ |
| 2528 static bool parseFunctionBodies = true; | 2580 static bool parseFunctionBodies = true; |
| 2529 | 2581 |
| 2530 /** | 2582 /** |
| 2583 * A flag indicating whether generic method support should be enabled for a |
| 2584 * specific test. |
| 2585 */ |
| 2586 bool enableGenericMethods = false; |
| 2587 |
| 2588 /** |
| 2531 * If non-null, this value is used to override the default value of | 2589 * If non-null, this value is used to override the default value of |
| 2532 * [Scanner.enableNullAwareOperators] before scanning. | 2590 * [Scanner.enableNullAwareOperators] before scanning. |
| 2533 */ | 2591 */ |
| 2534 bool _enableNullAwareOperators; | 2592 bool _enableNullAwareOperators; |
| 2535 | 2593 |
| 2536 /** | 2594 /** |
| 2537 * Return a CommentAndMetadata object with the given values that can be used f
or testing. | 2595 * Return a CommentAndMetadata object with the given values that can be used f
or testing. |
| 2538 * | 2596 * |
| 2539 * @param comment the comment to be wrapped in the object | 2597 * @param comment the comment to be wrapped in the object |
| 2540 * @param annotations the annotations to be wrapped in the object | 2598 * @param annotations the annotations to be wrapped in the object |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2578 new Scanner(null, new CharSequenceReader(source), listener); | 2636 new Scanner(null, new CharSequenceReader(source), listener); |
| 2579 if (_enableNullAwareOperators != null) { | 2637 if (_enableNullAwareOperators != null) { |
| 2580 scanner.enableNullAwareOperators = _enableNullAwareOperators; | 2638 scanner.enableNullAwareOperators = _enableNullAwareOperators; |
| 2581 } | 2639 } |
| 2582 Token tokenStream = scanner.tokenize(); | 2640 Token tokenStream = scanner.tokenize(); |
| 2583 listener.setLineInfo(new TestSource(), scanner.lineStarts); | 2641 listener.setLineInfo(new TestSource(), scanner.lineStarts); |
| 2584 // | 2642 // |
| 2585 // Parse the source. | 2643 // Parse the source. |
| 2586 // | 2644 // |
| 2587 Parser parser = createParser(listener); | 2645 Parser parser = createParser(listener); |
| 2646 parser.parseGenericMethods = enableGenericMethods; |
| 2588 parser.parseFunctionBodies = parseFunctionBodies; | 2647 parser.parseFunctionBodies = parseFunctionBodies; |
| 2589 Object result = | 2648 Object result = |
| 2590 invokeParserMethodImpl(parser, methodName, objects, tokenStream); | 2649 invokeParserMethodImpl(parser, methodName, objects, tokenStream); |
| 2591 // | 2650 // |
| 2592 // Partially test the results. | 2651 // Partially test the results. |
| 2593 // | 2652 // |
| 2594 if (!listener.hasErrors) { | 2653 if (!listener.hasErrors) { |
| 2595 expect(result, isNotNull); | 2654 expect(result, isNotNull); |
| 2596 } | 2655 } |
| 2597 return result; | 2656 return result; |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2711 [List<ErrorCode> errorCodes = ErrorCode.EMPTY_LIST]) { | 2770 [List<ErrorCode> errorCodes = ErrorCode.EMPTY_LIST]) { |
| 2712 GatheringErrorListener listener = new GatheringErrorListener(); | 2771 GatheringErrorListener listener = new GatheringErrorListener(); |
| 2713 Scanner scanner = | 2772 Scanner scanner = |
| 2714 new Scanner(null, new CharSequenceReader(source), listener); | 2773 new Scanner(null, new CharSequenceReader(source), listener); |
| 2715 if (_enableNullAwareOperators != null) { | 2774 if (_enableNullAwareOperators != null) { |
| 2716 scanner.enableNullAwareOperators = _enableNullAwareOperators; | 2775 scanner.enableNullAwareOperators = _enableNullAwareOperators; |
| 2717 } | 2776 } |
| 2718 listener.setLineInfo(new TestSource(), scanner.lineStarts); | 2777 listener.setLineInfo(new TestSource(), scanner.lineStarts); |
| 2719 Token token = scanner.tokenize(); | 2778 Token token = scanner.tokenize(); |
| 2720 Parser parser = createParser(listener); | 2779 Parser parser = createParser(listener); |
| 2780 parser.parseGenericMethods = enableGenericMethods; |
| 2721 Expression expression = parser.parseExpression(token); | 2781 Expression expression = parser.parseExpression(token); |
| 2722 expect(expression, isNotNull); | 2782 expect(expression, isNotNull); |
| 2723 listener.assertErrorsWithCodes(errorCodes); | 2783 listener.assertErrorsWithCodes(errorCodes); |
| 2724 return expression; | 2784 return expression; |
| 2725 } | 2785 } |
| 2726 | 2786 |
| 2727 @override | 2787 @override |
| 2728 void setUp() { | 2788 void setUp() { |
| 2729 super.setUp(); | 2789 super.setUp(); |
| 2730 parseFunctionBodies = true; | 2790 parseFunctionBodies = true; |
| (...skipping 1916 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4647 } | 4707 } |
| 4648 | 4708 |
| 4649 void test_isFunctionDeclaration_nameButNoReturn_block() { | 4709 void test_isFunctionDeclaration_nameButNoReturn_block() { |
| 4650 expect(_isFunctionDeclaration("f() {}"), isTrue); | 4710 expect(_isFunctionDeclaration("f() {}"), isTrue); |
| 4651 } | 4711 } |
| 4652 | 4712 |
| 4653 void test_isFunctionDeclaration_nameButNoReturn_expression() { | 4713 void test_isFunctionDeclaration_nameButNoReturn_expression() { |
| 4654 expect(_isFunctionDeclaration("f() => e"), isTrue); | 4714 expect(_isFunctionDeclaration("f() => e"), isTrue); |
| 4655 } | 4715 } |
| 4656 | 4716 |
| 4717 void test_isFunctionDeclaration_nameButNoReturn_typeParameters_block() { |
| 4718 enableGenericMethods = true; |
| 4719 expect(_isFunctionDeclaration("f<E>() {}"), isTrue); |
| 4720 } |
| 4721 |
| 4722 void test_isFunctionDeclaration_nameButNoReturn_typeParameters_expression() { |
| 4723 enableGenericMethods = true; |
| 4724 expect(_isFunctionDeclaration("f<E>() => e"), isTrue); |
| 4725 } |
| 4726 |
| 4657 void test_isFunctionDeclaration_normalReturn_block() { | 4727 void test_isFunctionDeclaration_normalReturn_block() { |
| 4658 expect(_isFunctionDeclaration("C f() {}"), isTrue); | 4728 expect(_isFunctionDeclaration("C f() {}"), isTrue); |
| 4659 } | 4729 } |
| 4660 | 4730 |
| 4661 void test_isFunctionDeclaration_normalReturn_expression() { | 4731 void test_isFunctionDeclaration_normalReturn_expression() { |
| 4662 expect(_isFunctionDeclaration("C f() => e"), isTrue); | 4732 expect(_isFunctionDeclaration("C f() => e"), isTrue); |
| 4663 } | 4733 } |
| 4664 | 4734 |
| 4735 void test_isFunctionDeclaration_normalReturn_typeParameters_block() { |
| 4736 enableGenericMethods = true; |
| 4737 expect(_isFunctionDeclaration("C f<E>() {}"), isTrue); |
| 4738 } |
| 4739 |
| 4740 void test_isFunctionDeclaration_normalReturn_typeParameters_expression() { |
| 4741 enableGenericMethods = true; |
| 4742 expect(_isFunctionDeclaration("C f<E>() => e"), isTrue); |
| 4743 } |
| 4744 |
| 4665 void test_isFunctionDeclaration_voidReturn_block() { | 4745 void test_isFunctionDeclaration_voidReturn_block() { |
| 4666 expect(_isFunctionDeclaration("void f() {}"), isTrue); | 4746 expect(_isFunctionDeclaration("void f() {}"), isTrue); |
| 4667 } | 4747 } |
| 4668 | 4748 |
| 4669 void test_isFunctionDeclaration_voidReturn_expression() { | 4749 void test_isFunctionDeclaration_voidReturn_expression() { |
| 4670 expect(_isFunctionDeclaration("void f() => e"), isTrue); | 4750 expect(_isFunctionDeclaration("void f() => e"), isTrue); |
| 4671 } | 4751 } |
| 4672 | 4752 |
| 4753 void test_isFunctionDeclaration_voidReturn_typeParameters_block() { |
| 4754 enableGenericMethods = true; |
| 4755 expect(_isFunctionDeclaration("void f<E>() {}"), isTrue); |
| 4756 } |
| 4757 |
| 4758 void test_isFunctionDeclaration_voidReturn_typeParameters_expression() { |
| 4759 enableGenericMethods = true; |
| 4760 expect(_isFunctionDeclaration("void f<E>() => e"), isTrue); |
| 4761 } |
| 4762 |
| 4673 void test_isFunctionExpression_false_noBody() { | 4763 void test_isFunctionExpression_false_noBody() { |
| 4674 expect(_isFunctionExpression("f();"), isFalse); | 4764 expect(_isFunctionExpression("f();"), isFalse); |
| 4675 } | 4765 } |
| 4676 | 4766 |
| 4677 void test_isFunctionExpression_false_notParameters() { | 4767 void test_isFunctionExpression_false_notParameters() { |
| 4678 expect(_isFunctionExpression("(a + b) {"), isFalse); | 4768 expect(_isFunctionExpression("(a + b) {"), isFalse); |
| 4679 } | 4769 } |
| 4680 | 4770 |
| 4681 void test_isFunctionExpression_noName_block() { | 4771 void test_isFunctionExpression_noParameters_block() { |
| 4682 expect(_isFunctionExpression("() {}"), isTrue); | 4772 expect(_isFunctionExpression("() {}"), isTrue); |
| 4683 } | 4773 } |
| 4684 | 4774 |
| 4685 void test_isFunctionExpression_noName_expression() { | 4775 void test_isFunctionExpression_noParameters_expression() { |
| 4686 expect(_isFunctionExpression("() => e"), isTrue); | 4776 expect(_isFunctionExpression("() => e"), isTrue); |
| 4687 } | 4777 } |
| 4688 | 4778 |
| 4779 void test_isFunctionExpression_noParameters_typeParameters_block() { |
| 4780 enableGenericMethods = true; |
| 4781 expect(_isFunctionExpression("<E>() {}"), isTrue); |
| 4782 } |
| 4783 |
| 4784 void test_isFunctionExpression_noParameters_typeParameters_expression() { |
| 4785 enableGenericMethods = true; |
| 4786 expect(_isFunctionExpression("<E>() => e"), isTrue); |
| 4787 } |
| 4788 |
| 4689 void test_isFunctionExpression_parameter_final() { | 4789 void test_isFunctionExpression_parameter_final() { |
| 4690 expect(_isFunctionExpression("(final a) {}"), isTrue); | 4790 expect(_isFunctionExpression("(final a) {}"), isTrue); |
| 4691 expect(_isFunctionExpression("(final a, b) {}"), isTrue); | 4791 expect(_isFunctionExpression("(final a, b) {}"), isTrue); |
| 4692 expect(_isFunctionExpression("(final a, final b) {}"), isTrue); | 4792 expect(_isFunctionExpression("(final a, final b) {}"), isTrue); |
| 4693 } | 4793 } |
| 4694 | 4794 |
| 4695 void test_isFunctionExpression_parameter_final_typed() { | 4795 void test_isFunctionExpression_parameter_final_typed() { |
| 4696 expect(_isFunctionExpression("(final int a) {}"), isTrue); | 4796 expect(_isFunctionExpression("(final int a) {}"), isTrue); |
| 4697 expect(_isFunctionExpression("(final prefix.List a) {}"), isTrue); | 4797 expect(_isFunctionExpression("(final prefix.List a) {}"), isTrue); |
| 4698 expect(_isFunctionExpression("(final List<int> a) {}"), isTrue); | 4798 expect(_isFunctionExpression("(final List<int> a) {}"), isTrue); |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4928 expect(statement.rightParenthesis, isNotNull); | 5028 expect(statement.rightParenthesis, isNotNull); |
| 4929 expect(statement.semicolon, isNotNull); | 5029 expect(statement.semicolon, isNotNull); |
| 4930 } | 5030 } |
| 4931 | 5031 |
| 4932 void test_parseAssignableExpression_expression_args_dot() { | 5032 void test_parseAssignableExpression_expression_args_dot() { |
| 4933 PropertyAccess propertyAccess = | 5033 PropertyAccess propertyAccess = |
| 4934 parse("parseAssignableExpression", <Object>[false], "(x)(y).z"); | 5034 parse("parseAssignableExpression", <Object>[false], "(x)(y).z"); |
| 4935 FunctionExpressionInvocation invocation = | 5035 FunctionExpressionInvocation invocation = |
| 4936 propertyAccess.target as FunctionExpressionInvocation; | 5036 propertyAccess.target as FunctionExpressionInvocation; |
| 4937 expect(invocation.function, isNotNull); | 5037 expect(invocation.function, isNotNull); |
| 5038 expect(invocation.typeArguments, isNull); |
| 4938 ArgumentList argumentList = invocation.argumentList; | 5039 ArgumentList argumentList = invocation.argumentList; |
| 4939 expect(argumentList, isNotNull); | 5040 expect(argumentList, isNotNull); |
| 4940 expect(argumentList.arguments, hasLength(1)); | 5041 expect(argumentList.arguments, hasLength(1)); |
| 5042 expect(propertyAccess.operator, isNotNull); |
| 5043 expect(propertyAccess.propertyName, isNotNull); |
| 5044 } |
| 5045 |
| 5046 void test_parseAssignableExpression_expression_args_dot_typeParameters() { |
| 5047 enableGenericMethods = true; |
| 5048 PropertyAccess propertyAccess = |
| 5049 parse("parseAssignableExpression", <Object>[false], "(x)<F>(y).z"); |
| 5050 FunctionExpressionInvocation invocation = |
| 5051 propertyAccess.target as FunctionExpressionInvocation; |
| 5052 expect(invocation.function, isNotNull); |
| 5053 expect(invocation.typeArguments, isNotNull); |
| 5054 ArgumentList argumentList = invocation.argumentList; |
| 5055 expect(argumentList, isNotNull); |
| 5056 expect(argumentList.arguments, hasLength(1)); |
| 4941 expect(propertyAccess.operator, isNotNull); | 5057 expect(propertyAccess.operator, isNotNull); |
| 4942 expect(propertyAccess.propertyName, isNotNull); | 5058 expect(propertyAccess.propertyName, isNotNull); |
| 4943 } | 5059 } |
| 4944 | 5060 |
| 4945 void test_parseAssignableExpression_expression_dot() { | 5061 void test_parseAssignableExpression_expression_dot() { |
| 4946 PropertyAccess propertyAccess = | 5062 PropertyAccess propertyAccess = |
| 4947 parse("parseAssignableExpression", <Object>[false], "(x).y"); | 5063 parse("parseAssignableExpression", <Object>[false], "(x).y"); |
| 4948 expect(propertyAccess.target, isNotNull); | 5064 expect(propertyAccess.target, isNotNull); |
| 4949 expect(propertyAccess.operator.type, TokenType.PERIOD); | 5065 expect(propertyAccess.operator.type, TokenType.PERIOD); |
| 4950 expect(propertyAccess.propertyName, isNotNull); | 5066 expect(propertyAccess.propertyName, isNotNull); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 4972 SimpleIdentifier identifier = | 5088 SimpleIdentifier identifier = |
| 4973 parse("parseAssignableExpression", <Object>[false], "x"); | 5089 parse("parseAssignableExpression", <Object>[false], "x"); |
| 4974 expect(identifier, isNotNull); | 5090 expect(identifier, isNotNull); |
| 4975 } | 5091 } |
| 4976 | 5092 |
| 4977 void test_parseAssignableExpression_identifier_args_dot() { | 5093 void test_parseAssignableExpression_identifier_args_dot() { |
| 4978 PropertyAccess propertyAccess = | 5094 PropertyAccess propertyAccess = |
| 4979 parse("parseAssignableExpression", <Object>[false], "x(y).z"); | 5095 parse("parseAssignableExpression", <Object>[false], "x(y).z"); |
| 4980 MethodInvocation invocation = propertyAccess.target as MethodInvocation; | 5096 MethodInvocation invocation = propertyAccess.target as MethodInvocation; |
| 4981 expect(invocation.methodName.name, "x"); | 5097 expect(invocation.methodName.name, "x"); |
| 5098 expect(invocation.typeArguments, isNull); |
| 4982 ArgumentList argumentList = invocation.argumentList; | 5099 ArgumentList argumentList = invocation.argumentList; |
| 4983 expect(argumentList, isNotNull); | 5100 expect(argumentList, isNotNull); |
| 4984 expect(argumentList.arguments, hasLength(1)); | 5101 expect(argumentList.arguments, hasLength(1)); |
| 5102 expect(propertyAccess.operator, isNotNull); |
| 5103 expect(propertyAccess.propertyName, isNotNull); |
| 5104 } |
| 5105 |
| 5106 void test_parseAssignableExpression_identifier_args_dot_typeParameters() { |
| 5107 enableGenericMethods = true; |
| 5108 PropertyAccess propertyAccess = |
| 5109 parse("parseAssignableExpression", <Object>[false], "x<E>(y).z"); |
| 5110 MethodInvocation invocation = propertyAccess.target as MethodInvocation; |
| 5111 expect(invocation.methodName.name, "x"); |
| 5112 expect(invocation.typeArguments, isNotNull); |
| 5113 ArgumentList argumentList = invocation.argumentList; |
| 5114 expect(argumentList, isNotNull); |
| 5115 expect(argumentList.arguments, hasLength(1)); |
| 4985 expect(propertyAccess.operator, isNotNull); | 5116 expect(propertyAccess.operator, isNotNull); |
| 4986 expect(propertyAccess.propertyName, isNotNull); | 5117 expect(propertyAccess.propertyName, isNotNull); |
| 4987 } | 5118 } |
| 4988 | 5119 |
| 4989 void test_parseAssignableExpression_identifier_dot() { | 5120 void test_parseAssignableExpression_identifier_dot() { |
| 4990 PropertyAccess propertyAccess = | 5121 PropertyAccess propertyAccess = |
| 4991 parse("parseAssignableExpression", <Object>[false], "x.y"); | 5122 parse("parseAssignableExpression", <Object>[false], "x.y"); |
| 4992 expect(propertyAccess.target, isNotNull); | 5123 expect(propertyAccess.target, isNotNull); |
| 4993 expect(propertyAccess.operator, isNotNull); | 5124 expect(propertyAccess.operator, isNotNull); |
| 4994 expect(propertyAccess.operator.type, TokenType.PERIOD); | 5125 expect(propertyAccess.operator.type, TokenType.PERIOD); |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5186 expect(section.leftBracket, isNotNull); | 5317 expect(section.leftBracket, isNotNull); |
| 5187 expect(section.index, isNotNull); | 5318 expect(section.index, isNotNull); |
| 5188 expect(section.rightBracket, isNotNull); | 5319 expect(section.rightBracket, isNotNull); |
| 5189 } | 5320 } |
| 5190 | 5321 |
| 5191 void test_parseCascadeSection_ia() { | 5322 void test_parseCascadeSection_ia() { |
| 5192 FunctionExpressionInvocation section = | 5323 FunctionExpressionInvocation section = |
| 5193 parse4("parseCascadeSection", "..[i](b)"); | 5324 parse4("parseCascadeSection", "..[i](b)"); |
| 5194 EngineTestCase.assertInstanceOf( | 5325 EngineTestCase.assertInstanceOf( |
| 5195 (obj) => obj is IndexExpression, IndexExpression, section.function); | 5326 (obj) => obj is IndexExpression, IndexExpression, section.function); |
| 5327 expect(section.typeArguments, isNull); |
| 5196 expect(section.argumentList, isNotNull); | 5328 expect(section.argumentList, isNotNull); |
| 5197 } | 5329 } |
| 5198 | 5330 |
| 5331 void test_parseCascadeSection_ia_typeArguments() { |
| 5332 enableGenericMethods = true; |
| 5333 FunctionExpressionInvocation section = |
| 5334 parse4("parseCascadeSection", "..[i]<E>(b)"); |
| 5335 EngineTestCase.assertInstanceOf( |
| 5336 (obj) => obj is IndexExpression, IndexExpression, section.function); |
| 5337 expect(section.typeArguments, isNotNull); |
| 5338 expect(section.argumentList, isNotNull); |
| 5339 } |
| 5340 |
| 5199 void test_parseCascadeSection_ii() { | 5341 void test_parseCascadeSection_ii() { |
| 5200 MethodInvocation section = parse4("parseCascadeSection", "..a(b).c(d)"); | 5342 MethodInvocation section = parse4("parseCascadeSection", "..a(b).c(d)"); |
| 5201 EngineTestCase.assertInstanceOf( | 5343 EngineTestCase.assertInstanceOf( |
| 5202 (obj) => obj is MethodInvocation, MethodInvocation, section.target); | 5344 (obj) => obj is MethodInvocation, MethodInvocation, section.target); |
| 5203 expect(section.operator, isNotNull); | 5345 expect(section.operator, isNotNull); |
| 5204 expect(section.methodName, isNotNull); | 5346 expect(section.methodName, isNotNull); |
| 5347 expect(section.typeArguments, isNull); |
| 5205 expect(section.argumentList, isNotNull); | 5348 expect(section.argumentList, isNotNull); |
| 5206 expect(section.argumentList.arguments, hasLength(1)); | 5349 expect(section.argumentList.arguments, hasLength(1)); |
| 5207 } | 5350 } |
| 5351 |
| 5352 void test_parseCascadeSection_ii_typeArguments() { |
| 5353 enableGenericMethods = true; |
| 5354 MethodInvocation section = |
| 5355 parse4("parseCascadeSection", "..a<E>(b).c<F>(d)"); |
| 5356 EngineTestCase.assertInstanceOf( |
| 5357 (obj) => obj is MethodInvocation, MethodInvocation, section.target); |
| 5358 expect(section.operator, isNotNull); |
| 5359 expect(section.methodName, isNotNull); |
| 5360 expect(section.typeArguments, isNotNull); |
| 5361 expect(section.argumentList, isNotNull); |
| 5362 expect(section.argumentList.arguments, hasLength(1)); |
| 5363 } |
| 5208 | 5364 |
| 5209 void test_parseCascadeSection_p() { | 5365 void test_parseCascadeSection_p() { |
| 5210 PropertyAccess section = parse4("parseCascadeSection", "..a"); | 5366 PropertyAccess section = parse4("parseCascadeSection", "..a"); |
| 5211 expect(section.target, isNull); | 5367 expect(section.target, isNull); |
| 5212 expect(section.operator, isNotNull); | 5368 expect(section.operator, isNotNull); |
| 5213 expect(section.propertyName, isNotNull); | 5369 expect(section.propertyName, isNotNull); |
| 5214 } | 5370 } |
| 5215 | 5371 |
| 5216 void test_parseCascadeSection_p_assign() { | 5372 void test_parseCascadeSection_p_assign() { |
| 5217 AssignmentExpression section = parse4("parseCascadeSection", "..a = 3"); | 5373 AssignmentExpression section = parse4("parseCascadeSection", "..a = 3"); |
| 5218 expect(section.leftHandSide, isNotNull); | 5374 expect(section.leftHandSide, isNotNull); |
| 5219 expect(section.operator, isNotNull); | 5375 expect(section.operator, isNotNull); |
| 5220 Expression rhs = section.rightHandSide; | 5376 Expression rhs = section.rightHandSide; |
| 5221 expect(rhs, isNotNull); | 5377 expect(rhs, isNotNull); |
| 5222 } | 5378 } |
| 5223 | 5379 |
| 5224 void test_parseCascadeSection_p_assign_withCascade() { | 5380 void test_parseCascadeSection_p_assign_withCascade() { |
| 5225 AssignmentExpression section = | 5381 AssignmentExpression section = |
| 5226 parse4("parseCascadeSection", "..a = 3..m()"); | 5382 parse4("parseCascadeSection", "..a = 3..m()"); |
| 5227 expect(section.leftHandSide, isNotNull); | 5383 expect(section.leftHandSide, isNotNull); |
| 5228 expect(section.operator, isNotNull); | 5384 expect(section.operator, isNotNull); |
| 5229 Expression rhs = section.rightHandSide; | 5385 Expression rhs = section.rightHandSide; |
| 5230 EngineTestCase.assertInstanceOf( | 5386 EngineTestCase.assertInstanceOf( |
| 5231 (obj) => obj is IntegerLiteral, IntegerLiteral, rhs); | 5387 (obj) => obj is IntegerLiteral, IntegerLiteral, rhs); |
| 5232 } | 5388 } |
| 5233 | 5389 |
| 5390 void test_parseCascadeSection_p_assign_withCascade_typeArguments() { |
| 5391 enableGenericMethods = true; |
| 5392 AssignmentExpression section = |
| 5393 parse4("parseCascadeSection", "..a = 3..m<E>()"); |
| 5394 expect(section.leftHandSide, isNotNull); |
| 5395 expect(section.operator, isNotNull); |
| 5396 Expression rhs = section.rightHandSide; |
| 5397 EngineTestCase.assertInstanceOf( |
| 5398 (obj) => obj is IntegerLiteral, IntegerLiteral, rhs); |
| 5399 } |
| 5400 |
| 5234 void test_parseCascadeSection_p_builtIn() { | 5401 void test_parseCascadeSection_p_builtIn() { |
| 5235 PropertyAccess section = parse4("parseCascadeSection", "..as"); | 5402 PropertyAccess section = parse4("parseCascadeSection", "..as"); |
| 5236 expect(section.target, isNull); | 5403 expect(section.target, isNull); |
| 5237 expect(section.operator, isNotNull); | 5404 expect(section.operator, isNotNull); |
| 5238 expect(section.propertyName, isNotNull); | 5405 expect(section.propertyName, isNotNull); |
| 5239 } | 5406 } |
| 5240 | 5407 |
| 5241 void test_parseCascadeSection_pa() { | 5408 void test_parseCascadeSection_pa() { |
| 5242 MethodInvocation section = parse4("parseCascadeSection", "..a(b)"); | 5409 MethodInvocation section = parse4("parseCascadeSection", "..a(b)"); |
| 5243 expect(section.target, isNull); | 5410 expect(section.target, isNull); |
| 5244 expect(section.operator, isNotNull); | 5411 expect(section.operator, isNotNull); |
| 5245 expect(section.methodName, isNotNull); | 5412 expect(section.methodName, isNotNull); |
| 5413 expect(section.typeArguments, isNull); |
| 5246 expect(section.argumentList, isNotNull); | 5414 expect(section.argumentList, isNotNull); |
| 5247 expect(section.argumentList.arguments, hasLength(1)); | 5415 expect(section.argumentList.arguments, hasLength(1)); |
| 5248 } | 5416 } |
| 5417 |
| 5418 void test_parseCascadeSection_pa_typeArguments() { |
| 5419 enableGenericMethods = true; |
| 5420 MethodInvocation section = parse4("parseCascadeSection", "..a<E>(b)"); |
| 5421 expect(section.target, isNull); |
| 5422 expect(section.operator, isNotNull); |
| 5423 expect(section.methodName, isNotNull); |
| 5424 expect(section.typeArguments, isNotNull); |
| 5425 expect(section.argumentList, isNotNull); |
| 5426 expect(section.argumentList.arguments, hasLength(1)); |
| 5427 } |
| 5249 | 5428 |
| 5250 void test_parseCascadeSection_paa() { | 5429 void test_parseCascadeSection_paa() { |
| 5251 FunctionExpressionInvocation section = | 5430 FunctionExpressionInvocation section = |
| 5252 parse4("parseCascadeSection", "..a(b)(c)"); | 5431 parse4("parseCascadeSection", "..a(b)(c)"); |
| 5253 EngineTestCase.assertInstanceOf( | 5432 EngineTestCase.assertInstanceOf( |
| 5254 (obj) => obj is MethodInvocation, MethodInvocation, section.function); | 5433 (obj) => obj is MethodInvocation, MethodInvocation, section.function); |
| 5434 expect(section.typeArguments, isNull); |
| 5255 expect(section.argumentList, isNotNull); | 5435 expect(section.argumentList, isNotNull); |
| 5256 expect(section.argumentList.arguments, hasLength(1)); | 5436 expect(section.argumentList.arguments, hasLength(1)); |
| 5257 } | 5437 } |
| 5438 |
| 5439 void test_parseCascadeSection_paa_typeArguments() { |
| 5440 enableGenericMethods = true; |
| 5441 FunctionExpressionInvocation section = |
| 5442 parse4("parseCascadeSection", "..a<E>(b)<F>(c)"); |
| 5443 EngineTestCase.assertInstanceOf( |
| 5444 (obj) => obj is MethodInvocation, MethodInvocation, section.function); |
| 5445 expect(section.typeArguments, isNotNull); |
| 5446 expect(section.argumentList, isNotNull); |
| 5447 expect(section.argumentList.arguments, hasLength(1)); |
| 5448 } |
| 5258 | 5449 |
| 5259 void test_parseCascadeSection_paapaa() { | 5450 void test_parseCascadeSection_paapaa() { |
| 5260 FunctionExpressionInvocation section = | 5451 FunctionExpressionInvocation section = |
| 5261 parse4("parseCascadeSection", "..a(b)(c).d(e)(f)"); | 5452 parse4("parseCascadeSection", "..a(b)(c).d(e)(f)"); |
| 5262 EngineTestCase.assertInstanceOf( | 5453 EngineTestCase.assertInstanceOf( |
| 5263 (obj) => obj is MethodInvocation, MethodInvocation, section.function); | 5454 (obj) => obj is MethodInvocation, MethodInvocation, section.function); |
| 5455 expect(section.typeArguments, isNull); |
| 5264 expect(section.argumentList, isNotNull); | 5456 expect(section.argumentList, isNotNull); |
| 5265 expect(section.argumentList.arguments, hasLength(1)); | 5457 expect(section.argumentList.arguments, hasLength(1)); |
| 5266 } | 5458 } |
| 5459 |
| 5460 void test_parseCascadeSection_paapaa_typeArguments() { |
| 5461 enableGenericMethods = true; |
| 5462 FunctionExpressionInvocation section = |
| 5463 parse4("parseCascadeSection", "..a<E>(b)<F>(c).d<G>(e)<H>(f)"); |
| 5464 EngineTestCase.assertInstanceOf( |
| 5465 (obj) => obj is MethodInvocation, MethodInvocation, section.function); |
| 5466 expect(section.typeArguments, isNotNull); |
| 5467 expect(section.argumentList, isNotNull); |
| 5468 expect(section.argumentList.arguments, hasLength(1)); |
| 5469 } |
| 5267 | 5470 |
| 5268 void test_parseCascadeSection_pap() { | 5471 void test_parseCascadeSection_pap() { |
| 5269 PropertyAccess section = parse4("parseCascadeSection", "..a(b).c"); | 5472 PropertyAccess section = parse4("parseCascadeSection", "..a(b).c"); |
| 5270 expect(section.target, isNotNull); | 5473 expect(section.target, isNotNull); |
| 5271 expect(section.operator, isNotNull); | 5474 expect(section.operator, isNotNull); |
| 5272 expect(section.propertyName, isNotNull); | 5475 expect(section.propertyName, isNotNull); |
| 5273 } | 5476 } |
| 5274 | 5477 |
| 5478 void test_parseCascadeSection_pap_typeArguments() { |
| 5479 enableGenericMethods = true; |
| 5480 PropertyAccess section = parse4("parseCascadeSection", "..a<E>(b).c"); |
| 5481 expect(section.target, isNotNull); |
| 5482 expect(section.operator, isNotNull); |
| 5483 expect(section.propertyName, isNotNull); |
| 5484 } |
| 5485 |
| 5275 void test_parseClassDeclaration_abstract() { | 5486 void test_parseClassDeclaration_abstract() { |
| 5276 ClassDeclaration declaration = parse("parseClassDeclaration", <Object>[ | 5487 ClassDeclaration declaration = parse("parseClassDeclaration", <Object>[ |
| 5277 emptyCommentAndMetadata(), | 5488 emptyCommentAndMetadata(), |
| 5278 TokenFactory.tokenFromKeyword(Keyword.ABSTRACT) | 5489 TokenFactory.tokenFromKeyword(Keyword.ABSTRACT) |
| 5279 ], "class A {}"); | 5490 ], "class A {}"); |
| 5280 expect(declaration.documentationComment, isNull); | 5491 expect(declaration.documentationComment, isNull); |
| 5281 expect(declaration.abstractKeyword, isNotNull); | 5492 expect(declaration.abstractKeyword, isNotNull); |
| 5282 expect(declaration.extendsClause, isNull); | 5493 expect(declaration.extendsClause, isNull); |
| 5283 expect(declaration.implementsClause, isNull); | 5494 expect(declaration.implementsClause, isNull); |
| 5284 expect(declaration.classKeyword, isNotNull); | 5495 expect(declaration.classKeyword, isNotNull); |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5574 | 5785 |
| 5575 void test_parseClassMember_method_external() { | 5786 void test_parseClassMember_method_external() { |
| 5576 MethodDeclaration method = | 5787 MethodDeclaration method = |
| 5577 parse("parseClassMember", <Object>["C"], "external m();"); | 5788 parse("parseClassMember", <Object>["C"], "external m();"); |
| 5578 expect(method.body, isNotNull); | 5789 expect(method.body, isNotNull); |
| 5579 expect(method.documentationComment, isNull); | 5790 expect(method.documentationComment, isNull); |
| 5580 expect(method.externalKeyword, isNotNull); | 5791 expect(method.externalKeyword, isNotNull); |
| 5581 expect(method.modifierKeyword, isNull); | 5792 expect(method.modifierKeyword, isNull); |
| 5582 expect(method.name, isNotNull); | 5793 expect(method.name, isNotNull); |
| 5583 expect(method.operatorKeyword, isNull); | 5794 expect(method.operatorKeyword, isNull); |
| 5795 expect(method.typeParameters, isNull); |
| 5584 expect(method.parameters, isNotNull); | 5796 expect(method.parameters, isNotNull); |
| 5585 expect(method.propertyKeyword, isNull); | 5797 expect(method.propertyKeyword, isNull); |
| 5586 expect(method.returnType, isNull); | 5798 expect(method.returnType, isNull); |
| 5587 } | 5799 } |
| 5588 | 5800 |
| 5589 void test_parseClassMember_method_external_withTypeAndArgs() { | 5801 void test_parseClassMember_method_external_withTypeAndArgs() { |
| 5590 MethodDeclaration method = | 5802 MethodDeclaration method = |
| 5591 parse("parseClassMember", <Object>["C"], "external int m(int a);"); | 5803 parse("parseClassMember", <Object>["C"], "external int m(int a);"); |
| 5592 expect(method.body, isNotNull); | 5804 expect(method.body, isNotNull); |
| 5593 expect(method.documentationComment, isNull); | 5805 expect(method.documentationComment, isNull); |
| 5594 expect(method.externalKeyword, isNotNull); | 5806 expect(method.externalKeyword, isNotNull); |
| 5595 expect(method.modifierKeyword, isNull); | 5807 expect(method.modifierKeyword, isNull); |
| 5596 expect(method.name, isNotNull); | 5808 expect(method.name, isNotNull); |
| 5597 expect(method.operatorKeyword, isNull); | 5809 expect(method.operatorKeyword, isNull); |
| 5810 expect(method.typeParameters, isNull); |
| 5598 expect(method.parameters, isNotNull); | 5811 expect(method.parameters, isNotNull); |
| 5599 expect(method.propertyKeyword, isNull); | 5812 expect(method.propertyKeyword, isNull); |
| 5600 expect(method.returnType, isNotNull); | 5813 expect(method.returnType, isNotNull); |
| 5601 } | 5814 } |
| 5602 | 5815 |
| 5816 void test_parseClassMember_method_generic_noReturnType() { |
| 5817 enableGenericMethods = true; |
| 5818 MethodDeclaration method = |
| 5819 parse("parseClassMember", <Object>["C"], "m<T>() {}"); |
| 5820 expect(method.documentationComment, isNull); |
| 5821 expect(method.externalKeyword, isNull); |
| 5822 expect(method.modifierKeyword, isNull); |
| 5823 expect(method.propertyKeyword, isNull); |
| 5824 expect(method.returnType, isNull); |
| 5825 expect(method.name, isNotNull); |
| 5826 expect(method.operatorKeyword, isNull); |
| 5827 expect(method.typeParameters, isNotNull); |
| 5828 expect(method.parameters, isNotNull); |
| 5829 expect(method.body, isNotNull); |
| 5830 } |
| 5831 |
| 5832 void test_parseClassMember_method_generic_returnType() { |
| 5833 enableGenericMethods = true; |
| 5834 MethodDeclaration method = |
| 5835 parse("parseClassMember", <Object>["C"], "T m<T>() {}"); |
| 5836 expect(method.documentationComment, isNull); |
| 5837 expect(method.externalKeyword, isNull); |
| 5838 expect(method.modifierKeyword, isNull); |
| 5839 expect(method.propertyKeyword, isNull); |
| 5840 expect(method.returnType, isNotNull); |
| 5841 expect(method.name, isNotNull); |
| 5842 expect(method.operatorKeyword, isNull); |
| 5843 expect(method.typeParameters, isNotNull); |
| 5844 expect(method.parameters, isNotNull); |
| 5845 expect(method.body, isNotNull); |
| 5846 } |
| 5847 |
| 5848 void test_parseClassMember_method_generic_void() { |
| 5849 enableGenericMethods = true; |
| 5850 MethodDeclaration method = |
| 5851 parse("parseClassMember", <Object>["C"], "void m<T>() {}"); |
| 5852 expect(method.documentationComment, isNull); |
| 5853 expect(method.externalKeyword, isNull); |
| 5854 expect(method.modifierKeyword, isNull); |
| 5855 expect(method.propertyKeyword, isNull); |
| 5856 expect(method.returnType, isNotNull); |
| 5857 expect(method.name, isNotNull); |
| 5858 expect(method.operatorKeyword, isNull); |
| 5859 expect(method.typeParameters, isNotNull); |
| 5860 expect(method.parameters, isNotNull); |
| 5861 expect(method.body, isNotNull); |
| 5862 } |
| 5863 |
| 5603 void test_parseClassMember_method_get_noType() { | 5864 void test_parseClassMember_method_get_noType() { |
| 5604 MethodDeclaration method = | 5865 MethodDeclaration method = |
| 5605 parse("parseClassMember", <Object>["C"], "get() {}"); | 5866 parse("parseClassMember", <Object>["C"], "get() {}"); |
| 5606 expect(method.documentationComment, isNull); | 5867 expect(method.documentationComment, isNull); |
| 5607 expect(method.externalKeyword, isNull); | 5868 expect(method.externalKeyword, isNull); |
| 5608 expect(method.modifierKeyword, isNull); | 5869 expect(method.modifierKeyword, isNull); |
| 5609 expect(method.propertyKeyword, isNull); | 5870 expect(method.propertyKeyword, isNull); |
| 5610 expect(method.returnType, isNull); | 5871 expect(method.returnType, isNull); |
| 5611 expect(method.name, isNotNull); | 5872 expect(method.name, isNotNull); |
| 5612 expect(method.operatorKeyword, isNull); | 5873 expect(method.operatorKeyword, isNull); |
| 5874 expect(method.typeParameters, isNull); |
| 5613 expect(method.parameters, isNotNull); | 5875 expect(method.parameters, isNotNull); |
| 5614 expect(method.body, isNotNull); | 5876 expect(method.body, isNotNull); |
| 5615 } | 5877 } |
| 5616 | 5878 |
| 5617 void test_parseClassMember_method_get_type() { | 5879 void test_parseClassMember_method_get_type() { |
| 5618 MethodDeclaration method = | 5880 MethodDeclaration method = |
| 5619 parse("parseClassMember", <Object>["C"], "int get() {}"); | 5881 parse("parseClassMember", <Object>["C"], "int get() {}"); |
| 5620 expect(method.documentationComment, isNull); | 5882 expect(method.documentationComment, isNull); |
| 5621 expect(method.externalKeyword, isNull); | 5883 expect(method.externalKeyword, isNull); |
| 5622 expect(method.modifierKeyword, isNull); | 5884 expect(method.modifierKeyword, isNull); |
| 5623 expect(method.propertyKeyword, isNull); | 5885 expect(method.propertyKeyword, isNull); |
| 5624 expect(method.returnType, isNotNull); | 5886 expect(method.returnType, isNotNull); |
| 5625 expect(method.name, isNotNull); | 5887 expect(method.name, isNotNull); |
| 5626 expect(method.operatorKeyword, isNull); | 5888 expect(method.operatorKeyword, isNull); |
| 5889 expect(method.typeParameters, isNull); |
| 5627 expect(method.parameters, isNotNull); | 5890 expect(method.parameters, isNotNull); |
| 5628 expect(method.body, isNotNull); | 5891 expect(method.body, isNotNull); |
| 5629 } | 5892 } |
| 5630 | 5893 |
| 5631 void test_parseClassMember_method_get_void() { | 5894 void test_parseClassMember_method_get_void() { |
| 5632 MethodDeclaration method = | 5895 MethodDeclaration method = |
| 5633 parse("parseClassMember", <Object>["C"], "void get() {}"); | 5896 parse("parseClassMember", <Object>["C"], "void get() {}"); |
| 5634 expect(method.documentationComment, isNull); | 5897 expect(method.documentationComment, isNull); |
| 5635 expect(method.externalKeyword, isNull); | 5898 expect(method.externalKeyword, isNull); |
| 5636 expect(method.modifierKeyword, isNull); | 5899 expect(method.modifierKeyword, isNull); |
| 5637 expect(method.propertyKeyword, isNull); | 5900 expect(method.propertyKeyword, isNull); |
| 5638 expect(method.returnType, isNotNull); | 5901 expect(method.returnType, isNotNull); |
| 5639 expect(method.name, isNotNull); | 5902 expect(method.name, isNotNull); |
| 5640 expect(method.operatorKeyword, isNull); | 5903 expect(method.operatorKeyword, isNull); |
| 5904 expect(method.typeParameters, isNull); |
| 5641 expect(method.parameters, isNotNull); | 5905 expect(method.parameters, isNotNull); |
| 5642 expect(method.body, isNotNull); | 5906 expect(method.body, isNotNull); |
| 5643 } | 5907 } |
| 5644 | 5908 |
| 5645 void test_parseClassMember_method_operator_noType() { | 5909 void test_parseClassMember_method_operator_noType() { |
| 5646 MethodDeclaration method = | 5910 MethodDeclaration method = |
| 5647 parse("parseClassMember", <Object>["C"], "operator() {}"); | 5911 parse("parseClassMember", <Object>["C"], "operator() {}"); |
| 5648 expect(method.documentationComment, isNull); | 5912 expect(method.documentationComment, isNull); |
| 5649 expect(method.externalKeyword, isNull); | 5913 expect(method.externalKeyword, isNull); |
| 5650 expect(method.modifierKeyword, isNull); | 5914 expect(method.modifierKeyword, isNull); |
| 5651 expect(method.propertyKeyword, isNull); | 5915 expect(method.propertyKeyword, isNull); |
| 5652 expect(method.returnType, isNull); | 5916 expect(method.returnType, isNull); |
| 5653 expect(method.name, isNotNull); | 5917 expect(method.name, isNotNull); |
| 5654 expect(method.operatorKeyword, isNull); | 5918 expect(method.operatorKeyword, isNull); |
| 5919 expect(method.typeParameters, isNull); |
| 5655 expect(method.parameters, isNotNull); | 5920 expect(method.parameters, isNotNull); |
| 5656 expect(method.body, isNotNull); | 5921 expect(method.body, isNotNull); |
| 5657 } | 5922 } |
| 5658 | 5923 |
| 5659 void test_parseClassMember_method_operator_type() { | 5924 void test_parseClassMember_method_operator_type() { |
| 5660 MethodDeclaration method = | 5925 MethodDeclaration method = |
| 5661 parse("parseClassMember", <Object>["C"], "int operator() {}"); | 5926 parse("parseClassMember", <Object>["C"], "int operator() {}"); |
| 5662 expect(method.documentationComment, isNull); | 5927 expect(method.documentationComment, isNull); |
| 5663 expect(method.externalKeyword, isNull); | 5928 expect(method.externalKeyword, isNull); |
| 5664 expect(method.modifierKeyword, isNull); | 5929 expect(method.modifierKeyword, isNull); |
| 5665 expect(method.propertyKeyword, isNull); | 5930 expect(method.propertyKeyword, isNull); |
| 5666 expect(method.returnType, isNotNull); | 5931 expect(method.returnType, isNotNull); |
| 5667 expect(method.name, isNotNull); | 5932 expect(method.name, isNotNull); |
| 5668 expect(method.operatorKeyword, isNull); | 5933 expect(method.operatorKeyword, isNull); |
| 5934 expect(method.typeParameters, isNull); |
| 5669 expect(method.parameters, isNotNull); | 5935 expect(method.parameters, isNotNull); |
| 5670 expect(method.body, isNotNull); | 5936 expect(method.body, isNotNull); |
| 5671 } | 5937 } |
| 5672 | 5938 |
| 5673 void test_parseClassMember_method_operator_void() { | 5939 void test_parseClassMember_method_operator_void() { |
| 5674 MethodDeclaration method = | 5940 MethodDeclaration method = |
| 5675 parse("parseClassMember", <Object>["C"], "void operator() {}"); | 5941 parse("parseClassMember", <Object>["C"], "void operator() {}"); |
| 5676 expect(method.documentationComment, isNull); | 5942 expect(method.documentationComment, isNull); |
| 5677 expect(method.externalKeyword, isNull); | 5943 expect(method.externalKeyword, isNull); |
| 5678 expect(method.modifierKeyword, isNull); | 5944 expect(method.modifierKeyword, isNull); |
| 5679 expect(method.propertyKeyword, isNull); | 5945 expect(method.propertyKeyword, isNull); |
| 5680 expect(method.returnType, isNotNull); | 5946 expect(method.returnType, isNotNull); |
| 5681 expect(method.name, isNotNull); | 5947 expect(method.name, isNotNull); |
| 5682 expect(method.operatorKeyword, isNull); | 5948 expect(method.operatorKeyword, isNull); |
| 5949 expect(method.typeParameters, isNull); |
| 5683 expect(method.parameters, isNotNull); | 5950 expect(method.parameters, isNotNull); |
| 5684 expect(method.body, isNotNull); | 5951 expect(method.body, isNotNull); |
| 5685 } | 5952 } |
| 5686 | 5953 |
| 5687 void test_parseClassMember_method_returnType_parameterized() { | 5954 void test_parseClassMember_method_returnType_parameterized() { |
| 5688 MethodDeclaration method = | 5955 MethodDeclaration method = |
| 5689 parse("parseClassMember", <Object>["C"], "p.A m() {}"); | 5956 parse("parseClassMember", <Object>["C"], "p.A m() {}"); |
| 5690 expect(method.documentationComment, isNull); | 5957 expect(method.documentationComment, isNull); |
| 5691 expect(method.externalKeyword, isNull); | 5958 expect(method.externalKeyword, isNull); |
| 5692 expect(method.modifierKeyword, isNull); | 5959 expect(method.modifierKeyword, isNull); |
| 5693 expect(method.propertyKeyword, isNull); | 5960 expect(method.propertyKeyword, isNull); |
| 5694 expect(method.returnType, isNotNull); | 5961 expect(method.returnType, isNotNull); |
| 5695 expect(method.name, isNotNull); | 5962 expect(method.name, isNotNull); |
| 5696 expect(method.operatorKeyword, isNull); | 5963 expect(method.operatorKeyword, isNull); |
| 5964 expect(method.typeParameters, isNull); |
| 5697 expect(method.parameters, isNotNull); | 5965 expect(method.parameters, isNotNull); |
| 5698 expect(method.body, isNotNull); | 5966 expect(method.body, isNotNull); |
| 5699 } | 5967 } |
| 5700 | 5968 |
| 5701 void test_parseClassMember_method_set_noType() { | 5969 void test_parseClassMember_method_set_noType() { |
| 5702 MethodDeclaration method = | 5970 MethodDeclaration method = |
| 5703 parse("parseClassMember", <Object>["C"], "set() {}"); | 5971 parse("parseClassMember", <Object>["C"], "set() {}"); |
| 5704 expect(method.documentationComment, isNull); | 5972 expect(method.documentationComment, isNull); |
| 5705 expect(method.externalKeyword, isNull); | 5973 expect(method.externalKeyword, isNull); |
| 5706 expect(method.modifierKeyword, isNull); | 5974 expect(method.modifierKeyword, isNull); |
| 5707 expect(method.propertyKeyword, isNull); | 5975 expect(method.propertyKeyword, isNull); |
| 5708 expect(method.returnType, isNull); | 5976 expect(method.returnType, isNull); |
| 5709 expect(method.name, isNotNull); | 5977 expect(method.name, isNotNull); |
| 5710 expect(method.operatorKeyword, isNull); | 5978 expect(method.operatorKeyword, isNull); |
| 5979 expect(method.typeParameters, isNull); |
| 5711 expect(method.parameters, isNotNull); | 5980 expect(method.parameters, isNotNull); |
| 5712 expect(method.body, isNotNull); | 5981 expect(method.body, isNotNull); |
| 5713 } | 5982 } |
| 5714 | 5983 |
| 5715 void test_parseClassMember_method_set_type() { | 5984 void test_parseClassMember_method_set_type() { |
| 5716 MethodDeclaration method = | 5985 MethodDeclaration method = |
| 5717 parse("parseClassMember", <Object>["C"], "int set() {}"); | 5986 parse("parseClassMember", <Object>["C"], "int set() {}"); |
| 5718 expect(method.documentationComment, isNull); | 5987 expect(method.documentationComment, isNull); |
| 5719 expect(method.externalKeyword, isNull); | 5988 expect(method.externalKeyword, isNull); |
| 5720 expect(method.modifierKeyword, isNull); | 5989 expect(method.modifierKeyword, isNull); |
| 5721 expect(method.propertyKeyword, isNull); | 5990 expect(method.propertyKeyword, isNull); |
| 5722 expect(method.returnType, isNotNull); | 5991 expect(method.returnType, isNotNull); |
| 5723 expect(method.name, isNotNull); | 5992 expect(method.name, isNotNull); |
| 5724 expect(method.operatorKeyword, isNull); | 5993 expect(method.operatorKeyword, isNull); |
| 5994 expect(method.typeParameters, isNull); |
| 5725 expect(method.parameters, isNotNull); | 5995 expect(method.parameters, isNotNull); |
| 5726 expect(method.body, isNotNull); | 5996 expect(method.body, isNotNull); |
| 5727 } | 5997 } |
| 5728 | 5998 |
| 5729 void test_parseClassMember_method_set_void() { | 5999 void test_parseClassMember_method_set_void() { |
| 5730 MethodDeclaration method = | 6000 MethodDeclaration method = |
| 5731 parse("parseClassMember", <Object>["C"], "void set() {}"); | 6001 parse("parseClassMember", <Object>["C"], "void set() {}"); |
| 5732 expect(method.documentationComment, isNull); | 6002 expect(method.documentationComment, isNull); |
| 5733 expect(method.externalKeyword, isNull); | 6003 expect(method.externalKeyword, isNull); |
| 5734 expect(method.modifierKeyword, isNull); | 6004 expect(method.modifierKeyword, isNull); |
| 5735 expect(method.propertyKeyword, isNull); | 6005 expect(method.propertyKeyword, isNull); |
| 5736 expect(method.returnType, isNotNull); | 6006 expect(method.returnType, isNotNull); |
| 5737 expect(method.name, isNotNull); | 6007 expect(method.name, isNotNull); |
| 5738 expect(method.operatorKeyword, isNull); | 6008 expect(method.operatorKeyword, isNull); |
| 6009 expect(method.typeParameters, isNull); |
| 5739 expect(method.parameters, isNotNull); | 6010 expect(method.parameters, isNotNull); |
| 5740 expect(method.body, isNotNull); | 6011 expect(method.body, isNotNull); |
| 5741 } | 6012 } |
| 5742 | 6013 |
| 5743 void test_parseClassMember_operator_index() { | 6014 void test_parseClassMember_operator_index() { |
| 5744 MethodDeclaration method = | 6015 MethodDeclaration method = |
| 5745 parse("parseClassMember", <Object>["C"], "int operator [](int i) {}"); | 6016 parse("parseClassMember", <Object>["C"], "int operator [](int i) {}"); |
| 5746 expect(method.documentationComment, isNull); | 6017 expect(method.documentationComment, isNull); |
| 5747 expect(method.externalKeyword, isNull); | 6018 expect(method.externalKeyword, isNull); |
| 5748 expect(method.modifierKeyword, isNull); | 6019 expect(method.modifierKeyword, isNull); |
| 5749 expect(method.propertyKeyword, isNull); | 6020 expect(method.propertyKeyword, isNull); |
| 5750 expect(method.returnType, isNotNull); | 6021 expect(method.returnType, isNotNull); |
| 5751 expect(method.name, isNotNull); | 6022 expect(method.name, isNotNull); |
| 5752 expect(method.operatorKeyword, isNotNull); | 6023 expect(method.operatorKeyword, isNotNull); |
| 6024 expect(method.typeParameters, isNull); |
| 5753 expect(method.parameters, isNotNull); | 6025 expect(method.parameters, isNotNull); |
| 5754 expect(method.body, isNotNull); | 6026 expect(method.body, isNotNull); |
| 5755 } | 6027 } |
| 5756 | 6028 |
| 5757 void test_parseClassMember_operator_indexAssign() { | 6029 void test_parseClassMember_operator_indexAssign() { |
| 5758 MethodDeclaration method = | 6030 MethodDeclaration method = |
| 5759 parse("parseClassMember", <Object>["C"], "int operator []=(int i) {}"); | 6031 parse("parseClassMember", <Object>["C"], "int operator []=(int i) {}"); |
| 5760 expect(method.documentationComment, isNull); | 6032 expect(method.documentationComment, isNull); |
| 5761 expect(method.externalKeyword, isNull); | 6033 expect(method.externalKeyword, isNull); |
| 5762 expect(method.modifierKeyword, isNull); | 6034 expect(method.modifierKeyword, isNull); |
| 5763 expect(method.propertyKeyword, isNull); | 6035 expect(method.propertyKeyword, isNull); |
| 5764 expect(method.returnType, isNotNull); | 6036 expect(method.returnType, isNotNull); |
| 5765 expect(method.name, isNotNull); | 6037 expect(method.name, isNotNull); |
| 5766 expect(method.operatorKeyword, isNotNull); | 6038 expect(method.operatorKeyword, isNotNull); |
| 6039 expect(method.typeParameters, isNull); |
| 5767 expect(method.parameters, isNotNull); | 6040 expect(method.parameters, isNotNull); |
| 5768 expect(method.body, isNotNull); | 6041 expect(method.body, isNotNull); |
| 5769 } | 6042 } |
| 5770 | 6043 |
| 5771 void test_parseClassMember_redirectingFactory_const() { | 6044 void test_parseClassMember_redirectingFactory_const() { |
| 5772 ConstructorDeclaration constructor = | 6045 ConstructorDeclaration constructor = |
| 5773 parse("parseClassMember", <Object>["C"], "const factory C() = B;"); | 6046 parse("parseClassMember", <Object>["C"], "const factory C() = B;"); |
| 5774 expect(constructor.externalKeyword, isNull); | 6047 expect(constructor.externalKeyword, isNull); |
| 5775 expect(constructor.constKeyword, isNotNull); | 6048 expect(constructor.constKeyword, isNotNull); |
| 5776 expect(constructor.factoryKeyword, isNotNull); | 6049 expect(constructor.factoryKeyword, isNotNull); |
| (...skipping 1194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6971 } | 7244 } |
| 6972 | 7245 |
| 6973 void test_parseExpression_invokeFunctionExpression() { | 7246 void test_parseExpression_invokeFunctionExpression() { |
| 6974 FunctionExpressionInvocation invocation = | 7247 FunctionExpressionInvocation invocation = |
| 6975 parse4("parseExpression", "(a) {return a + a;} (3)"); | 7248 parse4("parseExpression", "(a) {return a + a;} (3)"); |
| 6976 EngineTestCase.assertInstanceOf((obj) => obj is FunctionExpression, | 7249 EngineTestCase.assertInstanceOf((obj) => obj is FunctionExpression, |
| 6977 FunctionExpression, invocation.function); | 7250 FunctionExpression, invocation.function); |
| 6978 FunctionExpression expression = invocation.function as FunctionExpression; | 7251 FunctionExpression expression = invocation.function as FunctionExpression; |
| 6979 expect(expression.parameters, isNotNull); | 7252 expect(expression.parameters, isNotNull); |
| 6980 expect(expression.body, isNotNull); | 7253 expect(expression.body, isNotNull); |
| 7254 expect(invocation.typeArguments, isNull); |
| 6981 ArgumentList list = invocation.argumentList; | 7255 ArgumentList list = invocation.argumentList; |
| 6982 expect(list, isNotNull); | 7256 expect(list, isNotNull); |
| 6983 expect(list.arguments, hasLength(1)); | 7257 expect(list.arguments, hasLength(1)); |
| 6984 } | 7258 } |
| 6985 | 7259 |
| 6986 void test_parseExpression_nonAwait() { | 7260 void test_parseExpression_nonAwait() { |
| 6987 MethodInvocation expression = parseExpression("await()"); | 7261 MethodInvocation expression = parseExpression("await()"); |
| 6988 expect(expression.methodName.name, 'await'); | 7262 expect(expression.methodName.name, 'await'); |
| 7263 expect(expression.typeArguments, isNull); |
| 7264 expect(expression.argumentList, isNotNull); |
| 6989 } | 7265 } |
| 6990 | 7266 |
| 6991 void test_parseExpression_superMethodInvocation() { | 7267 void test_parseExpression_superMethodInvocation() { |
| 6992 MethodInvocation invocation = parse4("parseExpression", "super.m()"); | 7268 MethodInvocation invocation = parse4("parseExpression", "super.m()"); |
| 6993 expect(invocation.target, isNotNull); | 7269 expect(invocation.target, isNotNull); |
| 6994 expect(invocation.methodName, isNotNull); | 7270 expect(invocation.methodName, isNotNull); |
| 7271 expect(invocation.typeArguments, isNull); |
| 6995 expect(invocation.argumentList, isNotNull); | 7272 expect(invocation.argumentList, isNotNull); |
| 6996 } | 7273 } |
| 6997 | 7274 |
| 7275 void test_parseExpression_superMethodInvocation_typeArguments() { |
| 7276 enableGenericMethods = true; |
| 7277 MethodInvocation invocation = parse4("parseExpression", "super.m<E>()"); |
| 7278 expect(invocation.target, isNotNull); |
| 7279 expect(invocation.methodName, isNotNull); |
| 7280 expect(invocation.typeArguments, isNotNull); |
| 7281 expect(invocation.argumentList, isNotNull); |
| 7282 } |
| 7283 |
| 6998 void test_parseExpressionList_multiple() { | 7284 void test_parseExpressionList_multiple() { |
| 6999 List<Expression> result = parse4("parseExpressionList", "1, 2, 3"); | 7285 List<Expression> result = parse4("parseExpressionList", "1, 2, 3"); |
| 7000 expect(result, hasLength(3)); | 7286 expect(result, hasLength(3)); |
| 7001 } | 7287 } |
| 7002 | 7288 |
| 7003 void test_parseExpressionList_single() { | 7289 void test_parseExpressionList_single() { |
| 7004 List<Expression> result = parse4("parseExpressionList", "1"); | 7290 List<Expression> result = parse4("parseExpressionList", "1"); |
| 7005 expect(result, hasLength(1)); | 7291 expect(result, hasLength(1)); |
| 7006 } | 7292 } |
| 7007 | 7293 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 7022 expect(expression.operator, isNotNull); | 7308 expect(expression.operator, isNotNull); |
| 7023 expect(expression.operator.type, TokenType.EQ_EQ); | 7309 expect(expression.operator.type, TokenType.EQ_EQ); |
| 7024 expect(expression.rightOperand, isNotNull); | 7310 expect(expression.rightOperand, isNotNull); |
| 7025 } | 7311 } |
| 7026 | 7312 |
| 7027 void test_parseExpressionWithoutCascade_superMethodInvocation() { | 7313 void test_parseExpressionWithoutCascade_superMethodInvocation() { |
| 7028 MethodInvocation invocation = | 7314 MethodInvocation invocation = |
| 7029 parse4("parseExpressionWithoutCascade", "super.m()"); | 7315 parse4("parseExpressionWithoutCascade", "super.m()"); |
| 7030 expect(invocation.target, isNotNull); | 7316 expect(invocation.target, isNotNull); |
| 7031 expect(invocation.methodName, isNotNull); | 7317 expect(invocation.methodName, isNotNull); |
| 7318 expect(invocation.typeArguments, isNull); |
| 7032 expect(invocation.argumentList, isNotNull); | 7319 expect(invocation.argumentList, isNotNull); |
| 7033 } | 7320 } |
| 7034 | 7321 |
| 7322 void test_parseExpressionWithoutCascade_superMethodInvocation_typeArguments()
{ |
| 7323 enableGenericMethods = true; |
| 7324 MethodInvocation invocation = |
| 7325 parse4("parseExpressionWithoutCascade", "super.m<E>()"); |
| 7326 expect(invocation.target, isNotNull); |
| 7327 expect(invocation.methodName, isNotNull); |
| 7328 expect(invocation.typeArguments, isNotNull); |
| 7329 expect(invocation.argumentList, isNotNull); |
| 7330 } |
| 7331 |
| 7035 void test_parseExtendsClause() { | 7332 void test_parseExtendsClause() { |
| 7036 ExtendsClause clause = parse4("parseExtendsClause", "extends B"); | 7333 ExtendsClause clause = parse4("parseExtendsClause", "extends B"); |
| 7037 expect(clause.extendsKeyword, isNotNull); | 7334 expect(clause.extendsKeyword, isNotNull); |
| 7038 expect(clause.superclass, isNotNull); | 7335 expect(clause.superclass, isNotNull); |
| 7039 EngineTestCase.assertInstanceOf( | 7336 EngineTestCase.assertInstanceOf( |
| 7040 (obj) => obj is TypeName, TypeName, clause.superclass); | 7337 (obj) => obj is TypeName, TypeName, clause.superclass); |
| 7041 } | 7338 } |
| 7042 | 7339 |
| 7043 void test_parseFinalConstVarOrType_const_noType() { | 7340 void test_parseFinalConstVarOrType_const_noType() { |
| 7044 FinalConstVarOrType result = | 7341 FinalConstVarOrType result = |
| (...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7758 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); | 8055 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); |
| 7759 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); | 8056 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); |
| 7760 FunctionDeclaration declaration = parse("parseFunctionDeclaration", | 8057 FunctionDeclaration declaration = parse("parseFunctionDeclaration", |
| 7761 <Object>[commentAndMetadata(comment), null, returnType], "f() {}"); | 8058 <Object>[commentAndMetadata(comment), null, returnType], "f() {}"); |
| 7762 expect(declaration.documentationComment, comment); | 8059 expect(declaration.documentationComment, comment); |
| 7763 expect(declaration.returnType, returnType); | 8060 expect(declaration.returnType, returnType); |
| 7764 expect(declaration.name, isNotNull); | 8061 expect(declaration.name, isNotNull); |
| 7765 FunctionExpression expression = declaration.functionExpression; | 8062 FunctionExpression expression = declaration.functionExpression; |
| 7766 expect(expression, isNotNull); | 8063 expect(expression, isNotNull); |
| 7767 expect(expression.body, isNotNull); | 8064 expect(expression.body, isNotNull); |
| 8065 expect(expression.typeParameters, isNull); |
| 7768 expect(expression.parameters, isNotNull); | 8066 expect(expression.parameters, isNotNull); |
| 7769 expect(declaration.propertyKeyword, isNull); | 8067 expect(declaration.propertyKeyword, isNull); |
| 7770 } | 8068 } |
| 8069 |
| 8070 void test_parseFunctionDeclaration_functionWithTypeParameters() { |
| 8071 enableGenericMethods = true; |
| 8072 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); |
| 8073 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); |
| 8074 FunctionDeclaration declaration = parse("parseFunctionDeclaration", |
| 8075 <Object>[commentAndMetadata(comment), null, returnType], "f<E>() {}"); |
| 8076 expect(declaration.documentationComment, comment); |
| 8077 expect(declaration.returnType, returnType); |
| 8078 expect(declaration.name, isNotNull); |
| 8079 FunctionExpression expression = declaration.functionExpression; |
| 8080 expect(expression, isNotNull); |
| 8081 expect(expression.body, isNotNull); |
| 8082 expect(expression.typeParameters, isNotNull); |
| 8083 expect(expression.parameters, isNotNull); |
| 8084 expect(declaration.propertyKeyword, isNull); |
| 8085 } |
| 7771 | 8086 |
| 7772 void test_parseFunctionDeclaration_getter() { | 8087 void test_parseFunctionDeclaration_getter() { |
| 7773 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); | 8088 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); |
| 7774 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); | 8089 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); |
| 7775 FunctionDeclaration declaration = parse("parseFunctionDeclaration", | 8090 FunctionDeclaration declaration = parse("parseFunctionDeclaration", |
| 7776 <Object>[commentAndMetadata(comment), null, returnType], "get p => 0;"); | 8091 <Object>[commentAndMetadata(comment), null, returnType], "get p => 0;"); |
| 7777 expect(declaration.documentationComment, comment); | 8092 expect(declaration.documentationComment, comment); |
| 7778 expect(declaration.returnType, returnType); | 8093 expect(declaration.returnType, returnType); |
| 7779 expect(declaration.name, isNotNull); | 8094 expect(declaration.name, isNotNull); |
| 7780 FunctionExpression expression = declaration.functionExpression; | 8095 FunctionExpression expression = declaration.functionExpression; |
| 7781 expect(expression, isNotNull); | 8096 expect(expression, isNotNull); |
| 7782 expect(expression.body, isNotNull); | 8097 expect(expression.body, isNotNull); |
| 8098 expect(expression.typeParameters, isNull); |
| 7783 expect(expression.parameters, isNull); | 8099 expect(expression.parameters, isNull); |
| 7784 expect(declaration.propertyKeyword, isNotNull); | 8100 expect(declaration.propertyKeyword, isNotNull); |
| 7785 } | 8101 } |
| 7786 | 8102 |
| 7787 void test_parseFunctionDeclaration_setter() { | 8103 void test_parseFunctionDeclaration_setter() { |
| 7788 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); | 8104 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); |
| 7789 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); | 8105 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); |
| 7790 FunctionDeclaration declaration = parse("parseFunctionDeclaration", | 8106 FunctionDeclaration declaration = parse("parseFunctionDeclaration", |
| 7791 <Object>[commentAndMetadata(comment), null, returnType], "set p(v) {}"); | 8107 <Object>[commentAndMetadata(comment), null, returnType], "set p(v) {}"); |
| 7792 expect(declaration.documentationComment, comment); | 8108 expect(declaration.documentationComment, comment); |
| 7793 expect(declaration.returnType, returnType); | 8109 expect(declaration.returnType, returnType); |
| 7794 expect(declaration.name, isNotNull); | 8110 expect(declaration.name, isNotNull); |
| 7795 FunctionExpression expression = declaration.functionExpression; | 8111 FunctionExpression expression = declaration.functionExpression; |
| 7796 expect(expression, isNotNull); | 8112 expect(expression, isNotNull); |
| 7797 expect(expression.body, isNotNull); | 8113 expect(expression.body, isNotNull); |
| 8114 expect(expression.typeParameters, isNull); |
| 7798 expect(expression.parameters, isNotNull); | 8115 expect(expression.parameters, isNotNull); |
| 7799 expect(declaration.propertyKeyword, isNotNull); | 8116 expect(declaration.propertyKeyword, isNotNull); |
| 7800 } | 8117 } |
| 7801 | 8118 |
| 7802 void test_parseFunctionDeclarationStatement() { | 8119 void test_parseFunctionDeclarationStatement() { |
| 7803 FunctionDeclarationStatement statement = | 8120 FunctionDeclarationStatement statement = |
| 7804 parse4("parseFunctionDeclarationStatement", "void f(int p) => p * 2;"); | 8121 parse4("parseFunctionDeclarationStatement", "void f(int p) => p * 2;"); |
| 7805 expect(statement.functionDeclaration, isNotNull); | 8122 expect(statement.functionDeclaration, isNotNull); |
| 7806 } | 8123 } |
| 7807 | 8124 |
| 8125 void test_parseFunctionDeclarationStatement_typeParameters() { |
| 8126 enableGenericMethods = true; |
| 8127 FunctionDeclarationStatement statement = |
| 8128 parse4("parseFunctionDeclarationStatement", "E f<E>(E p) => p * 2;"); |
| 8129 expect(statement.functionDeclaration, isNotNull); |
| 8130 } |
| 8131 |
| 7808 void test_parseFunctionExpression_body_inExpression() { | 8132 void test_parseFunctionExpression_body_inExpression() { |
| 7809 FunctionExpression expression = | 8133 FunctionExpression expression = |
| 7810 parse4("parseFunctionExpression", "(int i) => i++"); | 8134 parse4("parseFunctionExpression", "(int i) => i++"); |
| 7811 expect(expression.body, isNotNull); | 8135 expect(expression.body, isNotNull); |
| 8136 expect(expression.typeParameters, isNull); |
| 7812 expect(expression.parameters, isNotNull); | 8137 expect(expression.parameters, isNotNull); |
| 7813 expect((expression.body as ExpressionFunctionBody).semicolon, isNull); | 8138 expect((expression.body as ExpressionFunctionBody).semicolon, isNull); |
| 7814 } | 8139 } |
| 8140 |
| 8141 void test_parseFunctionExpression_typeParameters() { |
| 8142 enableGenericMethods = true; |
| 8143 FunctionExpression expression = |
| 8144 parse4("parseFunctionExpression", "<E>(E i) => i++"); |
| 8145 expect(expression.body, isNotNull); |
| 8146 expect(expression.typeParameters, isNotNull); |
| 8147 expect(expression.parameters, isNotNull); |
| 8148 expect((expression.body as ExpressionFunctionBody).semicolon, isNull); |
| 8149 } |
| 7815 | 8150 |
| 7816 void test_parseGetter_nonStatic() { | 8151 void test_parseGetter_nonStatic() { |
| 7817 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); | 8152 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); |
| 7818 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); | 8153 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); |
| 7819 MethodDeclaration method = parse("parseGetter", <Object>[ | 8154 MethodDeclaration method = parse("parseGetter", <Object>[ |
| 7820 commentAndMetadata(comment), | 8155 commentAndMetadata(comment), |
| 7821 null, | 8156 null, |
| 7822 null, | 8157 null, |
| 7823 returnType | 8158 returnType |
| 7824 ], "get a;"); | 8159 ], "get a;"); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 7842 null, | 8177 null, |
| 7843 staticKeyword, | 8178 staticKeyword, |
| 7844 returnType | 8179 returnType |
| 7845 ], "get a => 42;"); | 8180 ], "get a => 42;"); |
| 7846 expect(method.body, isNotNull); | 8181 expect(method.body, isNotNull); |
| 7847 expect(method.documentationComment, comment); | 8182 expect(method.documentationComment, comment); |
| 7848 expect(method.externalKeyword, isNull); | 8183 expect(method.externalKeyword, isNull); |
| 7849 expect(method.modifierKeyword, staticKeyword); | 8184 expect(method.modifierKeyword, staticKeyword); |
| 7850 expect(method.name, isNotNull); | 8185 expect(method.name, isNotNull); |
| 7851 expect(method.operatorKeyword, isNull); | 8186 expect(method.operatorKeyword, isNull); |
| 8187 expect(method.typeParameters, isNull); |
| 7852 expect(method.parameters, isNull); | 8188 expect(method.parameters, isNull); |
| 7853 expect(method.propertyKeyword, isNotNull); | 8189 expect(method.propertyKeyword, isNotNull); |
| 7854 expect(method.returnType, returnType); | 8190 expect(method.returnType, returnType); |
| 7855 } | 8191 } |
| 7856 | 8192 |
| 7857 void test_parseIdentifierList_multiple() { | 8193 void test_parseIdentifierList_multiple() { |
| 7858 List<SimpleIdentifier> list = parse4("parseIdentifierList", "a, b, c"); | 8194 List<SimpleIdentifier> list = parse4("parseIdentifierList", "a, b, c"); |
| 7859 expect(list, hasLength(3)); | 8195 expect(list, hasLength(3)); |
| 7860 } | 8196 } |
| 7861 | 8197 |
| (...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8426 EngineTestCase.assertInstanceOf( | 8762 EngineTestCase.assertInstanceOf( |
| 8427 (obj) => obj is FunctionExpressionInvocation, | 8763 (obj) => obj is FunctionExpressionInvocation, |
| 8428 FunctionExpressionInvocation, statement.expression); | 8764 FunctionExpressionInvocation, statement.expression); |
| 8429 FunctionExpressionInvocation invocation = | 8765 FunctionExpressionInvocation invocation = |
| 8430 statement.expression as FunctionExpressionInvocation; | 8766 statement.expression as FunctionExpressionInvocation; |
| 8431 EngineTestCase.assertInstanceOf((obj) => obj is FunctionExpression, | 8767 EngineTestCase.assertInstanceOf((obj) => obj is FunctionExpression, |
| 8432 FunctionExpression, invocation.function); | 8768 FunctionExpression, invocation.function); |
| 8433 FunctionExpression expression = invocation.function as FunctionExpression; | 8769 FunctionExpression expression = invocation.function as FunctionExpression; |
| 8434 expect(expression.parameters, isNotNull); | 8770 expect(expression.parameters, isNotNull); |
| 8435 expect(expression.body, isNotNull); | 8771 expect(expression.body, isNotNull); |
| 8772 expect(invocation.typeArguments, isNull); |
| 8436 ArgumentList list = invocation.argumentList; | 8773 ArgumentList list = invocation.argumentList; |
| 8437 expect(list, isNotNull); | 8774 expect(list, isNotNull); |
| 8438 expect(list.arguments, hasLength(1)); | 8775 expect(list.arguments, hasLength(1)); |
| 8439 } | 8776 } |
| 8440 | 8777 |
| 8441 void test_parseNonLabeledStatement_null() { | 8778 void test_parseNonLabeledStatement_null() { |
| 8442 ExpressionStatement statement = parse4("parseNonLabeledStatement", "null;"); | 8779 ExpressionStatement statement = parse4("parseNonLabeledStatement", "null;"); |
| 8443 expect(statement.expression, isNotNull); | 8780 expect(statement.expression, isNotNull); |
| 8444 } | 8781 } |
| 8445 | 8782 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8543 expect(parameter.type, isNull); | 8880 expect(parameter.type, isNull); |
| 8544 expect(parameter.identifier, isNotNull); | 8881 expect(parameter.identifier, isNotNull); |
| 8545 expect(parameter.parameters, isNull); | 8882 expect(parameter.parameters, isNull); |
| 8546 } | 8883 } |
| 8547 | 8884 |
| 8548 void test_parseNormalFormalParameter_function_noType() { | 8885 void test_parseNormalFormalParameter_function_noType() { |
| 8549 FunctionTypedFormalParameter parameter = | 8886 FunctionTypedFormalParameter parameter = |
| 8550 parse4("parseNormalFormalParameter", "a())"); | 8887 parse4("parseNormalFormalParameter", "a())"); |
| 8551 expect(parameter.returnType, isNull); | 8888 expect(parameter.returnType, isNull); |
| 8552 expect(parameter.identifier, isNotNull); | 8889 expect(parameter.identifier, isNotNull); |
| 8890 expect(parameter.typeParameters, isNull); |
| 8553 expect(parameter.parameters, isNotNull); | 8891 expect(parameter.parameters, isNotNull); |
| 8554 } | 8892 } |
| 8555 | 8893 |
| 8894 void test_parseNormalFormalParameter_function_noType_typeParameters() { |
| 8895 enableGenericMethods = true; |
| 8896 FunctionTypedFormalParameter parameter = |
| 8897 parse4("parseNormalFormalParameter", "a<E>())"); |
| 8898 expect(parameter.returnType, isNull); |
| 8899 expect(parameter.identifier, isNotNull); |
| 8900 expect(parameter.typeParameters, isNotNull); |
| 8901 expect(parameter.parameters, isNotNull); |
| 8902 } |
| 8903 |
| 8556 void test_parseNormalFormalParameter_function_type() { | 8904 void test_parseNormalFormalParameter_function_type() { |
| 8557 FunctionTypedFormalParameter parameter = | 8905 FunctionTypedFormalParameter parameter = |
| 8558 parse4("parseNormalFormalParameter", "A a())"); | 8906 parse4("parseNormalFormalParameter", "A a())"); |
| 8559 expect(parameter.returnType, isNotNull); | 8907 expect(parameter.returnType, isNotNull); |
| 8560 expect(parameter.identifier, isNotNull); | 8908 expect(parameter.identifier, isNotNull); |
| 8909 expect(parameter.typeParameters, isNull); |
| 8561 expect(parameter.parameters, isNotNull); | 8910 expect(parameter.parameters, isNotNull); |
| 8562 } | 8911 } |
| 8563 | 8912 |
| 8913 void test_parseNormalFormalParameter_function_type_typeParameters() { |
| 8914 enableGenericMethods = true; |
| 8915 FunctionTypedFormalParameter parameter = |
| 8916 parse4("parseNormalFormalParameter", "A a<E>())"); |
| 8917 expect(parameter.returnType, isNotNull); |
| 8918 expect(parameter.identifier, isNotNull); |
| 8919 expect(parameter.typeParameters, isNotNull); |
| 8920 expect(parameter.parameters, isNotNull); |
| 8921 } |
| 8922 |
| 8564 void test_parseNormalFormalParameter_function_void() { | 8923 void test_parseNormalFormalParameter_function_void() { |
| 8565 FunctionTypedFormalParameter parameter = | 8924 FunctionTypedFormalParameter parameter = |
| 8566 parse4("parseNormalFormalParameter", "void a())"); | 8925 parse4("parseNormalFormalParameter", "void a())"); |
| 8567 expect(parameter.returnType, isNotNull); | 8926 expect(parameter.returnType, isNotNull); |
| 8568 expect(parameter.identifier, isNotNull); | 8927 expect(parameter.identifier, isNotNull); |
| 8928 expect(parameter.typeParameters, isNull); |
| 8569 expect(parameter.parameters, isNotNull); | 8929 expect(parameter.parameters, isNotNull); |
| 8570 } | 8930 } |
| 8571 | 8931 |
| 8932 void test_parseNormalFormalParameter_function_void_typeParameters() { |
| 8933 enableGenericMethods = true; |
| 8934 FunctionTypedFormalParameter parameter = |
| 8935 parse4("parseNormalFormalParameter", "void a<E>())"); |
| 8936 expect(parameter.returnType, isNotNull); |
| 8937 expect(parameter.identifier, isNotNull); |
| 8938 expect(parameter.typeParameters, isNotNull); |
| 8939 expect(parameter.parameters, isNotNull); |
| 8940 } |
| 8941 |
| 8572 void test_parseNormalFormalParameter_simple_const_noType() { | 8942 void test_parseNormalFormalParameter_simple_const_noType() { |
| 8573 SimpleFormalParameter parameter = | 8943 SimpleFormalParameter parameter = |
| 8574 parse4("parseNormalFormalParameter", "const a)"); | 8944 parse4("parseNormalFormalParameter", "const a)"); |
| 8575 expect(parameter.keyword, isNotNull); | 8945 expect(parameter.keyword, isNotNull); |
| 8576 expect(parameter.type, isNull); | 8946 expect(parameter.type, isNull); |
| 8577 expect(parameter.identifier, isNotNull); | 8947 expect(parameter.identifier, isNotNull); |
| 8578 } | 8948 } |
| 8579 | 8949 |
| 8580 void test_parseNormalFormalParameter_simple_const_type() { | 8950 void test_parseNormalFormalParameter_simple_const_type() { |
| 8581 SimpleFormalParameter parameter = | 8951 SimpleFormalParameter parameter = |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8624 commentAndMetadata(comment), | 8994 commentAndMetadata(comment), |
| 8625 null, | 8995 null, |
| 8626 returnType | 8996 returnType |
| 8627 ], "operator +(A a);"); | 8997 ], "operator +(A a);"); |
| 8628 expect(method.body, isNotNull); | 8998 expect(method.body, isNotNull); |
| 8629 expect(method.documentationComment, comment); | 8999 expect(method.documentationComment, comment); |
| 8630 expect(method.externalKeyword, isNull); | 9000 expect(method.externalKeyword, isNull); |
| 8631 expect(method.modifierKeyword, isNull); | 9001 expect(method.modifierKeyword, isNull); |
| 8632 expect(method.name, isNotNull); | 9002 expect(method.name, isNotNull); |
| 8633 expect(method.operatorKeyword, isNotNull); | 9003 expect(method.operatorKeyword, isNotNull); |
| 9004 expect(method.typeParameters, isNull); |
| 8634 expect(method.parameters, isNotNull); | 9005 expect(method.parameters, isNotNull); |
| 8635 expect(method.propertyKeyword, isNull); | 9006 expect(method.propertyKeyword, isNull); |
| 8636 expect(method.returnType, returnType); | 9007 expect(method.returnType, returnType); |
| 8637 } | 9008 } |
| 8638 | 9009 |
| 8639 void test_parseOptionalReturnType() { | 9010 void test_parseOptionalReturnType() { |
| 8640 // TODO(brianwilkerson) Implement tests for this method. | 9011 // TODO(brianwilkerson) Implement tests for this method. |
| 8641 } | 9012 } |
| 8642 | 9013 |
| 8643 void test_parsePartDirective_part() { | 9014 void test_parsePartDirective_part() { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8675 IndexExpression expression = parse4("parsePostfixExpression", "a[0]"); | 9046 IndexExpression expression = parse4("parsePostfixExpression", "a[0]"); |
| 8676 expect(expression.target, isNotNull); | 9047 expect(expression.target, isNotNull); |
| 8677 expect(expression.index, isNotNull); | 9048 expect(expression.index, isNotNull); |
| 8678 } | 9049 } |
| 8679 | 9050 |
| 8680 void test_parsePostfixExpression_none_methodInvocation() { | 9051 void test_parsePostfixExpression_none_methodInvocation() { |
| 8681 MethodInvocation expression = parse4("parsePostfixExpression", "a.m()"); | 9052 MethodInvocation expression = parse4("parsePostfixExpression", "a.m()"); |
| 8682 expect(expression.target, isNotNull); | 9053 expect(expression.target, isNotNull); |
| 8683 expect(expression.operator.type, TokenType.PERIOD); | 9054 expect(expression.operator.type, TokenType.PERIOD); |
| 8684 expect(expression.methodName, isNotNull); | 9055 expect(expression.methodName, isNotNull); |
| 9056 expect(expression.typeArguments, isNull); |
| 8685 expect(expression.argumentList, isNotNull); | 9057 expect(expression.argumentList, isNotNull); |
| 8686 } | 9058 } |
| 8687 | 9059 |
| 8688 void test_parsePostfixExpression_none_methodInvocation_question_dot() { | 9060 void test_parsePostfixExpression_none_methodInvocation_question_dot() { |
| 8689 _enableNullAwareOperators = true; | 9061 _enableNullAwareOperators = true; |
| 8690 MethodInvocation expression = parse4('parsePostfixExpression', 'a?.m()'); | 9062 MethodInvocation expression = parse4('parsePostfixExpression', 'a?.m()'); |
| 8691 expect(expression.target, isNotNull); | 9063 expect(expression.target, isNotNull); |
| 8692 expect(expression.operator.type, TokenType.QUESTION_PERIOD); | 9064 expect(expression.operator.type, TokenType.QUESTION_PERIOD); |
| 8693 expect(expression.methodName, isNotNull); | 9065 expect(expression.methodName, isNotNull); |
| 9066 expect(expression.typeArguments, isNull); |
| 8694 expect(expression.argumentList, isNotNull); | 9067 expect(expression.argumentList, isNotNull); |
| 8695 } | 9068 } |
| 8696 | 9069 |
| 9070 void test_parsePostfixExpression_none_methodInvocation_question_dot_typeArgume
nts() { |
| 9071 enableGenericMethods = true; |
| 9072 _enableNullAwareOperators = true; |
| 9073 MethodInvocation expression = parse4('parsePostfixExpression', 'a?.m<E>()'); |
| 9074 expect(expression.target, isNotNull); |
| 9075 expect(expression.operator.type, TokenType.QUESTION_PERIOD); |
| 9076 expect(expression.methodName, isNotNull); |
| 9077 expect(expression.typeArguments, isNotNull); |
| 9078 expect(expression.argumentList, isNotNull); |
| 9079 } |
| 9080 |
| 9081 void test_parsePostfixExpression_none_methodInvocation_typeArguments() { |
| 9082 enableGenericMethods = true; |
| 9083 MethodInvocation expression = parse4("parsePostfixExpression", "a.m<E>()"); |
| 9084 expect(expression.target, isNotNull); |
| 9085 expect(expression.operator.type, TokenType.PERIOD); |
| 9086 expect(expression.methodName, isNotNull); |
| 9087 expect(expression.typeArguments, isNotNull); |
| 9088 expect(expression.argumentList, isNotNull); |
| 9089 } |
| 9090 |
| 8697 void test_parsePostfixExpression_none_propertyAccess() { | 9091 void test_parsePostfixExpression_none_propertyAccess() { |
| 8698 PrefixedIdentifier expression = parse4("parsePostfixExpression", "a.b"); | 9092 PrefixedIdentifier expression = parse4("parsePostfixExpression", "a.b"); |
| 8699 expect(expression.prefix, isNotNull); | 9093 expect(expression.prefix, isNotNull); |
| 8700 expect(expression.identifier, isNotNull); | 9094 expect(expression.identifier, isNotNull); |
| 8701 } | 9095 } |
| 8702 | 9096 |
| 8703 void test_parsePrefixedIdentifier_noPrefix() { | 9097 void test_parsePrefixedIdentifier_noPrefix() { |
| 8704 String lexeme = "bar"; | 9098 String lexeme = "bar"; |
| 8705 SimpleIdentifier identifier = parse4("parsePrefixedIdentifier", lexeme); | 9099 SimpleIdentifier identifier = parse4("parsePrefixedIdentifier", lexeme); |
| 8706 expect(identifier.token, isNotNull); | 9100 expect(identifier.token, isNotNull); |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8954 null, | 9348 null, |
| 8955 null, | 9349 null, |
| 8956 returnType | 9350 returnType |
| 8957 ], "set a(var x);"); | 9351 ], "set a(var x);"); |
| 8958 expect(method.body, isNotNull); | 9352 expect(method.body, isNotNull); |
| 8959 expect(method.documentationComment, comment); | 9353 expect(method.documentationComment, comment); |
| 8960 expect(method.externalKeyword, isNull); | 9354 expect(method.externalKeyword, isNull); |
| 8961 expect(method.modifierKeyword, isNull); | 9355 expect(method.modifierKeyword, isNull); |
| 8962 expect(method.name, isNotNull); | 9356 expect(method.name, isNotNull); |
| 8963 expect(method.operatorKeyword, isNull); | 9357 expect(method.operatorKeyword, isNull); |
| 9358 expect(method.typeParameters, isNull); |
| 8964 expect(method.parameters, isNotNull); | 9359 expect(method.parameters, isNotNull); |
| 8965 expect(method.propertyKeyword, isNotNull); | 9360 expect(method.propertyKeyword, isNotNull); |
| 8966 expect(method.returnType, returnType); | 9361 expect(method.returnType, returnType); |
| 8967 } | 9362 } |
| 8968 | 9363 |
| 8969 void test_parseSetter_static() { | 9364 void test_parseSetter_static() { |
| 8970 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); | 9365 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); |
| 8971 Token staticKeyword = TokenFactory.tokenFromKeyword(Keyword.STATIC); | 9366 Token staticKeyword = TokenFactory.tokenFromKeyword(Keyword.STATIC); |
| 8972 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); | 9367 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); |
| 8973 MethodDeclaration method = parse("parseSetter", <Object>[ | 9368 MethodDeclaration method = parse("parseSetter", <Object>[ |
| 8974 commentAndMetadata(comment), | 9369 commentAndMetadata(comment), |
| 8975 null, | 9370 null, |
| 8976 staticKeyword, | 9371 staticKeyword, |
| 8977 returnType | 9372 returnType |
| 8978 ], "set a(var x) {}"); | 9373 ], "set a(var x) {}"); |
| 8979 expect(method.body, isNotNull); | 9374 expect(method.body, isNotNull); |
| 8980 expect(method.documentationComment, comment); | 9375 expect(method.documentationComment, comment); |
| 8981 expect(method.externalKeyword, isNull); | 9376 expect(method.externalKeyword, isNull); |
| 8982 expect(method.modifierKeyword, staticKeyword); | 9377 expect(method.modifierKeyword, staticKeyword); |
| 8983 expect(method.name, isNotNull); | 9378 expect(method.name, isNotNull); |
| 8984 expect(method.operatorKeyword, isNull); | 9379 expect(method.operatorKeyword, isNull); |
| 9380 expect(method.typeParameters, isNull); |
| 8985 expect(method.parameters, isNotNull); | 9381 expect(method.parameters, isNotNull); |
| 8986 expect(method.propertyKeyword, isNotNull); | 9382 expect(method.propertyKeyword, isNotNull); |
| 8987 expect(method.returnType, returnType); | 9383 expect(method.returnType, returnType); |
| 8988 } | 9384 } |
| 8989 | 9385 |
| 8990 void test_parseShiftExpression_normal() { | 9386 void test_parseShiftExpression_normal() { |
| 8991 BinaryExpression expression = parse4("parseShiftExpression", "x << y"); | 9387 BinaryExpression expression = parse4("parseShiftExpression", "x << y"); |
| 8992 expect(expression.leftOperand, isNotNull); | 9388 expect(expression.leftOperand, isNotNull); |
| 8993 expect(expression.operator, isNotNull); | 9389 expect(expression.operator, isNotNull); |
| 8994 expect(expression.operator.type, TokenType.LT_LT); | 9390 expect(expression.operator.type, TokenType.LT_LT); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9026 "parseStatement", "C<> c;", [ParserErrorCode.EXPECTED_TYPE_NAME]); | 9422 "parseStatement", "C<> c;", [ParserErrorCode.EXPECTED_TYPE_NAME]); |
| 9027 VariableDeclarationList variables = statement.variables; | 9423 VariableDeclarationList variables = statement.variables; |
| 9028 TypeName type = variables.type; | 9424 TypeName type = variables.type; |
| 9029 TypeArgumentList argumentList = type.typeArguments; | 9425 TypeArgumentList argumentList = type.typeArguments; |
| 9030 expect(argumentList.leftBracket, isNotNull); | 9426 expect(argumentList.leftBracket, isNotNull); |
| 9031 expect(argumentList.arguments, hasLength(1)); | 9427 expect(argumentList.arguments, hasLength(1)); |
| 9032 expect(argumentList.arguments[0].isSynthetic, isTrue); | 9428 expect(argumentList.arguments[0].isSynthetic, isTrue); |
| 9033 expect(argumentList.rightBracket, isNotNull); | 9429 expect(argumentList.rightBracket, isNotNull); |
| 9034 } | 9430 } |
| 9035 | 9431 |
| 9036 void test_parseStatement_functionDeclaration() { | 9432 void test_parseStatement_functionDeclaration_noReturnType() { |
| 9433 FunctionDeclarationStatement statement = |
| 9434 parse4("parseStatement", "f(a, b) {};"); |
| 9435 expect(statement.functionDeclaration, isNotNull); |
| 9436 } |
| 9437 |
| 9438 void test_parseStatement_functionDeclaration_noReturnType_typeParameters() { |
| 9439 enableGenericMethods = true; |
| 9440 FunctionDeclarationStatement statement = |
| 9441 parse4("parseStatement", "f(a, b) {};"); |
| 9442 expect(statement.functionDeclaration, isNotNull); |
| 9443 } |
| 9444 |
| 9445 void test_parseStatement_functionDeclaration_returnType() { |
| 9037 // TODO(brianwilkerson) Implement more tests for this method. | 9446 // TODO(brianwilkerson) Implement more tests for this method. |
| 9038 FunctionDeclarationStatement statement = | 9447 FunctionDeclarationStatement statement = |
| 9039 parse4("parseStatement", "int f(a, b) {};"); | 9448 parse4("parseStatement", "int f(a, b) {};"); |
| 9040 expect(statement.functionDeclaration, isNotNull); | 9449 expect(statement.functionDeclaration, isNotNull); |
| 9041 } | 9450 } |
| 9042 | 9451 |
| 9452 void test_parseStatement_functionDeclaration_returnType_typeParameters() { |
| 9453 enableGenericMethods = true; |
| 9454 FunctionDeclarationStatement statement = |
| 9455 parse4("parseStatement", "int f<E>(a, b) {};"); |
| 9456 expect(statement.functionDeclaration, isNotNull); |
| 9457 } |
| 9458 |
| 9043 void test_parseStatement_mulipleLabels() { | 9459 void test_parseStatement_mulipleLabels() { |
| 9044 LabeledStatement statement = parse4("parseStatement", "l: m: return x;"); | 9460 LabeledStatement statement = parse4("parseStatement", "l: m: return x;"); |
| 9045 expect(statement.labels, hasLength(2)); | 9461 expect(statement.labels, hasLength(2)); |
| 9046 expect(statement.statement, isNotNull); | 9462 expect(statement.statement, isNotNull); |
| 9047 } | 9463 } |
| 9048 | 9464 |
| 9049 void test_parseStatement_noLabels() { | 9465 void test_parseStatement_noLabels() { |
| 9050 parse4("parseStatement", "return x;"); | 9466 parse4("parseStatement", "return x;"); |
| 9051 } | 9467 } |
| 9052 | 9468 |
| (...skipping 1205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10258 new Scanner(null, new CharSequenceReader(source), listener); | 10674 new Scanner(null, new CharSequenceReader(source), listener); |
| 10259 Token tokenStream = scanner.tokenize(); | 10675 Token tokenStream = scanner.tokenize(); |
| 10260 // | 10676 // |
| 10261 // Parse the source. | 10677 // Parse the source. |
| 10262 // | 10678 // |
| 10263 Parser parser = new Parser(null, listener); | 10679 Parser parser = new Parser(null, listener); |
| 10264 return invokeParserMethodImpl( | 10680 return invokeParserMethodImpl( |
| 10265 parser, methodName, <Object>[tokenStream], tokenStream) as Token; | 10681 parser, methodName, <Object>[tokenStream], tokenStream) as Token; |
| 10266 } | 10682 } |
| 10267 } | 10683 } |
| OLD | NEW |