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

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

Issue 1434863003: initial generic method comment parsing (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library 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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 (obj) => obj is MethodInvocation, 197 (obj) => obj is MethodInvocation,
198 MethodInvocation, 198 MethodInvocation,
199 invocation3.function); 199 invocation3.function);
200 expect(invocation4.methodName.name, "a"); 200 expect(invocation4.methodName.name, "a");
201 expect(invocation4.typeArguments, isNull); 201 expect(invocation4.typeArguments, isNull);
202 ArgumentList argumentList4 = invocation4.argumentList; 202 ArgumentList argumentList4 = invocation4.argumentList;
203 expect(argumentList4, isNotNull); 203 expect(argumentList4, isNotNull);
204 expect(argumentList4.arguments, hasLength(1)); 204 expect(argumentList4.arguments, hasLength(1));
205 } 205 }
206 206
207 void test_assignableExpression_arguments_normal_chain_typeArgumentComments() {
208 enableGenericMethodComments = true;
209 PropertyAccess propertyAccess1 =
210 parseExpression("a/*<E>*/(b)/*<F>*/(c).d/*<G>*/(e).f");
211 expect(propertyAccess1.propertyName.name, "f");
212 //
213 // a<E>(b)<F>(c).d>G?(e)
Leaf 2015/11/11 21:04:05 Did something go wrong at the .d<G> in this commen
Jennifer Messerly 2015/11/11 21:45:31 it was like that in the test I copied from too. Fi
214 //
215 MethodInvocation invocation2 = EngineTestCase.assertInstanceOf(
216 (obj) => obj is MethodInvocation,
217 MethodInvocation,
218 propertyAccess1.target);
219 expect(invocation2.methodName.name, "d");
220 expect(invocation2.typeArguments, isNotNull);
221 ArgumentList argumentList2 = invocation2.argumentList;
222 expect(argumentList2, isNotNull);
223 expect(argumentList2.arguments, hasLength(1));
224 //
225 // a<E>(b)<F>(c)
226 //
227 FunctionExpressionInvocation invocation3 = EngineTestCase.assertInstanceOf(
228 (obj) => obj is FunctionExpressionInvocation,
229 FunctionExpressionInvocation,
230 invocation2.target);
231 expect(invocation3.typeArguments, isNotNull);
232 ArgumentList argumentList3 = invocation3.argumentList;
233 expect(argumentList3, isNotNull);
234 expect(argumentList3.arguments, hasLength(1));
235 //
236 // a(b)
237 //
238 MethodInvocation invocation4 = EngineTestCase.assertInstanceOf(
239 (obj) => obj is MethodInvocation,
240 MethodInvocation,
241 invocation3.function);
242 expect(invocation4.methodName.name, "a");
243 expect(invocation4.typeArguments, isNotNull);
244 ArgumentList argumentList4 = invocation4.argumentList;
245 expect(argumentList4, isNotNull);
246 expect(argumentList4.arguments, hasLength(1));
247 }
248
207 void test_assignableExpression_arguments_normal_chain_typeArguments() { 249 void test_assignableExpression_arguments_normal_chain_typeArguments() {
208 enableGenericMethods = true; 250 enableGenericMethods = true;
209 PropertyAccess propertyAccess1 = parseExpression("a<E>(b)<F>(c).d<G>(e).f"); 251 PropertyAccess propertyAccess1 = parseExpression("a<E>(b)<F>(c).d<G>(e).f");
210 expect(propertyAccess1.propertyName.name, "f"); 252 expect(propertyAccess1.propertyName.name, "f");
211 // 253 //
212 // a<E>(b)<F>(c).d>G?(e) 254 // a<E>(b)<F>(c).d>G?(e)
213 // 255 //
214 MethodInvocation invocation2 = EngineTestCase.assertInstanceOf( 256 MethodInvocation invocation2 = EngineTestCase.assertInstanceOf(
215 (obj) => obj is MethodInvocation, 257 (obj) => obj is MethodInvocation,
216 MethodInvocation, 258 MethodInvocation,
(...skipping 2372 matching lines...) Expand 10 before | Expand all | Expand 10 after
2589 */ 2631 */
2590 static bool parseFunctionBodies = true; 2632 static bool parseFunctionBodies = true;
2591 2633
2592 /** 2634 /**
2593 * A flag indicating whether generic method support should be enabled for a 2635 * A flag indicating whether generic method support should be enabled for a
2594 * specific test. 2636 * specific test.
2595 */ 2637 */
2596 bool enableGenericMethods = false; 2638 bool enableGenericMethods = false;
2597 2639
2598 /** 2640 /**
2641 * Whether generic method comments should be enabled for the test.
2642 */
2643 bool enableGenericMethodComments = false;
2644
2645 /**
2599 * Return a CommentAndMetadata object with the given values that can be used f or testing. 2646 * Return a CommentAndMetadata object with the given values that can be used f or testing.
2600 * 2647 *
2601 * @param comment the comment to be wrapped in the object 2648 * @param comment the comment to be wrapped in the object
2602 * @param annotations the annotations to be wrapped in the object 2649 * @param annotations the annotations to be wrapped in the object
2603 * @return a CommentAndMetadata object that can be used for testing 2650 * @return a CommentAndMetadata object that can be used for testing
2604 */ 2651 */
2605 CommentAndMetadata commentAndMetadata(Comment comment, 2652 CommentAndMetadata commentAndMetadata(Comment comment,
2606 [List<Annotation> annotations]) { 2653 [List<Annotation> annotations]) {
2607 return new CommentAndMetadata(comment, annotations); 2654 return new CommentAndMetadata(comment, annotations);
2608 } 2655 }
(...skipping 22 matching lines...) Expand all
2631 * @throws AssertionFailedError if the result is `null` or the errors produced while 2678 * @throws AssertionFailedError if the result is `null` or the errors produced while
2632 * scanning and parsing the source do not match the expected errors 2679 * scanning and parsing the source do not match the expected errors
2633 */ 2680 */
2634 Object invokeParserMethod(String methodName, List<Object> objects, 2681 Object invokeParserMethod(String methodName, List<Object> objects,
2635 String source, GatheringErrorListener listener) { 2682 String source, GatheringErrorListener listener) {
2636 // 2683 //
2637 // Scan the source. 2684 // Scan the source.
2638 // 2685 //
2639 Scanner scanner = 2686 Scanner scanner =
2640 new Scanner(null, new CharSequenceReader(source), listener); 2687 new Scanner(null, new CharSequenceReader(source), listener);
2688 scanner.parseGenericMethodComments = enableGenericMethodComments;
2641 Token tokenStream = scanner.tokenize(); 2689 Token tokenStream = scanner.tokenize();
2642 listener.setLineInfo(new TestSource(), scanner.lineStarts); 2690 listener.setLineInfo(new TestSource(), scanner.lineStarts);
2643 // 2691 //
2644 // Parse the source. 2692 // Parse the source.
2645 // 2693 //
2646 Parser parser = createParser(listener); 2694 Parser parser = createParser(listener);
2647 parser.parseGenericMethods = enableGenericMethods; 2695 parser.parseGenericMethods = enableGenericMethods;
2696 parser.parseGenericMethodComments = enableGenericMethodComments;
2648 parser.parseFunctionBodies = parseFunctionBodies; 2697 parser.parseFunctionBodies = parseFunctionBodies;
2649 Object result = 2698 Object result =
2650 invokeParserMethodImpl(parser, methodName, objects, tokenStream); 2699 invokeParserMethodImpl(parser, methodName, objects, tokenStream);
2651 // 2700 //
2652 // Partially test the results. 2701 // Partially test the results.
2653 // 2702 //
2654 if (!listener.hasErrors) { 2703 if (!listener.hasErrors) {
2655 expect(result, isNotNull); 2704 expect(result, isNotNull);
2656 } 2705 }
2657 return result; 2706 return result;
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
2765 * @param errorCodes the error codes of the errors that are expected to be fou nd 2814 * @param errorCodes the error codes of the errors that are expected to be fou nd
2766 * @return the expression that was parsed 2815 * @return the expression that was parsed
2767 * @throws Exception if the source could not be parsed, if the compilation err ors in the source do 2816 * @throws Exception if the source could not be parsed, if the compilation err ors in the source do
2768 * not match those that are expected, or if the result would have be en `null` 2817 * not match those that are expected, or if the result would have be en `null`
2769 */ 2818 */
2770 Expression parseExpression(String source, 2819 Expression parseExpression(String source,
2771 [List<ErrorCode> errorCodes = ErrorCode.EMPTY_LIST]) { 2820 [List<ErrorCode> errorCodes = ErrorCode.EMPTY_LIST]) {
2772 GatheringErrorListener listener = new GatheringErrorListener(); 2821 GatheringErrorListener listener = new GatheringErrorListener();
2773 Scanner scanner = 2822 Scanner scanner =
2774 new Scanner(null, new CharSequenceReader(source), listener); 2823 new Scanner(null, new CharSequenceReader(source), listener);
2824 scanner.parseGenericMethodComments = enableGenericMethodComments;
2775 listener.setLineInfo(new TestSource(), scanner.lineStarts); 2825 listener.setLineInfo(new TestSource(), scanner.lineStarts);
2776 Token token = scanner.tokenize(); 2826 Token token = scanner.tokenize();
2777 Parser parser = createParser(listener); 2827 Parser parser = createParser(listener);
2778 parser.parseGenericMethods = enableGenericMethods; 2828 parser.parseGenericMethods = enableGenericMethods;
2829 parser.parseGenericMethodComments = enableGenericMethodComments;
2779 Expression expression = parser.parseExpression(token); 2830 Expression expression = parser.parseExpression(token);
2780 expect(expression, isNotNull); 2831 expect(expression, isNotNull);
2781 listener.assertErrorsWithCodes(errorCodes); 2832 listener.assertErrorsWithCodes(errorCodes);
2782 return expression; 2833 return expression;
2783 } 2834 }
2784 2835
2785 @override 2836 @override
2786 void setUp() { 2837 void setUp() {
2787 super.setUp(); 2838 super.setUp();
2788 parseFunctionBodies = true; 2839 parseFunctionBodies = true;
(...skipping 2314 matching lines...) Expand 10 before | Expand all | Expand 10 after
5103 propertyAccess.target as FunctionExpressionInvocation; 5154 propertyAccess.target as FunctionExpressionInvocation;
5104 expect(invocation.function, isNotNull); 5155 expect(invocation.function, isNotNull);
5105 expect(invocation.typeArguments, isNull); 5156 expect(invocation.typeArguments, isNull);
5106 ArgumentList argumentList = invocation.argumentList; 5157 ArgumentList argumentList = invocation.argumentList;
5107 expect(argumentList, isNotNull); 5158 expect(argumentList, isNotNull);
5108 expect(argumentList.arguments, hasLength(1)); 5159 expect(argumentList.arguments, hasLength(1));
5109 expect(propertyAccess.operator, isNotNull); 5160 expect(propertyAccess.operator, isNotNull);
5110 expect(propertyAccess.propertyName, isNotNull); 5161 expect(propertyAccess.propertyName, isNotNull);
5111 } 5162 }
5112 5163
5164 void test_parseAssignableExpression_expression_args_dot_typeParameterComments( ) {
5165 enableGenericMethodComments = true;
5166 PropertyAccess propertyAccess =
5167 parse("parseAssignableExpression", <Object>[false], "(x)/*<F>*/(y).z");
5168 FunctionExpressionInvocation invocation =
5169 propertyAccess.target as FunctionExpressionInvocation;
5170 expect(invocation.function, isNotNull);
5171 expect(invocation.typeArguments, isNotNull);
5172 ArgumentList argumentList = invocation.argumentList;
5173 expect(argumentList, isNotNull);
5174 expect(argumentList.arguments, hasLength(1));
5175 expect(propertyAccess.operator, isNotNull);
5176 expect(propertyAccess.propertyName, isNotNull);
5177 }
5178
5113 void test_parseAssignableExpression_expression_args_dot_typeParameters() { 5179 void test_parseAssignableExpression_expression_args_dot_typeParameters() {
5114 enableGenericMethods = true; 5180 enableGenericMethods = true;
5115 PropertyAccess propertyAccess = 5181 PropertyAccess propertyAccess =
5116 parse("parseAssignableExpression", <Object>[false], "(x)<F>(y).z"); 5182 parse("parseAssignableExpression", <Object>[false], "(x)<F>(y).z");
5117 FunctionExpressionInvocation invocation = 5183 FunctionExpressionInvocation invocation =
5118 propertyAccess.target as FunctionExpressionInvocation; 5184 propertyAccess.target as FunctionExpressionInvocation;
5119 expect(invocation.function, isNotNull); 5185 expect(invocation.function, isNotNull);
5120 expect(invocation.typeArguments, isNotNull); 5186 expect(invocation.typeArguments, isNotNull);
5121 ArgumentList argumentList = invocation.argumentList; 5187 ArgumentList argumentList = invocation.argumentList;
5122 expect(argumentList, isNotNull); 5188 expect(argumentList, isNotNull);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
5162 MethodInvocation invocation = propertyAccess.target as MethodInvocation; 5228 MethodInvocation invocation = propertyAccess.target as MethodInvocation;
5163 expect(invocation.methodName.name, "x"); 5229 expect(invocation.methodName.name, "x");
5164 expect(invocation.typeArguments, isNull); 5230 expect(invocation.typeArguments, isNull);
5165 ArgumentList argumentList = invocation.argumentList; 5231 ArgumentList argumentList = invocation.argumentList;
5166 expect(argumentList, isNotNull); 5232 expect(argumentList, isNotNull);
5167 expect(argumentList.arguments, hasLength(1)); 5233 expect(argumentList.arguments, hasLength(1));
5168 expect(propertyAccess.operator, isNotNull); 5234 expect(propertyAccess.operator, isNotNull);
5169 expect(propertyAccess.propertyName, isNotNull); 5235 expect(propertyAccess.propertyName, isNotNull);
5170 } 5236 }
5171 5237
5238 void test_parseAssignableExpression_identifier_args_dot_typeParameterComments( ) {
5239 enableGenericMethodComments = true;
5240 PropertyAccess propertyAccess =
5241 parse("parseAssignableExpression", <Object>[false], "x/*<E>*/(y).z");
5242 MethodInvocation invocation = propertyAccess.target as MethodInvocation;
5243 expect(invocation.methodName.name, "x");
5244 expect(invocation.typeArguments, isNotNull);
5245 ArgumentList argumentList = invocation.argumentList;
5246 expect(argumentList, isNotNull);
5247 expect(argumentList.arguments, hasLength(1));
5248 expect(propertyAccess.operator, isNotNull);
5249 expect(propertyAccess.propertyName, isNotNull);
5250 }
5251
5172 void test_parseAssignableExpression_identifier_args_dot_typeParameters() { 5252 void test_parseAssignableExpression_identifier_args_dot_typeParameters() {
5173 enableGenericMethods = true; 5253 enableGenericMethods = true;
5174 PropertyAccess propertyAccess = 5254 PropertyAccess propertyAccess =
5175 parse("parseAssignableExpression", <Object>[false], "x<E>(y).z"); 5255 parse("parseAssignableExpression", <Object>[false], "x<E>(y).z");
5176 MethodInvocation invocation = propertyAccess.target as MethodInvocation; 5256 MethodInvocation invocation = propertyAccess.target as MethodInvocation;
5177 expect(invocation.methodName.name, "x"); 5257 expect(invocation.methodName.name, "x");
5178 expect(invocation.typeArguments, isNotNull); 5258 expect(invocation.typeArguments, isNotNull);
5179 ArgumentList argumentList = invocation.argumentList; 5259 ArgumentList argumentList = invocation.argumentList;
5180 expect(argumentList, isNotNull); 5260 expect(argumentList, isNotNull);
5181 expect(argumentList.arguments, hasLength(1)); 5261 expect(argumentList.arguments, hasLength(1));
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
5384 5464
5385 void test_parseCascadeSection_ia() { 5465 void test_parseCascadeSection_ia() {
5386 FunctionExpressionInvocation section = 5466 FunctionExpressionInvocation section =
5387 parse4("parseCascadeSection", "..[i](b)"); 5467 parse4("parseCascadeSection", "..[i](b)");
5388 EngineTestCase.assertInstanceOf( 5468 EngineTestCase.assertInstanceOf(
5389 (obj) => obj is IndexExpression, IndexExpression, section.function); 5469 (obj) => obj is IndexExpression, IndexExpression, section.function);
5390 expect(section.typeArguments, isNull); 5470 expect(section.typeArguments, isNull);
5391 expect(section.argumentList, isNotNull); 5471 expect(section.argumentList, isNotNull);
5392 } 5472 }
5393 5473
5474 void test_parseCascadeSection_ia_typeArgumentComments() {
5475 enableGenericMethodComments = true;
5476 FunctionExpressionInvocation section =
5477 parse4("parseCascadeSection", "..[i]/*<E>*/(b)");
5478 EngineTestCase.assertInstanceOf(
5479 (obj) => obj is IndexExpression, IndexExpression, section.function);
5480 expect(section.typeArguments, isNotNull);
5481 expect(section.argumentList, isNotNull);
5482 }
5483
5394 void test_parseCascadeSection_ia_typeArguments() { 5484 void test_parseCascadeSection_ia_typeArguments() {
5395 enableGenericMethods = true; 5485 enableGenericMethods = true;
5396 FunctionExpressionInvocation section = 5486 FunctionExpressionInvocation section =
5397 parse4("parseCascadeSection", "..[i]<E>(b)"); 5487 parse4("parseCascadeSection", "..[i]<E>(b)");
5398 EngineTestCase.assertInstanceOf( 5488 EngineTestCase.assertInstanceOf(
5399 (obj) => obj is IndexExpression, IndexExpression, section.function); 5489 (obj) => obj is IndexExpression, IndexExpression, section.function);
5400 expect(section.typeArguments, isNotNull); 5490 expect(section.typeArguments, isNotNull);
5401 expect(section.argumentList, isNotNull); 5491 expect(section.argumentList, isNotNull);
5402 } 5492 }
5403 5493
5404 void test_parseCascadeSection_ii() { 5494 void test_parseCascadeSection_ii() {
5405 MethodInvocation section = parse4("parseCascadeSection", "..a(b).c(d)"); 5495 MethodInvocation section = parse4("parseCascadeSection", "..a(b).c(d)");
5406 EngineTestCase.assertInstanceOf( 5496 EngineTestCase.assertInstanceOf(
5407 (obj) => obj is MethodInvocation, MethodInvocation, section.target); 5497 (obj) => obj is MethodInvocation, MethodInvocation, section.target);
5408 expect(section.operator, isNotNull); 5498 expect(section.operator, isNotNull);
5409 expect(section.methodName, isNotNull); 5499 expect(section.methodName, isNotNull);
5410 expect(section.typeArguments, isNull); 5500 expect(section.typeArguments, isNull);
5411 expect(section.argumentList, isNotNull); 5501 expect(section.argumentList, isNotNull);
5412 expect(section.argumentList.arguments, hasLength(1)); 5502 expect(section.argumentList.arguments, hasLength(1));
5413 } 5503 }
5414 5504
5505 void test_parseCascadeSection_ii_typeArgumentComments() {
5506 enableGenericMethodComments = true;
5507 MethodInvocation section =
5508 parse4("parseCascadeSection", "..a/*<E>*/(b).c/*<F>*/(d)");
5509 EngineTestCase.assertInstanceOf(
5510 (obj) => obj is MethodInvocation, MethodInvocation, section.target);
5511 expect(section.operator, isNotNull);
5512 expect(section.methodName, isNotNull);
5513 expect(section.typeArguments, isNotNull);
5514 expect(section.argumentList, isNotNull);
5515 expect(section.argumentList.arguments, hasLength(1));
5516 }
5517
5415 void test_parseCascadeSection_ii_typeArguments() { 5518 void test_parseCascadeSection_ii_typeArguments() {
5416 enableGenericMethods = true; 5519 enableGenericMethods = true;
5417 MethodInvocation section = 5520 MethodInvocation section =
5418 parse4("parseCascadeSection", "..a<E>(b).c<F>(d)"); 5521 parse4("parseCascadeSection", "..a<E>(b).c<F>(d)");
5419 EngineTestCase.assertInstanceOf( 5522 EngineTestCase.assertInstanceOf(
5420 (obj) => obj is MethodInvocation, MethodInvocation, section.target); 5523 (obj) => obj is MethodInvocation, MethodInvocation, section.target);
5421 expect(section.operator, isNotNull); 5524 expect(section.operator, isNotNull);
5422 expect(section.methodName, isNotNull); 5525 expect(section.methodName, isNotNull);
5423 expect(section.typeArguments, isNotNull); 5526 expect(section.typeArguments, isNotNull);
5424 expect(section.argumentList, isNotNull); 5527 expect(section.argumentList, isNotNull);
(...skipping 18 matching lines...) Expand all
5443 void test_parseCascadeSection_p_assign_withCascade() { 5546 void test_parseCascadeSection_p_assign_withCascade() {
5444 AssignmentExpression section = 5547 AssignmentExpression section =
5445 parse4("parseCascadeSection", "..a = 3..m()"); 5548 parse4("parseCascadeSection", "..a = 3..m()");
5446 expect(section.leftHandSide, isNotNull); 5549 expect(section.leftHandSide, isNotNull);
5447 expect(section.operator, isNotNull); 5550 expect(section.operator, isNotNull);
5448 Expression rhs = section.rightHandSide; 5551 Expression rhs = section.rightHandSide;
5449 EngineTestCase.assertInstanceOf( 5552 EngineTestCase.assertInstanceOf(
5450 (obj) => obj is IntegerLiteral, IntegerLiteral, rhs); 5553 (obj) => obj is IntegerLiteral, IntegerLiteral, rhs);
5451 } 5554 }
5452 5555
5556 void test_parseCascadeSection_p_assign_withCascade_typeArgumentComments() {
5557 enableGenericMethodComments = true;
5558 AssignmentExpression section =
5559 parse4("parseCascadeSection", "..a = 3..m/*<E>*/()");
5560 expect(section.leftHandSide, isNotNull);
5561 expect(section.operator, isNotNull);
5562 Expression rhs = section.rightHandSide;
5563 EngineTestCase.assertInstanceOf(
5564 (obj) => obj is IntegerLiteral, IntegerLiteral, rhs);
5565 }
5566
5453 void test_parseCascadeSection_p_assign_withCascade_typeArguments() { 5567 void test_parseCascadeSection_p_assign_withCascade_typeArguments() {
5454 enableGenericMethods = true; 5568 enableGenericMethods = true;
5455 AssignmentExpression section = 5569 AssignmentExpression section =
5456 parse4("parseCascadeSection", "..a = 3..m<E>()"); 5570 parse4("parseCascadeSection", "..a = 3..m<E>()");
5457 expect(section.leftHandSide, isNotNull); 5571 expect(section.leftHandSide, isNotNull);
5458 expect(section.operator, isNotNull); 5572 expect(section.operator, isNotNull);
5459 Expression rhs = section.rightHandSide; 5573 Expression rhs = section.rightHandSide;
5460 EngineTestCase.assertInstanceOf( 5574 EngineTestCase.assertInstanceOf(
5461 (obj) => obj is IntegerLiteral, IntegerLiteral, rhs); 5575 (obj) => obj is IntegerLiteral, IntegerLiteral, rhs);
5462 } 5576 }
5463 5577
5464 void test_parseCascadeSection_p_builtIn() { 5578 void test_parseCascadeSection_p_builtIn() {
5465 PropertyAccess section = parse4("parseCascadeSection", "..as"); 5579 PropertyAccess section = parse4("parseCascadeSection", "..as");
5466 expect(section.target, isNull); 5580 expect(section.target, isNull);
5467 expect(section.operator, isNotNull); 5581 expect(section.operator, isNotNull);
5468 expect(section.propertyName, isNotNull); 5582 expect(section.propertyName, isNotNull);
5469 } 5583 }
5470 5584
5471 void test_parseCascadeSection_pa() { 5585 void test_parseCascadeSection_pa() {
5472 MethodInvocation section = parse4("parseCascadeSection", "..a(b)"); 5586 MethodInvocation section = parse4("parseCascadeSection", "..a(b)");
5473 expect(section.target, isNull); 5587 expect(section.target, isNull);
5474 expect(section.operator, isNotNull); 5588 expect(section.operator, isNotNull);
5475 expect(section.methodName, isNotNull); 5589 expect(section.methodName, isNotNull);
5476 expect(section.typeArguments, isNull); 5590 expect(section.typeArguments, isNull);
5477 expect(section.argumentList, isNotNull); 5591 expect(section.argumentList, isNotNull);
5478 expect(section.argumentList.arguments, hasLength(1)); 5592 expect(section.argumentList.arguments, hasLength(1));
5479 } 5593 }
5480 5594
5595 void test_parseCascadeSection_pa_typeArgumentComments() {
5596 enableGenericMethodComments = true;
5597 MethodInvocation section = parse4("parseCascadeSection", "..a/*<E>*/(b)");
5598 expect(section.target, isNull);
5599 expect(section.operator, isNotNull);
5600 expect(section.methodName, isNotNull);
5601 expect(section.typeArguments, isNotNull);
5602 expect(section.argumentList, isNotNull);
5603 expect(section.argumentList.arguments, hasLength(1));
5604 }
5605
5481 void test_parseCascadeSection_pa_typeArguments() { 5606 void test_parseCascadeSection_pa_typeArguments() {
5482 enableGenericMethods = true; 5607 enableGenericMethods = true;
5483 MethodInvocation section = parse4("parseCascadeSection", "..a<E>(b)"); 5608 MethodInvocation section = parse4("parseCascadeSection", "..a<E>(b)");
5484 expect(section.target, isNull); 5609 expect(section.target, isNull);
5485 expect(section.operator, isNotNull); 5610 expect(section.operator, isNotNull);
5486 expect(section.methodName, isNotNull); 5611 expect(section.methodName, isNotNull);
5487 expect(section.typeArguments, isNotNull); 5612 expect(section.typeArguments, isNotNull);
5488 expect(section.argumentList, isNotNull); 5613 expect(section.argumentList, isNotNull);
5489 expect(section.argumentList.arguments, hasLength(1)); 5614 expect(section.argumentList.arguments, hasLength(1));
5490 } 5615 }
5491 5616
5492 void test_parseCascadeSection_paa() { 5617 void test_parseCascadeSection_paa() {
5493 FunctionExpressionInvocation section = 5618 FunctionExpressionInvocation section =
5494 parse4("parseCascadeSection", "..a(b)(c)"); 5619 parse4("parseCascadeSection", "..a(b)(c)");
5495 EngineTestCase.assertInstanceOf( 5620 EngineTestCase.assertInstanceOf(
5496 (obj) => obj is MethodInvocation, MethodInvocation, section.function); 5621 (obj) => obj is MethodInvocation, MethodInvocation, section.function);
5497 expect(section.typeArguments, isNull); 5622 expect(section.typeArguments, isNull);
5498 expect(section.argumentList, isNotNull); 5623 expect(section.argumentList, isNotNull);
5499 expect(section.argumentList.arguments, hasLength(1)); 5624 expect(section.argumentList.arguments, hasLength(1));
5500 } 5625 }
5501 5626
5627 void test_parseCascadeSection_paa_typeArgumentComments() {
5628 enableGenericMethodComments = true;
5629 FunctionExpressionInvocation section =
5630 parse4("parseCascadeSection", "..a/*<E>*/(b)/*<F>*/(c)");
5631 EngineTestCase.assertInstanceOf(
5632 (obj) => obj is MethodInvocation, MethodInvocation, section.function);
5633 expect(section.typeArguments, isNotNull);
5634 expect(section.argumentList, isNotNull);
5635 expect(section.argumentList.arguments, hasLength(1));
5636 }
5637
5502 void test_parseCascadeSection_paa_typeArguments() { 5638 void test_parseCascadeSection_paa_typeArguments() {
5503 enableGenericMethods = true; 5639 enableGenericMethods = true;
5504 FunctionExpressionInvocation section = 5640 FunctionExpressionInvocation section =
5505 parse4("parseCascadeSection", "..a<E>(b)<F>(c)"); 5641 parse4("parseCascadeSection", "..a<E>(b)<F>(c)");
5506 EngineTestCase.assertInstanceOf( 5642 EngineTestCase.assertInstanceOf(
5507 (obj) => obj is MethodInvocation, MethodInvocation, section.function); 5643 (obj) => obj is MethodInvocation, MethodInvocation, section.function);
5508 expect(section.typeArguments, isNotNull); 5644 expect(section.typeArguments, isNotNull);
5509 expect(section.argumentList, isNotNull); 5645 expect(section.argumentList, isNotNull);
5510 expect(section.argumentList.arguments, hasLength(1)); 5646 expect(section.argumentList.arguments, hasLength(1));
5511 } 5647 }
5512 5648
5513 void test_parseCascadeSection_paapaa() { 5649 void test_parseCascadeSection_paapaa() {
5514 FunctionExpressionInvocation section = 5650 FunctionExpressionInvocation section =
5515 parse4("parseCascadeSection", "..a(b)(c).d(e)(f)"); 5651 parse4("parseCascadeSection", "..a(b)(c).d(e)(f)");
5516 EngineTestCase.assertInstanceOf( 5652 EngineTestCase.assertInstanceOf(
5517 (obj) => obj is MethodInvocation, MethodInvocation, section.function); 5653 (obj) => obj is MethodInvocation, MethodInvocation, section.function);
5518 expect(section.typeArguments, isNull); 5654 expect(section.typeArguments, isNull);
5519 expect(section.argumentList, isNotNull); 5655 expect(section.argumentList, isNotNull);
5520 expect(section.argumentList.arguments, hasLength(1)); 5656 expect(section.argumentList.arguments, hasLength(1));
5521 } 5657 }
5522 5658
5659 void test_parseCascadeSection_paapaa_typeArgumentComments() {
5660 enableGenericMethodComments = true;
5661 FunctionExpressionInvocation section = parse4(
5662 "parseCascadeSection", "..a/*<E>*/(b)/*<F>*/(c).d/*<G>*/(e)/*<H>*/(f)");
5663 EngineTestCase.assertInstanceOf(
5664 (obj) => obj is MethodInvocation, MethodInvocation, section.function);
5665 expect(section.typeArguments, isNotNull);
5666 expect(section.argumentList, isNotNull);
5667 expect(section.argumentList.arguments, hasLength(1));
5668 }
5669
5523 void test_parseCascadeSection_paapaa_typeArguments() { 5670 void test_parseCascadeSection_paapaa_typeArguments() {
5524 enableGenericMethods = true; 5671 enableGenericMethods = true;
5525 FunctionExpressionInvocation section = 5672 FunctionExpressionInvocation section =
5526 parse4("parseCascadeSection", "..a<E>(b)<F>(c).d<G>(e)<H>(f)"); 5673 parse4("parseCascadeSection", "..a<E>(b)<F>(c).d<G>(e)<H>(f)");
5527 EngineTestCase.assertInstanceOf( 5674 EngineTestCase.assertInstanceOf(
5528 (obj) => obj is MethodInvocation, MethodInvocation, section.function); 5675 (obj) => obj is MethodInvocation, MethodInvocation, section.function);
5529 expect(section.typeArguments, isNotNull); 5676 expect(section.typeArguments, isNotNull);
5530 expect(section.argumentList, isNotNull); 5677 expect(section.argumentList, isNotNull);
5531 expect(section.argumentList.arguments, hasLength(1)); 5678 expect(section.argumentList.arguments, hasLength(1));
5532 } 5679 }
5533 5680
5534 void test_parseCascadeSection_pap() { 5681 void test_parseCascadeSection_pap() {
5535 PropertyAccess section = parse4("parseCascadeSection", "..a(b).c"); 5682 PropertyAccess section = parse4("parseCascadeSection", "..a(b).c");
5536 expect(section.target, isNotNull); 5683 expect(section.target, isNotNull);
5537 expect(section.operator, isNotNull); 5684 expect(section.operator, isNotNull);
5538 expect(section.propertyName, isNotNull); 5685 expect(section.propertyName, isNotNull);
5539 } 5686 }
5540 5687
5688 void test_parseCascadeSection_pap_typeArgumentComments() {
5689 enableGenericMethodComments = true;
5690 PropertyAccess section = parse4("parseCascadeSection", "..a/*<E>*/(b).c");
5691 expect(section.target, isNotNull);
5692 expect(section.operator, isNotNull);
5693 expect(section.propertyName, isNotNull);
5694 }
5695
5541 void test_parseCascadeSection_pap_typeArguments() { 5696 void test_parseCascadeSection_pap_typeArguments() {
5542 enableGenericMethods = true; 5697 enableGenericMethods = true;
5543 PropertyAccess section = parse4("parseCascadeSection", "..a<E>(b).c"); 5698 PropertyAccess section = parse4("parseCascadeSection", "..a<E>(b).c");
5544 expect(section.target, isNotNull); 5699 expect(section.target, isNotNull);
5545 expect(section.operator, isNotNull); 5700 expect(section.operator, isNotNull);
5546 expect(section.propertyName, isNotNull); 5701 expect(section.propertyName, isNotNull);
5547 } 5702 }
5548 5703
5549 void test_parseClassDeclaration_abstract() { 5704 void test_parseClassDeclaration_abstract() {
5550 ClassDeclaration declaration = parse( 5705 ClassDeclaration declaration = parse(
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
5860 expect(method.externalKeyword, isNotNull); 6015 expect(method.externalKeyword, isNotNull);
5861 expect(method.modifierKeyword, isNull); 6016 expect(method.modifierKeyword, isNull);
5862 expect(method.name, isNotNull); 6017 expect(method.name, isNotNull);
5863 expect(method.operatorKeyword, isNull); 6018 expect(method.operatorKeyword, isNull);
5864 expect(method.typeParameters, isNull); 6019 expect(method.typeParameters, isNull);
5865 expect(method.parameters, isNotNull); 6020 expect(method.parameters, isNotNull);
5866 expect(method.propertyKeyword, isNull); 6021 expect(method.propertyKeyword, isNull);
5867 expect(method.returnType, isNotNull); 6022 expect(method.returnType, isNotNull);
5868 } 6023 }
5869 6024
6025 void test_parseClassMember_method_generic_comment_noReturnType() {
6026 enableGenericMethodComments = true;
6027 MethodDeclaration method =
6028 parse("parseClassMember", <Object>["C"], "m/*<T>*/() {}");
6029 expect(method.documentationComment, isNull);
6030 expect(method.externalKeyword, isNull);
6031 expect(method.modifierKeyword, isNull);
6032 expect(method.propertyKeyword, isNull);
6033 expect(method.returnType, isNull);
6034 expect(method.name, isNotNull);
6035 expect(method.operatorKeyword, isNull);
6036 expect(method.typeParameters, isNotNull);
6037 expect(method.parameters, isNotNull);
6038 expect(method.body, isNotNull);
6039 }
6040
6041 void test_parseClassMember_method_generic_comment_returnType() {
6042 enableGenericMethodComments = true;
6043 MethodDeclaration method =
6044 parse("parseClassMember", <Object>["C"], "dynamic/*=T*/ m/*<T>*/() {}");
6045 expect(method.documentationComment, isNull);
6046 expect(method.externalKeyword, isNull);
6047 expect(method.modifierKeyword, isNull);
6048 expect(method.propertyKeyword, isNull);
6049 expect(method.returnType, isNotNull);
Leaf 2015/11/11 21:04:05 Maybe also expect(method.returnType.name.name, "T"
Jennifer Messerly 2015/11/11 21:45:31 yup, added in the latest. The /*=T*/ was actually
6050 expect(method.name, isNotNull);
6051 expect(method.operatorKeyword, isNull);
6052 expect(method.typeParameters, isNotNull);
6053 expect(method.parameters, isNotNull);
6054 expect(method.body, isNotNull);
6055 }
6056
6057 void test_parseClassMember_method_generic_comment_returnType_bound() {
6058 enableGenericMethodComments = true;
6059 MethodDeclaration method = parse("parseClassMember", <Object>["C"],
6060 "num/*=T*/ m/*<T extends num>*/() {}");
6061 expect(method.documentationComment, isNull);
6062 expect(method.externalKeyword, isNull);
6063 expect(method.modifierKeyword, isNull);
6064 expect(method.propertyKeyword, isNull);
6065 expect(method.returnType, isNotNull);
6066 expect(method.name, isNotNull);
6067 expect(method.operatorKeyword, isNull);
6068 expect(method.typeParameters, isNotNull);
6069 expect(method.parameters, isNotNull);
6070 expect(method.body, isNotNull);
6071 }
6072
6073 void test_parseClassMember_method_generic_comment_void() {
6074 enableGenericMethodComments = true;
6075 MethodDeclaration method =
6076 parse("parseClassMember", <Object>["C"], "void m/*<T>*/() {}");
6077 expect(method.documentationComment, isNull);
6078 expect(method.externalKeyword, isNull);
6079 expect(method.modifierKeyword, isNull);
6080 expect(method.propertyKeyword, isNull);
6081 expect(method.returnType, isNotNull);
6082 expect(method.name, isNotNull);
6083 expect(method.operatorKeyword, isNull);
6084 expect(method.typeParameters, isNotNull);
6085 expect(method.parameters, isNotNull);
6086 expect(method.body, isNotNull);
6087 }
6088
5870 void test_parseClassMember_method_generic_noReturnType() { 6089 void test_parseClassMember_method_generic_noReturnType() {
5871 enableGenericMethods = true; 6090 enableGenericMethods = true;
5872 MethodDeclaration method = 6091 MethodDeclaration method =
5873 parse("parseClassMember", <Object>["C"], "m<T>() {}"); 6092 parse("parseClassMember", <Object>["C"], "m<T>() {}");
5874 expect(method.documentationComment, isNull); 6093 expect(method.documentationComment, isNull);
5875 expect(method.externalKeyword, isNull); 6094 expect(method.externalKeyword, isNull);
5876 expect(method.modifierKeyword, isNull); 6095 expect(method.modifierKeyword, isNull);
5877 expect(method.propertyKeyword, isNull); 6096 expect(method.propertyKeyword, isNull);
5878 expect(method.returnType, isNull); 6097 expect(method.returnType, isNull);
5879 expect(method.name, isNotNull); 6098 expect(method.name, isNotNull);
(...skipping 1452 matching lines...) Expand 10 before | Expand all | Expand 10 after
7332 } 7551 }
7333 7552
7334 void test_parseExpression_superMethodInvocation() { 7553 void test_parseExpression_superMethodInvocation() {
7335 MethodInvocation invocation = parse4("parseExpression", "super.m()"); 7554 MethodInvocation invocation = parse4("parseExpression", "super.m()");
7336 expect(invocation.target, isNotNull); 7555 expect(invocation.target, isNotNull);
7337 expect(invocation.methodName, isNotNull); 7556 expect(invocation.methodName, isNotNull);
7338 expect(invocation.typeArguments, isNull); 7557 expect(invocation.typeArguments, isNull);
7339 expect(invocation.argumentList, isNotNull); 7558 expect(invocation.argumentList, isNotNull);
7340 } 7559 }
7341 7560
7561 void test_parseExpression_superMethodInvocation_typeArgumentComments() {
7562 enableGenericMethodComments = true;
7563 MethodInvocation invocation = parse4("parseExpression", "super.m/*<E>*/()");
7564 expect(invocation.target, isNotNull);
7565 expect(invocation.methodName, isNotNull);
7566 expect(invocation.typeArguments, isNotNull);
7567 expect(invocation.argumentList, isNotNull);
7568 }
7569
7342 void test_parseExpression_superMethodInvocation_typeArguments() { 7570 void test_parseExpression_superMethodInvocation_typeArguments() {
7343 enableGenericMethods = true; 7571 enableGenericMethods = true;
7344 MethodInvocation invocation = parse4("parseExpression", "super.m<E>()"); 7572 MethodInvocation invocation = parse4("parseExpression", "super.m<E>()");
7345 expect(invocation.target, isNotNull); 7573 expect(invocation.target, isNotNull);
7346 expect(invocation.methodName, isNotNull); 7574 expect(invocation.methodName, isNotNull);
7347 expect(invocation.typeArguments, isNotNull); 7575 expect(invocation.typeArguments, isNotNull);
7348 expect(invocation.argumentList, isNotNull); 7576 expect(invocation.argumentList, isNotNull);
7349 } 7577 }
7350 7578
7351 void test_parseExpressionList_multiple() { 7579 void test_parseExpressionList_multiple() {
(...skipping 27 matching lines...) Expand all
7379 7607
7380 void test_parseExpressionWithoutCascade_superMethodInvocation() { 7608 void test_parseExpressionWithoutCascade_superMethodInvocation() {
7381 MethodInvocation invocation = 7609 MethodInvocation invocation =
7382 parse4("parseExpressionWithoutCascade", "super.m()"); 7610 parse4("parseExpressionWithoutCascade", "super.m()");
7383 expect(invocation.target, isNotNull); 7611 expect(invocation.target, isNotNull);
7384 expect(invocation.methodName, isNotNull); 7612 expect(invocation.methodName, isNotNull);
7385 expect(invocation.typeArguments, isNull); 7613 expect(invocation.typeArguments, isNull);
7386 expect(invocation.argumentList, isNotNull); 7614 expect(invocation.argumentList, isNotNull);
7387 } 7615 }
7388 7616
7617 void test_parseExpressionWithoutCascade_superMethodInvocation_typeArgumentComm ents() {
7618 enableGenericMethodComments = true;
7619 MethodInvocation invocation =
7620 parse4("parseExpressionWithoutCascade", "super.m/*<E>*/()");
7621 expect(invocation.target, isNotNull);
7622 expect(invocation.methodName, isNotNull);
7623 expect(invocation.typeArguments, isNotNull);
7624 expect(invocation.argumentList, isNotNull);
7625 }
7626
7389 void test_parseExpressionWithoutCascade_superMethodInvocation_typeArguments() { 7627 void test_parseExpressionWithoutCascade_superMethodInvocation_typeArguments() {
7390 enableGenericMethods = true; 7628 enableGenericMethods = true;
7391 MethodInvocation invocation = 7629 MethodInvocation invocation =
7392 parse4("parseExpressionWithoutCascade", "super.m<E>()"); 7630 parse4("parseExpressionWithoutCascade", "super.m<E>()");
7393 expect(invocation.target, isNotNull); 7631 expect(invocation.target, isNotNull);
7394 expect(invocation.methodName, isNotNull); 7632 expect(invocation.methodName, isNotNull);
7395 expect(invocation.typeArguments, isNotNull); 7633 expect(invocation.typeArguments, isNotNull);
7396 expect(invocation.argumentList, isNotNull); 7634 expect(invocation.argumentList, isNotNull);
7397 } 7635 }
7398 7636
(...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after
8141 expect(declaration.returnType, returnType); 8379 expect(declaration.returnType, returnType);
8142 expect(declaration.name, isNotNull); 8380 expect(declaration.name, isNotNull);
8143 FunctionExpression expression = declaration.functionExpression; 8381 FunctionExpression expression = declaration.functionExpression;
8144 expect(expression, isNotNull); 8382 expect(expression, isNotNull);
8145 expect(expression.body, isNotNull); 8383 expect(expression.body, isNotNull);
8146 expect(expression.typeParameters, isNotNull); 8384 expect(expression.typeParameters, isNotNull);
8147 expect(expression.parameters, isNotNull); 8385 expect(expression.parameters, isNotNull);
8148 expect(declaration.propertyKeyword, isNull); 8386 expect(declaration.propertyKeyword, isNull);
8149 } 8387 }
8150 8388
8389 void test_parseFunctionDeclaration_functionWithTypeParameters_comment() {
8390 enableGenericMethodComments = true;
8391 Comment comment = Comment.createDocumentationComment(new List<Token>(0));
8392 TypeName returnType = new TypeName(new SimpleIdentifier(null), null);
8393 FunctionDeclaration declaration = parse(
8394 "parseFunctionDeclaration",
8395 <Object>[commentAndMetadata(comment), null, returnType],
8396 "f/*<E>*/() {}");
8397 expect(declaration.documentationComment, comment);
8398 expect(declaration.returnType, returnType);
8399 expect(declaration.name, isNotNull);
8400 FunctionExpression expression = declaration.functionExpression;
8401 expect(expression, isNotNull);
8402 expect(expression.body, isNotNull);
8403 expect(expression.typeParameters, isNotNull);
8404 expect(expression.parameters, isNotNull);
8405 expect(declaration.propertyKeyword, isNull);
8406 }
8407
8151 void test_parseFunctionDeclaration_getter() { 8408 void test_parseFunctionDeclaration_getter() {
8152 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); 8409 Comment comment = Comment.createDocumentationComment(new List<Token>(0));
8153 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); 8410 TypeName returnType = new TypeName(new SimpleIdentifier(null), null);
8154 FunctionDeclaration declaration = parse("parseFunctionDeclaration", 8411 FunctionDeclaration declaration = parse("parseFunctionDeclaration",
8155 <Object>[commentAndMetadata(comment), null, returnType], "get p => 0;"); 8412 <Object>[commentAndMetadata(comment), null, returnType], "get p => 0;");
8156 expect(declaration.documentationComment, comment); 8413 expect(declaration.documentationComment, comment);
8157 expect(declaration.returnType, returnType); 8414 expect(declaration.returnType, returnType);
8158 expect(declaration.name, isNotNull); 8415 expect(declaration.name, isNotNull);
8159 FunctionExpression expression = declaration.functionExpression; 8416 FunctionExpression expression = declaration.functionExpression;
8160 expect(expression, isNotNull); 8417 expect(expression, isNotNull);
(...skipping 18 matching lines...) Expand all
8179 expect(expression.parameters, isNotNull); 8436 expect(expression.parameters, isNotNull);
8180 expect(declaration.propertyKeyword, isNotNull); 8437 expect(declaration.propertyKeyword, isNotNull);
8181 } 8438 }
8182 8439
8183 void test_parseFunctionDeclarationStatement() { 8440 void test_parseFunctionDeclarationStatement() {
8184 FunctionDeclarationStatement statement = 8441 FunctionDeclarationStatement statement =
8185 parse4("parseFunctionDeclarationStatement", "void f(int p) => p * 2;"); 8442 parse4("parseFunctionDeclarationStatement", "void f(int p) => p * 2;");
8186 expect(statement.functionDeclaration, isNotNull); 8443 expect(statement.functionDeclaration, isNotNull);
8187 } 8444 }
8188 8445
8446 void test_parseFunctionDeclarationStatement_typeParameterComments() {
8447 enableGenericMethodComments = true;
8448 FunctionDeclarationStatement statement = parse4(
8449 "parseFunctionDeclarationStatement",
8450 "/*=E*/ f/*<E>*/(/*=E*/ p) => p * 2;");
8451 expect(statement.functionDeclaration, isNotNull);
8452 expect(statement.functionDeclaration.functionExpression.typeParameters,
8453 isNotNull);
8454 }
8455
8189 void test_parseFunctionDeclarationStatement_typeParameters() { 8456 void test_parseFunctionDeclarationStatement_typeParameters() {
8190 enableGenericMethods = true; 8457 enableGenericMethods = true;
8191 FunctionDeclarationStatement statement = 8458 FunctionDeclarationStatement statement =
8192 parse4("parseFunctionDeclarationStatement", "E f<E>(E p) => p * 2;"); 8459 parse4("parseFunctionDeclarationStatement", "E f<E>(E p) => p * 2;");
8193 expect(statement.functionDeclaration, isNotNull); 8460 expect(statement.functionDeclaration, isNotNull);
8461 expect(statement.functionDeclaration.functionExpression.typeParameters,
8462 isNotNull);
8194 } 8463 }
8195 8464
8196 void test_parseFunctionExpression_body_inExpression() { 8465 void test_parseFunctionExpression_body_inExpression() {
8197 FunctionExpression expression = 8466 FunctionExpression expression =
8198 parse4("parseFunctionExpression", "(int i) => i++"); 8467 parse4("parseFunctionExpression", "(int i) => i++");
8199 expect(expression.body, isNotNull); 8468 expect(expression.body, isNotNull);
8200 expect(expression.typeParameters, isNull); 8469 expect(expression.typeParameters, isNull);
8201 expect(expression.parameters, isNotNull); 8470 expect(expression.parameters, isNotNull);
8202 expect((expression.body as ExpressionFunctionBody).semicolon, isNull); 8471 expect((expression.body as ExpressionFunctionBody).semicolon, isNull);
8203 } 8472 }
8204 8473
8474 void test_parseFunctionExpression_typeParameterComments() {
8475 enableGenericMethodComments = true;
8476 FunctionExpression expression =
8477 parse4("parseFunctionExpression", "/*<E>*/(/*=E*/ i) => i++");
8478 expect(expression.body, isNotNull);
8479 expect(expression.typeParameters, isNotNull);
8480 expect(expression.parameters, isNotNull);
8481 expect((expression.body as ExpressionFunctionBody).semicolon, isNull);
8482 }
8483
8205 void test_parseFunctionExpression_typeParameters() { 8484 void test_parseFunctionExpression_typeParameters() {
8206 enableGenericMethods = true; 8485 enableGenericMethods = true;
8207 FunctionExpression expression = 8486 FunctionExpression expression =
8208 parse4("parseFunctionExpression", "<E>(E i) => i++"); 8487 parse4("parseFunctionExpression", "<E>(E i) => i++");
8209 expect(expression.body, isNotNull); 8488 expect(expression.body, isNotNull);
8210 expect(expression.typeParameters, isNotNull); 8489 expect(expression.typeParameters, isNotNull);
8211 expect(expression.parameters, isNotNull); 8490 expect(expression.parameters, isNotNull);
8212 expect((expression.body as ExpressionFunctionBody).semicolon, isNull); 8491 expect((expression.body as ExpressionFunctionBody).semicolon, isNull);
8213 } 8492 }
8214 8493
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after
8944 9223
8945 void test_parseNormalFormalParameter_function_noType() { 9224 void test_parseNormalFormalParameter_function_noType() {
8946 FunctionTypedFormalParameter parameter = 9225 FunctionTypedFormalParameter parameter =
8947 parse4("parseNormalFormalParameter", "a())"); 9226 parse4("parseNormalFormalParameter", "a())");
8948 expect(parameter.returnType, isNull); 9227 expect(parameter.returnType, isNull);
8949 expect(parameter.identifier, isNotNull); 9228 expect(parameter.identifier, isNotNull);
8950 expect(parameter.typeParameters, isNull); 9229 expect(parameter.typeParameters, isNull);
8951 expect(parameter.parameters, isNotNull); 9230 expect(parameter.parameters, isNotNull);
8952 } 9231 }
8953 9232
9233 void test_parseNormalFormalParameter_function_noType_typeParameterComments() {
9234 enableGenericMethodComments = true;
9235 FunctionTypedFormalParameter parameter =
9236 parse4("parseNormalFormalParameter", "a/*<E>*/())");
9237 expect(parameter.returnType, isNull);
9238 expect(parameter.identifier, isNotNull);
9239 expect(parameter.typeParameters, isNotNull);
9240 expect(parameter.parameters, isNotNull);
9241 }
9242
8954 void test_parseNormalFormalParameter_function_noType_typeParameters() { 9243 void test_parseNormalFormalParameter_function_noType_typeParameters() {
8955 enableGenericMethods = true; 9244 enableGenericMethods = true;
8956 FunctionTypedFormalParameter parameter = 9245 FunctionTypedFormalParameter parameter =
8957 parse4("parseNormalFormalParameter", "a<E>())"); 9246 parse4("parseNormalFormalParameter", "a<E>())");
8958 expect(parameter.returnType, isNull); 9247 expect(parameter.returnType, isNull);
8959 expect(parameter.identifier, isNotNull); 9248 expect(parameter.identifier, isNotNull);
8960 expect(parameter.typeParameters, isNotNull); 9249 expect(parameter.typeParameters, isNotNull);
8961 expect(parameter.parameters, isNotNull); 9250 expect(parameter.parameters, isNotNull);
8962 } 9251 }
8963 9252
8964 void test_parseNormalFormalParameter_function_type() { 9253 void test_parseNormalFormalParameter_function_type() {
8965 FunctionTypedFormalParameter parameter = 9254 FunctionTypedFormalParameter parameter =
8966 parse4("parseNormalFormalParameter", "A a())"); 9255 parse4("parseNormalFormalParameter", "A a())");
8967 expect(parameter.returnType, isNotNull); 9256 expect(parameter.returnType, isNotNull);
8968 expect(parameter.identifier, isNotNull); 9257 expect(parameter.identifier, isNotNull);
8969 expect(parameter.typeParameters, isNull); 9258 expect(parameter.typeParameters, isNull);
8970 expect(parameter.parameters, isNotNull); 9259 expect(parameter.parameters, isNotNull);
8971 } 9260 }
8972 9261
9262 void test_parseNormalFormalParameter_function_type_typeParameterComments() {
9263 enableGenericMethodComments = true;
9264 FunctionTypedFormalParameter parameter =
9265 parse4("parseNormalFormalParameter", "A a/*<E>*/())");
9266 expect(parameter.returnType, isNotNull);
9267 expect(parameter.identifier, isNotNull);
9268 expect(parameter.typeParameters, isNotNull);
9269 expect(parameter.parameters, isNotNull);
9270 }
9271
8973 void test_parseNormalFormalParameter_function_type_typeParameters() { 9272 void test_parseNormalFormalParameter_function_type_typeParameters() {
8974 enableGenericMethods = true; 9273 enableGenericMethods = true;
8975 FunctionTypedFormalParameter parameter = 9274 FunctionTypedFormalParameter parameter =
8976 parse4("parseNormalFormalParameter", "A a<E>())"); 9275 parse4("parseNormalFormalParameter", "A a<E>())");
8977 expect(parameter.returnType, isNotNull); 9276 expect(parameter.returnType, isNotNull);
8978 expect(parameter.identifier, isNotNull); 9277 expect(parameter.identifier, isNotNull);
8979 expect(parameter.typeParameters, isNotNull); 9278 expect(parameter.typeParameters, isNotNull);
8980 expect(parameter.parameters, isNotNull); 9279 expect(parameter.parameters, isNotNull);
8981 } 9280 }
8982 9281
8983 void test_parseNormalFormalParameter_function_void() { 9282 void test_parseNormalFormalParameter_function_void() {
8984 FunctionTypedFormalParameter parameter = 9283 FunctionTypedFormalParameter parameter =
8985 parse4("parseNormalFormalParameter", "void a())"); 9284 parse4("parseNormalFormalParameter", "void a())");
8986 expect(parameter.returnType, isNotNull); 9285 expect(parameter.returnType, isNotNull);
8987 expect(parameter.identifier, isNotNull); 9286 expect(parameter.identifier, isNotNull);
8988 expect(parameter.typeParameters, isNull); 9287 expect(parameter.typeParameters, isNull);
8989 expect(parameter.parameters, isNotNull); 9288 expect(parameter.parameters, isNotNull);
8990 } 9289 }
8991 9290
9291 void test_parseNormalFormalParameter_function_void_typeParameterComments() {
9292 enableGenericMethodComments = true;
9293 FunctionTypedFormalParameter parameter =
9294 parse4("parseNormalFormalParameter", "void a/*<E>*/())");
9295 expect(parameter.returnType, isNotNull);
9296 expect(parameter.identifier, isNotNull);
9297 expect(parameter.typeParameters, isNotNull);
9298 expect(parameter.parameters, isNotNull);
9299 }
9300
8992 void test_parseNormalFormalParameter_function_void_typeParameters() { 9301 void test_parseNormalFormalParameter_function_void_typeParameters() {
8993 enableGenericMethods = true; 9302 enableGenericMethods = true;
8994 FunctionTypedFormalParameter parameter = 9303 FunctionTypedFormalParameter parameter =
8995 parse4("parseNormalFormalParameter", "void a<E>())"); 9304 parse4("parseNormalFormalParameter", "void a<E>())");
8996 expect(parameter.returnType, isNotNull); 9305 expect(parameter.returnType, isNotNull);
8997 expect(parameter.identifier, isNotNull); 9306 expect(parameter.identifier, isNotNull);
8998 expect(parameter.typeParameters, isNotNull); 9307 expect(parameter.typeParameters, isNotNull);
8999 expect(parameter.parameters, isNotNull); 9308 expect(parameter.parameters, isNotNull);
9000 } 9309 }
9001 9310
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
9118 9427
9119 void test_parsePostfixExpression_none_methodInvocation_question_dot() { 9428 void test_parsePostfixExpression_none_methodInvocation_question_dot() {
9120 MethodInvocation expression = parse4('parsePostfixExpression', 'a?.m()'); 9429 MethodInvocation expression = parse4('parsePostfixExpression', 'a?.m()');
9121 expect(expression.target, isNotNull); 9430 expect(expression.target, isNotNull);
9122 expect(expression.operator.type, TokenType.QUESTION_PERIOD); 9431 expect(expression.operator.type, TokenType.QUESTION_PERIOD);
9123 expect(expression.methodName, isNotNull); 9432 expect(expression.methodName, isNotNull);
9124 expect(expression.typeArguments, isNull); 9433 expect(expression.typeArguments, isNull);
9125 expect(expression.argumentList, isNotNull); 9434 expect(expression.argumentList, isNotNull);
9126 } 9435 }
9127 9436
9437 void test_parsePostfixExpression_none_methodInvocation_question_dot_typeArgume ntComments() {
9438 enableGenericMethodComments = true;
9439 MethodInvocation expression =
9440 parse4('parsePostfixExpression', 'a?.m/*<E>*/()');
9441 expect(expression.target, isNotNull);
9442 expect(expression.operator.type, TokenType.QUESTION_PERIOD);
9443 expect(expression.methodName, isNotNull);
9444 expect(expression.typeArguments, isNotNull);
9445 expect(expression.argumentList, isNotNull);
9446 }
9447
9128 void test_parsePostfixExpression_none_methodInvocation_question_dot_typeArgume nts() { 9448 void test_parsePostfixExpression_none_methodInvocation_question_dot_typeArgume nts() {
9129 enableGenericMethods = true; 9449 enableGenericMethods = true;
9130 MethodInvocation expression = parse4('parsePostfixExpression', 'a?.m<E>()'); 9450 MethodInvocation expression = parse4('parsePostfixExpression', 'a?.m<E>()');
9131 expect(expression.target, isNotNull); 9451 expect(expression.target, isNotNull);
9132 expect(expression.operator.type, TokenType.QUESTION_PERIOD); 9452 expect(expression.operator.type, TokenType.QUESTION_PERIOD);
9133 expect(expression.methodName, isNotNull); 9453 expect(expression.methodName, isNotNull);
9134 expect(expression.typeArguments, isNotNull); 9454 expect(expression.typeArguments, isNotNull);
9135 expect(expression.argumentList, isNotNull); 9455 expect(expression.argumentList, isNotNull);
9136 } 9456 }
9137 9457
9458 void test_parsePostfixExpression_none_methodInvocation_typeArgumentComments() {
9459 enableGenericMethodComments = true;
9460 MethodInvocation expression =
9461 parse4("parsePostfixExpression", "a.m/*<E>*/()");
9462 expect(expression.target, isNotNull);
9463 expect(expression.operator.type, TokenType.PERIOD);
9464 expect(expression.methodName, isNotNull);
9465 expect(expression.typeArguments, isNotNull);
9466 expect(expression.argumentList, isNotNull);
9467 }
9468
9138 void test_parsePostfixExpression_none_methodInvocation_typeArguments() { 9469 void test_parsePostfixExpression_none_methodInvocation_typeArguments() {
9139 enableGenericMethods = true; 9470 enableGenericMethods = true;
9140 MethodInvocation expression = parse4("parsePostfixExpression", "a.m<E>()"); 9471 MethodInvocation expression = parse4("parsePostfixExpression", "a.m<E>()");
9141 expect(expression.target, isNotNull); 9472 expect(expression.target, isNotNull);
9142 expect(expression.operator.type, TokenType.PERIOD); 9473 expect(expression.operator.type, TokenType.PERIOD);
9143 expect(expression.methodName, isNotNull); 9474 expect(expression.methodName, isNotNull);
9144 expect(expression.typeArguments, isNotNull); 9475 expect(expression.typeArguments, isNotNull);
9145 expect(expression.argumentList, isNotNull); 9476 expect(expression.argumentList, isNotNull);
9146 } 9477 }
9147 9478
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
9481 expect(argumentList.arguments[0].isSynthetic, isTrue); 9812 expect(argumentList.arguments[0].isSynthetic, isTrue);
9482 expect(argumentList.rightBracket, isNotNull); 9813 expect(argumentList.rightBracket, isNotNull);
9483 } 9814 }
9484 9815
9485 void test_parseStatement_functionDeclaration_noReturnType() { 9816 void test_parseStatement_functionDeclaration_noReturnType() {
9486 FunctionDeclarationStatement statement = 9817 FunctionDeclarationStatement statement =
9487 parse4("parseStatement", "f(a, b) {};"); 9818 parse4("parseStatement", "f(a, b) {};");
9488 expect(statement.functionDeclaration, isNotNull); 9819 expect(statement.functionDeclaration, isNotNull);
9489 } 9820 }
9490 9821
9822 void test_parseStatement_functionDeclaration_noReturnType_typeParameterComment s() {
9823 enableGenericMethodComments = true;
9824 FunctionDeclarationStatement statement =
9825 parse4("parseStatement", "f/*<E>*/(a, b) {};");
9826 expect(statement.functionDeclaration, isNotNull);
9827 expect(statement.functionDeclaration.functionExpression.typeParameters,
9828 isNotNull);
9829 }
9830
9491 void test_parseStatement_functionDeclaration_noReturnType_typeParameters() { 9831 void test_parseStatement_functionDeclaration_noReturnType_typeParameters() {
9492 enableGenericMethods = true; 9832 enableGenericMethods = true;
9833 // TODO(jmesserly): is this a bug? it doesn't actually use type parameters,
Jennifer Messerly 2015/11/11 18:28:06 not sure if this existing test was broken or ...
Brian Wilkerson 2015/11/11 21:53:42 The implementation of the test certainly doesn't m
Jennifer Messerly 2015/11/12 00:20:00 Done
9834 // and if I add them, it doesnt' work.
9493 FunctionDeclarationStatement statement = 9835 FunctionDeclarationStatement statement =
9494 parse4("parseStatement", "f(a, b) {};"); 9836 parse4("parseStatement", "f(a, b) {};");
9495 expect(statement.functionDeclaration, isNotNull); 9837 expect(statement.functionDeclaration, isNotNull);
9496 } 9838 }
9497 9839
9498 void test_parseStatement_functionDeclaration_returnType() { 9840 void test_parseStatement_functionDeclaration_returnType() {
9499 // TODO(brianwilkerson) Implement more tests for this method. 9841 // TODO(brianwilkerson) Implement more tests for this method.
9500 FunctionDeclarationStatement statement = 9842 FunctionDeclarationStatement statement =
9501 parse4("parseStatement", "int f(a, b) {};"); 9843 parse4("parseStatement", "int f(a, b) {};");
9502 expect(statement.functionDeclaration, isNotNull); 9844 expect(statement.functionDeclaration, isNotNull);
(...skipping 1229 matching lines...) Expand 10 before | Expand all | Expand 10 after
10732 new Scanner(null, new CharSequenceReader(source), listener); 11074 new Scanner(null, new CharSequenceReader(source), listener);
10733 Token tokenStream = scanner.tokenize(); 11075 Token tokenStream = scanner.tokenize();
10734 // 11076 //
10735 // Parse the source. 11077 // Parse the source.
10736 // 11078 //
10737 Parser parser = new Parser(null, listener); 11079 Parser parser = new Parser(null, listener);
10738 return invokeParserMethodImpl( 11080 return invokeParserMethodImpl(
10739 parser, methodName, <Object>[tokenStream], tokenStream) as Token; 11081 parser, methodName, <Object>[tokenStream], tokenStream) as Token;
10740 } 11082 }
10741 } 11083 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698