Chromium Code Reviews| 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/error.dart'; | 9 import 'package:analyzer/src/generated/error.dart'; |
| 10 import 'package:analyzer/src/generated/incremental_scanner.dart'; | 10 import 'package:analyzer/src/generated/incremental_scanner.dart'; |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 309 (obj) => obj is AssignmentExpression, AssignmentExpression, section); | 309 (obj) => obj is AssignmentExpression, AssignmentExpression, section); |
| 310 Expression lhs = (section as AssignmentExpression).leftHandSide; | 310 Expression lhs = (section as AssignmentExpression).leftHandSide; |
| 311 EngineTestCase.assertInstanceOf( | 311 EngineTestCase.assertInstanceOf( |
| 312 (obj) => obj is IndexExpression, IndexExpression, lhs); | 312 (obj) => obj is IndexExpression, IndexExpression, lhs); |
| 313 IndexExpression index = lhs as IndexExpression; | 313 IndexExpression index = lhs as IndexExpression; |
| 314 expect(index.isCascaded, isTrue); | 314 expect(index.isCascaded, isTrue); |
| 315 expect(index.realTarget, same(target)); | 315 expect(index.realTarget, same(target)); |
| 316 } | 316 } |
| 317 } | 317 } |
| 318 | 318 |
| 319 void test_conditionalExpression_precedence_ifNullExpression() { | |
| 320 _enableNullAwareOperators = true; | |
| 321 ConditionalExpression expression = parseExpression('a ?? b ? y : z'); | |
| 322 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | |
| 323 BinaryExpression, expression.condition); | |
| 324 } | |
| 325 | |
| 319 void test_conditionalExpression_precedence_logicalOrExpression() { | 326 void test_conditionalExpression_precedence_logicalOrExpression() { |
| 320 ConditionalExpression expression = parseExpression("a | b ? y : z"); | 327 ConditionalExpression expression = parseExpression("a | b ? y : z"); |
| 321 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | 328 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, |
| 322 BinaryExpression, expression.condition); | 329 BinaryExpression, expression.condition); |
| 323 } | 330 } |
| 324 | 331 |
| 325 void test_constructor_initializer_withParenthesizedExpression() { | 332 void test_constructor_initializer_withParenthesizedExpression() { |
| 326 CompilationUnit unit = ParserTestCase.parseCompilationUnit(r''' | 333 CompilationUnit unit = ParserTestCase.parseCompilationUnit(r''' |
| 327 class C { | 334 class C { |
| 328 C() : | 335 C() : |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 352 (obj) => obj is IsExpression, IsExpression, expression.rightOperand); | 359 (obj) => obj is IsExpression, IsExpression, expression.rightOperand); |
| 353 } | 360 } |
| 354 | 361 |
| 355 void test_equalityExpression_super() { | 362 void test_equalityExpression_super() { |
| 356 BinaryExpression expression = parseExpression("super == y != z", | 363 BinaryExpression expression = parseExpression("super == y != z", |
| 357 [ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND]); | 364 [ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND]); |
| 358 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | 365 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, |
| 359 BinaryExpression, expression.leftOperand); | 366 BinaryExpression, expression.leftOperand); |
| 360 } | 367 } |
| 361 | 368 |
| 369 void test_ifNullExpression() { | |
| 370 _enableNullAwareOperators = true; | |
| 371 BinaryExpression expression = parseExpression('x ?? y ?? z'); | |
| 372 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | |
| 373 BinaryExpression, expression.leftOperand); | |
| 374 } | |
| 375 | |
| 376 void test_ifNullExpression_precedence_logicalOr_left() { | |
| 377 _enableNullAwareOperators = true; | |
| 378 BinaryExpression expression = parseExpression('x || y ?? z'); | |
| 379 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | |
| 380 BinaryExpression, expression.leftOperand); | |
| 381 } | |
| 382 | |
| 383 void test_ifNullExpression_precendce_logicalOr_right() { | |
| 384 _enableNullAwareOperators = true; | |
| 385 BinaryExpression expression = parseExpression('x ?? y || z'); | |
| 386 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | |
| 387 BinaryExpression, expression.rightOperand); | |
| 388 } | |
| 389 | |
| 362 void test_logicalAndExpression() { | 390 void test_logicalAndExpression() { |
| 363 BinaryExpression expression = parseExpression("x && y && z"); | 391 BinaryExpression expression = parseExpression("x && y && z"); |
| 364 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | 392 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, |
| 365 BinaryExpression, expression.leftOperand); | 393 BinaryExpression, expression.leftOperand); |
| 366 } | 394 } |
| 367 | 395 |
| 368 void test_logicalAndExpression_precedence_bitwiseOr_left() { | 396 void test_logicalAndExpression_precedence_bitwiseOr_left() { |
| 369 BinaryExpression expression = parseExpression("x | y < z"); | 397 BinaryExpression expression = parseExpression("x | y < z"); |
| 370 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | 398 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, |
| 371 BinaryExpression, expression.leftOperand); | 399 BinaryExpression, expression.leftOperand); |
| (...skipping 2020 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2392 * An empty list of objects used as arguments to zero-argument methods. | 2420 * An empty list of objects used as arguments to zero-argument methods. |
| 2393 */ | 2421 */ |
| 2394 static const List<Object> _EMPTY_ARGUMENTS = const <Object>[]; | 2422 static const List<Object> _EMPTY_ARGUMENTS = const <Object>[]; |
| 2395 | 2423 |
| 2396 /** | 2424 /** |
| 2397 * A flag indicating whether parser is to parse function bodies. | 2425 * A flag indicating whether parser is to parse function bodies. |
| 2398 */ | 2426 */ |
| 2399 static bool parseFunctionBodies = true; | 2427 static bool parseFunctionBodies = true; |
| 2400 | 2428 |
| 2401 /** | 2429 /** |
| 2430 * If non-null, this value is used to override the default value of | |
| 2431 * [Scanner.enableNullAwareOperators] before scanning. | |
| 2432 */ | |
| 2433 bool _enableNullAwareOperators; | |
| 2434 | |
| 2435 /** | |
| 2402 * Return a CommentAndMetadata object with the given values that can be used f or testing. | 2436 * Return a CommentAndMetadata object with the given values that can be used f or testing. |
| 2403 * | 2437 * |
| 2404 * @param comment the comment to be wrapped in the object | 2438 * @param comment the comment to be wrapped in the object |
| 2405 * @param annotations the annotations to be wrapped in the object | 2439 * @param annotations the annotations to be wrapped in the object |
| 2406 * @return a CommentAndMetadata object that can be used for testing | 2440 * @return a CommentAndMetadata object that can be used for testing |
| 2407 */ | 2441 */ |
| 2408 CommentAndMetadata commentAndMetadata(Comment comment, | 2442 CommentAndMetadata commentAndMetadata(Comment comment, |
| 2409 [List<Annotation> annotations]) { | 2443 [List<Annotation> annotations]) { |
| 2410 return new CommentAndMetadata(comment, annotations); | 2444 return new CommentAndMetadata(comment, annotations); |
| 2411 } | 2445 } |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 2434 * @throws AssertionFailedError if the result is `null` or the errors produced while | 2468 * @throws AssertionFailedError if the result is `null` or the errors produced while |
| 2435 * scanning and parsing the source do not match the expected errors | 2469 * scanning and parsing the source do not match the expected errors |
| 2436 */ | 2470 */ |
| 2437 Object invokeParserMethod(String methodName, List<Object> objects, | 2471 Object invokeParserMethod(String methodName, List<Object> objects, |
| 2438 String source, GatheringErrorListener listener) { | 2472 String source, GatheringErrorListener listener) { |
| 2439 // | 2473 // |
| 2440 // Scan the source. | 2474 // Scan the source. |
| 2441 // | 2475 // |
| 2442 Scanner scanner = | 2476 Scanner scanner = |
| 2443 new Scanner(null, new CharSequenceReader(source), listener); | 2477 new Scanner(null, new CharSequenceReader(source), listener); |
| 2478 if (_enableNullAwareOperators != null) { | |
| 2479 scanner.enableNullAwareOperators = _enableNullAwareOperators; | |
| 2480 } | |
| 2444 Token tokenStream = scanner.tokenize(); | 2481 Token tokenStream = scanner.tokenize(); |
| 2445 listener.setLineInfo(new TestSource(), scanner.lineStarts); | 2482 listener.setLineInfo(new TestSource(), scanner.lineStarts); |
| 2446 // | 2483 // |
| 2447 // Parse the source. | 2484 // Parse the source. |
| 2448 // | 2485 // |
| 2449 Parser parser = createParser(listener); | 2486 Parser parser = createParser(listener); |
| 2450 parser.parseFunctionBodies = parseFunctionBodies; | 2487 parser.parseFunctionBodies = parseFunctionBodies; |
| 2451 Object result = | 2488 Object result = |
| 2452 invokeParserMethodImpl(parser, methodName, objects, tokenStream); | 2489 invokeParserMethodImpl(parser, methodName, objects, tokenStream); |
| 2453 // | 2490 // |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2567 * @param errorCodes the error codes of the errors that are expected to be fou nd | 2604 * @param errorCodes the error codes of the errors that are expected to be fou nd |
| 2568 * @return the expression that was parsed | 2605 * @return the expression that was parsed |
| 2569 * @throws Exception if the source could not be parsed, if the compilation err ors in the source do | 2606 * @throws Exception if the source could not be parsed, if the compilation err ors in the source do |
| 2570 * not match those that are expected, or if the result would have be en `null` | 2607 * not match those that are expected, or if the result would have be en `null` |
| 2571 */ | 2608 */ |
| 2572 Expression parseExpression(String source, | 2609 Expression parseExpression(String source, |
| 2573 [List<ErrorCode> errorCodes = ErrorCode.EMPTY_LIST]) { | 2610 [List<ErrorCode> errorCodes = ErrorCode.EMPTY_LIST]) { |
| 2574 GatheringErrorListener listener = new GatheringErrorListener(); | 2611 GatheringErrorListener listener = new GatheringErrorListener(); |
| 2575 Scanner scanner = | 2612 Scanner scanner = |
| 2576 new Scanner(null, new CharSequenceReader(source), listener); | 2613 new Scanner(null, new CharSequenceReader(source), listener); |
| 2614 if (_enableNullAwareOperators != null) { | |
| 2615 scanner.enableNullAwareOperators = _enableNullAwareOperators; | |
| 2616 } | |
| 2577 listener.setLineInfo(new TestSource(), scanner.lineStarts); | 2617 listener.setLineInfo(new TestSource(), scanner.lineStarts); |
| 2578 Token token = scanner.tokenize(); | 2618 Token token = scanner.tokenize(); |
| 2579 Parser parser = createParser(listener); | 2619 Parser parser = createParser(listener); |
| 2580 Expression expression = parser.parseExpression(token); | 2620 Expression expression = parser.parseExpression(token); |
| 2581 expect(expression, isNotNull); | 2621 expect(expression, isNotNull); |
| 2582 listener.assertErrorsWithCodes(errorCodes); | 2622 listener.assertErrorsWithCodes(errorCodes); |
| 2583 return expression; | 2623 return expression; |
| 2584 } | 2624 } |
| 2585 | 2625 |
| 2586 @override | 2626 @override |
| (...skipping 2175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4762 expect(argumentList, isNotNull); | 4802 expect(argumentList, isNotNull); |
| 4763 expect(argumentList.arguments, hasLength(1)); | 4803 expect(argumentList.arguments, hasLength(1)); |
| 4764 expect(propertyAccess.operator, isNotNull); | 4804 expect(propertyAccess.operator, isNotNull); |
| 4765 expect(propertyAccess.propertyName, isNotNull); | 4805 expect(propertyAccess.propertyName, isNotNull); |
| 4766 } | 4806 } |
| 4767 | 4807 |
| 4768 void test_parseAssignableExpression_expression_dot() { | 4808 void test_parseAssignableExpression_expression_dot() { |
| 4769 PropertyAccess propertyAccess = | 4809 PropertyAccess propertyAccess = |
| 4770 parse("parseAssignableExpression", <Object>[false], "(x).y"); | 4810 parse("parseAssignableExpression", <Object>[false], "(x).y"); |
| 4771 expect(propertyAccess.target, isNotNull); | 4811 expect(propertyAccess.target, isNotNull); |
| 4772 expect(propertyAccess.operator, isNotNull); | 4812 expect(propertyAccess.operator.type, TokenType.PERIOD); |
| 4773 expect(propertyAccess.propertyName, isNotNull); | 4813 expect(propertyAccess.propertyName, isNotNull); |
| 4774 } | 4814 } |
| 4775 | 4815 |
| 4776 void test_parseAssignableExpression_expression_index() { | 4816 void test_parseAssignableExpression_expression_index() { |
| 4777 IndexExpression expression = | 4817 IndexExpression expression = |
| 4778 parse("parseAssignableExpression", <Object>[false], "(x)[y]"); | 4818 parse("parseAssignableExpression", <Object>[false], "(x)[y]"); |
| 4779 expect(expression.target, isNotNull); | 4819 expect(expression.target, isNotNull); |
| 4780 expect(expression.leftBracket, isNotNull); | 4820 expect(expression.leftBracket, isNotNull); |
| 4781 expect(expression.index, isNotNull); | 4821 expect(expression.index, isNotNull); |
| 4782 expect(expression.rightBracket, isNotNull); | 4822 expect(expression.rightBracket, isNotNull); |
| 4783 } | 4823 } |
| 4784 | 4824 |
| 4825 void test_parseAssignableExpression_expression_question_dot() { | |
| 4826 _enableNullAwareOperators = true; | |
| 4827 PropertyAccess propertyAccess = | |
| 4828 parse("parseAssignableExpression", <Object>[false], "(x)?.y"); | |
| 4829 expect(propertyAccess.target, isNotNull); | |
| 4830 expect(propertyAccess.operator.type, TokenType.QUESTION_PERIOD); | |
| 4831 expect(propertyAccess.propertyName, isNotNull); | |
| 4832 } | |
| 4833 | |
| 4785 void test_parseAssignableExpression_identifier() { | 4834 void test_parseAssignableExpression_identifier() { |
| 4786 SimpleIdentifier identifier = | 4835 SimpleIdentifier identifier = |
| 4787 parse("parseAssignableExpression", <Object>[false], "x"); | 4836 parse("parseAssignableExpression", <Object>[false], "x"); |
| 4788 expect(identifier, isNotNull); | 4837 expect(identifier, isNotNull); |
| 4789 } | 4838 } |
| 4790 | 4839 |
| 4791 void test_parseAssignableExpression_identifier_args_dot() { | 4840 void test_parseAssignableExpression_identifier_args_dot() { |
| 4792 PropertyAccess propertyAccess = | 4841 PropertyAccess propertyAccess = |
| 4793 parse("parseAssignableExpression", <Object>[false], "x(y).z"); | 4842 parse("parseAssignableExpression", <Object>[false], "x(y).z"); |
| 4794 MethodInvocation invocation = propertyAccess.target as MethodInvocation; | 4843 MethodInvocation invocation = propertyAccess.target as MethodInvocation; |
| 4795 expect(invocation.methodName.name, "x"); | 4844 expect(invocation.methodName.name, "x"); |
| 4796 ArgumentList argumentList = invocation.argumentList; | 4845 ArgumentList argumentList = invocation.argumentList; |
| 4797 expect(argumentList, isNotNull); | 4846 expect(argumentList, isNotNull); |
| 4798 expect(argumentList.arguments, hasLength(1)); | 4847 expect(argumentList.arguments, hasLength(1)); |
| 4799 expect(propertyAccess.operator, isNotNull); | 4848 expect(propertyAccess.operator, isNotNull); |
| 4800 expect(propertyAccess.propertyName, isNotNull); | 4849 expect(propertyAccess.propertyName, isNotNull); |
| 4801 } | 4850 } |
| 4802 | 4851 |
| 4803 void test_parseAssignableExpression_identifier_dot() { | 4852 void test_parseAssignableExpression_identifier_dot() { |
| 4804 PropertyAccess propertyAccess = | 4853 PropertyAccess propertyAccess = |
| 4805 parse("parseAssignableExpression", <Object>[false], "x.y"); | 4854 parse("parseAssignableExpression", <Object>[false], "x.y"); |
| 4806 expect(propertyAccess.target, isNotNull); | 4855 expect(propertyAccess.target, isNotNull); |
| 4807 expect(propertyAccess.operator, isNotNull); | 4856 expect(propertyAccess.operator.type, TokenType.PERIOD); |
|
Brian Wilkerson
2015/03/27 22:56:37
I generally prefer to leave in the explicit tests
Paul Berry
2015/03/28 02:25:09
Done.
| |
| 4808 expect(propertyAccess.propertyName, isNotNull); | 4857 expect(propertyAccess.propertyName, isNotNull); |
| 4809 } | 4858 } |
| 4810 | 4859 |
| 4811 void test_parseAssignableExpression_identifier_index() { | 4860 void test_parseAssignableExpression_identifier_index() { |
| 4812 IndexExpression expression = | 4861 IndexExpression expression = |
| 4813 parse("parseAssignableExpression", <Object>[false], "x[y]"); | 4862 parse("parseAssignableExpression", <Object>[false], "x[y]"); |
| 4814 expect(expression.target, isNotNull); | 4863 expect(expression.target, isNotNull); |
| 4815 expect(expression.leftBracket, isNotNull); | 4864 expect(expression.leftBracket, isNotNull); |
| 4816 expect(expression.index, isNotNull); | 4865 expect(expression.index, isNotNull); |
| 4817 expect(expression.rightBracket, isNotNull); | 4866 expect(expression.rightBracket, isNotNull); |
| 4818 } | 4867 } |
| 4819 | 4868 |
| 4869 void test_parseAssignableExpression_identifier_question_dot() { | |
| 4870 _enableNullAwareOperators = true; | |
| 4871 PropertyAccess propertyAccess = | |
| 4872 parse("parseAssignableExpression", <Object>[false], "x?.y"); | |
| 4873 expect(propertyAccess.target, isNotNull); | |
| 4874 expect(propertyAccess.operator.type, TokenType.QUESTION_PERIOD); | |
| 4875 expect(propertyAccess.propertyName, isNotNull); | |
| 4876 } | |
| 4877 | |
| 4820 void test_parseAssignableExpression_super_dot() { | 4878 void test_parseAssignableExpression_super_dot() { |
| 4821 PropertyAccess propertyAccess = | 4879 PropertyAccess propertyAccess = |
| 4822 parse("parseAssignableExpression", <Object>[false], "super.y"); | 4880 parse("parseAssignableExpression", <Object>[false], "super.y"); |
| 4823 EngineTestCase.assertInstanceOf((obj) => obj is SuperExpression, | 4881 EngineTestCase.assertInstanceOf((obj) => obj is SuperExpression, |
| 4824 SuperExpression, propertyAccess.target); | 4882 SuperExpression, propertyAccess.target); |
| 4825 expect(propertyAccess.operator, isNotNull); | 4883 expect(propertyAccess.operator, isNotNull); |
| 4826 expect(propertyAccess.propertyName, isNotNull); | 4884 expect(propertyAccess.propertyName, isNotNull); |
| 4827 } | 4885 } |
| 4828 | 4886 |
| 4829 void test_parseAssignableExpression_super_index() { | 4887 void test_parseAssignableExpression_super_index() { |
| 4830 IndexExpression expression = | 4888 IndexExpression expression = |
| 4831 parse("parseAssignableExpression", <Object>[false], "super[y]"); | 4889 parse("parseAssignableExpression", <Object>[false], "super[y]"); |
| 4832 EngineTestCase.assertInstanceOf( | 4890 EngineTestCase.assertInstanceOf( |
| 4833 (obj) => obj is SuperExpression, SuperExpression, expression.target); | 4891 (obj) => obj is SuperExpression, SuperExpression, expression.target); |
| 4834 expect(expression.leftBracket, isNotNull); | 4892 expect(expression.leftBracket, isNotNull); |
| 4835 expect(expression.index, isNotNull); | 4893 expect(expression.index, isNotNull); |
| 4836 expect(expression.rightBracket, isNotNull); | 4894 expect(expression.rightBracket, isNotNull); |
| 4837 } | 4895 } |
| 4838 | 4896 |
| 4839 void test_parseAssignableSelector_dot() { | 4897 void test_parseAssignableSelector_dot() { |
| 4840 PropertyAccess selector = | 4898 PropertyAccess selector = |
| 4841 parse("parseAssignableSelector", <Object>[null, true], ".x"); | 4899 parse("parseAssignableSelector", <Object>[null, true], ".x"); |
| 4842 expect(selector.operator, isNotNull); | 4900 expect(selector.operator.type, TokenType.PERIOD); |
| 4843 expect(selector.propertyName, isNotNull); | 4901 expect(selector.propertyName, isNotNull); |
| 4844 } | 4902 } |
| 4845 | 4903 |
| 4846 void test_parseAssignableSelector_index() { | 4904 void test_parseAssignableSelector_index() { |
| 4847 IndexExpression selector = | 4905 IndexExpression selector = |
| 4848 parse("parseAssignableSelector", <Object>[null, true], "[x]"); | 4906 parse("parseAssignableSelector", <Object>[null, true], "[x]"); |
| 4849 expect(selector.leftBracket, isNotNull); | 4907 expect(selector.leftBracket, isNotNull); |
| 4850 expect(selector.index, isNotNull); | 4908 expect(selector.index, isNotNull); |
| 4851 expect(selector.rightBracket, isNotNull); | 4909 expect(selector.rightBracket, isNotNull); |
| 4852 } | 4910 } |
| 4853 | 4911 |
| 4854 void test_parseAssignableSelector_none() { | 4912 void test_parseAssignableSelector_none() { |
| 4855 SimpleIdentifier selector = parse("parseAssignableSelector", <Object>[ | 4913 SimpleIdentifier selector = parse("parseAssignableSelector", <Object>[ |
| 4856 new SimpleIdentifier(null), | 4914 new SimpleIdentifier(null), |
| 4857 true | 4915 true |
| 4858 ], ";"); | 4916 ], ";"); |
| 4859 expect(selector, isNotNull); | 4917 expect(selector, isNotNull); |
| 4860 } | 4918 } |
| 4861 | 4919 |
| 4920 void test_parseAssignableSelector_question_dot() { | |
| 4921 _enableNullAwareOperators = true; | |
| 4922 PropertyAccess selector = | |
| 4923 parse("parseAssignableSelector", <Object>[null, true], "?.x"); | |
| 4924 expect(selector.operator.type, TokenType.QUESTION_PERIOD); | |
| 4925 expect(selector.propertyName, isNotNull); | |
| 4926 } | |
| 4927 | |
| 4862 void test_parseAwaitExpression() { | 4928 void test_parseAwaitExpression() { |
| 4863 AwaitExpression expression = parse4("parseAwaitExpression", "await x;"); | 4929 AwaitExpression expression = parse4("parseAwaitExpression", "await x;"); |
| 4864 expect(expression.awaitKeyword, isNotNull); | 4930 expect(expression.awaitKeyword, isNotNull); |
| 4865 expect(expression.expression, isNotNull); | 4931 expect(expression.expression, isNotNull); |
| 4866 } | 4932 } |
| 4867 | 4933 |
| 4868 void test_parseAwaitExpression_asStatement_inAsync() { | 4934 void test_parseAwaitExpression_asStatement_inAsync() { |
| 4869 MethodDeclaration method = | 4935 MethodDeclaration method = |
| 4870 parse("parseClassMember", <Object>["C"], "m() async { await x; }"); | 4936 parse("parseClassMember", <Object>["C"], "m() async { await x; }"); |
| 4871 FunctionBody body = method.body; | 4937 FunctionBody body = method.body; |
| (...skipping 3594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8466 | 8532 |
| 8467 void test_parsePostfixExpression_none_indexExpression() { | 8533 void test_parsePostfixExpression_none_indexExpression() { |
| 8468 IndexExpression expression = parse4("parsePostfixExpression", "a[0]"); | 8534 IndexExpression expression = parse4("parsePostfixExpression", "a[0]"); |
| 8469 expect(expression.target, isNotNull); | 8535 expect(expression.target, isNotNull); |
| 8470 expect(expression.index, isNotNull); | 8536 expect(expression.index, isNotNull); |
| 8471 } | 8537 } |
| 8472 | 8538 |
| 8473 void test_parsePostfixExpression_none_methodInvocation() { | 8539 void test_parsePostfixExpression_none_methodInvocation() { |
| 8474 MethodInvocation expression = parse4("parsePostfixExpression", "a.m()"); | 8540 MethodInvocation expression = parse4("parsePostfixExpression", "a.m()"); |
| 8475 expect(expression.target, isNotNull); | 8541 expect(expression.target, isNotNull); |
| 8542 expect(expression.operator.type, TokenType.PERIOD); | |
| 8476 expect(expression.methodName, isNotNull); | 8543 expect(expression.methodName, isNotNull); |
| 8477 expect(expression.argumentList, isNotNull); | 8544 expect(expression.argumentList, isNotNull); |
| 8478 } | 8545 } |
| 8546 | |
| 8547 void test_parsePostfixExpression_none_methodInvocation_question_dot() { | |
| 8548 _enableNullAwareOperators = true; | |
| 8549 MethodInvocation expression = parse4('parsePostfixExpression', 'a?.m()'); | |
| 8550 expect(expression.target, isNotNull); | |
| 8551 expect(expression.operator.type, TokenType.QUESTION_PERIOD); | |
| 8552 expect(expression.methodName, isNotNull); | |
| 8553 expect(expression.argumentList, isNotNull); | |
| 8554 } | |
| 8479 | 8555 |
| 8480 void test_parsePostfixExpression_none_propertyAccess() { | 8556 void test_parsePostfixExpression_none_propertyAccess() { |
| 8481 PrefixedIdentifier expression = parse4("parsePostfixExpression", "a.b"); | 8557 PrefixedIdentifier expression = parse4("parsePostfixExpression", "a.b"); |
| 8482 expect(expression.prefix, isNotNull); | 8558 expect(expression.prefix, isNotNull); |
| 8483 expect(expression.identifier, isNotNull); | 8559 expect(expression.identifier, isNotNull); |
| 8484 } | 8560 } |
| 8485 | 8561 |
| 8486 void test_parsePrefixedIdentifier_noPrefix() { | 8562 void test_parsePrefixedIdentifier_noPrefix() { |
| 8487 String lexeme = "bar"; | 8563 String lexeme = "bar"; |
| 8488 SimpleIdentifier identifier = parse4("parsePrefixedIdentifier", lexeme); | 8564 SimpleIdentifier identifier = parse4("parsePrefixedIdentifier", lexeme); |
| (...skipping 1450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9939 new Scanner(null, new CharSequenceReader(source), listener); | 10015 new Scanner(null, new CharSequenceReader(source), listener); |
| 9940 Token tokenStream = scanner.tokenize(); | 10016 Token tokenStream = scanner.tokenize(); |
| 9941 // | 10017 // |
| 9942 // Parse the source. | 10018 // Parse the source. |
| 9943 // | 10019 // |
| 9944 Parser parser = new Parser(null, listener); | 10020 Parser parser = new Parser(null, listener); |
| 9945 return invokeParserMethodImpl( | 10021 return invokeParserMethodImpl( |
| 9946 parser, methodName, <Object>[tokenStream], tokenStream) as Token; | 10022 parser, methodName, <Object>[tokenStream], tokenStream) as Token; |
| 9947 } | 10023 } |
| 9948 } | 10024 } |
| OLD | NEW |