OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library analyzer.test.generated.parser_test; | 5 library analyzer.test.generated.parser_test; |
6 | 6 |
7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
8 import 'package:analyzer/dart/ast/standard_ast_factory.dart'; | 8 import 'package:analyzer/dart/ast/standard_ast_factory.dart'; |
9 import 'package:analyzer/dart/ast/token.dart'; | 9 import 'package:analyzer/dart/ast/token.dart'; |
10 import 'package:analyzer/dart/ast/visitor.dart'; | 10 import 'package:analyzer/dart/ast/visitor.dart'; |
(...skipping 3848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3859 ParserErrorCode.EXPECTED_TOKEN, | 3859 ParserErrorCode.EXPECTED_TOKEN, |
3860 ParserErrorCode.EXPECTED_TOKEN | 3860 ParserErrorCode.EXPECTED_TOKEN |
3861 ]); | 3861 ]); |
3862 } | 3862 } |
3863 | 3863 |
3864 void test_useOfUnaryPlusOperator() { | 3864 void test_useOfUnaryPlusOperator() { |
3865 createParser('+x'); | 3865 createParser('+x'); |
3866 Expression expression = parser.parseUnaryExpression(); | 3866 Expression expression = parser.parseUnaryExpression(); |
3867 expectNotNullIfNoErrors(expression); | 3867 expectNotNullIfNoErrors(expression); |
3868 listener.assertErrorsWithCodes([ParserErrorCode.MISSING_IDENTIFIER]); | 3868 listener.assertErrorsWithCodes([ParserErrorCode.MISSING_IDENTIFIER]); |
3869 expect(expression, new isInstanceOf<SimpleIdentifier>()); | 3869 var identifier = expression as SimpleIdentifier; |
3870 SimpleIdentifier identifier = expression; | |
3871 expect(identifier.isSynthetic, isTrue); | 3870 expect(identifier.isSynthetic, isTrue); |
3872 } | 3871 } |
3873 | 3872 |
3874 void test_varAndType_field() { | 3873 void test_varAndType_field() { |
3875 parseCompilationUnit( | 3874 parseCompilationUnit( |
3876 "class C { var int x; }", [ParserErrorCode.VAR_AND_TYPE]); | 3875 "class C { var int x; }", [ParserErrorCode.VAR_AND_TYPE]); |
3877 } | 3876 } |
3878 | 3877 |
3879 @failingTest | 3878 @failingTest |
3880 void test_varAndType_local() { | 3879 void test_varAndType_local() { |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4016 | 4015 |
4017 @reflectiveTest | 4016 @reflectiveTest |
4018 class ExpressionParserTest extends ParserTestCase | 4017 class ExpressionParserTest extends ParserTestCase |
4019 with ExpressionParserTestMixin {} | 4018 with ExpressionParserTestMixin {} |
4020 | 4019 |
4021 abstract class ExpressionParserTestMixin implements AbstractParserTestCase { | 4020 abstract class ExpressionParserTestMixin implements AbstractParserTestCase { |
4022 void test_parseAdditiveExpression_normal() { | 4021 void test_parseAdditiveExpression_normal() { |
4023 Expression expression = parseAdditiveExpression('x + y'); | 4022 Expression expression = parseAdditiveExpression('x + y'); |
4024 expect(expression, isNotNull); | 4023 expect(expression, isNotNull); |
4025 assertNoErrors(); | 4024 assertNoErrors(); |
4026 expect(expression, new isInstanceOf<BinaryExpression>()); | 4025 var binaryExpression = expression as BinaryExpression; |
4027 BinaryExpression binaryExpression = expression; | |
4028 expect(binaryExpression.leftOperand, isNotNull); | 4026 expect(binaryExpression.leftOperand, isNotNull); |
4029 expect(binaryExpression.operator, isNotNull); | 4027 expect(binaryExpression.operator, isNotNull); |
4030 expect(binaryExpression.operator.type, TokenType.PLUS); | 4028 expect(binaryExpression.operator.type, TokenType.PLUS); |
4031 expect(binaryExpression.rightOperand, isNotNull); | 4029 expect(binaryExpression.rightOperand, isNotNull); |
4032 } | 4030 } |
4033 | 4031 |
4034 void test_parseAdditiveExpression_super() { | 4032 void test_parseAdditiveExpression_super() { |
4035 Expression expression = parseAdditiveExpression('super + y'); | 4033 Expression expression = parseAdditiveExpression('super + y'); |
4036 expect(expression, isNotNull); | 4034 expect(expression, isNotNull); |
4037 assertNoErrors(); | 4035 assertNoErrors(); |
4038 expect(expression, new isInstanceOf<BinaryExpression>()); | 4036 var binaryExpression = expression as BinaryExpression; |
4039 BinaryExpression binaryExpression = expression; | |
4040 expect(binaryExpression.leftOperand, new isInstanceOf<SuperExpression>()); | 4037 expect(binaryExpression.leftOperand, new isInstanceOf<SuperExpression>()); |
4041 expect(binaryExpression.operator, isNotNull); | 4038 expect(binaryExpression.operator, isNotNull); |
4042 expect(binaryExpression.operator.type, TokenType.PLUS); | 4039 expect(binaryExpression.operator.type, TokenType.PLUS); |
4043 expect(binaryExpression.rightOperand, isNotNull); | 4040 expect(binaryExpression.rightOperand, isNotNull); |
4044 } | 4041 } |
4045 | 4042 |
4046 void test_parseAssignableExpression_expression_args_dot() { | 4043 void test_parseAssignableExpression_expression_args_dot() { |
4047 Expression expression = parseAssignableExpression('(x)(y).z', false); | 4044 Expression expression = parseAssignableExpression('(x)(y).z', false); |
4048 expect(expression, isNotNull); | 4045 expect(expression, isNotNull); |
4049 assertNoErrors(); | 4046 assertNoErrors(); |
4050 expect(expression, new isInstanceOf<PropertyAccess>()); | 4047 var propertyAccess = expression as PropertyAccess; |
4051 PropertyAccess propertyAccess = expression; | |
4052 FunctionExpressionInvocation invocation = | 4048 FunctionExpressionInvocation invocation = |
4053 propertyAccess.target as FunctionExpressionInvocation; | 4049 propertyAccess.target as FunctionExpressionInvocation; |
4054 expect(invocation.function, isNotNull); | 4050 expect(invocation.function, isNotNull); |
4055 expect(invocation.typeArguments, isNull); | 4051 expect(invocation.typeArguments, isNull); |
4056 ArgumentList argumentList = invocation.argumentList; | 4052 ArgumentList argumentList = invocation.argumentList; |
4057 expect(argumentList, isNotNull); | 4053 expect(argumentList, isNotNull); |
4058 expect(argumentList.arguments, hasLength(1)); | 4054 expect(argumentList.arguments, hasLength(1)); |
4059 expect(propertyAccess.operator, isNotNull); | 4055 expect(propertyAccess.operator, isNotNull); |
4060 expect(propertyAccess.propertyName, isNotNull); | 4056 expect(propertyAccess.propertyName, isNotNull); |
4061 } | 4057 } |
4062 | 4058 |
4063 void | 4059 void |
4064 test_parseAssignableExpression_expression_args_dot_typeParameterComments()
{ | 4060 test_parseAssignableExpression_expression_args_dot_typeParameterComments()
{ |
4065 enableGenericMethodComments = true; | 4061 enableGenericMethodComments = true; |
4066 Expression expression = parseAssignableExpression('(x)/*<F>*/(y).z', false); | 4062 Expression expression = parseAssignableExpression('(x)/*<F>*/(y).z', false); |
4067 expect(expression, isNotNull); | 4063 expect(expression, isNotNull); |
4068 assertNoErrors(); | 4064 assertNoErrors(); |
4069 expect(expression, new isInstanceOf<PropertyAccess>()); | 4065 var propertyAccess = expression as PropertyAccess; |
4070 PropertyAccess propertyAccess = expression; | |
4071 FunctionExpressionInvocation invocation = | 4066 FunctionExpressionInvocation invocation = |
4072 propertyAccess.target as FunctionExpressionInvocation; | 4067 propertyAccess.target as FunctionExpressionInvocation; |
4073 expect(invocation.function, isNotNull); | 4068 expect(invocation.function, isNotNull); |
4074 expect(invocation.typeArguments, isNotNull); | 4069 expect(invocation.typeArguments, isNotNull); |
4075 ArgumentList argumentList = invocation.argumentList; | 4070 ArgumentList argumentList = invocation.argumentList; |
4076 expect(argumentList, isNotNull); | 4071 expect(argumentList, isNotNull); |
4077 expect(argumentList.arguments, hasLength(1)); | 4072 expect(argumentList.arguments, hasLength(1)); |
4078 expect(propertyAccess.operator, isNotNull); | 4073 expect(propertyAccess.operator, isNotNull); |
4079 expect(propertyAccess.propertyName, isNotNull); | 4074 expect(propertyAccess.propertyName, isNotNull); |
4080 } | 4075 } |
4081 | 4076 |
4082 void test_parseAssignableExpression_expression_args_dot_typeParameters() { | 4077 void test_parseAssignableExpression_expression_args_dot_typeParameters() { |
4083 Expression expression = parseAssignableExpression('(x)<F>(y).z', false); | 4078 Expression expression = parseAssignableExpression('(x)<F>(y).z', false); |
4084 expect(expression, isNotNull); | 4079 expect(expression, isNotNull); |
4085 assertNoErrors(); | 4080 assertNoErrors(); |
4086 expect(expression, new isInstanceOf<PropertyAccess>()); | 4081 var propertyAccess = expression as PropertyAccess; |
4087 PropertyAccess propertyAccess = expression; | |
4088 FunctionExpressionInvocation invocation = | 4082 FunctionExpressionInvocation invocation = |
4089 propertyAccess.target as FunctionExpressionInvocation; | 4083 propertyAccess.target as FunctionExpressionInvocation; |
4090 expect(invocation.function, isNotNull); | 4084 expect(invocation.function, isNotNull); |
4091 expect(invocation.typeArguments, isNotNull); | 4085 expect(invocation.typeArguments, isNotNull); |
4092 ArgumentList argumentList = invocation.argumentList; | 4086 ArgumentList argumentList = invocation.argumentList; |
4093 expect(argumentList, isNotNull); | 4087 expect(argumentList, isNotNull); |
4094 expect(argumentList.arguments, hasLength(1)); | 4088 expect(argumentList.arguments, hasLength(1)); |
4095 expect(propertyAccess.operator, isNotNull); | 4089 expect(propertyAccess.operator, isNotNull); |
4096 expect(propertyAccess.propertyName, isNotNull); | 4090 expect(propertyAccess.propertyName, isNotNull); |
4097 } | 4091 } |
4098 | 4092 |
4099 void test_parseAssignableExpression_expression_dot() { | 4093 void test_parseAssignableExpression_expression_dot() { |
4100 Expression expression = parseAssignableExpression('(x).y', false); | 4094 Expression expression = parseAssignableExpression('(x).y', false); |
4101 expect(expression, isNotNull); | 4095 expect(expression, isNotNull); |
4102 assertNoErrors(); | 4096 assertNoErrors(); |
4103 expect(expression, new isInstanceOf<PropertyAccess>()); | 4097 var propertyAccess = expression as PropertyAccess; |
4104 PropertyAccess propertyAccess = expression; | |
4105 expect(propertyAccess.target, isNotNull); | 4098 expect(propertyAccess.target, isNotNull); |
4106 expect(propertyAccess.operator.type, TokenType.PERIOD); | 4099 expect(propertyAccess.operator.type, TokenType.PERIOD); |
4107 expect(propertyAccess.propertyName, isNotNull); | 4100 expect(propertyAccess.propertyName, isNotNull); |
4108 } | 4101 } |
4109 | 4102 |
4110 void test_parseAssignableExpression_expression_index() { | 4103 void test_parseAssignableExpression_expression_index() { |
4111 Expression expression = parseAssignableExpression('(x)[y]', false); | 4104 Expression expression = parseAssignableExpression('(x)[y]', false); |
4112 expect(expression, isNotNull); | 4105 expect(expression, isNotNull); |
4113 assertNoErrors(); | 4106 assertNoErrors(); |
4114 expect(expression, new isInstanceOf<IndexExpression>()); | 4107 var indexExpression = expression as IndexExpression; |
4115 IndexExpression indexExpression = expression; | |
4116 expect(indexExpression.target, isNotNull); | 4108 expect(indexExpression.target, isNotNull); |
4117 expect(indexExpression.leftBracket, isNotNull); | 4109 expect(indexExpression.leftBracket, isNotNull); |
4118 expect(indexExpression.index, isNotNull); | 4110 expect(indexExpression.index, isNotNull); |
4119 expect(indexExpression.rightBracket, isNotNull); | 4111 expect(indexExpression.rightBracket, isNotNull); |
4120 } | 4112 } |
4121 | 4113 |
4122 void test_parseAssignableExpression_expression_question_dot() { | 4114 void test_parseAssignableExpression_expression_question_dot() { |
4123 Expression expression = parseAssignableExpression('(x)?.y', false); | 4115 Expression expression = parseAssignableExpression('(x)?.y', false); |
4124 expect(expression, isNotNull); | 4116 expect(expression, isNotNull); |
4125 assertNoErrors(); | 4117 assertNoErrors(); |
4126 expect(expression, new isInstanceOf<PropertyAccess>()); | 4118 var propertyAccess = expression as PropertyAccess; |
4127 PropertyAccess propertyAccess = expression; | |
4128 expect(propertyAccess.target, isNotNull); | 4119 expect(propertyAccess.target, isNotNull); |
4129 expect(propertyAccess.operator.type, TokenType.QUESTION_PERIOD); | 4120 expect(propertyAccess.operator.type, TokenType.QUESTION_PERIOD); |
4130 expect(propertyAccess.propertyName, isNotNull); | 4121 expect(propertyAccess.propertyName, isNotNull); |
4131 } | 4122 } |
4132 | 4123 |
4133 void test_parseAssignableExpression_identifier() { | 4124 void test_parseAssignableExpression_identifier() { |
4134 Expression expression = parseAssignableExpression('x', false); | 4125 Expression expression = parseAssignableExpression('x', false); |
4135 expect(expression, isNotNull); | 4126 expect(expression, isNotNull); |
4136 assertNoErrors(); | 4127 assertNoErrors(); |
4137 expect(expression, new isInstanceOf<SimpleIdentifier>()); | 4128 var identifier = expression as SimpleIdentifier; |
4138 SimpleIdentifier identifier = expression; | |
4139 expect(identifier, isNotNull); | 4129 expect(identifier, isNotNull); |
4140 } | 4130 } |
4141 | 4131 |
4142 void test_parseAssignableExpression_identifier_args_dot() { | 4132 void test_parseAssignableExpression_identifier_args_dot() { |
4143 Expression expression = parseAssignableExpression('x(y).z', false); | 4133 Expression expression = parseAssignableExpression('x(y).z', false); |
4144 expect(expression, isNotNull); | 4134 expect(expression, isNotNull); |
4145 assertNoErrors(); | 4135 assertNoErrors(); |
4146 expect(expression, new isInstanceOf<PropertyAccess>()); | 4136 var propertyAccess = expression as PropertyAccess; |
4147 PropertyAccess propertyAccess = expression; | |
4148 MethodInvocation invocation = propertyAccess.target as MethodInvocation; | 4137 MethodInvocation invocation = propertyAccess.target as MethodInvocation; |
4149 expect(invocation.methodName.name, "x"); | 4138 expect(invocation.methodName.name, "x"); |
4150 expect(invocation.typeArguments, isNull); | 4139 expect(invocation.typeArguments, isNull); |
4151 ArgumentList argumentList = invocation.argumentList; | 4140 ArgumentList argumentList = invocation.argumentList; |
4152 expect(argumentList, isNotNull); | 4141 expect(argumentList, isNotNull); |
4153 expect(argumentList.arguments, hasLength(1)); | 4142 expect(argumentList.arguments, hasLength(1)); |
4154 expect(propertyAccess.operator, isNotNull); | 4143 expect(propertyAccess.operator, isNotNull); |
4155 expect(propertyAccess.propertyName, isNotNull); | 4144 expect(propertyAccess.propertyName, isNotNull); |
4156 } | 4145 } |
4157 | 4146 |
4158 void | 4147 void |
4159 test_parseAssignableExpression_identifier_args_dot_typeParameterComments()
{ | 4148 test_parseAssignableExpression_identifier_args_dot_typeParameterComments()
{ |
4160 enableGenericMethodComments = true; | 4149 enableGenericMethodComments = true; |
4161 Expression expression = parseAssignableExpression('x/*<E>*/(y).z', false); | 4150 Expression expression = parseAssignableExpression('x/*<E>*/(y).z', false); |
4162 expect(expression, isNotNull); | 4151 expect(expression, isNotNull); |
4163 assertNoErrors(); | 4152 assertNoErrors(); |
4164 expect(expression, new isInstanceOf<PropertyAccess>()); | 4153 var propertyAccess = expression as PropertyAccess; |
4165 PropertyAccess propertyAccess = expression; | |
4166 MethodInvocation invocation = propertyAccess.target as MethodInvocation; | 4154 MethodInvocation invocation = propertyAccess.target as MethodInvocation; |
4167 expect(invocation.methodName.name, "x"); | 4155 expect(invocation.methodName.name, "x"); |
4168 expect(invocation.typeArguments, isNotNull); | 4156 expect(invocation.typeArguments, isNotNull); |
4169 ArgumentList argumentList = invocation.argumentList; | 4157 ArgumentList argumentList = invocation.argumentList; |
4170 expect(argumentList, isNotNull); | 4158 expect(argumentList, isNotNull); |
4171 expect(argumentList.arguments, hasLength(1)); | 4159 expect(argumentList.arguments, hasLength(1)); |
4172 expect(propertyAccess.operator, isNotNull); | 4160 expect(propertyAccess.operator, isNotNull); |
4173 expect(propertyAccess.propertyName, isNotNull); | 4161 expect(propertyAccess.propertyName, isNotNull); |
4174 } | 4162 } |
4175 | 4163 |
4176 void test_parseAssignableExpression_identifier_args_dot_typeParameters() { | 4164 void test_parseAssignableExpression_identifier_args_dot_typeParameters() { |
4177 Expression expression = parseAssignableExpression('x<E>(y).z', false); | 4165 Expression expression = parseAssignableExpression('x<E>(y).z', false); |
4178 expect(expression, isNotNull); | 4166 expect(expression, isNotNull); |
4179 assertNoErrors(); | 4167 assertNoErrors(); |
4180 expect(expression, new isInstanceOf<PropertyAccess>()); | 4168 var propertyAccess = expression as PropertyAccess; |
4181 PropertyAccess propertyAccess = expression; | |
4182 MethodInvocation invocation = propertyAccess.target as MethodInvocation; | 4169 MethodInvocation invocation = propertyAccess.target as MethodInvocation; |
4183 expect(invocation.methodName.name, "x"); | 4170 expect(invocation.methodName.name, "x"); |
4184 expect(invocation.typeArguments, isNotNull); | 4171 expect(invocation.typeArguments, isNotNull); |
4185 ArgumentList argumentList = invocation.argumentList; | 4172 ArgumentList argumentList = invocation.argumentList; |
4186 expect(argumentList, isNotNull); | 4173 expect(argumentList, isNotNull); |
4187 expect(argumentList.arguments, hasLength(1)); | 4174 expect(argumentList.arguments, hasLength(1)); |
4188 expect(propertyAccess.operator, isNotNull); | 4175 expect(propertyAccess.operator, isNotNull); |
4189 expect(propertyAccess.propertyName, isNotNull); | 4176 expect(propertyAccess.propertyName, isNotNull); |
4190 } | 4177 } |
4191 | 4178 |
4192 void test_parseAssignableExpression_identifier_dot() { | 4179 void test_parseAssignableExpression_identifier_dot() { |
4193 Expression expression = parseAssignableExpression('x.y', false); | 4180 Expression expression = parseAssignableExpression('x.y', false); |
4194 expect(expression, isNotNull); | 4181 expect(expression, isNotNull); |
4195 assertNoErrors(); | 4182 assertNoErrors(); |
4196 expect(expression, new isInstanceOf<PropertyAccess>()); | 4183 var propertyAccess = expression as PropertyAccess; |
4197 PropertyAccess propertyAccess = expression; | |
4198 expect(propertyAccess.target, isNotNull); | 4184 expect(propertyAccess.target, isNotNull); |
4199 expect(propertyAccess.operator, isNotNull); | 4185 expect(propertyAccess.operator, isNotNull); |
4200 expect(propertyAccess.operator.type, TokenType.PERIOD); | 4186 expect(propertyAccess.operator.type, TokenType.PERIOD); |
4201 expect(propertyAccess.propertyName, isNotNull); | 4187 expect(propertyAccess.propertyName, isNotNull); |
4202 } | 4188 } |
4203 | 4189 |
4204 void test_parseAssignableExpression_identifier_index() { | 4190 void test_parseAssignableExpression_identifier_index() { |
4205 Expression expression = parseAssignableExpression('x[y]', false); | 4191 Expression expression = parseAssignableExpression('x[y]', false); |
4206 expect(expression, isNotNull); | 4192 expect(expression, isNotNull); |
4207 assertNoErrors(); | 4193 assertNoErrors(); |
4208 expect(expression, new isInstanceOf<IndexExpression>()); | 4194 var indexExpression = expression as IndexExpression; |
4209 IndexExpression indexExpression = expression; | |
4210 expect(indexExpression.target, isNotNull); | 4195 expect(indexExpression.target, isNotNull); |
4211 expect(indexExpression.leftBracket, isNotNull); | 4196 expect(indexExpression.leftBracket, isNotNull); |
4212 expect(indexExpression.index, isNotNull); | 4197 expect(indexExpression.index, isNotNull); |
4213 expect(indexExpression.rightBracket, isNotNull); | 4198 expect(indexExpression.rightBracket, isNotNull); |
4214 } | 4199 } |
4215 | 4200 |
4216 void test_parseAssignableExpression_identifier_question_dot() { | 4201 void test_parseAssignableExpression_identifier_question_dot() { |
4217 Expression expression = parseAssignableExpression('x?.y', false); | 4202 Expression expression = parseAssignableExpression('x?.y', false); |
4218 expect(expression, isNotNull); | 4203 expect(expression, isNotNull); |
4219 assertNoErrors(); | 4204 assertNoErrors(); |
4220 expect(expression, new isInstanceOf<PropertyAccess>()); | 4205 var propertyAccess = expression as PropertyAccess; |
4221 PropertyAccess propertyAccess = expression; | |
4222 expect(propertyAccess.target, isNotNull); | 4206 expect(propertyAccess.target, isNotNull); |
4223 expect(propertyAccess.operator.type, TokenType.QUESTION_PERIOD); | 4207 expect(propertyAccess.operator.type, TokenType.QUESTION_PERIOD); |
4224 expect(propertyAccess.propertyName, isNotNull); | 4208 expect(propertyAccess.propertyName, isNotNull); |
4225 } | 4209 } |
4226 | 4210 |
4227 void test_parseAssignableExpression_super_dot() { | 4211 void test_parseAssignableExpression_super_dot() { |
4228 Expression expression = parseAssignableExpression('super.y', false); | 4212 Expression expression = parseAssignableExpression('super.y', false); |
4229 expect(expression, isNotNull); | 4213 expect(expression, isNotNull); |
4230 assertNoErrors(); | 4214 assertNoErrors(); |
4231 expect(expression, new isInstanceOf<PropertyAccess>()); | 4215 var propertyAccess = expression as PropertyAccess; |
4232 PropertyAccess propertyAccess = expression; | |
4233 EngineTestCase.assertInstanceOf((obj) => obj is SuperExpression, | 4216 EngineTestCase.assertInstanceOf((obj) => obj is SuperExpression, |
4234 SuperExpression, propertyAccess.target); | 4217 SuperExpression, propertyAccess.target); |
4235 expect(propertyAccess.operator, isNotNull); | 4218 expect(propertyAccess.operator, isNotNull); |
4236 expect(propertyAccess.propertyName, isNotNull); | 4219 expect(propertyAccess.propertyName, isNotNull); |
4237 } | 4220 } |
4238 | 4221 |
4239 void test_parseAssignableExpression_super_index() { | 4222 void test_parseAssignableExpression_super_index() { |
4240 Expression expression = parseAssignableExpression('super[y]', false); | 4223 Expression expression = parseAssignableExpression('super[y]', false); |
4241 expect(expression, isNotNull); | 4224 expect(expression, isNotNull); |
4242 assertNoErrors(); | 4225 assertNoErrors(); |
4243 expect(expression, new isInstanceOf<IndexExpression>()); | 4226 var indexExpression = expression as IndexExpression; |
4244 IndexExpression indexExpression = expression; | |
4245 expect(indexExpression.target, new isInstanceOf<SuperExpression>()); | 4227 expect(indexExpression.target, new isInstanceOf<SuperExpression>()); |
4246 expect(indexExpression.leftBracket, isNotNull); | 4228 expect(indexExpression.leftBracket, isNotNull); |
4247 expect(indexExpression.index, isNotNull); | 4229 expect(indexExpression.index, isNotNull); |
4248 expect(indexExpression.rightBracket, isNotNull); | 4230 expect(indexExpression.rightBracket, isNotNull); |
4249 } | 4231 } |
4250 | 4232 |
4251 void test_parseAssignableSelector_dot() { | 4233 void test_parseAssignableSelector_dot() { |
4252 Expression expression = parseAssignableSelector('.x', null, true); | 4234 Expression expression = parseAssignableSelector('.x', null, true); |
4253 expect(expression, isNotNull); | 4235 expect(expression, isNotNull); |
4254 assertNoErrors(); | 4236 assertNoErrors(); |
4255 expect(expression, new isInstanceOf<PropertyAccess>()); | 4237 var propertyAccess = expression as PropertyAccess; |
4256 PropertyAccess propertyAccess = expression; | |
4257 expect(propertyAccess.operator.type, TokenType.PERIOD); | 4238 expect(propertyAccess.operator.type, TokenType.PERIOD); |
4258 expect(propertyAccess.propertyName, isNotNull); | 4239 expect(propertyAccess.propertyName, isNotNull); |
4259 } | 4240 } |
4260 | 4241 |
4261 void test_parseAssignableSelector_index() { | 4242 void test_parseAssignableSelector_index() { |
4262 Expression expression = parseAssignableSelector('[x]', null, true); | 4243 Expression expression = parseAssignableSelector('[x]', null, true); |
4263 expect(expression, isNotNull); | 4244 expect(expression, isNotNull); |
4264 assertNoErrors(); | 4245 assertNoErrors(); |
4265 expect(expression, new isInstanceOf<IndexExpression>()); | 4246 var indexExpression = expression as IndexExpression; |
4266 IndexExpression indexExpression = expression; | |
4267 expect(indexExpression.leftBracket, isNotNull); | 4247 expect(indexExpression.leftBracket, isNotNull); |
4268 expect(indexExpression.index, isNotNull); | 4248 expect(indexExpression.index, isNotNull); |
4269 expect(indexExpression.rightBracket, isNotNull); | 4249 expect(indexExpression.rightBracket, isNotNull); |
4270 } | 4250 } |
4271 | 4251 |
4272 void test_parseAssignableSelector_none() { | 4252 void test_parseAssignableSelector_none() { |
4273 Expression expression = | 4253 Expression expression = |
4274 parseAssignableSelector(';', astFactory.simpleIdentifier(null), true); | 4254 parseAssignableSelector(';', astFactory.simpleIdentifier(null), true); |
4275 expect(expression, isNotNull); | 4255 expect(expression, isNotNull); |
4276 assertNoErrors(); | 4256 assertNoErrors(); |
4277 expect(expression, new isInstanceOf<SimpleIdentifier>()); | 4257 var identifier = expression as SimpleIdentifier; |
4278 SimpleIdentifier identifier = expression; | |
4279 expect(identifier, isNotNull); | 4258 expect(identifier, isNotNull); |
4280 } | 4259 } |
4281 | 4260 |
4282 void test_parseAssignableSelector_question_dot() { | 4261 void test_parseAssignableSelector_question_dot() { |
4283 Expression expression = parseAssignableSelector('?.x', null, true); | 4262 Expression expression = parseAssignableSelector('?.x', null, true); |
4284 expect(expression, isNotNull); | 4263 expect(expression, isNotNull); |
4285 assertNoErrors(); | 4264 assertNoErrors(); |
4286 expect(expression, new isInstanceOf<PropertyAccess>()); | 4265 var propertyAccess = expression as PropertyAccess; |
4287 PropertyAccess propertyAccess = expression; | |
4288 expect(propertyAccess.operator.type, TokenType.QUESTION_PERIOD); | 4266 expect(propertyAccess.operator.type, TokenType.QUESTION_PERIOD); |
4289 expect(propertyAccess.propertyName, isNotNull); | 4267 expect(propertyAccess.propertyName, isNotNull); |
4290 } | 4268 } |
4291 | 4269 |
4292 void test_parseAwaitExpression() { | 4270 void test_parseAwaitExpression() { |
4293 AwaitExpression expression = parseAwaitExpression('await x;'); | 4271 AwaitExpression expression = parseAwaitExpression('await x;'); |
4294 expect(expression, isNotNull); | 4272 expect(expression, isNotNull); |
4295 assertNoErrors(); | 4273 assertNoErrors(); |
4296 expect(expression.awaitKeyword, isNotNull); | 4274 expect(expression.awaitKeyword, isNotNull); |
4297 expect(expression.expression, isNotNull); | 4275 expect(expression.expression, isNotNull); |
4298 } | 4276 } |
4299 | 4277 |
4300 void test_parseBitwiseAndExpression_normal() { | 4278 void test_parseBitwiseAndExpression_normal() { |
4301 Expression expression = parseBitwiseAndExpression('x & y'); | 4279 Expression expression = parseBitwiseAndExpression('x & y'); |
4302 expect(expression, isNotNull); | 4280 expect(expression, isNotNull); |
4303 assertNoErrors(); | 4281 assertNoErrors(); |
4304 expect(expression, new isInstanceOf<BinaryExpression>()); | 4282 var binaryExpression = expression as BinaryExpression; |
4305 BinaryExpression binaryExpression = expression; | |
4306 expect(binaryExpression.leftOperand, isNotNull); | 4283 expect(binaryExpression.leftOperand, isNotNull); |
4307 expect(binaryExpression.operator, isNotNull); | 4284 expect(binaryExpression.operator, isNotNull); |
4308 expect(binaryExpression.operator.type, TokenType.AMPERSAND); | 4285 expect(binaryExpression.operator.type, TokenType.AMPERSAND); |
4309 expect(binaryExpression.rightOperand, isNotNull); | 4286 expect(binaryExpression.rightOperand, isNotNull); |
4310 } | 4287 } |
4311 | 4288 |
4312 void test_parseBitwiseAndExpression_super() { | 4289 void test_parseBitwiseAndExpression_super() { |
4313 Expression expression = parseBitwiseAndExpression('super & y'); | 4290 Expression expression = parseBitwiseAndExpression('super & y'); |
4314 expect(expression, isNotNull); | 4291 expect(expression, isNotNull); |
4315 assertNoErrors(); | 4292 assertNoErrors(); |
4316 expect(expression, new isInstanceOf<BinaryExpression>()); | 4293 var binaryExpression = expression as BinaryExpression; |
4317 BinaryExpression binaryExpression = expression; | |
4318 expect(binaryExpression.leftOperand, new isInstanceOf<SuperExpression>()); | 4294 expect(binaryExpression.leftOperand, new isInstanceOf<SuperExpression>()); |
4319 expect(binaryExpression.operator, isNotNull); | 4295 expect(binaryExpression.operator, isNotNull); |
4320 expect(binaryExpression.operator.type, TokenType.AMPERSAND); | 4296 expect(binaryExpression.operator.type, TokenType.AMPERSAND); |
4321 expect(binaryExpression.rightOperand, isNotNull); | 4297 expect(binaryExpression.rightOperand, isNotNull); |
4322 } | 4298 } |
4323 | 4299 |
4324 void test_parseBitwiseOrExpression_normal() { | 4300 void test_parseBitwiseOrExpression_normal() { |
4325 Expression expression = parseBitwiseOrExpression('x | y'); | 4301 Expression expression = parseBitwiseOrExpression('x | y'); |
4326 expect(expression, isNotNull); | 4302 expect(expression, isNotNull); |
4327 assertNoErrors(); | 4303 assertNoErrors(); |
4328 expect(expression, new isInstanceOf<BinaryExpression>()); | 4304 var binaryExpression = expression as BinaryExpression; |
4329 BinaryExpression binaryExpression = expression; | |
4330 expect(binaryExpression.leftOperand, isNotNull); | 4305 expect(binaryExpression.leftOperand, isNotNull); |
4331 expect(binaryExpression.operator, isNotNull); | 4306 expect(binaryExpression.operator, isNotNull); |
4332 expect(binaryExpression.operator.type, TokenType.BAR); | 4307 expect(binaryExpression.operator.type, TokenType.BAR); |
4333 expect(binaryExpression.rightOperand, isNotNull); | 4308 expect(binaryExpression.rightOperand, isNotNull); |
4334 } | 4309 } |
4335 | 4310 |
4336 void test_parseBitwiseOrExpression_super() { | 4311 void test_parseBitwiseOrExpression_super() { |
4337 Expression expression = parseBitwiseOrExpression('super | y'); | 4312 Expression expression = parseBitwiseOrExpression('super | y'); |
4338 expect(expression, isNotNull); | 4313 expect(expression, isNotNull); |
4339 assertNoErrors(); | 4314 assertNoErrors(); |
4340 expect(expression, new isInstanceOf<BinaryExpression>()); | 4315 var binaryExpression = expression as BinaryExpression; |
4341 BinaryExpression binaryExpression = expression; | |
4342 expect(binaryExpression.leftOperand, new isInstanceOf<SuperExpression>()); | 4316 expect(binaryExpression.leftOperand, new isInstanceOf<SuperExpression>()); |
4343 expect(binaryExpression.operator, isNotNull); | 4317 expect(binaryExpression.operator, isNotNull); |
4344 expect(binaryExpression.operator.type, TokenType.BAR); | 4318 expect(binaryExpression.operator.type, TokenType.BAR); |
4345 expect(binaryExpression.rightOperand, isNotNull); | 4319 expect(binaryExpression.rightOperand, isNotNull); |
4346 } | 4320 } |
4347 | 4321 |
4348 void test_parseBitwiseXorExpression_normal() { | 4322 void test_parseBitwiseXorExpression_normal() { |
4349 Expression expression = parseBitwiseXorExpression('x ^ y'); | 4323 Expression expression = parseBitwiseXorExpression('x ^ y'); |
4350 expect(expression, isNotNull); | 4324 expect(expression, isNotNull); |
4351 assertNoErrors(); | 4325 assertNoErrors(); |
4352 expect(expression, new isInstanceOf<BinaryExpression>()); | 4326 var binaryExpression = expression as BinaryExpression; |
4353 BinaryExpression binaryExpression = expression; | |
4354 expect(binaryExpression.leftOperand, isNotNull); | 4327 expect(binaryExpression.leftOperand, isNotNull); |
4355 expect(binaryExpression.operator, isNotNull); | 4328 expect(binaryExpression.operator, isNotNull); |
4356 expect(binaryExpression.operator.type, TokenType.CARET); | 4329 expect(binaryExpression.operator.type, TokenType.CARET); |
4357 expect(binaryExpression.rightOperand, isNotNull); | 4330 expect(binaryExpression.rightOperand, isNotNull); |
4358 } | 4331 } |
4359 | 4332 |
4360 void test_parseBitwiseXorExpression_super() { | 4333 void test_parseBitwiseXorExpression_super() { |
4361 Expression expression = parseBitwiseXorExpression('super ^ y'); | 4334 Expression expression = parseBitwiseXorExpression('super ^ y'); |
4362 expect(expression, isNotNull); | 4335 expect(expression, isNotNull); |
4363 assertNoErrors(); | 4336 assertNoErrors(); |
4364 expect(expression, new isInstanceOf<BinaryExpression>()); | 4337 var binaryExpression = expression as BinaryExpression; |
4365 BinaryExpression binaryExpression = expression; | |
4366 expect(binaryExpression.leftOperand, new isInstanceOf<SuperExpression>()); | 4338 expect(binaryExpression.leftOperand, new isInstanceOf<SuperExpression>()); |
4367 expect(binaryExpression.operator, isNotNull); | 4339 expect(binaryExpression.operator, isNotNull); |
4368 expect(binaryExpression.operator.type, TokenType.CARET); | 4340 expect(binaryExpression.operator.type, TokenType.CARET); |
4369 expect(binaryExpression.rightOperand, isNotNull); | 4341 expect(binaryExpression.rightOperand, isNotNull); |
4370 } | 4342 } |
4371 | 4343 |
4372 void test_parseCascadeSection_i() { | 4344 void test_parseCascadeSection_i() { |
4373 Expression expression = parseCascadeSection('..[i]'); | 4345 Expression expression = parseCascadeSection('..[i]'); |
4374 expect(expression, isNotNull); | 4346 expect(expression, isNotNull); |
4375 assertNoErrors(); | 4347 assertNoErrors(); |
4376 expect(expression, new isInstanceOf<IndexExpression>()); | 4348 var section = expression as IndexExpression; |
4377 IndexExpression section = expression; | |
4378 expect(section.target, isNull); | 4349 expect(section.target, isNull); |
4379 expect(section.leftBracket, isNotNull); | 4350 expect(section.leftBracket, isNotNull); |
4380 expect(section.index, isNotNull); | 4351 expect(section.index, isNotNull); |
4381 expect(section.rightBracket, isNotNull); | 4352 expect(section.rightBracket, isNotNull); |
4382 } | 4353 } |
4383 | 4354 |
4384 void test_parseCascadeSection_ia() { | 4355 void test_parseCascadeSection_ia() { |
4385 Expression expression = parseCascadeSection('..[i](b)'); | 4356 Expression expression = parseCascadeSection('..[i](b)'); |
4386 expect(expression, isNotNull); | 4357 expect(expression, isNotNull); |
4387 assertNoErrors(); | 4358 assertNoErrors(); |
4388 expect(expression, new isInstanceOf<FunctionExpressionInvocation>()); | 4359 var section = expression as FunctionExpressionInvocation; |
4389 FunctionExpressionInvocation section = expression; | |
4390 expect(section.function, new isInstanceOf<IndexExpression>()); | 4360 expect(section.function, new isInstanceOf<IndexExpression>()); |
4391 expect(section.typeArguments, isNull); | 4361 expect(section.typeArguments, isNull); |
4392 expect(section.argumentList, isNotNull); | 4362 expect(section.argumentList, isNotNull); |
4393 } | 4363 } |
4394 | 4364 |
4395 void test_parseCascadeSection_ia_typeArgumentComments() { | 4365 void test_parseCascadeSection_ia_typeArgumentComments() { |
4396 enableGenericMethodComments = true; | 4366 enableGenericMethodComments = true; |
4397 Expression expression = parseCascadeSection('..[i]/*<E>*/(b)'); | 4367 Expression expression = parseCascadeSection('..[i]/*<E>*/(b)'); |
4398 expect(expression, isNotNull); | 4368 expect(expression, isNotNull); |
4399 assertNoErrors(); | 4369 assertNoErrors(); |
4400 expect(expression, new isInstanceOf<FunctionExpressionInvocation>()); | 4370 var section = expression as FunctionExpressionInvocation; |
4401 FunctionExpressionInvocation section = expression; | |
4402 expect(section.function, new isInstanceOf<IndexExpression>()); | 4371 expect(section.function, new isInstanceOf<IndexExpression>()); |
4403 expect(section.typeArguments, isNotNull); | 4372 expect(section.typeArguments, isNotNull); |
4404 expect(section.argumentList, isNotNull); | 4373 expect(section.argumentList, isNotNull); |
4405 } | 4374 } |
4406 | 4375 |
4407 void test_parseCascadeSection_ia_typeArguments() { | 4376 void test_parseCascadeSection_ia_typeArguments() { |
4408 Expression expression = parseCascadeSection('..[i]<E>(b)'); | 4377 Expression expression = parseCascadeSection('..[i]<E>(b)'); |
4409 expect(expression, isNotNull); | 4378 expect(expression, isNotNull); |
4410 assertNoErrors(); | 4379 assertNoErrors(); |
4411 expect(expression, new isInstanceOf<FunctionExpressionInvocation>()); | 4380 var section = expression as FunctionExpressionInvocation; |
4412 FunctionExpressionInvocation section = expression; | |
4413 expect(section.function, new isInstanceOf<IndexExpression>()); | 4381 expect(section.function, new isInstanceOf<IndexExpression>()); |
4414 expect(section.typeArguments, isNotNull); | 4382 expect(section.typeArguments, isNotNull); |
4415 expect(section.argumentList, isNotNull); | 4383 expect(section.argumentList, isNotNull); |
4416 } | 4384 } |
4417 | 4385 |
4418 void test_parseCascadeSection_ii() { | 4386 void test_parseCascadeSection_ii() { |
4419 Expression expression = parseCascadeSection('..a(b).c(d)'); | 4387 Expression expression = parseCascadeSection('..a(b).c(d)'); |
4420 expect(expression, isNotNull); | 4388 expect(expression, isNotNull); |
4421 assertNoErrors(); | 4389 assertNoErrors(); |
4422 expect(expression, new isInstanceOf<MethodInvocation>()); | 4390 var section = expression as MethodInvocation; |
4423 MethodInvocation section = expression; | |
4424 expect(section.target, new isInstanceOf<MethodInvocation>()); | 4391 expect(section.target, new isInstanceOf<MethodInvocation>()); |
4425 expect(section.operator, isNotNull); | 4392 expect(section.operator, isNotNull); |
4426 expect(section.methodName, isNotNull); | 4393 expect(section.methodName, isNotNull); |
4427 expect(section.typeArguments, isNull); | 4394 expect(section.typeArguments, isNull); |
4428 expect(section.argumentList, isNotNull); | 4395 expect(section.argumentList, isNotNull); |
4429 expect(section.argumentList.arguments, hasLength(1)); | 4396 expect(section.argumentList.arguments, hasLength(1)); |
4430 } | 4397 } |
4431 | 4398 |
4432 void test_parseCascadeSection_ii_typeArgumentComments() { | 4399 void test_parseCascadeSection_ii_typeArgumentComments() { |
4433 enableGenericMethodComments = true; | 4400 enableGenericMethodComments = true; |
4434 Expression expression = parseCascadeSection('..a/*<E>*/(b).c/*<F>*/(d)'); | 4401 Expression expression = parseCascadeSection('..a/*<E>*/(b).c/*<F>*/(d)'); |
4435 expect(expression, isNotNull); | 4402 expect(expression, isNotNull); |
4436 assertNoErrors(); | 4403 assertNoErrors(); |
4437 expect(expression, new isInstanceOf<MethodInvocation>()); | 4404 var section = expression as MethodInvocation; |
4438 MethodInvocation section = expression; | |
4439 expect(section.target, new isInstanceOf<MethodInvocation>()); | 4405 expect(section.target, new isInstanceOf<MethodInvocation>()); |
4440 expect(section.operator, isNotNull); | 4406 expect(section.operator, isNotNull); |
4441 expect(section.methodName, isNotNull); | 4407 expect(section.methodName, isNotNull); |
4442 expect(section.typeArguments, isNotNull); | 4408 expect(section.typeArguments, isNotNull); |
4443 expect(section.argumentList, isNotNull); | 4409 expect(section.argumentList, isNotNull); |
4444 expect(section.argumentList.arguments, hasLength(1)); | 4410 expect(section.argumentList.arguments, hasLength(1)); |
4445 } | 4411 } |
4446 | 4412 |
4447 void test_parseCascadeSection_ii_typeArguments() { | 4413 void test_parseCascadeSection_ii_typeArguments() { |
4448 Expression expression = parseCascadeSection('..a<E>(b).c<F>(d)'); | 4414 Expression expression = parseCascadeSection('..a<E>(b).c<F>(d)'); |
4449 expect(expression, isNotNull); | 4415 expect(expression, isNotNull); |
4450 assertNoErrors(); | 4416 assertNoErrors(); |
4451 expect(expression, new isInstanceOf<MethodInvocation>()); | 4417 var section = expression as MethodInvocation; |
4452 MethodInvocation section = expression; | |
4453 expect(section.target, new isInstanceOf<MethodInvocation>()); | 4418 expect(section.target, new isInstanceOf<MethodInvocation>()); |
4454 expect(section.operator, isNotNull); | 4419 expect(section.operator, isNotNull); |
4455 expect(section.methodName, isNotNull); | 4420 expect(section.methodName, isNotNull); |
4456 expect(section.typeArguments, isNotNull); | 4421 expect(section.typeArguments, isNotNull); |
4457 expect(section.argumentList, isNotNull); | 4422 expect(section.argumentList, isNotNull); |
4458 expect(section.argumentList.arguments, hasLength(1)); | 4423 expect(section.argumentList.arguments, hasLength(1)); |
4459 } | 4424 } |
4460 | 4425 |
4461 void test_parseCascadeSection_p() { | 4426 void test_parseCascadeSection_p() { |
4462 Expression expression = parseCascadeSection('..a'); | 4427 Expression expression = parseCascadeSection('..a'); |
4463 expect(expression, isNotNull); | 4428 expect(expression, isNotNull); |
4464 assertNoErrors(); | 4429 assertNoErrors(); |
4465 expect(expression, new isInstanceOf<PropertyAccess>()); | 4430 var section = expression as PropertyAccess; |
4466 PropertyAccess section = expression; | |
4467 expect(section.target, isNull); | 4431 expect(section.target, isNull); |
4468 expect(section.operator, isNotNull); | 4432 expect(section.operator, isNotNull); |
4469 expect(section.propertyName, isNotNull); | 4433 expect(section.propertyName, isNotNull); |
4470 } | 4434 } |
4471 | 4435 |
4472 void test_parseCascadeSection_p_assign() { | 4436 void test_parseCascadeSection_p_assign() { |
4473 Expression expression = parseCascadeSection('..a = 3'); | 4437 Expression expression = parseCascadeSection('..a = 3'); |
4474 expect(expression, isNotNull); | 4438 expect(expression, isNotNull); |
4475 assertNoErrors(); | 4439 assertNoErrors(); |
4476 expect(expression, new isInstanceOf<AssignmentExpression>()); | 4440 var section = expression as AssignmentExpression; |
4477 AssignmentExpression section = expression; | |
4478 expect(section.leftHandSide, isNotNull); | 4441 expect(section.leftHandSide, isNotNull); |
4479 expect(section.operator, isNotNull); | 4442 expect(section.operator, isNotNull); |
4480 Expression rhs = section.rightHandSide; | 4443 Expression rhs = section.rightHandSide; |
4481 expect(rhs, isNotNull); | 4444 expect(rhs, isNotNull); |
4482 } | 4445 } |
4483 | 4446 |
4484 void test_parseCascadeSection_p_assign_withCascade() { | 4447 void test_parseCascadeSection_p_assign_withCascade() { |
4485 Expression expression = parseCascadeSection('..a = 3..m()'); | 4448 Expression expression = parseCascadeSection('..a = 3..m()'); |
4486 expect(expression, isNotNull); | 4449 expect(expression, isNotNull); |
4487 assertNoErrors(); | 4450 assertNoErrors(); |
4488 expect(expression, new isInstanceOf<AssignmentExpression>()); | 4451 var section = expression as AssignmentExpression; |
4489 AssignmentExpression section = expression; | |
4490 expect(section.leftHandSide, isNotNull); | 4452 expect(section.leftHandSide, isNotNull); |
4491 expect(section.operator, isNotNull); | 4453 expect(section.operator, isNotNull); |
4492 Expression rhs = section.rightHandSide; | 4454 Expression rhs = section.rightHandSide; |
4493 EngineTestCase.assertInstanceOf( | 4455 EngineTestCase.assertInstanceOf( |
4494 (obj) => obj is IntegerLiteral, IntegerLiteral, rhs); | 4456 (obj) => obj is IntegerLiteral, IntegerLiteral, rhs); |
4495 } | 4457 } |
4496 | 4458 |
4497 void test_parseCascadeSection_p_assign_withCascade_typeArgumentComments() { | 4459 void test_parseCascadeSection_p_assign_withCascade_typeArgumentComments() { |
4498 enableGenericMethodComments = true; | 4460 enableGenericMethodComments = true; |
4499 Expression expression = parseCascadeSection('..a = 3..m/*<E>*/()'); | 4461 Expression expression = parseCascadeSection('..a = 3..m/*<E>*/()'); |
4500 expect(expression, isNotNull); | 4462 expect(expression, isNotNull); |
4501 assertNoErrors(); | 4463 assertNoErrors(); |
4502 expect(expression, new isInstanceOf<AssignmentExpression>()); | 4464 var section = expression as AssignmentExpression; |
4503 AssignmentExpression section = expression; | |
4504 expect(section.leftHandSide, isNotNull); | 4465 expect(section.leftHandSide, isNotNull); |
4505 expect(section.operator, isNotNull); | 4466 expect(section.operator, isNotNull); |
4506 Expression rhs = section.rightHandSide; | 4467 Expression rhs = section.rightHandSide; |
4507 EngineTestCase.assertInstanceOf( | 4468 EngineTestCase.assertInstanceOf( |
4508 (obj) => obj is IntegerLiteral, IntegerLiteral, rhs); | 4469 (obj) => obj is IntegerLiteral, IntegerLiteral, rhs); |
4509 } | 4470 } |
4510 | 4471 |
4511 void test_parseCascadeSection_p_assign_withCascade_typeArguments() { | 4472 void test_parseCascadeSection_p_assign_withCascade_typeArguments() { |
4512 Expression expression = parseCascadeSection('..a = 3..m<E>()'); | 4473 Expression expression = parseCascadeSection('..a = 3..m<E>()'); |
4513 expect(expression, isNotNull); | 4474 expect(expression, isNotNull); |
4514 assertNoErrors(); | 4475 assertNoErrors(); |
4515 expect(expression, new isInstanceOf<AssignmentExpression>()); | 4476 var section = expression as AssignmentExpression; |
4516 AssignmentExpression section = expression; | |
4517 expect(section.leftHandSide, isNotNull); | 4477 expect(section.leftHandSide, isNotNull); |
4518 expect(section.operator, isNotNull); | 4478 expect(section.operator, isNotNull); |
4519 Expression rhs = section.rightHandSide; | 4479 Expression rhs = section.rightHandSide; |
4520 EngineTestCase.assertInstanceOf( | 4480 EngineTestCase.assertInstanceOf( |
4521 (obj) => obj is IntegerLiteral, IntegerLiteral, rhs); | 4481 (obj) => obj is IntegerLiteral, IntegerLiteral, rhs); |
4522 } | 4482 } |
4523 | 4483 |
4524 void test_parseCascadeSection_p_builtIn() { | 4484 void test_parseCascadeSection_p_builtIn() { |
4525 Expression expression = parseCascadeSection('..as'); | 4485 Expression expression = parseCascadeSection('..as'); |
4526 expect(expression, isNotNull); | 4486 expect(expression, isNotNull); |
4527 assertNoErrors(); | 4487 assertNoErrors(); |
4528 expect(expression, new isInstanceOf<PropertyAccess>()); | 4488 var section = expression as PropertyAccess; |
4529 PropertyAccess section = expression; | |
4530 expect(section.target, isNull); | 4489 expect(section.target, isNull); |
4531 expect(section.operator, isNotNull); | 4490 expect(section.operator, isNotNull); |
4532 expect(section.propertyName, isNotNull); | 4491 expect(section.propertyName, isNotNull); |
4533 } | 4492 } |
4534 | 4493 |
4535 void test_parseCascadeSection_pa() { | 4494 void test_parseCascadeSection_pa() { |
4536 Expression expression = parseCascadeSection('..a(b)'); | 4495 Expression expression = parseCascadeSection('..a(b)'); |
4537 expect(expression, isNotNull); | 4496 expect(expression, isNotNull); |
4538 assertNoErrors(); | 4497 assertNoErrors(); |
4539 expect(expression, new isInstanceOf<MethodInvocation>()); | 4498 var section = expression as MethodInvocation; |
4540 MethodInvocation section = expression; | |
4541 expect(section.target, isNull); | 4499 expect(section.target, isNull); |
4542 expect(section.operator, isNotNull); | 4500 expect(section.operator, isNotNull); |
4543 expect(section.methodName, isNotNull); | 4501 expect(section.methodName, isNotNull); |
4544 expect(section.typeArguments, isNull); | 4502 expect(section.typeArguments, isNull); |
4545 expect(section.argumentList, isNotNull); | 4503 expect(section.argumentList, isNotNull); |
4546 expect(section.argumentList.arguments, hasLength(1)); | 4504 expect(section.argumentList.arguments, hasLength(1)); |
4547 } | 4505 } |
4548 | 4506 |
4549 void test_parseCascadeSection_pa_typeArgumentComments() { | 4507 void test_parseCascadeSection_pa_typeArgumentComments() { |
4550 enableGenericMethodComments = true; | 4508 enableGenericMethodComments = true; |
4551 Expression expression = parseCascadeSection('..a/*<E>*/(b)'); | 4509 Expression expression = parseCascadeSection('..a/*<E>*/(b)'); |
4552 expect(expression, isNotNull); | 4510 expect(expression, isNotNull); |
4553 assertNoErrors(); | 4511 assertNoErrors(); |
4554 expect(expression, new isInstanceOf<MethodInvocation>()); | 4512 var section = expression as MethodInvocation; |
4555 MethodInvocation section = expression; | |
4556 expect(section.target, isNull); | 4513 expect(section.target, isNull); |
4557 expect(section.operator, isNotNull); | 4514 expect(section.operator, isNotNull); |
4558 expect(section.methodName, isNotNull); | 4515 expect(section.methodName, isNotNull); |
4559 expect(section.typeArguments, isNotNull); | 4516 expect(section.typeArguments, isNotNull); |
4560 expect(section.argumentList, isNotNull); | 4517 expect(section.argumentList, isNotNull); |
4561 expect(section.argumentList.arguments, hasLength(1)); | 4518 expect(section.argumentList.arguments, hasLength(1)); |
4562 } | 4519 } |
4563 | 4520 |
4564 void test_parseCascadeSection_pa_typeArguments() { | 4521 void test_parseCascadeSection_pa_typeArguments() { |
4565 Expression expression = parseCascadeSection('..a<E>(b)'); | 4522 Expression expression = parseCascadeSection('..a<E>(b)'); |
4566 expect(expression, isNotNull); | 4523 expect(expression, isNotNull); |
4567 assertNoErrors(); | 4524 assertNoErrors(); |
4568 expect(expression, new isInstanceOf<MethodInvocation>()); | 4525 var section = expression as MethodInvocation; |
4569 MethodInvocation section = expression; | |
4570 expect(section.target, isNull); | 4526 expect(section.target, isNull); |
4571 expect(section.operator, isNotNull); | 4527 expect(section.operator, isNotNull); |
4572 expect(section.methodName, isNotNull); | 4528 expect(section.methodName, isNotNull); |
4573 expect(section.typeArguments, isNotNull); | 4529 expect(section.typeArguments, isNotNull); |
4574 expect(section.argumentList, isNotNull); | 4530 expect(section.argumentList, isNotNull); |
4575 expect(section.argumentList.arguments, hasLength(1)); | 4531 expect(section.argumentList.arguments, hasLength(1)); |
4576 } | 4532 } |
4577 | 4533 |
4578 void test_parseCascadeSection_paa() { | 4534 void test_parseCascadeSection_paa() { |
4579 Expression expression = parseCascadeSection('..a(b)(c)'); | 4535 Expression expression = parseCascadeSection('..a(b)(c)'); |
4580 expect(expression, isNotNull); | 4536 expect(expression, isNotNull); |
4581 assertNoErrors(); | 4537 assertNoErrors(); |
4582 expect(expression, new isInstanceOf<FunctionExpressionInvocation>()); | 4538 var section = expression as FunctionExpressionInvocation; |
4583 FunctionExpressionInvocation section = expression; | |
4584 expect(section.function, new isInstanceOf<MethodInvocation>()); | 4539 expect(section.function, new isInstanceOf<MethodInvocation>()); |
4585 expect(section.typeArguments, isNull); | 4540 expect(section.typeArguments, isNull); |
4586 expect(section.argumentList, isNotNull); | 4541 expect(section.argumentList, isNotNull); |
4587 expect(section.argumentList.arguments, hasLength(1)); | 4542 expect(section.argumentList.arguments, hasLength(1)); |
4588 } | 4543 } |
4589 | 4544 |
4590 void test_parseCascadeSection_paa_typeArgumentComments() { | 4545 void test_parseCascadeSection_paa_typeArgumentComments() { |
4591 enableGenericMethodComments = true; | 4546 enableGenericMethodComments = true; |
4592 Expression expression = parseCascadeSection('..a/*<E>*/(b)/*<F>*/(c)'); | 4547 Expression expression = parseCascadeSection('..a/*<E>*/(b)/*<F>*/(c)'); |
4593 expect(expression, isNotNull); | 4548 expect(expression, isNotNull); |
4594 assertNoErrors(); | 4549 assertNoErrors(); |
4595 expect(expression, new isInstanceOf<FunctionExpressionInvocation>()); | 4550 var section = expression as FunctionExpressionInvocation; |
4596 FunctionExpressionInvocation section = expression; | |
4597 expect(section.function, new isInstanceOf<MethodInvocation>()); | 4551 expect(section.function, new isInstanceOf<MethodInvocation>()); |
4598 expect(section.typeArguments, isNotNull); | 4552 expect(section.typeArguments, isNotNull); |
4599 expect(section.argumentList, isNotNull); | 4553 expect(section.argumentList, isNotNull); |
4600 expect(section.argumentList.arguments, hasLength(1)); | 4554 expect(section.argumentList.arguments, hasLength(1)); |
4601 } | 4555 } |
4602 | 4556 |
4603 void test_parseCascadeSection_paa_typeArguments() { | 4557 void test_parseCascadeSection_paa_typeArguments() { |
4604 Expression expression = parseCascadeSection('..a<E>(b)<F>(c)'); | 4558 Expression expression = parseCascadeSection('..a<E>(b)<F>(c)'); |
4605 expect(expression, isNotNull); | 4559 expect(expression, isNotNull); |
4606 assertNoErrors(); | 4560 assertNoErrors(); |
4607 expect(expression, new isInstanceOf<FunctionExpressionInvocation>()); | 4561 var section = expression as FunctionExpressionInvocation; |
4608 FunctionExpressionInvocation section = expression; | |
4609 expect(section.function, new isInstanceOf<MethodInvocation>()); | 4562 expect(section.function, new isInstanceOf<MethodInvocation>()); |
4610 expect(section.typeArguments, isNotNull); | 4563 expect(section.typeArguments, isNotNull); |
4611 expect(section.argumentList, isNotNull); | 4564 expect(section.argumentList, isNotNull); |
4612 expect(section.argumentList.arguments, hasLength(1)); | 4565 expect(section.argumentList.arguments, hasLength(1)); |
4613 } | 4566 } |
4614 | 4567 |
4615 void test_parseCascadeSection_paapaa() { | 4568 void test_parseCascadeSection_paapaa() { |
4616 Expression expression = parseCascadeSection('..a(b)(c).d(e)(f)'); | 4569 Expression expression = parseCascadeSection('..a(b)(c).d(e)(f)'); |
4617 expect(expression, isNotNull); | 4570 expect(expression, isNotNull); |
4618 assertNoErrors(); | 4571 assertNoErrors(); |
4619 expect(expression, new isInstanceOf<FunctionExpressionInvocation>()); | 4572 var section = expression as FunctionExpressionInvocation; |
4620 FunctionExpressionInvocation section = expression; | |
4621 expect(section.function, new isInstanceOf<MethodInvocation>()); | 4573 expect(section.function, new isInstanceOf<MethodInvocation>()); |
4622 expect(section.typeArguments, isNull); | 4574 expect(section.typeArguments, isNull); |
4623 expect(section.argumentList, isNotNull); | 4575 expect(section.argumentList, isNotNull); |
4624 expect(section.argumentList.arguments, hasLength(1)); | 4576 expect(section.argumentList.arguments, hasLength(1)); |
4625 } | 4577 } |
4626 | 4578 |
4627 void test_parseCascadeSection_paapaa_typeArgumentComments() { | 4579 void test_parseCascadeSection_paapaa_typeArgumentComments() { |
4628 enableGenericMethodComments = true; | 4580 enableGenericMethodComments = true; |
4629 Expression expression = | 4581 Expression expression = |
4630 parseCascadeSection('..a/*<E>*/(b)/*<F>*/(c).d/*<G>*/(e)/*<H>*/(f)'); | 4582 parseCascadeSection('..a/*<E>*/(b)/*<F>*/(c).d/*<G>*/(e)/*<H>*/(f)'); |
4631 expect(expression, isNotNull); | 4583 expect(expression, isNotNull); |
4632 assertNoErrors(); | 4584 assertNoErrors(); |
4633 expect(expression, new isInstanceOf<FunctionExpressionInvocation>()); | 4585 var section = expression as FunctionExpressionInvocation; |
4634 FunctionExpressionInvocation section = expression; | |
4635 expect(section.function, new isInstanceOf<MethodInvocation>()); | 4586 expect(section.function, new isInstanceOf<MethodInvocation>()); |
4636 expect(section.typeArguments, isNotNull); | 4587 expect(section.typeArguments, isNotNull); |
4637 expect(section.argumentList, isNotNull); | 4588 expect(section.argumentList, isNotNull); |
4638 expect(section.argumentList.arguments, hasLength(1)); | 4589 expect(section.argumentList.arguments, hasLength(1)); |
4639 } | 4590 } |
4640 | 4591 |
4641 void test_parseCascadeSection_paapaa_typeArguments() { | 4592 void test_parseCascadeSection_paapaa_typeArguments() { |
4642 Expression expression = | 4593 Expression expression = |
4643 parseCascadeSection('..a<E>(b)<F>(c).d<G>(e)<H>(f)'); | 4594 parseCascadeSection('..a<E>(b)<F>(c).d<G>(e)<H>(f)'); |
4644 expect(expression, isNotNull); | 4595 expect(expression, isNotNull); |
4645 assertNoErrors(); | 4596 assertNoErrors(); |
4646 expect(expression, new isInstanceOf<FunctionExpressionInvocation>()); | 4597 var section = expression as FunctionExpressionInvocation; |
4647 FunctionExpressionInvocation section = expression; | |
4648 expect(section.function, new isInstanceOf<MethodInvocation>()); | 4598 expect(section.function, new isInstanceOf<MethodInvocation>()); |
4649 expect(section.typeArguments, isNotNull); | 4599 expect(section.typeArguments, isNotNull); |
4650 expect(section.argumentList, isNotNull); | 4600 expect(section.argumentList, isNotNull); |
4651 expect(section.argumentList.arguments, hasLength(1)); | 4601 expect(section.argumentList.arguments, hasLength(1)); |
4652 } | 4602 } |
4653 | 4603 |
4654 void test_parseCascadeSection_pap() { | 4604 void test_parseCascadeSection_pap() { |
4655 Expression expression = parseCascadeSection('..a(b).c'); | 4605 Expression expression = parseCascadeSection('..a(b).c'); |
4656 expect(expression, isNotNull); | 4606 expect(expression, isNotNull); |
4657 assertNoErrors(); | 4607 assertNoErrors(); |
4658 expect(expression, new isInstanceOf<PropertyAccess>()); | 4608 var section = expression as PropertyAccess; |
4659 PropertyAccess section = expression; | |
4660 expect(section.target, isNotNull); | 4609 expect(section.target, isNotNull); |
4661 expect(section.operator, isNotNull); | 4610 expect(section.operator, isNotNull); |
4662 expect(section.propertyName, isNotNull); | 4611 expect(section.propertyName, isNotNull); |
4663 } | 4612 } |
4664 | 4613 |
4665 void test_parseCascadeSection_pap_typeArgumentComments() { | 4614 void test_parseCascadeSection_pap_typeArgumentComments() { |
4666 enableGenericMethodComments = true; | 4615 enableGenericMethodComments = true; |
4667 Expression expression = parseCascadeSection('..a/*<E>*/(b).c'); | 4616 Expression expression = parseCascadeSection('..a/*<E>*/(b).c'); |
4668 expect(expression, isNotNull); | 4617 expect(expression, isNotNull); |
4669 assertNoErrors(); | 4618 assertNoErrors(); |
4670 expect(expression, new isInstanceOf<PropertyAccess>()); | 4619 var section = expression as PropertyAccess; |
4671 PropertyAccess section = expression; | |
4672 expect(section.target, isNotNull); | 4620 expect(section.target, isNotNull); |
4673 expect(section.operator, isNotNull); | 4621 expect(section.operator, isNotNull); |
4674 expect(section.propertyName, isNotNull); | 4622 expect(section.propertyName, isNotNull); |
4675 } | 4623 } |
4676 | 4624 |
4677 void test_parseCascadeSection_pap_typeArguments() { | 4625 void test_parseCascadeSection_pap_typeArguments() { |
4678 Expression expression = parseCascadeSection('..a<E>(b).c'); | 4626 Expression expression = parseCascadeSection('..a<E>(b).c'); |
4679 expect(expression, isNotNull); | 4627 expect(expression, isNotNull); |
4680 assertNoErrors(); | 4628 assertNoErrors(); |
4681 expect(expression, new isInstanceOf<PropertyAccess>()); | 4629 var section = expression as PropertyAccess; |
4682 PropertyAccess section = expression; | |
4683 expect(section.target, isNotNull); | 4630 expect(section.target, isNotNull); |
4684 expect(section.operator, isNotNull); | 4631 expect(section.operator, isNotNull); |
4685 expect(section.propertyName, isNotNull); | 4632 expect(section.propertyName, isNotNull); |
4686 } | 4633 } |
4687 | 4634 |
4688 void test_parseConditionalExpression() { | 4635 void test_parseConditionalExpression() { |
4689 ConditionalExpression expression = parseConditionalExpression('x ? y : z'); | 4636 ConditionalExpression expression = parseConditionalExpression('x ? y : z'); |
4690 expect(expression, isNotNull); | 4637 expect(expression, isNotNull); |
4691 assertNoErrors(); | 4638 assertNoErrors(); |
4692 expect(expression.condition, isNotNull); | 4639 expect(expression.condition, isNotNull); |
(...skipping 15 matching lines...) Expand all Loading... |
4708 expect(name.type, isNotNull); | 4655 expect(name.type, isNotNull); |
4709 expect(name.period, isNull); | 4656 expect(name.period, isNull); |
4710 expect(name.name, isNull); | 4657 expect(name.name, isNull); |
4711 expect(instanceCreation.argumentList, isNotNull); | 4658 expect(instanceCreation.argumentList, isNotNull); |
4712 } | 4659 } |
4713 | 4660 |
4714 void test_parseConstExpression_listLiteral_typed() { | 4661 void test_parseConstExpression_listLiteral_typed() { |
4715 Expression expression = parseConstExpression('const <A> []'); | 4662 Expression expression = parseConstExpression('const <A> []'); |
4716 expect(expression, isNotNull); | 4663 expect(expression, isNotNull); |
4717 assertNoErrors(); | 4664 assertNoErrors(); |
4718 expect(expression, new isInstanceOf<ListLiteral>()); | 4665 var literal = expression as ListLiteral; |
4719 ListLiteral literal = expression; | |
4720 expect(literal.constKeyword, isNotNull); | 4666 expect(literal.constKeyword, isNotNull); |
4721 expect(literal.typeArguments, isNotNull); | 4667 expect(literal.typeArguments, isNotNull); |
4722 expect(literal.leftBracket, isNotNull); | 4668 expect(literal.leftBracket, isNotNull); |
4723 expect(literal.elements, hasLength(0)); | 4669 expect(literal.elements, hasLength(0)); |
4724 expect(literal.rightBracket, isNotNull); | 4670 expect(literal.rightBracket, isNotNull); |
4725 } | 4671 } |
4726 | 4672 |
4727 void test_parseConstExpression_listLiteral_typed_genericComment() { | 4673 void test_parseConstExpression_listLiteral_typed_genericComment() { |
4728 enableGenericMethodComments = true; | 4674 enableGenericMethodComments = true; |
4729 Expression expression = parseConstExpression('const /*<A>*/ []'); | 4675 Expression expression = parseConstExpression('const /*<A>*/ []'); |
4730 expect(expression, isNotNull); | 4676 expect(expression, isNotNull); |
4731 assertNoErrors(); | 4677 assertNoErrors(); |
4732 expect(expression, new isInstanceOf<ListLiteral>()); | 4678 var literal = expression as ListLiteral; |
4733 ListLiteral literal = expression; | |
4734 expect(literal.constKeyword, isNotNull); | 4679 expect(literal.constKeyword, isNotNull); |
4735 expect(literal.typeArguments, isNotNull); | 4680 expect(literal.typeArguments, isNotNull); |
4736 expect(literal.leftBracket, isNotNull); | 4681 expect(literal.leftBracket, isNotNull); |
4737 expect(literal.elements, hasLength(0)); | 4682 expect(literal.elements, hasLength(0)); |
4738 expect(literal.rightBracket, isNotNull); | 4683 expect(literal.rightBracket, isNotNull); |
4739 } | 4684 } |
4740 | 4685 |
4741 void test_parseConstExpression_listLiteral_untyped() { | 4686 void test_parseConstExpression_listLiteral_untyped() { |
4742 Expression expression = parseConstExpression('const []'); | 4687 Expression expression = parseConstExpression('const []'); |
4743 expect(expression, isNotNull); | 4688 expect(expression, isNotNull); |
4744 assertNoErrors(); | 4689 assertNoErrors(); |
4745 expect(expression, new isInstanceOf<ListLiteral>()); | 4690 var literal = expression as ListLiteral; |
4746 ListLiteral literal = expression; | |
4747 expect(literal.constKeyword, isNotNull); | 4691 expect(literal.constKeyword, isNotNull); |
4748 expect(literal.typeArguments, isNull); | 4692 expect(literal.typeArguments, isNull); |
4749 expect(literal.leftBracket, isNotNull); | 4693 expect(literal.leftBracket, isNotNull); |
4750 expect(literal.elements, hasLength(0)); | 4694 expect(literal.elements, hasLength(0)); |
4751 expect(literal.rightBracket, isNotNull); | 4695 expect(literal.rightBracket, isNotNull); |
4752 } | 4696 } |
4753 | 4697 |
4754 void test_parseConstExpression_mapLiteral_typed() { | 4698 void test_parseConstExpression_mapLiteral_typed() { |
4755 Expression expression = parseConstExpression('const <A, B> {}'); | 4699 Expression expression = parseConstExpression('const <A, B> {}'); |
4756 expect(expression, isNotNull); | 4700 expect(expression, isNotNull); |
4757 assertNoErrors(); | 4701 assertNoErrors(); |
4758 expect(expression, new isInstanceOf<MapLiteral>()); | 4702 var literal = expression as MapLiteral; |
4759 MapLiteral literal = expression; | |
4760 expect(literal.leftBracket, isNotNull); | 4703 expect(literal.leftBracket, isNotNull); |
4761 expect(literal.entries, hasLength(0)); | 4704 expect(literal.entries, hasLength(0)); |
4762 expect(literal.rightBracket, isNotNull); | 4705 expect(literal.rightBracket, isNotNull); |
4763 expect(literal.typeArguments, isNotNull); | 4706 expect(literal.typeArguments, isNotNull); |
4764 } | 4707 } |
4765 | 4708 |
4766 void test_parseConstExpression_mapLiteral_typed_genericComment() { | 4709 void test_parseConstExpression_mapLiteral_typed_genericComment() { |
4767 enableGenericMethodComments = true; | 4710 enableGenericMethodComments = true; |
4768 Expression expression = parseConstExpression('const /*<A, B>*/ {}'); | 4711 Expression expression = parseConstExpression('const /*<A, B>*/ {}'); |
4769 expect(expression, isNotNull); | 4712 expect(expression, isNotNull); |
4770 assertNoErrors(); | 4713 assertNoErrors(); |
4771 expect(expression, new isInstanceOf<MapLiteral>()); | 4714 var literal = expression as MapLiteral; |
4772 MapLiteral literal = expression; | |
4773 expect(literal.leftBracket, isNotNull); | 4715 expect(literal.leftBracket, isNotNull); |
4774 expect(literal.entries, hasLength(0)); | 4716 expect(literal.entries, hasLength(0)); |
4775 expect(literal.rightBracket, isNotNull); | 4717 expect(literal.rightBracket, isNotNull); |
4776 expect(literal.typeArguments, isNotNull); | 4718 expect(literal.typeArguments, isNotNull); |
4777 } | 4719 } |
4778 | 4720 |
4779 void test_parseConstExpression_mapLiteral_untyped() { | 4721 void test_parseConstExpression_mapLiteral_untyped() { |
4780 Expression expression = parseConstExpression('const {}'); | 4722 Expression expression = parseConstExpression('const {}'); |
4781 expect(expression, isNotNull); | 4723 expect(expression, isNotNull); |
4782 assertNoErrors(); | 4724 assertNoErrors(); |
4783 expect(expression, new isInstanceOf<MapLiteral>()); | 4725 var literal = expression as MapLiteral; |
4784 MapLiteral literal = expression; | |
4785 expect(literal.leftBracket, isNotNull); | 4726 expect(literal.leftBracket, isNotNull); |
4786 expect(literal.entries, hasLength(0)); | 4727 expect(literal.entries, hasLength(0)); |
4787 expect(literal.rightBracket, isNotNull); | 4728 expect(literal.rightBracket, isNotNull); |
4788 expect(literal.typeArguments, isNull); | 4729 expect(literal.typeArguments, isNull); |
4789 } | 4730 } |
4790 | 4731 |
4791 void test_parseEqualityExpression_normal() { | 4732 void test_parseEqualityExpression_normal() { |
4792 BinaryExpression expression = parseEqualityExpression('x == y'); | 4733 BinaryExpression expression = parseEqualityExpression('x == y'); |
4793 expect(expression, isNotNull); | 4734 expect(expression, isNotNull); |
4794 assertNoErrors(); | 4735 assertNoErrors(); |
4795 expect(expression.leftOperand, isNotNull); | 4736 expect(expression.leftOperand, isNotNull); |
4796 expect(expression.operator, isNotNull); | 4737 expect(expression.operator, isNotNull); |
4797 expect(expression.operator.type, TokenType.EQ_EQ); | 4738 expect(expression.operator.type, TokenType.EQ_EQ); |
4798 expect(expression.rightOperand, isNotNull); | 4739 expect(expression.rightOperand, isNotNull); |
4799 } | 4740 } |
4800 | 4741 |
4801 void test_parseEqualityExpression_super() { | 4742 void test_parseEqualityExpression_super() { |
4802 BinaryExpression expression = parseEqualityExpression('super == y'); | 4743 BinaryExpression expression = parseEqualityExpression('super == y'); |
4803 expect(expression, isNotNull); | 4744 expect(expression, isNotNull); |
4804 assertNoErrors(); | 4745 assertNoErrors(); |
4805 expect(expression.leftOperand, new isInstanceOf<SuperExpression>()); | 4746 expect(expression.leftOperand, new isInstanceOf<SuperExpression>()); |
4806 expect(expression.operator, isNotNull); | 4747 expect(expression.operator, isNotNull); |
4807 expect(expression.operator.type, TokenType.EQ_EQ); | 4748 expect(expression.operator.type, TokenType.EQ_EQ); |
4808 expect(expression.rightOperand, isNotNull); | 4749 expect(expression.rightOperand, isNotNull); |
4809 } | 4750 } |
4810 | 4751 |
4811 void test_parseExpression_assign() { | 4752 void test_parseExpression_assign() { |
4812 // TODO(brianwilkerson) Implement more tests for this method. | 4753 // TODO(brianwilkerson) Implement more tests for this method. |
4813 Expression expression = parseExpression('x = y'); | 4754 Expression expression = parseExpression('x = y'); |
4814 expect(expression, new isInstanceOf<AssignmentExpression>()); | 4755 var assignmentExpression = expression as AssignmentExpression; |
4815 AssignmentExpression assignmentExpression = expression; | |
4816 expect(assignmentExpression.leftHandSide, isNotNull); | 4756 expect(assignmentExpression.leftHandSide, isNotNull); |
4817 expect(assignmentExpression.operator, isNotNull); | 4757 expect(assignmentExpression.operator, isNotNull); |
4818 expect(assignmentExpression.operator.type, TokenType.EQ); | 4758 expect(assignmentExpression.operator.type, TokenType.EQ); |
4819 expect(assignmentExpression.rightHandSide, isNotNull); | 4759 expect(assignmentExpression.rightHandSide, isNotNull); |
4820 } | 4760 } |
4821 | 4761 |
4822 void test_parseExpression_assign_compound() { | 4762 void test_parseExpression_assign_compound() { |
4823 enableLazyAssignmentOperators = true; | 4763 enableLazyAssignmentOperators = true; |
4824 Expression expression = parseExpression('x ||= y'); | 4764 Expression expression = parseExpression('x ||= y'); |
4825 expect(expression, new isInstanceOf<AssignmentExpression>()); | 4765 var assignmentExpression = expression as AssignmentExpression; |
4826 AssignmentExpression assignmentExpression = expression; | |
4827 expect(assignmentExpression.leftHandSide, isNotNull); | 4766 expect(assignmentExpression.leftHandSide, isNotNull); |
4828 expect(assignmentExpression.operator, isNotNull); | 4767 expect(assignmentExpression.operator, isNotNull); |
4829 expect(assignmentExpression.operator.type, TokenType.BAR_BAR_EQ); | 4768 expect(assignmentExpression.operator.type, TokenType.BAR_BAR_EQ); |
4830 expect(assignmentExpression.rightHandSide, isNotNull); | 4769 expect(assignmentExpression.rightHandSide, isNotNull); |
4831 } | 4770 } |
4832 | 4771 |
4833 void test_parseExpression_comparison() { | 4772 void test_parseExpression_comparison() { |
4834 Expression expression = parseExpression('--a.b == c'); | 4773 Expression expression = parseExpression('--a.b == c'); |
4835 expect(expression, new isInstanceOf<BinaryExpression>()); | 4774 var binaryExpression = expression as BinaryExpression; |
4836 BinaryExpression binaryExpression = expression; | |
4837 expect(binaryExpression.leftOperand, isNotNull); | 4775 expect(binaryExpression.leftOperand, isNotNull); |
4838 expect(binaryExpression.operator, isNotNull); | 4776 expect(binaryExpression.operator, isNotNull); |
4839 expect(binaryExpression.operator.type, TokenType.EQ_EQ); | 4777 expect(binaryExpression.operator.type, TokenType.EQ_EQ); |
4840 expect(binaryExpression.rightOperand, isNotNull); | 4778 expect(binaryExpression.rightOperand, isNotNull); |
4841 } | 4779 } |
4842 | 4780 |
4843 void test_parseExpression_function_async() { | 4781 void test_parseExpression_function_async() { |
4844 Expression expression = parseExpression('() async {}'); | 4782 Expression expression = parseExpression('() async {}'); |
4845 expect(expression, new isInstanceOf<FunctionExpression>()); | 4783 var functionExpression = expression as FunctionExpression; |
4846 FunctionExpression functionExpression = expression; | |
4847 expect(functionExpression.body, isNotNull); | 4784 expect(functionExpression.body, isNotNull); |
4848 expect(functionExpression.body.isAsynchronous, isTrue); | 4785 expect(functionExpression.body.isAsynchronous, isTrue); |
4849 expect(functionExpression.body.isGenerator, isFalse); | 4786 expect(functionExpression.body.isGenerator, isFalse); |
4850 expect(functionExpression.parameters, isNotNull); | 4787 expect(functionExpression.parameters, isNotNull); |
4851 } | 4788 } |
4852 | 4789 |
4853 void test_parseExpression_function_asyncStar() { | 4790 void test_parseExpression_function_asyncStar() { |
4854 Expression expression = parseExpression('() async* {}'); | 4791 Expression expression = parseExpression('() async* {}'); |
4855 expect(expression, new isInstanceOf<FunctionExpression>()); | 4792 var functionExpression = expression as FunctionExpression; |
4856 FunctionExpression functionExpression = expression; | |
4857 expect(functionExpression.body, isNotNull); | 4793 expect(functionExpression.body, isNotNull); |
4858 expect(functionExpression.body.isAsynchronous, isTrue); | 4794 expect(functionExpression.body.isAsynchronous, isTrue); |
4859 expect(functionExpression.body.isGenerator, isTrue); | 4795 expect(functionExpression.body.isGenerator, isTrue); |
4860 expect(functionExpression.parameters, isNotNull); | 4796 expect(functionExpression.parameters, isNotNull); |
4861 } | 4797 } |
4862 | 4798 |
4863 void test_parseExpression_function_sync() { | 4799 void test_parseExpression_function_sync() { |
4864 Expression expression = parseExpression('() {}'); | 4800 Expression expression = parseExpression('() {}'); |
4865 expect(expression, new isInstanceOf<FunctionExpression>()); | 4801 var functionExpression = expression as FunctionExpression; |
4866 FunctionExpression functionExpression = expression; | |
4867 expect(functionExpression.body, isNotNull); | 4802 expect(functionExpression.body, isNotNull); |
4868 expect(functionExpression.body.isAsynchronous, isFalse); | 4803 expect(functionExpression.body.isAsynchronous, isFalse); |
4869 expect(functionExpression.body.isGenerator, isFalse); | 4804 expect(functionExpression.body.isGenerator, isFalse); |
4870 expect(functionExpression.parameters, isNotNull); | 4805 expect(functionExpression.parameters, isNotNull); |
4871 } | 4806 } |
4872 | 4807 |
4873 void test_parseExpression_function_syncStar() { | 4808 void test_parseExpression_function_syncStar() { |
4874 Expression expression = parseExpression('() sync* {}'); | 4809 Expression expression = parseExpression('() sync* {}'); |
4875 expect(expression, new isInstanceOf<FunctionExpression>()); | 4810 var functionExpression = expression as FunctionExpression; |
4876 FunctionExpression functionExpression = expression; | |
4877 expect(functionExpression.body, isNotNull); | 4811 expect(functionExpression.body, isNotNull); |
4878 expect(functionExpression.body.isAsynchronous, isFalse); | 4812 expect(functionExpression.body.isAsynchronous, isFalse); |
4879 expect(functionExpression.body.isGenerator, isTrue); | 4813 expect(functionExpression.body.isGenerator, isTrue); |
4880 expect(functionExpression.parameters, isNotNull); | 4814 expect(functionExpression.parameters, isNotNull); |
4881 } | 4815 } |
4882 | 4816 |
4883 void test_parseExpression_invokeFunctionExpression() { | 4817 void test_parseExpression_invokeFunctionExpression() { |
4884 Expression expression = parseExpression('(a) {return a + a;} (3)'); | 4818 Expression expression = parseExpression('(a) {return a + a;} (3)'); |
4885 expect(expression, new isInstanceOf<FunctionExpressionInvocation>()); | 4819 var invocation = expression as FunctionExpressionInvocation; |
4886 FunctionExpressionInvocation invocation = expression; | |
4887 expect(invocation.function, new isInstanceOf<FunctionExpression>()); | 4820 expect(invocation.function, new isInstanceOf<FunctionExpression>()); |
4888 FunctionExpression functionExpression = | 4821 FunctionExpression functionExpression = |
4889 invocation.function as FunctionExpression; | 4822 invocation.function as FunctionExpression; |
4890 expect(functionExpression.parameters, isNotNull); | 4823 expect(functionExpression.parameters, isNotNull); |
4891 expect(functionExpression.body, isNotNull); | 4824 expect(functionExpression.body, isNotNull); |
4892 expect(invocation.typeArguments, isNull); | 4825 expect(invocation.typeArguments, isNull); |
4893 ArgumentList list = invocation.argumentList; | 4826 ArgumentList list = invocation.argumentList; |
4894 expect(list, isNotNull); | 4827 expect(list, isNotNull); |
4895 expect(list.arguments, hasLength(1)); | 4828 expect(list.arguments, hasLength(1)); |
4896 } | 4829 } |
4897 | 4830 |
4898 void test_parseExpression_nonAwait() { | 4831 void test_parseExpression_nonAwait() { |
4899 Expression expression = parseExpression('await()'); | 4832 Expression expression = parseExpression('await()'); |
4900 expect(expression, new isInstanceOf<MethodInvocation>()); | 4833 var invocation = expression as MethodInvocation; |
4901 MethodInvocation invocation = expression; | |
4902 expect(invocation.methodName.name, 'await'); | 4834 expect(invocation.methodName.name, 'await'); |
4903 expect(invocation.typeArguments, isNull); | 4835 expect(invocation.typeArguments, isNull); |
4904 expect(invocation.argumentList, isNotNull); | 4836 expect(invocation.argumentList, isNotNull); |
4905 } | 4837 } |
4906 | 4838 |
4907 void test_parseExpression_superMethodInvocation() { | 4839 void test_parseExpression_superMethodInvocation() { |
4908 Expression expression = parseExpression('super.m()'); | 4840 Expression expression = parseExpression('super.m()'); |
4909 expect(expression, new isInstanceOf<MethodInvocation>()); | 4841 var invocation = expression as MethodInvocation; |
4910 MethodInvocation invocation = expression; | |
4911 expect(invocation.target, isNotNull); | 4842 expect(invocation.target, isNotNull); |
4912 expect(invocation.methodName, isNotNull); | 4843 expect(invocation.methodName, isNotNull); |
4913 expect(invocation.typeArguments, isNull); | 4844 expect(invocation.typeArguments, isNull); |
4914 expect(invocation.argumentList, isNotNull); | 4845 expect(invocation.argumentList, isNotNull); |
4915 } | 4846 } |
4916 | 4847 |
4917 void test_parseExpression_superMethodInvocation_typeArgumentComments() { | 4848 void test_parseExpression_superMethodInvocation_typeArgumentComments() { |
4918 enableGenericMethodComments = true; | 4849 enableGenericMethodComments = true; |
4919 Expression expression = parseExpression('super.m/*<E>*/()'); | 4850 Expression expression = parseExpression('super.m/*<E>*/()'); |
4920 expect(expression, new isInstanceOf<MethodInvocation>()); | 4851 var invocation = expression as MethodInvocation; |
4921 MethodInvocation invocation = expression; | |
4922 expect(invocation.target, isNotNull); | 4852 expect(invocation.target, isNotNull); |
4923 expect(invocation.methodName, isNotNull); | 4853 expect(invocation.methodName, isNotNull); |
4924 expect(invocation.typeArguments, isNotNull); | 4854 expect(invocation.typeArguments, isNotNull); |
4925 expect(invocation.argumentList, isNotNull); | 4855 expect(invocation.argumentList, isNotNull); |
4926 } | 4856 } |
4927 | 4857 |
4928 void test_parseExpression_superMethodInvocation_typeArguments() { | 4858 void test_parseExpression_superMethodInvocation_typeArguments() { |
4929 Expression expression = parseExpression('super.m<E>()'); | 4859 Expression expression = parseExpression('super.m<E>()'); |
4930 expect(expression, new isInstanceOf<MethodInvocation>()); | 4860 var invocation = expression as MethodInvocation; |
4931 MethodInvocation invocation = expression; | |
4932 expect(invocation.target, isNotNull); | 4861 expect(invocation.target, isNotNull); |
4933 expect(invocation.methodName, isNotNull); | 4862 expect(invocation.methodName, isNotNull); |
4934 expect(invocation.typeArguments, isNotNull); | 4863 expect(invocation.typeArguments, isNotNull); |
4935 expect(invocation.argumentList, isNotNull); | 4864 expect(invocation.argumentList, isNotNull); |
4936 } | 4865 } |
4937 | 4866 |
4938 void test_parseExpressionList_multiple() { | 4867 void test_parseExpressionList_multiple() { |
4939 List<Expression> result = parseExpressionList('1, 2, 3'); | 4868 List<Expression> result = parseExpressionList('1, 2, 3'); |
4940 expect(result, isNotNull); | 4869 expect(result, isNotNull); |
4941 assertNoErrors(); | 4870 assertNoErrors(); |
4942 expect(result, hasLength(3)); | 4871 expect(result, hasLength(3)); |
4943 } | 4872 } |
4944 | 4873 |
4945 void test_parseExpressionList_single() { | 4874 void test_parseExpressionList_single() { |
4946 List<Expression> result = parseExpressionList('1'); | 4875 List<Expression> result = parseExpressionList('1'); |
4947 expect(result, isNotNull); | 4876 expect(result, isNotNull); |
4948 assertNoErrors(); | 4877 assertNoErrors(); |
4949 expect(result, hasLength(1)); | 4878 expect(result, hasLength(1)); |
4950 } | 4879 } |
4951 | 4880 |
4952 void test_parseExpressionWithoutCascade_assign() { | 4881 void test_parseExpressionWithoutCascade_assign() { |
4953 // TODO(brianwilkerson) Implement more tests for this method. | 4882 // TODO(brianwilkerson) Implement more tests for this method. |
4954 Expression expression = parseExpressionWithoutCascade('x = y'); | 4883 Expression expression = parseExpressionWithoutCascade('x = y'); |
4955 expect(expression, isNotNull); | 4884 expect(expression, isNotNull); |
4956 assertNoErrors(); | 4885 assertNoErrors(); |
4957 expect(expression, new isInstanceOf<AssignmentExpression>()); | 4886 var assignmentExpression = expression as AssignmentExpression; |
4958 AssignmentExpression assignmentExpression = expression; | |
4959 expect(assignmentExpression.leftHandSide, isNotNull); | 4887 expect(assignmentExpression.leftHandSide, isNotNull); |
4960 expect(assignmentExpression.operator, isNotNull); | 4888 expect(assignmentExpression.operator, isNotNull); |
4961 expect(assignmentExpression.operator.type, TokenType.EQ); | 4889 expect(assignmentExpression.operator.type, TokenType.EQ); |
4962 expect(assignmentExpression.rightHandSide, isNotNull); | 4890 expect(assignmentExpression.rightHandSide, isNotNull); |
4963 } | 4891 } |
4964 | 4892 |
4965 void test_parseExpressionWithoutCascade_comparison() { | 4893 void test_parseExpressionWithoutCascade_comparison() { |
4966 Expression expression = parseExpressionWithoutCascade('--a.b == c'); | 4894 Expression expression = parseExpressionWithoutCascade('--a.b == c'); |
4967 expect(expression, isNotNull); | 4895 expect(expression, isNotNull); |
4968 assertNoErrors(); | 4896 assertNoErrors(); |
4969 expect(expression, new isInstanceOf<BinaryExpression>()); | 4897 var binaryExpression = expression as BinaryExpression; |
4970 BinaryExpression binaryExpression = expression; | |
4971 expect(binaryExpression.leftOperand, isNotNull); | 4898 expect(binaryExpression.leftOperand, isNotNull); |
4972 expect(binaryExpression.operator, isNotNull); | 4899 expect(binaryExpression.operator, isNotNull); |
4973 expect(binaryExpression.operator.type, TokenType.EQ_EQ); | 4900 expect(binaryExpression.operator.type, TokenType.EQ_EQ); |
4974 expect(binaryExpression.rightOperand, isNotNull); | 4901 expect(binaryExpression.rightOperand, isNotNull); |
4975 } | 4902 } |
4976 | 4903 |
4977 void test_parseExpressionWithoutCascade_superMethodInvocation() { | 4904 void test_parseExpressionWithoutCascade_superMethodInvocation() { |
4978 Expression expression = parseExpressionWithoutCascade('super.m()'); | 4905 Expression expression = parseExpressionWithoutCascade('super.m()'); |
4979 expect(expression, isNotNull); | 4906 expect(expression, isNotNull); |
4980 assertNoErrors(); | 4907 assertNoErrors(); |
4981 expect(expression, new isInstanceOf<MethodInvocation>()); | 4908 var invocation = expression as MethodInvocation; |
4982 MethodInvocation invocation = expression; | |
4983 expect(invocation.target, isNotNull); | 4909 expect(invocation.target, isNotNull); |
4984 expect(invocation.methodName, isNotNull); | 4910 expect(invocation.methodName, isNotNull); |
4985 expect(invocation.typeArguments, isNull); | 4911 expect(invocation.typeArguments, isNull); |
4986 expect(invocation.argumentList, isNotNull); | 4912 expect(invocation.argumentList, isNotNull); |
4987 } | 4913 } |
4988 | 4914 |
4989 void | 4915 void |
4990 test_parseExpressionWithoutCascade_superMethodInvocation_typeArgumentComme
nts() { | 4916 test_parseExpressionWithoutCascade_superMethodInvocation_typeArgumentComme
nts() { |
4991 enableGenericMethodComments = true; | 4917 enableGenericMethodComments = true; |
4992 Expression expression = parseExpressionWithoutCascade('super.m/*<E>*/()'); | 4918 Expression expression = parseExpressionWithoutCascade('super.m/*<E>*/()'); |
4993 expect(expression, isNotNull); | 4919 expect(expression, isNotNull); |
4994 assertNoErrors(); | 4920 assertNoErrors(); |
4995 expect(expression, new isInstanceOf<MethodInvocation>()); | 4921 var invocation = expression as MethodInvocation; |
4996 MethodInvocation invocation = expression; | |
4997 expect(invocation.target, isNotNull); | 4922 expect(invocation.target, isNotNull); |
4998 expect(invocation.methodName, isNotNull); | 4923 expect(invocation.methodName, isNotNull); |
4999 expect(invocation.typeArguments, isNotNull); | 4924 expect(invocation.typeArguments, isNotNull); |
5000 expect(invocation.argumentList, isNotNull); | 4925 expect(invocation.argumentList, isNotNull); |
5001 } | 4926 } |
5002 | 4927 |
5003 void | 4928 void |
5004 test_parseExpressionWithoutCascade_superMethodInvocation_typeArguments() { | 4929 test_parseExpressionWithoutCascade_superMethodInvocation_typeArguments() { |
5005 Expression expression = parseExpressionWithoutCascade('super.m<E>()'); | 4930 Expression expression = parseExpressionWithoutCascade('super.m<E>()'); |
5006 expect(expression, isNotNull); | 4931 expect(expression, isNotNull); |
5007 assertNoErrors(); | 4932 assertNoErrors(); |
5008 expect(expression, new isInstanceOf<MethodInvocation>()); | 4933 var invocation = expression as MethodInvocation; |
5009 MethodInvocation invocation = expression; | |
5010 expect(invocation.target, isNotNull); | 4934 expect(invocation.target, isNotNull); |
5011 expect(invocation.methodName, isNotNull); | 4935 expect(invocation.methodName, isNotNull); |
5012 expect(invocation.typeArguments, isNotNull); | 4936 expect(invocation.typeArguments, isNotNull); |
5013 expect(invocation.argumentList, isNotNull); | 4937 expect(invocation.argumentList, isNotNull); |
5014 } | 4938 } |
5015 | 4939 |
5016 void test_parseFunctionExpression_body_inExpression() { | 4940 void test_parseFunctionExpression_body_inExpression() { |
5017 FunctionExpression expression = parseFunctionExpression('(int i) => i++'); | 4941 FunctionExpression expression = parseFunctionExpression('(int i) => i++'); |
5018 expect(expression, isNotNull); | 4942 expect(expression, isNotNull); |
5019 assertNoErrors(); | 4943 assertNoErrors(); |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5346 expect(literal.typeArguments, isNotNull); | 5270 expect(literal.typeArguments, isNotNull); |
5347 expect(literal.leftBracket, isNotNull); | 5271 expect(literal.leftBracket, isNotNull); |
5348 expect(literal.elements, hasLength(1)); | 5272 expect(literal.elements, hasLength(1)); |
5349 expect(literal.rightBracket, isNotNull); | 5273 expect(literal.rightBracket, isNotNull); |
5350 } | 5274 } |
5351 | 5275 |
5352 void test_parseListOrMapLiteral_list_noType() { | 5276 void test_parseListOrMapLiteral_list_noType() { |
5353 TypedLiteral literal = parseListOrMapLiteral(null, '[1]'); | 5277 TypedLiteral literal = parseListOrMapLiteral(null, '[1]'); |
5354 expect(literal, isNotNull); | 5278 expect(literal, isNotNull); |
5355 assertNoErrors(); | 5279 assertNoErrors(); |
5356 expect(literal, new isInstanceOf<ListLiteral>()); | 5280 var listLiteral = literal as ListLiteral; |
5357 ListLiteral listLiteral = literal; | |
5358 expect(listLiteral.constKeyword, isNull); | 5281 expect(listLiteral.constKeyword, isNull); |
5359 expect(listLiteral.typeArguments, isNull); | 5282 expect(listLiteral.typeArguments, isNull); |
5360 expect(listLiteral.leftBracket, isNotNull); | 5283 expect(listLiteral.leftBracket, isNotNull); |
5361 expect(listLiteral.elements, hasLength(1)); | 5284 expect(listLiteral.elements, hasLength(1)); |
5362 expect(listLiteral.rightBracket, isNotNull); | 5285 expect(listLiteral.rightBracket, isNotNull); |
5363 } | 5286 } |
5364 | 5287 |
5365 void test_parseListOrMapLiteral_list_type() { | 5288 void test_parseListOrMapLiteral_list_type() { |
5366 TypedLiteral literal = parseListOrMapLiteral(null, '<int> [1]'); | 5289 TypedLiteral literal = parseListOrMapLiteral(null, '<int> [1]'); |
5367 expect(literal, isNotNull); | 5290 expect(literal, isNotNull); |
5368 assertNoErrors(); | 5291 assertNoErrors(); |
5369 expect(literal, new isInstanceOf<ListLiteral>()); | 5292 var listLiteral = literal as ListLiteral; |
5370 ListLiteral listLiteral = literal; | |
5371 expect(listLiteral.constKeyword, isNull); | 5293 expect(listLiteral.constKeyword, isNull); |
5372 expect(listLiteral.typeArguments, isNotNull); | 5294 expect(listLiteral.typeArguments, isNotNull); |
5373 expect(listLiteral.leftBracket, isNotNull); | 5295 expect(listLiteral.leftBracket, isNotNull); |
5374 expect(listLiteral.elements, hasLength(1)); | 5296 expect(listLiteral.elements, hasLength(1)); |
5375 expect(listLiteral.rightBracket, isNotNull); | 5297 expect(listLiteral.rightBracket, isNotNull); |
5376 } | 5298 } |
5377 | 5299 |
5378 void test_parseListOrMapLiteral_map_noType() { | 5300 void test_parseListOrMapLiteral_map_noType() { |
5379 TypedLiteral literal = parseListOrMapLiteral(null, "{'1' : 1}"); | 5301 TypedLiteral literal = parseListOrMapLiteral(null, "{'1' : 1}"); |
5380 expect(literal, isNotNull); | 5302 expect(literal, isNotNull); |
5381 assertNoErrors(); | 5303 assertNoErrors(); |
5382 expect(literal, new isInstanceOf<MapLiteral>()); | 5304 var mapLiteral = literal as MapLiteral; |
5383 MapLiteral mapLiteral = literal; | |
5384 expect(mapLiteral.constKeyword, isNull); | 5305 expect(mapLiteral.constKeyword, isNull); |
5385 expect(mapLiteral.typeArguments, isNull); | 5306 expect(mapLiteral.typeArguments, isNull); |
5386 expect(mapLiteral.leftBracket, isNotNull); | 5307 expect(mapLiteral.leftBracket, isNotNull); |
5387 expect(mapLiteral.entries, hasLength(1)); | 5308 expect(mapLiteral.entries, hasLength(1)); |
5388 expect(mapLiteral.rightBracket, isNotNull); | 5309 expect(mapLiteral.rightBracket, isNotNull); |
5389 } | 5310 } |
5390 | 5311 |
5391 void test_parseListOrMapLiteral_map_type() { | 5312 void test_parseListOrMapLiteral_map_type() { |
5392 TypedLiteral literal = | 5313 TypedLiteral literal = |
5393 parseListOrMapLiteral(null, "<String, int> {'1' : 1}"); | 5314 parseListOrMapLiteral(null, "<String, int> {'1' : 1}"); |
5394 expect(literal, isNotNull); | 5315 expect(literal, isNotNull); |
5395 assertNoErrors(); | 5316 assertNoErrors(); |
5396 expect(literal, new isInstanceOf<MapLiteral>()); | 5317 var mapLiteral = literal as MapLiteral; |
5397 MapLiteral mapLiteral = literal; | |
5398 expect(mapLiteral.constKeyword, isNull); | 5318 expect(mapLiteral.constKeyword, isNull); |
5399 expect(mapLiteral.typeArguments, isNotNull); | 5319 expect(mapLiteral.typeArguments, isNotNull); |
5400 expect(mapLiteral.leftBracket, isNotNull); | 5320 expect(mapLiteral.leftBracket, isNotNull); |
5401 expect(mapLiteral.entries, hasLength(1)); | 5321 expect(mapLiteral.entries, hasLength(1)); |
5402 expect(mapLiteral.rightBracket, isNotNull); | 5322 expect(mapLiteral.rightBracket, isNotNull); |
5403 } | 5323 } |
5404 | 5324 |
5405 void test_parseLogicalAndExpression() { | 5325 void test_parseLogicalAndExpression() { |
5406 Expression expression = parseLogicalAndExpression('x && y'); | 5326 Expression expression = parseLogicalAndExpression('x && y'); |
5407 expect(expression, isNotNull); | 5327 expect(expression, isNotNull); |
5408 assertNoErrors(); | 5328 assertNoErrors(); |
5409 expect(expression, new isInstanceOf<BinaryExpression>()); | 5329 var binaryExpression = expression as BinaryExpression; |
5410 BinaryExpression binaryExpression = expression; | |
5411 expect(binaryExpression.leftOperand, isNotNull); | 5330 expect(binaryExpression.leftOperand, isNotNull); |
5412 expect(binaryExpression.operator, isNotNull); | 5331 expect(binaryExpression.operator, isNotNull); |
5413 expect(binaryExpression.operator.type, TokenType.AMPERSAND_AMPERSAND); | 5332 expect(binaryExpression.operator.type, TokenType.AMPERSAND_AMPERSAND); |
5414 expect(binaryExpression.rightOperand, isNotNull); | 5333 expect(binaryExpression.rightOperand, isNotNull); |
5415 } | 5334 } |
5416 | 5335 |
5417 void test_parseLogicalOrExpression() { | 5336 void test_parseLogicalOrExpression() { |
5418 Expression expression = parseLogicalOrExpression('x || y'); | 5337 Expression expression = parseLogicalOrExpression('x || y'); |
5419 expect(expression, isNotNull); | 5338 expect(expression, isNotNull); |
5420 assertNoErrors(); | 5339 assertNoErrors(); |
5421 expect(expression, new isInstanceOf<BinaryExpression>()); | 5340 var binaryExpression = expression as BinaryExpression; |
5422 BinaryExpression binaryExpression = expression; | |
5423 expect(binaryExpression.leftOperand, isNotNull); | 5341 expect(binaryExpression.leftOperand, isNotNull); |
5424 expect(binaryExpression.operator, isNotNull); | 5342 expect(binaryExpression.operator, isNotNull); |
5425 expect(binaryExpression.operator.type, TokenType.BAR_BAR); | 5343 expect(binaryExpression.operator.type, TokenType.BAR_BAR); |
5426 expect(binaryExpression.rightOperand, isNotNull); | 5344 expect(binaryExpression.rightOperand, isNotNull); |
5427 } | 5345 } |
5428 | 5346 |
5429 void test_parseMapLiteral_empty() { | 5347 void test_parseMapLiteral_empty() { |
5430 Token token = TokenFactory.tokenFromKeyword(Keyword.CONST); | 5348 Token token = TokenFactory.tokenFromKeyword(Keyword.CONST); |
5431 MapLiteral literal = parseMapLiteral(token, '<String, int>', '{}'); | 5349 MapLiteral literal = parseMapLiteral(token, '<String, int>', '{}'); |
5432 expect(literal, isNotNull); | 5350 expect(literal, isNotNull); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5480 assertNoErrors(); | 5398 assertNoErrors(); |
5481 expect(entry.key, isNotNull); | 5399 expect(entry.key, isNotNull); |
5482 expect(entry.separator, isNotNull); | 5400 expect(entry.separator, isNotNull); |
5483 expect(entry.value, isNotNull); | 5401 expect(entry.value, isNotNull); |
5484 } | 5402 } |
5485 | 5403 |
5486 void test_parseMultiplicativeExpression_normal() { | 5404 void test_parseMultiplicativeExpression_normal() { |
5487 Expression expression = parseMultiplicativeExpression('x * y'); | 5405 Expression expression = parseMultiplicativeExpression('x * y'); |
5488 expect(expression, isNotNull); | 5406 expect(expression, isNotNull); |
5489 assertNoErrors(); | 5407 assertNoErrors(); |
5490 expect(expression, new isInstanceOf<BinaryExpression>()); | 5408 var binaryExpression = expression as BinaryExpression; |
5491 BinaryExpression binaryExpression = expression; | |
5492 expect(binaryExpression.leftOperand, isNotNull); | 5409 expect(binaryExpression.leftOperand, isNotNull); |
5493 expect(binaryExpression.operator, isNotNull); | 5410 expect(binaryExpression.operator, isNotNull); |
5494 expect(binaryExpression.operator.type, TokenType.STAR); | 5411 expect(binaryExpression.operator.type, TokenType.STAR); |
5495 expect(binaryExpression.rightOperand, isNotNull); | 5412 expect(binaryExpression.rightOperand, isNotNull); |
5496 } | 5413 } |
5497 | 5414 |
5498 void test_parseMultiplicativeExpression_super() { | 5415 void test_parseMultiplicativeExpression_super() { |
5499 Expression expression = parseMultiplicativeExpression('super * y'); | 5416 Expression expression = parseMultiplicativeExpression('super * y'); |
5500 expect(expression, isNotNull); | 5417 expect(expression, isNotNull); |
5501 assertNoErrors(); | 5418 assertNoErrors(); |
5502 expect(expression, new isInstanceOf<BinaryExpression>()); | 5419 var binaryExpression = expression as BinaryExpression; |
5503 BinaryExpression binaryExpression = expression; | |
5504 expect(binaryExpression.leftOperand, new isInstanceOf<SuperExpression>()); | 5420 expect(binaryExpression.leftOperand, new isInstanceOf<SuperExpression>()); |
5505 expect(binaryExpression.operator, isNotNull); | 5421 expect(binaryExpression.operator, isNotNull); |
5506 expect(binaryExpression.operator.type, TokenType.STAR); | 5422 expect(binaryExpression.operator.type, TokenType.STAR); |
5507 expect(binaryExpression.rightOperand, isNotNull); | 5423 expect(binaryExpression.rightOperand, isNotNull); |
5508 } | 5424 } |
5509 | 5425 |
5510 void test_parseNewExpression() { | 5426 void test_parseNewExpression() { |
5511 InstanceCreationExpression expression = parseNewExpression('new A()'); | 5427 InstanceCreationExpression expression = parseNewExpression('new A()'); |
5512 expect(expression, isNotNull); | 5428 expect(expression, isNotNull); |
5513 assertNoErrors(); | 5429 assertNoErrors(); |
5514 expect(expression.keyword, isNotNull); | 5430 expect(expression.keyword, isNotNull); |
5515 ConstructorName name = expression.constructorName; | 5431 ConstructorName name = expression.constructorName; |
5516 expect(name, isNotNull); | 5432 expect(name, isNotNull); |
5517 expect(name.type, isNotNull); | 5433 expect(name.type, isNotNull); |
5518 expect(name.period, isNull); | 5434 expect(name.period, isNull); |
5519 expect(name.name, isNull); | 5435 expect(name.name, isNull); |
5520 expect(expression.argumentList, isNotNull); | 5436 expect(expression.argumentList, isNotNull); |
5521 } | 5437 } |
5522 | 5438 |
5523 void test_parsePostfixExpression_decrement() { | 5439 void test_parsePostfixExpression_decrement() { |
5524 Expression expression = parsePostfixExpression('i--'); | 5440 Expression expression = parsePostfixExpression('i--'); |
5525 expect(expression, isNotNull); | 5441 expect(expression, isNotNull); |
5526 assertNoErrors(); | 5442 assertNoErrors(); |
5527 expect(expression, new isInstanceOf<PostfixExpression>()); | 5443 var postfixExpression = expression as PostfixExpression; |
5528 PostfixExpression postfixExpression = expression; | |
5529 expect(postfixExpression.operand, isNotNull); | 5444 expect(postfixExpression.operand, isNotNull); |
5530 expect(postfixExpression.operator, isNotNull); | 5445 expect(postfixExpression.operator, isNotNull); |
5531 expect(postfixExpression.operator.type, TokenType.MINUS_MINUS); | 5446 expect(postfixExpression.operator.type, TokenType.MINUS_MINUS); |
5532 } | 5447 } |
5533 | 5448 |
5534 void test_parsePostfixExpression_increment() { | 5449 void test_parsePostfixExpression_increment() { |
5535 Expression expression = parsePostfixExpression('i++'); | 5450 Expression expression = parsePostfixExpression('i++'); |
5536 expect(expression, isNotNull); | 5451 expect(expression, isNotNull); |
5537 assertNoErrors(); | 5452 assertNoErrors(); |
5538 expect(expression, new isInstanceOf<PostfixExpression>()); | 5453 var postfixExpression = expression as PostfixExpression; |
5539 PostfixExpression postfixExpression = expression; | |
5540 expect(postfixExpression.operand, isNotNull); | 5454 expect(postfixExpression.operand, isNotNull); |
5541 expect(postfixExpression.operator, isNotNull); | 5455 expect(postfixExpression.operator, isNotNull); |
5542 expect(postfixExpression.operator.type, TokenType.PLUS_PLUS); | 5456 expect(postfixExpression.operator.type, TokenType.PLUS_PLUS); |
5543 } | 5457 } |
5544 | 5458 |
5545 void test_parsePostfixExpression_none_indexExpression() { | 5459 void test_parsePostfixExpression_none_indexExpression() { |
5546 Expression expression = parsePostfixExpression('a[0]'); | 5460 Expression expression = parsePostfixExpression('a[0]'); |
5547 expect(expression, isNotNull); | 5461 expect(expression, isNotNull); |
5548 assertNoErrors(); | 5462 assertNoErrors(); |
5549 expect(expression, new isInstanceOf<IndexExpression>()); | 5463 var indexExpression = expression as IndexExpression; |
5550 IndexExpression indexExpression = expression; | |
5551 expect(indexExpression.target, isNotNull); | 5464 expect(indexExpression.target, isNotNull); |
5552 expect(indexExpression.index, isNotNull); | 5465 expect(indexExpression.index, isNotNull); |
5553 } | 5466 } |
5554 | 5467 |
5555 void test_parsePostfixExpression_none_methodInvocation() { | 5468 void test_parsePostfixExpression_none_methodInvocation() { |
5556 Expression expression = parsePostfixExpression('a.m()'); | 5469 Expression expression = parsePostfixExpression('a.m()'); |
5557 expect(expression, isNotNull); | 5470 expect(expression, isNotNull); |
5558 assertNoErrors(); | 5471 assertNoErrors(); |
5559 expect(expression, new isInstanceOf<MethodInvocation>()); | 5472 var methodInvocation = expression as MethodInvocation; |
5560 MethodInvocation methodInvocation = expression; | |
5561 expect(methodInvocation.target, isNotNull); | 5473 expect(methodInvocation.target, isNotNull); |
5562 expect(methodInvocation.operator.type, TokenType.PERIOD); | 5474 expect(methodInvocation.operator.type, TokenType.PERIOD); |
5563 expect(methodInvocation.methodName, isNotNull); | 5475 expect(methodInvocation.methodName, isNotNull); |
5564 expect(methodInvocation.typeArguments, isNull); | 5476 expect(methodInvocation.typeArguments, isNull); |
5565 expect(methodInvocation.argumentList, isNotNull); | 5477 expect(methodInvocation.argumentList, isNotNull); |
5566 } | 5478 } |
5567 | 5479 |
5568 void test_parsePostfixExpression_none_methodInvocation_question_dot() { | 5480 void test_parsePostfixExpression_none_methodInvocation_question_dot() { |
5569 Expression expression = parsePostfixExpression('a?.m()'); | 5481 Expression expression = parsePostfixExpression('a?.m()'); |
5570 expect(expression, isNotNull); | 5482 expect(expression, isNotNull); |
5571 assertNoErrors(); | 5483 assertNoErrors(); |
5572 expect(expression, new isInstanceOf<MethodInvocation>()); | 5484 var methodInvocation = expression as MethodInvocation; |
5573 MethodInvocation methodInvocation = expression; | |
5574 expect(methodInvocation.target, isNotNull); | 5485 expect(methodInvocation.target, isNotNull); |
5575 expect(methodInvocation.operator.type, TokenType.QUESTION_PERIOD); | 5486 expect(methodInvocation.operator.type, TokenType.QUESTION_PERIOD); |
5576 expect(methodInvocation.methodName, isNotNull); | 5487 expect(methodInvocation.methodName, isNotNull); |
5577 expect(methodInvocation.typeArguments, isNull); | 5488 expect(methodInvocation.typeArguments, isNull); |
5578 expect(methodInvocation.argumentList, isNotNull); | 5489 expect(methodInvocation.argumentList, isNotNull); |
5579 } | 5490 } |
5580 | 5491 |
5581 void | 5492 void |
5582 test_parsePostfixExpression_none_methodInvocation_question_dot_typeArgumen
tComments() { | 5493 test_parsePostfixExpression_none_methodInvocation_question_dot_typeArgumen
tComments() { |
5583 enableGenericMethodComments = true; | 5494 enableGenericMethodComments = true; |
5584 Expression expression = parsePostfixExpression('a?.m/*<E>*/()'); | 5495 Expression expression = parsePostfixExpression('a?.m/*<E>*/()'); |
5585 expect(expression, isNotNull); | 5496 expect(expression, isNotNull); |
5586 assertNoErrors(); | 5497 assertNoErrors(); |
5587 expect(expression, new isInstanceOf<MethodInvocation>()); | 5498 var methodInvocation = expression as MethodInvocation; |
5588 MethodInvocation methodInvocation = expression; | |
5589 expect(methodInvocation.target, isNotNull); | 5499 expect(methodInvocation.target, isNotNull); |
5590 expect(methodInvocation.operator.type, TokenType.QUESTION_PERIOD); | 5500 expect(methodInvocation.operator.type, TokenType.QUESTION_PERIOD); |
5591 expect(methodInvocation.methodName, isNotNull); | 5501 expect(methodInvocation.methodName, isNotNull); |
5592 expect(methodInvocation.typeArguments, isNotNull); | 5502 expect(methodInvocation.typeArguments, isNotNull); |
5593 expect(methodInvocation.argumentList, isNotNull); | 5503 expect(methodInvocation.argumentList, isNotNull); |
5594 } | 5504 } |
5595 | 5505 |
5596 void | 5506 void |
5597 test_parsePostfixExpression_none_methodInvocation_question_dot_typeArgumen
ts() { | 5507 test_parsePostfixExpression_none_methodInvocation_question_dot_typeArgumen
ts() { |
5598 Expression expression = parsePostfixExpression('a?.m<E>()'); | 5508 Expression expression = parsePostfixExpression('a?.m<E>()'); |
5599 expect(expression, isNotNull); | 5509 expect(expression, isNotNull); |
5600 assertNoErrors(); | 5510 assertNoErrors(); |
5601 expect(expression, new isInstanceOf<MethodInvocation>()); | 5511 var methodInvocation = expression as MethodInvocation; |
5602 MethodInvocation methodInvocation = expression; | |
5603 expect(methodInvocation.target, isNotNull); | 5512 expect(methodInvocation.target, isNotNull); |
5604 expect(methodInvocation.operator.type, TokenType.QUESTION_PERIOD); | 5513 expect(methodInvocation.operator.type, TokenType.QUESTION_PERIOD); |
5605 expect(methodInvocation.methodName, isNotNull); | 5514 expect(methodInvocation.methodName, isNotNull); |
5606 expect(methodInvocation.typeArguments, isNotNull); | 5515 expect(methodInvocation.typeArguments, isNotNull); |
5607 expect(methodInvocation.argumentList, isNotNull); | 5516 expect(methodInvocation.argumentList, isNotNull); |
5608 } | 5517 } |
5609 | 5518 |
5610 void | 5519 void |
5611 test_parsePostfixExpression_none_methodInvocation_typeArgumentComments() { | 5520 test_parsePostfixExpression_none_methodInvocation_typeArgumentComments() { |
5612 enableGenericMethodComments = true; | 5521 enableGenericMethodComments = true; |
5613 Expression expression = parsePostfixExpression('a.m/*<E>*/()'); | 5522 Expression expression = parsePostfixExpression('a.m/*<E>*/()'); |
5614 expect(expression, isNotNull); | 5523 expect(expression, isNotNull); |
5615 assertNoErrors(); | 5524 assertNoErrors(); |
5616 expect(expression, new isInstanceOf<MethodInvocation>()); | 5525 var methodInvocation = expression as MethodInvocation; |
5617 MethodInvocation methodInvocation = expression; | |
5618 expect(methodInvocation.target, isNotNull); | 5526 expect(methodInvocation.target, isNotNull); |
5619 expect(methodInvocation.operator.type, TokenType.PERIOD); | 5527 expect(methodInvocation.operator.type, TokenType.PERIOD); |
5620 expect(methodInvocation.methodName, isNotNull); | 5528 expect(methodInvocation.methodName, isNotNull); |
5621 expect(methodInvocation.typeArguments, isNotNull); | 5529 expect(methodInvocation.typeArguments, isNotNull); |
5622 expect(methodInvocation.argumentList, isNotNull); | 5530 expect(methodInvocation.argumentList, isNotNull); |
5623 } | 5531 } |
5624 | 5532 |
5625 void test_parsePostfixExpression_none_methodInvocation_typeArguments() { | 5533 void test_parsePostfixExpression_none_methodInvocation_typeArguments() { |
5626 Expression expression = parsePostfixExpression('a.m<E>()'); | 5534 Expression expression = parsePostfixExpression('a.m<E>()'); |
5627 expect(expression, isNotNull); | 5535 expect(expression, isNotNull); |
5628 assertNoErrors(); | 5536 assertNoErrors(); |
5629 expect(expression, new isInstanceOf<MethodInvocation>()); | 5537 var methodInvocation = expression as MethodInvocation; |
5630 MethodInvocation methodInvocation = expression; | |
5631 expect(methodInvocation.target, isNotNull); | 5538 expect(methodInvocation.target, isNotNull); |
5632 expect(methodInvocation.operator.type, TokenType.PERIOD); | 5539 expect(methodInvocation.operator.type, TokenType.PERIOD); |
5633 expect(methodInvocation.methodName, isNotNull); | 5540 expect(methodInvocation.methodName, isNotNull); |
5634 expect(methodInvocation.typeArguments, isNotNull); | 5541 expect(methodInvocation.typeArguments, isNotNull); |
5635 expect(methodInvocation.argumentList, isNotNull); | 5542 expect(methodInvocation.argumentList, isNotNull); |
5636 } | 5543 } |
5637 | 5544 |
5638 void test_parsePostfixExpression_none_propertyAccess() { | 5545 void test_parsePostfixExpression_none_propertyAccess() { |
5639 Expression expression = parsePostfixExpression('a.b'); | 5546 Expression expression = parsePostfixExpression('a.b'); |
5640 expect(expression, isNotNull); | 5547 expect(expression, isNotNull); |
5641 assertNoErrors(); | 5548 assertNoErrors(); |
5642 expect(expression, new isInstanceOf<PrefixedIdentifier>()); | 5549 var identifier = expression as PrefixedIdentifier; |
5643 PrefixedIdentifier identifier = expression; | |
5644 expect(identifier.prefix, isNotNull); | 5550 expect(identifier.prefix, isNotNull); |
5645 expect(identifier.identifier, isNotNull); | 5551 expect(identifier.identifier, isNotNull); |
5646 } | 5552 } |
5647 | 5553 |
5648 void test_parsePrefixedIdentifier_noPrefix() { | 5554 void test_parsePrefixedIdentifier_noPrefix() { |
5649 String lexeme = "bar"; | 5555 String lexeme = "bar"; |
5650 Identifier identifier = parsePrefixedIdentifier(lexeme); | 5556 Identifier identifier = parsePrefixedIdentifier(lexeme); |
5651 expect(identifier, isNotNull); | 5557 expect(identifier, isNotNull); |
5652 assertNoErrors(); | 5558 assertNoErrors(); |
5653 expect(identifier, new isInstanceOf<SimpleIdentifier>()); | 5559 var simpleIdentifier = identifier as SimpleIdentifier; |
5654 SimpleIdentifier simpleIdentifier = identifier; | |
5655 expect(simpleIdentifier.token, isNotNull); | 5560 expect(simpleIdentifier.token, isNotNull); |
5656 expect(simpleIdentifier.name, lexeme); | 5561 expect(simpleIdentifier.name, lexeme); |
5657 } | 5562 } |
5658 | 5563 |
5659 void test_parsePrefixedIdentifier_prefix() { | 5564 void test_parsePrefixedIdentifier_prefix() { |
5660 String lexeme = "foo.bar"; | 5565 String lexeme = "foo.bar"; |
5661 Identifier identifier = parsePrefixedIdentifier(lexeme); | 5566 Identifier identifier = parsePrefixedIdentifier(lexeme); |
5662 expect(identifier, isNotNull); | 5567 expect(identifier, isNotNull); |
5663 assertNoErrors(); | 5568 assertNoErrors(); |
5664 expect(identifier, new isInstanceOf<PrefixedIdentifier>()); | 5569 var prefixedIdentifier = identifier as PrefixedIdentifier; |
5665 PrefixedIdentifier prefixedIdentifier = identifier; | |
5666 expect(prefixedIdentifier.prefix.name, "foo"); | 5570 expect(prefixedIdentifier.prefix.name, "foo"); |
5667 expect(prefixedIdentifier.period, isNotNull); | 5571 expect(prefixedIdentifier.period, isNotNull); |
5668 expect(prefixedIdentifier.identifier.name, "bar"); | 5572 expect(prefixedIdentifier.identifier.name, "bar"); |
5669 } | 5573 } |
5670 | 5574 |
5671 void test_parsePrimaryExpression_const() { | 5575 void test_parsePrimaryExpression_const() { |
5672 Expression expression = parsePrimaryExpression('const A()'); | 5576 Expression expression = parsePrimaryExpression('const A()'); |
5673 expect(expression, isNotNull); | 5577 expect(expression, isNotNull); |
5674 assertNoErrors(); | 5578 assertNoErrors(); |
5675 expect(expression, isNotNull); | 5579 expect(expression, isNotNull); |
5676 } | 5580 } |
5677 | 5581 |
5678 void test_parsePrimaryExpression_double() { | 5582 void test_parsePrimaryExpression_double() { |
5679 String doubleLiteral = "3.2e4"; | 5583 String doubleLiteral = "3.2e4"; |
5680 Expression expression = parsePrimaryExpression(doubleLiteral); | 5584 Expression expression = parsePrimaryExpression(doubleLiteral); |
5681 expect(expression, isNotNull); | 5585 expect(expression, isNotNull); |
5682 assertNoErrors(); | 5586 assertNoErrors(); |
5683 expect(expression, new isInstanceOf<DoubleLiteral>()); | 5587 var literal = expression as DoubleLiteral; |
5684 DoubleLiteral literal = expression; | |
5685 expect(literal.literal, isNotNull); | 5588 expect(literal.literal, isNotNull); |
5686 expect(literal.value, double.parse(doubleLiteral)); | 5589 expect(literal.value, double.parse(doubleLiteral)); |
5687 } | 5590 } |
5688 | 5591 |
5689 void test_parsePrimaryExpression_false() { | 5592 void test_parsePrimaryExpression_false() { |
5690 Expression expression = parsePrimaryExpression('false'); | 5593 Expression expression = parsePrimaryExpression('false'); |
5691 expect(expression, isNotNull); | 5594 expect(expression, isNotNull); |
5692 assertNoErrors(); | 5595 assertNoErrors(); |
5693 expect(expression, new isInstanceOf<BooleanLiteral>()); | 5596 var literal = expression as BooleanLiteral; |
5694 BooleanLiteral literal = expression; | |
5695 expect(literal.literal, isNotNull); | 5597 expect(literal.literal, isNotNull); |
5696 expect(literal.value, isFalse); | 5598 expect(literal.value, isFalse); |
5697 } | 5599 } |
5698 | 5600 |
5699 void test_parsePrimaryExpression_function_arguments() { | 5601 void test_parsePrimaryExpression_function_arguments() { |
5700 Expression expression = parsePrimaryExpression('(int i) => i + 1'); | 5602 Expression expression = parsePrimaryExpression('(int i) => i + 1'); |
5701 expect(expression, isNotNull); | 5603 expect(expression, isNotNull); |
5702 assertNoErrors(); | 5604 assertNoErrors(); |
5703 expect(expression, new isInstanceOf<FunctionExpression>()); | 5605 var functionExpression = expression as FunctionExpression; |
5704 FunctionExpression functionExpression = expression; | |
5705 expect(functionExpression.parameters, isNotNull); | 5606 expect(functionExpression.parameters, isNotNull); |
5706 expect(functionExpression.body, isNotNull); | 5607 expect(functionExpression.body, isNotNull); |
5707 } | 5608 } |
5708 | 5609 |
5709 void test_parsePrimaryExpression_function_noArguments() { | 5610 void test_parsePrimaryExpression_function_noArguments() { |
5710 Expression expression = parsePrimaryExpression('() => 42'); | 5611 Expression expression = parsePrimaryExpression('() => 42'); |
5711 expect(expression, isNotNull); | 5612 expect(expression, isNotNull); |
5712 assertNoErrors(); | 5613 assertNoErrors(); |
5713 expect(expression, new isInstanceOf<FunctionExpression>()); | 5614 var functionExpression = expression as FunctionExpression; |
5714 FunctionExpression functionExpression = expression; | |
5715 expect(functionExpression.parameters, isNotNull); | 5615 expect(functionExpression.parameters, isNotNull); |
5716 expect(functionExpression.body, isNotNull); | 5616 expect(functionExpression.body, isNotNull); |
5717 } | 5617 } |
5718 | 5618 |
5719 void test_parsePrimaryExpression_genericFunctionExpression() { | 5619 void test_parsePrimaryExpression_genericFunctionExpression() { |
5720 Expression expression = | 5620 Expression expression = |
5721 parsePrimaryExpression('<X, Y>(Map<X, Y> m, X x) => m[x]'); | 5621 parsePrimaryExpression('<X, Y>(Map<X, Y> m, X x) => m[x]'); |
5722 expect(expression, isNotNull); | 5622 expect(expression, isNotNull); |
5723 assertNoErrors(); | 5623 assertNoErrors(); |
5724 expect(expression, new isInstanceOf<FunctionExpression>()); | 5624 var functionExpression = expression as FunctionExpression; |
5725 FunctionExpression function = expression; | 5625 expect(functionExpression.typeParameters, isNotNull); |
5726 expect(function.typeParameters, isNotNull); | |
5727 } | 5626 } |
5728 | 5627 |
5729 void test_parsePrimaryExpression_hex() { | 5628 void test_parsePrimaryExpression_hex() { |
5730 String hexLiteral = "3F"; | 5629 String hexLiteral = "3F"; |
5731 Expression expression = parsePrimaryExpression('0x$hexLiteral'); | 5630 Expression expression = parsePrimaryExpression('0x$hexLiteral'); |
5732 expect(expression, isNotNull); | 5631 expect(expression, isNotNull); |
5733 assertNoErrors(); | 5632 assertNoErrors(); |
5734 expect(expression, new isInstanceOf<IntegerLiteral>()); | 5633 var literal = expression as IntegerLiteral; |
5735 IntegerLiteral literal = expression; | |
5736 expect(literal.literal, isNotNull); | 5634 expect(literal.literal, isNotNull); |
5737 expect(literal.value, int.parse(hexLiteral, radix: 16)); | 5635 expect(literal.value, int.parse(hexLiteral, radix: 16)); |
5738 } | 5636 } |
5739 | 5637 |
5740 void test_parsePrimaryExpression_identifier() { | 5638 void test_parsePrimaryExpression_identifier() { |
5741 Expression expression = parsePrimaryExpression('a'); | 5639 Expression expression = parsePrimaryExpression('a'); |
5742 expect(expression, isNotNull); | 5640 expect(expression, isNotNull); |
5743 assertNoErrors(); | 5641 assertNoErrors(); |
5744 expect(expression, new isInstanceOf<SimpleIdentifier>()); | 5642 var identifier = expression as SimpleIdentifier; |
5745 SimpleIdentifier identifier = expression; | |
5746 expect(identifier, isNotNull); | 5643 expect(identifier, isNotNull); |
5747 } | 5644 } |
5748 | 5645 |
5749 void test_parsePrimaryExpression_int() { | 5646 void test_parsePrimaryExpression_int() { |
5750 String intLiteral = "472"; | 5647 String intLiteral = "472"; |
5751 Expression expression = parsePrimaryExpression(intLiteral); | 5648 Expression expression = parsePrimaryExpression(intLiteral); |
5752 expect(expression, isNotNull); | 5649 expect(expression, isNotNull); |
5753 assertNoErrors(); | 5650 assertNoErrors(); |
5754 expect(expression, new isInstanceOf<IntegerLiteral>()); | 5651 var literal = expression as IntegerLiteral; |
5755 IntegerLiteral literal = expression; | |
5756 expect(literal.literal, isNotNull); | 5652 expect(literal.literal, isNotNull); |
5757 expect(literal.value, int.parse(intLiteral)); | 5653 expect(literal.value, int.parse(intLiteral)); |
5758 } | 5654 } |
5759 | 5655 |
5760 void test_parsePrimaryExpression_listLiteral() { | 5656 void test_parsePrimaryExpression_listLiteral() { |
5761 Expression expression = parsePrimaryExpression('[ ]'); | 5657 Expression expression = parsePrimaryExpression('[ ]'); |
5762 expect(expression, isNotNull); | 5658 expect(expression, isNotNull); |
5763 assertNoErrors(); | 5659 assertNoErrors(); |
5764 expect(expression, new isInstanceOf<ListLiteral>()); | 5660 var literal = expression as ListLiteral; |
5765 ListLiteral literal = expression; | |
5766 expect(literal, isNotNull); | 5661 expect(literal, isNotNull); |
5767 } | 5662 } |
5768 | 5663 |
5769 void test_parsePrimaryExpression_listLiteral_index() { | 5664 void test_parsePrimaryExpression_listLiteral_index() { |
5770 Expression expression = parsePrimaryExpression('[]'); | 5665 Expression expression = parsePrimaryExpression('[]'); |
5771 expect(expression, isNotNull); | 5666 expect(expression, isNotNull); |
5772 assertNoErrors(); | 5667 assertNoErrors(); |
5773 expect(expression, new isInstanceOf<ListLiteral>()); | 5668 var literal = expression as ListLiteral; |
5774 ListLiteral literal = expression; | |
5775 expect(literal, isNotNull); | 5669 expect(literal, isNotNull); |
5776 } | 5670 } |
5777 | 5671 |
5778 void test_parsePrimaryExpression_listLiteral_typed() { | 5672 void test_parsePrimaryExpression_listLiteral_typed() { |
5779 Expression expression = parsePrimaryExpression('<A>[ ]'); | 5673 Expression expression = parsePrimaryExpression('<A>[ ]'); |
5780 expect(expression, isNotNull); | 5674 expect(expression, isNotNull); |
5781 assertNoErrors(); | 5675 assertNoErrors(); |
5782 expect(expression, new isInstanceOf<ListLiteral>()); | 5676 var literal = expression as ListLiteral; |
5783 ListLiteral literal = expression; | |
5784 expect(literal.typeArguments, isNotNull); | 5677 expect(literal.typeArguments, isNotNull); |
5785 expect(literal.typeArguments.arguments, hasLength(1)); | 5678 expect(literal.typeArguments.arguments, hasLength(1)); |
5786 } | 5679 } |
5787 | 5680 |
5788 void test_parsePrimaryExpression_listLiteral_typed_genericComment() { | 5681 void test_parsePrimaryExpression_listLiteral_typed_genericComment() { |
5789 enableGenericMethodComments = true; | 5682 enableGenericMethodComments = true; |
5790 Expression expression = parsePrimaryExpression('/*<A>*/[ ]'); | 5683 Expression expression = parsePrimaryExpression('/*<A>*/[ ]'); |
5791 expect(expression, isNotNull); | 5684 expect(expression, isNotNull); |
5792 assertNoErrors(); | 5685 assertNoErrors(); |
5793 expect(expression, new isInstanceOf<ListLiteral>()); | 5686 var literal = expression as ListLiteral; |
5794 ListLiteral literal = expression; | |
5795 expect(literal.typeArguments, isNotNull); | 5687 expect(literal.typeArguments, isNotNull); |
5796 expect(literal.typeArguments.arguments, hasLength(1)); | 5688 expect(literal.typeArguments.arguments, hasLength(1)); |
5797 } | 5689 } |
5798 | 5690 |
5799 void test_parsePrimaryExpression_mapLiteral() { | 5691 void test_parsePrimaryExpression_mapLiteral() { |
5800 Expression expression = parsePrimaryExpression('{}'); | 5692 Expression expression = parsePrimaryExpression('{}'); |
5801 expect(expression, isNotNull); | 5693 expect(expression, isNotNull); |
5802 assertNoErrors(); | 5694 assertNoErrors(); |
5803 expect(expression, new isInstanceOf<MapLiteral>()); | 5695 var literal = expression as MapLiteral; |
5804 MapLiteral literal = expression; | |
5805 expect(literal.typeArguments, isNull); | 5696 expect(literal.typeArguments, isNull); |
5806 expect(literal, isNotNull); | 5697 expect(literal, isNotNull); |
5807 } | 5698 } |
5808 | 5699 |
5809 void test_parsePrimaryExpression_mapLiteral_typed() { | 5700 void test_parsePrimaryExpression_mapLiteral_typed() { |
5810 Expression expression = parsePrimaryExpression('<A, B>{}'); | 5701 Expression expression = parsePrimaryExpression('<A, B>{}'); |
5811 expect(expression, isNotNull); | 5702 expect(expression, isNotNull); |
5812 assertNoErrors(); | 5703 assertNoErrors(); |
5813 expect(expression, new isInstanceOf<MapLiteral>()); | 5704 var literal = expression as MapLiteral; |
5814 MapLiteral literal = expression; | |
5815 expect(literal.typeArguments, isNotNull); | 5705 expect(literal.typeArguments, isNotNull); |
5816 expect(literal.typeArguments.arguments, hasLength(2)); | 5706 expect(literal.typeArguments.arguments, hasLength(2)); |
5817 } | 5707 } |
5818 | 5708 |
5819 void test_parsePrimaryExpression_mapLiteral_typed_genericComment() { | 5709 void test_parsePrimaryExpression_mapLiteral_typed_genericComment() { |
5820 enableGenericMethodComments = true; | 5710 enableGenericMethodComments = true; |
5821 Expression expression = parsePrimaryExpression('/*<A, B>*/{}'); | 5711 Expression expression = parsePrimaryExpression('/*<A, B>*/{}'); |
5822 expect(expression, isNotNull); | 5712 expect(expression, isNotNull); |
5823 assertNoErrors(); | 5713 assertNoErrors(); |
5824 expect(expression, new isInstanceOf<MapLiteral>()); | 5714 var literal = expression as MapLiteral; |
5825 MapLiteral literal = expression; | |
5826 expect(literal.typeArguments, isNotNull); | 5715 expect(literal.typeArguments, isNotNull); |
5827 expect(literal.typeArguments.arguments, hasLength(2)); | 5716 expect(literal.typeArguments.arguments, hasLength(2)); |
5828 } | 5717 } |
5829 | 5718 |
5830 void test_parsePrimaryExpression_new() { | 5719 void test_parsePrimaryExpression_new() { |
5831 Expression expression = parsePrimaryExpression('new A()'); | 5720 Expression expression = parsePrimaryExpression('new A()'); |
5832 expect(expression, isNotNull); | 5721 expect(expression, isNotNull); |
5833 assertNoErrors(); | 5722 assertNoErrors(); |
5834 expect(expression, new isInstanceOf<InstanceCreationExpression>()); | 5723 var creation = expression as InstanceCreationExpression; |
5835 InstanceCreationExpression creation = expression; | |
5836 expect(creation, isNotNull); | 5724 expect(creation, isNotNull); |
5837 } | 5725 } |
5838 | 5726 |
5839 void test_parsePrimaryExpression_null() { | 5727 void test_parsePrimaryExpression_null() { |
5840 Expression expression = parsePrimaryExpression('null'); | 5728 Expression expression = parsePrimaryExpression('null'); |
5841 expect(expression, isNotNull); | 5729 expect(expression, isNotNull); |
5842 assertNoErrors(); | 5730 assertNoErrors(); |
5843 expect(expression, new isInstanceOf<NullLiteral>()); | 5731 expect(expression, new isInstanceOf<NullLiteral>()); |
5844 NullLiteral literal = expression; | 5732 NullLiteral literal = expression; |
5845 expect(literal.literal, isNotNull); | 5733 expect(literal.literal, isNotNull); |
5846 } | 5734 } |
5847 | 5735 |
5848 void test_parsePrimaryExpression_parenthesized() { | 5736 void test_parsePrimaryExpression_parenthesized() { |
5849 Expression expression = parsePrimaryExpression('(x)'); | 5737 Expression expression = parsePrimaryExpression('(x)'); |
5850 expect(expression, isNotNull); | 5738 expect(expression, isNotNull); |
5851 assertNoErrors(); | 5739 assertNoErrors(); |
5852 expect(expression, new isInstanceOf<ParenthesizedExpression>()); | 5740 var parens = expression as ParenthesizedExpression; |
5853 ParenthesizedExpression parens = expression; | |
5854 expect(parens, isNotNull); | 5741 expect(parens, isNotNull); |
5855 } | 5742 } |
5856 | 5743 |
5857 void test_parsePrimaryExpression_string() { | 5744 void test_parsePrimaryExpression_string() { |
5858 Expression expression = parsePrimaryExpression('"string"'); | 5745 Expression expression = parsePrimaryExpression('"string"'); |
5859 expect(expression, isNotNull); | 5746 expect(expression, isNotNull); |
5860 assertNoErrors(); | 5747 assertNoErrors(); |
5861 expect(expression, new isInstanceOf<SimpleStringLiteral>()); | 5748 var literal = expression as SimpleStringLiteral; |
5862 SimpleStringLiteral literal = expression; | |
5863 expect(literal.isMultiline, isFalse); | 5749 expect(literal.isMultiline, isFalse); |
5864 expect(literal.isRaw, isFalse); | 5750 expect(literal.isRaw, isFalse); |
5865 expect(literal.value, "string"); | 5751 expect(literal.value, "string"); |
5866 } | 5752 } |
5867 | 5753 |
5868 void test_parsePrimaryExpression_string_multiline() { | 5754 void test_parsePrimaryExpression_string_multiline() { |
5869 Expression expression = parsePrimaryExpression("'''string'''"); | 5755 Expression expression = parsePrimaryExpression("'''string'''"); |
5870 expect(expression, isNotNull); | 5756 expect(expression, isNotNull); |
5871 assertNoErrors(); | 5757 assertNoErrors(); |
5872 expect(expression, new isInstanceOf<SimpleStringLiteral>()); | 5758 var literal = expression as SimpleStringLiteral; |
5873 SimpleStringLiteral literal = expression; | |
5874 expect(literal.isMultiline, isTrue); | 5759 expect(literal.isMultiline, isTrue); |
5875 expect(literal.isRaw, isFalse); | 5760 expect(literal.isRaw, isFalse); |
5876 expect(literal.value, "string"); | 5761 expect(literal.value, "string"); |
5877 } | 5762 } |
5878 | 5763 |
5879 void test_parsePrimaryExpression_string_raw() { | 5764 void test_parsePrimaryExpression_string_raw() { |
5880 Expression expression = parsePrimaryExpression("r'string'"); | 5765 Expression expression = parsePrimaryExpression("r'string'"); |
5881 expect(expression, isNotNull); | 5766 expect(expression, isNotNull); |
5882 assertNoErrors(); | 5767 assertNoErrors(); |
5883 expect(expression, new isInstanceOf<SimpleStringLiteral>()); | 5768 var literal = expression as SimpleStringLiteral; |
5884 SimpleStringLiteral literal = expression; | |
5885 expect(literal.isMultiline, isFalse); | 5769 expect(literal.isMultiline, isFalse); |
5886 expect(literal.isRaw, isTrue); | 5770 expect(literal.isRaw, isTrue); |
5887 expect(literal.value, "string"); | 5771 expect(literal.value, "string"); |
5888 } | 5772 } |
5889 | 5773 |
5890 void test_parsePrimaryExpression_super() { | 5774 void test_parsePrimaryExpression_super() { |
5891 Expression expression = parsePrimaryExpression('super.x'); | 5775 Expression expression = parsePrimaryExpression('super.x'); |
5892 expect(expression, isNotNull); | 5776 expect(expression, isNotNull); |
5893 assertNoErrors(); | 5777 assertNoErrors(); |
5894 expect(expression, new isInstanceOf<PropertyAccess>()); | 5778 var propertyAccess = expression as PropertyAccess; |
5895 PropertyAccess propertyAccess = expression; | |
5896 expect(propertyAccess.target is SuperExpression, isTrue); | 5779 expect(propertyAccess.target is SuperExpression, isTrue); |
5897 expect(propertyAccess.operator, isNotNull); | 5780 expect(propertyAccess.operator, isNotNull); |
5898 expect(propertyAccess.operator.type, TokenType.PERIOD); | 5781 expect(propertyAccess.operator.type, TokenType.PERIOD); |
5899 expect(propertyAccess.propertyName, isNotNull); | 5782 expect(propertyAccess.propertyName, isNotNull); |
5900 } | 5783 } |
5901 | 5784 |
5902 void test_parsePrimaryExpression_this() { | 5785 void test_parsePrimaryExpression_this() { |
5903 Expression expression = parsePrimaryExpression('this'); | 5786 Expression expression = parsePrimaryExpression('this'); |
5904 expect(expression, isNotNull); | 5787 expect(expression, isNotNull); |
5905 assertNoErrors(); | 5788 assertNoErrors(); |
5906 expect(expression, new isInstanceOf<ThisExpression>()); | 5789 var thisExpression = expression as ThisExpression; |
5907 ThisExpression thisExpression = expression; | |
5908 expect(thisExpression.thisKeyword, isNotNull); | 5790 expect(thisExpression.thisKeyword, isNotNull); |
5909 } | 5791 } |
5910 | 5792 |
5911 void test_parsePrimaryExpression_true() { | 5793 void test_parsePrimaryExpression_true() { |
5912 Expression expression = parsePrimaryExpression('true'); | 5794 Expression expression = parsePrimaryExpression('true'); |
5913 expect(expression, isNotNull); | 5795 expect(expression, isNotNull); |
5914 assertNoErrors(); | 5796 assertNoErrors(); |
5915 expect(expression, new isInstanceOf<BooleanLiteral>()); | 5797 var literal = expression as BooleanLiteral; |
5916 BooleanLiteral literal = expression; | |
5917 expect(literal.literal, isNotNull); | 5798 expect(literal.literal, isNotNull); |
5918 expect(literal.value, isTrue); | 5799 expect(literal.value, isTrue); |
5919 } | 5800 } |
5920 | 5801 |
5921 void test_parseRelationalExpression_as_functionType_noReturnType() { | 5802 void test_parseRelationalExpression_as_functionType_noReturnType() { |
5922 Expression expression = parseRelationalExpression('x as Function(int)'); | 5803 Expression expression = parseRelationalExpression('x as Function(int)'); |
5923 expect(expression, isNotNull); | 5804 expect(expression, isNotNull); |
5924 assertNoErrors(); | 5805 assertNoErrors(); |
5925 expect(expression, new isInstanceOf<AsExpression>()); | 5806 var asExpression = expression as AsExpression; |
5926 AsExpression asExpression = expression; | |
5927 expect(asExpression.expression, isNotNull); | 5807 expect(asExpression.expression, isNotNull); |
5928 expect(asExpression.asOperator, isNotNull); | 5808 expect(asExpression.asOperator, isNotNull); |
5929 expect(asExpression.type, new isInstanceOf<GenericFunctionType>()); | 5809 expect(asExpression.type, new isInstanceOf<GenericFunctionType>()); |
5930 } | 5810 } |
5931 | 5811 |
5932 void test_parseRelationalExpression_as_functionType_returnType() { | 5812 void test_parseRelationalExpression_as_functionType_returnType() { |
5933 Expression expression = | 5813 Expression expression = |
5934 parseRelationalExpression('x as String Function(int)'); | 5814 parseRelationalExpression('x as String Function(int)'); |
5935 expect(expression, isNotNull); | 5815 expect(expression, isNotNull); |
5936 assertNoErrors(); | 5816 assertNoErrors(); |
5937 expect(expression, new isInstanceOf<AsExpression>()); | 5817 var asExpression = expression as AsExpression; |
5938 AsExpression asExpression = expression; | |
5939 expect(asExpression.expression, isNotNull); | 5818 expect(asExpression.expression, isNotNull); |
5940 expect(asExpression.asOperator, isNotNull); | 5819 expect(asExpression.asOperator, isNotNull); |
5941 expect(asExpression.type, new isInstanceOf<GenericFunctionType>()); | 5820 expect(asExpression.type, new isInstanceOf<GenericFunctionType>()); |
5942 } | 5821 } |
5943 | 5822 |
5944 void test_parseRelationalExpression_as_generic() { | 5823 void test_parseRelationalExpression_as_generic() { |
5945 Expression expression = parseRelationalExpression('x as C<D>'); | 5824 Expression expression = parseRelationalExpression('x as C<D>'); |
5946 expect(expression, isNotNull); | 5825 expect(expression, isNotNull); |
5947 assertNoErrors(); | 5826 assertNoErrors(); |
5948 expect(expression, new isInstanceOf<AsExpression>()); | 5827 var asExpression = expression as AsExpression; |
5949 AsExpression asExpression = expression; | |
5950 expect(asExpression.expression, isNotNull); | 5828 expect(asExpression.expression, isNotNull); |
5951 expect(asExpression.asOperator, isNotNull); | 5829 expect(asExpression.asOperator, isNotNull); |
5952 expect(asExpression.type, new isInstanceOf<TypeName>()); | 5830 expect(asExpression.type, new isInstanceOf<TypeName>()); |
5953 } | 5831 } |
5954 | 5832 |
5955 void test_parseRelationalExpression_as_nullable() { | 5833 void test_parseRelationalExpression_as_nullable() { |
5956 enableNnbd = true; | 5834 enableNnbd = true; |
5957 Expression expression = parseRelationalExpression('x as Y?)'); | 5835 Expression expression = parseRelationalExpression('x as Y?)'); |
5958 expect(expression, isNotNull); | 5836 expect(expression, isNotNull); |
5959 assertNoErrors(); | 5837 assertNoErrors(); |
5960 expect(expression, new isInstanceOf<AsExpression>()); | 5838 var asExpression = expression as AsExpression; |
5961 AsExpression asExpression = expression; | |
5962 expect(asExpression.expression, isNotNull); | 5839 expect(asExpression.expression, isNotNull); |
5963 expect(asExpression.asOperator, isNotNull); | 5840 expect(asExpression.asOperator, isNotNull); |
5964 expect(asExpression.type, new isInstanceOf<TypeName>()); | 5841 expect(asExpression.type, new isInstanceOf<TypeName>()); |
5965 } | 5842 } |
5966 | 5843 |
5967 void test_parseRelationalExpression_as_simple() { | 5844 void test_parseRelationalExpression_as_simple() { |
5968 Expression expression = parseRelationalExpression('x as Y'); | 5845 Expression expression = parseRelationalExpression('x as Y'); |
5969 expect(expression, isNotNull); | 5846 expect(expression, isNotNull); |
5970 assertNoErrors(); | 5847 assertNoErrors(); |
5971 expect(expression, new isInstanceOf<AsExpression>()); | 5848 var asExpression = expression as AsExpression; |
5972 AsExpression asExpression = expression; | |
5973 expect(asExpression.expression, isNotNull); | 5849 expect(asExpression.expression, isNotNull); |
5974 expect(asExpression.asOperator, isNotNull); | 5850 expect(asExpression.asOperator, isNotNull); |
5975 expect(asExpression.type, new isInstanceOf<TypeName>()); | 5851 expect(asExpression.type, new isInstanceOf<TypeName>()); |
5976 } | 5852 } |
5977 | 5853 |
5978 void test_parseRelationalExpression_as_simple_function() { | 5854 void test_parseRelationalExpression_as_simple_function() { |
5979 Expression expression = parseRelationalExpression('x as Function'); | 5855 Expression expression = parseRelationalExpression('x as Function'); |
5980 expect(expression, isNotNull); | 5856 expect(expression, isNotNull); |
5981 assertNoErrors(); | 5857 assertNoErrors(); |
5982 expect(expression, new isInstanceOf<AsExpression>()); | 5858 var asExpression = expression as AsExpression; |
5983 AsExpression asExpression = expression; | |
5984 expect(asExpression.expression, isNotNull); | 5859 expect(asExpression.expression, isNotNull); |
5985 expect(asExpression.asOperator, isNotNull); | 5860 expect(asExpression.asOperator, isNotNull); |
5986 expect(asExpression.type, new isInstanceOf<TypeName>()); | 5861 expect(asExpression.type, new isInstanceOf<TypeName>()); |
5987 } | 5862 } |
5988 | 5863 |
5989 void test_parseRelationalExpression_is() { | 5864 void test_parseRelationalExpression_is() { |
5990 Expression expression = parseRelationalExpression('x is y'); | 5865 Expression expression = parseRelationalExpression('x is y'); |
5991 expect(expression, isNotNull); | 5866 expect(expression, isNotNull); |
5992 assertNoErrors(); | 5867 assertNoErrors(); |
5993 expect(expression, new isInstanceOf<IsExpression>()); | 5868 var isExpression = expression as IsExpression; |
5994 IsExpression isExpression = expression; | |
5995 expect(isExpression.expression, isNotNull); | 5869 expect(isExpression.expression, isNotNull); |
5996 expect(isExpression.isOperator, isNotNull); | 5870 expect(isExpression.isOperator, isNotNull); |
5997 expect(isExpression.notOperator, isNull); | 5871 expect(isExpression.notOperator, isNull); |
5998 expect(isExpression.type, isNotNull); | 5872 expect(isExpression.type, isNotNull); |
5999 } | 5873 } |
6000 | 5874 |
6001 void test_parseRelationalExpression_is_nullable() { | 5875 void test_parseRelationalExpression_is_nullable() { |
6002 enableNnbd = true; | 5876 enableNnbd = true; |
6003 Expression expression = parseRelationalExpression('x is y?)'); | 5877 Expression expression = parseRelationalExpression('x is y?)'); |
6004 expect(expression, isNotNull); | 5878 expect(expression, isNotNull); |
6005 assertNoErrors(); | 5879 assertNoErrors(); |
6006 expect(expression, new isInstanceOf<IsExpression>()); | 5880 var isExpression = expression as IsExpression; |
6007 IsExpression isExpression = expression; | |
6008 expect(isExpression.expression, isNotNull); | 5881 expect(isExpression.expression, isNotNull); |
6009 expect(isExpression.isOperator, isNotNull); | 5882 expect(isExpression.isOperator, isNotNull); |
6010 expect(isExpression.notOperator, isNull); | 5883 expect(isExpression.notOperator, isNull); |
6011 expect(isExpression.type, isNotNull); | 5884 expect(isExpression.type, isNotNull); |
6012 } | 5885 } |
6013 | 5886 |
6014 void test_parseRelationalExpression_isNot() { | 5887 void test_parseRelationalExpression_isNot() { |
6015 Expression expression = parseRelationalExpression('x is! y'); | 5888 Expression expression = parseRelationalExpression('x is! y'); |
6016 expect(expression, isNotNull); | 5889 expect(expression, isNotNull); |
6017 assertNoErrors(); | 5890 assertNoErrors(); |
6018 expect(expression, new isInstanceOf<IsExpression>()); | 5891 var isExpression = expression as IsExpression; |
6019 IsExpression isExpression = expression; | |
6020 expect(isExpression.expression, isNotNull); | 5892 expect(isExpression.expression, isNotNull); |
6021 expect(isExpression.isOperator, isNotNull); | 5893 expect(isExpression.isOperator, isNotNull); |
6022 expect(isExpression.notOperator, isNotNull); | 5894 expect(isExpression.notOperator, isNotNull); |
6023 expect(isExpression.type, isNotNull); | 5895 expect(isExpression.type, isNotNull); |
6024 } | 5896 } |
6025 | 5897 |
6026 void test_parseRelationalExpression_normal() { | 5898 void test_parseRelationalExpression_normal() { |
6027 Expression expression = parseRelationalExpression('x < y'); | 5899 Expression expression = parseRelationalExpression('x < y'); |
6028 expect(expression, isNotNull); | 5900 expect(expression, isNotNull); |
6029 assertNoErrors(); | 5901 assertNoErrors(); |
6030 expect(expression, new isInstanceOf<BinaryExpression>()); | 5902 var binaryExpression = expression as BinaryExpression; |
6031 BinaryExpression binaryExpression = expression; | |
6032 expect(binaryExpression.leftOperand, isNotNull); | 5903 expect(binaryExpression.leftOperand, isNotNull); |
6033 expect(binaryExpression.operator, isNotNull); | 5904 expect(binaryExpression.operator, isNotNull); |
6034 expect(binaryExpression.operator.type, TokenType.LT); | 5905 expect(binaryExpression.operator.type, TokenType.LT); |
6035 expect(binaryExpression.rightOperand, isNotNull); | 5906 expect(binaryExpression.rightOperand, isNotNull); |
6036 } | 5907 } |
6037 | 5908 |
6038 void test_parseRelationalExpression_super() { | 5909 void test_parseRelationalExpression_super() { |
6039 Expression expression = parseRelationalExpression('super < y'); | 5910 Expression expression = parseRelationalExpression('super < y'); |
6040 expect(expression, isNotNull); | 5911 expect(expression, isNotNull); |
6041 assertNoErrors(); | 5912 assertNoErrors(); |
6042 expect(expression, new isInstanceOf<BinaryExpression>()); | 5913 var binaryExpression = expression as BinaryExpression; |
6043 BinaryExpression binaryExpression = expression; | |
6044 expect(binaryExpression.leftOperand, isNotNull); | 5914 expect(binaryExpression.leftOperand, isNotNull); |
6045 expect(binaryExpression.operator, isNotNull); | 5915 expect(binaryExpression.operator, isNotNull); |
6046 expect(binaryExpression.operator.type, TokenType.LT); | 5916 expect(binaryExpression.operator.type, TokenType.LT); |
6047 expect(binaryExpression.rightOperand, isNotNull); | 5917 expect(binaryExpression.rightOperand, isNotNull); |
6048 } | 5918 } |
6049 | 5919 |
6050 void test_parseRethrowExpression() { | 5920 void test_parseRethrowExpression() { |
6051 RethrowExpression expression = parseRethrowExpression('rethrow'); | 5921 RethrowExpression expression = parseRethrowExpression('rethrow'); |
6052 expect(expression, isNotNull); | 5922 expect(expression, isNotNull); |
6053 assertNoErrors(); | 5923 assertNoErrors(); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6093 expect(identifier, isNotNull); | 5963 expect(identifier, isNotNull); |
6094 assertNoErrors(); | 5964 assertNoErrors(); |
6095 expect(identifier.token, isNotNull); | 5965 expect(identifier.token, isNotNull); |
6096 expect(identifier.name, lexeme); | 5966 expect(identifier.name, lexeme); |
6097 } | 5967 } |
6098 | 5968 |
6099 void test_parseStringLiteral_adjacent() { | 5969 void test_parseStringLiteral_adjacent() { |
6100 Expression expression = parseStringLiteral("'a' 'b'"); | 5970 Expression expression = parseStringLiteral("'a' 'b'"); |
6101 expect(expression, isNotNull); | 5971 expect(expression, isNotNull); |
6102 assertNoErrors(); | 5972 assertNoErrors(); |
6103 expect(expression, new isInstanceOf<AdjacentStrings>()); | 5973 var literal = expression as AdjacentStrings; |
6104 AdjacentStrings literal = expression; | |
6105 NodeList<StringLiteral> strings = literal.strings; | 5974 NodeList<StringLiteral> strings = literal.strings; |
6106 expect(strings, hasLength(2)); | 5975 expect(strings, hasLength(2)); |
6107 StringLiteral firstString = strings[0]; | 5976 StringLiteral firstString = strings[0]; |
6108 StringLiteral secondString = strings[1]; | 5977 StringLiteral secondString = strings[1]; |
6109 expect((firstString as SimpleStringLiteral).value, "a"); | 5978 expect((firstString as SimpleStringLiteral).value, "a"); |
6110 expect((secondString as SimpleStringLiteral).value, "b"); | 5979 expect((secondString as SimpleStringLiteral).value, "b"); |
6111 } | 5980 } |
6112 | 5981 |
6113 void test_parseStringLiteral_endsWithInterpolation() { | 5982 void test_parseStringLiteral_endsWithInterpolation() { |
6114 Expression expression = parseStringLiteral(r"'x$y'"); | 5983 Expression expression = parseStringLiteral(r"'x$y'"); |
6115 expect(expression, isNotNull); | 5984 expect(expression, isNotNull); |
6116 assertNoErrors(); | 5985 assertNoErrors(); |
6117 expect(expression, new isInstanceOf<StringInterpolation>()); | 5986 var interpolation = expression as StringInterpolation; |
6118 StringInterpolation interpolation = expression; | |
6119 expect(interpolation.elements, hasLength(3)); | 5987 expect(interpolation.elements, hasLength(3)); |
6120 expect(interpolation.elements[0], new isInstanceOf<InterpolationString>()); | 5988 expect(interpolation.elements[0], new isInstanceOf<InterpolationString>()); |
6121 InterpolationString element0 = interpolation.elements[0]; | 5989 InterpolationString element0 = interpolation.elements[0]; |
6122 expect(element0.value, 'x'); | 5990 expect(element0.value, 'x'); |
6123 expect( | 5991 expect( |
6124 interpolation.elements[1], new isInstanceOf<InterpolationExpression>()); | 5992 interpolation.elements[1], new isInstanceOf<InterpolationExpression>()); |
6125 InterpolationExpression element1 = interpolation.elements[1]; | 5993 InterpolationExpression element1 = interpolation.elements[1]; |
6126 expect(element1.expression, new isInstanceOf<SimpleIdentifier>()); | 5994 expect(element1.expression, new isInstanceOf<SimpleIdentifier>()); |
6127 expect(interpolation.elements[2], new isInstanceOf<InterpolationString>()); | 5995 expect(interpolation.elements[2], new isInstanceOf<InterpolationString>()); |
6128 InterpolationString element2 = interpolation.elements[2]; | 5996 InterpolationString element2 = interpolation.elements[2]; |
(...skipping 12 matching lines...) Expand all Loading... |
6141 expect(elements[1] is InterpolationExpression, isTrue); | 6009 expect(elements[1] is InterpolationExpression, isTrue); |
6142 expect(elements[2] is InterpolationString, isTrue); | 6010 expect(elements[2] is InterpolationString, isTrue); |
6143 expect(elements[3] is InterpolationExpression, isTrue); | 6011 expect(elements[3] is InterpolationExpression, isTrue); |
6144 expect(elements[4] is InterpolationString, isTrue); | 6012 expect(elements[4] is InterpolationString, isTrue); |
6145 } | 6013 } |
6146 | 6014 |
6147 void test_parseStringLiteral_multiline_encodedSpace() { | 6015 void test_parseStringLiteral_multiline_encodedSpace() { |
6148 Expression expression = parseStringLiteral("'''\\x20\na'''"); | 6016 Expression expression = parseStringLiteral("'''\\x20\na'''"); |
6149 expect(expression, isNotNull); | 6017 expect(expression, isNotNull); |
6150 assertNoErrors(); | 6018 assertNoErrors(); |
6151 expect(expression, new isInstanceOf<SimpleStringLiteral>()); | 6019 var literal = expression as SimpleStringLiteral; |
6152 SimpleStringLiteral literal = expression; | |
6153 expect(literal.literal, isNotNull); | 6020 expect(literal.literal, isNotNull); |
6154 expect(literal.value, " \na"); | 6021 expect(literal.value, " \na"); |
6155 } | 6022 } |
6156 | 6023 |
6157 void test_parseStringLiteral_multiline_endsWithInterpolation() { | 6024 void test_parseStringLiteral_multiline_endsWithInterpolation() { |
6158 Expression expression = parseStringLiteral(r"'''x$y'''"); | 6025 Expression expression = parseStringLiteral(r"'''x$y'''"); |
6159 expect(expression, isNotNull); | 6026 expect(expression, isNotNull); |
6160 assertNoErrors(); | 6027 assertNoErrors(); |
6161 expect(expression, new isInstanceOf<StringInterpolation>()); | 6028 var interpolation = expression as StringInterpolation; |
6162 StringInterpolation interpolation = expression; | |
6163 expect(interpolation.elements, hasLength(3)); | 6029 expect(interpolation.elements, hasLength(3)); |
6164 expect(interpolation.elements[0], new isInstanceOf<InterpolationString>()); | 6030 expect(interpolation.elements[0], new isInstanceOf<InterpolationString>()); |
6165 InterpolationString element0 = interpolation.elements[0]; | 6031 InterpolationString element0 = interpolation.elements[0]; |
6166 expect(element0.value, 'x'); | 6032 expect(element0.value, 'x'); |
6167 expect( | 6033 expect( |
6168 interpolation.elements[1], new isInstanceOf<InterpolationExpression>()); | 6034 interpolation.elements[1], new isInstanceOf<InterpolationExpression>()); |
6169 InterpolationExpression element1 = interpolation.elements[1]; | 6035 InterpolationExpression element1 = interpolation.elements[1]; |
6170 expect(element1.expression, new isInstanceOf<SimpleIdentifier>()); | 6036 expect(element1.expression, new isInstanceOf<SimpleIdentifier>()); |
6171 expect(interpolation.elements[2], new isInstanceOf<InterpolationString>()); | 6037 expect(interpolation.elements[2], new isInstanceOf<InterpolationString>()); |
6172 InterpolationString element2 = interpolation.elements[2]; | 6038 InterpolationString element2 = interpolation.elements[2]; |
6173 expect(element2.value, ''); | 6039 expect(element2.value, ''); |
6174 } | 6040 } |
6175 | 6041 |
6176 void test_parseStringLiteral_multiline_escapedBackslash() { | 6042 void test_parseStringLiteral_multiline_escapedBackslash() { |
6177 Expression expression = parseStringLiteral("'''\\\\\na'''"); | 6043 Expression expression = parseStringLiteral("'''\\\\\na'''"); |
6178 expect(expression, isNotNull); | 6044 expect(expression, isNotNull); |
6179 assertNoErrors(); | 6045 assertNoErrors(); |
6180 expect(expression, new isInstanceOf<SimpleStringLiteral>()); | 6046 var literal = expression as SimpleStringLiteral; |
6181 SimpleStringLiteral literal = expression; | |
6182 expect(literal.literal, isNotNull); | 6047 expect(literal.literal, isNotNull); |
6183 expect(literal.value, "\\\na"); | 6048 expect(literal.value, "\\\na"); |
6184 } | 6049 } |
6185 | 6050 |
6186 void test_parseStringLiteral_multiline_escapedBackslash_raw() { | 6051 void test_parseStringLiteral_multiline_escapedBackslash_raw() { |
6187 Expression expression = parseStringLiteral("r'''\\\\\na'''"); | 6052 Expression expression = parseStringLiteral("r'''\\\\\na'''"); |
6188 expect(expression, isNotNull); | 6053 expect(expression, isNotNull); |
6189 assertNoErrors(); | 6054 assertNoErrors(); |
6190 expect(expression, new isInstanceOf<SimpleStringLiteral>()); | 6055 var literal = expression as SimpleStringLiteral; |
6191 SimpleStringLiteral literal = expression; | |
6192 expect(literal.literal, isNotNull); | 6056 expect(literal.literal, isNotNull); |
6193 expect(literal.value, "\\\\\na"); | 6057 expect(literal.value, "\\\\\na"); |
6194 } | 6058 } |
6195 | 6059 |
6196 void test_parseStringLiteral_multiline_escapedEolMarker() { | 6060 void test_parseStringLiteral_multiline_escapedEolMarker() { |
6197 Expression expression = parseStringLiteral("'''\\\na'''"); | 6061 Expression expression = parseStringLiteral("'''\\\na'''"); |
6198 expect(expression, isNotNull); | 6062 expect(expression, isNotNull); |
6199 assertNoErrors(); | 6063 assertNoErrors(); |
6200 expect(expression, new isInstanceOf<SimpleStringLiteral>()); | 6064 var literal = expression as SimpleStringLiteral; |
6201 SimpleStringLiteral literal = expression; | |
6202 expect(literal.literal, isNotNull); | 6065 expect(literal.literal, isNotNull); |
6203 expect(literal.value, "a"); | 6066 expect(literal.value, "a"); |
6204 } | 6067 } |
6205 | 6068 |
6206 void test_parseStringLiteral_multiline_escapedEolMarker_raw() { | 6069 void test_parseStringLiteral_multiline_escapedEolMarker_raw() { |
6207 Expression expression = parseStringLiteral("r'''\\\na'''"); | 6070 Expression expression = parseStringLiteral("r'''\\\na'''"); |
6208 expect(expression, isNotNull); | 6071 expect(expression, isNotNull); |
6209 assertNoErrors(); | 6072 assertNoErrors(); |
6210 expect(expression, new isInstanceOf<SimpleStringLiteral>()); | 6073 var literal = expression as SimpleStringLiteral; |
6211 SimpleStringLiteral literal = expression; | |
6212 expect(literal.literal, isNotNull); | 6074 expect(literal.literal, isNotNull); |
6213 expect(literal.value, "a"); | 6075 expect(literal.value, "a"); |
6214 } | 6076 } |
6215 | 6077 |
6216 void test_parseStringLiteral_multiline_escapedSpaceAndEolMarker() { | 6078 void test_parseStringLiteral_multiline_escapedSpaceAndEolMarker() { |
6217 Expression expression = parseStringLiteral("'''\\ \\\na'''"); | 6079 Expression expression = parseStringLiteral("'''\\ \\\na'''"); |
6218 expect(expression, isNotNull); | 6080 expect(expression, isNotNull); |
6219 assertNoErrors(); | 6081 assertNoErrors(); |
6220 expect(expression, new isInstanceOf<SimpleStringLiteral>()); | 6082 var literal = expression as SimpleStringLiteral; |
6221 SimpleStringLiteral literal = expression; | |
6222 expect(literal.literal, isNotNull); | 6083 expect(literal.literal, isNotNull); |
6223 expect(literal.value, "a"); | 6084 expect(literal.value, "a"); |
6224 } | 6085 } |
6225 | 6086 |
6226 void test_parseStringLiteral_multiline_escapedSpaceAndEolMarker_raw() { | 6087 void test_parseStringLiteral_multiline_escapedSpaceAndEolMarker_raw() { |
6227 Expression expression = parseStringLiteral("r'''\\ \\\na'''"); | 6088 Expression expression = parseStringLiteral("r'''\\ \\\na'''"); |
6228 expect(expression, isNotNull); | 6089 expect(expression, isNotNull); |
6229 assertNoErrors(); | 6090 assertNoErrors(); |
6230 expect(expression, new isInstanceOf<SimpleStringLiteral>()); | 6091 var literal = expression as SimpleStringLiteral; |
6231 SimpleStringLiteral literal = expression; | |
6232 expect(literal.literal, isNotNull); | 6092 expect(literal.literal, isNotNull); |
6233 expect(literal.value, "a"); | 6093 expect(literal.value, "a"); |
6234 } | 6094 } |
6235 | 6095 |
6236 void test_parseStringLiteral_multiline_escapedTab() { | 6096 void test_parseStringLiteral_multiline_escapedTab() { |
6237 Expression expression = parseStringLiteral("'''\\t\na'''"); | 6097 Expression expression = parseStringLiteral("'''\\t\na'''"); |
6238 expect(expression, isNotNull); | 6098 expect(expression, isNotNull); |
6239 assertNoErrors(); | 6099 assertNoErrors(); |
6240 expect(expression, new isInstanceOf<SimpleStringLiteral>()); | 6100 var literal = expression as SimpleStringLiteral; |
6241 SimpleStringLiteral literal = expression; | |
6242 expect(literal.literal, isNotNull); | 6101 expect(literal.literal, isNotNull); |
6243 expect(literal.value, "\t\na"); | 6102 expect(literal.value, "\t\na"); |
6244 } | 6103 } |
6245 | 6104 |
6246 void test_parseStringLiteral_multiline_escapedTab_raw() { | 6105 void test_parseStringLiteral_multiline_escapedTab_raw() { |
6247 Expression expression = parseStringLiteral("r'''\\t\na'''"); | 6106 Expression expression = parseStringLiteral("r'''\\t\na'''"); |
6248 expect(expression, isNotNull); | 6107 expect(expression, isNotNull); |
6249 assertNoErrors(); | 6108 assertNoErrors(); |
6250 expect(expression, new isInstanceOf<SimpleStringLiteral>()); | 6109 var literal = expression as SimpleStringLiteral; |
6251 SimpleStringLiteral literal = expression; | |
6252 expect(literal.literal, isNotNull); | 6110 expect(literal.literal, isNotNull); |
6253 expect(literal.value, "\\t\na"); | 6111 expect(literal.value, "\\t\na"); |
6254 } | 6112 } |
6255 | 6113 |
6256 void test_parseStringLiteral_multiline_quoteAfterInterpolation() { | 6114 void test_parseStringLiteral_multiline_quoteAfterInterpolation() { |
6257 Expression expression = parseStringLiteral(r"""'''$x'y'''"""); | 6115 Expression expression = parseStringLiteral(r"""'''$x'y'''"""); |
6258 expect(expression, isNotNull); | 6116 expect(expression, isNotNull); |
6259 assertNoErrors(); | 6117 assertNoErrors(); |
6260 expect(expression, new isInstanceOf<StringInterpolation>()); | 6118 var interpolation = expression as StringInterpolation; |
6261 StringInterpolation interpolation = expression; | |
6262 expect(interpolation.elements, hasLength(3)); | 6119 expect(interpolation.elements, hasLength(3)); |
6263 expect(interpolation.elements[0], new isInstanceOf<InterpolationString>()); | 6120 expect(interpolation.elements[0], new isInstanceOf<InterpolationString>()); |
6264 InterpolationString element0 = interpolation.elements[0]; | 6121 InterpolationString element0 = interpolation.elements[0]; |
6265 expect(element0.value, ''); | 6122 expect(element0.value, ''); |
6266 expect( | 6123 expect( |
6267 interpolation.elements[1], new isInstanceOf<InterpolationExpression>()); | 6124 interpolation.elements[1], new isInstanceOf<InterpolationExpression>()); |
6268 InterpolationExpression element1 = interpolation.elements[1]; | 6125 InterpolationExpression element1 = interpolation.elements[1]; |
6269 expect(element1.expression, new isInstanceOf<SimpleIdentifier>()); | 6126 expect(element1.expression, new isInstanceOf<SimpleIdentifier>()); |
6270 expect(interpolation.elements[2], new isInstanceOf<InterpolationString>()); | 6127 expect(interpolation.elements[2], new isInstanceOf<InterpolationString>()); |
6271 InterpolationString element2 = interpolation.elements[2]; | 6128 InterpolationString element2 = interpolation.elements[2]; |
6272 expect(element2.value, "'y"); | 6129 expect(element2.value, "'y"); |
6273 } | 6130 } |
6274 | 6131 |
6275 void test_parseStringLiteral_multiline_startsWithInterpolation() { | 6132 void test_parseStringLiteral_multiline_startsWithInterpolation() { |
6276 Expression expression = parseStringLiteral(r"'''${x}y'''"); | 6133 Expression expression = parseStringLiteral(r"'''${x}y'''"); |
6277 expect(expression, isNotNull); | 6134 expect(expression, isNotNull); |
6278 assertNoErrors(); | 6135 assertNoErrors(); |
6279 expect(expression, new isInstanceOf<StringInterpolation>()); | 6136 var interpolation = expression as StringInterpolation; |
6280 StringInterpolation interpolation = expression; | |
6281 expect(interpolation.elements, hasLength(3)); | 6137 expect(interpolation.elements, hasLength(3)); |
6282 expect(interpolation.elements[0], new isInstanceOf<InterpolationString>()); | 6138 expect(interpolation.elements[0], new isInstanceOf<InterpolationString>()); |
6283 InterpolationString element0 = interpolation.elements[0]; | 6139 InterpolationString element0 = interpolation.elements[0]; |
6284 expect(element0.value, ''); | 6140 expect(element0.value, ''); |
6285 expect( | 6141 expect( |
6286 interpolation.elements[1], new isInstanceOf<InterpolationExpression>()); | 6142 interpolation.elements[1], new isInstanceOf<InterpolationExpression>()); |
6287 InterpolationExpression element1 = interpolation.elements[1]; | 6143 InterpolationExpression element1 = interpolation.elements[1]; |
6288 expect(element1.expression, new isInstanceOf<SimpleIdentifier>()); | 6144 expect(element1.expression, new isInstanceOf<SimpleIdentifier>()); |
6289 expect(interpolation.elements[2], new isInstanceOf<InterpolationString>()); | 6145 expect(interpolation.elements[2], new isInstanceOf<InterpolationString>()); |
6290 InterpolationString element2 = interpolation.elements[2]; | 6146 InterpolationString element2 = interpolation.elements[2]; |
6291 expect(element2.value, 'y'); | 6147 expect(element2.value, 'y'); |
6292 } | 6148 } |
6293 | 6149 |
6294 void test_parseStringLiteral_multiline_twoSpaces() { | 6150 void test_parseStringLiteral_multiline_twoSpaces() { |
6295 Expression expression = parseStringLiteral("''' \na'''"); | 6151 Expression expression = parseStringLiteral("''' \na'''"); |
6296 expect(expression, isNotNull); | 6152 expect(expression, isNotNull); |
6297 assertNoErrors(); | 6153 assertNoErrors(); |
6298 expect(expression, new isInstanceOf<SimpleStringLiteral>()); | 6154 var literal = expression as SimpleStringLiteral; |
6299 SimpleStringLiteral literal = expression; | |
6300 expect(literal.literal, isNotNull); | 6155 expect(literal.literal, isNotNull); |
6301 expect(literal.value, "a"); | 6156 expect(literal.value, "a"); |
6302 } | 6157 } |
6303 | 6158 |
6304 void test_parseStringLiteral_multiline_twoSpaces_raw() { | 6159 void test_parseStringLiteral_multiline_twoSpaces_raw() { |
6305 Expression expression = parseStringLiteral("r''' \na'''"); | 6160 Expression expression = parseStringLiteral("r''' \na'''"); |
6306 expect(expression, isNotNull); | 6161 expect(expression, isNotNull); |
6307 assertNoErrors(); | 6162 assertNoErrors(); |
6308 expect(expression, new isInstanceOf<SimpleStringLiteral>()); | 6163 var literal = expression as SimpleStringLiteral; |
6309 SimpleStringLiteral literal = expression; | |
6310 expect(literal.literal, isNotNull); | 6164 expect(literal.literal, isNotNull); |
6311 expect(literal.value, "a"); | 6165 expect(literal.value, "a"); |
6312 } | 6166 } |
6313 | 6167 |
6314 void test_parseStringLiteral_multiline_untrimmed() { | 6168 void test_parseStringLiteral_multiline_untrimmed() { |
6315 Expression expression = parseStringLiteral("''' a\nb'''"); | 6169 Expression expression = parseStringLiteral("''' a\nb'''"); |
6316 expect(expression, isNotNull); | 6170 expect(expression, isNotNull); |
6317 assertNoErrors(); | 6171 assertNoErrors(); |
6318 expect(expression, new isInstanceOf<SimpleStringLiteral>()); | 6172 var literal = expression as SimpleStringLiteral; |
6319 SimpleStringLiteral literal = expression; | |
6320 expect(literal.literal, isNotNull); | 6173 expect(literal.literal, isNotNull); |
6321 expect(literal.value, " a\nb"); | 6174 expect(literal.value, " a\nb"); |
6322 } | 6175 } |
6323 | 6176 |
6324 void test_parseStringLiteral_quoteAfterInterpolation() { | 6177 void test_parseStringLiteral_quoteAfterInterpolation() { |
6325 Expression expression = parseStringLiteral(r"""'$x"'"""); | 6178 Expression expression = parseStringLiteral(r"""'$x"'"""); |
6326 expect(expression, isNotNull); | 6179 expect(expression, isNotNull); |
6327 assertNoErrors(); | 6180 assertNoErrors(); |
6328 expect(expression, new isInstanceOf<StringInterpolation>()); | 6181 var interpolation = expression as StringInterpolation; |
6329 StringInterpolation interpolation = expression; | |
6330 expect(interpolation.elements, hasLength(3)); | 6182 expect(interpolation.elements, hasLength(3)); |
6331 expect(interpolation.elements[0], new isInstanceOf<InterpolationString>()); | 6183 expect(interpolation.elements[0], new isInstanceOf<InterpolationString>()); |
6332 InterpolationString element0 = interpolation.elements[0]; | 6184 InterpolationString element0 = interpolation.elements[0]; |
6333 expect(element0.value, ''); | 6185 expect(element0.value, ''); |
6334 expect( | 6186 expect( |
6335 interpolation.elements[1], new isInstanceOf<InterpolationExpression>()); | 6187 interpolation.elements[1], new isInstanceOf<InterpolationExpression>()); |
6336 InterpolationExpression element1 = interpolation.elements[1]; | 6188 InterpolationExpression element1 = interpolation.elements[1]; |
6337 expect(element1.expression, new isInstanceOf<SimpleIdentifier>()); | 6189 expect(element1.expression, new isInstanceOf<SimpleIdentifier>()); |
6338 expect(interpolation.elements[2], new isInstanceOf<InterpolationString>()); | 6190 expect(interpolation.elements[2], new isInstanceOf<InterpolationString>()); |
6339 InterpolationString element2 = interpolation.elements[2]; | 6191 InterpolationString element2 = interpolation.elements[2]; |
6340 expect(element2.value, '"'); | 6192 expect(element2.value, '"'); |
6341 } | 6193 } |
6342 | 6194 |
6343 void test_parseStringLiteral_single() { | 6195 void test_parseStringLiteral_single() { |
6344 Expression expression = parseStringLiteral("'a'"); | 6196 Expression expression = parseStringLiteral("'a'"); |
6345 expect(expression, isNotNull); | 6197 expect(expression, isNotNull); |
6346 assertNoErrors(); | 6198 assertNoErrors(); |
6347 expect(expression, new isInstanceOf<SimpleStringLiteral>()); | 6199 var literal = expression as SimpleStringLiteral; |
6348 SimpleStringLiteral literal = expression; | |
6349 expect(literal.literal, isNotNull); | 6200 expect(literal.literal, isNotNull); |
6350 expect(literal.value, "a"); | 6201 expect(literal.value, "a"); |
6351 } | 6202 } |
6352 | 6203 |
6353 void test_parseStringLiteral_startsWithInterpolation() { | 6204 void test_parseStringLiteral_startsWithInterpolation() { |
6354 Expression expression = parseStringLiteral(r"'${x}y'"); | 6205 Expression expression = parseStringLiteral(r"'${x}y'"); |
6355 expect(expression, isNotNull); | 6206 expect(expression, isNotNull); |
6356 assertNoErrors(); | 6207 assertNoErrors(); |
6357 expect(expression, new isInstanceOf<StringInterpolation>()); | 6208 var interpolation = expression as StringInterpolation; |
6358 StringInterpolation interpolation = expression; | |
6359 expect(interpolation.elements, hasLength(3)); | 6209 expect(interpolation.elements, hasLength(3)); |
6360 expect(interpolation.elements[0], new isInstanceOf<InterpolationString>()); | 6210 expect(interpolation.elements[0], new isInstanceOf<InterpolationString>()); |
6361 InterpolationString element0 = interpolation.elements[0]; | 6211 InterpolationString element0 = interpolation.elements[0]; |
6362 expect(element0.value, ''); | 6212 expect(element0.value, ''); |
6363 expect( | 6213 expect( |
6364 interpolation.elements[1], new isInstanceOf<InterpolationExpression>()); | 6214 interpolation.elements[1], new isInstanceOf<InterpolationExpression>()); |
6365 InterpolationExpression element1 = interpolation.elements[1]; | 6215 InterpolationExpression element1 = interpolation.elements[1]; |
6366 expect(element1.expression, new isInstanceOf<SimpleIdentifier>()); | 6216 expect(element1.expression, new isInstanceOf<SimpleIdentifier>()); |
6367 expect(interpolation.elements[2], new isInstanceOf<InterpolationString>()); | 6217 expect(interpolation.elements[2], new isInstanceOf<InterpolationString>()); |
6368 InterpolationString element2 = interpolation.elements[2]; | 6218 InterpolationString element2 = interpolation.elements[2]; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6442 expect(literal.poundSign, isNotNull); | 6292 expect(literal.poundSign, isNotNull); |
6443 List<Token> components = literal.components; | 6293 List<Token> components = literal.components; |
6444 expect(components, hasLength(1)); | 6294 expect(components, hasLength(1)); |
6445 expect(components[0].lexeme, "void"); | 6295 expect(components[0].lexeme, "void"); |
6446 } | 6296 } |
6447 | 6297 |
6448 void test_parseThrowExpression() { | 6298 void test_parseThrowExpression() { |
6449 Expression expression = parseThrowExpression('throw x'); | 6299 Expression expression = parseThrowExpression('throw x'); |
6450 expect(expression, isNotNull); | 6300 expect(expression, isNotNull); |
6451 assertNoErrors(); | 6301 assertNoErrors(); |
6452 expect(expression, new isInstanceOf<ThrowExpression>()); | 6302 var throwExpression = expression as ThrowExpression; |
6453 ThrowExpression throwExpression = expression; | |
6454 expect(throwExpression.throwKeyword, isNotNull); | 6303 expect(throwExpression.throwKeyword, isNotNull); |
6455 expect(throwExpression.expression, isNotNull); | 6304 expect(throwExpression.expression, isNotNull); |
6456 } | 6305 } |
6457 | 6306 |
6458 void test_parseThrowExpressionWithoutCascade() { | 6307 void test_parseThrowExpressionWithoutCascade() { |
6459 Expression expression = parseThrowExpressionWithoutCascade('throw x'); | 6308 Expression expression = parseThrowExpressionWithoutCascade('throw x'); |
6460 expect(expression, isNotNull); | 6309 expect(expression, isNotNull); |
6461 assertNoErrors(); | 6310 assertNoErrors(); |
6462 expect(expression, new isInstanceOf<ThrowExpression>()); | 6311 var throwExpression = expression as ThrowExpression; |
6463 ThrowExpression throwExpression = expression; | |
6464 expect(throwExpression.throwKeyword, isNotNull); | 6312 expect(throwExpression.throwKeyword, isNotNull); |
6465 expect(throwExpression.expression, isNotNull); | 6313 expect(throwExpression.expression, isNotNull); |
6466 } | 6314 } |
6467 | 6315 |
6468 void test_parseUnaryExpression_decrement_normal() { | 6316 void test_parseUnaryExpression_decrement_normal() { |
6469 PrefixExpression expression = parseUnaryExpression('--x'); | 6317 PrefixExpression expression = parseUnaryExpression('--x'); |
6470 expect(expression, isNotNull); | 6318 expect(expression, isNotNull); |
6471 assertNoErrors(); | 6319 assertNoErrors(); |
6472 expect(expression.operator, isNotNull); | 6320 expect(expression.operator, isNotNull); |
6473 expect(expression.operator.type, TokenType.MINUS_MINUS); | 6321 expect(expression.operator.type, TokenType.MINUS_MINUS); |
(...skipping 3410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9884 expect(name.colon, isNotNull); | 9732 expect(name.colon, isNotNull); |
9885 expect(namedExpression.expression, isNotNull); | 9733 expect(namedExpression.expression, isNotNull); |
9886 } | 9734 } |
9887 | 9735 |
9888 void test_parseArgument_unnamed() { | 9736 void test_parseArgument_unnamed() { |
9889 String lexeme = "x"; | 9737 String lexeme = "x"; |
9890 createParser(lexeme); | 9738 createParser(lexeme); |
9891 Expression expression = parser.parseArgument(); | 9739 Expression expression = parser.parseArgument(); |
9892 expectNotNullIfNoErrors(expression); | 9740 expectNotNullIfNoErrors(expression); |
9893 listener.assertNoErrors(); | 9741 listener.assertNoErrors(); |
9894 expect(expression, new isInstanceOf<SimpleIdentifier>()); | 9742 var identifier = expression as SimpleIdentifier; |
9895 SimpleIdentifier identifier = expression; | |
9896 expect(identifier.name, lexeme); | 9743 expect(identifier.name, lexeme); |
9897 } | 9744 } |
9898 | 9745 |
9899 void test_parseArgumentList_empty() { | 9746 void test_parseArgumentList_empty() { |
9900 createParser('()'); | 9747 createParser('()'); |
9901 ArgumentList argumentList = parser.parseArgumentList(); | 9748 ArgumentList argumentList = parser.parseArgumentList(); |
9902 expectNotNullIfNoErrors(argumentList); | 9749 expectNotNullIfNoErrors(argumentList); |
9903 listener.assertNoErrors(); | 9750 listener.assertNoErrors(); |
9904 NodeList<Expression> arguments = argumentList.arguments; | 9751 NodeList<Expression> arguments = argumentList.arguments; |
9905 expect(arguments, hasLength(0)); | 9752 expect(arguments, hasLength(0)); |
(...skipping 4823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14729 expect(typeAlias.name, isNotNull); | 14576 expect(typeAlias.name, isNotNull); |
14730 expect(typeAlias.typeParameters, isNull); | 14577 expect(typeAlias.typeParameters, isNull); |
14731 expect(typeAlias.semicolon, isNotNull); | 14578 expect(typeAlias.semicolon, isNotNull); |
14732 GenericFunctionType functionType = typeAlias.functionType; | 14579 GenericFunctionType functionType = typeAlias.functionType; |
14733 expect(functionType, isNotNull); | 14580 expect(functionType, isNotNull); |
14734 expect(functionType.parameters, isNotNull); | 14581 expect(functionType.parameters, isNotNull); |
14735 expect(functionType.returnType, isNotNull); | 14582 expect(functionType.returnType, isNotNull); |
14736 expect(functionType.typeParameters, isNull); | 14583 expect(functionType.typeParameters, isNull); |
14737 } | 14584 } |
14738 } | 14585 } |
OLD | NEW |