| 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 // This code was auto-generated, is not intended to be edited, and is subject to | 5 // This code was auto-generated, is not intended to be edited, and is subject to |
| 6 // significant change. Please see the README file for more information. | 6 // significant change. Please see the README file for more information. |
| 7 | 7 |
| 8 library engine.parser_test; | 8 library engine.parser_test; |
| 9 | 9 |
| 10 import 'package:analyzer/src/generated/error.dart'; | 10 import 'package:analyzer/src/generated/error.dart'; |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 | 105 |
| 106 /** | 106 /** |
| 107 * The class `ComplexParserTest` defines parser tests that test the parsing of m
ore complex | 107 * The class `ComplexParserTest` defines parser tests that test the parsing of m
ore complex |
| 108 * code fragments or the interactions between multiple parsing methods. For exam
ple, tests to ensure | 108 * code fragments or the interactions between multiple parsing methods. For exam
ple, tests to ensure |
| 109 * that the precedence of operations is being handled correctly should be define
d in this class. | 109 * that the precedence of operations is being handled correctly should be define
d in this class. |
| 110 * | 110 * |
| 111 * Simpler tests should be defined in the class [SimpleParserTest]. | 111 * Simpler tests should be defined in the class [SimpleParserTest]. |
| 112 */ | 112 */ |
| 113 class ComplexParserTest extends ParserTestCase { | 113 class ComplexParserTest extends ParserTestCase { |
| 114 void test_additiveExpression_normal() { | 114 void test_additiveExpression_normal() { |
| 115 BinaryExpression expression = ParserTestCase.parseExpression("x + y - z", []
); | 115 BinaryExpression expression = ParserTestCase.parseExpression("x + y - z"); |
| 116 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, BinaryExpr
ession, expression.leftOperand); | 116 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, BinaryExpr
ession, expression.leftOperand); |
| 117 } | 117 } |
| 118 | 118 |
| 119 void test_additiveExpression_noSpaces() { | 119 void test_additiveExpression_noSpaces() { |
| 120 BinaryExpression expression = ParserTestCase.parseExpression("i+1", []); | 120 BinaryExpression expression = ParserTestCase.parseExpression("i+1"); |
| 121 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, SimpleIden
tifier, expression.leftOperand); | 121 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, SimpleIden
tifier, expression.leftOperand); |
| 122 EngineTestCase.assertInstanceOf((obj) => obj is IntegerLiteral, IntegerLiter
al, expression.rightOperand); | 122 EngineTestCase.assertInstanceOf((obj) => obj is IntegerLiteral, IntegerLiter
al, expression.rightOperand); |
| 123 } | 123 } |
| 124 | 124 |
| 125 void test_additiveExpression_precedence_multiplicative_left() { | 125 void test_additiveExpression_precedence_multiplicative_left() { |
| 126 BinaryExpression expression = ParserTestCase.parseExpression("x * y + z", []
); | 126 BinaryExpression expression = ParserTestCase.parseExpression("x * y + z"); |
| 127 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, BinaryExpr
ession, expression.leftOperand); | 127 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, BinaryExpr
ession, expression.leftOperand); |
| 128 } | 128 } |
| 129 | 129 |
| 130 void test_additiveExpression_precedence_multiplicative_left_withSuper() { | 130 void test_additiveExpression_precedence_multiplicative_left_withSuper() { |
| 131 BinaryExpression expression = ParserTestCase.parseExpression("super * y - z"
, []); | 131 BinaryExpression expression = ParserTestCase.parseExpression("super * y - z"
); |
| 132 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, BinaryExpr
ession, expression.leftOperand); | 132 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, BinaryExpr
ession, expression.leftOperand); |
| 133 } | 133 } |
| 134 | 134 |
| 135 void test_additiveExpression_precedence_multiplicative_right() { | 135 void test_additiveExpression_precedence_multiplicative_right() { |
| 136 BinaryExpression expression = ParserTestCase.parseExpression("x + y * z", []
); | 136 BinaryExpression expression = ParserTestCase.parseExpression("x + y * z"); |
| 137 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, BinaryExpr
ession, expression.rightOperand); | 137 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, BinaryExpr
ession, expression.rightOperand); |
| 138 } | 138 } |
| 139 | 139 |
| 140 void test_additiveExpression_super() { | 140 void test_additiveExpression_super() { |
| 141 BinaryExpression expression = ParserTestCase.parseExpression("super + y - z"
, []); | 141 BinaryExpression expression = ParserTestCase.parseExpression("super + y - z"
); |
| 142 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, BinaryExpr
ession, expression.leftOperand); | 142 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, BinaryExpr
ession, expression.leftOperand); |
| 143 } | 143 } |
| 144 | 144 |
| 145 void test_assignableExpression_arguments_normal_chain() { | 145 void test_assignableExpression_arguments_normal_chain() { |
| 146 PropertyAccess propertyAccess1 = ParserTestCase.parseExpression("a(b)(c).d(e
).f", []); | 146 PropertyAccess propertyAccess1 = ParserTestCase.parseExpression("a(b)(c).d(e
).f"); |
| 147 expect(propertyAccess1.propertyName.name, "f"); | 147 expect(propertyAccess1.propertyName.name, "f"); |
| 148 // | 148 // |
| 149 // a(b)(c).d(e) | 149 // a(b)(c).d(e) |
| 150 // | 150 // |
| 151 MethodInvocation invocation2 = EngineTestCase.assertInstanceOf((obj) => obj
is MethodInvocation, MethodInvocation, propertyAccess1.target); | 151 MethodInvocation invocation2 = EngineTestCase.assertInstanceOf((obj) => obj
is MethodInvocation, MethodInvocation, propertyAccess1.target); |
| 152 expect(invocation2.methodName.name, "d"); | 152 expect(invocation2.methodName.name, "d"); |
| 153 ArgumentList argumentList2 = invocation2.argumentList; | 153 ArgumentList argumentList2 = invocation2.argumentList; |
| 154 expect(argumentList2, isNotNull); | 154 expect(argumentList2, isNotNull); |
| 155 expect(argumentList2.arguments, hasLength(1)); | 155 expect(argumentList2.arguments, hasLength(1)); |
| 156 // | 156 // |
| 157 // a(b)(c) | 157 // a(b)(c) |
| 158 // | 158 // |
| 159 FunctionExpressionInvocation invocation3 = EngineTestCase.assertInstanceOf((
obj) => obj is FunctionExpressionInvocation, FunctionExpressionInvocation, invoc
ation2.target); | 159 FunctionExpressionInvocation invocation3 = EngineTestCase.assertInstanceOf((
obj) => obj is FunctionExpressionInvocation, FunctionExpressionInvocation, invoc
ation2.target); |
| 160 ArgumentList argumentList3 = invocation3.argumentList; | 160 ArgumentList argumentList3 = invocation3.argumentList; |
| 161 expect(argumentList3, isNotNull); | 161 expect(argumentList3, isNotNull); |
| 162 expect(argumentList3.arguments, hasLength(1)); | 162 expect(argumentList3.arguments, hasLength(1)); |
| 163 // | 163 // |
| 164 // a(b) | 164 // a(b) |
| 165 // | 165 // |
| 166 MethodInvocation invocation4 = EngineTestCase.assertInstanceOf((obj) => obj
is MethodInvocation, MethodInvocation, invocation3.function); | 166 MethodInvocation invocation4 = EngineTestCase.assertInstanceOf((obj) => obj
is MethodInvocation, MethodInvocation, invocation3.function); |
| 167 expect(invocation4.methodName.name, "a"); | 167 expect(invocation4.methodName.name, "a"); |
| 168 ArgumentList argumentList4 = invocation4.argumentList; | 168 ArgumentList argumentList4 = invocation4.argumentList; |
| 169 expect(argumentList4, isNotNull); | 169 expect(argumentList4, isNotNull); |
| 170 expect(argumentList4.arguments, hasLength(1)); | 170 expect(argumentList4.arguments, hasLength(1)); |
| 171 } | 171 } |
| 172 | 172 |
| 173 void test_assignmentExpression_compound() { | 173 void test_assignmentExpression_compound() { |
| 174 AssignmentExpression expression = ParserTestCase.parseExpression("x = y = 0"
, []); | 174 AssignmentExpression expression = ParserTestCase.parseExpression("x = y = 0"
); |
| 175 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, SimpleIden
tifier, expression.leftHandSide); | 175 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, SimpleIden
tifier, expression.leftHandSide); |
| 176 EngineTestCase.assertInstanceOf((obj) => obj is AssignmentExpression, Assign
mentExpression, expression.rightHandSide); | 176 EngineTestCase.assertInstanceOf((obj) => obj is AssignmentExpression, Assign
mentExpression, expression.rightHandSide); |
| 177 } | 177 } |
| 178 | 178 |
| 179 void test_assignmentExpression_indexExpression() { | 179 void test_assignmentExpression_indexExpression() { |
| 180 AssignmentExpression expression = ParserTestCase.parseExpression("x[1] = 0",
[]); | 180 AssignmentExpression expression = ParserTestCase.parseExpression("x[1] = 0")
; |
| 181 EngineTestCase.assertInstanceOf((obj) => obj is IndexExpression, IndexExpres
sion, expression.leftHandSide); | 181 EngineTestCase.assertInstanceOf((obj) => obj is IndexExpression, IndexExpres
sion, expression.leftHandSide); |
| 182 EngineTestCase.assertInstanceOf((obj) => obj is IntegerLiteral, IntegerLiter
al, expression.rightHandSide); | 182 EngineTestCase.assertInstanceOf((obj) => obj is IntegerLiteral, IntegerLiter
al, expression.rightHandSide); |
| 183 } | 183 } |
| 184 | 184 |
| 185 void test_assignmentExpression_prefixedIdentifier() { | 185 void test_assignmentExpression_prefixedIdentifier() { |
| 186 AssignmentExpression expression = ParserTestCase.parseExpression("x.y = 0",
[]); | 186 AssignmentExpression expression = ParserTestCase.parseExpression("x.y = 0"); |
| 187 EngineTestCase.assertInstanceOf((obj) => obj is PrefixedIdentifier, Prefixed
Identifier, expression.leftHandSide); | 187 EngineTestCase.assertInstanceOf((obj) => obj is PrefixedIdentifier, Prefixed
Identifier, expression.leftHandSide); |
| 188 EngineTestCase.assertInstanceOf((obj) => obj is IntegerLiteral, IntegerLiter
al, expression.rightHandSide); | 188 EngineTestCase.assertInstanceOf((obj) => obj is IntegerLiteral, IntegerLiter
al, expression.rightHandSide); |
| 189 } | 189 } |
| 190 | 190 |
| 191 void test_assignmentExpression_propertyAccess() { | 191 void test_assignmentExpression_propertyAccess() { |
| 192 AssignmentExpression expression = ParserTestCase.parseExpression("super.y =
0", []); | 192 AssignmentExpression expression = ParserTestCase.parseExpression("super.y =
0"); |
| 193 EngineTestCase.assertInstanceOf((obj) => obj is PropertyAccess, PropertyAcce
ss, expression.leftHandSide); | 193 EngineTestCase.assertInstanceOf((obj) => obj is PropertyAccess, PropertyAcce
ss, expression.leftHandSide); |
| 194 EngineTestCase.assertInstanceOf((obj) => obj is IntegerLiteral, IntegerLiter
al, expression.rightHandSide); | 194 EngineTestCase.assertInstanceOf((obj) => obj is IntegerLiteral, IntegerLiter
al, expression.rightHandSide); |
| 195 } | 195 } |
| 196 | 196 |
| 197 void test_bitwiseAndExpression_normal() { | 197 void test_bitwiseAndExpression_normal() { |
| 198 BinaryExpression expression = ParserTestCase.parseExpression("x & y & z", []
); | 198 BinaryExpression expression = ParserTestCase.parseExpression("x & y & z"); |
| 199 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, BinaryExpr
ession, expression.leftOperand); | 199 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, BinaryExpr
ession, expression.leftOperand); |
| 200 } | 200 } |
| 201 | 201 |
| 202 void test_bitwiseAndExpression_precedence_equality_left() { | 202 void test_bitwiseAndExpression_precedence_equality_left() { |
| 203 BinaryExpression expression = ParserTestCase.parseExpression("x == y && z",
[]); | 203 BinaryExpression expression = ParserTestCase.parseExpression("x == y && z"); |
| 204 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, BinaryExpr
ession, expression.leftOperand); | 204 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, BinaryExpr
ession, expression.leftOperand); |
| 205 } | 205 } |
| 206 | 206 |
| 207 void test_bitwiseAndExpression_precedence_equality_right() { | 207 void test_bitwiseAndExpression_precedence_equality_right() { |
| 208 BinaryExpression expression = ParserTestCase.parseExpression("x && y == z",
[]); | 208 BinaryExpression expression = ParserTestCase.parseExpression("x && y == z"); |
| 209 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, BinaryExpr
ession, expression.rightOperand); | 209 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, BinaryExpr
ession, expression.rightOperand); |
| 210 } | 210 } |
| 211 | 211 |
| 212 void test_bitwiseAndExpression_super() { | 212 void test_bitwiseAndExpression_super() { |
| 213 BinaryExpression expression = ParserTestCase.parseExpression("super & y & z"
, []); | 213 BinaryExpression expression = ParserTestCase.parseExpression("super & y & z"
); |
| 214 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, BinaryExpr
ession, expression.leftOperand); | 214 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, BinaryExpr
ession, expression.leftOperand); |
| 215 } | 215 } |
| 216 | 216 |
| 217 void test_bitwiseOrExpression_normal() { | 217 void test_bitwiseOrExpression_normal() { |
| 218 BinaryExpression expression = ParserTestCase.parseExpression("x | y | z", []
); | 218 BinaryExpression expression = ParserTestCase.parseExpression("x | y | z"); |
| 219 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, BinaryExpr
ession, expression.leftOperand); | 219 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, BinaryExpr
ession, expression.leftOperand); |
| 220 } | 220 } |
| 221 | 221 |
| 222 void test_bitwiseOrExpression_precedence_xor_left() { | 222 void test_bitwiseOrExpression_precedence_xor_left() { |
| 223 BinaryExpression expression = ParserTestCase.parseExpression("x ^ y | z", []
); | 223 BinaryExpression expression = ParserTestCase.parseExpression("x ^ y | z"); |
| 224 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, BinaryExpr
ession, expression.leftOperand); | 224 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, BinaryExpr
ession, expression.leftOperand); |
| 225 } | 225 } |
| 226 | 226 |
| 227 void test_bitwiseOrExpression_precedence_xor_right() { | 227 void test_bitwiseOrExpression_precedence_xor_right() { |
| 228 BinaryExpression expression = ParserTestCase.parseExpression("x | y ^ z", []
); | 228 BinaryExpression expression = ParserTestCase.parseExpression("x | y ^ z"); |
| 229 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, BinaryExpr
ession, expression.rightOperand); | 229 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, BinaryExpr
ession, expression.rightOperand); |
| 230 } | 230 } |
| 231 | 231 |
| 232 void test_bitwiseOrExpression_super() { | 232 void test_bitwiseOrExpression_super() { |
| 233 BinaryExpression expression = ParserTestCase.parseExpression("super | y | z"
, []); | 233 BinaryExpression expression = ParserTestCase.parseExpression("super | y | z"
); |
| 234 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, BinaryExpr
ession, expression.leftOperand); | 234 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, BinaryExpr
ession, expression.leftOperand); |
| 235 } | 235 } |
| 236 | 236 |
| 237 void test_bitwiseXorExpression_normal() { | 237 void test_bitwiseXorExpression_normal() { |
| 238 BinaryExpression expression = ParserTestCase.parseExpression("x ^ y ^ z", []
); | 238 BinaryExpression expression = ParserTestCase.parseExpression("x ^ y ^ z"); |
| 239 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, BinaryExpr
ession, expression.leftOperand); | 239 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, BinaryExpr
ession, expression.leftOperand); |
| 240 } | 240 } |
| 241 | 241 |
| 242 void test_bitwiseXorExpression_precedence_and_left() { | 242 void test_bitwiseXorExpression_precedence_and_left() { |
| 243 BinaryExpression expression = ParserTestCase.parseExpression("x & y ^ z", []
); | 243 BinaryExpression expression = ParserTestCase.parseExpression("x & y ^ z"); |
| 244 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, BinaryExpr
ession, expression.leftOperand); | 244 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, BinaryExpr
ession, expression.leftOperand); |
| 245 } | 245 } |
| 246 | 246 |
| 247 void test_bitwiseXorExpression_precedence_and_right() { | 247 void test_bitwiseXorExpression_precedence_and_right() { |
| 248 BinaryExpression expression = ParserTestCase.parseExpression("x ^ y & z", []
); | 248 BinaryExpression expression = ParserTestCase.parseExpression("x ^ y & z"); |
| 249 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, BinaryExpr
ession, expression.rightOperand); | 249 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, BinaryExpr
ession, expression.rightOperand); |
| 250 } | 250 } |
| 251 | 251 |
| 252 void test_bitwiseXorExpression_super() { | 252 void test_bitwiseXorExpression_super() { |
| 253 BinaryExpression expression = ParserTestCase.parseExpression("super ^ y ^ z"
, []); | 253 BinaryExpression expression = ParserTestCase.parseExpression("super ^ y ^ z"
); |
| 254 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, BinaryExpr
ession, expression.leftOperand); | 254 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, BinaryExpr
ession, expression.leftOperand); |
| 255 } | 255 } |
| 256 | 256 |
| 257 void test_cascade_withAssignment() { | 257 void test_cascade_withAssignment() { |
| 258 CascadeExpression cascade = ParserTestCase.parseExpression("new Map()..[3] =
4 ..[0] = 11;", []); | 258 CascadeExpression cascade = ParserTestCase.parseExpression("new Map()..[3] =
4 ..[0] = 11;"); |
| 259 Expression target = cascade.target; | 259 Expression target = cascade.target; |
| 260 for (Expression section in cascade.cascadeSections) { | 260 for (Expression section in cascade.cascadeSections) { |
| 261 EngineTestCase.assertInstanceOf((obj) => obj is AssignmentExpression, Assi
gnmentExpression, section); | 261 EngineTestCase.assertInstanceOf((obj) => obj is AssignmentExpression, Assi
gnmentExpression, section); |
| 262 Expression lhs = (section as AssignmentExpression).leftHandSide; | 262 Expression lhs = (section as AssignmentExpression).leftHandSide; |
| 263 EngineTestCase.assertInstanceOf((obj) => obj is IndexExpression, IndexExpr
ession, lhs); | 263 EngineTestCase.assertInstanceOf((obj) => obj is IndexExpression, IndexExpr
ession, lhs); |
| 264 IndexExpression index = lhs as IndexExpression; | 264 IndexExpression index = lhs as IndexExpression; |
| 265 expect(index.isCascaded, isTrue); | 265 expect(index.isCascaded, isTrue); |
| 266 expect(index.realTarget, same(target)); | 266 expect(index.realTarget, same(target)); |
| 267 } | 267 } |
| 268 } | 268 } |
| 269 | 269 |
| 270 void test_conditionalExpression_precedence_logicalOrExpression() { | 270 void test_conditionalExpression_precedence_logicalOrExpression() { |
| 271 ConditionalExpression expression = ParserTestCase.parseExpression("a | b ? y
: z", []); | 271 ConditionalExpression expression = ParserTestCase.parseExpression("a | b ? y
: z"); |
| 272 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, BinaryExpr
ession, expression.condition); | 272 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, BinaryExpr
ession, expression.condition); |
| 273 } | 273 } |
| 274 | 274 |
| 275 void test_constructor_initializer_withParenthesizedExpression() { | 275 void test_constructor_initializer_withParenthesizedExpression() { |
| 276 CompilationUnit unit = ParserTestCase.parseCompilationUnit(r''' | 276 CompilationUnit unit = ParserTestCase.parseCompilationUnit(r''' |
| 277 class C { | 277 class C { |
| 278 C() : | 278 C() : |
| 279 this.a = (b == null ? c : d) { | 279 this.a = (b == null ? c : d) { |
| 280 } | 280 } |
| 281 }''', []); | 281 }'''); |
| 282 NodeList<CompilationUnitMember> declarations = unit.declarations; | 282 NodeList<CompilationUnitMember> declarations = unit.declarations; |
| 283 expect(declarations, hasLength(1)); | 283 expect(declarations, hasLength(1)); |
| 284 } | 284 } |
| 285 | 285 |
| 286 void test_equalityExpression_normal() { | 286 void test_equalityExpression_normal() { |
| 287 BinaryExpression expression = ParserTestCase.parseExpression("x == y != z",
[ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND]); | 287 BinaryExpression expression = ParserTestCase.parseExpression("x == y != z",
[ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND]); |
| 288 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, BinaryExpr
ession, expression.leftOperand); | 288 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, BinaryExpr
ession, expression.leftOperand); |
| 289 } | 289 } |
| 290 | 290 |
| 291 void test_equalityExpression_precedence_relational_left() { | 291 void test_equalityExpression_precedence_relational_left() { |
| 292 BinaryExpression expression = ParserTestCase.parseExpression("x is y == z",
[]); | 292 BinaryExpression expression = ParserTestCase.parseExpression("x is y == z"); |
| 293 EngineTestCase.assertInstanceOf((obj) => obj is IsExpression, IsExpression,
expression.leftOperand); | 293 EngineTestCase.assertInstanceOf((obj) => obj is IsExpression, IsExpression,
expression.leftOperand); |
| 294 } | 294 } |
| 295 | 295 |
| 296 void test_equalityExpression_precedence_relational_right() { | 296 void test_equalityExpression_precedence_relational_right() { |
| 297 BinaryExpression expression = ParserTestCase.parseExpression("x == y is z",
[]); | 297 BinaryExpression expression = ParserTestCase.parseExpression("x == y is z"); |
| 298 EngineTestCase.assertInstanceOf((obj) => obj is IsExpression, IsExpression,
expression.rightOperand); | 298 EngineTestCase.assertInstanceOf((obj) => obj is IsExpression, IsExpression,
expression.rightOperand); |
| 299 } | 299 } |
| 300 | 300 |
| 301 void test_equalityExpression_super() { | 301 void test_equalityExpression_super() { |
| 302 BinaryExpression expression = ParserTestCase.parseExpression("super == y !=
z", [ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND]); | 302 BinaryExpression expression = ParserTestCase.parseExpression("super == y !=
z", [ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND]); |
| 303 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, BinaryExpr
ession, expression.leftOperand); | 303 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, BinaryExpr
ession, expression.leftOperand); |
| 304 } | 304 } |
| 305 | 305 |
| 306 void test_logicalAndExpression() { | 306 void test_logicalAndExpression() { |
| 307 BinaryExpression expression = ParserTestCase.parseExpression("x && y && z",
[]); | 307 BinaryExpression expression = ParserTestCase.parseExpression("x && y && z"); |
| 308 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, BinaryExpr
ession, expression.leftOperand); | 308 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, BinaryExpr
ession, expression.leftOperand); |
| 309 } | 309 } |
| 310 | 310 |
| 311 void test_logicalAndExpression_precedence_bitwiseOr_left() { | 311 void test_logicalAndExpression_precedence_bitwiseOr_left() { |
| 312 BinaryExpression expression = ParserTestCase.parseExpression("x | y < z", []
); | 312 BinaryExpression expression = ParserTestCase.parseExpression("x | y < z"); |
| 313 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, BinaryExpr
ession, expression.leftOperand); | 313 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, BinaryExpr
ession, expression.leftOperand); |
| 314 } | 314 } |
| 315 | 315 |
| 316 void test_logicalAndExpression_precedence_bitwiseOr_right() { | 316 void test_logicalAndExpression_precedence_bitwiseOr_right() { |
| 317 BinaryExpression expression = ParserTestCase.parseExpression("x < y | z", []
); | 317 BinaryExpression expression = ParserTestCase.parseExpression("x < y | z"); |
| 318 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, BinaryExpr
ession, expression.rightOperand); | 318 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, BinaryExpr
ession, expression.rightOperand); |
| 319 } | 319 } |
| 320 | 320 |
| 321 void test_logicalOrExpression() { | 321 void test_logicalOrExpression() { |
| 322 BinaryExpression expression = ParserTestCase.parseExpression("x || y || z",
[]); | 322 BinaryExpression expression = ParserTestCase.parseExpression("x || y || z"); |
| 323 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, BinaryExpr
ession, expression.leftOperand); | 323 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, BinaryExpr
ession, expression.leftOperand); |
| 324 } | 324 } |
| 325 | 325 |
| 326 void test_logicalOrExpression_precedence_logicalAnd_left() { | 326 void test_logicalOrExpression_precedence_logicalAnd_left() { |
| 327 BinaryExpression expression = ParserTestCase.parseExpression("x && y || z",
[]); | 327 BinaryExpression expression = ParserTestCase.parseExpression("x && y || z"); |
| 328 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, BinaryExpr
ession, expression.leftOperand); | 328 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, BinaryExpr
ession, expression.leftOperand); |
| 329 } | 329 } |
| 330 | 330 |
| 331 void test_logicalOrExpression_precedence_logicalAnd_right() { | 331 void test_logicalOrExpression_precedence_logicalAnd_right() { |
| 332 BinaryExpression expression = ParserTestCase.parseExpression("x || y && z",
[]); | 332 BinaryExpression expression = ParserTestCase.parseExpression("x || y && z"); |
| 333 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, BinaryExpr
ession, expression.rightOperand); | 333 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, BinaryExpr
ession, expression.rightOperand); |
| 334 } | 334 } |
| 335 | 335 |
| 336 void test_multipleLabels_statement() { | 336 void test_multipleLabels_statement() { |
| 337 LabeledStatement statement = ParserTestCase.parseStatement("a: b: c: return
x;", []); | 337 LabeledStatement statement = ParserTestCase.parseStatement("a: b: c: return
x;"); |
| 338 expect(statement.labels, hasLength(3)); | 338 expect(statement.labels, hasLength(3)); |
| 339 EngineTestCase.assertInstanceOf((obj) => obj is ReturnStatement, ReturnState
ment, statement.statement); | 339 EngineTestCase.assertInstanceOf((obj) => obj is ReturnStatement, ReturnState
ment, statement.statement); |
| 340 } | 340 } |
| 341 | 341 |
| 342 void test_multiplicativeExpression_normal() { | 342 void test_multiplicativeExpression_normal() { |
| 343 BinaryExpression expression = ParserTestCase.parseExpression("x * y / z", []
); | 343 BinaryExpression expression = ParserTestCase.parseExpression("x * y / z"); |
| 344 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, BinaryExpr
ession, expression.leftOperand); | 344 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, BinaryExpr
ession, expression.leftOperand); |
| 345 } | 345 } |
| 346 | 346 |
| 347 void test_multiplicativeExpression_precedence_unary_left() { | 347 void test_multiplicativeExpression_precedence_unary_left() { |
| 348 BinaryExpression expression = ParserTestCase.parseExpression("-x * y", []); | 348 BinaryExpression expression = ParserTestCase.parseExpression("-x * y"); |
| 349 EngineTestCase.assertInstanceOf((obj) => obj is PrefixExpression, PrefixExpr
ession, expression.leftOperand); | 349 EngineTestCase.assertInstanceOf((obj) => obj is PrefixExpression, PrefixExpr
ession, expression.leftOperand); |
| 350 } | 350 } |
| 351 | 351 |
| 352 void test_multiplicativeExpression_precedence_unary_right() { | 352 void test_multiplicativeExpression_precedence_unary_right() { |
| 353 BinaryExpression expression = ParserTestCase.parseExpression("x * -y", []); | 353 BinaryExpression expression = ParserTestCase.parseExpression("x * -y"); |
| 354 EngineTestCase.assertInstanceOf((obj) => obj is PrefixExpression, PrefixExpr
ession, expression.rightOperand); | 354 EngineTestCase.assertInstanceOf((obj) => obj is PrefixExpression, PrefixExpr
ession, expression.rightOperand); |
| 355 } | 355 } |
| 356 | 356 |
| 357 void test_multiplicativeExpression_super() { | 357 void test_multiplicativeExpression_super() { |
| 358 BinaryExpression expression = ParserTestCase.parseExpression("super * y / z"
, []); | 358 BinaryExpression expression = ParserTestCase.parseExpression("super * y / z"
); |
| 359 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, BinaryExpr
ession, expression.leftOperand); | 359 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, BinaryExpr
ession, expression.leftOperand); |
| 360 } | 360 } |
| 361 | 361 |
| 362 void test_relationalExpression_precedence_shift_right() { | 362 void test_relationalExpression_precedence_shift_right() { |
| 363 IsExpression expression = ParserTestCase.parseExpression("x << y is z", []); | 363 IsExpression expression = ParserTestCase.parseExpression("x << y is z"); |
| 364 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, BinaryExpr
ession, expression.expression); | 364 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, BinaryExpr
ession, expression.expression); |
| 365 } | 365 } |
| 366 | 366 |
| 367 void test_shiftExpression_normal() { | 367 void test_shiftExpression_normal() { |
| 368 BinaryExpression expression = ParserTestCase.parseExpression("x >> 4 << 3",
[]); | 368 BinaryExpression expression = ParserTestCase.parseExpression("x >> 4 << 3"); |
| 369 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, BinaryExpr
ession, expression.leftOperand); | 369 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, BinaryExpr
ession, expression.leftOperand); |
| 370 } | 370 } |
| 371 | 371 |
| 372 void test_shiftExpression_precedence_additive_left() { | 372 void test_shiftExpression_precedence_additive_left() { |
| 373 BinaryExpression expression = ParserTestCase.parseExpression("x + y << z", [
]); | 373 BinaryExpression expression = ParserTestCase.parseExpression("x + y << z"); |
| 374 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, BinaryExpr
ession, expression.leftOperand); | 374 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, BinaryExpr
ession, expression.leftOperand); |
| 375 } | 375 } |
| 376 | 376 |
| 377 void test_shiftExpression_precedence_additive_right() { | 377 void test_shiftExpression_precedence_additive_right() { |
| 378 BinaryExpression expression = ParserTestCase.parseExpression("x << y + z", [
]); | 378 BinaryExpression expression = ParserTestCase.parseExpression("x << y + z"); |
| 379 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, BinaryExpr
ession, expression.rightOperand); | 379 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, BinaryExpr
ession, expression.rightOperand); |
| 380 } | 380 } |
| 381 | 381 |
| 382 void test_shiftExpression_super() { | 382 void test_shiftExpression_super() { |
| 383 BinaryExpression expression = ParserTestCase.parseExpression("super >> 4 <<
3", []); | 383 BinaryExpression expression = ParserTestCase.parseExpression("super >> 4 <<
3"); |
| 384 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, BinaryExpr
ession, expression.leftOperand); | 384 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, BinaryExpr
ession, expression.leftOperand); |
| 385 } | 385 } |
| 386 | 386 |
| 387 void test_topLevelVariable_withMetadata() { | 387 void test_topLevelVariable_withMetadata() { |
| 388 ParserTestCase.parseCompilationUnit("String @A string;", []); | 388 ParserTestCase.parseCompilationUnit("String @A string;"); |
| 389 } | 389 } |
| 390 } | 390 } |
| 391 | 391 |
| 392 /** | 392 /** |
| 393 * The class `ErrorParserTest` defines parser tests that test the parsing of cod
e to ensure | 393 * The class `ErrorParserTest` defines parser tests that test the parsing of cod
e to ensure |
| 394 * that errors are correctly reported, and in some cases, not reported. | 394 * that errors are correctly reported, and in some cases, not reported. |
| 395 */ | 395 */ |
| 396 class ErrorParserTest extends ParserTestCase { | 396 class ErrorParserTest extends ParserTestCase { |
| 397 void fail_expectedListOrMapLiteral() { | 397 void fail_expectedListOrMapLiteral() { |
| 398 // It isn't clear that this test can ever pass. The parser is currently crea
te a synthetic list | 398 // It isn't clear that this test can ever pass. The parser is currently crea
te a synthetic list |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 | 521 |
| 522 void test_assertDoesNotTakeRethrow() { | 522 void test_assertDoesNotTakeRethrow() { |
| 523 ParserTestCase.parse4("parseAssertStatement", "assert(rethrow);", [ParserErr
orCode.ASSERT_DOES_NOT_TAKE_RETHROW]); | 523 ParserTestCase.parse4("parseAssertStatement", "assert(rethrow);", [ParserErr
orCode.ASSERT_DOES_NOT_TAKE_RETHROW]); |
| 524 } | 524 } |
| 525 | 525 |
| 526 void test_assertDoesNotTakeThrow() { | 526 void test_assertDoesNotTakeThrow() { |
| 527 ParserTestCase.parse4("parseAssertStatement", "assert(throw x);", [ParserErr
orCode.ASSERT_DOES_NOT_TAKE_THROW]); | 527 ParserTestCase.parse4("parseAssertStatement", "assert(throw x);", [ParserErr
orCode.ASSERT_DOES_NOT_TAKE_THROW]); |
| 528 } | 528 } |
| 529 | 529 |
| 530 void test_breakOutsideOfLoop_breakInDoStatement() { | 530 void test_breakOutsideOfLoop_breakInDoStatement() { |
| 531 ParserTestCase.parse4("parseDoStatement", "do {break;} while (x);", []); | 531 ParserTestCase.parse4("parseDoStatement", "do {break;} while (x);"); |
| 532 } | 532 } |
| 533 | 533 |
| 534 void test_breakOutsideOfLoop_breakInForStatement() { | 534 void test_breakOutsideOfLoop_breakInForStatement() { |
| 535 ParserTestCase.parse4("parseForStatement", "for (; x;) {break;}", []); | 535 ParserTestCase.parse4("parseForStatement", "for (; x;) {break;}"); |
| 536 } | 536 } |
| 537 | 537 |
| 538 void test_breakOutsideOfLoop_breakInIfStatement() { | 538 void test_breakOutsideOfLoop_breakInIfStatement() { |
| 539 ParserTestCase.parse4("parseIfStatement", "if (x) {break;}", [ParserErrorCod
e.BREAK_OUTSIDE_OF_LOOP]); | 539 ParserTestCase.parse4("parseIfStatement", "if (x) {break;}", [ParserErrorCod
e.BREAK_OUTSIDE_OF_LOOP]); |
| 540 } | 540 } |
| 541 | 541 |
| 542 void test_breakOutsideOfLoop_breakInSwitchStatement() { | 542 void test_breakOutsideOfLoop_breakInSwitchStatement() { |
| 543 ParserTestCase.parse4("parseSwitchStatement", "switch (x) {case 1: break;}",
[]); | 543 ParserTestCase.parse4("parseSwitchStatement", "switch (x) {case 1: break;}")
; |
| 544 } | 544 } |
| 545 | 545 |
| 546 void test_breakOutsideOfLoop_breakInWhileStatement() { | 546 void test_breakOutsideOfLoop_breakInWhileStatement() { |
| 547 ParserTestCase.parse4("parseWhileStatement", "while (x) {break;}", []); | 547 ParserTestCase.parse4("parseWhileStatement", "while (x) {break;}"); |
| 548 } | 548 } |
| 549 | 549 |
| 550 void test_breakOutsideOfLoop_functionExpression_inALoop() { | 550 void test_breakOutsideOfLoop_functionExpression_inALoop() { |
| 551 ParserTestCase.parseStatement("for(; x;) {() {break;};}", [ParserErrorCode.B
REAK_OUTSIDE_OF_LOOP]); | 551 ParserTestCase.parseStatement("for(; x;) {() {break;};}", [ParserErrorCode.B
REAK_OUTSIDE_OF_LOOP]); |
| 552 } | 552 } |
| 553 | 553 |
| 554 void test_breakOutsideOfLoop_functionExpression_withALoop() { | 554 void test_breakOutsideOfLoop_functionExpression_withALoop() { |
| 555 ParserTestCase.parseStatement("() {for (; x;) {break;}};", []); | 555 ParserTestCase.parseStatement("() {for (; x;) {break;}};"); |
| 556 } | 556 } |
| 557 | 557 |
| 558 void test_classTypeAlias_abstractAfterEq() { | 558 void test_classTypeAlias_abstractAfterEq() { |
| 559 // This syntax has been removed from the language in favor of "abstract clas
s A = B with C;" | 559 // This syntax has been removed from the language in favor of "abstract clas
s A = B with C;" |
| 560 // (issue 18098). | 560 // (issue 18098). |
| 561 ParserTestCase.parse3("parseCompilationUnitMember", <Object> [emptyCommentAn
dMetadata()], "class A = abstract B with C;", [ | 561 ParserTestCase.parse3("parseCompilationUnitMember", <Object> [emptyCommentAn
dMetadata()], "class A = abstract B with C;", [ |
| 562 ParserErrorCode.EXPECTED_TOKEN, | 562 ParserErrorCode.EXPECTED_TOKEN, |
| 563 ParserErrorCode.EXPECTED_TOKEN]); | 563 ParserErrorCode.EXPECTED_TOKEN]); |
| 564 } | 564 } |
| 565 | 565 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 | 597 |
| 598 void test_constructorWithReturnType_var() { | 598 void test_constructorWithReturnType_var() { |
| 599 ParserTestCase.parse3("parseClassMember", <Object> ["C"], "var C() {}", [Par
serErrorCode.CONSTRUCTOR_WITH_RETURN_TYPE]); | 599 ParserTestCase.parse3("parseClassMember", <Object> ["C"], "var C() {}", [Par
serErrorCode.CONSTRUCTOR_WITH_RETURN_TYPE]); |
| 600 } | 600 } |
| 601 | 601 |
| 602 void test_constTypedef() { | 602 void test_constTypedef() { |
| 603 ParserTestCase.parseCompilationUnit("const typedef F();", [ParserErrorCode.C
ONST_TYPEDEF]); | 603 ParserTestCase.parseCompilationUnit("const typedef F();", [ParserErrorCode.C
ONST_TYPEDEF]); |
| 604 } | 604 } |
| 605 | 605 |
| 606 void test_continueOutsideOfLoop_continueInDoStatement() { | 606 void test_continueOutsideOfLoop_continueInDoStatement() { |
| 607 ParserTestCase.parse4("parseDoStatement", "do {continue;} while (x);", []); | 607 ParserTestCase.parse4("parseDoStatement", "do {continue;} while (x);"); |
| 608 } | 608 } |
| 609 | 609 |
| 610 void test_continueOutsideOfLoop_continueInForStatement() { | 610 void test_continueOutsideOfLoop_continueInForStatement() { |
| 611 ParserTestCase.parse4("parseForStatement", "for (; x;) {continue;}", []); | 611 ParserTestCase.parse4("parseForStatement", "for (; x;) {continue;}"); |
| 612 } | 612 } |
| 613 | 613 |
| 614 void test_continueOutsideOfLoop_continueInIfStatement() { | 614 void test_continueOutsideOfLoop_continueInIfStatement() { |
| 615 ParserTestCase.parse4("parseIfStatement", "if (x) {continue;}", [ParserError
Code.CONTINUE_OUTSIDE_OF_LOOP]); | 615 ParserTestCase.parse4("parseIfStatement", "if (x) {continue;}", [ParserError
Code.CONTINUE_OUTSIDE_OF_LOOP]); |
| 616 } | 616 } |
| 617 | 617 |
| 618 void test_continueOutsideOfLoop_continueInSwitchStatement() { | 618 void test_continueOutsideOfLoop_continueInSwitchStatement() { |
| 619 ParserTestCase.parse4("parseSwitchStatement", "switch (x) {case 1: continue
a;}", []); | 619 ParserTestCase.parse4("parseSwitchStatement", "switch (x) {case 1: continue
a;}"); |
| 620 } | 620 } |
| 621 | 621 |
| 622 void test_continueOutsideOfLoop_continueInWhileStatement() { | 622 void test_continueOutsideOfLoop_continueInWhileStatement() { |
| 623 ParserTestCase.parse4("parseWhileStatement", "while (x) {continue;}", []); | 623 ParserTestCase.parse4("parseWhileStatement", "while (x) {continue;}"); |
| 624 } | 624 } |
| 625 | 625 |
| 626 void test_continueOutsideOfLoop_functionExpression_inALoop() { | 626 void test_continueOutsideOfLoop_functionExpression_inALoop() { |
| 627 ParserTestCase.parseStatement("for(; x;) {() {continue;};}", [ParserErrorCod
e.CONTINUE_OUTSIDE_OF_LOOP]); | 627 ParserTestCase.parseStatement("for(; x;) {() {continue;};}", [ParserErrorCod
e.CONTINUE_OUTSIDE_OF_LOOP]); |
| 628 } | 628 } |
| 629 | 629 |
| 630 void test_continueOutsideOfLoop_functionExpression_withALoop() { | 630 void test_continueOutsideOfLoop_functionExpression_withALoop() { |
| 631 ParserTestCase.parseStatement("() {for (; x;) {continue;}};", []); | 631 ParserTestCase.parseStatement("() {for (; x;) {continue;}};"); |
| 632 } | 632 } |
| 633 | 633 |
| 634 void test_continueWithoutLabelInCase_error() { | 634 void test_continueWithoutLabelInCase_error() { |
| 635 ParserTestCase.parse4("parseSwitchStatement", "switch (x) {case 1: continue;
}", [ParserErrorCode.CONTINUE_WITHOUT_LABEL_IN_CASE]); | 635 ParserTestCase.parse4("parseSwitchStatement", "switch (x) {case 1: continue;
}", [ParserErrorCode.CONTINUE_WITHOUT_LABEL_IN_CASE]); |
| 636 } | 636 } |
| 637 | 637 |
| 638 void test_continueWithoutLabelInCase_noError() { | 638 void test_continueWithoutLabelInCase_noError() { |
| 639 ParserTestCase.parse4("parseSwitchStatement", "switch (x) {case 1: continue
a;}", []); | 639 ParserTestCase.parse4("parseSwitchStatement", "switch (x) {case 1: continue
a;}"); |
| 640 } | 640 } |
| 641 | 641 |
| 642 void test_continueWithoutLabelInCase_noError_switchInLoop() { | 642 void test_continueWithoutLabelInCase_noError_switchInLoop() { |
| 643 ParserTestCase.parse4("parseWhileStatement", "while (a) { switch (b) {defaul
t: continue;}}", []); | 643 ParserTestCase.parse4("parseWhileStatement", "while (a) { switch (b) {defaul
t: continue;}}"); |
| 644 } | 644 } |
| 645 | 645 |
| 646 void test_deprecatedClassTypeAlias() { | 646 void test_deprecatedClassTypeAlias() { |
| 647 ParserTestCase.parseCompilationUnit("typedef C = S with M;", [ParserErrorCod
e.DEPRECATED_CLASS_TYPE_ALIAS]); | 647 ParserTestCase.parseCompilationUnit("typedef C = S with M;", [ParserErrorCod
e.DEPRECATED_CLASS_TYPE_ALIAS]); |
| 648 } | 648 } |
| 649 | 649 |
| 650 void test_deprecatedClassTypeAlias_withGeneric() { | 650 void test_deprecatedClassTypeAlias_withGeneric() { |
| 651 ParserTestCase.parseCompilationUnit("typedef C<T> = S<T> with M;", [ParserEr
rorCode.DEPRECATED_CLASS_TYPE_ALIAS]); | 651 ParserTestCase.parseCompilationUnit("typedef C<T> = S<T> with M;", [ParserEr
rorCode.DEPRECATED_CLASS_TYPE_ALIAS]); |
| 652 } | 652 } |
| 653 | 653 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 727 | 727 |
| 728 void test_expectedExecutable_topLevel_afterVoid() { | 728 void test_expectedExecutable_topLevel_afterVoid() { |
| 729 ParserTestCase.parse3("parseCompilationUnitMember", <Object> [emptyCommentAn
dMetadata()], "void 2 void", [ParserErrorCode.EXPECTED_EXECUTABLE]); | 729 ParserTestCase.parse3("parseCompilationUnitMember", <Object> [emptyCommentAn
dMetadata()], "void 2 void", [ParserErrorCode.EXPECTED_EXECUTABLE]); |
| 730 } | 730 } |
| 731 | 731 |
| 732 void test_expectedExecutable_topLevel_beforeType() { | 732 void test_expectedExecutable_topLevel_beforeType() { |
| 733 ParserTestCase.parse3("parseCompilationUnitMember", <Object> [emptyCommentAn
dMetadata()], "4 score", [ParserErrorCode.EXPECTED_EXECUTABLE]); | 733 ParserTestCase.parse3("parseCompilationUnitMember", <Object> [emptyCommentAn
dMetadata()], "4 score", [ParserErrorCode.EXPECTED_EXECUTABLE]); |
| 734 } | 734 } |
| 735 | 735 |
| 736 void test_expectedExecutable_topLevel_eof() { | 736 void test_expectedExecutable_topLevel_eof() { |
| 737 ParserTestCase.parse2("parseCompilationUnitMember", <Object> [emptyCommentAn
dMetadata()], "x", [new AnalysisError.con2(null, 0, 1, ParserErrorCode.EXPECTED_
EXECUTABLE, [])]); | 737 ParserTestCase.parse2("parseCompilationUnitMember", <Object> [emptyCommentAn
dMetadata()], "x", [new AnalysisError.con2(null, 0, 1, ParserErrorCode.EXPECTED_
EXECUTABLE)]); |
| 738 } | 738 } |
| 739 | 739 |
| 740 void test_expectedInterpolationIdentifier() { | 740 void test_expectedInterpolationIdentifier() { |
| 741 ParserTestCase.parse4("parseStringLiteral", "'\$x\$'", [ParserErrorCode.MISS
ING_IDENTIFIER]); | 741 ParserTestCase.parse4("parseStringLiteral", "'\$x\$'", [ParserErrorCode.MISS
ING_IDENTIFIER]); |
| 742 } | 742 } |
| 743 | 743 |
| 744 void test_expectedInterpolationIdentifier_emptyString() { | 744 void test_expectedInterpolationIdentifier_emptyString() { |
| 745 // The scanner inserts an empty string token between the two $'s; we need to
make sure that the | 745 // The scanner inserts an empty string token between the two $'s; we need to
make sure that the |
| 746 // MISSING_IDENTIFIER error that is generated has a nonzero width so that it
will show up in | 746 // MISSING_IDENTIFIER error that is generated has a nonzero width so that it
will show up in |
| 747 // the editor UI. | 747 // the editor UI. |
| 748 ParserTestCase.parse2("parseStringLiteral", <Object> [], "'\$\$foo'", [new A
nalysisError.con2(null, 2, 1, ParserErrorCode.MISSING_IDENTIFIER, [])]); | 748 ParserTestCase.parse2("parseStringLiteral", <Object>[], "'\$\$foo'", [new An
alysisError.con2(null, 2, 1, ParserErrorCode.MISSING_IDENTIFIER)]); |
| 749 } | 749 } |
| 750 | 750 |
| 751 void test_expectedStringLiteral() { | 751 void test_expectedStringLiteral() { |
| 752 StringLiteral expression = ParserTestCase.parse4("parseStringLiteral", "1",
[ParserErrorCode.EXPECTED_STRING_LITERAL]); | 752 StringLiteral expression = ParserTestCase.parse4("parseStringLiteral", "1",
[ParserErrorCode.EXPECTED_STRING_LITERAL]); |
| 753 expect(expression.isSynthetic, isTrue); | 753 expect(expression.isSynthetic, isTrue); |
| 754 } | 754 } |
| 755 | 755 |
| 756 void test_expectedToken_commaMissingInArgumentList() { | 756 void test_expectedToken_commaMissingInArgumentList() { |
| 757 ParserTestCase.parse4("parseArgumentList", "(x, y z)", [ParserErrorCode.EXPE
CTED_TOKEN]); | 757 ParserTestCase.parse4("parseArgumentList", "(x, y z)", [ParserErrorCode.EXPE
CTED_TOKEN]); |
| 758 } | 758 } |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1070 | 1070 |
| 1071 void test_localFunctionDeclarationModifier_factory() { | 1071 void test_localFunctionDeclarationModifier_factory() { |
| 1072 ParserTestCase.parseStatement("factory f() {}", [ParserErrorCode.LOCAL_FUNCT
ION_DECLARATION_MODIFIER]); | 1072 ParserTestCase.parseStatement("factory f() {}", [ParserErrorCode.LOCAL_FUNCT
ION_DECLARATION_MODIFIER]); |
| 1073 } | 1073 } |
| 1074 | 1074 |
| 1075 void test_localFunctionDeclarationModifier_static() { | 1075 void test_localFunctionDeclarationModifier_static() { |
| 1076 ParserTestCase.parseStatement("static f() {}", [ParserErrorCode.LOCAL_FUNCTI
ON_DECLARATION_MODIFIER]); | 1076 ParserTestCase.parseStatement("static f() {}", [ParserErrorCode.LOCAL_FUNCTI
ON_DECLARATION_MODIFIER]); |
| 1077 } | 1077 } |
| 1078 | 1078 |
| 1079 void test_missingAssignableSelector_identifiersAssigned() { | 1079 void test_missingAssignableSelector_identifiersAssigned() { |
| 1080 ParserTestCase.parseExpression("x.y = y;", []); | 1080 ParserTestCase.parseExpression("x.y = y;"); |
| 1081 } | 1081 } |
| 1082 | 1082 |
| 1083 void test_missingAssignableSelector_prefix_minusMinus_literal() { | 1083 void test_missingAssignableSelector_prefix_minusMinus_literal() { |
| 1084 ParserTestCase.parseExpression("--0", [ParserErrorCode.MISSING_ASSIGNABLE_SE
LECTOR]); | 1084 ParserTestCase.parseExpression("--0", [ParserErrorCode.MISSING_ASSIGNABLE_SE
LECTOR]); |
| 1085 } | 1085 } |
| 1086 | 1086 |
| 1087 void test_missingAssignableSelector_prefix_plusPlus_literal() { | 1087 void test_missingAssignableSelector_prefix_plusPlus_literal() { |
| 1088 ParserTestCase.parseExpression("++0", [ParserErrorCode.MISSING_ASSIGNABLE_SE
LECTOR]); | 1088 ParserTestCase.parseExpression("++0", [ParserErrorCode.MISSING_ASSIGNABLE_SE
LECTOR]); |
| 1089 } | 1089 } |
| 1090 | 1090 |
| 1091 void test_missingAssignableSelector_selector() { | 1091 void test_missingAssignableSelector_selector() { |
| 1092 ParserTestCase.parseExpression("x(y)(z).a++", []); | 1092 ParserTestCase.parseExpression("x(y)(z).a++"); |
| 1093 } | 1093 } |
| 1094 | 1094 |
| 1095 void test_missingAssignableSelector_superPrimaryExpression() { | 1095 void test_missingAssignableSelector_superPrimaryExpression() { |
| 1096 SuperExpression expression = ParserTestCase.parse4("parsePrimaryExpression",
"super", [ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR]); | 1096 SuperExpression expression = ParserTestCase.parse4("parsePrimaryExpression",
"super", [ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR]); |
| 1097 expect(expression.keyword, isNotNull); | 1097 expect(expression.keyword, isNotNull); |
| 1098 } | 1098 } |
| 1099 | 1099 |
| 1100 void test_missingAssignableSelector_superPropertyAccessAssigned() { | 1100 void test_missingAssignableSelector_superPropertyAccessAssigned() { |
| 1101 ParserTestCase.parseExpression("super.x = x;", []); | 1101 ParserTestCase.parseExpression("super.x = x;"); |
| 1102 } | 1102 } |
| 1103 | 1103 |
| 1104 void test_missingCatchOrFinally() { | 1104 void test_missingCatchOrFinally() { |
| 1105 TryStatement statement = ParserTestCase.parse4("parseTryStatement", "try {}"
, [ParserErrorCode.MISSING_CATCH_OR_FINALLY]); | 1105 TryStatement statement = ParserTestCase.parse4("parseTryStatement", "try {}"
, [ParserErrorCode.MISSING_CATCH_OR_FINALLY]); |
| 1106 expect(statement, isNotNull); | 1106 expect(statement, isNotNull); |
| 1107 } | 1107 } |
| 1108 | 1108 |
| 1109 void test_missingClassBody() { | 1109 void test_missingClassBody() { |
| 1110 ParserTestCase.parseCompilationUnit("class A class B {}", [ParserErrorCode.M
ISSING_CLASS_BODY]); | 1110 ParserTestCase.parseCompilationUnit("class A class B {}", [ParserErrorCode.M
ISSING_CLASS_BODY]); |
| 1111 } | 1111 } |
| (...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1869 * The given source is scanned and the parser is initialized to start with the
first token in the | 1869 * The given source is scanned and the parser is initialized to start with the
first token in the |
| 1870 * source before the parse method is invoked. | 1870 * source before the parse method is invoked. |
| 1871 * | 1871 * |
| 1872 * @param methodName the name of the parse method that should be invoked to pa
rse the source | 1872 * @param methodName the name of the parse method that should be invoked to pa
rse the source |
| 1873 * @param objects the values of the arguments to the method | 1873 * @param objects the values of the arguments to the method |
| 1874 * @param source the source to be parsed by the parse method | 1874 * @param source the source to be parsed by the parse method |
| 1875 * @return the result of invoking the method | 1875 * @return the result of invoking the method |
| 1876 * @throws Exception if the method could not be invoked or throws an exception | 1876 * @throws Exception if the method could not be invoked or throws an exception |
| 1877 * @throws AssertionFailedError if the result is `null` or if any errors are p
roduced | 1877 * @throws AssertionFailedError if the result is `null` or if any errors are p
roduced |
| 1878 */ | 1878 */ |
| 1879 static Object parse(String methodName, List<Object> objects, String source) =>
parse2(methodName, objects, source, new List<AnalysisError>(0)); | 1879 static Object parse(String methodName, List<Object> objects, String source) |
| 1880 => parse2(methodName, objects, source); |
| 1880 | 1881 |
| 1881 /** | 1882 /** |
| 1882 * Invoke a parse method in [Parser]. The method is assumed to have the given
number and | 1883 * Invoke a parse method in [Parser]. The method is assumed to have the given
number and |
| 1883 * type of parameters and will be invoked with the given arguments. | 1884 * type of parameters and will be invoked with the given arguments. |
| 1884 * | 1885 * |
| 1885 * The given source is scanned and the parser is initialized to start with the
first token in the | 1886 * The given source is scanned and the parser is initialized to start with the
first token in the |
| 1886 * source before the parse method is invoked. | 1887 * source before the parse method is invoked. |
| 1887 * | 1888 * |
| 1888 * @param methodName the name of the parse method that should be invoked to pa
rse the source | 1889 * @param methodName the name of the parse method that should be invoked to pa
rse the source |
| 1889 * @param objects the values of the arguments to the method | 1890 * @param objects the values of the arguments to the method |
| 1890 * @param source the source to be parsed by the parse method | 1891 * @param source the source to be parsed by the parse method |
| 1891 * @param errors the errors that should be generated | 1892 * @param errors the errors that should be generated |
| 1892 * @return the result of invoking the method | 1893 * @return the result of invoking the method |
| 1893 * @throws Exception if the method could not be invoked or throws an exception | 1894 * @throws Exception if the method could not be invoked or throws an exception |
| 1894 * @throws AssertionFailedError if the result is `null` or the errors produced
while | 1895 * @throws AssertionFailedError if the result is `null` or the errors produced
while |
| 1895 * scanning and parsing the source do not match the expected errors | 1896 * scanning and parsing the source do not match the expected errors |
| 1896 */ | 1897 */ |
| 1897 static Object parse2(String methodName, List<Object> objects, String source, L
ist<AnalysisError> errors) { | 1898 static Object parse2(String methodName, List<Object> objects, String source, [
List<AnalysisError> errors = AnalysisError.NO_ERRORS]) { |
| 1898 GatheringErrorListener listener = new GatheringErrorListener(); | 1899 GatheringErrorListener listener = new GatheringErrorListener(); |
| 1899 Object result = invokeParserMethod(methodName, objects, source, listener); | 1900 Object result = invokeParserMethod(methodName, objects, source, listener); |
| 1900 listener.assertErrors(errors); | 1901 listener.assertErrors(errors); |
| 1901 return result; | 1902 return result; |
| 1902 } | 1903 } |
| 1903 | 1904 |
| 1904 /** | 1905 /** |
| 1905 * Invoke a parse method in [Parser]. The method is assumed to have the given
number and | 1906 * Invoke a parse method in [Parser]. The method is assumed to have the given
number and |
| 1906 * type of parameters and will be invoked with the given arguments. | 1907 * type of parameters and will be invoked with the given arguments. |
| 1907 * | 1908 * |
| 1908 * The given source is scanned and the parser is initialized to start with the
first token in the | 1909 * The given source is scanned and the parser is initialized to start with the
first token in the |
| 1909 * source before the parse method is invoked. | 1910 * source before the parse method is invoked. |
| 1910 * | 1911 * |
| 1911 * @param methodName the name of the parse method that should be invoked to pa
rse the source | 1912 * @param methodName the name of the parse method that should be invoked to pa
rse the source |
| 1912 * @param objects the values of the arguments to the method | 1913 * @param objects the values of the arguments to the method |
| 1913 * @param source the source to be parsed by the parse method | 1914 * @param source the source to be parsed by the parse method |
| 1914 * @param errorCodes the error codes of the errors that should be generated | 1915 * @param errorCodes the error codes of the errors that should be generated |
| 1915 * @return the result of invoking the method | 1916 * @return the result of invoking the method |
| 1916 * @throws Exception if the method could not be invoked or throws an exception | 1917 * @throws Exception if the method could not be invoked or throws an exception |
| 1917 * @throws AssertionFailedError if the result is `null` or the errors produced
while | 1918 * @throws AssertionFailedError if the result is `null` or the errors produced
while |
| 1918 * scanning and parsing the source do not match the expected errors | 1919 * scanning and parsing the source do not match the expected errors |
| 1919 */ | 1920 */ |
| 1920 static Object parse3(String methodName, List<Object> objects, String source, L
ist<ErrorCode> errorCodes) { | 1921 static Object parse3(String methodName, List<Object> objects, String source, [
List<ErrorCode> errorCodes = ErrorCode.EMPTY_LIST]) { |
| 1921 GatheringErrorListener listener = new GatheringErrorListener(); | 1922 GatheringErrorListener listener = new GatheringErrorListener(); |
| 1922 Object result = invokeParserMethod(methodName, objects, source, listener); | 1923 Object result = invokeParserMethod(methodName, objects, source, listener); |
| 1923 listener.assertErrorsWithCodes(errorCodes); | 1924 listener.assertErrorsWithCodes(errorCodes); |
| 1924 return result; | 1925 return result; |
| 1925 } | 1926 } |
| 1926 | 1927 |
| 1927 /** | 1928 /** |
| 1928 * Invoke a parse method in [Parser]. The method is assumed to have no argumen
ts. | 1929 * Invoke a parse method in [Parser]. The method is assumed to have no argumen
ts. |
| 1929 * | 1930 * |
| 1930 * The given source is scanned and the parser is initialized to start with the
first token in the | 1931 * The given source is scanned and the parser is initialized to start with the
first token in the |
| 1931 * source before the parse method is invoked. | 1932 * source before the parse method is invoked. |
| 1932 * | 1933 * |
| 1933 * @param methodName the name of the parse method that should be invoked to pa
rse the source | 1934 * @param methodName the name of the parse method that should be invoked to pa
rse the source |
| 1934 * @param source the source to be parsed by the parse method | 1935 * @param source the source to be parsed by the parse method |
| 1935 * @param errorCodes the error codes of the errors that should be generated | 1936 * @param errorCodes the error codes of the errors that should be generated |
| 1936 * @return the result of invoking the method | 1937 * @return the result of invoking the method |
| 1937 * @throws Exception if the method could not be invoked or throws an exception | 1938 * @throws Exception if the method could not be invoked or throws an exception |
| 1938 * @throws AssertionFailedError if the result is `null` or the errors produced
while | 1939 * @throws AssertionFailedError if the result is `null` or the errors produced
while |
| 1939 * scanning and parsing the source do not match the expected errors | 1940 * scanning and parsing the source do not match the expected errors |
| 1940 */ | 1941 */ |
| 1941 static Object parse4(String methodName, String source, List<ErrorCode> errorCo
des) => parse3(methodName, _EMPTY_ARGUMENTS, source, errorCodes); | 1942 static Object parse4(String methodName, String source, [List<ErrorCode> errorC
odes = ErrorCode.EMPTY_LIST]) |
| 1943 => parse3(methodName, _EMPTY_ARGUMENTS, source, errorCodes); |
| 1942 | 1944 |
| 1943 /** | 1945 /** |
| 1944 * Parse the given source as a compilation unit. | 1946 * Parse the given source as a compilation unit. |
| 1945 * | 1947 * |
| 1946 * @param source the source to be parsed | 1948 * @param source the source to be parsed |
| 1947 * @param errorCodes the error codes of the errors that are expected to be fou
nd | 1949 * @param errorCodes the error codes of the errors that are expected to be fou
nd |
| 1948 * @return the compilation unit that was parsed | 1950 * @return the compilation unit that was parsed |
| 1949 * @throws Exception if the source could not be parsed, if the compilation err
ors in the source do | 1951 * @throws Exception if the source could not be parsed, if the compilation err
ors in the source do |
| 1950 * not match those that are expected, or if the result would have be
en `null` | 1952 * not match those that are expected, or if the result would have be
en `null` |
| 1951 */ | 1953 */ |
| 1952 static CompilationUnit parseCompilationUnit(String source, List<ErrorCode> err
orCodes) { | 1954 static CompilationUnit parseCompilationUnit(String source, [List<ErrorCode> er
rorCodes = ErrorCode.EMPTY_LIST]) { |
| 1953 GatheringErrorListener listener = new GatheringErrorListener(); | 1955 GatheringErrorListener listener = new GatheringErrorListener(); |
| 1954 Scanner scanner = new Scanner(null, new CharSequenceReader(source), listener
); | 1956 Scanner scanner = new Scanner(null, new CharSequenceReader(source), listener
); |
| 1955 listener.setLineInfo(new TestSource(), scanner.lineStarts); | 1957 listener.setLineInfo(new TestSource(), scanner.lineStarts); |
| 1956 Token token = scanner.tokenize(); | 1958 Token token = scanner.tokenize(); |
| 1957 Parser parser = createParser(listener); | 1959 Parser parser = createParser(listener); |
| 1958 CompilationUnit unit = parser.parseCompilationUnit(token); | 1960 CompilationUnit unit = parser.parseCompilationUnit(token); |
| 1959 expect(unit, isNotNull); | 1961 expect(unit, isNotNull); |
| 1960 listener.assertErrorsWithCodes(errorCodes); | 1962 listener.assertErrorsWithCodes(errorCodes); |
| 1961 return unit; | 1963 return unit; |
| 1962 } | 1964 } |
| 1963 | 1965 |
| 1964 /** | 1966 /** |
| 1965 * Parse the given source as an expression. | 1967 * Parse the given source as an expression. |
| 1966 * | 1968 * |
| 1967 * @param source the source to be parsed | 1969 * @param source the source to be parsed |
| 1968 * @param errorCodes the error codes of the errors that are expected to be fou
nd | 1970 * @param errorCodes the error codes of the errors that are expected to be fou
nd |
| 1969 * @return the expression that was parsed | 1971 * @return the expression that was parsed |
| 1970 * @throws Exception if the source could not be parsed, if the compilation err
ors in the source do | 1972 * @throws Exception if the source could not be parsed, if the compilation err
ors in the source do |
| 1971 * not match those that are expected, or if the result would have be
en `null` | 1973 * not match those that are expected, or if the result would have be
en `null` |
| 1972 */ | 1974 */ |
| 1973 static Expression parseExpression(String source, List<ErrorCode> errorCodes) { | 1975 static Expression parseExpression(String source, [List<ErrorCode> errorCodes =
ErrorCode.EMPTY_LIST]) { |
| 1974 GatheringErrorListener listener = new GatheringErrorListener(); | 1976 GatheringErrorListener listener = new GatheringErrorListener(); |
| 1975 Scanner scanner = new Scanner(null, new CharSequenceReader(source), listener
); | 1977 Scanner scanner = new Scanner(null, new CharSequenceReader(source), listener
); |
| 1976 listener.setLineInfo(new TestSource(), scanner.lineStarts); | 1978 listener.setLineInfo(new TestSource(), scanner.lineStarts); |
| 1977 Token token = scanner.tokenize(); | 1979 Token token = scanner.tokenize(); |
| 1978 Parser parser = createParser(listener); | 1980 Parser parser = createParser(listener); |
| 1979 Expression expression = parser.parseExpression(token); | 1981 Expression expression = parser.parseExpression(token); |
| 1980 expect(expression, isNotNull); | 1982 expect(expression, isNotNull); |
| 1981 listener.assertErrorsWithCodes(errorCodes); | 1983 listener.assertErrorsWithCodes(errorCodes); |
| 1982 return expression; | 1984 return expression; |
| 1983 } | 1985 } |
| 1984 | 1986 |
| 1985 /** | 1987 /** |
| 1986 * Parse the given source as a statement. | 1988 * Parse the given source as a statement. |
| 1987 * | 1989 * |
| 1988 * @param source the source to be parsed | 1990 * @param source the source to be parsed |
| 1989 * @param errorCodes the error codes of the errors that are expected to be fou
nd | 1991 * @param errorCodes the error codes of the errors that are expected to be fou
nd |
| 1990 * @return the statement that was parsed | 1992 * @return the statement that was parsed |
| 1991 * @throws Exception if the source could not be parsed, if the compilation err
ors in the source do | 1993 * @throws Exception if the source could not be parsed, if the compilation err
ors in the source do |
| 1992 * not match those that are expected, or if the result would have be
en `null` | 1994 * not match those that are expected, or if the result would have be
en `null` |
| 1993 */ | 1995 */ |
| 1994 static Statement parseStatement(String source, List<ErrorCode> errorCodes) { | 1996 static Statement parseStatement(String source, [List<ErrorCode> errorCodes = E
rrorCode.EMPTY_LIST]) { |
| 1995 GatheringErrorListener listener = new GatheringErrorListener(); | 1997 GatheringErrorListener listener = new GatheringErrorListener(); |
| 1996 Scanner scanner = new Scanner(null, new CharSequenceReader(source), listener
); | 1998 Scanner scanner = new Scanner(null, new CharSequenceReader(source), listener
); |
| 1997 listener.setLineInfo(new TestSource(), scanner.lineStarts); | 1999 listener.setLineInfo(new TestSource(), scanner.lineStarts); |
| 1998 Token token = scanner.tokenize(); | 2000 Token token = scanner.tokenize(); |
| 1999 Parser parser = createParser(listener); | 2001 Parser parser = createParser(listener); |
| 2000 Statement statement = parser.parseStatement(token); | 2002 Statement statement = parser.parseStatement(token); |
| 2001 expect(statement, isNotNull); | 2003 expect(statement, isNotNull); |
| 2002 listener.assertErrorsWithCodes(errorCodes); | 2004 listener.assertErrorsWithCodes(errorCodes); |
| 2003 return statement; | 2005 return statement; |
| 2004 } | 2006 } |
| 2005 | 2007 |
| 2006 /** | 2008 /** |
| 2007 * Parse the given source as a sequence of statements. | 2009 * Parse the given source as a sequence of statements. |
| 2008 * | 2010 * |
| 2009 * @param source the source to be parsed | 2011 * @param source the source to be parsed |
| 2010 * @param expectedCount the number of statements that are expected | 2012 * @param expectedCount the number of statements that are expected |
| 2011 * @param errorCodes the error codes of the errors that are expected to be fou
nd | 2013 * @param errorCodes the error codes of the errors that are expected to be fou
nd |
| 2012 * @return the statements that were parsed | 2014 * @return the statements that were parsed |
| 2013 * @throws Exception if the source could not be parsed, if the number of state
ments does not match | 2015 * @throws Exception if the source could not be parsed, if the number of state
ments does not match |
| 2014 * the expected count, if the compilation errors in the source do no
t match those that | 2016 * the expected count, if the compilation errors in the source do no
t match those that |
| 2015 * are expected, or if the result would have been `null` | 2017 * are expected, or if the result would have been `null` |
| 2016 */ | 2018 */ |
| 2017 static List<Statement> parseStatements(String source, int expectedCount, List<
ErrorCode> errorCodes) { | 2019 static List<Statement> parseStatements(String source, int expectedCount, [List
<ErrorCode> errorCodes = ErrorCode.EMPTY_LIST]) { |
| 2018 GatheringErrorListener listener = new GatheringErrorListener(); | 2020 GatheringErrorListener listener = new GatheringErrorListener(); |
| 2019 Scanner scanner = new Scanner(null, new CharSequenceReader(source), listener
); | 2021 Scanner scanner = new Scanner(null, new CharSequenceReader(source), listener
); |
| 2020 listener.setLineInfo(new TestSource(), scanner.lineStarts); | 2022 listener.setLineInfo(new TestSource(), scanner.lineStarts); |
| 2021 Token token = scanner.tokenize(); | 2023 Token token = scanner.tokenize(); |
| 2022 Parser parser = createParser(listener); | 2024 Parser parser = createParser(listener); |
| 2023 List<Statement> statements = parser.parseStatements(token); | 2025 List<Statement> statements = parser.parseStatements(token); |
| 2024 expect(statements, hasLength(expectedCount)); | 2026 expect(statements, hasLength(expectedCount)); |
| 2025 listener.assertErrorsWithCodes(errorCodes); | 2027 listener.assertErrorsWithCodes(errorCodes); |
| 2026 return statements; | 2028 return statements; |
| 2027 } | 2029 } |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2082 */ | 2084 */ |
| 2083 static Object invokeParserMethod2(String methodName, String source, GatheringE
rrorListener listener) => invokeParserMethod(methodName, _EMPTY_ARGUMENTS, sourc
e, listener); | 2085 static Object invokeParserMethod2(String methodName, String source, GatheringE
rrorListener listener) => invokeParserMethod(methodName, _EMPTY_ARGUMENTS, sourc
e, listener); |
| 2084 | 2086 |
| 2085 /** | 2087 /** |
| 2086 * Return a CommentAndMetadata object with the given values that can be used f
or testing. | 2088 * Return a CommentAndMetadata object with the given values that can be used f
or testing. |
| 2087 * | 2089 * |
| 2088 * @param comment the comment to be wrapped in the object | 2090 * @param comment the comment to be wrapped in the object |
| 2089 * @param annotations the annotations to be wrapped in the object | 2091 * @param annotations the annotations to be wrapped in the object |
| 2090 * @return a CommentAndMetadata object that can be used for testing | 2092 * @return a CommentAndMetadata object that can be used for testing |
| 2091 */ | 2093 */ |
| 2092 CommentAndMetadata commentAndMetadata(Comment comment, List<Annotation> annota
tions) { | 2094 CommentAndMetadata commentAndMetadata(Comment comment, [List<Annotation> annot
ations]) { |
| 2093 List<Annotation> metadata = new List<Annotation>(); | 2095 return new CommentAndMetadata(comment, annotations); |
| 2094 for (Annotation annotation in annotations) { | |
| 2095 metadata.add(annotation); | |
| 2096 } | |
| 2097 return new CommentAndMetadata(comment, metadata); | |
| 2098 } | 2096 } |
| 2099 | 2097 |
| 2100 /** | 2098 /** |
| 2101 * Return an empty CommentAndMetadata object that can be used for testing. | 2099 * Return an empty CommentAndMetadata object that can be used for testing. |
| 2102 * | 2100 * |
| 2103 * @return an empty CommentAndMetadata object that can be used for testing | 2101 * @return an empty CommentAndMetadata object that can be used for testing |
| 2104 */ | 2102 */ |
| 2105 CommentAndMetadata emptyCommentAndMetadata() => new CommentAndMetadata(null, n
ew List<Annotation>()); | 2103 CommentAndMetadata emptyCommentAndMetadata() => new CommentAndMetadata(null, n
ull); |
| 2106 | 2104 |
| 2107 @override | 2105 @override |
| 2108 void setUp() { | 2106 void setUp() { |
| 2109 super.setUp(); | 2107 super.setUp(); |
| 2110 parseFunctionBodies = true; | 2108 parseFunctionBodies = true; |
| 2111 } | 2109 } |
| 2112 } | 2110 } |
| 2113 | 2111 |
| 2114 /** | 2112 /** |
| 2115 * The class `RecoveryParserTest` defines parser tests that test the parsing of
invalid code | 2113 * The class `RecoveryParserTest` defines parser tests that test the parsing of
invalid code |
| 2116 * sequences to ensure that the correct recovery steps are taken in the parser. | 2114 * sequences to ensure that the correct recovery steps are taken in the parser. |
| 2117 */ | 2115 */ |
| 2118 class RecoveryParserTest extends ParserTestCase { | 2116 class RecoveryParserTest extends ParserTestCase { |
| 2119 void fail_incomplete_returnType() { | 2117 void fail_incomplete_returnType() { |
| 2120 ParserTestCase.parseCompilationUnit(r''' | 2118 ParserTestCase.parseCompilationUnit(r''' |
| 2121 Map<Symbol, convertStringToSymbolMap(Map<String, dynamic> map) { | 2119 Map<Symbol, convertStringToSymbolMap(Map<String, dynamic> map) { |
| 2122 if (map == null) return null; | 2120 if (map == null) return null; |
| 2123 Map<Symbol, dynamic> result = new Map<Symbol, dynamic>(); | 2121 Map<Symbol, dynamic> result = new Map<Symbol, dynamic>(); |
| 2124 map.forEach((name, value) { | 2122 map.forEach((name, value) { |
| 2125 result[new Symbol(name)] = value; | 2123 result[new Symbol(name)] = value; |
| 2126 }); | 2124 }); |
| 2127 return result; | 2125 return result; |
| 2128 }''', []); | 2126 }'''); |
| 2129 } | 2127 } |
| 2130 | 2128 |
| 2131 void test_additiveExpression_missing_LHS() { | 2129 void test_additiveExpression_missing_LHS() { |
| 2132 BinaryExpression expression = ParserTestCase.parseExpression("+ y", [ParserE
rrorCode.MISSING_IDENTIFIER]); | 2130 BinaryExpression expression = ParserTestCase.parseExpression("+ y", [ParserE
rrorCode.MISSING_IDENTIFIER]); |
| 2133 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, SimpleIden
tifier, expression.leftOperand); | 2131 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, SimpleIden
tifier, expression.leftOperand); |
| 2134 expect(expression.leftOperand.isSynthetic, isTrue); | 2132 expect(expression.leftOperand.isSynthetic, isTrue); |
| 2135 } | 2133 } |
| 2136 | 2134 |
| 2137 void test_additiveExpression_missing_LHS_RHS() { | 2135 void test_additiveExpression_missing_LHS_RHS() { |
| 2138 BinaryExpression expression = ParserTestCase.parseExpression("+", [ | 2136 BinaryExpression expression = ParserTestCase.parseExpression("+", [ |
| (...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2886 String annotationName = "proxy"; | 2884 String annotationName = "proxy"; |
| 2887 Annotation fromNode = AstFactory.annotation(AstFactory.identifier3(annotatio
nName)); | 2885 Annotation fromNode = AstFactory.annotation(AstFactory.identifier3(annotatio
nName)); |
| 2888 Element element = ElementFactory.topLevelVariableElement2(annotationName); | 2886 Element element = ElementFactory.topLevelVariableElement2(annotationName); |
| 2889 fromNode.element = element; | 2887 fromNode.element = element; |
| 2890 Annotation toNode = AstFactory.annotation(AstFactory.identifier3(annotationN
ame)); | 2888 Annotation toNode = AstFactory.annotation(AstFactory.identifier3(annotationN
ame)); |
| 2891 ResolutionCopier.copyResolutionData(fromNode, toNode); | 2889 ResolutionCopier.copyResolutionData(fromNode, toNode); |
| 2892 expect(toNode.element, same(element)); | 2890 expect(toNode.element, same(element)); |
| 2893 } | 2891 } |
| 2894 | 2892 |
| 2895 void test_visitAsExpression() { | 2893 void test_visitAsExpression() { |
| 2896 AsExpression fromNode = AstFactory.asExpression(AstFactory.identifier3("x"),
AstFactory.typeName4("A", [])); | 2894 AsExpression fromNode = AstFactory.asExpression(AstFactory.identifier3("x"),
AstFactory.typeName4("A")); |
| 2897 DartType propagatedType = ElementFactory.classElement2("A", []).type; | 2895 DartType propagatedType = ElementFactory.classElement2("A").type; |
| 2898 fromNode.propagatedType = propagatedType; | 2896 fromNode.propagatedType = propagatedType; |
| 2899 DartType staticType = ElementFactory.classElement2("B", []).type; | 2897 DartType staticType = ElementFactory.classElement2("B").type; |
| 2900 fromNode.staticType = staticType; | 2898 fromNode.staticType = staticType; |
| 2901 AsExpression toNode = AstFactory.asExpression(AstFactory.identifier3("x"), A
stFactory.typeName4("A", [])); | 2899 AsExpression toNode = AstFactory.asExpression(AstFactory.identifier3("x"), A
stFactory.typeName4("A")); |
| 2902 ResolutionCopier.copyResolutionData(fromNode, toNode); | 2900 ResolutionCopier.copyResolutionData(fromNode, toNode); |
| 2903 expect(toNode.propagatedType, same(propagatedType)); | 2901 expect(toNode.propagatedType, same(propagatedType)); |
| 2904 expect(toNode.staticType, same(staticType)); | 2902 expect(toNode.staticType, same(staticType)); |
| 2905 } | 2903 } |
| 2906 | 2904 |
| 2907 void test_visitAssignmentExpression() { | 2905 void test_visitAssignmentExpression() { |
| 2908 AssignmentExpression fromNode = AstFactory.assignmentExpression(AstFactory.i
dentifier3("a"), TokenType.PLUS_EQ, AstFactory.identifier3("b")); | 2906 AssignmentExpression fromNode = AstFactory.assignmentExpression(AstFactory.i
dentifier3("a"), TokenType.PLUS_EQ, AstFactory.identifier3("b")); |
| 2909 DartType propagatedType = ElementFactory.classElement2("C", []).type; | 2907 DartType propagatedType = ElementFactory.classElement2("C").type; |
| 2910 MethodElement propagatedElement = ElementFactory.methodElement("+", propagat
edType, []); | 2908 MethodElement propagatedElement = ElementFactory.methodElement("+", propagat
edType); |
| 2911 fromNode.propagatedElement = propagatedElement; | 2909 fromNode.propagatedElement = propagatedElement; |
| 2912 fromNode.propagatedType = propagatedType; | 2910 fromNode.propagatedType = propagatedType; |
| 2913 DartType staticType = ElementFactory.classElement2("C", []).type; | 2911 DartType staticType = ElementFactory.classElement2("C").type; |
| 2914 MethodElement staticElement = ElementFactory.methodElement("+", staticType,
[]); | 2912 MethodElement staticElement = ElementFactory.methodElement("+", staticType); |
| 2915 fromNode.staticElement = staticElement; | 2913 fromNode.staticElement = staticElement; |
| 2916 fromNode.staticType = staticType; | 2914 fromNode.staticType = staticType; |
| 2917 AssignmentExpression toNode = AstFactory.assignmentExpression(AstFactory.ide
ntifier3("a"), TokenType.PLUS_EQ, AstFactory.identifier3("b")); | 2915 AssignmentExpression toNode = AstFactory.assignmentExpression(AstFactory.ide
ntifier3("a"), TokenType.PLUS_EQ, AstFactory.identifier3("b")); |
| 2918 ResolutionCopier.copyResolutionData(fromNode, toNode); | 2916 ResolutionCopier.copyResolutionData(fromNode, toNode); |
| 2919 expect(toNode.propagatedElement, same(propagatedElement)); | 2917 expect(toNode.propagatedElement, same(propagatedElement)); |
| 2920 expect(toNode.propagatedType, same(propagatedType)); | 2918 expect(toNode.propagatedType, same(propagatedType)); |
| 2921 expect(toNode.staticElement, same(staticElement)); | 2919 expect(toNode.staticElement, same(staticElement)); |
| 2922 expect(toNode.staticType, same(staticType)); | 2920 expect(toNode.staticType, same(staticType)); |
| 2923 } | 2921 } |
| 2924 | 2922 |
| 2925 void test_visitBinaryExpression() { | 2923 void test_visitBinaryExpression() { |
| 2926 BinaryExpression fromNode = AstFactory.binaryExpression(AstFactory.identifie
r3("a"), TokenType.PLUS, AstFactory.identifier3("b")); | 2924 BinaryExpression fromNode = AstFactory.binaryExpression(AstFactory.identifie
r3("a"), TokenType.PLUS, AstFactory.identifier3("b")); |
| 2927 DartType propagatedType = ElementFactory.classElement2("C", []).type; | 2925 DartType propagatedType = ElementFactory.classElement2("C").type; |
| 2928 MethodElement propagatedElement = ElementFactory.methodElement("+", propagat
edType, []); | 2926 MethodElement propagatedElement = ElementFactory.methodElement("+", propagat
edType); |
| 2929 fromNode.propagatedElement = propagatedElement; | 2927 fromNode.propagatedElement = propagatedElement; |
| 2930 fromNode.propagatedType = propagatedType; | 2928 fromNode.propagatedType = propagatedType; |
| 2931 DartType staticType = ElementFactory.classElement2("C", []).type; | 2929 DartType staticType = ElementFactory.classElement2("C").type; |
| 2932 MethodElement staticElement = ElementFactory.methodElement("+", staticType,
[]); | 2930 MethodElement staticElement = ElementFactory.methodElement("+", staticType); |
| 2933 fromNode.staticElement = staticElement; | 2931 fromNode.staticElement = staticElement; |
| 2934 fromNode.staticType = staticType; | 2932 fromNode.staticType = staticType; |
| 2935 BinaryExpression toNode = AstFactory.binaryExpression(AstFactory.identifier3
("a"), TokenType.PLUS, AstFactory.identifier3("b")); | 2933 BinaryExpression toNode = AstFactory.binaryExpression(AstFactory.identifier3
("a"), TokenType.PLUS, AstFactory.identifier3("b")); |
| 2936 ResolutionCopier.copyResolutionData(fromNode, toNode); | 2934 ResolutionCopier.copyResolutionData(fromNode, toNode); |
| 2937 expect(toNode.propagatedElement, same(propagatedElement)); | 2935 expect(toNode.propagatedElement, same(propagatedElement)); |
| 2938 expect(toNode.propagatedType, same(propagatedType)); | 2936 expect(toNode.propagatedType, same(propagatedType)); |
| 2939 expect(toNode.staticElement, same(staticElement)); | 2937 expect(toNode.staticElement, same(staticElement)); |
| 2940 expect(toNode.staticType, same(staticType)); | 2938 expect(toNode.staticType, same(staticType)); |
| 2941 } | 2939 } |
| 2942 | 2940 |
| 2943 void test_visitBooleanLiteral() { | 2941 void test_visitBooleanLiteral() { |
| 2944 BooleanLiteral fromNode = AstFactory.booleanLiteral(true); | 2942 BooleanLiteral fromNode = AstFactory.booleanLiteral(true); |
| 2945 DartType propagatedType = ElementFactory.classElement2("C", []).type; | 2943 DartType propagatedType = ElementFactory.classElement2("C").type; |
| 2946 fromNode.propagatedType = propagatedType; | 2944 fromNode.propagatedType = propagatedType; |
| 2947 DartType staticType = ElementFactory.classElement2("C", []).type; | 2945 DartType staticType = ElementFactory.classElement2("C").type; |
| 2948 fromNode.staticType = staticType; | 2946 fromNode.staticType = staticType; |
| 2949 BooleanLiteral toNode = AstFactory.booleanLiteral(true); | 2947 BooleanLiteral toNode = AstFactory.booleanLiteral(true); |
| 2950 ResolutionCopier.copyResolutionData(fromNode, toNode); | 2948 ResolutionCopier.copyResolutionData(fromNode, toNode); |
| 2951 expect(toNode.propagatedType, same(propagatedType)); | 2949 expect(toNode.propagatedType, same(propagatedType)); |
| 2952 expect(toNode.staticType, same(staticType)); | 2950 expect(toNode.staticType, same(staticType)); |
| 2953 } | 2951 } |
| 2954 | 2952 |
| 2955 void test_visitCascadeExpression() { | 2953 void test_visitCascadeExpression() { |
| 2956 CascadeExpression fromNode = AstFactory.cascadeExpression(AstFactory.identif
ier3("a"), [AstFactory.identifier3("b")]); | 2954 CascadeExpression fromNode = AstFactory.cascadeExpression(AstFactory.identif
ier3("a"), [AstFactory.identifier3("b")]); |
| 2957 DartType propagatedType = ElementFactory.classElement2("C", []).type; | 2955 DartType propagatedType = ElementFactory.classElement2("C").type; |
| 2958 fromNode.propagatedType = propagatedType; | 2956 fromNode.propagatedType = propagatedType; |
| 2959 DartType staticType = ElementFactory.classElement2("C", []).type; | 2957 DartType staticType = ElementFactory.classElement2("C").type; |
| 2960 fromNode.staticType = staticType; | 2958 fromNode.staticType = staticType; |
| 2961 CascadeExpression toNode = AstFactory.cascadeExpression(AstFactory.identifie
r3("a"), [AstFactory.identifier3("b")]); | 2959 CascadeExpression toNode = AstFactory.cascadeExpression(AstFactory.identifie
r3("a"), [AstFactory.identifier3("b")]); |
| 2962 ResolutionCopier.copyResolutionData(fromNode, toNode); | 2960 ResolutionCopier.copyResolutionData(fromNode, toNode); |
| 2963 expect(toNode.propagatedType, same(propagatedType)); | 2961 expect(toNode.propagatedType, same(propagatedType)); |
| 2964 expect(toNode.staticType, same(staticType)); | 2962 expect(toNode.staticType, same(staticType)); |
| 2965 } | 2963 } |
| 2966 | 2964 |
| 2967 void test_visitCompilationUnit() { | 2965 void test_visitCompilationUnit() { |
| 2968 CompilationUnit fromNode = AstFactory.compilationUnit(); | 2966 CompilationUnit fromNode = AstFactory.compilationUnit(); |
| 2969 CompilationUnitElement element = new CompilationUnitElementImpl("test.dart")
; | 2967 CompilationUnitElement element = new CompilationUnitElementImpl("test.dart")
; |
| 2970 fromNode.element = element; | 2968 fromNode.element = element; |
| 2971 CompilationUnit toNode = AstFactory.compilationUnit(); | 2969 CompilationUnit toNode = AstFactory.compilationUnit(); |
| 2972 ResolutionCopier.copyResolutionData(fromNode, toNode); | 2970 ResolutionCopier.copyResolutionData(fromNode, toNode); |
| 2973 expect(toNode.element, same(element)); | 2971 expect(toNode.element, same(element)); |
| 2974 } | 2972 } |
| 2975 | 2973 |
| 2976 void test_visitConditionalExpression() { | 2974 void test_visitConditionalExpression() { |
| 2977 ConditionalExpression fromNode = AstFactory.conditionalExpression(AstFactory
.identifier3("c"), AstFactory.identifier3("a"), AstFactory.identifier3("b")); | 2975 ConditionalExpression fromNode = AstFactory.conditionalExpression(AstFactory
.identifier3("c"), AstFactory.identifier3("a"), AstFactory.identifier3("b")); |
| 2978 DartType propagatedType = ElementFactory.classElement2("C", []).type; | 2976 DartType propagatedType = ElementFactory.classElement2("C").type; |
| 2979 fromNode.propagatedType = propagatedType; | 2977 fromNode.propagatedType = propagatedType; |
| 2980 DartType staticType = ElementFactory.classElement2("C", []).type; | 2978 DartType staticType = ElementFactory.classElement2("C").type; |
| 2981 fromNode.staticType = staticType; | 2979 fromNode.staticType = staticType; |
| 2982 ConditionalExpression toNode = AstFactory.conditionalExpression(AstFactory.i
dentifier3("c"), AstFactory.identifier3("a"), AstFactory.identifier3("b")); | 2980 ConditionalExpression toNode = AstFactory.conditionalExpression(AstFactory.i
dentifier3("c"), AstFactory.identifier3("a"), AstFactory.identifier3("b")); |
| 2983 ResolutionCopier.copyResolutionData(fromNode, toNode); | 2981 ResolutionCopier.copyResolutionData(fromNode, toNode); |
| 2984 expect(toNode.propagatedType, same(propagatedType)); | 2982 expect(toNode.propagatedType, same(propagatedType)); |
| 2985 expect(toNode.staticType, same(staticType)); | 2983 expect(toNode.staticType, same(staticType)); |
| 2986 } | 2984 } |
| 2987 | 2985 |
| 2988 void test_visitConstructorDeclaration() { | 2986 void test_visitConstructorDeclaration() { |
| 2989 String className = "A"; | 2987 String className = "A"; |
| 2990 String constructorName = "c"; | 2988 String constructorName = "c"; |
| 2991 ConstructorDeclaration fromNode = AstFactory.constructorDeclaration(AstFacto
ry.identifier3(className), constructorName, AstFactory.formalParameterList([]),
null); | 2989 ConstructorDeclaration fromNode = AstFactory.constructorDeclaration(AstFacto
ry.identifier3(className), constructorName, AstFactory.formalParameterList(), nu
ll); |
| 2992 ConstructorElement element = ElementFactory.constructorElement2(ElementFacto
ry.classElement2(className, []), constructorName, []); | 2990 ConstructorElement element = ElementFactory.constructorElement2(ElementFacto
ry.classElement2(className), constructorName); |
| 2993 fromNode.element = element; | 2991 fromNode.element = element; |
| 2994 ConstructorDeclaration toNode = AstFactory.constructorDeclaration(AstFactory
.identifier3(className), constructorName, AstFactory.formalParameterList([]), nu
ll); | 2992 ConstructorDeclaration toNode = AstFactory.constructorDeclaration(AstFactory
.identifier3(className), constructorName, AstFactory.formalParameterList(), null
); |
| 2995 ResolutionCopier.copyResolutionData(fromNode, toNode); | 2993 ResolutionCopier.copyResolutionData(fromNode, toNode); |
| 2996 expect(toNode.element, same(element)); | 2994 expect(toNode.element, same(element)); |
| 2997 } | 2995 } |
| 2998 | 2996 |
| 2999 void test_visitConstructorName() { | 2997 void test_visitConstructorName() { |
| 3000 ConstructorName fromNode = AstFactory.constructorName(AstFactory.typeName4("
A", []), "c"); | 2998 ConstructorName fromNode = AstFactory.constructorName(AstFactory.typeName4("
A"), "c"); |
| 3001 ConstructorElement staticElement = ElementFactory.constructorElement2(Elemen
tFactory.classElement2("A", []), "c", []); | 2999 ConstructorElement staticElement = ElementFactory.constructorElement2(Elemen
tFactory.classElement2("A"), "c"); |
| 3002 fromNode.staticElement = staticElement; | 3000 fromNode.staticElement = staticElement; |
| 3003 ConstructorName toNode = AstFactory.constructorName(AstFactory.typeName4("A"
, []), "c"); | 3001 ConstructorName toNode = AstFactory.constructorName(AstFactory.typeName4("A"
), "c"); |
| 3004 ResolutionCopier.copyResolutionData(fromNode, toNode); | 3002 ResolutionCopier.copyResolutionData(fromNode, toNode); |
| 3005 expect(toNode.staticElement, same(staticElement)); | 3003 expect(toNode.staticElement, same(staticElement)); |
| 3006 } | 3004 } |
| 3007 | 3005 |
| 3008 void test_visitDoubleLiteral() { | 3006 void test_visitDoubleLiteral() { |
| 3009 DoubleLiteral fromNode = AstFactory.doubleLiteral(1.0); | 3007 DoubleLiteral fromNode = AstFactory.doubleLiteral(1.0); |
| 3010 DartType propagatedType = ElementFactory.classElement2("C", []).type; | 3008 DartType propagatedType = ElementFactory.classElement2("C").type; |
| 3011 fromNode.propagatedType = propagatedType; | 3009 fromNode.propagatedType = propagatedType; |
| 3012 DartType staticType = ElementFactory.classElement2("C", []).type; | 3010 DartType staticType = ElementFactory.classElement2("C").type; |
| 3013 fromNode.staticType = staticType; | 3011 fromNode.staticType = staticType; |
| 3014 DoubleLiteral toNode = AstFactory.doubleLiteral(1.0); | 3012 DoubleLiteral toNode = AstFactory.doubleLiteral(1.0); |
| 3015 ResolutionCopier.copyResolutionData(fromNode, toNode); | 3013 ResolutionCopier.copyResolutionData(fromNode, toNode); |
| 3016 expect(toNode.propagatedType, same(propagatedType)); | 3014 expect(toNode.propagatedType, same(propagatedType)); |
| 3017 expect(toNode.staticType, same(staticType)); | 3015 expect(toNode.staticType, same(staticType)); |
| 3018 } | 3016 } |
| 3019 | 3017 |
| 3020 void test_visitExportDirective() { | 3018 void test_visitExportDirective() { |
| 3021 ExportDirective fromNode = AstFactory.exportDirective2("dart:uri", []); | 3019 ExportDirective fromNode = AstFactory.exportDirective2("dart:uri"); |
| 3022 ExportElement element = new ExportElementImpl(); | 3020 ExportElement element = new ExportElementImpl(); |
| 3023 fromNode.element = element; | 3021 fromNode.element = element; |
| 3024 ExportDirective toNode = AstFactory.exportDirective2("dart:uri", []); | 3022 ExportDirective toNode = AstFactory.exportDirective2("dart:uri"); |
| 3025 ResolutionCopier.copyResolutionData(fromNode, toNode); | 3023 ResolutionCopier.copyResolutionData(fromNode, toNode); |
| 3026 expect(toNode.element, same(element)); | 3024 expect(toNode.element, same(element)); |
| 3027 } | 3025 } |
| 3028 | 3026 |
| 3029 void test_visitFunctionExpression() { | 3027 void test_visitFunctionExpression() { |
| 3030 FunctionExpression fromNode = AstFactory.functionExpression2(AstFactory.form
alParameterList([]), AstFactory.emptyFunctionBody()); | 3028 FunctionExpression fromNode = AstFactory.functionExpression2(AstFactory.form
alParameterList(), AstFactory.emptyFunctionBody()); |
| 3031 MethodElement element = ElementFactory.methodElement("m", ElementFactory.cla
ssElement2("C", []).type, []); | 3029 MethodElement element = ElementFactory.methodElement("m", ElementFactory.cla
ssElement2("C").type); |
| 3032 fromNode.element = element; | 3030 fromNode.element = element; |
| 3033 DartType propagatedType = ElementFactory.classElement2("C", []).type; | 3031 DartType propagatedType = ElementFactory.classElement2("C").type; |
| 3034 fromNode.propagatedType = propagatedType; | 3032 fromNode.propagatedType = propagatedType; |
| 3035 DartType staticType = ElementFactory.classElement2("C", []).type; | 3033 DartType staticType = ElementFactory.classElement2("C").type; |
| 3036 fromNode.staticType = staticType; | 3034 fromNode.staticType = staticType; |
| 3037 FunctionExpression toNode = AstFactory.functionExpression2(AstFactory.formal
ParameterList([]), AstFactory.emptyFunctionBody()); | 3035 FunctionExpression toNode = AstFactory.functionExpression2(AstFactory.formal
ParameterList(), AstFactory.emptyFunctionBody()); |
| 3038 ResolutionCopier.copyResolutionData(fromNode, toNode); | 3036 ResolutionCopier.copyResolutionData(fromNode, toNode); |
| 3039 expect(toNode.element, same(element)); | 3037 expect(toNode.element, same(element)); |
| 3040 expect(toNode.propagatedType, same(propagatedType)); | 3038 expect(toNode.propagatedType, same(propagatedType)); |
| 3041 expect(toNode.staticType, same(staticType)); | 3039 expect(toNode.staticType, same(staticType)); |
| 3042 } | 3040 } |
| 3043 | 3041 |
| 3044 void test_visitFunctionExpressionInvocation() { | 3042 void test_visitFunctionExpressionInvocation() { |
| 3045 FunctionExpressionInvocation fromNode = AstFactory.functionExpressionInvocat
ion(AstFactory.identifier3("f"), []); | 3043 FunctionExpressionInvocation fromNode = AstFactory.functionExpressionInvocat
ion(AstFactory.identifier3("f")); |
| 3046 MethodElement propagatedElement = ElementFactory.methodElement("m", ElementF
actory.classElement2("C", []).type, []); | 3044 MethodElement propagatedElement = ElementFactory.methodElement("m", ElementF
actory.classElement2("C").type); |
| 3047 fromNode.propagatedElement = propagatedElement; | 3045 fromNode.propagatedElement = propagatedElement; |
| 3048 DartType propagatedType = ElementFactory.classElement2("C", []).type; | 3046 DartType propagatedType = ElementFactory.classElement2("C").type; |
| 3049 fromNode.propagatedType = propagatedType; | 3047 fromNode.propagatedType = propagatedType; |
| 3050 MethodElement staticElement = ElementFactory.methodElement("m", ElementFacto
ry.classElement2("C", []).type, []); | 3048 MethodElement staticElement = ElementFactory.methodElement("m", ElementFacto
ry.classElement2("C").type); |
| 3051 fromNode.staticElement = staticElement; | 3049 fromNode.staticElement = staticElement; |
| 3052 DartType staticType = ElementFactory.classElement2("C", []).type; | 3050 DartType staticType = ElementFactory.classElement2("C").type; |
| 3053 fromNode.staticType = staticType; | 3051 fromNode.staticType = staticType; |
| 3054 FunctionExpressionInvocation toNode = AstFactory.functionExpressionInvocatio
n(AstFactory.identifier3("f"), []); | 3052 FunctionExpressionInvocation toNode = AstFactory.functionExpressionInvocatio
n(AstFactory.identifier3("f")); |
| 3055 ResolutionCopier.copyResolutionData(fromNode, toNode); | 3053 ResolutionCopier.copyResolutionData(fromNode, toNode); |
| 3056 expect(toNode.propagatedElement, same(propagatedElement)); | 3054 expect(toNode.propagatedElement, same(propagatedElement)); |
| 3057 expect(toNode.propagatedType, same(propagatedType)); | 3055 expect(toNode.propagatedType, same(propagatedType)); |
| 3058 expect(toNode.staticElement, same(staticElement)); | 3056 expect(toNode.staticElement, same(staticElement)); |
| 3059 expect(toNode.staticType, same(staticType)); | 3057 expect(toNode.staticType, same(staticType)); |
| 3060 } | 3058 } |
| 3061 | 3059 |
| 3062 void test_visitImportDirective() { | 3060 void test_visitImportDirective() { |
| 3063 ImportDirective fromNode = AstFactory.importDirective3("dart:uri", null, [])
; | 3061 ImportDirective fromNode = AstFactory.importDirective3("dart:uri", null); |
| 3064 ImportElement element = new ImportElementImpl(0); | 3062 ImportElement element = new ImportElementImpl(0); |
| 3065 fromNode.element = element; | 3063 fromNode.element = element; |
| 3066 ImportDirective toNode = AstFactory.importDirective3("dart:uri", null, []); | 3064 ImportDirective toNode = AstFactory.importDirective3("dart:uri", null); |
| 3067 ResolutionCopier.copyResolutionData(fromNode, toNode); | 3065 ResolutionCopier.copyResolutionData(fromNode, toNode); |
| 3068 expect(toNode.element, same(element)); | 3066 expect(toNode.element, same(element)); |
| 3069 } | 3067 } |
| 3070 | 3068 |
| 3071 void test_visitIndexExpression() { | 3069 void test_visitIndexExpression() { |
| 3072 IndexExpression fromNode = AstFactory.indexExpression(AstFactory.identifier3
("a"), AstFactory.integer(0)); | 3070 IndexExpression fromNode = AstFactory.indexExpression(AstFactory.identifier3
("a"), AstFactory.integer(0)); |
| 3073 MethodElement propagatedElement = ElementFactory.methodElement("m", ElementF
actory.classElement2("C", []).type, []); | 3071 MethodElement propagatedElement = ElementFactory.methodElement("m", ElementF
actory.classElement2("C").type); |
| 3074 MethodElement staticElement = ElementFactory.methodElement("m", ElementFacto
ry.classElement2("C", []).type, []); | 3072 MethodElement staticElement = ElementFactory.methodElement("m", ElementFacto
ry.classElement2("C").type); |
| 3075 AuxiliaryElements auxiliaryElements = new AuxiliaryElements(staticElement, p
ropagatedElement); | 3073 AuxiliaryElements auxiliaryElements = new AuxiliaryElements(staticElement, p
ropagatedElement); |
| 3076 fromNode.auxiliaryElements = auxiliaryElements; | 3074 fromNode.auxiliaryElements = auxiliaryElements; |
| 3077 fromNode.propagatedElement = propagatedElement; | 3075 fromNode.propagatedElement = propagatedElement; |
| 3078 DartType propagatedType = ElementFactory.classElement2("C", []).type; | 3076 DartType propagatedType = ElementFactory.classElement2("C").type; |
| 3079 fromNode.propagatedType = propagatedType; | 3077 fromNode.propagatedType = propagatedType; |
| 3080 fromNode.staticElement = staticElement; | 3078 fromNode.staticElement = staticElement; |
| 3081 DartType staticType = ElementFactory.classElement2("C", []).type; | 3079 DartType staticType = ElementFactory.classElement2("C").type; |
| 3082 fromNode.staticType = staticType; | 3080 fromNode.staticType = staticType; |
| 3083 IndexExpression toNode = AstFactory.indexExpression(AstFactory.identifier3("
a"), AstFactory.integer(0)); | 3081 IndexExpression toNode = AstFactory.indexExpression(AstFactory.identifier3("
a"), AstFactory.integer(0)); |
| 3084 ResolutionCopier.copyResolutionData(fromNode, toNode); | 3082 ResolutionCopier.copyResolutionData(fromNode, toNode); |
| 3085 expect(toNode.auxiliaryElements, same(auxiliaryElements)); | 3083 expect(toNode.auxiliaryElements, same(auxiliaryElements)); |
| 3086 expect(toNode.propagatedElement, same(propagatedElement)); | 3084 expect(toNode.propagatedElement, same(propagatedElement)); |
| 3087 expect(toNode.propagatedType, same(propagatedType)); | 3085 expect(toNode.propagatedType, same(propagatedType)); |
| 3088 expect(toNode.staticElement, same(staticElement)); | 3086 expect(toNode.staticElement, same(staticElement)); |
| 3089 expect(toNode.staticType, same(staticType)); | 3087 expect(toNode.staticType, same(staticType)); |
| 3090 } | 3088 } |
| 3091 | 3089 |
| 3092 void test_visitInstanceCreationExpression() { | 3090 void test_visitInstanceCreationExpression() { |
| 3093 InstanceCreationExpression fromNode = AstFactory.instanceCreationExpression2
(Keyword.NEW, AstFactory.typeName4("C", []), []); | 3091 InstanceCreationExpression fromNode = AstFactory.instanceCreationExpression2
(Keyword.NEW, AstFactory.typeName4("C")); |
| 3094 DartType propagatedType = ElementFactory.classElement2("C", []).type; | 3092 DartType propagatedType = ElementFactory.classElement2("C").type; |
| 3095 fromNode.propagatedType = propagatedType; | 3093 fromNode.propagatedType = propagatedType; |
| 3096 ConstructorElement staticElement = ElementFactory.constructorElement2(Elemen
tFactory.classElement2("C", []), null, []); | 3094 ConstructorElement staticElement = ElementFactory.constructorElement2(Elemen
tFactory.classElement2("C"), null); |
| 3097 fromNode.staticElement = staticElement; | 3095 fromNode.staticElement = staticElement; |
| 3098 DartType staticType = ElementFactory.classElement2("C", []).type; | 3096 DartType staticType = ElementFactory.classElement2("C").type; |
| 3099 fromNode.staticType = staticType; | 3097 fromNode.staticType = staticType; |
| 3100 InstanceCreationExpression toNode = AstFactory.instanceCreationExpression2(K
eyword.NEW, AstFactory.typeName4("C", []), []); | 3098 InstanceCreationExpression toNode = AstFactory.instanceCreationExpression2(K
eyword.NEW, AstFactory.typeName4("C")); |
| 3101 ResolutionCopier.copyResolutionData(fromNode, toNode); | 3099 ResolutionCopier.copyResolutionData(fromNode, toNode); |
| 3102 expect(toNode.propagatedType, same(propagatedType)); | 3100 expect(toNode.propagatedType, same(propagatedType)); |
| 3103 expect(toNode.staticElement, same(staticElement)); | 3101 expect(toNode.staticElement, same(staticElement)); |
| 3104 expect(toNode.staticType, same(staticType)); | 3102 expect(toNode.staticType, same(staticType)); |
| 3105 } | 3103 } |
| 3106 | 3104 |
| 3107 void test_visitIntegerLiteral() { | 3105 void test_visitIntegerLiteral() { |
| 3108 IntegerLiteral fromNode = AstFactory.integer(2); | 3106 IntegerLiteral fromNode = AstFactory.integer(2); |
| 3109 DartType propagatedType = ElementFactory.classElement2("C", []).type; | 3107 DartType propagatedType = ElementFactory.classElement2("C").type; |
| 3110 fromNode.propagatedType = propagatedType; | 3108 fromNode.propagatedType = propagatedType; |
| 3111 DartType staticType = ElementFactory.classElement2("C", []).type; | 3109 DartType staticType = ElementFactory.classElement2("C").type; |
| 3112 fromNode.staticType = staticType; | 3110 fromNode.staticType = staticType; |
| 3113 IntegerLiteral toNode = AstFactory.integer(2); | 3111 IntegerLiteral toNode = AstFactory.integer(2); |
| 3114 ResolutionCopier.copyResolutionData(fromNode, toNode); | 3112 ResolutionCopier.copyResolutionData(fromNode, toNode); |
| 3115 expect(toNode.propagatedType, same(propagatedType)); | 3113 expect(toNode.propagatedType, same(propagatedType)); |
| 3116 expect(toNode.staticType, same(staticType)); | 3114 expect(toNode.staticType, same(staticType)); |
| 3117 } | 3115 } |
| 3118 | 3116 |
| 3119 void test_visitIsExpression() { | 3117 void test_visitIsExpression() { |
| 3120 IsExpression fromNode = AstFactory.isExpression(AstFactory.identifier3("x"),
false, AstFactory.typeName4("A", [])); | 3118 IsExpression fromNode = AstFactory.isExpression(AstFactory.identifier3("x"),
false, AstFactory.typeName4("A")); |
| 3121 DartType propagatedType = ElementFactory.classElement2("C", []).type; | 3119 DartType propagatedType = ElementFactory.classElement2("C").type; |
| 3122 fromNode.propagatedType = propagatedType; | 3120 fromNode.propagatedType = propagatedType; |
| 3123 DartType staticType = ElementFactory.classElement2("C", []).type; | 3121 DartType staticType = ElementFactory.classElement2("C").type; |
| 3124 fromNode.staticType = staticType; | 3122 fromNode.staticType = staticType; |
| 3125 IsExpression toNode = AstFactory.isExpression(AstFactory.identifier3("x"), f
alse, AstFactory.typeName4("A", [])); | 3123 IsExpression toNode = AstFactory.isExpression(AstFactory.identifier3("x"), f
alse, AstFactory.typeName4("A")); |
| 3126 ResolutionCopier.copyResolutionData(fromNode, toNode); | 3124 ResolutionCopier.copyResolutionData(fromNode, toNode); |
| 3127 expect(toNode.propagatedType, same(propagatedType)); | 3125 expect(toNode.propagatedType, same(propagatedType)); |
| 3128 expect(toNode.staticType, same(staticType)); | 3126 expect(toNode.staticType, same(staticType)); |
| 3129 } | 3127 } |
| 3130 | 3128 |
| 3131 void test_visitLibraryIdentifier() { | 3129 void test_visitLibraryIdentifier() { |
| 3132 LibraryIdentifier fromNode = AstFactory.libraryIdentifier([AstFactory.identi
fier3("lib")]); | 3130 LibraryIdentifier fromNode = AstFactory.libraryIdentifier([AstFactory.identi
fier3("lib")]); |
| 3133 DartType propagatedType = ElementFactory.classElement2("C", []).type; | 3131 DartType propagatedType = ElementFactory.classElement2("C").type; |
| 3134 fromNode.propagatedType = propagatedType; | 3132 fromNode.propagatedType = propagatedType; |
| 3135 DartType staticType = ElementFactory.classElement2("C", []).type; | 3133 DartType staticType = ElementFactory.classElement2("C").type; |
| 3136 fromNode.staticType = staticType; | 3134 fromNode.staticType = staticType; |
| 3137 LibraryIdentifier toNode = AstFactory.libraryIdentifier([AstFactory.identifi
er3("lib")]); | 3135 LibraryIdentifier toNode = AstFactory.libraryIdentifier([AstFactory.identifi
er3("lib")]); |
| 3138 ResolutionCopier.copyResolutionData(fromNode, toNode); | 3136 ResolutionCopier.copyResolutionData(fromNode, toNode); |
| 3139 expect(toNode.propagatedType, same(propagatedType)); | 3137 expect(toNode.propagatedType, same(propagatedType)); |
| 3140 expect(toNode.staticType, same(staticType)); | 3138 expect(toNode.staticType, same(staticType)); |
| 3141 } | 3139 } |
| 3142 | 3140 |
| 3143 void test_visitListLiteral() { | 3141 void test_visitListLiteral() { |
| 3144 ListLiteral fromNode = AstFactory.listLiteral([]); | 3142 ListLiteral fromNode = AstFactory.listLiteral(); |
| 3145 DartType propagatedType = ElementFactory.classElement2("C", []).type; | 3143 DartType propagatedType = ElementFactory.classElement2("C").type; |
| 3146 fromNode.propagatedType = propagatedType; | 3144 fromNode.propagatedType = propagatedType; |
| 3147 DartType staticType = ElementFactory.classElement2("C", []).type; | 3145 DartType staticType = ElementFactory.classElement2("C").type; |
| 3148 fromNode.staticType = staticType; | 3146 fromNode.staticType = staticType; |
| 3149 ListLiteral toNode = AstFactory.listLiteral([]); | 3147 ListLiteral toNode = AstFactory.listLiteral(); |
| 3150 ResolutionCopier.copyResolutionData(fromNode, toNode); | 3148 ResolutionCopier.copyResolutionData(fromNode, toNode); |
| 3151 expect(toNode.propagatedType, same(propagatedType)); | 3149 expect(toNode.propagatedType, same(propagatedType)); |
| 3152 expect(toNode.staticType, same(staticType)); | 3150 expect(toNode.staticType, same(staticType)); |
| 3153 } | 3151 } |
| 3154 | 3152 |
| 3155 void test_visitMapLiteral() { | 3153 void test_visitMapLiteral() { |
| 3156 MapLiteral fromNode = AstFactory.mapLiteral2([]); | 3154 MapLiteral fromNode = AstFactory.mapLiteral2(); |
| 3157 DartType propagatedType = ElementFactory.classElement2("C", []).type; | 3155 DartType propagatedType = ElementFactory.classElement2("C").type; |
| 3158 fromNode.propagatedType = propagatedType; | 3156 fromNode.propagatedType = propagatedType; |
| 3159 DartType staticType = ElementFactory.classElement2("C", []).type; | 3157 DartType staticType = ElementFactory.classElement2("C").type; |
| 3160 fromNode.staticType = staticType; | 3158 fromNode.staticType = staticType; |
| 3161 MapLiteral toNode = AstFactory.mapLiteral2([]); | 3159 MapLiteral toNode = AstFactory.mapLiteral2(); |
| 3162 ResolutionCopier.copyResolutionData(fromNode, toNode); | 3160 ResolutionCopier.copyResolutionData(fromNode, toNode); |
| 3163 expect(toNode.propagatedType, same(propagatedType)); | 3161 expect(toNode.propagatedType, same(propagatedType)); |
| 3164 expect(toNode.staticType, same(staticType)); | 3162 expect(toNode.staticType, same(staticType)); |
| 3165 } | 3163 } |
| 3166 | 3164 |
| 3167 void test_visitMethodInvocation() { | 3165 void test_visitMethodInvocation() { |
| 3168 MethodInvocation fromNode = AstFactory.methodInvocation2("m", []); | 3166 MethodInvocation fromNode = AstFactory.methodInvocation2("m"); |
| 3169 DartType propagatedType = ElementFactory.classElement2("C", []).type; | 3167 DartType propagatedType = ElementFactory.classElement2("C").type; |
| 3170 fromNode.propagatedType = propagatedType; | 3168 fromNode.propagatedType = propagatedType; |
| 3171 DartType staticType = ElementFactory.classElement2("C", []).type; | 3169 DartType staticType = ElementFactory.classElement2("C").type; |
| 3172 fromNode.staticType = staticType; | 3170 fromNode.staticType = staticType; |
| 3173 MethodInvocation toNode = AstFactory.methodInvocation2("m", []); | 3171 MethodInvocation toNode = AstFactory.methodInvocation2("m"); |
| 3174 ResolutionCopier.copyResolutionData(fromNode, toNode); | 3172 ResolutionCopier.copyResolutionData(fromNode, toNode); |
| 3175 expect(toNode.propagatedType, same(propagatedType)); | 3173 expect(toNode.propagatedType, same(propagatedType)); |
| 3176 expect(toNode.staticType, same(staticType)); | 3174 expect(toNode.staticType, same(staticType)); |
| 3177 } | 3175 } |
| 3178 | 3176 |
| 3179 void test_visitNamedExpression() { | 3177 void test_visitNamedExpression() { |
| 3180 NamedExpression fromNode = AstFactory.namedExpression2("n", AstFactory.integ
er(0)); | 3178 NamedExpression fromNode = AstFactory.namedExpression2("n", AstFactory.integ
er(0)); |
| 3181 DartType propagatedType = ElementFactory.classElement2("C", []).type; | 3179 DartType propagatedType = ElementFactory.classElement2("C").type; |
| 3182 fromNode.propagatedType = propagatedType; | 3180 fromNode.propagatedType = propagatedType; |
| 3183 DartType staticType = ElementFactory.classElement2("C", []).type; | 3181 DartType staticType = ElementFactory.classElement2("C").type; |
| 3184 fromNode.staticType = staticType; | 3182 fromNode.staticType = staticType; |
| 3185 NamedExpression toNode = AstFactory.namedExpression2("n", AstFactory.integer
(0)); | 3183 NamedExpression toNode = AstFactory.namedExpression2("n", AstFactory.integer
(0)); |
| 3186 ResolutionCopier.copyResolutionData(fromNode, toNode); | 3184 ResolutionCopier.copyResolutionData(fromNode, toNode); |
| 3187 expect(toNode.propagatedType, same(propagatedType)); | 3185 expect(toNode.propagatedType, same(propagatedType)); |
| 3188 expect(toNode.staticType, same(staticType)); | 3186 expect(toNode.staticType, same(staticType)); |
| 3189 } | 3187 } |
| 3190 | 3188 |
| 3191 void test_visitNullLiteral() { | 3189 void test_visitNullLiteral() { |
| 3192 NullLiteral fromNode = AstFactory.nullLiteral(); | 3190 NullLiteral fromNode = AstFactory.nullLiteral(); |
| 3193 DartType propagatedType = ElementFactory.classElement2("C", []).type; | 3191 DartType propagatedType = ElementFactory.classElement2("C").type; |
| 3194 fromNode.propagatedType = propagatedType; | 3192 fromNode.propagatedType = propagatedType; |
| 3195 DartType staticType = ElementFactory.classElement2("C", []).type; | 3193 DartType staticType = ElementFactory.classElement2("C").type; |
| 3196 fromNode.staticType = staticType; | 3194 fromNode.staticType = staticType; |
| 3197 NullLiteral toNode = AstFactory.nullLiteral(); | 3195 NullLiteral toNode = AstFactory.nullLiteral(); |
| 3198 ResolutionCopier.copyResolutionData(fromNode, toNode); | 3196 ResolutionCopier.copyResolutionData(fromNode, toNode); |
| 3199 expect(toNode.propagatedType, same(propagatedType)); | 3197 expect(toNode.propagatedType, same(propagatedType)); |
| 3200 expect(toNode.staticType, same(staticType)); | 3198 expect(toNode.staticType, same(staticType)); |
| 3201 } | 3199 } |
| 3202 | 3200 |
| 3203 void test_visitParenthesizedExpression() { | 3201 void test_visitParenthesizedExpression() { |
| 3204 ParenthesizedExpression fromNode = AstFactory.parenthesizedExpression(AstFac
tory.integer(0)); | 3202 ParenthesizedExpression fromNode = AstFactory.parenthesizedExpression(AstFac
tory.integer(0)); |
| 3205 DartType propagatedType = ElementFactory.classElement2("C", []).type; | 3203 DartType propagatedType = ElementFactory.classElement2("C").type; |
| 3206 fromNode.propagatedType = propagatedType; | 3204 fromNode.propagatedType = propagatedType; |
| 3207 DartType staticType = ElementFactory.classElement2("C", []).type; | 3205 DartType staticType = ElementFactory.classElement2("C").type; |
| 3208 fromNode.staticType = staticType; | 3206 fromNode.staticType = staticType; |
| 3209 ParenthesizedExpression toNode = AstFactory.parenthesizedExpression(AstFacto
ry.integer(0)); | 3207 ParenthesizedExpression toNode = AstFactory.parenthesizedExpression(AstFacto
ry.integer(0)); |
| 3210 ResolutionCopier.copyResolutionData(fromNode, toNode); | 3208 ResolutionCopier.copyResolutionData(fromNode, toNode); |
| 3211 expect(toNode.propagatedType, same(propagatedType)); | 3209 expect(toNode.propagatedType, same(propagatedType)); |
| 3212 expect(toNode.staticType, same(staticType)); | 3210 expect(toNode.staticType, same(staticType)); |
| 3213 } | 3211 } |
| 3214 | 3212 |
| 3215 void test_visitPartDirective() { | 3213 void test_visitPartDirective() { |
| 3216 PartDirective fromNode = AstFactory.partDirective2("part.dart"); | 3214 PartDirective fromNode = AstFactory.partDirective2("part.dart"); |
| 3217 LibraryElement element = new LibraryElementImpl.forNode(null, AstFactory.lib
raryIdentifier2(["lib"])); | 3215 LibraryElement element = new LibraryElementImpl.forNode(null, AstFactory.lib
raryIdentifier2(["lib"])); |
| 3218 fromNode.element = element; | 3216 fromNode.element = element; |
| 3219 PartDirective toNode = AstFactory.partDirective2("part.dart"); | 3217 PartDirective toNode = AstFactory.partDirective2("part.dart"); |
| 3220 ResolutionCopier.copyResolutionData(fromNode, toNode); | 3218 ResolutionCopier.copyResolutionData(fromNode, toNode); |
| 3221 expect(toNode.element, same(element)); | 3219 expect(toNode.element, same(element)); |
| 3222 } | 3220 } |
| 3223 | 3221 |
| 3224 void test_visitPartOfDirective() { | 3222 void test_visitPartOfDirective() { |
| 3225 PartOfDirective fromNode = AstFactory.partOfDirective(AstFactory.libraryIden
tifier2(["lib"])); | 3223 PartOfDirective fromNode = AstFactory.partOfDirective(AstFactory.libraryIden
tifier2(["lib"])); |
| 3226 LibraryElement element = new LibraryElementImpl.forNode(null, AstFactory.lib
raryIdentifier2(["lib"])); | 3224 LibraryElement element = new LibraryElementImpl.forNode(null, AstFactory.lib
raryIdentifier2(["lib"])); |
| 3227 fromNode.element = element; | 3225 fromNode.element = element; |
| 3228 PartOfDirective toNode = AstFactory.partOfDirective(AstFactory.libraryIdenti
fier2(["lib"])); | 3226 PartOfDirective toNode = AstFactory.partOfDirective(AstFactory.libraryIdenti
fier2(["lib"])); |
| 3229 ResolutionCopier.copyResolutionData(fromNode, toNode); | 3227 ResolutionCopier.copyResolutionData(fromNode, toNode); |
| 3230 expect(toNode.element, same(element)); | 3228 expect(toNode.element, same(element)); |
| 3231 } | 3229 } |
| 3232 | 3230 |
| 3233 void test_visitPostfixExpression() { | 3231 void test_visitPostfixExpression() { |
| 3234 String variableName = "x"; | 3232 String variableName = "x"; |
| 3235 PostfixExpression fromNode = AstFactory.postfixExpression(AstFactory.identif
ier3(variableName), TokenType.PLUS_PLUS); | 3233 PostfixExpression fromNode = AstFactory.postfixExpression(AstFactory.identif
ier3(variableName), TokenType.PLUS_PLUS); |
| 3236 MethodElement propagatedElement = ElementFactory.methodElement("+", ElementF
actory.classElement2("C", []).type, []); | 3234 MethodElement propagatedElement = ElementFactory.methodElement("+", ElementF
actory.classElement2("C").type); |
| 3237 fromNode.propagatedElement = propagatedElement; | 3235 fromNode.propagatedElement = propagatedElement; |
| 3238 DartType propagatedType = ElementFactory.classElement2("C", []).type; | 3236 DartType propagatedType = ElementFactory.classElement2("C").type; |
| 3239 fromNode.propagatedType = propagatedType; | 3237 fromNode.propagatedType = propagatedType; |
| 3240 MethodElement staticElement = ElementFactory.methodElement("+", ElementFacto
ry.classElement2("C", []).type, []); | 3238 MethodElement staticElement = ElementFactory.methodElement("+", ElementFacto
ry.classElement2("C").type); |
| 3241 fromNode.staticElement = staticElement; | 3239 fromNode.staticElement = staticElement; |
| 3242 DartType staticType = ElementFactory.classElement2("C", []).type; | 3240 DartType staticType = ElementFactory.classElement2("C").type; |
| 3243 fromNode.staticType = staticType; | 3241 fromNode.staticType = staticType; |
| 3244 PostfixExpression toNode = AstFactory.postfixExpression(AstFactory.identifie
r3(variableName), TokenType.PLUS_PLUS); | 3242 PostfixExpression toNode = AstFactory.postfixExpression(AstFactory.identifie
r3(variableName), TokenType.PLUS_PLUS); |
| 3245 ResolutionCopier.copyResolutionData(fromNode, toNode); | 3243 ResolutionCopier.copyResolutionData(fromNode, toNode); |
| 3246 expect(toNode.propagatedElement, same(propagatedElement)); | 3244 expect(toNode.propagatedElement, same(propagatedElement)); |
| 3247 expect(toNode.propagatedType, same(propagatedType)); | 3245 expect(toNode.propagatedType, same(propagatedType)); |
| 3248 expect(toNode.staticElement, same(staticElement)); | 3246 expect(toNode.staticElement, same(staticElement)); |
| 3249 expect(toNode.staticType, same(staticType)); | 3247 expect(toNode.staticType, same(staticType)); |
| 3250 } | 3248 } |
| 3251 | 3249 |
| 3252 void test_visitPrefixedIdentifier() { | 3250 void test_visitPrefixedIdentifier() { |
| 3253 PrefixedIdentifier fromNode = AstFactory.identifier5("p", "f"); | 3251 PrefixedIdentifier fromNode = AstFactory.identifier5("p", "f"); |
| 3254 DartType propagatedType = ElementFactory.classElement2("C", []).type; | 3252 DartType propagatedType = ElementFactory.classElement2("C").type; |
| 3255 fromNode.propagatedType = propagatedType; | 3253 fromNode.propagatedType = propagatedType; |
| 3256 DartType staticType = ElementFactory.classElement2("C", []).type; | 3254 DartType staticType = ElementFactory.classElement2("C").type; |
| 3257 fromNode.staticType = staticType; | 3255 fromNode.staticType = staticType; |
| 3258 PrefixedIdentifier toNode = AstFactory.identifier5("p", "f"); | 3256 PrefixedIdentifier toNode = AstFactory.identifier5("p", "f"); |
| 3259 ResolutionCopier.copyResolutionData(fromNode, toNode); | 3257 ResolutionCopier.copyResolutionData(fromNode, toNode); |
| 3260 expect(toNode.propagatedType, same(propagatedType)); | 3258 expect(toNode.propagatedType, same(propagatedType)); |
| 3261 expect(toNode.staticType, same(staticType)); | 3259 expect(toNode.staticType, same(staticType)); |
| 3262 } | 3260 } |
| 3263 | 3261 |
| 3264 void test_visitPrefixExpression() { | 3262 void test_visitPrefixExpression() { |
| 3265 PrefixExpression fromNode = AstFactory.prefixExpression(TokenType.PLUS_PLUS,
AstFactory.identifier3("x")); | 3263 PrefixExpression fromNode = AstFactory.prefixExpression(TokenType.PLUS_PLUS,
AstFactory.identifier3("x")); |
| 3266 MethodElement propagatedElement = ElementFactory.methodElement("+", ElementF
actory.classElement2("C", []).type, []); | 3264 MethodElement propagatedElement = ElementFactory.methodElement("+", ElementF
actory.classElement2("C").type); |
| 3267 DartType propagatedType = ElementFactory.classElement2("C", []).type; | 3265 DartType propagatedType = ElementFactory.classElement2("C").type; |
| 3268 fromNode.propagatedElement = propagatedElement; | 3266 fromNode.propagatedElement = propagatedElement; |
| 3269 fromNode.propagatedType = propagatedType; | 3267 fromNode.propagatedType = propagatedType; |
| 3270 DartType staticType = ElementFactory.classElement2("C", []).type; | 3268 DartType staticType = ElementFactory.classElement2("C").type; |
| 3271 MethodElement staticElement = ElementFactory.methodElement("+", ElementFacto
ry.classElement2("C", []).type, []); | 3269 MethodElement staticElement = ElementFactory.methodElement("+", ElementFacto
ry.classElement2("C").type); |
| 3272 fromNode.staticElement = staticElement; | 3270 fromNode.staticElement = staticElement; |
| 3273 fromNode.staticType = staticType; | 3271 fromNode.staticType = staticType; |
| 3274 PrefixExpression toNode = AstFactory.prefixExpression(TokenType.PLUS_PLUS, A
stFactory.identifier3("x")); | 3272 PrefixExpression toNode = AstFactory.prefixExpression(TokenType.PLUS_PLUS, A
stFactory.identifier3("x")); |
| 3275 ResolutionCopier.copyResolutionData(fromNode, toNode); | 3273 ResolutionCopier.copyResolutionData(fromNode, toNode); |
| 3276 expect(toNode.propagatedElement, same(propagatedElement)); | 3274 expect(toNode.propagatedElement, same(propagatedElement)); |
| 3277 expect(toNode.propagatedType, same(propagatedType)); | 3275 expect(toNode.propagatedType, same(propagatedType)); |
| 3278 expect(toNode.staticElement, same(staticElement)); | 3276 expect(toNode.staticElement, same(staticElement)); |
| 3279 expect(toNode.staticType, same(staticType)); | 3277 expect(toNode.staticType, same(staticType)); |
| 3280 } | 3278 } |
| 3281 | 3279 |
| 3282 void test_visitPropertyAccess() { | 3280 void test_visitPropertyAccess() { |
| 3283 PropertyAccess fromNode = AstFactory.propertyAccess2(AstFactory.identifier3(
"x"), "y"); | 3281 PropertyAccess fromNode = AstFactory.propertyAccess2(AstFactory.identifier3(
"x"), "y"); |
| 3284 DartType propagatedType = ElementFactory.classElement2("C", []).type; | 3282 DartType propagatedType = ElementFactory.classElement2("C").type; |
| 3285 fromNode.propagatedType = propagatedType; | 3283 fromNode.propagatedType = propagatedType; |
| 3286 DartType staticType = ElementFactory.classElement2("C", []).type; | 3284 DartType staticType = ElementFactory.classElement2("C").type; |
| 3287 fromNode.staticType = staticType; | 3285 fromNode.staticType = staticType; |
| 3288 PropertyAccess toNode = AstFactory.propertyAccess2(AstFactory.identifier3("x
"), "y"); | 3286 PropertyAccess toNode = AstFactory.propertyAccess2(AstFactory.identifier3("x
"), "y"); |
| 3289 ResolutionCopier.copyResolutionData(fromNode, toNode); | 3287 ResolutionCopier.copyResolutionData(fromNode, toNode); |
| 3290 expect(toNode.propagatedType, same(propagatedType)); | 3288 expect(toNode.propagatedType, same(propagatedType)); |
| 3291 expect(toNode.staticType, same(staticType)); | 3289 expect(toNode.staticType, same(staticType)); |
| 3292 } | 3290 } |
| 3293 | 3291 |
| 3294 void test_visitRedirectingConstructorInvocation() { | 3292 void test_visitRedirectingConstructorInvocation() { |
| 3295 RedirectingConstructorInvocation fromNode = AstFactory.redirectingConstructo
rInvocation([]); | 3293 RedirectingConstructorInvocation fromNode = AstFactory.redirectingConstructo
rInvocation(); |
| 3296 ConstructorElement staticElement = ElementFactory.constructorElement2(Elemen
tFactory.classElement2("C", []), null, []); | 3294 ConstructorElement staticElement = ElementFactory.constructorElement2(Elemen
tFactory.classElement2("C"), null); |
| 3297 fromNode.staticElement = staticElement; | 3295 fromNode.staticElement = staticElement; |
| 3298 RedirectingConstructorInvocation toNode = AstFactory.redirectingConstructorI
nvocation([]); | 3296 RedirectingConstructorInvocation toNode = AstFactory.redirectingConstructorI
nvocation(); |
| 3299 ResolutionCopier.copyResolutionData(fromNode, toNode); | 3297 ResolutionCopier.copyResolutionData(fromNode, toNode); |
| 3300 expect(toNode.staticElement, same(staticElement)); | 3298 expect(toNode.staticElement, same(staticElement)); |
| 3301 } | 3299 } |
| 3302 | 3300 |
| 3303 void test_visitRethrowExpression() { | 3301 void test_visitRethrowExpression() { |
| 3304 RethrowExpression fromNode = AstFactory.rethrowExpression(); | 3302 RethrowExpression fromNode = AstFactory.rethrowExpression(); |
| 3305 DartType propagatedType = ElementFactory.classElement2("C", []).type; | 3303 DartType propagatedType = ElementFactory.classElement2("C").type; |
| 3306 fromNode.propagatedType = propagatedType; | 3304 fromNode.propagatedType = propagatedType; |
| 3307 DartType staticType = ElementFactory.classElement2("C", []).type; | 3305 DartType staticType = ElementFactory.classElement2("C").type; |
| 3308 fromNode.staticType = staticType; | 3306 fromNode.staticType = staticType; |
| 3309 RethrowExpression toNode = AstFactory.rethrowExpression(); | 3307 RethrowExpression toNode = AstFactory.rethrowExpression(); |
| 3310 ResolutionCopier.copyResolutionData(fromNode, toNode); | 3308 ResolutionCopier.copyResolutionData(fromNode, toNode); |
| 3311 expect(toNode.propagatedType, same(propagatedType)); | 3309 expect(toNode.propagatedType, same(propagatedType)); |
| 3312 expect(toNode.staticType, same(staticType)); | 3310 expect(toNode.staticType, same(staticType)); |
| 3313 } | 3311 } |
| 3314 | 3312 |
| 3315 void test_visitSimpleIdentifier() { | 3313 void test_visitSimpleIdentifier() { |
| 3316 SimpleIdentifier fromNode = AstFactory.identifier3("x"); | 3314 SimpleIdentifier fromNode = AstFactory.identifier3("x"); |
| 3317 MethodElement propagatedElement = ElementFactory.methodElement("m", ElementF
actory.classElement2("C", []).type, []); | 3315 MethodElement propagatedElement = ElementFactory.methodElement("m", ElementF
actory.classElement2("C").type); |
| 3318 MethodElement staticElement = ElementFactory.methodElement("m", ElementFacto
ry.classElement2("C", []).type, []); | 3316 MethodElement staticElement = ElementFactory.methodElement("m", ElementFacto
ry.classElement2("C").type); |
| 3319 AuxiliaryElements auxiliaryElements = new AuxiliaryElements(staticElement, p
ropagatedElement); | 3317 AuxiliaryElements auxiliaryElements = new AuxiliaryElements(staticElement, p
ropagatedElement); |
| 3320 fromNode.auxiliaryElements = auxiliaryElements; | 3318 fromNode.auxiliaryElements = auxiliaryElements; |
| 3321 fromNode.propagatedElement = propagatedElement; | 3319 fromNode.propagatedElement = propagatedElement; |
| 3322 DartType propagatedType = ElementFactory.classElement2("C", []).type; | 3320 DartType propagatedType = ElementFactory.classElement2("C").type; |
| 3323 fromNode.propagatedType = propagatedType; | 3321 fromNode.propagatedType = propagatedType; |
| 3324 fromNode.staticElement = staticElement; | 3322 fromNode.staticElement = staticElement; |
| 3325 DartType staticType = ElementFactory.classElement2("C", []).type; | 3323 DartType staticType = ElementFactory.classElement2("C").type; |
| 3326 fromNode.staticType = staticType; | 3324 fromNode.staticType = staticType; |
| 3327 SimpleIdentifier toNode = AstFactory.identifier3("x"); | 3325 SimpleIdentifier toNode = AstFactory.identifier3("x"); |
| 3328 ResolutionCopier.copyResolutionData(fromNode, toNode); | 3326 ResolutionCopier.copyResolutionData(fromNode, toNode); |
| 3329 expect(toNode.auxiliaryElements, same(auxiliaryElements)); | 3327 expect(toNode.auxiliaryElements, same(auxiliaryElements)); |
| 3330 expect(toNode.propagatedElement, same(propagatedElement)); | 3328 expect(toNode.propagatedElement, same(propagatedElement)); |
| 3331 expect(toNode.propagatedType, same(propagatedType)); | 3329 expect(toNode.propagatedType, same(propagatedType)); |
| 3332 expect(toNode.staticElement, same(staticElement)); | 3330 expect(toNode.staticElement, same(staticElement)); |
| 3333 expect(toNode.staticType, same(staticType)); | 3331 expect(toNode.staticType, same(staticType)); |
| 3334 } | 3332 } |
| 3335 | 3333 |
| 3336 void test_visitSimpleStringLiteral() { | 3334 void test_visitSimpleStringLiteral() { |
| 3337 SimpleStringLiteral fromNode = AstFactory.string2("abc"); | 3335 SimpleStringLiteral fromNode = AstFactory.string2("abc"); |
| 3338 DartType propagatedType = ElementFactory.classElement2("C", []).type; | 3336 DartType propagatedType = ElementFactory.classElement2("C").type; |
| 3339 fromNode.propagatedType = propagatedType; | 3337 fromNode.propagatedType = propagatedType; |
| 3340 DartType staticType = ElementFactory.classElement2("C", []).type; | 3338 DartType staticType = ElementFactory.classElement2("C").type; |
| 3341 fromNode.staticType = staticType; | 3339 fromNode.staticType = staticType; |
| 3342 SimpleStringLiteral toNode = AstFactory.string2("abc"); | 3340 SimpleStringLiteral toNode = AstFactory.string2("abc"); |
| 3343 ResolutionCopier.copyResolutionData(fromNode, toNode); | 3341 ResolutionCopier.copyResolutionData(fromNode, toNode); |
| 3344 expect(toNode.propagatedType, same(propagatedType)); | 3342 expect(toNode.propagatedType, same(propagatedType)); |
| 3345 expect(toNode.staticType, same(staticType)); | 3343 expect(toNode.staticType, same(staticType)); |
| 3346 } | 3344 } |
| 3347 | 3345 |
| 3348 void test_visitStringInterpolation() { | 3346 void test_visitStringInterpolation() { |
| 3349 StringInterpolation fromNode = AstFactory.string([AstFactory.interpolationSt
ring("a", "'a'")]); | 3347 StringInterpolation fromNode = AstFactory.string([AstFactory.interpolationSt
ring("a", "'a'")]); |
| 3350 DartType propagatedType = ElementFactory.classElement2("C", []).type; | 3348 DartType propagatedType = ElementFactory.classElement2("C").type; |
| 3351 fromNode.propagatedType = propagatedType; | 3349 fromNode.propagatedType = propagatedType; |
| 3352 DartType staticType = ElementFactory.classElement2("C", []).type; | 3350 DartType staticType = ElementFactory.classElement2("C").type; |
| 3353 fromNode.staticType = staticType; | 3351 fromNode.staticType = staticType; |
| 3354 StringInterpolation toNode = AstFactory.string([AstFactory.interpolationStri
ng("a", "'a'")]); | 3352 StringInterpolation toNode = AstFactory.string([AstFactory.interpolationStri
ng("a", "'a'")]); |
| 3355 ResolutionCopier.copyResolutionData(fromNode, toNode); | 3353 ResolutionCopier.copyResolutionData(fromNode, toNode); |
| 3356 expect(toNode.propagatedType, same(propagatedType)); | 3354 expect(toNode.propagatedType, same(propagatedType)); |
| 3357 expect(toNode.staticType, same(staticType)); | 3355 expect(toNode.staticType, same(staticType)); |
| 3358 } | 3356 } |
| 3359 | 3357 |
| 3360 void test_visitSuperConstructorInvocation() { | 3358 void test_visitSuperConstructorInvocation() { |
| 3361 SuperConstructorInvocation fromNode = AstFactory.superConstructorInvocation(
[]); | 3359 SuperConstructorInvocation fromNode = AstFactory.superConstructorInvocation(
); |
| 3362 ConstructorElement staticElement = ElementFactory.constructorElement2(Elemen
tFactory.classElement2("C", []), null, []); | 3360 ConstructorElement staticElement = ElementFactory.constructorElement2(Elemen
tFactory.classElement2("C"), null); |
| 3363 fromNode.staticElement = staticElement; | 3361 fromNode.staticElement = staticElement; |
| 3364 SuperConstructorInvocation toNode = AstFactory.superConstructorInvocation([]
); | 3362 SuperConstructorInvocation toNode = AstFactory.superConstructorInvocation(); |
| 3365 ResolutionCopier.copyResolutionData(fromNode, toNode); | 3363 ResolutionCopier.copyResolutionData(fromNode, toNode); |
| 3366 expect(toNode.staticElement, same(staticElement)); | 3364 expect(toNode.staticElement, same(staticElement)); |
| 3367 } | 3365 } |
| 3368 | 3366 |
| 3369 void test_visitSuperExpression() { | 3367 void test_visitSuperExpression() { |
| 3370 SuperExpression fromNode = AstFactory.superExpression(); | 3368 SuperExpression fromNode = AstFactory.superExpression(); |
| 3371 DartType propagatedType = ElementFactory.classElement2("C", []).type; | 3369 DartType propagatedType = ElementFactory.classElement2("C").type; |
| 3372 fromNode.propagatedType = propagatedType; | 3370 fromNode.propagatedType = propagatedType; |
| 3373 DartType staticType = ElementFactory.classElement2("C", []).type; | 3371 DartType staticType = ElementFactory.classElement2("C").type; |
| 3374 fromNode.staticType = staticType; | 3372 fromNode.staticType = staticType; |
| 3375 SuperExpression toNode = AstFactory.superExpression(); | 3373 SuperExpression toNode = AstFactory.superExpression(); |
| 3376 ResolutionCopier.copyResolutionData(fromNode, toNode); | 3374 ResolutionCopier.copyResolutionData(fromNode, toNode); |
| 3377 expect(toNode.propagatedType, same(propagatedType)); | 3375 expect(toNode.propagatedType, same(propagatedType)); |
| 3378 expect(toNode.staticType, same(staticType)); | 3376 expect(toNode.staticType, same(staticType)); |
| 3379 } | 3377 } |
| 3380 | 3378 |
| 3381 void test_visitSymbolLiteral() { | 3379 void test_visitSymbolLiteral() { |
| 3382 SymbolLiteral fromNode = AstFactory.symbolLiteral(["s"]); | 3380 SymbolLiteral fromNode = AstFactory.symbolLiteral(["s"]); |
| 3383 DartType propagatedType = ElementFactory.classElement2("C", []).type; | 3381 DartType propagatedType = ElementFactory.classElement2("C").type; |
| 3384 fromNode.propagatedType = propagatedType; | 3382 fromNode.propagatedType = propagatedType; |
| 3385 DartType staticType = ElementFactory.classElement2("C", []).type; | 3383 DartType staticType = ElementFactory.classElement2("C").type; |
| 3386 fromNode.staticType = staticType; | 3384 fromNode.staticType = staticType; |
| 3387 SymbolLiteral toNode = AstFactory.symbolLiteral(["s"]); | 3385 SymbolLiteral toNode = AstFactory.symbolLiteral(["s"]); |
| 3388 ResolutionCopier.copyResolutionData(fromNode, toNode); | 3386 ResolutionCopier.copyResolutionData(fromNode, toNode); |
| 3389 expect(toNode.propagatedType, same(propagatedType)); | 3387 expect(toNode.propagatedType, same(propagatedType)); |
| 3390 expect(toNode.staticType, same(staticType)); | 3388 expect(toNode.staticType, same(staticType)); |
| 3391 } | 3389 } |
| 3392 | 3390 |
| 3393 void test_visitThisExpression() { | 3391 void test_visitThisExpression() { |
| 3394 ThisExpression fromNode = AstFactory.thisExpression(); | 3392 ThisExpression fromNode = AstFactory.thisExpression(); |
| 3395 DartType propagatedType = ElementFactory.classElement2("C", []).type; | 3393 DartType propagatedType = ElementFactory.classElement2("C").type; |
| 3396 fromNode.propagatedType = propagatedType; | 3394 fromNode.propagatedType = propagatedType; |
| 3397 DartType staticType = ElementFactory.classElement2("C", []).type; | 3395 DartType staticType = ElementFactory.classElement2("C").type; |
| 3398 fromNode.staticType = staticType; | 3396 fromNode.staticType = staticType; |
| 3399 ThisExpression toNode = AstFactory.thisExpression(); | 3397 ThisExpression toNode = AstFactory.thisExpression(); |
| 3400 ResolutionCopier.copyResolutionData(fromNode, toNode); | 3398 ResolutionCopier.copyResolutionData(fromNode, toNode); |
| 3401 expect(toNode.propagatedType, same(propagatedType)); | 3399 expect(toNode.propagatedType, same(propagatedType)); |
| 3402 expect(toNode.staticType, same(staticType)); | 3400 expect(toNode.staticType, same(staticType)); |
| 3403 } | 3401 } |
| 3404 | 3402 |
| 3405 void test_visitThrowExpression() { | 3403 void test_visitThrowExpression() { |
| 3406 ThrowExpression fromNode = AstFactory.throwExpression(); | 3404 ThrowExpression fromNode = AstFactory.throwExpression(); |
| 3407 DartType propagatedType = ElementFactory.classElement2("C", []).type; | 3405 DartType propagatedType = ElementFactory.classElement2("C").type; |
| 3408 fromNode.propagatedType = propagatedType; | 3406 fromNode.propagatedType = propagatedType; |
| 3409 DartType staticType = ElementFactory.classElement2("C", []).type; | 3407 DartType staticType = ElementFactory.classElement2("C").type; |
| 3410 fromNode.staticType = staticType; | 3408 fromNode.staticType = staticType; |
| 3411 ThrowExpression toNode = AstFactory.throwExpression(); | 3409 ThrowExpression toNode = AstFactory.throwExpression(); |
| 3412 ResolutionCopier.copyResolutionData(fromNode, toNode); | 3410 ResolutionCopier.copyResolutionData(fromNode, toNode); |
| 3413 expect(toNode.propagatedType, same(propagatedType)); | 3411 expect(toNode.propagatedType, same(propagatedType)); |
| 3414 expect(toNode.staticType, same(staticType)); | 3412 expect(toNode.staticType, same(staticType)); |
| 3415 } | 3413 } |
| 3416 | 3414 |
| 3417 void test_visitTypeName() { | 3415 void test_visitTypeName() { |
| 3418 TypeName fromNode = AstFactory.typeName4("C", []); | 3416 TypeName fromNode = AstFactory.typeName4("C"); |
| 3419 DartType type = ElementFactory.classElement2("C", []).type; | 3417 DartType type = ElementFactory.classElement2("C").type; |
| 3420 fromNode.type = type; | 3418 fromNode.type = type; |
| 3421 TypeName toNode = AstFactory.typeName4("C", []); | 3419 TypeName toNode = AstFactory.typeName4("C"); |
| 3422 ResolutionCopier.copyResolutionData(fromNode, toNode); | 3420 ResolutionCopier.copyResolutionData(fromNode, toNode); |
| 3423 expect(toNode.type, same(type)); | 3421 expect(toNode.type, same(type)); |
| 3424 } | 3422 } |
| 3425 } | 3423 } |
| 3426 | 3424 |
| 3427 /** | 3425 /** |
| 3428 * The class `SimpleParserTest` defines parser tests that test individual parsin
g method. The | 3426 * The class `SimpleParserTest` defines parser tests that test individual parsin
g method. The |
| 3429 * code fragments should be as minimal as possible in order to test the method,
but should not test | 3427 * code fragments should be as minimal as possible in order to test the method,
but should not test |
| 3430 * the interactions between the method under test and other methods. | 3428 * the interactions between the method under test and other methods. |
| 3431 * | 3429 * |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3530 SimpleIdentifier identifier = _createSyntheticIdentifier(); | 3528 SimpleIdentifier identifier = _createSyntheticIdentifier(); |
| 3531 expect(identifier.isSynthetic, isTrue); | 3529 expect(identifier.isSynthetic, isTrue); |
| 3532 } | 3530 } |
| 3533 | 3531 |
| 3534 void test_createSyntheticStringLiteral() { | 3532 void test_createSyntheticStringLiteral() { |
| 3535 SimpleStringLiteral literal = _createSyntheticStringLiteral(); | 3533 SimpleStringLiteral literal = _createSyntheticStringLiteral(); |
| 3536 expect(literal.isSynthetic, isTrue); | 3534 expect(literal.isSynthetic, isTrue); |
| 3537 } | 3535 } |
| 3538 | 3536 |
| 3539 void test_function_literal_allowed_at_toplevel() { | 3537 void test_function_literal_allowed_at_toplevel() { |
| 3540 ParserTestCase.parseCompilationUnit("var x = () {};", []); | 3538 ParserTestCase.parseCompilationUnit("var x = () {};"); |
| 3541 } | 3539 } |
| 3542 | 3540 |
| 3543 void test_function_literal_allowed_in_ArgumentList_in_ConstructorFieldInitiali
zer() { | 3541 void test_function_literal_allowed_in_ArgumentList_in_ConstructorFieldInitiali
zer() { |
| 3544 ParserTestCase.parseCompilationUnit("class C { C() : a = f(() {}); }", []); | 3542 ParserTestCase.parseCompilationUnit("class C { C() : a = f(() {}); }"); |
| 3545 } | 3543 } |
| 3546 | 3544 |
| 3547 void test_function_literal_allowed_in_IndexExpression_in_ConstructorFieldIniti
alizer() { | 3545 void test_function_literal_allowed_in_IndexExpression_in_ConstructorFieldIniti
alizer() { |
| 3548 ParserTestCase.parseCompilationUnit("class C { C() : a = x[() {}]; }", []); | 3546 ParserTestCase.parseCompilationUnit("class C { C() : a = x[() {}]; }"); |
| 3549 } | 3547 } |
| 3550 | 3548 |
| 3551 void test_function_literal_allowed_in_ListLiteral_in_ConstructorFieldInitializ
er() { | 3549 void test_function_literal_allowed_in_ListLiteral_in_ConstructorFieldInitializ
er() { |
| 3552 ParserTestCase.parseCompilationUnit("class C { C() : a = [() {}]; }", []); | 3550 ParserTestCase.parseCompilationUnit("class C { C() : a = [() {}]; }"); |
| 3553 } | 3551 } |
| 3554 | 3552 |
| 3555 void test_function_literal_allowed_in_MapLiteral_in_ConstructorFieldInitialize
r() { | 3553 void test_function_literal_allowed_in_MapLiteral_in_ConstructorFieldInitialize
r() { |
| 3556 ParserTestCase.parseCompilationUnit("class C { C() : a = {'key': () {}}; }",
[]); | 3554 ParserTestCase.parseCompilationUnit("class C { C() : a = {'key': () {}}; }")
; |
| 3557 } | 3555 } |
| 3558 | 3556 |
| 3559 void test_function_literal_allowed_in_ParenthesizedExpression_in_ConstructorFi
eldInitializer() { | 3557 void test_function_literal_allowed_in_ParenthesizedExpression_in_ConstructorFi
eldInitializer() { |
| 3560 ParserTestCase.parseCompilationUnit("class C { C() : a = (() {}); }", []); | 3558 ParserTestCase.parseCompilationUnit("class C { C() : a = (() {}); }"); |
| 3561 } | 3559 } |
| 3562 | 3560 |
| 3563 void test_function_literal_allowed_in_StringInterpolation_in_ConstructorFieldI
nitializer() { | 3561 void test_function_literal_allowed_in_StringInterpolation_in_ConstructorFieldI
nitializer() { |
| 3564 ParserTestCase.parseCompilationUnit("class C { C() : a = \"\${(){}}\"; }", [
]); | 3562 ParserTestCase.parseCompilationUnit("class C { C() : a = \"\${(){}}\"; }"); |
| 3565 } | 3563 } |
| 3566 | 3564 |
| 3567 void test_isFunctionDeclaration_nameButNoReturn_block() { | 3565 void test_isFunctionDeclaration_nameButNoReturn_block() { |
| 3568 expect(_isFunctionDeclaration("f() {}"), isTrue); | 3566 expect(_isFunctionDeclaration("f() {}"), isTrue); |
| 3569 } | 3567 } |
| 3570 | 3568 |
| 3571 void test_isFunctionDeclaration_nameButNoReturn_expression() { | 3569 void test_isFunctionDeclaration_nameButNoReturn_expression() { |
| 3572 expect(_isFunctionDeclaration("f() => e"), isTrue); | 3570 expect(_isFunctionDeclaration("f() => e"), isTrue); |
| 3573 } | 3571 } |
| 3574 | 3572 |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3719 | 3717 |
| 3720 void test_isSwitchMember_default_unlabeled() { | 3718 void test_isSwitchMember_default_unlabeled() { |
| 3721 expect(_isSwitchMember("default"), isTrue); | 3719 expect(_isSwitchMember("default"), isTrue); |
| 3722 } | 3720 } |
| 3723 | 3721 |
| 3724 void test_isSwitchMember_false() { | 3722 void test_isSwitchMember_false() { |
| 3725 expect(_isSwitchMember("break;"), isFalse); | 3723 expect(_isSwitchMember("break;"), isFalse); |
| 3726 } | 3724 } |
| 3727 | 3725 |
| 3728 void test_parseAdditiveExpression_normal() { | 3726 void test_parseAdditiveExpression_normal() { |
| 3729 BinaryExpression expression = ParserTestCase.parse4("parseAdditiveExpression
", "x + y", []); | 3727 BinaryExpression expression = ParserTestCase.parse4("parseAdditiveExpression
", "x + y"); |
| 3730 expect(expression.leftOperand, isNotNull); | 3728 expect(expression.leftOperand, isNotNull); |
| 3731 expect(expression.operator, isNotNull); | 3729 expect(expression.operator, isNotNull); |
| 3732 expect(expression.operator.type, TokenType.PLUS); | 3730 expect(expression.operator.type, TokenType.PLUS); |
| 3733 expect(expression.rightOperand, isNotNull); | 3731 expect(expression.rightOperand, isNotNull); |
| 3734 } | 3732 } |
| 3735 | 3733 |
| 3736 void test_parseAdditiveExpression_super() { | 3734 void test_parseAdditiveExpression_super() { |
| 3737 BinaryExpression expression = ParserTestCase.parse4("parseAdditiveExpression
", "super + y", []); | 3735 BinaryExpression expression = ParserTestCase.parse4("parseAdditiveExpression
", "super + y"); |
| 3738 EngineTestCase.assertInstanceOf((obj) => obj is SuperExpression, SuperExpres
sion, expression.leftOperand); | 3736 EngineTestCase.assertInstanceOf((obj) => obj is SuperExpression, SuperExpres
sion, expression.leftOperand); |
| 3739 expect(expression.operator, isNotNull); | 3737 expect(expression.operator, isNotNull); |
| 3740 expect(expression.operator.type, TokenType.PLUS); | 3738 expect(expression.operator.type, TokenType.PLUS); |
| 3741 expect(expression.rightOperand, isNotNull); | 3739 expect(expression.rightOperand, isNotNull); |
| 3742 } | 3740 } |
| 3743 | 3741 |
| 3744 void test_parseAnnotation_n1() { | 3742 void test_parseAnnotation_n1() { |
| 3745 Annotation annotation = ParserTestCase.parse4("parseAnnotation", "@A", []); | 3743 Annotation annotation = ParserTestCase.parse4("parseAnnotation", "@A"); |
| 3746 expect(annotation.atSign, isNotNull); | 3744 expect(annotation.atSign, isNotNull); |
| 3747 expect(annotation.name, isNotNull); | 3745 expect(annotation.name, isNotNull); |
| 3748 expect(annotation.period, isNull); | 3746 expect(annotation.period, isNull); |
| 3749 expect(annotation.constructorName, isNull); | 3747 expect(annotation.constructorName, isNull); |
| 3750 expect(annotation.arguments, isNull); | 3748 expect(annotation.arguments, isNull); |
| 3751 } | 3749 } |
| 3752 | 3750 |
| 3753 void test_parseAnnotation_n1_a() { | 3751 void test_parseAnnotation_n1_a() { |
| 3754 Annotation annotation = ParserTestCase.parse4("parseAnnotation", "@A(x,y)",
[]); | 3752 Annotation annotation = ParserTestCase.parse4("parseAnnotation", "@A(x,y)"); |
| 3755 expect(annotation.atSign, isNotNull); | 3753 expect(annotation.atSign, isNotNull); |
| 3756 expect(annotation.name, isNotNull); | 3754 expect(annotation.name, isNotNull); |
| 3757 expect(annotation.period, isNull); | 3755 expect(annotation.period, isNull); |
| 3758 expect(annotation.constructorName, isNull); | 3756 expect(annotation.constructorName, isNull); |
| 3759 expect(annotation.arguments, isNotNull); | 3757 expect(annotation.arguments, isNotNull); |
| 3760 } | 3758 } |
| 3761 | 3759 |
| 3762 void test_parseAnnotation_n2() { | 3760 void test_parseAnnotation_n2() { |
| 3763 Annotation annotation = ParserTestCase.parse4("parseAnnotation", "@A.B", [])
; | 3761 Annotation annotation = ParserTestCase.parse4("parseAnnotation", "@A.B"); |
| 3764 expect(annotation.atSign, isNotNull); | 3762 expect(annotation.atSign, isNotNull); |
| 3765 expect(annotation.name, isNotNull); | 3763 expect(annotation.name, isNotNull); |
| 3766 expect(annotation.period, isNull); | 3764 expect(annotation.period, isNull); |
| 3767 expect(annotation.constructorName, isNull); | 3765 expect(annotation.constructorName, isNull); |
| 3768 expect(annotation.arguments, isNull); | 3766 expect(annotation.arguments, isNull); |
| 3769 } | 3767 } |
| 3770 | 3768 |
| 3771 void test_parseAnnotation_n2_a() { | 3769 void test_parseAnnotation_n2_a() { |
| 3772 Annotation annotation = ParserTestCase.parse4("parseAnnotation", "@A.B(x,y)"
, []); | 3770 Annotation annotation = ParserTestCase.parse4("parseAnnotation", "@A.B(x,y)"
); |
| 3773 expect(annotation.atSign, isNotNull); | 3771 expect(annotation.atSign, isNotNull); |
| 3774 expect(annotation.name, isNotNull); | 3772 expect(annotation.name, isNotNull); |
| 3775 expect(annotation.period, isNull); | 3773 expect(annotation.period, isNull); |
| 3776 expect(annotation.constructorName, isNull); | 3774 expect(annotation.constructorName, isNull); |
| 3777 expect(annotation.arguments, isNotNull); | 3775 expect(annotation.arguments, isNotNull); |
| 3778 } | 3776 } |
| 3779 | 3777 |
| 3780 void test_parseAnnotation_n3() { | 3778 void test_parseAnnotation_n3() { |
| 3781 Annotation annotation = ParserTestCase.parse4("parseAnnotation", "@A.B.C", [
]); | 3779 Annotation annotation = ParserTestCase.parse4("parseAnnotation", "@A.B.C"); |
| 3782 expect(annotation.atSign, isNotNull); | 3780 expect(annotation.atSign, isNotNull); |
| 3783 expect(annotation.name, isNotNull); | 3781 expect(annotation.name, isNotNull); |
| 3784 expect(annotation.period, isNotNull); | 3782 expect(annotation.period, isNotNull); |
| 3785 expect(annotation.constructorName, isNotNull); | 3783 expect(annotation.constructorName, isNotNull); |
| 3786 expect(annotation.arguments, isNull); | 3784 expect(annotation.arguments, isNull); |
| 3787 } | 3785 } |
| 3788 | 3786 |
| 3789 void test_parseAnnotation_n3_a() { | 3787 void test_parseAnnotation_n3_a() { |
| 3790 Annotation annotation = ParserTestCase.parse4("parseAnnotation", "@A.B.C(x,y
)", []); | 3788 Annotation annotation = ParserTestCase.parse4("parseAnnotation", "@A.B.C(x,y
)"); |
| 3791 expect(annotation.atSign, isNotNull); | 3789 expect(annotation.atSign, isNotNull); |
| 3792 expect(annotation.name, isNotNull); | 3790 expect(annotation.name, isNotNull); |
| 3793 expect(annotation.period, isNotNull); | 3791 expect(annotation.period, isNotNull); |
| 3794 expect(annotation.constructorName, isNotNull); | 3792 expect(annotation.constructorName, isNotNull); |
| 3795 expect(annotation.arguments, isNotNull); | 3793 expect(annotation.arguments, isNotNull); |
| 3796 } | 3794 } |
| 3797 | 3795 |
| 3798 void test_parseArgument_named() { | 3796 void test_parseArgument_named() { |
| 3799 NamedExpression expression = ParserTestCase.parse4("parseArgument", "n: x",
[]); | 3797 NamedExpression expression = ParserTestCase.parse4("parseArgument", "n: x"); |
| 3800 Label name = expression.name; | 3798 Label name = expression.name; |
| 3801 expect(name, isNotNull); | 3799 expect(name, isNotNull); |
| 3802 expect(name.label, isNotNull); | 3800 expect(name.label, isNotNull); |
| 3803 expect(name.colon, isNotNull); | 3801 expect(name.colon, isNotNull); |
| 3804 expect(expression.expression, isNotNull); | 3802 expect(expression.expression, isNotNull); |
| 3805 } | 3803 } |
| 3806 | 3804 |
| 3807 void test_parseArgument_unnamed() { | 3805 void test_parseArgument_unnamed() { |
| 3808 String lexeme = "x"; | 3806 String lexeme = "x"; |
| 3809 SimpleIdentifier identifier = ParserTestCase.parse4("parseArgument", lexeme,
[]); | 3807 SimpleIdentifier identifier = ParserTestCase.parse4("parseArgument", lexeme)
; |
| 3810 expect(identifier.name, lexeme); | 3808 expect(identifier.name, lexeme); |
| 3811 } | 3809 } |
| 3812 | 3810 |
| 3813 void test_parseArgumentList_empty() { | 3811 void test_parseArgumentList_empty() { |
| 3814 ArgumentList argumentList = ParserTestCase.parse4("parseArgumentList", "()",
[]); | 3812 ArgumentList argumentList = ParserTestCase.parse4("parseArgumentList", "()")
; |
| 3815 NodeList<Expression> arguments = argumentList.arguments; | 3813 NodeList<Expression> arguments = argumentList.arguments; |
| 3816 expect(arguments, hasLength(0)); | 3814 expect(arguments, hasLength(0)); |
| 3817 } | 3815 } |
| 3818 | 3816 |
| 3819 void test_parseArgumentList_mixed() { | 3817 void test_parseArgumentList_mixed() { |
| 3820 ArgumentList argumentList = ParserTestCase.parse4("parseArgumentList", "(w,
x, y: y, z: z)", []); | 3818 ArgumentList argumentList = ParserTestCase.parse4("parseArgumentList", "(w,
x, y: y, z: z)"); |
| 3821 NodeList<Expression> arguments = argumentList.arguments; | 3819 NodeList<Expression> arguments = argumentList.arguments; |
| 3822 expect(arguments, hasLength(4)); | 3820 expect(arguments, hasLength(4)); |
| 3823 } | 3821 } |
| 3824 | 3822 |
| 3825 void test_parseArgumentList_noNamed() { | 3823 void test_parseArgumentList_noNamed() { |
| 3826 ArgumentList argumentList = ParserTestCase.parse4("parseArgumentList", "(x,
y, z)", []); | 3824 ArgumentList argumentList = ParserTestCase.parse4("parseArgumentList", "(x,
y, z)"); |
| 3827 NodeList<Expression> arguments = argumentList.arguments; | 3825 NodeList<Expression> arguments = argumentList.arguments; |
| 3828 expect(arguments, hasLength(3)); | 3826 expect(arguments, hasLength(3)); |
| 3829 } | 3827 } |
| 3830 | 3828 |
| 3831 void test_parseArgumentList_onlyNamed() { | 3829 void test_parseArgumentList_onlyNamed() { |
| 3832 ArgumentList argumentList = ParserTestCase.parse4("parseArgumentList", "(x:
x, y: y)", []); | 3830 ArgumentList argumentList = ParserTestCase.parse4("parseArgumentList", "(x:
x, y: y)"); |
| 3833 NodeList<Expression> arguments = argumentList.arguments; | 3831 NodeList<Expression> arguments = argumentList.arguments; |
| 3834 expect(arguments, hasLength(2)); | 3832 expect(arguments, hasLength(2)); |
| 3835 } | 3833 } |
| 3836 | 3834 |
| 3837 void test_parseAssertStatement() { | 3835 void test_parseAssertStatement() { |
| 3838 AssertStatement statement = ParserTestCase.parse4("parseAssertStatement", "a
ssert (x);", []); | 3836 AssertStatement statement = ParserTestCase.parse4("parseAssertStatement", "a
ssert (x);"); |
| 3839 expect(statement.keyword, isNotNull); | 3837 expect(statement.keyword, isNotNull); |
| 3840 expect(statement.leftParenthesis, isNotNull); | 3838 expect(statement.leftParenthesis, isNotNull); |
| 3841 expect(statement.condition, isNotNull); | 3839 expect(statement.condition, isNotNull); |
| 3842 expect(statement.rightParenthesis, isNotNull); | 3840 expect(statement.rightParenthesis, isNotNull); |
| 3843 expect(statement.semicolon, isNotNull); | 3841 expect(statement.semicolon, isNotNull); |
| 3844 } | 3842 } |
| 3845 | 3843 |
| 3846 void test_parseAssignableExpression_expression_args_dot() { | 3844 void test_parseAssignableExpression_expression_args_dot() { |
| 3847 PropertyAccess propertyAccess = ParserTestCase.parse("parseAssignableExpress
ion", <Object> [false], "(x)(y).z"); | 3845 PropertyAccess propertyAccess = ParserTestCase.parse("parseAssignableExpress
ion", <Object> [false], "(x)(y).z"); |
| 3848 FunctionExpressionInvocation invocation = propertyAccess.target as FunctionE
xpressionInvocation; | 3846 FunctionExpressionInvocation invocation = propertyAccess.target as FunctionE
xpressionInvocation; |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3927 expect(selector.index, isNotNull); | 3925 expect(selector.index, isNotNull); |
| 3928 expect(selector.rightBracket, isNotNull); | 3926 expect(selector.rightBracket, isNotNull); |
| 3929 } | 3927 } |
| 3930 | 3928 |
| 3931 void test_parseAssignableSelector_none() { | 3929 void test_parseAssignableSelector_none() { |
| 3932 SimpleIdentifier selector = ParserTestCase.parse("parseAssignableSelector",
<Object> [new SimpleIdentifier(null), true], ";"); | 3930 SimpleIdentifier selector = ParserTestCase.parse("parseAssignableSelector",
<Object> [new SimpleIdentifier(null), true], ";"); |
| 3933 expect(selector, isNotNull); | 3931 expect(selector, isNotNull); |
| 3934 } | 3932 } |
| 3935 | 3933 |
| 3936 void test_parseAwaitExpression() { | 3934 void test_parseAwaitExpression() { |
| 3937 AwaitExpression expression = ParserTestCase.parse4("parseAwaitExpression", "
await x;", []); | 3935 AwaitExpression expression = ParserTestCase.parse4("parseAwaitExpression", "
await x;"); |
| 3938 expect(expression.awaitKeyword, isNotNull); | 3936 expect(expression.awaitKeyword, isNotNull); |
| 3939 expect(expression.expression, isNotNull); | 3937 expect(expression.expression, isNotNull); |
| 3940 } | 3938 } |
| 3941 | 3939 |
| 3942 void test_parseAwaitExpression_asStatement_inAsync() { | 3940 void test_parseAwaitExpression_asStatement_inAsync() { |
| 3943 MethodDeclaration method = ParserTestCase.parse("parseClassMember", <Object>
["C"], "m() async { await x; }"); | 3941 MethodDeclaration method = ParserTestCase.parse("parseClassMember", <Object>
["C"], "m() async { await x; }"); |
| 3944 FunctionBody body = method.body; | 3942 FunctionBody body = method.body; |
| 3945 EngineTestCase.assertInstanceOf((obj) => obj is BlockFunctionBody, BlockFunc
tionBody, body); | 3943 EngineTestCase.assertInstanceOf((obj) => obj is BlockFunctionBody, BlockFunc
tionBody, body); |
| 3946 Statement statement = (body as BlockFunctionBody).block.statements[0]; | 3944 Statement statement = (body as BlockFunctionBody).block.statements[0]; |
| 3947 EngineTestCase.assertInstanceOf((obj) => obj is ExpressionStatement, Express
ionStatement, statement); | 3945 EngineTestCase.assertInstanceOf((obj) => obj is ExpressionStatement, Express
ionStatement, statement); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 3965 EngineTestCase.assertInstanceOf((obj) => obj is BlockFunctionBody, BlockFunc
tionBody, body); | 3963 EngineTestCase.assertInstanceOf((obj) => obj is BlockFunctionBody, BlockFunc
tionBody, body); |
| 3966 Statement statement = (body as BlockFunctionBody).block.statements[0]; | 3964 Statement statement = (body as BlockFunctionBody).block.statements[0]; |
| 3967 EngineTestCase.assertInstanceOf((obj) => obj is ReturnStatement, ReturnState
ment, statement); | 3965 EngineTestCase.assertInstanceOf((obj) => obj is ReturnStatement, ReturnState
ment, statement); |
| 3968 Expression expression = (statement as ReturnStatement).expression; | 3966 Expression expression = (statement as ReturnStatement).expression; |
| 3969 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, BinaryExpr
ession, expression); | 3967 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, BinaryExpr
ession, expression); |
| 3970 EngineTestCase.assertInstanceOf((obj) => obj is AwaitExpression, AwaitExpres
sion, (expression as BinaryExpression).leftOperand); | 3968 EngineTestCase.assertInstanceOf((obj) => obj is AwaitExpression, AwaitExpres
sion, (expression as BinaryExpression).leftOperand); |
| 3971 EngineTestCase.assertInstanceOf((obj) => obj is AwaitExpression, AwaitExpres
sion, (expression as BinaryExpression).rightOperand); | 3969 EngineTestCase.assertInstanceOf((obj) => obj is AwaitExpression, AwaitExpres
sion, (expression as BinaryExpression).rightOperand); |
| 3972 } | 3970 } |
| 3973 | 3971 |
| 3974 void test_parseBitwiseAndExpression_normal() { | 3972 void test_parseBitwiseAndExpression_normal() { |
| 3975 BinaryExpression expression = ParserTestCase.parse4("parseBitwiseAndExpressi
on", "x & y", []); | 3973 BinaryExpression expression = ParserTestCase.parse4("parseBitwiseAndExpressi
on", "x & y"); |
| 3976 expect(expression.leftOperand, isNotNull); | 3974 expect(expression.leftOperand, isNotNull); |
| 3977 expect(expression.operator, isNotNull); | 3975 expect(expression.operator, isNotNull); |
| 3978 expect(expression.operator.type, TokenType.AMPERSAND); | 3976 expect(expression.operator.type, TokenType.AMPERSAND); |
| 3979 expect(expression.rightOperand, isNotNull); | 3977 expect(expression.rightOperand, isNotNull); |
| 3980 } | 3978 } |
| 3981 | 3979 |
| 3982 void test_parseBitwiseAndExpression_super() { | 3980 void test_parseBitwiseAndExpression_super() { |
| 3983 BinaryExpression expression = ParserTestCase.parse4("parseBitwiseAndExpressi
on", "super & y", []); | 3981 BinaryExpression expression = ParserTestCase.parse4("parseBitwiseAndExpressi
on", "super & y"); |
| 3984 EngineTestCase.assertInstanceOf((obj) => obj is SuperExpression, SuperExpres
sion, expression.leftOperand); | 3982 EngineTestCase.assertInstanceOf((obj) => obj is SuperExpression, SuperExpres
sion, expression.leftOperand); |
| 3985 expect(expression.operator, isNotNull); | 3983 expect(expression.operator, isNotNull); |
| 3986 expect(expression.operator.type, TokenType.AMPERSAND); | 3984 expect(expression.operator.type, TokenType.AMPERSAND); |
| 3987 expect(expression.rightOperand, isNotNull); | 3985 expect(expression.rightOperand, isNotNull); |
| 3988 } | 3986 } |
| 3989 | 3987 |
| 3990 void test_parseBitwiseOrExpression_normal() { | 3988 void test_parseBitwiseOrExpression_normal() { |
| 3991 BinaryExpression expression = ParserTestCase.parse4("parseBitwiseOrExpressio
n", "x | y", []); | 3989 BinaryExpression expression = ParserTestCase.parse4("parseBitwiseOrExpressio
n", "x | y"); |
| 3992 expect(expression.leftOperand, isNotNull); | 3990 expect(expression.leftOperand, isNotNull); |
| 3993 expect(expression.operator, isNotNull); | 3991 expect(expression.operator, isNotNull); |
| 3994 expect(expression.operator.type, TokenType.BAR); | 3992 expect(expression.operator.type, TokenType.BAR); |
| 3995 expect(expression.rightOperand, isNotNull); | 3993 expect(expression.rightOperand, isNotNull); |
| 3996 } | 3994 } |
| 3997 | 3995 |
| 3998 void test_parseBitwiseOrExpression_super() { | 3996 void test_parseBitwiseOrExpression_super() { |
| 3999 BinaryExpression expression = ParserTestCase.parse4("parseBitwiseOrExpressio
n", "super | y", []); | 3997 BinaryExpression expression = ParserTestCase.parse4("parseBitwiseOrExpressio
n", "super | y"); |
| 4000 EngineTestCase.assertInstanceOf((obj) => obj is SuperExpression, SuperExpres
sion, expression.leftOperand); | 3998 EngineTestCase.assertInstanceOf((obj) => obj is SuperExpression, SuperExpres
sion, expression.leftOperand); |
| 4001 expect(expression.operator, isNotNull); | 3999 expect(expression.operator, isNotNull); |
| 4002 expect(expression.operator.type, TokenType.BAR); | 4000 expect(expression.operator.type, TokenType.BAR); |
| 4003 expect(expression.rightOperand, isNotNull); | 4001 expect(expression.rightOperand, isNotNull); |
| 4004 } | 4002 } |
| 4005 | 4003 |
| 4006 void test_parseBitwiseXorExpression_normal() { | 4004 void test_parseBitwiseXorExpression_normal() { |
| 4007 BinaryExpression expression = ParserTestCase.parse4("parseBitwiseXorExpressi
on", "x ^ y", []); | 4005 BinaryExpression expression = ParserTestCase.parse4("parseBitwiseXorExpressi
on", "x ^ y"); |
| 4008 expect(expression.leftOperand, isNotNull); | 4006 expect(expression.leftOperand, isNotNull); |
| 4009 expect(expression.operator, isNotNull); | 4007 expect(expression.operator, isNotNull); |
| 4010 expect(expression.operator.type, TokenType.CARET); | 4008 expect(expression.operator.type, TokenType.CARET); |
| 4011 expect(expression.rightOperand, isNotNull); | 4009 expect(expression.rightOperand, isNotNull); |
| 4012 } | 4010 } |
| 4013 | 4011 |
| 4014 void test_parseBitwiseXorExpression_super() { | 4012 void test_parseBitwiseXorExpression_super() { |
| 4015 BinaryExpression expression = ParserTestCase.parse4("parseBitwiseXorExpressi
on", "super ^ y", []); | 4013 BinaryExpression expression = ParserTestCase.parse4("parseBitwiseXorExpressi
on", "super ^ y"); |
| 4016 EngineTestCase.assertInstanceOf((obj) => obj is SuperExpression, SuperExpres
sion, expression.leftOperand); | 4014 EngineTestCase.assertInstanceOf((obj) => obj is SuperExpression, SuperExpres
sion, expression.leftOperand); |
| 4017 expect(expression.operator, isNotNull); | 4015 expect(expression.operator, isNotNull); |
| 4018 expect(expression.operator.type, TokenType.CARET); | 4016 expect(expression.operator.type, TokenType.CARET); |
| 4019 expect(expression.rightOperand, isNotNull); | 4017 expect(expression.rightOperand, isNotNull); |
| 4020 } | 4018 } |
| 4021 | 4019 |
| 4022 void test_parseBlock_empty() { | 4020 void test_parseBlock_empty() { |
| 4023 Block block = ParserTestCase.parse4("parseBlock", "{}", []); | 4021 Block block = ParserTestCase.parse4("parseBlock", "{}"); |
| 4024 expect(block.leftBracket, isNotNull); | 4022 expect(block.leftBracket, isNotNull); |
| 4025 expect(block.statements, hasLength(0)); | 4023 expect(block.statements, hasLength(0)); |
| 4026 expect(block.rightBracket, isNotNull); | 4024 expect(block.rightBracket, isNotNull); |
| 4027 } | 4025 } |
| 4028 | 4026 |
| 4029 void test_parseBlock_nonEmpty() { | 4027 void test_parseBlock_nonEmpty() { |
| 4030 Block block = ParserTestCase.parse4("parseBlock", "{;}", []); | 4028 Block block = ParserTestCase.parse4("parseBlock", "{;}"); |
| 4031 expect(block.leftBracket, isNotNull); | 4029 expect(block.leftBracket, isNotNull); |
| 4032 expect(block.statements, hasLength(1)); | 4030 expect(block.statements, hasLength(1)); |
| 4033 expect(block.rightBracket, isNotNull); | 4031 expect(block.rightBracket, isNotNull); |
| 4034 } | 4032 } |
| 4035 | 4033 |
| 4036 void test_parseBreakStatement_label() { | 4034 void test_parseBreakStatement_label() { |
| 4037 BreakStatement statement = ParserTestCase.parse4("parseBreakStatement", "bre
ak foo;", []); | 4035 BreakStatement statement = ParserTestCase.parse4("parseBreakStatement", "bre
ak foo;"); |
| 4038 expect(statement.keyword, isNotNull); | 4036 expect(statement.keyword, isNotNull); |
| 4039 expect(statement.label, isNotNull); | 4037 expect(statement.label, isNotNull); |
| 4040 expect(statement.semicolon, isNotNull); | 4038 expect(statement.semicolon, isNotNull); |
| 4041 } | 4039 } |
| 4042 | 4040 |
| 4043 void test_parseBreakStatement_noLabel() { | 4041 void test_parseBreakStatement_noLabel() { |
| 4044 BreakStatement statement = ParserTestCase.parse4("parseBreakStatement", "bre
ak;", [ParserErrorCode.BREAK_OUTSIDE_OF_LOOP]); | 4042 BreakStatement statement = ParserTestCase.parse4("parseBreakStatement", "bre
ak;", [ParserErrorCode.BREAK_OUTSIDE_OF_LOOP]); |
| 4045 expect(statement.keyword, isNotNull); | 4043 expect(statement.keyword, isNotNull); |
| 4046 expect(statement.label, isNull); | 4044 expect(statement.label, isNull); |
| 4047 expect(statement.semicolon, isNotNull); | 4045 expect(statement.semicolon, isNotNull); |
| 4048 } | 4046 } |
| 4049 | 4047 |
| 4050 void test_parseCascadeSection_i() { | 4048 void test_parseCascadeSection_i() { |
| 4051 IndexExpression section = ParserTestCase.parse4("parseCascadeSection", "..[i
]", []); | 4049 IndexExpression section = ParserTestCase.parse4("parseCascadeSection", "..[i
]"); |
| 4052 expect(section.target, isNull); | 4050 expect(section.target, isNull); |
| 4053 expect(section.leftBracket, isNotNull); | 4051 expect(section.leftBracket, isNotNull); |
| 4054 expect(section.index, isNotNull); | 4052 expect(section.index, isNotNull); |
| 4055 expect(section.rightBracket, isNotNull); | 4053 expect(section.rightBracket, isNotNull); |
| 4056 } | 4054 } |
| 4057 | 4055 |
| 4058 void test_parseCascadeSection_ia() { | 4056 void test_parseCascadeSection_ia() { |
| 4059 FunctionExpressionInvocation section = ParserTestCase.parse4("parseCascadeSe
ction", "..[i](b)", []); | 4057 FunctionExpressionInvocation section = ParserTestCase.parse4("parseCascadeSe
ction", "..[i](b)"); |
| 4060 EngineTestCase.assertInstanceOf((obj) => obj is IndexExpression, IndexExpres
sion, section.function); | 4058 EngineTestCase.assertInstanceOf((obj) => obj is IndexExpression, IndexExpres
sion, section.function); |
| 4061 expect(section.argumentList, isNotNull); | 4059 expect(section.argumentList, isNotNull); |
| 4062 } | 4060 } |
| 4063 | 4061 |
| 4064 void test_parseCascadeSection_ii() { | 4062 void test_parseCascadeSection_ii() { |
| 4065 MethodInvocation section = ParserTestCase.parse4("parseCascadeSection", "..a
(b).c(d)", []); | 4063 MethodInvocation section = ParserTestCase.parse4("parseCascadeSection", "..a
(b).c(d)"); |
| 4066 EngineTestCase.assertInstanceOf((obj) => obj is MethodInvocation, MethodInvo
cation, section.target); | 4064 EngineTestCase.assertInstanceOf((obj) => obj is MethodInvocation, MethodInvo
cation, section.target); |
| 4067 expect(section.period, isNotNull); | 4065 expect(section.period, isNotNull); |
| 4068 expect(section.methodName, isNotNull); | 4066 expect(section.methodName, isNotNull); |
| 4069 expect(section.argumentList, isNotNull); | 4067 expect(section.argumentList, isNotNull); |
| 4070 expect(section.argumentList.arguments, hasLength(1)); | 4068 expect(section.argumentList.arguments, hasLength(1)); |
| 4071 } | 4069 } |
| 4072 | 4070 |
| 4073 void test_parseCascadeSection_p() { | 4071 void test_parseCascadeSection_p() { |
| 4074 PropertyAccess section = ParserTestCase.parse4("parseCascadeSection", "..a",
[]); | 4072 PropertyAccess section = ParserTestCase.parse4("parseCascadeSection", "..a")
; |
| 4075 expect(section.target, isNull); | 4073 expect(section.target, isNull); |
| 4076 expect(section.operator, isNotNull); | 4074 expect(section.operator, isNotNull); |
| 4077 expect(section.propertyName, isNotNull); | 4075 expect(section.propertyName, isNotNull); |
| 4078 } | 4076 } |
| 4079 | 4077 |
| 4080 void test_parseCascadeSection_p_assign() { | 4078 void test_parseCascadeSection_p_assign() { |
| 4081 AssignmentExpression section = ParserTestCase.parse4("parseCascadeSection",
"..a = 3", []); | 4079 AssignmentExpression section = ParserTestCase.parse4("parseCascadeSection",
"..a = 3"); |
| 4082 expect(section.leftHandSide, isNotNull); | 4080 expect(section.leftHandSide, isNotNull); |
| 4083 expect(section.operator, isNotNull); | 4081 expect(section.operator, isNotNull); |
| 4084 Expression rhs = section.rightHandSide; | 4082 Expression rhs = section.rightHandSide; |
| 4085 expect(rhs, isNotNull); | 4083 expect(rhs, isNotNull); |
| 4086 } | 4084 } |
| 4087 | 4085 |
| 4088 void test_parseCascadeSection_p_assign_withCascade() { | 4086 void test_parseCascadeSection_p_assign_withCascade() { |
| 4089 AssignmentExpression section = ParserTestCase.parse4("parseCascadeSection",
"..a = 3..m()", []); | 4087 AssignmentExpression section = ParserTestCase.parse4("parseCascadeSection",
"..a = 3..m()"); |
| 4090 expect(section.leftHandSide, isNotNull); | 4088 expect(section.leftHandSide, isNotNull); |
| 4091 expect(section.operator, isNotNull); | 4089 expect(section.operator, isNotNull); |
| 4092 Expression rhs = section.rightHandSide; | 4090 Expression rhs = section.rightHandSide; |
| 4093 EngineTestCase.assertInstanceOf((obj) => obj is IntegerLiteral, IntegerLiter
al, rhs); | 4091 EngineTestCase.assertInstanceOf((obj) => obj is IntegerLiteral, IntegerLiter
al, rhs); |
| 4094 } | 4092 } |
| 4095 | 4093 |
| 4096 void test_parseCascadeSection_p_builtIn() { | 4094 void test_parseCascadeSection_p_builtIn() { |
| 4097 PropertyAccess section = ParserTestCase.parse4("parseCascadeSection", "..as"
, []); | 4095 PropertyAccess section = ParserTestCase.parse4("parseCascadeSection", "..as"
); |
| 4098 expect(section.target, isNull); | 4096 expect(section.target, isNull); |
| 4099 expect(section.operator, isNotNull); | 4097 expect(section.operator, isNotNull); |
| 4100 expect(section.propertyName, isNotNull); | 4098 expect(section.propertyName, isNotNull); |
| 4101 } | 4099 } |
| 4102 | 4100 |
| 4103 void test_parseCascadeSection_pa() { | 4101 void test_parseCascadeSection_pa() { |
| 4104 MethodInvocation section = ParserTestCase.parse4("parseCascadeSection", "..a
(b)", []); | 4102 MethodInvocation section = ParserTestCase.parse4("parseCascadeSection", "..a
(b)"); |
| 4105 expect(section.target, isNull); | 4103 expect(section.target, isNull); |
| 4106 expect(section.period, isNotNull); | 4104 expect(section.period, isNotNull); |
| 4107 expect(section.methodName, isNotNull); | 4105 expect(section.methodName, isNotNull); |
| 4108 expect(section.argumentList, isNotNull); | 4106 expect(section.argumentList, isNotNull); |
| 4109 expect(section.argumentList.arguments, hasLength(1)); | 4107 expect(section.argumentList.arguments, hasLength(1)); |
| 4110 } | 4108 } |
| 4111 | 4109 |
| 4112 void test_parseCascadeSection_paa() { | 4110 void test_parseCascadeSection_paa() { |
| 4113 FunctionExpressionInvocation section = ParserTestCase.parse4("parseCascadeSe
ction", "..a(b)(c)", []); | 4111 FunctionExpressionInvocation section = ParserTestCase.parse4("parseCascadeSe
ction", "..a(b)(c)"); |
| 4114 EngineTestCase.assertInstanceOf((obj) => obj is MethodInvocation, MethodInvo
cation, section.function); | 4112 EngineTestCase.assertInstanceOf((obj) => obj is MethodInvocation, MethodInvo
cation, section.function); |
| 4115 expect(section.argumentList, isNotNull); | 4113 expect(section.argumentList, isNotNull); |
| 4116 expect(section.argumentList.arguments, hasLength(1)); | 4114 expect(section.argumentList.arguments, hasLength(1)); |
| 4117 } | 4115 } |
| 4118 | 4116 |
| 4119 void test_parseCascadeSection_paapaa() { | 4117 void test_parseCascadeSection_paapaa() { |
| 4120 FunctionExpressionInvocation section = ParserTestCase.parse4("parseCascadeSe
ction", "..a(b)(c).d(e)(f)", []); | 4118 FunctionExpressionInvocation section = ParserTestCase.parse4("parseCascadeSe
ction", "..a(b)(c).d(e)(f)"); |
| 4121 EngineTestCase.assertInstanceOf((obj) => obj is MethodInvocation, MethodInvo
cation, section.function); | 4119 EngineTestCase.assertInstanceOf((obj) => obj is MethodInvocation, MethodInvo
cation, section.function); |
| 4122 expect(section.argumentList, isNotNull); | 4120 expect(section.argumentList, isNotNull); |
| 4123 expect(section.argumentList.arguments, hasLength(1)); | 4121 expect(section.argumentList.arguments, hasLength(1)); |
| 4124 } | 4122 } |
| 4125 | 4123 |
| 4126 void test_parseCascadeSection_pap() { | 4124 void test_parseCascadeSection_pap() { |
| 4127 PropertyAccess section = ParserTestCase.parse4("parseCascadeSection", "..a(b
).c", []); | 4125 PropertyAccess section = ParserTestCase.parse4("parseCascadeSection", "..a(b
).c"); |
| 4128 expect(section.target, isNotNull); | 4126 expect(section.target, isNotNull); |
| 4129 expect(section.operator, isNotNull); | 4127 expect(section.operator, isNotNull); |
| 4130 expect(section.propertyName, isNotNull); | 4128 expect(section.propertyName, isNotNull); |
| 4131 } | 4129 } |
| 4132 | 4130 |
| 4133 void test_parseClassDeclaration_abstract() { | 4131 void test_parseClassDeclaration_abstract() { |
| 4134 ClassDeclaration declaration = ParserTestCase.parse("parseClassDeclaration",
<Object> [ | 4132 ClassDeclaration declaration = ParserTestCase.parse("parseClassDeclaration",
<Object> [ |
| 4135 emptyCommentAndMetadata(), | 4133 emptyCommentAndMetadata(), |
| 4136 TokenFactory.tokenFromKeyword(Keyword.ABSTRACT)], "class A {}"); | 4134 TokenFactory.tokenFromKeyword(Keyword.ABSTRACT)], "class A {}"); |
| 4137 expect(declaration.documentationComment, isNull); | 4135 expect(declaration.documentationComment, isNull); |
| (...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4647 expect(classTypeAlias.name.name, "A"); | 4645 expect(classTypeAlias.name.name, "A"); |
| 4648 expect(classTypeAlias.equals, isNotNull); | 4646 expect(classTypeAlias.equals, isNotNull); |
| 4649 expect(classTypeAlias.abstractKeyword, isNull); | 4647 expect(classTypeAlias.abstractKeyword, isNull); |
| 4650 expect(classTypeAlias.superclass.name.name, isNotNull, reason: "B"); | 4648 expect(classTypeAlias.superclass.name.name, isNotNull, reason: "B"); |
| 4651 expect(classTypeAlias.withClause, isNotNull); | 4649 expect(classTypeAlias.withClause, isNotNull); |
| 4652 expect(classTypeAlias.implementsClause, isNotNull); | 4650 expect(classTypeAlias.implementsClause, isNotNull); |
| 4653 expect(classTypeAlias.semicolon, isNotNull); | 4651 expect(classTypeAlias.semicolon, isNotNull); |
| 4654 } | 4652 } |
| 4655 | 4653 |
| 4656 void test_parseCombinators_h() { | 4654 void test_parseCombinators_h() { |
| 4657 List<Combinator> combinators = ParserTestCase.parse4("parseCombinators", "hi
de a;", []); | 4655 List<Combinator> combinators = ParserTestCase.parse4("parseCombinators", "hi
de a;"); |
| 4658 expect(combinators, hasLength(1)); | 4656 expect(combinators, hasLength(1)); |
| 4659 HideCombinator combinator = combinators[0] as HideCombinator; | 4657 HideCombinator combinator = combinators[0] as HideCombinator; |
| 4660 expect(combinator, isNotNull); | 4658 expect(combinator, isNotNull); |
| 4661 expect(combinator.keyword, isNotNull); | 4659 expect(combinator.keyword, isNotNull); |
| 4662 expect(combinator.hiddenNames, hasLength(1)); | 4660 expect(combinator.hiddenNames, hasLength(1)); |
| 4663 } | 4661 } |
| 4664 | 4662 |
| 4665 void test_parseCombinators_hs() { | 4663 void test_parseCombinators_hs() { |
| 4666 List<Combinator> combinators = ParserTestCase.parse4("parseCombinators", "hi
de a show b;", []); | 4664 List<Combinator> combinators = ParserTestCase.parse4("parseCombinators", "hi
de a show b;"); |
| 4667 expect(combinators, hasLength(2)); | 4665 expect(combinators, hasLength(2)); |
| 4668 HideCombinator hideCombinator = combinators[0] as HideCombinator; | 4666 HideCombinator hideCombinator = combinators[0] as HideCombinator; |
| 4669 expect(hideCombinator, isNotNull); | 4667 expect(hideCombinator, isNotNull); |
| 4670 expect(hideCombinator.keyword, isNotNull); | 4668 expect(hideCombinator.keyword, isNotNull); |
| 4671 expect(hideCombinator.hiddenNames, hasLength(1)); | 4669 expect(hideCombinator.hiddenNames, hasLength(1)); |
| 4672 ShowCombinator showCombinator = combinators[1] as ShowCombinator; | 4670 ShowCombinator showCombinator = combinators[1] as ShowCombinator; |
| 4673 expect(showCombinator, isNotNull); | 4671 expect(showCombinator, isNotNull); |
| 4674 expect(showCombinator.keyword, isNotNull); | 4672 expect(showCombinator.keyword, isNotNull); |
| 4675 expect(showCombinator.shownNames, hasLength(1)); | 4673 expect(showCombinator.shownNames, hasLength(1)); |
| 4676 } | 4674 } |
| 4677 | 4675 |
| 4678 void test_parseCombinators_hshs() { | 4676 void test_parseCombinators_hshs() { |
| 4679 List<Combinator> combinators = ParserTestCase.parse4("parseCombinators", "hi
de a show b hide c show d;", []); | 4677 List<Combinator> combinators = ParserTestCase.parse4("parseCombinators", "hi
de a show b hide c show d;"); |
| 4680 expect(combinators, hasLength(4)); | 4678 expect(combinators, hasLength(4)); |
| 4681 } | 4679 } |
| 4682 | 4680 |
| 4683 void test_parseCombinators_s() { | 4681 void test_parseCombinators_s() { |
| 4684 List<Combinator> combinators = ParserTestCase.parse4("parseCombinators", "sh
ow a;", []); | 4682 List<Combinator> combinators = ParserTestCase.parse4("parseCombinators", "sh
ow a;"); |
| 4685 expect(combinators, hasLength(1)); | 4683 expect(combinators, hasLength(1)); |
| 4686 ShowCombinator combinator = combinators[0] as ShowCombinator; | 4684 ShowCombinator combinator = combinators[0] as ShowCombinator; |
| 4687 expect(combinator, isNotNull); | 4685 expect(combinator, isNotNull); |
| 4688 expect(combinator.keyword, isNotNull); | 4686 expect(combinator.keyword, isNotNull); |
| 4689 expect(combinator.shownNames, hasLength(1)); | 4687 expect(combinator.shownNames, hasLength(1)); |
| 4690 } | 4688 } |
| 4691 | 4689 |
| 4692 void test_parseCommentAndMetadata_c() { | 4690 void test_parseCommentAndMetadata_c() { |
| 4693 CommentAndMetadata commentAndMetadata = ParserTestCase.parse4("parseCommentA
ndMetadata", "/** 1 */ void", []); | 4691 CommentAndMetadata commentAndMetadata = ParserTestCase.parse4("parseCommentA
ndMetadata", "/** 1 */ void"); |
| 4694 expect(commentAndMetadata.comment, isNotNull); | 4692 expect(commentAndMetadata.comment, isNotNull); |
| 4695 expect(commentAndMetadata.metadata, hasLength(0)); | 4693 expect(commentAndMetadata.metadata, hasLength(0)); |
| 4696 } | 4694 } |
| 4697 | 4695 |
| 4698 void test_parseCommentAndMetadata_cmc() { | 4696 void test_parseCommentAndMetadata_cmc() { |
| 4699 CommentAndMetadata commentAndMetadata = ParserTestCase.parse4("parseCommentA
ndMetadata", "/** 1 */ @A /** 2 */ void", []); | 4697 CommentAndMetadata commentAndMetadata = ParserTestCase.parse4("parseCommentA
ndMetadata", "/** 1 */ @A /** 2 */ void"); |
| 4700 expect(commentAndMetadata.comment, isNotNull); | 4698 expect(commentAndMetadata.comment, isNotNull); |
| 4701 expect(commentAndMetadata.metadata, hasLength(1)); | 4699 expect(commentAndMetadata.metadata, hasLength(1)); |
| 4702 } | 4700 } |
| 4703 | 4701 |
| 4704 void test_parseCommentAndMetadata_cmcm() { | 4702 void test_parseCommentAndMetadata_cmcm() { |
| 4705 CommentAndMetadata commentAndMetadata = ParserTestCase.parse4("parseCommentA
ndMetadata", "/** 1 */ @A /** 2 */ @B void", []); | 4703 CommentAndMetadata commentAndMetadata = ParserTestCase.parse4("parseCommentA
ndMetadata", "/** 1 */ @A /** 2 */ @B void"); |
| 4706 expect(commentAndMetadata.comment, isNotNull); | 4704 expect(commentAndMetadata.comment, isNotNull); |
| 4707 expect(commentAndMetadata.metadata, hasLength(2)); | 4705 expect(commentAndMetadata.metadata, hasLength(2)); |
| 4708 } | 4706 } |
| 4709 | 4707 |
| 4710 void test_parseCommentAndMetadata_cmm() { | 4708 void test_parseCommentAndMetadata_cmm() { |
| 4711 CommentAndMetadata commentAndMetadata = ParserTestCase.parse4("parseCommentA
ndMetadata", "/** 1 */ @A @B void", []); | 4709 CommentAndMetadata commentAndMetadata = ParserTestCase.parse4("parseCommentA
ndMetadata", "/** 1 */ @A @B void"); |
| 4712 expect(commentAndMetadata.comment, isNotNull); | 4710 expect(commentAndMetadata.comment, isNotNull); |
| 4713 expect(commentAndMetadata.metadata, hasLength(2)); | 4711 expect(commentAndMetadata.metadata, hasLength(2)); |
| 4714 } | 4712 } |
| 4715 | 4713 |
| 4716 void test_parseCommentAndMetadata_m() { | 4714 void test_parseCommentAndMetadata_m() { |
| 4717 CommentAndMetadata commentAndMetadata = ParserTestCase.parse4("parseCommentA
ndMetadata", "@A void", []); | 4715 CommentAndMetadata commentAndMetadata = ParserTestCase.parse4("parseCommentA
ndMetadata", "@A void"); |
| 4718 expect(commentAndMetadata.comment, isNull); | 4716 expect(commentAndMetadata.comment, isNull); |
| 4719 expect(commentAndMetadata.metadata, hasLength(1)); | 4717 expect(commentAndMetadata.metadata, hasLength(1)); |
| 4720 } | 4718 } |
| 4721 | 4719 |
| 4722 void test_parseCommentAndMetadata_mcm() { | 4720 void test_parseCommentAndMetadata_mcm() { |
| 4723 CommentAndMetadata commentAndMetadata = ParserTestCase.parse4("parseCommentA
ndMetadata", "@A /** 1 */ @B void", []); | 4721 CommentAndMetadata commentAndMetadata = ParserTestCase.parse4("parseCommentA
ndMetadata", "@A /** 1 */ @B void"); |
| 4724 expect(commentAndMetadata.comment, isNotNull); | 4722 expect(commentAndMetadata.comment, isNotNull); |
| 4725 expect(commentAndMetadata.metadata, hasLength(2)); | 4723 expect(commentAndMetadata.metadata, hasLength(2)); |
| 4726 } | 4724 } |
| 4727 | 4725 |
| 4728 void test_parseCommentAndMetadata_mcmc() { | 4726 void test_parseCommentAndMetadata_mcmc() { |
| 4729 CommentAndMetadata commentAndMetadata = ParserTestCase.parse4("parseCommentA
ndMetadata", "@A /** 1 */ @B /** 2 */ void", []); | 4727 CommentAndMetadata commentAndMetadata = ParserTestCase.parse4("parseCommentA
ndMetadata", "@A /** 1 */ @B /** 2 */ void"); |
| 4730 expect(commentAndMetadata.comment, isNotNull); | 4728 expect(commentAndMetadata.comment, isNotNull); |
| 4731 expect(commentAndMetadata.metadata, hasLength(2)); | 4729 expect(commentAndMetadata.metadata, hasLength(2)); |
| 4732 } | 4730 } |
| 4733 | 4731 |
| 4734 void test_parseCommentAndMetadata_mm() { | 4732 void test_parseCommentAndMetadata_mm() { |
| 4735 CommentAndMetadata commentAndMetadata = ParserTestCase.parse4("parseCommentA
ndMetadata", "@A @B(x) void", []); | 4733 CommentAndMetadata commentAndMetadata = ParserTestCase.parse4("parseCommentA
ndMetadata", "@A @B(x) void"); |
| 4736 expect(commentAndMetadata.comment, isNull); | 4734 expect(commentAndMetadata.comment, isNull); |
| 4737 expect(commentAndMetadata.metadata, hasLength(2)); | 4735 expect(commentAndMetadata.metadata, hasLength(2)); |
| 4738 } | 4736 } |
| 4739 | 4737 |
| 4740 void test_parseCommentAndMetadata_none() { | 4738 void test_parseCommentAndMetadata_none() { |
| 4741 CommentAndMetadata commentAndMetadata = ParserTestCase.parse4("parseCommentA
ndMetadata", "void", []); | 4739 CommentAndMetadata commentAndMetadata = ParserTestCase.parse4("parseCommentA
ndMetadata", "void"); |
| 4742 expect(commentAndMetadata.comment, isNull); | 4740 expect(commentAndMetadata.comment, isNull); |
| 4743 expect(commentAndMetadata.metadata, hasLength(0)); | 4741 expect(commentAndMetadata.metadata, hasLength(0)); |
| 4744 } | 4742 } |
| 4745 | 4743 |
| 4746 void test_parseCommentAndMetadata_singleLine() { | 4744 void test_parseCommentAndMetadata_singleLine() { |
| 4747 CommentAndMetadata commentAndMetadata = ParserTestCase.parse4("parseCommentA
ndMetadata", r''' | 4745 CommentAndMetadata commentAndMetadata = ParserTestCase.parse4("parseCommentA
ndMetadata", r''' |
| 4748 /// 1 | 4746 /// 1 |
| 4749 /// 2 | 4747 /// 2 |
| 4750 void''', []); | 4748 void'''); |
| 4751 expect(commentAndMetadata.comment, isNotNull); | 4749 expect(commentAndMetadata.comment, isNotNull); |
| 4752 expect(commentAndMetadata.metadata, hasLength(0)); | 4750 expect(commentAndMetadata.metadata, hasLength(0)); |
| 4753 } | 4751 } |
| 4754 | 4752 |
| 4755 void test_parseCommentReference_new_prefixed() { | 4753 void test_parseCommentReference_new_prefixed() { |
| 4756 CommentReference reference = ParserTestCase.parse("parseCommentReference", <
Object> ["new a.b", 7], ""); | 4754 CommentReference reference = ParserTestCase.parse("parseCommentReference", <
Object> ["new a.b", 7], ""); |
| 4757 PrefixedIdentifier prefixedIdentifier = EngineTestCase.assertInstanceOf((obj
) => obj is PrefixedIdentifier, PrefixedIdentifier, reference.identifier); | 4755 PrefixedIdentifier prefixedIdentifier = EngineTestCase.assertInstanceOf((obj
) => obj is PrefixedIdentifier, PrefixedIdentifier, reference.identifier); |
| 4758 SimpleIdentifier prefix = prefixedIdentifier.prefix; | 4756 SimpleIdentifier prefix = prefixedIdentifier.prefix; |
| 4759 expect(prefix.token, isNotNull); | 4757 expect(prefix.token, isNotNull); |
| 4760 expect(prefix.name, "a"); | 4758 expect(prefix.name, "a"); |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4906 List<Token> tokens = <Token> [new StringToken(TokenType.MULTI_LINE_COMMENT,
"/** [a][c] [b] zzz */", 3)]; | 4904 List<Token> tokens = <Token> [new StringToken(TokenType.MULTI_LINE_COMMENT,
"/** [a][c] [b] zzz */", 3)]; |
| 4907 List<CommentReference> references = ParserTestCase.parse("parseCommentRefere
nces", <Object> [tokens], ""); | 4905 List<CommentReference> references = ParserTestCase.parse("parseCommentRefere
nces", <Object> [tokens], ""); |
| 4908 expect(references, hasLength(1)); | 4906 expect(references, hasLength(1)); |
| 4909 CommentReference reference = references[0]; | 4907 CommentReference reference = references[0]; |
| 4910 expect(reference, isNotNull); | 4908 expect(reference, isNotNull); |
| 4911 expect(reference.identifier, isNotNull); | 4909 expect(reference.identifier, isNotNull); |
| 4912 expect(reference.offset, 15); | 4910 expect(reference.offset, 15); |
| 4913 } | 4911 } |
| 4914 | 4912 |
| 4915 void test_parseCompilationUnit_abstractAsPrefix_parameterized() { | 4913 void test_parseCompilationUnit_abstractAsPrefix_parameterized() { |
| 4916 CompilationUnit unit = ParserTestCase.parse4("parseCompilationUnit", "abstra
ct<dynamic> _abstract = new abstract.A();", []); | 4914 CompilationUnit unit = ParserTestCase.parse4("parseCompilationUnit", "abstra
ct<dynamic> _abstract = new abstract.A();"); |
| 4917 expect(unit.scriptTag, isNull); | 4915 expect(unit.scriptTag, isNull); |
| 4918 expect(unit.directives, hasLength(0)); | 4916 expect(unit.directives, hasLength(0)); |
| 4919 expect(unit.declarations, hasLength(1)); | 4917 expect(unit.declarations, hasLength(1)); |
| 4920 } | 4918 } |
| 4921 | 4919 |
| 4922 void test_parseCompilationUnit_builtIn_asFunctionName() { | 4920 void test_parseCompilationUnit_builtIn_asFunctionName() { |
| 4923 ParserTestCase.parse4("parseCompilationUnit", "abstract(x) => 0;", []); | 4921 ParserTestCase.parse4("parseCompilationUnit", "abstract(x) => 0;"); |
| 4924 ParserTestCase.parse4("parseCompilationUnit", "as(x) => 0;", []); | 4922 ParserTestCase.parse4("parseCompilationUnit", "as(x) => 0;"); |
| 4925 ParserTestCase.parse4("parseCompilationUnit", "dynamic(x) => 0;", []); | 4923 ParserTestCase.parse4("parseCompilationUnit", "dynamic(x) => 0;"); |
| 4926 ParserTestCase.parse4("parseCompilationUnit", "export(x) => 0;", []); | 4924 ParserTestCase.parse4("parseCompilationUnit", "export(x) => 0;"); |
| 4927 ParserTestCase.parse4("parseCompilationUnit", "external(x) => 0;", []); | 4925 ParserTestCase.parse4("parseCompilationUnit", "external(x) => 0;"); |
| 4928 ParserTestCase.parse4("parseCompilationUnit", "factory(x) => 0;", []); | 4926 ParserTestCase.parse4("parseCompilationUnit", "factory(x) => 0;"); |
| 4929 ParserTestCase.parse4("parseCompilationUnit", "get(x) => 0;", []); | 4927 ParserTestCase.parse4("parseCompilationUnit", "get(x) => 0;"); |
| 4930 ParserTestCase.parse4("parseCompilationUnit", "implements(x) => 0;", []); | 4928 ParserTestCase.parse4("parseCompilationUnit", "implements(x) => 0;"); |
| 4931 ParserTestCase.parse4("parseCompilationUnit", "import(x) => 0;", []); | 4929 ParserTestCase.parse4("parseCompilationUnit", "import(x) => 0;"); |
| 4932 ParserTestCase.parse4("parseCompilationUnit", "library(x) => 0;", []); | 4930 ParserTestCase.parse4("parseCompilationUnit", "library(x) => 0;"); |
| 4933 ParserTestCase.parse4("parseCompilationUnit", "operator(x) => 0;", []); | 4931 ParserTestCase.parse4("parseCompilationUnit", "operator(x) => 0;"); |
| 4934 ParserTestCase.parse4("parseCompilationUnit", "part(x) => 0;", []); | 4932 ParserTestCase.parse4("parseCompilationUnit", "part(x) => 0;"); |
| 4935 ParserTestCase.parse4("parseCompilationUnit", "set(x) => 0;", []); | 4933 ParserTestCase.parse4("parseCompilationUnit", "set(x) => 0;"); |
| 4936 ParserTestCase.parse4("parseCompilationUnit", "static(x) => 0;", []); | 4934 ParserTestCase.parse4("parseCompilationUnit", "static(x) => 0;"); |
| 4937 ParserTestCase.parse4("parseCompilationUnit", "typedef(x) => 0;", []); | 4935 ParserTestCase.parse4("parseCompilationUnit", "typedef(x) => 0;"); |
| 4938 } | 4936 } |
| 4939 | 4937 |
| 4940 void test_parseCompilationUnit_directives_multiple() { | 4938 void test_parseCompilationUnit_directives_multiple() { |
| 4941 CompilationUnit unit = ParserTestCase.parse4("parseCompilationUnit", "librar
y l;\npart 'a.dart';", []); | 4939 CompilationUnit unit = ParserTestCase.parse4("parseCompilationUnit", "librar
y l;\npart 'a.dart';"); |
| 4942 expect(unit.scriptTag, isNull); | 4940 expect(unit.scriptTag, isNull); |
| 4943 expect(unit.directives, hasLength(2)); | 4941 expect(unit.directives, hasLength(2)); |
| 4944 expect(unit.declarations, hasLength(0)); | 4942 expect(unit.declarations, hasLength(0)); |
| 4945 } | 4943 } |
| 4946 | 4944 |
| 4947 void test_parseCompilationUnit_directives_single() { | 4945 void test_parseCompilationUnit_directives_single() { |
| 4948 CompilationUnit unit = ParserTestCase.parse4("parseCompilationUnit", "librar
y l;", []); | 4946 CompilationUnit unit = ParserTestCase.parse4("parseCompilationUnit", "librar
y l;"); |
| 4949 expect(unit.scriptTag, isNull); | 4947 expect(unit.scriptTag, isNull); |
| 4950 expect(unit.directives, hasLength(1)); | 4948 expect(unit.directives, hasLength(1)); |
| 4951 expect(unit.declarations, hasLength(0)); | 4949 expect(unit.declarations, hasLength(0)); |
| 4952 } | 4950 } |
| 4953 | 4951 |
| 4954 void test_parseCompilationUnit_empty() { | 4952 void test_parseCompilationUnit_empty() { |
| 4955 CompilationUnit unit = ParserTestCase.parse4("parseCompilationUnit", "", [])
; | 4953 CompilationUnit unit = ParserTestCase.parse4("parseCompilationUnit", ""); |
| 4956 expect(unit.scriptTag, isNull); | 4954 expect(unit.scriptTag, isNull); |
| 4957 expect(unit.directives, hasLength(0)); | 4955 expect(unit.directives, hasLength(0)); |
| 4958 expect(unit.declarations, hasLength(0)); | 4956 expect(unit.declarations, hasLength(0)); |
| 4959 } | 4957 } |
| 4960 | 4958 |
| 4961 void test_parseCompilationUnit_exportAsPrefix() { | 4959 void test_parseCompilationUnit_exportAsPrefix() { |
| 4962 CompilationUnit unit = ParserTestCase.parse4("parseCompilationUnit", "export
.A _export = new export.A();", []); | 4960 CompilationUnit unit = ParserTestCase.parse4("parseCompilationUnit", "export
.A _export = new export.A();"); |
| 4963 expect(unit.scriptTag, isNull); | 4961 expect(unit.scriptTag, isNull); |
| 4964 expect(unit.directives, hasLength(0)); | 4962 expect(unit.directives, hasLength(0)); |
| 4965 expect(unit.declarations, hasLength(1)); | 4963 expect(unit.declarations, hasLength(1)); |
| 4966 } | 4964 } |
| 4967 | 4965 |
| 4968 void test_parseCompilationUnit_exportAsPrefix_parameterized() { | 4966 void test_parseCompilationUnit_exportAsPrefix_parameterized() { |
| 4969 CompilationUnit unit = ParserTestCase.parse4("parseCompilationUnit", "export
<dynamic> _export = new export.A();", []); | 4967 CompilationUnit unit = ParserTestCase.parse4("parseCompilationUnit", "export
<dynamic> _export = new export.A();"); |
| 4970 expect(unit.scriptTag, isNull); | 4968 expect(unit.scriptTag, isNull); |
| 4971 expect(unit.directives, hasLength(0)); | 4969 expect(unit.directives, hasLength(0)); |
| 4972 expect(unit.declarations, hasLength(1)); | 4970 expect(unit.declarations, hasLength(1)); |
| 4973 } | 4971 } |
| 4974 | 4972 |
| 4975 void test_parseCompilationUnit_operatorAsPrefix_parameterized() { | 4973 void test_parseCompilationUnit_operatorAsPrefix_parameterized() { |
| 4976 CompilationUnit unit = ParserTestCase.parse4("parseCompilationUnit", "operat
or<dynamic> _operator = new operator.A();", []); | 4974 CompilationUnit unit = ParserTestCase.parse4("parseCompilationUnit", "operat
or<dynamic> _operator = new operator.A();"); |
| 4977 expect(unit.scriptTag, isNull); | 4975 expect(unit.scriptTag, isNull); |
| 4978 expect(unit.directives, hasLength(0)); | 4976 expect(unit.directives, hasLength(0)); |
| 4979 expect(unit.declarations, hasLength(1)); | 4977 expect(unit.declarations, hasLength(1)); |
| 4980 } | 4978 } |
| 4981 | 4979 |
| 4982 void test_parseCompilationUnit_script() { | 4980 void test_parseCompilationUnit_script() { |
| 4983 CompilationUnit unit = ParserTestCase.parse4("parseCompilationUnit", "#! /bi
n/dart", []); | 4981 CompilationUnit unit = ParserTestCase.parse4("parseCompilationUnit", "#! /bi
n/dart"); |
| 4984 expect(unit.scriptTag, isNotNull); | 4982 expect(unit.scriptTag, isNotNull); |
| 4985 expect(unit.directives, hasLength(0)); | 4983 expect(unit.directives, hasLength(0)); |
| 4986 expect(unit.declarations, hasLength(0)); | 4984 expect(unit.declarations, hasLength(0)); |
| 4987 } | 4985 } |
| 4988 | 4986 |
| 4989 void test_parseCompilationUnit_skipFunctionBody_withInterpolation() { | 4987 void test_parseCompilationUnit_skipFunctionBody_withInterpolation() { |
| 4990 ParserTestCase.parseFunctionBodies = false; | 4988 ParserTestCase.parseFunctionBodies = false; |
| 4991 CompilationUnit unit = ParserTestCase.parse4("parseCompilationUnit", "f() {
'\${n}'; }", []); | 4989 CompilationUnit unit = ParserTestCase.parse4("parseCompilationUnit", "f() {
'\${n}'; }"); |
| 4992 expect(unit.scriptTag, isNull); | 4990 expect(unit.scriptTag, isNull); |
| 4993 expect(unit.declarations, hasLength(1)); | 4991 expect(unit.declarations, hasLength(1)); |
| 4994 } | 4992 } |
| 4995 | 4993 |
| 4996 void test_parseCompilationUnit_topLevelDeclaration() { | 4994 void test_parseCompilationUnit_topLevelDeclaration() { |
| 4997 CompilationUnit unit = ParserTestCase.parse4("parseCompilationUnit", "class
A {}", []); | 4995 CompilationUnit unit = ParserTestCase.parse4("parseCompilationUnit", "class
A {}"); |
| 4998 expect(unit.scriptTag, isNull); | 4996 expect(unit.scriptTag, isNull); |
| 4999 expect(unit.directives, hasLength(0)); | 4997 expect(unit.directives, hasLength(0)); |
| 5000 expect(unit.declarations, hasLength(1)); | 4998 expect(unit.declarations, hasLength(1)); |
| 5001 } | 4999 } |
| 5002 | 5000 |
| 5003 void test_parseCompilationUnit_typedefAsPrefix() { | 5001 void test_parseCompilationUnit_typedefAsPrefix() { |
| 5004 CompilationUnit unit = ParserTestCase.parse4("parseCompilationUnit", "typede
f.A _typedef = new typedef.A();", []); | 5002 CompilationUnit unit = ParserTestCase.parse4("parseCompilationUnit", "typede
f.A _typedef = new typedef.A();"); |
| 5005 expect(unit.scriptTag, isNull); | 5003 expect(unit.scriptTag, isNull); |
| 5006 expect(unit.directives, hasLength(0)); | 5004 expect(unit.directives, hasLength(0)); |
| 5007 expect(unit.declarations, hasLength(1)); | 5005 expect(unit.declarations, hasLength(1)); |
| 5008 } | 5006 } |
| 5009 | 5007 |
| 5010 void test_parseCompilationUnitMember_abstractAsPrefix() { | 5008 void test_parseCompilationUnitMember_abstractAsPrefix() { |
| 5011 TopLevelVariableDeclaration declaration = ParserTestCase.parse("parseCompila
tionUnitMember", <Object> [emptyCommentAndMetadata()], "abstract.A _abstract = n
ew abstract.A();"); | 5009 TopLevelVariableDeclaration declaration = ParserTestCase.parse("parseCompila
tionUnitMember", <Object> [emptyCommentAndMetadata()], "abstract.A _abstract = n
ew abstract.A();"); |
| 5012 expect(declaration.semicolon, isNotNull); | 5010 expect(declaration.semicolon, isNotNull); |
| 5013 expect(declaration.variables, isNotNull); | 5011 expect(declaration.variables, isNotNull); |
| 5014 } | 5012 } |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5191 expect(declaration.variables, isNotNull); | 5189 expect(declaration.variables, isNotNull); |
| 5192 } | 5190 } |
| 5193 | 5191 |
| 5194 void test_parseCompilationUnitMember_variableSet() { | 5192 void test_parseCompilationUnitMember_variableSet() { |
| 5195 TopLevelVariableDeclaration declaration = ParserTestCase.parse("parseCompila
tionUnitMember", <Object> [emptyCommentAndMetadata()], "String set = null;"); | 5193 TopLevelVariableDeclaration declaration = ParserTestCase.parse("parseCompila
tionUnitMember", <Object> [emptyCommentAndMetadata()], "String set = null;"); |
| 5196 expect(declaration.semicolon, isNotNull); | 5194 expect(declaration.semicolon, isNotNull); |
| 5197 expect(declaration.variables, isNotNull); | 5195 expect(declaration.variables, isNotNull); |
| 5198 } | 5196 } |
| 5199 | 5197 |
| 5200 void test_parseConditionalExpression() { | 5198 void test_parseConditionalExpression() { |
| 5201 ConditionalExpression expression = ParserTestCase.parse4("parseConditionalEx
pression", "x ? y : z", []); | 5199 ConditionalExpression expression = ParserTestCase.parse4("parseConditionalEx
pression", "x ? y : z"); |
| 5202 expect(expression.condition, isNotNull); | 5200 expect(expression.condition, isNotNull); |
| 5203 expect(expression.question, isNotNull); | 5201 expect(expression.question, isNotNull); |
| 5204 expect(expression.thenExpression, isNotNull); | 5202 expect(expression.thenExpression, isNotNull); |
| 5205 expect(expression.colon, isNotNull); | 5203 expect(expression.colon, isNotNull); |
| 5206 expect(expression.elseExpression, isNotNull); | 5204 expect(expression.elseExpression, isNotNull); |
| 5207 } | 5205 } |
| 5208 | 5206 |
| 5209 void test_parseConstExpression_instanceCreation() { | 5207 void test_parseConstExpression_instanceCreation() { |
| 5210 InstanceCreationExpression expression = ParserTestCase.parse4("parseConstExp
ression", "const A()", []); | 5208 InstanceCreationExpression expression = ParserTestCase.parse4("parseConstExp
ression", "const A()"); |
| 5211 expect(expression.keyword, isNotNull); | 5209 expect(expression.keyword, isNotNull); |
| 5212 ConstructorName name = expression.constructorName; | 5210 ConstructorName name = expression.constructorName; |
| 5213 expect(name, isNotNull); | 5211 expect(name, isNotNull); |
| 5214 expect(name.type, isNotNull); | 5212 expect(name.type, isNotNull); |
| 5215 expect(name.period, isNull); | 5213 expect(name.period, isNull); |
| 5216 expect(name.name, isNull); | 5214 expect(name.name, isNull); |
| 5217 expect(expression.argumentList, isNotNull); | 5215 expect(expression.argumentList, isNotNull); |
| 5218 } | 5216 } |
| 5219 | 5217 |
| 5220 void test_parseConstExpression_listLiteral_typed() { | 5218 void test_parseConstExpression_listLiteral_typed() { |
| 5221 ListLiteral literal = ParserTestCase.parse4("parseConstExpression", "const <
A> []", []); | 5219 ListLiteral literal = ParserTestCase.parse4("parseConstExpression", "const <
A> []"); |
| 5222 expect(literal.constKeyword, isNotNull); | 5220 expect(literal.constKeyword, isNotNull); |
| 5223 expect(literal.typeArguments, isNotNull); | 5221 expect(literal.typeArguments, isNotNull); |
| 5224 expect(literal.leftBracket, isNotNull); | 5222 expect(literal.leftBracket, isNotNull); |
| 5225 expect(literal.elements, hasLength(0)); | 5223 expect(literal.elements, hasLength(0)); |
| 5226 expect(literal.rightBracket, isNotNull); | 5224 expect(literal.rightBracket, isNotNull); |
| 5227 } | 5225 } |
| 5228 | 5226 |
| 5229 void test_parseConstExpression_listLiteral_untyped() { | 5227 void test_parseConstExpression_listLiteral_untyped() { |
| 5230 ListLiteral literal = ParserTestCase.parse4("parseConstExpression", "const [
]", []); | 5228 ListLiteral literal = ParserTestCase.parse4("parseConstExpression", "const [
]"); |
| 5231 expect(literal.constKeyword, isNotNull); | 5229 expect(literal.constKeyword, isNotNull); |
| 5232 expect(literal.typeArguments, isNull); | 5230 expect(literal.typeArguments, isNull); |
| 5233 expect(literal.leftBracket, isNotNull); | 5231 expect(literal.leftBracket, isNotNull); |
| 5234 expect(literal.elements, hasLength(0)); | 5232 expect(literal.elements, hasLength(0)); |
| 5235 expect(literal.rightBracket, isNotNull); | 5233 expect(literal.rightBracket, isNotNull); |
| 5236 } | 5234 } |
| 5237 | 5235 |
| 5238 void test_parseConstExpression_mapLiteral_typed() { | 5236 void test_parseConstExpression_mapLiteral_typed() { |
| 5239 MapLiteral literal = ParserTestCase.parse4("parseConstExpression", "const <A
, B> {}", []); | 5237 MapLiteral literal = ParserTestCase.parse4("parseConstExpression", "const <A
, B> {}"); |
| 5240 expect(literal.leftBracket, isNotNull); | 5238 expect(literal.leftBracket, isNotNull); |
| 5241 expect(literal.entries, hasLength(0)); | 5239 expect(literal.entries, hasLength(0)); |
| 5242 expect(literal.rightBracket, isNotNull); | 5240 expect(literal.rightBracket, isNotNull); |
| 5243 expect(literal.typeArguments, isNotNull); | 5241 expect(literal.typeArguments, isNotNull); |
| 5244 } | 5242 } |
| 5245 | 5243 |
| 5246 void test_parseConstExpression_mapLiteral_untyped() { | 5244 void test_parseConstExpression_mapLiteral_untyped() { |
| 5247 MapLiteral literal = ParserTestCase.parse4("parseConstExpression", "const {}
", []); | 5245 MapLiteral literal = ParserTestCase.parse4("parseConstExpression", "const {}
"); |
| 5248 expect(literal.leftBracket, isNotNull); | 5246 expect(literal.leftBracket, isNotNull); |
| 5249 expect(literal.entries, hasLength(0)); | 5247 expect(literal.entries, hasLength(0)); |
| 5250 expect(literal.rightBracket, isNotNull); | 5248 expect(literal.rightBracket, isNotNull); |
| 5251 expect(literal.typeArguments, isNull); | 5249 expect(literal.typeArguments, isNull); |
| 5252 } | 5250 } |
| 5253 | 5251 |
| 5254 void test_parseConstructor() { | 5252 void test_parseConstructor() { |
| 5255 // TODO(brianwilkerson) Implement tests for this method. | 5253 // TODO(brianwilkerson) Implement tests for this method. |
| 5256 // parse("parseConstructor", new Class[] {Parser.CommentAndMetadata.class
, | 5254 // parse("parseConstructor", new Class[] {Parser.CommentAndMetadata.class
, |
| 5257 // Token.class, Token.class, SimpleIdentifier.class, Token.class, | 5255 // Token.class, Token.class, SimpleIdentifier.class, Token.class, |
| 5258 // SimpleIdentifier.class, FormalParameterList.class}, new Object[] {
emptyCommentAndMetadata(), | 5256 // SimpleIdentifier.class, FormalParameterList.class}, new Object[] {
emptyCommentAndMetadata(), |
| 5259 // null, null, null, null, null, null}, ""); | 5257 // null, null, null, null, null, null}, ""); |
| 5260 } | 5258 } |
| 5261 | 5259 |
| 5262 void test_parseConstructor_with_pseudo_function_literal() { | 5260 void test_parseConstructor_with_pseudo_function_literal() { |
| 5263 // "(b) {}" should not be misinterpreted as a function literal even though i
t looks like one. | 5261 // "(b) {}" should not be misinterpreted as a function literal even though i
t looks like one. |
| 5264 ClassMember classMember = ParserTestCase.parse("parseClassMember", <Object>
["C"], "C() : a = (b) {}"); | 5262 ClassMember classMember = ParserTestCase.parse("parseClassMember", <Object>
["C"], "C() : a = (b) {}"); |
| 5265 EngineTestCase.assertInstanceOf((obj) => obj is ConstructorDeclaration, Cons
tructorDeclaration, classMember); | 5263 EngineTestCase.assertInstanceOf((obj) => obj is ConstructorDeclaration, Cons
tructorDeclaration, classMember); |
| 5266 ConstructorDeclaration constructor = classMember as ConstructorDeclaration; | 5264 ConstructorDeclaration constructor = classMember as ConstructorDeclaration; |
| 5267 NodeList<ConstructorInitializer> initializers = constructor.initializers; | 5265 NodeList<ConstructorInitializer> initializers = constructor.initializers; |
| 5268 expect(initializers, hasLength(1)); | 5266 expect(initializers, hasLength(1)); |
| 5269 ConstructorInitializer initializer = initializers[0]; | 5267 ConstructorInitializer initializer = initializers[0]; |
| 5270 EngineTestCase.assertInstanceOf((obj) => obj is ConstructorFieldInitializer,
ConstructorFieldInitializer, initializer); | 5268 EngineTestCase.assertInstanceOf((obj) => obj is ConstructorFieldInitializer,
ConstructorFieldInitializer, initializer); |
| 5271 EngineTestCase.assertInstanceOf((obj) => obj is ParenthesizedExpression, Par
enthesizedExpression, (initializer as ConstructorFieldInitializer).expression); | 5269 EngineTestCase.assertInstanceOf((obj) => obj is ParenthesizedExpression, Par
enthesizedExpression, (initializer as ConstructorFieldInitializer).expression); |
| 5272 EngineTestCase.assertInstanceOf((obj) => obj is BlockFunctionBody, BlockFunc
tionBody, constructor.body); | 5270 EngineTestCase.assertInstanceOf((obj) => obj is BlockFunctionBody, BlockFunc
tionBody, constructor.body); |
| 5273 } | 5271 } |
| 5274 | 5272 |
| 5275 void test_parseConstructorFieldInitializer_qualified() { | 5273 void test_parseConstructorFieldInitializer_qualified() { |
| 5276 ConstructorFieldInitializer invocation = ParserTestCase.parse4("parseConstru
ctorFieldInitializer", "this.a = b", []); | 5274 ConstructorFieldInitializer invocation = ParserTestCase.parse4("parseConstru
ctorFieldInitializer", "this.a = b"); |
| 5277 expect(invocation.equals, isNotNull); | 5275 expect(invocation.equals, isNotNull); |
| 5278 expect(invocation.expression, isNotNull); | 5276 expect(invocation.expression, isNotNull); |
| 5279 expect(invocation.fieldName, isNotNull); | 5277 expect(invocation.fieldName, isNotNull); |
| 5280 expect(invocation.keyword, isNotNull); | 5278 expect(invocation.keyword, isNotNull); |
| 5281 expect(invocation.period, isNotNull); | 5279 expect(invocation.period, isNotNull); |
| 5282 } | 5280 } |
| 5283 | 5281 |
| 5284 void test_parseConstructorFieldInitializer_unqualified() { | 5282 void test_parseConstructorFieldInitializer_unqualified() { |
| 5285 ConstructorFieldInitializer invocation = ParserTestCase.parse4("parseConstru
ctorFieldInitializer", "a = b", []); | 5283 ConstructorFieldInitializer invocation = ParserTestCase.parse4("parseConstru
ctorFieldInitializer", "a = b"); |
| 5286 expect(invocation.equals, isNotNull); | 5284 expect(invocation.equals, isNotNull); |
| 5287 expect(invocation.expression, isNotNull); | 5285 expect(invocation.expression, isNotNull); |
| 5288 expect(invocation.fieldName, isNotNull); | 5286 expect(invocation.fieldName, isNotNull); |
| 5289 expect(invocation.keyword, isNull); | 5287 expect(invocation.keyword, isNull); |
| 5290 expect(invocation.period, isNull); | 5288 expect(invocation.period, isNull); |
| 5291 } | 5289 } |
| 5292 | 5290 |
| 5293 void test_parseConstructorName_named_noPrefix() { | 5291 void test_parseConstructorName_named_noPrefix() { |
| 5294 ConstructorName name = ParserTestCase.parse4("parseConstructorName", "A.n;",
[]); | 5292 ConstructorName name = ParserTestCase.parse4("parseConstructorName", "A.n;")
; |
| 5295 expect(name.type, isNotNull); | 5293 expect(name.type, isNotNull); |
| 5296 expect(name.period, isNull); | 5294 expect(name.period, isNull); |
| 5297 expect(name.name, isNull); | 5295 expect(name.name, isNull); |
| 5298 } | 5296 } |
| 5299 | 5297 |
| 5300 void test_parseConstructorName_named_prefixed() { | 5298 void test_parseConstructorName_named_prefixed() { |
| 5301 ConstructorName name = ParserTestCase.parse4("parseConstructorName", "p.A.n;
", []); | 5299 ConstructorName name = ParserTestCase.parse4("parseConstructorName", "p.A.n;
"); |
| 5302 expect(name.type, isNotNull); | 5300 expect(name.type, isNotNull); |
| 5303 expect(name.period, isNotNull); | 5301 expect(name.period, isNotNull); |
| 5304 expect(name.name, isNotNull); | 5302 expect(name.name, isNotNull); |
| 5305 } | 5303 } |
| 5306 | 5304 |
| 5307 void test_parseConstructorName_unnamed_noPrefix() { | 5305 void test_parseConstructorName_unnamed_noPrefix() { |
| 5308 ConstructorName name = ParserTestCase.parse4("parseConstructorName", "A;", [
]); | 5306 ConstructorName name = ParserTestCase.parse4("parseConstructorName", "A;"); |
| 5309 expect(name.type, isNotNull); | 5307 expect(name.type, isNotNull); |
| 5310 expect(name.period, isNull); | 5308 expect(name.period, isNull); |
| 5311 expect(name.name, isNull); | 5309 expect(name.name, isNull); |
| 5312 } | 5310 } |
| 5313 | 5311 |
| 5314 void test_parseConstructorName_unnamed_prefixed() { | 5312 void test_parseConstructorName_unnamed_prefixed() { |
| 5315 ConstructorName name = ParserTestCase.parse4("parseConstructorName", "p.A;",
[]); | 5313 ConstructorName name = ParserTestCase.parse4("parseConstructorName", "p.A;")
; |
| 5316 expect(name.type, isNotNull); | 5314 expect(name.type, isNotNull); |
| 5317 expect(name.period, isNull); | 5315 expect(name.period, isNull); |
| 5318 expect(name.name, isNull); | 5316 expect(name.name, isNull); |
| 5319 } | 5317 } |
| 5320 | 5318 |
| 5321 void test_parseContinueStatement_label() { | 5319 void test_parseContinueStatement_label() { |
| 5322 ContinueStatement statement = ParserTestCase.parse4("parseContinueStatement"
, "continue foo;", [ParserErrorCode.CONTINUE_OUTSIDE_OF_LOOP]); | 5320 ContinueStatement statement = ParserTestCase.parse4("parseContinueStatement"
, "continue foo;", [ParserErrorCode.CONTINUE_OUTSIDE_OF_LOOP]); |
| 5323 expect(statement.keyword, isNotNull); | 5321 expect(statement.keyword, isNotNull); |
| 5324 expect(statement.label, isNotNull); | 5322 expect(statement.label, isNotNull); |
| 5325 expect(statement.semicolon, isNotNull); | 5323 expect(statement.semicolon, isNotNull); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5366 | 5364 |
| 5367 void test_parseDirective_partOf() { | 5365 void test_parseDirective_partOf() { |
| 5368 PartOfDirective directive = ParserTestCase.parse("parseDirective", <Object>
[emptyCommentAndMetadata()], "part of l;"); | 5366 PartOfDirective directive = ParserTestCase.parse("parseDirective", <Object>
[emptyCommentAndMetadata()], "part of l;"); |
| 5369 expect(directive.partToken, isNotNull); | 5367 expect(directive.partToken, isNotNull); |
| 5370 expect(directive.ofToken, isNotNull); | 5368 expect(directive.ofToken, isNotNull); |
| 5371 expect(directive.libraryName, isNotNull); | 5369 expect(directive.libraryName, isNotNull); |
| 5372 expect(directive.semicolon, isNotNull); | 5370 expect(directive.semicolon, isNotNull); |
| 5373 } | 5371 } |
| 5374 | 5372 |
| 5375 void test_parseDirectives_complete() { | 5373 void test_parseDirectives_complete() { |
| 5376 CompilationUnit unit = _parseDirectives("#! /bin/dart\nlibrary l;\nclass A {
}", []); | 5374 CompilationUnit unit = _parseDirectives("#! /bin/dart\nlibrary l;\nclass A {
}"); |
| 5377 expect(unit.scriptTag, isNotNull); | 5375 expect(unit.scriptTag, isNotNull); |
| 5378 expect(unit.directives, hasLength(1)); | 5376 expect(unit.directives, hasLength(1)); |
| 5379 } | 5377 } |
| 5380 | 5378 |
| 5381 void test_parseDirectives_empty() { | 5379 void test_parseDirectives_empty() { |
| 5382 CompilationUnit unit = _parseDirectives("", []); | 5380 CompilationUnit unit = _parseDirectives(""); |
| 5383 expect(unit.scriptTag, isNull); | 5381 expect(unit.scriptTag, isNull); |
| 5384 expect(unit.directives, hasLength(0)); | 5382 expect(unit.directives, hasLength(0)); |
| 5385 } | 5383 } |
| 5386 | 5384 |
| 5387 void test_parseDirectives_mixed() { | 5385 void test_parseDirectives_mixed() { |
| 5388 CompilationUnit unit = _parseDirectives("library l; class A {} part 'foo.dar
t';", []); | 5386 CompilationUnit unit = _parseDirectives("library l; class A {} part 'foo.dar
t';"); |
| 5389 expect(unit.scriptTag, isNull); | 5387 expect(unit.scriptTag, isNull); |
| 5390 expect(unit.directives, hasLength(1)); | 5388 expect(unit.directives, hasLength(1)); |
| 5391 } | 5389 } |
| 5392 | 5390 |
| 5393 void test_parseDirectives_multiple() { | 5391 void test_parseDirectives_multiple() { |
| 5394 CompilationUnit unit = _parseDirectives("library l;\npart 'a.dart';", []); | 5392 CompilationUnit unit = _parseDirectives("library l;\npart 'a.dart';"); |
| 5395 expect(unit.scriptTag, isNull); | 5393 expect(unit.scriptTag, isNull); |
| 5396 expect(unit.directives, hasLength(2)); | 5394 expect(unit.directives, hasLength(2)); |
| 5397 } | 5395 } |
| 5398 | 5396 |
| 5399 void test_parseDirectives_script() { | 5397 void test_parseDirectives_script() { |
| 5400 CompilationUnit unit = _parseDirectives("#! /bin/dart", []); | 5398 CompilationUnit unit = _parseDirectives("#! /bin/dart"); |
| 5401 expect(unit.scriptTag, isNotNull); | 5399 expect(unit.scriptTag, isNotNull); |
| 5402 expect(unit.directives, hasLength(0)); | 5400 expect(unit.directives, hasLength(0)); |
| 5403 } | 5401 } |
| 5404 | 5402 |
| 5405 void test_parseDirectives_single() { | 5403 void test_parseDirectives_single() { |
| 5406 CompilationUnit unit = _parseDirectives("library l;", []); | 5404 CompilationUnit unit = _parseDirectives("library l;"); |
| 5407 expect(unit.scriptTag, isNull); | 5405 expect(unit.scriptTag, isNull); |
| 5408 expect(unit.directives, hasLength(1)); | 5406 expect(unit.directives, hasLength(1)); |
| 5409 } | 5407 } |
| 5410 | 5408 |
| 5411 void test_parseDirectives_topLevelDeclaration() { | 5409 void test_parseDirectives_topLevelDeclaration() { |
| 5412 CompilationUnit unit = _parseDirectives("class A {}", []); | 5410 CompilationUnit unit = _parseDirectives("class A {}"); |
| 5413 expect(unit.scriptTag, isNull); | 5411 expect(unit.scriptTag, isNull); |
| 5414 expect(unit.directives, hasLength(0)); | 5412 expect(unit.directives, hasLength(0)); |
| 5415 } | 5413 } |
| 5416 | 5414 |
| 5417 void test_parseDocumentationComment_block() { | 5415 void test_parseDocumentationComment_block() { |
| 5418 Comment comment = ParserTestCase.parse4("parseDocumentationComment", "/** */
class", []); | 5416 Comment comment = ParserTestCase.parse4("parseDocumentationComment", "/** */
class"); |
| 5419 expect(comment.isBlock, isFalse); | 5417 expect(comment.isBlock, isFalse); |
| 5420 expect(comment.isDocumentation, isTrue); | 5418 expect(comment.isDocumentation, isTrue); |
| 5421 expect(comment.isEndOfLine, isFalse); | 5419 expect(comment.isEndOfLine, isFalse); |
| 5422 } | 5420 } |
| 5423 | 5421 |
| 5424 void test_parseDocumentationComment_block_withReference() { | 5422 void test_parseDocumentationComment_block_withReference() { |
| 5425 Comment comment = ParserTestCase.parse4("parseDocumentationComment", "/** [a
] */ class", []); | 5423 Comment comment = ParserTestCase.parse4("parseDocumentationComment", "/** [a
] */ class"); |
| 5426 expect(comment.isBlock, isFalse); | 5424 expect(comment.isBlock, isFalse); |
| 5427 expect(comment.isDocumentation, isTrue); | 5425 expect(comment.isDocumentation, isTrue); |
| 5428 expect(comment.isEndOfLine, isFalse); | 5426 expect(comment.isEndOfLine, isFalse); |
| 5429 NodeList<CommentReference> references = comment.references; | 5427 NodeList<CommentReference> references = comment.references; |
| 5430 expect(references, hasLength(1)); | 5428 expect(references, hasLength(1)); |
| 5431 CommentReference reference = references[0]; | 5429 CommentReference reference = references[0]; |
| 5432 expect(reference, isNotNull); | 5430 expect(reference, isNotNull); |
| 5433 expect(reference.offset, 5); | 5431 expect(reference.offset, 5); |
| 5434 } | 5432 } |
| 5435 | 5433 |
| 5436 void test_parseDocumentationComment_endOfLine() { | 5434 void test_parseDocumentationComment_endOfLine() { |
| 5437 Comment comment = ParserTestCase.parse4("parseDocumentationComment", "/// \n
/// \n class", []); | 5435 Comment comment = ParserTestCase.parse4("parseDocumentationComment", "/// \n
/// \n class"); |
| 5438 expect(comment.isBlock, isFalse); | 5436 expect(comment.isBlock, isFalse); |
| 5439 expect(comment.isDocumentation, isTrue); | 5437 expect(comment.isDocumentation, isTrue); |
| 5440 expect(comment.isEndOfLine, isFalse); | 5438 expect(comment.isEndOfLine, isFalse); |
| 5441 } | 5439 } |
| 5442 | 5440 |
| 5443 void test_parseDoStatement() { | 5441 void test_parseDoStatement() { |
| 5444 DoStatement statement = ParserTestCase.parse4("parseDoStatement", "do {} whi
le (x);", []); | 5442 DoStatement statement = ParserTestCase.parse4("parseDoStatement", "do {} whi
le (x);"); |
| 5445 expect(statement.doKeyword, isNotNull); | 5443 expect(statement.doKeyword, isNotNull); |
| 5446 expect(statement.body, isNotNull); | 5444 expect(statement.body, isNotNull); |
| 5447 expect(statement.whileKeyword, isNotNull); | 5445 expect(statement.whileKeyword, isNotNull); |
| 5448 expect(statement.leftParenthesis, isNotNull); | 5446 expect(statement.leftParenthesis, isNotNull); |
| 5449 expect(statement.condition, isNotNull); | 5447 expect(statement.condition, isNotNull); |
| 5450 expect(statement.rightParenthesis, isNotNull); | 5448 expect(statement.rightParenthesis, isNotNull); |
| 5451 expect(statement.semicolon, isNotNull); | 5449 expect(statement.semicolon, isNotNull); |
| 5452 } | 5450 } |
| 5453 | 5451 |
| 5454 void test_parseEmptyStatement() { | 5452 void test_parseEmptyStatement() { |
| 5455 EmptyStatement statement = ParserTestCase.parse4("parseEmptyStatement", ";",
[]); | 5453 EmptyStatement statement = ParserTestCase.parse4("parseEmptyStatement", ";")
; |
| 5456 expect(statement.semicolon, isNotNull); | 5454 expect(statement.semicolon, isNotNull); |
| 5457 } | 5455 } |
| 5458 | 5456 |
| 5459 void test_parseEnumDeclaration_one() { | 5457 void test_parseEnumDeclaration_one() { |
| 5460 EnumDeclaration declaration = ParserTestCase.parse("parseEnumDeclaration", <
Object> [emptyCommentAndMetadata()], "enum E {ONE}"); | 5458 EnumDeclaration declaration = ParserTestCase.parse("parseEnumDeclaration", <
Object> [emptyCommentAndMetadata()], "enum E {ONE}"); |
| 5461 expect(declaration.documentationComment, isNull); | 5459 expect(declaration.documentationComment, isNull); |
| 5462 expect(declaration.keyword, isNotNull); | 5460 expect(declaration.keyword, isNotNull); |
| 5463 expect(declaration.leftBracket, isNotNull); | 5461 expect(declaration.leftBracket, isNotNull); |
| 5464 expect(declaration.name, isNotNull); | 5462 expect(declaration.name, isNotNull); |
| 5465 expect(declaration.constants, hasLength(1)); | 5463 expect(declaration.constants, hasLength(1)); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 5480 EnumDeclaration declaration = ParserTestCase.parse("parseEnumDeclaration", <
Object> [emptyCommentAndMetadata()], "enum E {ONE, TWO}"); | 5478 EnumDeclaration declaration = ParserTestCase.parse("parseEnumDeclaration", <
Object> [emptyCommentAndMetadata()], "enum E {ONE, TWO}"); |
| 5481 expect(declaration.documentationComment, isNull); | 5479 expect(declaration.documentationComment, isNull); |
| 5482 expect(declaration.keyword, isNotNull); | 5480 expect(declaration.keyword, isNotNull); |
| 5483 expect(declaration.leftBracket, isNotNull); | 5481 expect(declaration.leftBracket, isNotNull); |
| 5484 expect(declaration.name, isNotNull); | 5482 expect(declaration.name, isNotNull); |
| 5485 expect(declaration.constants, hasLength(2)); | 5483 expect(declaration.constants, hasLength(2)); |
| 5486 expect(declaration.rightBracket, isNotNull); | 5484 expect(declaration.rightBracket, isNotNull); |
| 5487 } | 5485 } |
| 5488 | 5486 |
| 5489 void test_parseEqualityExpression_normal() { | 5487 void test_parseEqualityExpression_normal() { |
| 5490 BinaryExpression expression = ParserTestCase.parse4("parseEqualityExpression
", "x == y", []); | 5488 BinaryExpression expression = ParserTestCase.parse4("parseEqualityExpression
", "x == y"); |
| 5491 expect(expression.leftOperand, isNotNull); | 5489 expect(expression.leftOperand, isNotNull); |
| 5492 expect(expression.operator, isNotNull); | 5490 expect(expression.operator, isNotNull); |
| 5493 expect(expression.operator.type, TokenType.EQ_EQ); | 5491 expect(expression.operator.type, TokenType.EQ_EQ); |
| 5494 expect(expression.rightOperand, isNotNull); | 5492 expect(expression.rightOperand, isNotNull); |
| 5495 } | 5493 } |
| 5496 | 5494 |
| 5497 void test_parseEqualityExpression_super() { | 5495 void test_parseEqualityExpression_super() { |
| 5498 BinaryExpression expression = ParserTestCase.parse4("parseEqualityExpression
", "super == y", []); | 5496 BinaryExpression expression = ParserTestCase.parse4("parseEqualityExpression
", "super == y"); |
| 5499 EngineTestCase.assertInstanceOf((obj) => obj is SuperExpression, SuperExpres
sion, expression.leftOperand); | 5497 EngineTestCase.assertInstanceOf((obj) => obj is SuperExpression, SuperExpres
sion, expression.leftOperand); |
| 5500 expect(expression.operator, isNotNull); | 5498 expect(expression.operator, isNotNull); |
| 5501 expect(expression.operator.type, TokenType.EQ_EQ); | 5499 expect(expression.operator.type, TokenType.EQ_EQ); |
| 5502 expect(expression.rightOperand, isNotNull); | 5500 expect(expression.rightOperand, isNotNull); |
| 5503 } | 5501 } |
| 5504 | 5502 |
| 5505 void test_parseExportDirective_hide() { | 5503 void test_parseExportDirective_hide() { |
| 5506 ExportDirective directive = ParserTestCase.parse("parseExportDirective", <Ob
ject> [emptyCommentAndMetadata()], "export 'lib/lib.dart' hide A, B;"); | 5504 ExportDirective directive = ParserTestCase.parse("parseExportDirective", <Ob
ject> [emptyCommentAndMetadata()], "export 'lib/lib.dart' hide A, B;"); |
| 5507 expect(directive.keyword, isNotNull); | 5505 expect(directive.keyword, isNotNull); |
| 5508 expect(directive.uri, isNotNull); | 5506 expect(directive.uri, isNotNull); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 5537 void test_parseExportDirective_show_hide() { | 5535 void test_parseExportDirective_show_hide() { |
| 5538 ExportDirective directive = ParserTestCase.parse("parseExportDirective", <Ob
ject> [emptyCommentAndMetadata()], "export 'lib/lib.dart' show B hide A;"); | 5536 ExportDirective directive = ParserTestCase.parse("parseExportDirective", <Ob
ject> [emptyCommentAndMetadata()], "export 'lib/lib.dart' show B hide A;"); |
| 5539 expect(directive.keyword, isNotNull); | 5537 expect(directive.keyword, isNotNull); |
| 5540 expect(directive.uri, isNotNull); | 5538 expect(directive.uri, isNotNull); |
| 5541 expect(directive.combinators, hasLength(2)); | 5539 expect(directive.combinators, hasLength(2)); |
| 5542 expect(directive.semicolon, isNotNull); | 5540 expect(directive.semicolon, isNotNull); |
| 5543 } | 5541 } |
| 5544 | 5542 |
| 5545 void test_parseExpression_assign() { | 5543 void test_parseExpression_assign() { |
| 5546 // TODO(brianwilkerson) Implement more tests for this method. | 5544 // TODO(brianwilkerson) Implement more tests for this method. |
| 5547 AssignmentExpression expression = ParserTestCase.parse4("parseExpression", "
x = y", []); | 5545 AssignmentExpression expression = ParserTestCase.parse4("parseExpression", "
x = y"); |
| 5548 expect(expression.leftHandSide, isNotNull); | 5546 expect(expression.leftHandSide, isNotNull); |
| 5549 expect(expression.operator, isNotNull); | 5547 expect(expression.operator, isNotNull); |
| 5550 expect(expression.operator.type, TokenType.EQ); | 5548 expect(expression.operator.type, TokenType.EQ); |
| 5551 expect(expression.rightHandSide, isNotNull); | 5549 expect(expression.rightHandSide, isNotNull); |
| 5552 } | 5550 } |
| 5553 | 5551 |
| 5554 void test_parseExpression_comparison() { | 5552 void test_parseExpression_comparison() { |
| 5555 BinaryExpression expression = ParserTestCase.parse4("parseExpression", "--a.
b == c", []); | 5553 BinaryExpression expression = ParserTestCase.parse4("parseExpression", "--a.
b == c"); |
| 5556 expect(expression.leftOperand, isNotNull); | 5554 expect(expression.leftOperand, isNotNull); |
| 5557 expect(expression.operator, isNotNull); | 5555 expect(expression.operator, isNotNull); |
| 5558 expect(expression.operator.type, TokenType.EQ_EQ); | 5556 expect(expression.operator.type, TokenType.EQ_EQ); |
| 5559 expect(expression.rightOperand, isNotNull); | 5557 expect(expression.rightOperand, isNotNull); |
| 5560 } | 5558 } |
| 5561 | 5559 |
| 5562 void test_parseExpression_function_async() { | 5560 void test_parseExpression_function_async() { |
| 5563 FunctionExpression expression = ParserTestCase.parseExpression("() async {}"
, []); | 5561 FunctionExpression expression = ParserTestCase.parseExpression("() async {}"
); |
| 5564 expect(expression.body, isNotNull); | 5562 expect(expression.body, isNotNull); |
| 5565 expect(expression.body.isAsynchronous, isTrue); | 5563 expect(expression.body.isAsynchronous, isTrue); |
| 5566 expect(expression.body.isGenerator, isFalse); | 5564 expect(expression.body.isGenerator, isFalse); |
| 5567 expect(expression.parameters, isNotNull); | 5565 expect(expression.parameters, isNotNull); |
| 5568 } | 5566 } |
| 5569 | 5567 |
| 5570 void test_parseExpression_function_asyncStar() { | 5568 void test_parseExpression_function_asyncStar() { |
| 5571 FunctionExpression expression = ParserTestCase.parseExpression("() async* {}
", []); | 5569 FunctionExpression expression = ParserTestCase.parseExpression("() async* {}
"); |
| 5572 expect(expression.body, isNotNull); | 5570 expect(expression.body, isNotNull); |
| 5573 expect(expression.body.isAsynchronous, isTrue); | 5571 expect(expression.body.isAsynchronous, isTrue); |
| 5574 expect(expression.body.isGenerator, isTrue); | 5572 expect(expression.body.isGenerator, isTrue); |
| 5575 expect(expression.parameters, isNotNull); | 5573 expect(expression.parameters, isNotNull); |
| 5576 } | 5574 } |
| 5577 | 5575 |
| 5578 void test_parseExpression_function_sync() { | 5576 void test_parseExpression_function_sync() { |
| 5579 FunctionExpression expression = ParserTestCase.parseExpression("() {}", []); | 5577 FunctionExpression expression = ParserTestCase.parseExpression("() {}"); |
| 5580 expect(expression.body, isNotNull); | 5578 expect(expression.body, isNotNull); |
| 5581 expect(expression.body.isAsynchronous, isFalse); | 5579 expect(expression.body.isAsynchronous, isFalse); |
| 5582 expect(expression.body.isGenerator, isFalse); | 5580 expect(expression.body.isGenerator, isFalse); |
| 5583 expect(expression.parameters, isNotNull); | 5581 expect(expression.parameters, isNotNull); |
| 5584 } | 5582 } |
| 5585 | 5583 |
| 5586 void test_parseExpression_function_syncStar() { | 5584 void test_parseExpression_function_syncStar() { |
| 5587 FunctionExpression expression = ParserTestCase.parseExpression("() sync* {}"
, []); | 5585 FunctionExpression expression = ParserTestCase.parseExpression("() sync* {}"
); |
| 5588 expect(expression.body, isNotNull); | 5586 expect(expression.body, isNotNull); |
| 5589 expect(expression.body.isAsynchronous, isFalse); | 5587 expect(expression.body.isAsynchronous, isFalse); |
| 5590 expect(expression.body.isGenerator, isTrue); | 5588 expect(expression.body.isGenerator, isTrue); |
| 5591 expect(expression.parameters, isNotNull); | 5589 expect(expression.parameters, isNotNull); |
| 5592 } | 5590 } |
| 5593 | 5591 |
| 5594 void test_parseExpression_invokeFunctionExpression() { | 5592 void test_parseExpression_invokeFunctionExpression() { |
| 5595 FunctionExpressionInvocation invocation = ParserTestCase.parse4("parseExpres
sion", "(a) {return a + a;} (3)", []); | 5593 FunctionExpressionInvocation invocation = ParserTestCase.parse4("parseExpres
sion", "(a) {return a + a;} (3)"); |
| 5596 EngineTestCase.assertInstanceOf((obj) => obj is FunctionExpression, Function
Expression, invocation.function); | 5594 EngineTestCase.assertInstanceOf((obj) => obj is FunctionExpression, Function
Expression, invocation.function); |
| 5597 FunctionExpression expression = invocation.function as FunctionExpression; | 5595 FunctionExpression expression = invocation.function as FunctionExpression; |
| 5598 expect(expression.parameters, isNotNull); | 5596 expect(expression.parameters, isNotNull); |
| 5599 expect(expression.body, isNotNull); | 5597 expect(expression.body, isNotNull); |
| 5600 ArgumentList list = invocation.argumentList; | 5598 ArgumentList list = invocation.argumentList; |
| 5601 expect(list, isNotNull); | 5599 expect(list, isNotNull); |
| 5602 expect(list.arguments, hasLength(1)); | 5600 expect(list.arguments, hasLength(1)); |
| 5603 } | 5601 } |
| 5604 | 5602 |
| 5605 void test_parseExpression_superMethodInvocation() { | 5603 void test_parseExpression_superMethodInvocation() { |
| 5606 MethodInvocation invocation = ParserTestCase.parse4("parseExpression", "supe
r.m()", []); | 5604 MethodInvocation invocation = ParserTestCase.parse4("parseExpression", "supe
r.m()"); |
| 5607 expect(invocation.target, isNotNull); | 5605 expect(invocation.target, isNotNull); |
| 5608 expect(invocation.methodName, isNotNull); | 5606 expect(invocation.methodName, isNotNull); |
| 5609 expect(invocation.argumentList, isNotNull); | 5607 expect(invocation.argumentList, isNotNull); |
| 5610 } | 5608 } |
| 5611 | 5609 |
| 5612 void test_parseExpressionList_multiple() { | 5610 void test_parseExpressionList_multiple() { |
| 5613 List<Expression> result = ParserTestCase.parse4("parseExpressionList", "1, 2
, 3", []); | 5611 List<Expression> result = ParserTestCase.parse4("parseExpressionList", "1, 2
, 3"); |
| 5614 expect(result, hasLength(3)); | 5612 expect(result, hasLength(3)); |
| 5615 } | 5613 } |
| 5616 | 5614 |
| 5617 void test_parseExpressionList_single() { | 5615 void test_parseExpressionList_single() { |
| 5618 List<Expression> result = ParserTestCase.parse4("parseExpressionList", "1",
[]); | 5616 List<Expression> result = ParserTestCase.parse4("parseExpressionList", "1"); |
| 5619 expect(result, hasLength(1)); | 5617 expect(result, hasLength(1)); |
| 5620 } | 5618 } |
| 5621 | 5619 |
| 5622 void test_parseExpressionWithoutCascade_assign() { | 5620 void test_parseExpressionWithoutCascade_assign() { |
| 5623 // TODO(brianwilkerson) Implement more tests for this method. | 5621 // TODO(brianwilkerson) Implement more tests for this method. |
| 5624 AssignmentExpression expression = ParserTestCase.parse4("parseExpressionWith
outCascade", "x = y", []); | 5622 AssignmentExpression expression = ParserTestCase.parse4("parseExpressionWith
outCascade", "x = y"); |
| 5625 expect(expression.leftHandSide, isNotNull); | 5623 expect(expression.leftHandSide, isNotNull); |
| 5626 expect(expression.operator, isNotNull); | 5624 expect(expression.operator, isNotNull); |
| 5627 expect(expression.operator.type, TokenType.EQ); | 5625 expect(expression.operator.type, TokenType.EQ); |
| 5628 expect(expression.rightHandSide, isNotNull); | 5626 expect(expression.rightHandSide, isNotNull); |
| 5629 } | 5627 } |
| 5630 | 5628 |
| 5631 void test_parseExpressionWithoutCascade_comparison() { | 5629 void test_parseExpressionWithoutCascade_comparison() { |
| 5632 BinaryExpression expression = ParserTestCase.parse4("parseExpressionWithoutC
ascade", "--a.b == c", []); | 5630 BinaryExpression expression = ParserTestCase.parse4("parseExpressionWithoutC
ascade", "--a.b == c"); |
| 5633 expect(expression.leftOperand, isNotNull); | 5631 expect(expression.leftOperand, isNotNull); |
| 5634 expect(expression.operator, isNotNull); | 5632 expect(expression.operator, isNotNull); |
| 5635 expect(expression.operator.type, TokenType.EQ_EQ); | 5633 expect(expression.operator.type, TokenType.EQ_EQ); |
| 5636 expect(expression.rightOperand, isNotNull); | 5634 expect(expression.rightOperand, isNotNull); |
| 5637 } | 5635 } |
| 5638 | 5636 |
| 5639 void test_parseExpressionWithoutCascade_superMethodInvocation() { | 5637 void test_parseExpressionWithoutCascade_superMethodInvocation() { |
| 5640 MethodInvocation invocation = ParserTestCase.parse4("parseExpressionWithoutC
ascade", "super.m()", []); | 5638 MethodInvocation invocation = ParserTestCase.parse4("parseExpressionWithoutC
ascade", "super.m()"); |
| 5641 expect(invocation.target, isNotNull); | 5639 expect(invocation.target, isNotNull); |
| 5642 expect(invocation.methodName, isNotNull); | 5640 expect(invocation.methodName, isNotNull); |
| 5643 expect(invocation.argumentList, isNotNull); | 5641 expect(invocation.argumentList, isNotNull); |
| 5644 } | 5642 } |
| 5645 | 5643 |
| 5646 void test_parseExtendsClause() { | 5644 void test_parseExtendsClause() { |
| 5647 ExtendsClause clause = ParserTestCase.parse4("parseExtendsClause", "extends
B", []); | 5645 ExtendsClause clause = ParserTestCase.parse4("parseExtendsClause", "extends
B"); |
| 5648 expect(clause.keyword, isNotNull); | 5646 expect(clause.keyword, isNotNull); |
| 5649 expect(clause.superclass, isNotNull); | 5647 expect(clause.superclass, isNotNull); |
| 5650 EngineTestCase.assertInstanceOf((obj) => obj is TypeName, TypeName, clause.s
uperclass); | 5648 EngineTestCase.assertInstanceOf((obj) => obj is TypeName, TypeName, clause.s
uperclass); |
| 5651 } | 5649 } |
| 5652 | 5650 |
| 5653 void test_parseFinalConstVarOrType_const_noType() { | 5651 void test_parseFinalConstVarOrType_const_noType() { |
| 5654 FinalConstVarOrType result = ParserTestCase.parse("parseFinalConstVarOrType"
, <Object> [false], "const"); | 5652 FinalConstVarOrType result = ParserTestCase.parse("parseFinalConstVarOrType"
, <Object> [false], "const"); |
| 5655 Token keyword = result.keyword; | 5653 Token keyword = result.keyword; |
| 5656 expect(keyword, isNotNull); | 5654 expect(keyword, isNotNull); |
| 5657 expect(keyword.type, TokenType.KEYWORD); | 5655 expect(keyword.type, TokenType.KEYWORD); |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5845 expect(simpleParameter.identifier, isNotNull); | 5843 expect(simpleParameter.identifier, isNotNull); |
| 5846 expect(simpleParameter.keyword, isNotNull); | 5844 expect(simpleParameter.keyword, isNotNull); |
| 5847 expect(simpleParameter.type, isNull); | 5845 expect(simpleParameter.type, isNull); |
| 5848 expect(simpleParameter.kind, kind); | 5846 expect(simpleParameter.kind, kind); |
| 5849 expect(parameter.separator, isNotNull); | 5847 expect(parameter.separator, isNotNull); |
| 5850 expect(parameter.defaultValue, isNotNull); | 5848 expect(parameter.defaultValue, isNotNull); |
| 5851 expect(parameter.kind, kind); | 5849 expect(parameter.kind, kind); |
| 5852 } | 5850 } |
| 5853 | 5851 |
| 5854 void test_parseFormalParameterList_empty() { | 5852 void test_parseFormalParameterList_empty() { |
| 5855 FormalParameterList parameterList = ParserTestCase.parse4("parseFormalParame
terList", "()", []); | 5853 FormalParameterList parameterList = ParserTestCase.parse4("parseFormalParame
terList", "()"); |
| 5856 expect(parameterList.leftParenthesis, isNotNull); | 5854 expect(parameterList.leftParenthesis, isNotNull); |
| 5857 expect(parameterList.leftDelimiter, isNull); | 5855 expect(parameterList.leftDelimiter, isNull); |
| 5858 expect(parameterList.parameters, hasLength(0)); | 5856 expect(parameterList.parameters, hasLength(0)); |
| 5859 expect(parameterList.rightDelimiter, isNull); | 5857 expect(parameterList.rightDelimiter, isNull); |
| 5860 expect(parameterList.rightParenthesis, isNotNull); | 5858 expect(parameterList.rightParenthesis, isNotNull); |
| 5861 } | 5859 } |
| 5862 | 5860 |
| 5863 void test_parseFormalParameterList_named_multiple() { | 5861 void test_parseFormalParameterList_named_multiple() { |
| 5864 FormalParameterList parameterList = ParserTestCase.parse4("parseFormalParame
terList", "({A a : 1, B b, C c : 3})", []); | 5862 FormalParameterList parameterList = ParserTestCase.parse4("parseFormalParame
terList", "({A a : 1, B b, C c : 3})"); |
| 5865 expect(parameterList.leftParenthesis, isNotNull); | 5863 expect(parameterList.leftParenthesis, isNotNull); |
| 5866 expect(parameterList.leftDelimiter, isNotNull); | 5864 expect(parameterList.leftDelimiter, isNotNull); |
| 5867 expect(parameterList.parameters, hasLength(3)); | 5865 expect(parameterList.parameters, hasLength(3)); |
| 5868 expect(parameterList.rightDelimiter, isNotNull); | 5866 expect(parameterList.rightDelimiter, isNotNull); |
| 5869 expect(parameterList.rightParenthesis, isNotNull); | 5867 expect(parameterList.rightParenthesis, isNotNull); |
| 5870 } | 5868 } |
| 5871 | 5869 |
| 5872 void test_parseFormalParameterList_named_single() { | 5870 void test_parseFormalParameterList_named_single() { |
| 5873 FormalParameterList parameterList = ParserTestCase.parse4("parseFormalParame
terList", "({A a})", []); | 5871 FormalParameterList parameterList = ParserTestCase.parse4("parseFormalParame
terList", "({A a})"); |
| 5874 expect(parameterList.leftParenthesis, isNotNull); | 5872 expect(parameterList.leftParenthesis, isNotNull); |
| 5875 expect(parameterList.leftDelimiter, isNotNull); | 5873 expect(parameterList.leftDelimiter, isNotNull); |
| 5876 expect(parameterList.parameters, hasLength(1)); | 5874 expect(parameterList.parameters, hasLength(1)); |
| 5877 expect(parameterList.rightDelimiter, isNotNull); | 5875 expect(parameterList.rightDelimiter, isNotNull); |
| 5878 expect(parameterList.rightParenthesis, isNotNull); | 5876 expect(parameterList.rightParenthesis, isNotNull); |
| 5879 } | 5877 } |
| 5880 | 5878 |
| 5881 void test_parseFormalParameterList_normal_multiple() { | 5879 void test_parseFormalParameterList_normal_multiple() { |
| 5882 FormalParameterList parameterList = ParserTestCase.parse4("parseFormalParame
terList", "(A a, B b, C c)", []); | 5880 FormalParameterList parameterList = ParserTestCase.parse4("parseFormalParame
terList", "(A a, B b, C c)"); |
| 5883 expect(parameterList.leftParenthesis, isNotNull); | 5881 expect(parameterList.leftParenthesis, isNotNull); |
| 5884 expect(parameterList.leftDelimiter, isNull); | 5882 expect(parameterList.leftDelimiter, isNull); |
| 5885 expect(parameterList.parameters, hasLength(3)); | 5883 expect(parameterList.parameters, hasLength(3)); |
| 5886 expect(parameterList.rightDelimiter, isNull); | 5884 expect(parameterList.rightDelimiter, isNull); |
| 5887 expect(parameterList.rightParenthesis, isNotNull); | 5885 expect(parameterList.rightParenthesis, isNotNull); |
| 5888 } | 5886 } |
| 5889 | 5887 |
| 5890 void test_parseFormalParameterList_normal_named() { | 5888 void test_parseFormalParameterList_normal_named() { |
| 5891 FormalParameterList parameterList = ParserTestCase.parse4("parseFormalParame
terList", "(A a, {B b})", []); | 5889 FormalParameterList parameterList = ParserTestCase.parse4("parseFormalParame
terList", "(A a, {B b})"); |
| 5892 expect(parameterList.leftParenthesis, isNotNull); | 5890 expect(parameterList.leftParenthesis, isNotNull); |
| 5893 expect(parameterList.leftDelimiter, isNotNull); | 5891 expect(parameterList.leftDelimiter, isNotNull); |
| 5894 expect(parameterList.parameters, hasLength(2)); | 5892 expect(parameterList.parameters, hasLength(2)); |
| 5895 expect(parameterList.rightDelimiter, isNotNull); | 5893 expect(parameterList.rightDelimiter, isNotNull); |
| 5896 expect(parameterList.rightParenthesis, isNotNull); | 5894 expect(parameterList.rightParenthesis, isNotNull); |
| 5897 } | 5895 } |
| 5898 | 5896 |
| 5899 void test_parseFormalParameterList_normal_positional() { | 5897 void test_parseFormalParameterList_normal_positional() { |
| 5900 FormalParameterList parameterList = ParserTestCase.parse4("parseFormalParame
terList", "(A a, [B b])", []); | 5898 FormalParameterList parameterList = ParserTestCase.parse4("parseFormalParame
terList", "(A a, [B b])"); |
| 5901 expect(parameterList.leftParenthesis, isNotNull); | 5899 expect(parameterList.leftParenthesis, isNotNull); |
| 5902 expect(parameterList.leftDelimiter, isNotNull); | 5900 expect(parameterList.leftDelimiter, isNotNull); |
| 5903 expect(parameterList.parameters, hasLength(2)); | 5901 expect(parameterList.parameters, hasLength(2)); |
| 5904 expect(parameterList.rightDelimiter, isNotNull); | 5902 expect(parameterList.rightDelimiter, isNotNull); |
| 5905 expect(parameterList.rightParenthesis, isNotNull); | 5903 expect(parameterList.rightParenthesis, isNotNull); |
| 5906 } | 5904 } |
| 5907 | 5905 |
| 5908 void test_parseFormalParameterList_normal_single() { | 5906 void test_parseFormalParameterList_normal_single() { |
| 5909 FormalParameterList parameterList = ParserTestCase.parse4("parseFormalParame
terList", "(A a)", []); | 5907 FormalParameterList parameterList = ParserTestCase.parse4("parseFormalParame
terList", "(A a)"); |
| 5910 expect(parameterList.leftParenthesis, isNotNull); | 5908 expect(parameterList.leftParenthesis, isNotNull); |
| 5911 expect(parameterList.leftDelimiter, isNull); | 5909 expect(parameterList.leftDelimiter, isNull); |
| 5912 expect(parameterList.parameters, hasLength(1)); | 5910 expect(parameterList.parameters, hasLength(1)); |
| 5913 expect(parameterList.rightDelimiter, isNull); | 5911 expect(parameterList.rightDelimiter, isNull); |
| 5914 expect(parameterList.rightParenthesis, isNotNull); | 5912 expect(parameterList.rightParenthesis, isNotNull); |
| 5915 } | 5913 } |
| 5916 | 5914 |
| 5917 void test_parseFormalParameterList_positional_multiple() { | 5915 void test_parseFormalParameterList_positional_multiple() { |
| 5918 FormalParameterList parameterList = ParserTestCase.parse4("parseFormalParame
terList", "([A a = null, B b, C c = null])", []); | 5916 FormalParameterList parameterList = ParserTestCase.parse4("parseFormalParame
terList", "([A a = null, B b, C c = null])"); |
| 5919 expect(parameterList.leftParenthesis, isNotNull); | 5917 expect(parameterList.leftParenthesis, isNotNull); |
| 5920 expect(parameterList.leftDelimiter, isNotNull); | 5918 expect(parameterList.leftDelimiter, isNotNull); |
| 5921 expect(parameterList.parameters, hasLength(3)); | 5919 expect(parameterList.parameters, hasLength(3)); |
| 5922 expect(parameterList.rightDelimiter, isNotNull); | 5920 expect(parameterList.rightDelimiter, isNotNull); |
| 5923 expect(parameterList.rightParenthesis, isNotNull); | 5921 expect(parameterList.rightParenthesis, isNotNull); |
| 5924 } | 5922 } |
| 5925 | 5923 |
| 5926 void test_parseFormalParameterList_positional_single() { | 5924 void test_parseFormalParameterList_positional_single() { |
| 5927 FormalParameterList parameterList = ParserTestCase.parse4("parseFormalParame
terList", "([A a = null])", []); | 5925 FormalParameterList parameterList = ParserTestCase.parse4("parseFormalParame
terList", "([A a = null])"); |
| 5928 expect(parameterList.leftParenthesis, isNotNull); | 5926 expect(parameterList.leftParenthesis, isNotNull); |
| 5929 expect(parameterList.leftDelimiter, isNotNull); | 5927 expect(parameterList.leftDelimiter, isNotNull); |
| 5930 expect(parameterList.parameters, hasLength(1)); | 5928 expect(parameterList.parameters, hasLength(1)); |
| 5931 expect(parameterList.rightDelimiter, isNotNull); | 5929 expect(parameterList.rightDelimiter, isNotNull); |
| 5932 expect(parameterList.rightParenthesis, isNotNull); | 5930 expect(parameterList.rightParenthesis, isNotNull); |
| 5933 } | 5931 } |
| 5934 | 5932 |
| 5935 void test_parseForStatement_each_await() { | 5933 void test_parseForStatement_each_await() { |
| 5936 ForEachStatement statement = ParserTestCase.parse4("parseForStatement", "awa
it for (element in list) {}", []); | 5934 ForEachStatement statement = ParserTestCase.parse4("parseForStatement", "awa
it for (element in list) {}"); |
| 5937 expect(statement.awaitKeyword, isNotNull); | 5935 expect(statement.awaitKeyword, isNotNull); |
| 5938 expect(statement.forKeyword, isNotNull); | 5936 expect(statement.forKeyword, isNotNull); |
| 5939 expect(statement.leftParenthesis, isNotNull); | 5937 expect(statement.leftParenthesis, isNotNull); |
| 5940 expect(statement.loopVariable, isNull); | 5938 expect(statement.loopVariable, isNull); |
| 5941 expect(statement.identifier, isNotNull); | 5939 expect(statement.identifier, isNotNull); |
| 5942 expect(statement.inKeyword, isNotNull); | 5940 expect(statement.inKeyword, isNotNull); |
| 5943 expect(statement.iterable, isNotNull); | 5941 expect(statement.iterable, isNotNull); |
| 5944 expect(statement.rightParenthesis, isNotNull); | 5942 expect(statement.rightParenthesis, isNotNull); |
| 5945 expect(statement.body, isNotNull); | 5943 expect(statement.body, isNotNull); |
| 5946 } | 5944 } |
| 5947 | 5945 |
| 5948 void test_parseForStatement_each_identifier() { | 5946 void test_parseForStatement_each_identifier() { |
| 5949 ForEachStatement statement = ParserTestCase.parse4("parseForStatement", "for
(element in list) {}", []); | 5947 ForEachStatement statement = ParserTestCase.parse4("parseForStatement", "for
(element in list) {}"); |
| 5950 expect(statement.awaitKeyword, isNull); | 5948 expect(statement.awaitKeyword, isNull); |
| 5951 expect(statement.forKeyword, isNotNull); | 5949 expect(statement.forKeyword, isNotNull); |
| 5952 expect(statement.leftParenthesis, isNotNull); | 5950 expect(statement.leftParenthesis, isNotNull); |
| 5953 expect(statement.loopVariable, isNull); | 5951 expect(statement.loopVariable, isNull); |
| 5954 expect(statement.identifier, isNotNull); | 5952 expect(statement.identifier, isNotNull); |
| 5955 expect(statement.inKeyword, isNotNull); | 5953 expect(statement.inKeyword, isNotNull); |
| 5956 expect(statement.iterable, isNotNull); | 5954 expect(statement.iterable, isNotNull); |
| 5957 expect(statement.rightParenthesis, isNotNull); | 5955 expect(statement.rightParenthesis, isNotNull); |
| 5958 expect(statement.body, isNotNull); | 5956 expect(statement.body, isNotNull); |
| 5959 } | 5957 } |
| 5960 | 5958 |
| 5961 void test_parseForStatement_each_noType_metadata() { | 5959 void test_parseForStatement_each_noType_metadata() { |
| 5962 ForEachStatement statement = ParserTestCase.parse4("parseForStatement", "for
(@A var element in list) {}", []); | 5960 ForEachStatement statement = ParserTestCase.parse4("parseForStatement", "for
(@A var element in list) {}"); |
| 5963 expect(statement.awaitKeyword, isNull); | 5961 expect(statement.awaitKeyword, isNull); |
| 5964 expect(statement.forKeyword, isNotNull); | 5962 expect(statement.forKeyword, isNotNull); |
| 5965 expect(statement.leftParenthesis, isNotNull); | 5963 expect(statement.leftParenthesis, isNotNull); |
| 5966 expect(statement.loopVariable, isNotNull); | 5964 expect(statement.loopVariable, isNotNull); |
| 5967 expect(statement.loopVariable.metadata, hasLength(1)); | 5965 expect(statement.loopVariable.metadata, hasLength(1)); |
| 5968 expect(statement.identifier, isNull); | 5966 expect(statement.identifier, isNull); |
| 5969 expect(statement.inKeyword, isNotNull); | 5967 expect(statement.inKeyword, isNotNull); |
| 5970 expect(statement.iterable, isNotNull); | 5968 expect(statement.iterable, isNotNull); |
| 5971 expect(statement.rightParenthesis, isNotNull); | 5969 expect(statement.rightParenthesis, isNotNull); |
| 5972 expect(statement.body, isNotNull); | 5970 expect(statement.body, isNotNull); |
| 5973 } | 5971 } |
| 5974 | 5972 |
| 5975 void test_parseForStatement_each_type() { | 5973 void test_parseForStatement_each_type() { |
| 5976 ForEachStatement statement = ParserTestCase.parse4("parseForStatement", "for
(A element in list) {}", []); | 5974 ForEachStatement statement = ParserTestCase.parse4("parseForStatement", "for
(A element in list) {}"); |
| 5977 expect(statement.awaitKeyword, isNull); | 5975 expect(statement.awaitKeyword, isNull); |
| 5978 expect(statement.forKeyword, isNotNull); | 5976 expect(statement.forKeyword, isNotNull); |
| 5979 expect(statement.leftParenthesis, isNotNull); | 5977 expect(statement.leftParenthesis, isNotNull); |
| 5980 expect(statement.loopVariable, isNotNull); | 5978 expect(statement.loopVariable, isNotNull); |
| 5981 expect(statement.identifier, isNull); | 5979 expect(statement.identifier, isNull); |
| 5982 expect(statement.inKeyword, isNotNull); | 5980 expect(statement.inKeyword, isNotNull); |
| 5983 expect(statement.iterable, isNotNull); | 5981 expect(statement.iterable, isNotNull); |
| 5984 expect(statement.rightParenthesis, isNotNull); | 5982 expect(statement.rightParenthesis, isNotNull); |
| 5985 expect(statement.body, isNotNull); | 5983 expect(statement.body, isNotNull); |
| 5986 } | 5984 } |
| 5987 | 5985 |
| 5988 void test_parseForStatement_each_var() { | 5986 void test_parseForStatement_each_var() { |
| 5989 ForEachStatement statement = ParserTestCase.parse4("parseForStatement", "for
(var element in list) {}", []); | 5987 ForEachStatement statement = ParserTestCase.parse4("parseForStatement", "for
(var element in list) {}"); |
| 5990 expect(statement.awaitKeyword, isNull); | 5988 expect(statement.awaitKeyword, isNull); |
| 5991 expect(statement.forKeyword, isNotNull); | 5989 expect(statement.forKeyword, isNotNull); |
| 5992 expect(statement.leftParenthesis, isNotNull); | 5990 expect(statement.leftParenthesis, isNotNull); |
| 5993 expect(statement.loopVariable, isNotNull); | 5991 expect(statement.loopVariable, isNotNull); |
| 5994 expect(statement.identifier, isNull); | 5992 expect(statement.identifier, isNull); |
| 5995 expect(statement.inKeyword, isNotNull); | 5993 expect(statement.inKeyword, isNotNull); |
| 5996 expect(statement.iterable, isNotNull); | 5994 expect(statement.iterable, isNotNull); |
| 5997 expect(statement.rightParenthesis, isNotNull); | 5995 expect(statement.rightParenthesis, isNotNull); |
| 5998 expect(statement.body, isNotNull); | 5996 expect(statement.body, isNotNull); |
| 5999 } | 5997 } |
| 6000 | 5998 |
| 6001 void test_parseForStatement_loop_c() { | 5999 void test_parseForStatement_loop_c() { |
| 6002 ForStatement statement = ParserTestCase.parse4("parseForStatement", "for (;
i < count;) {}", []); | 6000 ForStatement statement = ParserTestCase.parse4("parseForStatement", "for (;
i < count;) {}"); |
| 6003 expect(statement.forKeyword, isNotNull); | 6001 expect(statement.forKeyword, isNotNull); |
| 6004 expect(statement.leftParenthesis, isNotNull); | 6002 expect(statement.leftParenthesis, isNotNull); |
| 6005 expect(statement.variables, isNull); | 6003 expect(statement.variables, isNull); |
| 6006 expect(statement.initialization, isNull); | 6004 expect(statement.initialization, isNull); |
| 6007 expect(statement.leftSeparator, isNotNull); | 6005 expect(statement.leftSeparator, isNotNull); |
| 6008 expect(statement.condition, isNotNull); | 6006 expect(statement.condition, isNotNull); |
| 6009 expect(statement.rightSeparator, isNotNull); | 6007 expect(statement.rightSeparator, isNotNull); |
| 6010 expect(statement.updaters, hasLength(0)); | 6008 expect(statement.updaters, hasLength(0)); |
| 6011 expect(statement.rightParenthesis, isNotNull); | 6009 expect(statement.rightParenthesis, isNotNull); |
| 6012 expect(statement.body, isNotNull); | 6010 expect(statement.body, isNotNull); |
| 6013 } | 6011 } |
| 6014 | 6012 |
| 6015 void test_parseForStatement_loop_cu() { | 6013 void test_parseForStatement_loop_cu() { |
| 6016 ForStatement statement = ParserTestCase.parse4("parseForStatement", "for (;
i < count; i++) {}", []); | 6014 ForStatement statement = ParserTestCase.parse4("parseForStatement", "for (;
i < count; i++) {}"); |
| 6017 expect(statement.forKeyword, isNotNull); | 6015 expect(statement.forKeyword, isNotNull); |
| 6018 expect(statement.leftParenthesis, isNotNull); | 6016 expect(statement.leftParenthesis, isNotNull); |
| 6019 expect(statement.variables, isNull); | 6017 expect(statement.variables, isNull); |
| 6020 expect(statement.initialization, isNull); | 6018 expect(statement.initialization, isNull); |
| 6021 expect(statement.leftSeparator, isNotNull); | 6019 expect(statement.leftSeparator, isNotNull); |
| 6022 expect(statement.condition, isNotNull); | 6020 expect(statement.condition, isNotNull); |
| 6023 expect(statement.rightSeparator, isNotNull); | 6021 expect(statement.rightSeparator, isNotNull); |
| 6024 expect(statement.updaters, hasLength(1)); | 6022 expect(statement.updaters, hasLength(1)); |
| 6025 expect(statement.rightParenthesis, isNotNull); | 6023 expect(statement.rightParenthesis, isNotNull); |
| 6026 expect(statement.body, isNotNull); | 6024 expect(statement.body, isNotNull); |
| 6027 } | 6025 } |
| 6028 | 6026 |
| 6029 void test_parseForStatement_loop_ecu() { | 6027 void test_parseForStatement_loop_ecu() { |
| 6030 ForStatement statement = ParserTestCase.parse4("parseForStatement", "for (i-
-; i < count; i++) {}", []); | 6028 ForStatement statement = ParserTestCase.parse4("parseForStatement", "for (i-
-; i < count; i++) {}"); |
| 6031 expect(statement.forKeyword, isNotNull); | 6029 expect(statement.forKeyword, isNotNull); |
| 6032 expect(statement.leftParenthesis, isNotNull); | 6030 expect(statement.leftParenthesis, isNotNull); |
| 6033 expect(statement.variables, isNull); | 6031 expect(statement.variables, isNull); |
| 6034 expect(statement.initialization, isNotNull); | 6032 expect(statement.initialization, isNotNull); |
| 6035 expect(statement.leftSeparator, isNotNull); | 6033 expect(statement.leftSeparator, isNotNull); |
| 6036 expect(statement.condition, isNotNull); | 6034 expect(statement.condition, isNotNull); |
| 6037 expect(statement.rightSeparator, isNotNull); | 6035 expect(statement.rightSeparator, isNotNull); |
| 6038 expect(statement.updaters, hasLength(1)); | 6036 expect(statement.updaters, hasLength(1)); |
| 6039 expect(statement.rightParenthesis, isNotNull); | 6037 expect(statement.rightParenthesis, isNotNull); |
| 6040 expect(statement.body, isNotNull); | 6038 expect(statement.body, isNotNull); |
| 6041 } | 6039 } |
| 6042 | 6040 |
| 6043 void test_parseForStatement_loop_i() { | 6041 void test_parseForStatement_loop_i() { |
| 6044 ForStatement statement = ParserTestCase.parse4("parseForStatement", "for (va
r i = 0;;) {}", []); | 6042 ForStatement statement = ParserTestCase.parse4("parseForStatement", "for (va
r i = 0;;) {}"); |
| 6045 expect(statement.forKeyword, isNotNull); | 6043 expect(statement.forKeyword, isNotNull); |
| 6046 expect(statement.leftParenthesis, isNotNull); | 6044 expect(statement.leftParenthesis, isNotNull); |
| 6047 VariableDeclarationList variables = statement.variables; | 6045 VariableDeclarationList variables = statement.variables; |
| 6048 expect(variables, isNotNull); | 6046 expect(variables, isNotNull); |
| 6049 expect(variables.metadata, hasLength(0)); | 6047 expect(variables.metadata, hasLength(0)); |
| 6050 expect(variables.variables, hasLength(1)); | 6048 expect(variables.variables, hasLength(1)); |
| 6051 expect(statement.initialization, isNull); | 6049 expect(statement.initialization, isNull); |
| 6052 expect(statement.leftSeparator, isNotNull); | 6050 expect(statement.leftSeparator, isNotNull); |
| 6053 expect(statement.condition, isNull); | 6051 expect(statement.condition, isNull); |
| 6054 expect(statement.rightSeparator, isNotNull); | 6052 expect(statement.rightSeparator, isNotNull); |
| 6055 expect(statement.updaters, hasLength(0)); | 6053 expect(statement.updaters, hasLength(0)); |
| 6056 expect(statement.rightParenthesis, isNotNull); | 6054 expect(statement.rightParenthesis, isNotNull); |
| 6057 expect(statement.body, isNotNull); | 6055 expect(statement.body, isNotNull); |
| 6058 } | 6056 } |
| 6059 | 6057 |
| 6060 void test_parseForStatement_loop_i_withMetadata() { | 6058 void test_parseForStatement_loop_i_withMetadata() { |
| 6061 ForStatement statement = ParserTestCase.parse4("parseForStatement", "for (@A
var i = 0;;) {}", []); | 6059 ForStatement statement = ParserTestCase.parse4("parseForStatement", "for (@A
var i = 0;;) {}"); |
| 6062 expect(statement.forKeyword, isNotNull); | 6060 expect(statement.forKeyword, isNotNull); |
| 6063 expect(statement.leftParenthesis, isNotNull); | 6061 expect(statement.leftParenthesis, isNotNull); |
| 6064 VariableDeclarationList variables = statement.variables; | 6062 VariableDeclarationList variables = statement.variables; |
| 6065 expect(variables, isNotNull); | 6063 expect(variables, isNotNull); |
| 6066 expect(variables.metadata, hasLength(1)); | 6064 expect(variables.metadata, hasLength(1)); |
| 6067 expect(variables.variables, hasLength(1)); | 6065 expect(variables.variables, hasLength(1)); |
| 6068 expect(statement.initialization, isNull); | 6066 expect(statement.initialization, isNull); |
| 6069 expect(statement.leftSeparator, isNotNull); | 6067 expect(statement.leftSeparator, isNotNull); |
| 6070 expect(statement.condition, isNull); | 6068 expect(statement.condition, isNull); |
| 6071 expect(statement.rightSeparator, isNotNull); | 6069 expect(statement.rightSeparator, isNotNull); |
| 6072 expect(statement.updaters, hasLength(0)); | 6070 expect(statement.updaters, hasLength(0)); |
| 6073 expect(statement.rightParenthesis, isNotNull); | 6071 expect(statement.rightParenthesis, isNotNull); |
| 6074 expect(statement.body, isNotNull); | 6072 expect(statement.body, isNotNull); |
| 6075 } | 6073 } |
| 6076 | 6074 |
| 6077 void test_parseForStatement_loop_ic() { | 6075 void test_parseForStatement_loop_ic() { |
| 6078 ForStatement statement = ParserTestCase.parse4("parseForStatement", "for (va
r i = 0; i < count;) {}", []); | 6076 ForStatement statement = ParserTestCase.parse4("parseForStatement", "for (va
r i = 0; i < count;) {}"); |
| 6079 expect(statement.forKeyword, isNotNull); | 6077 expect(statement.forKeyword, isNotNull); |
| 6080 expect(statement.leftParenthesis, isNotNull); | 6078 expect(statement.leftParenthesis, isNotNull); |
| 6081 VariableDeclarationList variables = statement.variables; | 6079 VariableDeclarationList variables = statement.variables; |
| 6082 expect(variables, isNotNull); | 6080 expect(variables, isNotNull); |
| 6083 expect(variables.variables, hasLength(1)); | 6081 expect(variables.variables, hasLength(1)); |
| 6084 expect(statement.initialization, isNull); | 6082 expect(statement.initialization, isNull); |
| 6085 expect(statement.leftSeparator, isNotNull); | 6083 expect(statement.leftSeparator, isNotNull); |
| 6086 expect(statement.condition, isNotNull); | 6084 expect(statement.condition, isNotNull); |
| 6087 expect(statement.rightSeparator, isNotNull); | 6085 expect(statement.rightSeparator, isNotNull); |
| 6088 expect(statement.updaters, hasLength(0)); | 6086 expect(statement.updaters, hasLength(0)); |
| 6089 expect(statement.rightParenthesis, isNotNull); | 6087 expect(statement.rightParenthesis, isNotNull); |
| 6090 expect(statement.body, isNotNull); | 6088 expect(statement.body, isNotNull); |
| 6091 } | 6089 } |
| 6092 | 6090 |
| 6093 void test_parseForStatement_loop_icu() { | 6091 void test_parseForStatement_loop_icu() { |
| 6094 ForStatement statement = ParserTestCase.parse4("parseForStatement", "for (va
r i = 0; i < count; i++) {}", []); | 6092 ForStatement statement = ParserTestCase.parse4("parseForStatement", "for (va
r i = 0; i < count; i++) {}"); |
| 6095 expect(statement.forKeyword, isNotNull); | 6093 expect(statement.forKeyword, isNotNull); |
| 6096 expect(statement.leftParenthesis, isNotNull); | 6094 expect(statement.leftParenthesis, isNotNull); |
| 6097 VariableDeclarationList variables = statement.variables; | 6095 VariableDeclarationList variables = statement.variables; |
| 6098 expect(variables, isNotNull); | 6096 expect(variables, isNotNull); |
| 6099 expect(variables.variables, hasLength(1)); | 6097 expect(variables.variables, hasLength(1)); |
| 6100 expect(statement.initialization, isNull); | 6098 expect(statement.initialization, isNull); |
| 6101 expect(statement.leftSeparator, isNotNull); | 6099 expect(statement.leftSeparator, isNotNull); |
| 6102 expect(statement.condition, isNotNull); | 6100 expect(statement.condition, isNotNull); |
| 6103 expect(statement.rightSeparator, isNotNull); | 6101 expect(statement.rightSeparator, isNotNull); |
| 6104 expect(statement.updaters, hasLength(1)); | 6102 expect(statement.updaters, hasLength(1)); |
| 6105 expect(statement.rightParenthesis, isNotNull); | 6103 expect(statement.rightParenthesis, isNotNull); |
| 6106 expect(statement.body, isNotNull); | 6104 expect(statement.body, isNotNull); |
| 6107 } | 6105 } |
| 6108 | 6106 |
| 6109 void test_parseForStatement_loop_iicuu() { | 6107 void test_parseForStatement_loop_iicuu() { |
| 6110 ForStatement statement = ParserTestCase.parse4("parseForStatement", "for (in
t i = 0, j = count; i < j; i++, j--) {}", []); | 6108 ForStatement statement = ParserTestCase.parse4("parseForStatement", "for (in
t i = 0, j = count; i < j; i++, j--) {}"); |
| 6111 expect(statement.forKeyword, isNotNull); | 6109 expect(statement.forKeyword, isNotNull); |
| 6112 expect(statement.leftParenthesis, isNotNull); | 6110 expect(statement.leftParenthesis, isNotNull); |
| 6113 VariableDeclarationList variables = statement.variables; | 6111 VariableDeclarationList variables = statement.variables; |
| 6114 expect(variables, isNotNull); | 6112 expect(variables, isNotNull); |
| 6115 expect(variables.variables, hasLength(2)); | 6113 expect(variables.variables, hasLength(2)); |
| 6116 expect(statement.initialization, isNull); | 6114 expect(statement.initialization, isNull); |
| 6117 expect(statement.leftSeparator, isNotNull); | 6115 expect(statement.leftSeparator, isNotNull); |
| 6118 expect(statement.condition, isNotNull); | 6116 expect(statement.condition, isNotNull); |
| 6119 expect(statement.rightSeparator, isNotNull); | 6117 expect(statement.rightSeparator, isNotNull); |
| 6120 expect(statement.updaters, hasLength(2)); | 6118 expect(statement.updaters, hasLength(2)); |
| 6121 expect(statement.rightParenthesis, isNotNull); | 6119 expect(statement.rightParenthesis, isNotNull); |
| 6122 expect(statement.body, isNotNull); | 6120 expect(statement.body, isNotNull); |
| 6123 } | 6121 } |
| 6124 | 6122 |
| 6125 void test_parseForStatement_loop_iu() { | 6123 void test_parseForStatement_loop_iu() { |
| 6126 ForStatement statement = ParserTestCase.parse4("parseForStatement", "for (va
r i = 0;; i++) {}", []); | 6124 ForStatement statement = ParserTestCase.parse4("parseForStatement", "for (va
r i = 0;; i++) {}"); |
| 6127 expect(statement.forKeyword, isNotNull); | 6125 expect(statement.forKeyword, isNotNull); |
| 6128 expect(statement.leftParenthesis, isNotNull); | 6126 expect(statement.leftParenthesis, isNotNull); |
| 6129 VariableDeclarationList variables = statement.variables; | 6127 VariableDeclarationList variables = statement.variables; |
| 6130 expect(variables, isNotNull); | 6128 expect(variables, isNotNull); |
| 6131 expect(variables.variables, hasLength(1)); | 6129 expect(variables.variables, hasLength(1)); |
| 6132 expect(statement.initialization, isNull); | 6130 expect(statement.initialization, isNull); |
| 6133 expect(statement.leftSeparator, isNotNull); | 6131 expect(statement.leftSeparator, isNotNull); |
| 6134 expect(statement.condition, isNull); | 6132 expect(statement.condition, isNull); |
| 6135 expect(statement.rightSeparator, isNotNull); | 6133 expect(statement.rightSeparator, isNotNull); |
| 6136 expect(statement.updaters, hasLength(1)); | 6134 expect(statement.updaters, hasLength(1)); |
| 6137 expect(statement.rightParenthesis, isNotNull); | 6135 expect(statement.rightParenthesis, isNotNull); |
| 6138 expect(statement.body, isNotNull); | 6136 expect(statement.body, isNotNull); |
| 6139 } | 6137 } |
| 6140 | 6138 |
| 6141 void test_parseForStatement_loop_u() { | 6139 void test_parseForStatement_loop_u() { |
| 6142 ForStatement statement = ParserTestCase.parse4("parseForStatement", "for (;;
i++) {}", []); | 6140 ForStatement statement = ParserTestCase.parse4("parseForStatement", "for (;;
i++) {}"); |
| 6143 expect(statement.forKeyword, isNotNull); | 6141 expect(statement.forKeyword, isNotNull); |
| 6144 expect(statement.leftParenthesis, isNotNull); | 6142 expect(statement.leftParenthesis, isNotNull); |
| 6145 expect(statement.variables, isNull); | 6143 expect(statement.variables, isNull); |
| 6146 expect(statement.initialization, isNull); | 6144 expect(statement.initialization, isNull); |
| 6147 expect(statement.leftSeparator, isNotNull); | 6145 expect(statement.leftSeparator, isNotNull); |
| 6148 expect(statement.condition, isNull); | 6146 expect(statement.condition, isNull); |
| 6149 expect(statement.rightSeparator, isNotNull); | 6147 expect(statement.rightSeparator, isNotNull); |
| 6150 expect(statement.updaters, hasLength(1)); | 6148 expect(statement.updaters, hasLength(1)); |
| 6151 expect(statement.rightParenthesis, isNotNull); | 6149 expect(statement.rightParenthesis, isNotNull); |
| 6152 expect(statement.body, isNotNull); | 6150 expect(statement.body, isNotNull); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6250 | 6248 |
| 6251 void test_parseFunctionBody_skip_expression() { | 6249 void test_parseFunctionBody_skip_expression() { |
| 6252 ParserTestCase.parseFunctionBodies = false; | 6250 ParserTestCase.parseFunctionBodies = false; |
| 6253 FunctionBody functionBody = ParserTestCase.parse("parseFunctionBody", <Objec
t> [false, null, false], "=> y;"); | 6251 FunctionBody functionBody = ParserTestCase.parse("parseFunctionBody", <Objec
t> [false, null, false], "=> y;"); |
| 6254 EngineTestCase.assertInstanceOf((obj) => obj is EmptyFunctionBody, EmptyFunc
tionBody, functionBody); | 6252 EngineTestCase.assertInstanceOf((obj) => obj is EmptyFunctionBody, EmptyFunc
tionBody, functionBody); |
| 6255 } | 6253 } |
| 6256 | 6254 |
| 6257 void test_parseFunctionDeclaration_function() { | 6255 void test_parseFunctionDeclaration_function() { |
| 6258 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); | 6256 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); |
| 6259 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); | 6257 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); |
| 6260 FunctionDeclaration declaration = ParserTestCase.parse("parseFunctionDeclara
tion", <Object> [commentAndMetadata(comment, []), null, returnType], "f() {}"); | 6258 FunctionDeclaration declaration = ParserTestCase.parse("parseFunctionDeclara
tion", <Object> [commentAndMetadata(comment), null, returnType], "f() {}"); |
| 6261 expect(declaration.documentationComment, comment); | 6259 expect(declaration.documentationComment, comment); |
| 6262 expect(declaration.returnType, returnType); | 6260 expect(declaration.returnType, returnType); |
| 6263 expect(declaration.name, isNotNull); | 6261 expect(declaration.name, isNotNull); |
| 6264 FunctionExpression expression = declaration.functionExpression; | 6262 FunctionExpression expression = declaration.functionExpression; |
| 6265 expect(expression, isNotNull); | 6263 expect(expression, isNotNull); |
| 6266 expect(expression.body, isNotNull); | 6264 expect(expression.body, isNotNull); |
| 6267 expect(expression.parameters, isNotNull); | 6265 expect(expression.parameters, isNotNull); |
| 6268 expect(declaration.propertyKeyword, isNull); | 6266 expect(declaration.propertyKeyword, isNull); |
| 6269 } | 6267 } |
| 6270 | 6268 |
| 6271 void test_parseFunctionDeclaration_getter() { | 6269 void test_parseFunctionDeclaration_getter() { |
| 6272 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); | 6270 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); |
| 6273 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); | 6271 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); |
| 6274 FunctionDeclaration declaration = ParserTestCase.parse("parseFunctionDeclara
tion", <Object> [commentAndMetadata(comment, []), null, returnType], "get p => 0
;"); | 6272 FunctionDeclaration declaration = ParserTestCase.parse("parseFunctionDeclara
tion", <Object> [commentAndMetadata(comment), null, returnType], "get p => 0;"); |
| 6275 expect(declaration.documentationComment, comment); | 6273 expect(declaration.documentationComment, comment); |
| 6276 expect(declaration.returnType, returnType); | 6274 expect(declaration.returnType, returnType); |
| 6277 expect(declaration.name, isNotNull); | 6275 expect(declaration.name, isNotNull); |
| 6278 FunctionExpression expression = declaration.functionExpression; | 6276 FunctionExpression expression = declaration.functionExpression; |
| 6279 expect(expression, isNotNull); | 6277 expect(expression, isNotNull); |
| 6280 expect(expression.body, isNotNull); | 6278 expect(expression.body, isNotNull); |
| 6281 expect(expression.parameters, isNull); | 6279 expect(expression.parameters, isNull); |
| 6282 expect(declaration.propertyKeyword, isNotNull); | 6280 expect(declaration.propertyKeyword, isNotNull); |
| 6283 } | 6281 } |
| 6284 | 6282 |
| 6285 void test_parseFunctionDeclaration_setter() { | 6283 void test_parseFunctionDeclaration_setter() { |
| 6286 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); | 6284 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); |
| 6287 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); | 6285 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); |
| 6288 FunctionDeclaration declaration = ParserTestCase.parse("parseFunctionDeclara
tion", <Object> [commentAndMetadata(comment, []), null, returnType], "set p(v) {
}"); | 6286 FunctionDeclaration declaration = ParserTestCase.parse("parseFunctionDeclara
tion", <Object> [commentAndMetadata(comment), null, returnType], "set p(v) {}"); |
| 6289 expect(declaration.documentationComment, comment); | 6287 expect(declaration.documentationComment, comment); |
| 6290 expect(declaration.returnType, returnType); | 6288 expect(declaration.returnType, returnType); |
| 6291 expect(declaration.name, isNotNull); | 6289 expect(declaration.name, isNotNull); |
| 6292 FunctionExpression expression = declaration.functionExpression; | 6290 FunctionExpression expression = declaration.functionExpression; |
| 6293 expect(expression, isNotNull); | 6291 expect(expression, isNotNull); |
| 6294 expect(expression.body, isNotNull); | 6292 expect(expression.body, isNotNull); |
| 6295 expect(expression.parameters, isNotNull); | 6293 expect(expression.parameters, isNotNull); |
| 6296 expect(declaration.propertyKeyword, isNotNull); | 6294 expect(declaration.propertyKeyword, isNotNull); |
| 6297 } | 6295 } |
| 6298 | 6296 |
| 6299 void test_parseFunctionDeclarationStatement() { | 6297 void test_parseFunctionDeclarationStatement() { |
| 6300 FunctionDeclarationStatement statement = ParserTestCase.parse4("parseFunctio
nDeclarationStatement", "void f(int p) => p * 2;", []); | 6298 FunctionDeclarationStatement statement = ParserTestCase.parse4("parseFunctio
nDeclarationStatement", "void f(int p) => p * 2;"); |
| 6301 expect(statement.functionDeclaration, isNotNull); | 6299 expect(statement.functionDeclaration, isNotNull); |
| 6302 } | 6300 } |
| 6303 | 6301 |
| 6304 void test_parseFunctionExpression_body_inExpression() { | 6302 void test_parseFunctionExpression_body_inExpression() { |
| 6305 FunctionExpression expression = ParserTestCase.parse4("parseFunctionExpressi
on", "(int i) => i++", []); | 6303 FunctionExpression expression = ParserTestCase.parse4("parseFunctionExpressi
on", "(int i) => i++"); |
| 6306 expect(expression.body, isNotNull); | 6304 expect(expression.body, isNotNull); |
| 6307 expect(expression.parameters, isNotNull); | 6305 expect(expression.parameters, isNotNull); |
| 6308 expect((expression.body as ExpressionFunctionBody).semicolon, isNull); | 6306 expect((expression.body as ExpressionFunctionBody).semicolon, isNull); |
| 6309 } | 6307 } |
| 6310 | 6308 |
| 6311 void test_parseGetter_nonStatic() { | 6309 void test_parseGetter_nonStatic() { |
| 6312 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); | 6310 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); |
| 6313 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); | 6311 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); |
| 6314 MethodDeclaration method = ParserTestCase.parse("parseGetter", <Object> [com
mentAndMetadata(comment, []), null, null, returnType], "get a;"); | 6312 MethodDeclaration method = ParserTestCase.parse("parseGetter", <Object> [com
mentAndMetadata(comment), null, null, returnType], "get a;"); |
| 6315 expect(method.body, isNotNull); | 6313 expect(method.body, isNotNull); |
| 6316 expect(method.documentationComment, comment); | 6314 expect(method.documentationComment, comment); |
| 6317 expect(method.externalKeyword, isNull); | 6315 expect(method.externalKeyword, isNull); |
| 6318 expect(method.modifierKeyword, isNull); | 6316 expect(method.modifierKeyword, isNull); |
| 6319 expect(method.name, isNotNull); | 6317 expect(method.name, isNotNull); |
| 6320 expect(method.operatorKeyword, isNull); | 6318 expect(method.operatorKeyword, isNull); |
| 6321 expect(method.parameters, isNull); | 6319 expect(method.parameters, isNull); |
| 6322 expect(method.propertyKeyword, isNotNull); | 6320 expect(method.propertyKeyword, isNotNull); |
| 6323 expect(method.returnType, returnType); | 6321 expect(method.returnType, returnType); |
| 6324 } | 6322 } |
| 6325 | 6323 |
| 6326 void test_parseGetter_static() { | 6324 void test_parseGetter_static() { |
| 6327 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); | 6325 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); |
| 6328 Token staticKeyword = TokenFactory.tokenFromKeyword(Keyword.STATIC); | 6326 Token staticKeyword = TokenFactory.tokenFromKeyword(Keyword.STATIC); |
| 6329 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); | 6327 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); |
| 6330 MethodDeclaration method = ParserTestCase.parse("parseGetter", <Object> [ | 6328 MethodDeclaration method = ParserTestCase.parse("parseGetter", <Object> [ |
| 6331 commentAndMetadata(comment, []), | 6329 commentAndMetadata(comment), |
| 6332 null, | 6330 null, |
| 6333 staticKeyword, | 6331 staticKeyword, |
| 6334 returnType], "get a => 42;"); | 6332 returnType], "get a => 42;"); |
| 6335 expect(method.body, isNotNull); | 6333 expect(method.body, isNotNull); |
| 6336 expect(method.documentationComment, comment); | 6334 expect(method.documentationComment, comment); |
| 6337 expect(method.externalKeyword, isNull); | 6335 expect(method.externalKeyword, isNull); |
| 6338 expect(method.modifierKeyword, staticKeyword); | 6336 expect(method.modifierKeyword, staticKeyword); |
| 6339 expect(method.name, isNotNull); | 6337 expect(method.name, isNotNull); |
| 6340 expect(method.operatorKeyword, isNull); | 6338 expect(method.operatorKeyword, isNull); |
| 6341 expect(method.parameters, isNull); | 6339 expect(method.parameters, isNull); |
| 6342 expect(method.propertyKeyword, isNotNull); | 6340 expect(method.propertyKeyword, isNotNull); |
| 6343 expect(method.returnType, returnType); | 6341 expect(method.returnType, returnType); |
| 6344 } | 6342 } |
| 6345 | 6343 |
| 6346 void test_parseIdentifierList_multiple() { | 6344 void test_parseIdentifierList_multiple() { |
| 6347 List<SimpleIdentifier> list = ParserTestCase.parse4("parseIdentifierList", "
a, b, c", []); | 6345 List<SimpleIdentifier> list = ParserTestCase.parse4("parseIdentifierList", "
a, b, c"); |
| 6348 expect(list, hasLength(3)); | 6346 expect(list, hasLength(3)); |
| 6349 } | 6347 } |
| 6350 | 6348 |
| 6351 void test_parseIdentifierList_single() { | 6349 void test_parseIdentifierList_single() { |
| 6352 List<SimpleIdentifier> list = ParserTestCase.parse4("parseIdentifierList", "
a", []); | 6350 List<SimpleIdentifier> list = ParserTestCase.parse4("parseIdentifierList", "
a"); |
| 6353 expect(list, hasLength(1)); | 6351 expect(list, hasLength(1)); |
| 6354 } | 6352 } |
| 6355 | 6353 |
| 6356 void test_parseIfStatement_else_block() { | 6354 void test_parseIfStatement_else_block() { |
| 6357 IfStatement statement = ParserTestCase.parse4("parseIfStatement", "if (x) {}
else {}", []); | 6355 IfStatement statement = ParserTestCase.parse4("parseIfStatement", "if (x) {}
else {}"); |
| 6358 expect(statement.ifKeyword, isNotNull); | 6356 expect(statement.ifKeyword, isNotNull); |
| 6359 expect(statement.leftParenthesis, isNotNull); | 6357 expect(statement.leftParenthesis, isNotNull); |
| 6360 expect(statement.condition, isNotNull); | 6358 expect(statement.condition, isNotNull); |
| 6361 expect(statement.rightParenthesis, isNotNull); | 6359 expect(statement.rightParenthesis, isNotNull); |
| 6362 expect(statement.thenStatement, isNotNull); | 6360 expect(statement.thenStatement, isNotNull); |
| 6363 expect(statement.elseKeyword, isNotNull); | 6361 expect(statement.elseKeyword, isNotNull); |
| 6364 expect(statement.elseStatement, isNotNull); | 6362 expect(statement.elseStatement, isNotNull); |
| 6365 } | 6363 } |
| 6366 | 6364 |
| 6367 void test_parseIfStatement_else_statement() { | 6365 void test_parseIfStatement_else_statement() { |
| 6368 IfStatement statement = ParserTestCase.parse4("parseIfStatement", "if (x) f(
x); else f(y);", []); | 6366 IfStatement statement = ParserTestCase.parse4("parseIfStatement", "if (x) f(
x); else f(y);"); |
| 6369 expect(statement.ifKeyword, isNotNull); | 6367 expect(statement.ifKeyword, isNotNull); |
| 6370 expect(statement.leftParenthesis, isNotNull); | 6368 expect(statement.leftParenthesis, isNotNull); |
| 6371 expect(statement.condition, isNotNull); | 6369 expect(statement.condition, isNotNull); |
| 6372 expect(statement.rightParenthesis, isNotNull); | 6370 expect(statement.rightParenthesis, isNotNull); |
| 6373 expect(statement.thenStatement, isNotNull); | 6371 expect(statement.thenStatement, isNotNull); |
| 6374 expect(statement.elseKeyword, isNotNull); | 6372 expect(statement.elseKeyword, isNotNull); |
| 6375 expect(statement.elseStatement, isNotNull); | 6373 expect(statement.elseStatement, isNotNull); |
| 6376 } | 6374 } |
| 6377 | 6375 |
| 6378 void test_parseIfStatement_noElse_block() { | 6376 void test_parseIfStatement_noElse_block() { |
| 6379 IfStatement statement = ParserTestCase.parse4("parseIfStatement", "if (x) {}
", []); | 6377 IfStatement statement = ParserTestCase.parse4("parseIfStatement", "if (x) {}
"); |
| 6380 expect(statement.ifKeyword, isNotNull); | 6378 expect(statement.ifKeyword, isNotNull); |
| 6381 expect(statement.leftParenthesis, isNotNull); | 6379 expect(statement.leftParenthesis, isNotNull); |
| 6382 expect(statement.condition, isNotNull); | 6380 expect(statement.condition, isNotNull); |
| 6383 expect(statement.rightParenthesis, isNotNull); | 6381 expect(statement.rightParenthesis, isNotNull); |
| 6384 expect(statement.thenStatement, isNotNull); | 6382 expect(statement.thenStatement, isNotNull); |
| 6385 expect(statement.elseKeyword, isNull); | 6383 expect(statement.elseKeyword, isNull); |
| 6386 expect(statement.elseStatement, isNull); | 6384 expect(statement.elseStatement, isNull); |
| 6387 } | 6385 } |
| 6388 | 6386 |
| 6389 void test_parseIfStatement_noElse_statement() { | 6387 void test_parseIfStatement_noElse_statement() { |
| 6390 IfStatement statement = ParserTestCase.parse4("parseIfStatement", "if (x) f(
x);", []); | 6388 IfStatement statement = ParserTestCase.parse4("parseIfStatement", "if (x) f(
x);"); |
| 6391 expect(statement.ifKeyword, isNotNull); | 6389 expect(statement.ifKeyword, isNotNull); |
| 6392 expect(statement.leftParenthesis, isNotNull); | 6390 expect(statement.leftParenthesis, isNotNull); |
| 6393 expect(statement.condition, isNotNull); | 6391 expect(statement.condition, isNotNull); |
| 6394 expect(statement.rightParenthesis, isNotNull); | 6392 expect(statement.rightParenthesis, isNotNull); |
| 6395 expect(statement.thenStatement, isNotNull); | 6393 expect(statement.thenStatement, isNotNull); |
| 6396 expect(statement.elseKeyword, isNull); | 6394 expect(statement.elseKeyword, isNull); |
| 6397 expect(statement.elseStatement, isNull); | 6395 expect(statement.elseStatement, isNull); |
| 6398 } | 6396 } |
| 6399 | 6397 |
| 6400 void test_parseImplementsClause_multiple() { | 6398 void test_parseImplementsClause_multiple() { |
| 6401 ImplementsClause clause = ParserTestCase.parse4("parseImplementsClause", "im
plements A, B, C", []); | 6399 ImplementsClause clause = ParserTestCase.parse4("parseImplementsClause", "im
plements A, B, C"); |
| 6402 expect(clause.interfaces, hasLength(3)); | 6400 expect(clause.interfaces, hasLength(3)); |
| 6403 expect(clause.keyword, isNotNull); | 6401 expect(clause.keyword, isNotNull); |
| 6404 } | 6402 } |
| 6405 | 6403 |
| 6406 void test_parseImplementsClause_single() { | 6404 void test_parseImplementsClause_single() { |
| 6407 ImplementsClause clause = ParserTestCase.parse4("parseImplementsClause", "im
plements A", []); | 6405 ImplementsClause clause = ParserTestCase.parse4("parseImplementsClause", "im
plements A"); |
| 6408 expect(clause.interfaces, hasLength(1)); | 6406 expect(clause.interfaces, hasLength(1)); |
| 6409 expect(clause.keyword, isNotNull); | 6407 expect(clause.keyword, isNotNull); |
| 6410 } | 6408 } |
| 6411 | 6409 |
| 6412 void test_parseImportDirective_deferred() { | 6410 void test_parseImportDirective_deferred() { |
| 6413 ImportDirective directive = ParserTestCase.parse("parseImportDirective", <Ob
ject> [emptyCommentAndMetadata()], "import 'lib/lib.dart' deferred as a;"); | 6411 ImportDirective directive = ParserTestCase.parse("parseImportDirective", <Ob
ject> [emptyCommentAndMetadata()], "import 'lib/lib.dart' deferred as a;"); |
| 6414 expect(directive.keyword, isNotNull); | 6412 expect(directive.keyword, isNotNull); |
| 6415 expect(directive.uri, isNotNull); | 6413 expect(directive.uri, isNotNull); |
| 6416 expect(directive.deferredToken, isNotNull); | 6414 expect(directive.deferredToken, isNotNull); |
| 6417 expect(directive.asToken, isNotNull); | 6415 expect(directive.asToken, isNotNull); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6484 expect(directive.prefix, isNull); | 6482 expect(directive.prefix, isNull); |
| 6485 expect(directive.combinators, hasLength(1)); | 6483 expect(directive.combinators, hasLength(1)); |
| 6486 expect(directive.semicolon, isNotNull); | 6484 expect(directive.semicolon, isNotNull); |
| 6487 } | 6485 } |
| 6488 | 6486 |
| 6489 void test_parseInitializedIdentifierList_type() { | 6487 void test_parseInitializedIdentifierList_type() { |
| 6490 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); | 6488 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); |
| 6491 Token staticKeyword = TokenFactory.tokenFromKeyword(Keyword.STATIC); | 6489 Token staticKeyword = TokenFactory.tokenFromKeyword(Keyword.STATIC); |
| 6492 TypeName type = new TypeName(new SimpleIdentifier(null), null); | 6490 TypeName type = new TypeName(new SimpleIdentifier(null), null); |
| 6493 FieldDeclaration declaration = ParserTestCase.parse("parseInitializedIdentif
ierList", <Object> [ | 6491 FieldDeclaration declaration = ParserTestCase.parse("parseInitializedIdentif
ierList", <Object> [ |
| 6494 commentAndMetadata(comment, []), | 6492 commentAndMetadata(comment), |
| 6495 staticKeyword, | 6493 staticKeyword, |
| 6496 null, | 6494 null, |
| 6497 type], "a = 1, b, c = 3;"); | 6495 type], "a = 1, b, c = 3;"); |
| 6498 expect(declaration.documentationComment, comment); | 6496 expect(declaration.documentationComment, comment); |
| 6499 VariableDeclarationList fields = declaration.fields; | 6497 VariableDeclarationList fields = declaration.fields; |
| 6500 expect(fields, isNotNull); | 6498 expect(fields, isNotNull); |
| 6501 expect(fields.keyword, isNull); | 6499 expect(fields.keyword, isNull); |
| 6502 expect(fields.type, type); | 6500 expect(fields.type, type); |
| 6503 expect(fields.variables, hasLength(3)); | 6501 expect(fields.variables, hasLength(3)); |
| 6504 expect(declaration.staticKeyword, staticKeyword); | 6502 expect(declaration.staticKeyword, staticKeyword); |
| 6505 expect(declaration.semicolon, isNotNull); | 6503 expect(declaration.semicolon, isNotNull); |
| 6506 } | 6504 } |
| 6507 | 6505 |
| 6508 void test_parseInitializedIdentifierList_var() { | 6506 void test_parseInitializedIdentifierList_var() { |
| 6509 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); | 6507 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); |
| 6510 Token staticKeyword = TokenFactory.tokenFromKeyword(Keyword.STATIC); | 6508 Token staticKeyword = TokenFactory.tokenFromKeyword(Keyword.STATIC); |
| 6511 Token varKeyword = TokenFactory.tokenFromKeyword(Keyword.VAR); | 6509 Token varKeyword = TokenFactory.tokenFromKeyword(Keyword.VAR); |
| 6512 FieldDeclaration declaration = ParserTestCase.parse("parseInitializedIdentif
ierList", <Object> [ | 6510 FieldDeclaration declaration = ParserTestCase.parse("parseInitializedIdentif
ierList", <Object> [ |
| 6513 commentAndMetadata(comment, []), | 6511 commentAndMetadata(comment), |
| 6514 staticKeyword, | 6512 staticKeyword, |
| 6515 varKeyword, | 6513 varKeyword, |
| 6516 null], "a = 1, b, c = 3;"); | 6514 null], "a = 1, b, c = 3;"); |
| 6517 expect(declaration.documentationComment, comment); | 6515 expect(declaration.documentationComment, comment); |
| 6518 VariableDeclarationList fields = declaration.fields; | 6516 VariableDeclarationList fields = declaration.fields; |
| 6519 expect(fields, isNotNull); | 6517 expect(fields, isNotNull); |
| 6520 expect(fields.keyword, varKeyword); | 6518 expect(fields.keyword, varKeyword); |
| 6521 expect(fields.type, isNull); | 6519 expect(fields.type, isNull); |
| 6522 expect(fields.variables, hasLength(3)); | 6520 expect(fields.variables, hasLength(3)); |
| 6523 expect(declaration.staticKeyword, staticKeyword); | 6521 expect(declaration.staticKeyword, staticKeyword); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6574 | 6572 |
| 6575 void test_parseLibraryDirective() { | 6573 void test_parseLibraryDirective() { |
| 6576 LibraryDirective directive = ParserTestCase.parse("parseLibraryDirective", <
Object> [emptyCommentAndMetadata()], "library l;"); | 6574 LibraryDirective directive = ParserTestCase.parse("parseLibraryDirective", <
Object> [emptyCommentAndMetadata()], "library l;"); |
| 6577 expect(directive.libraryToken, isNotNull); | 6575 expect(directive.libraryToken, isNotNull); |
| 6578 expect(directive.name, isNotNull); | 6576 expect(directive.name, isNotNull); |
| 6579 expect(directive.semicolon, isNotNull); | 6577 expect(directive.semicolon, isNotNull); |
| 6580 } | 6578 } |
| 6581 | 6579 |
| 6582 void test_parseLibraryIdentifier_multiple() { | 6580 void test_parseLibraryIdentifier_multiple() { |
| 6583 String name = "a.b.c"; | 6581 String name = "a.b.c"; |
| 6584 LibraryIdentifier identifier = ParserTestCase.parse4("parseLibraryIdentifier
", name, []); | 6582 LibraryIdentifier identifier = ParserTestCase.parse4("parseLibraryIdentifier
", name); |
| 6585 expect(identifier.name, name); | 6583 expect(identifier.name, name); |
| 6586 } | 6584 } |
| 6587 | 6585 |
| 6588 void test_parseLibraryIdentifier_single() { | 6586 void test_parseLibraryIdentifier_single() { |
| 6589 String name = "a"; | 6587 String name = "a"; |
| 6590 LibraryIdentifier identifier = ParserTestCase.parse4("parseLibraryIdentifier
", name, []); | 6588 LibraryIdentifier identifier = ParserTestCase.parse4("parseLibraryIdentifier
", name); |
| 6591 expect(identifier.name, name); | 6589 expect(identifier.name, name); |
| 6592 } | 6590 } |
| 6593 | 6591 |
| 6594 void test_parseListLiteral_empty_oneToken() { | 6592 void test_parseListLiteral_empty_oneToken() { |
| 6595 Token token = TokenFactory.tokenFromKeyword(Keyword.CONST); | 6593 Token token = TokenFactory.tokenFromKeyword(Keyword.CONST); |
| 6596 TypeArgumentList typeArguments = null; | 6594 TypeArgumentList typeArguments = null; |
| 6597 ListLiteral literal = ParserTestCase.parse("parseListLiteral", <Object> [tok
en, typeArguments], "[]"); | 6595 ListLiteral literal = ParserTestCase.parse("parseListLiteral", <Object> [tok
en, typeArguments], "[]"); |
| 6598 expect(literal.constKeyword, token); | 6596 expect(literal.constKeyword, token); |
| 6599 expect(literal.typeArguments, typeArguments); | 6597 expect(literal.typeArguments, typeArguments); |
| 6600 expect(literal.leftBracket, isNotNull); | 6598 expect(literal.leftBracket, isNotNull); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6661 void test_parseListOrMapLiteral_map_type() { | 6659 void test_parseListOrMapLiteral_map_type() { |
| 6662 MapLiteral literal = ParserTestCase.parse("parseListOrMapLiteral", <Object>
[null], "<String, int> {'1' : 1}"); | 6660 MapLiteral literal = ParserTestCase.parse("parseListOrMapLiteral", <Object>
[null], "<String, int> {'1' : 1}"); |
| 6663 expect(literal.constKeyword, isNull); | 6661 expect(literal.constKeyword, isNull); |
| 6664 expect(literal.typeArguments, isNotNull); | 6662 expect(literal.typeArguments, isNotNull); |
| 6665 expect(literal.leftBracket, isNotNull); | 6663 expect(literal.leftBracket, isNotNull); |
| 6666 expect(literal.entries, hasLength(1)); | 6664 expect(literal.entries, hasLength(1)); |
| 6667 expect(literal.rightBracket, isNotNull); | 6665 expect(literal.rightBracket, isNotNull); |
| 6668 } | 6666 } |
| 6669 | 6667 |
| 6670 void test_parseLogicalAndExpression() { | 6668 void test_parseLogicalAndExpression() { |
| 6671 BinaryExpression expression = ParserTestCase.parse4("parseLogicalAndExpressi
on", "x && y", []); | 6669 BinaryExpression expression = ParserTestCase.parse4("parseLogicalAndExpressi
on", "x && y"); |
| 6672 expect(expression.leftOperand, isNotNull); | 6670 expect(expression.leftOperand, isNotNull); |
| 6673 expect(expression.operator, isNotNull); | 6671 expect(expression.operator, isNotNull); |
| 6674 expect(expression.operator.type, TokenType.AMPERSAND_AMPERSAND); | 6672 expect(expression.operator.type, TokenType.AMPERSAND_AMPERSAND); |
| 6675 expect(expression.rightOperand, isNotNull); | 6673 expect(expression.rightOperand, isNotNull); |
| 6676 } | 6674 } |
| 6677 | 6675 |
| 6678 void test_parseLogicalOrExpression() { | 6676 void test_parseLogicalOrExpression() { |
| 6679 BinaryExpression expression = ParserTestCase.parse4("parseLogicalOrExpressio
n", "x || y", []); | 6677 BinaryExpression expression = ParserTestCase.parse4("parseLogicalOrExpressio
n", "x || y"); |
| 6680 expect(expression.leftOperand, isNotNull); | 6678 expect(expression.leftOperand, isNotNull); |
| 6681 expect(expression.operator, isNotNull); | 6679 expect(expression.operator, isNotNull); |
| 6682 expect(expression.operator.type, TokenType.BAR_BAR); | 6680 expect(expression.operator.type, TokenType.BAR_BAR); |
| 6683 expect(expression.rightOperand, isNotNull); | 6681 expect(expression.rightOperand, isNotNull); |
| 6684 } | 6682 } |
| 6685 | 6683 |
| 6686 void test_parseMapLiteral_empty() { | 6684 void test_parseMapLiteral_empty() { |
| 6687 Token token = TokenFactory.tokenFromKeyword(Keyword.CONST); | 6685 Token token = TokenFactory.tokenFromKeyword(Keyword.CONST); |
| 6688 TypeArgumentList typeArguments = AstFactory.typeArgumentList([ | 6686 TypeArgumentList typeArguments = AstFactory.typeArgumentList([ |
| 6689 AstFactory.typeName4("String", []), | 6687 AstFactory.typeName4("String"), |
| 6690 AstFactory.typeName4("int", [])]); | 6688 AstFactory.typeName4("int")]); |
| 6691 MapLiteral literal = ParserTestCase.parse("parseMapLiteral", <Object> [token
, typeArguments], "{}"); | 6689 MapLiteral literal = ParserTestCase.parse("parseMapLiteral", <Object> [token
, typeArguments], "{}"); |
| 6692 expect(literal.constKeyword, token); | 6690 expect(literal.constKeyword, token); |
| 6693 expect(literal.typeArguments, typeArguments); | 6691 expect(literal.typeArguments, typeArguments); |
| 6694 expect(literal.leftBracket, isNotNull); | 6692 expect(literal.leftBracket, isNotNull); |
| 6695 expect(literal.entries, hasLength(0)); | 6693 expect(literal.entries, hasLength(0)); |
| 6696 expect(literal.rightBracket, isNotNull); | 6694 expect(literal.rightBracket, isNotNull); |
| 6697 } | 6695 } |
| 6698 | 6696 |
| 6699 void test_parseMapLiteral_multiple() { | 6697 void test_parseMapLiteral_multiple() { |
| 6700 MapLiteral literal = ParserTestCase.parse("parseMapLiteral", <Object> [null,
null], "{'a' : b, 'x' : y}"); | 6698 MapLiteral literal = ParserTestCase.parse("parseMapLiteral", <Object> [null,
null], "{'a' : b, 'x' : y}"); |
| 6701 expect(literal.leftBracket, isNotNull); | 6699 expect(literal.leftBracket, isNotNull); |
| 6702 expect(literal.entries, hasLength(2)); | 6700 expect(literal.entries, hasLength(2)); |
| 6703 expect(literal.rightBracket, isNotNull); | 6701 expect(literal.rightBracket, isNotNull); |
| 6704 } | 6702 } |
| 6705 | 6703 |
| 6706 void test_parseMapLiteral_single() { | 6704 void test_parseMapLiteral_single() { |
| 6707 MapLiteral literal = ParserTestCase.parse("parseMapLiteral", <Object> [null,
null], "{'x' : y}"); | 6705 MapLiteral literal = ParserTestCase.parse("parseMapLiteral", <Object> [null,
null], "{'x' : y}"); |
| 6708 expect(literal.leftBracket, isNotNull); | 6706 expect(literal.leftBracket, isNotNull); |
| 6709 expect(literal.entries, hasLength(1)); | 6707 expect(literal.entries, hasLength(1)); |
| 6710 expect(literal.rightBracket, isNotNull); | 6708 expect(literal.rightBracket, isNotNull); |
| 6711 } | 6709 } |
| 6712 | 6710 |
| 6713 void test_parseMapLiteralEntry_complex() { | 6711 void test_parseMapLiteralEntry_complex() { |
| 6714 MapLiteralEntry entry = ParserTestCase.parse4("parseMapLiteralEntry", "2 + 2
: y", []); | 6712 MapLiteralEntry entry = ParserTestCase.parse4("parseMapLiteralEntry", "2 + 2
: y"); |
| 6715 expect(entry.key, isNotNull); | 6713 expect(entry.key, isNotNull); |
| 6716 expect(entry.separator, isNotNull); | 6714 expect(entry.separator, isNotNull); |
| 6717 expect(entry.value, isNotNull); | 6715 expect(entry.value, isNotNull); |
| 6718 } | 6716 } |
| 6719 | 6717 |
| 6720 void test_parseMapLiteralEntry_int() { | 6718 void test_parseMapLiteralEntry_int() { |
| 6721 MapLiteralEntry entry = ParserTestCase.parse4("parseMapLiteralEntry", "0 : y
", []); | 6719 MapLiteralEntry entry = ParserTestCase.parse4("parseMapLiteralEntry", "0 : y
"); |
| 6722 expect(entry.key, isNotNull); | 6720 expect(entry.key, isNotNull); |
| 6723 expect(entry.separator, isNotNull); | 6721 expect(entry.separator, isNotNull); |
| 6724 expect(entry.value, isNotNull); | 6722 expect(entry.value, isNotNull); |
| 6725 } | 6723 } |
| 6726 | 6724 |
| 6727 void test_parseMapLiteralEntry_string() { | 6725 void test_parseMapLiteralEntry_string() { |
| 6728 MapLiteralEntry entry = ParserTestCase.parse4("parseMapLiteralEntry", "'x' :
y", []); | 6726 MapLiteralEntry entry = ParserTestCase.parse4("parseMapLiteralEntry", "'x' :
y"); |
| 6729 expect(entry.key, isNotNull); | 6727 expect(entry.key, isNotNull); |
| 6730 expect(entry.separator, isNotNull); | 6728 expect(entry.separator, isNotNull); |
| 6731 expect(entry.value, isNotNull); | 6729 expect(entry.value, isNotNull); |
| 6732 } | 6730 } |
| 6733 | 6731 |
| 6734 void test_parseModifiers_abstract() { | 6732 void test_parseModifiers_abstract() { |
| 6735 Modifiers modifiers = ParserTestCase.parse4("parseModifiers", "abstract A",
[]); | 6733 Modifiers modifiers = ParserTestCase.parse4("parseModifiers", "abstract A"); |
| 6736 expect(modifiers.abstractKeyword, isNotNull); | 6734 expect(modifiers.abstractKeyword, isNotNull); |
| 6737 } | 6735 } |
| 6738 | 6736 |
| 6739 void test_parseModifiers_const() { | 6737 void test_parseModifiers_const() { |
| 6740 Modifiers modifiers = ParserTestCase.parse4("parseModifiers", "const A", [])
; | 6738 Modifiers modifiers = ParserTestCase.parse4("parseModifiers", "const A"); |
| 6741 expect(modifiers.constKeyword, isNotNull); | 6739 expect(modifiers.constKeyword, isNotNull); |
| 6742 } | 6740 } |
| 6743 | 6741 |
| 6744 void test_parseModifiers_external() { | 6742 void test_parseModifiers_external() { |
| 6745 Modifiers modifiers = ParserTestCase.parse4("parseModifiers", "external A",
[]); | 6743 Modifiers modifiers = ParserTestCase.parse4("parseModifiers", "external A"); |
| 6746 expect(modifiers.externalKeyword, isNotNull); | 6744 expect(modifiers.externalKeyword, isNotNull); |
| 6747 } | 6745 } |
| 6748 | 6746 |
| 6749 void test_parseModifiers_factory() { | 6747 void test_parseModifiers_factory() { |
| 6750 Modifiers modifiers = ParserTestCase.parse4("parseModifiers", "factory A", [
]); | 6748 Modifiers modifiers = ParserTestCase.parse4("parseModifiers", "factory A"); |
| 6751 expect(modifiers.factoryKeyword, isNotNull); | 6749 expect(modifiers.factoryKeyword, isNotNull); |
| 6752 } | 6750 } |
| 6753 | 6751 |
| 6754 void test_parseModifiers_final() { | 6752 void test_parseModifiers_final() { |
| 6755 Modifiers modifiers = ParserTestCase.parse4("parseModifiers", "final A", [])
; | 6753 Modifiers modifiers = ParserTestCase.parse4("parseModifiers", "final A"); |
| 6756 expect(modifiers.finalKeyword, isNotNull); | 6754 expect(modifiers.finalKeyword, isNotNull); |
| 6757 } | 6755 } |
| 6758 | 6756 |
| 6759 void test_parseModifiers_static() { | 6757 void test_parseModifiers_static() { |
| 6760 Modifiers modifiers = ParserTestCase.parse4("parseModifiers", "static A", []
); | 6758 Modifiers modifiers = ParserTestCase.parse4("parseModifiers", "static A"); |
| 6761 expect(modifiers.staticKeyword, isNotNull); | 6759 expect(modifiers.staticKeyword, isNotNull); |
| 6762 } | 6760 } |
| 6763 | 6761 |
| 6764 void test_parseModifiers_var() { | 6762 void test_parseModifiers_var() { |
| 6765 Modifiers modifiers = ParserTestCase.parse4("parseModifiers", "var A", []); | 6763 Modifiers modifiers = ParserTestCase.parse4("parseModifiers", "var A"); |
| 6766 expect(modifiers.varKeyword, isNotNull); | 6764 expect(modifiers.varKeyword, isNotNull); |
| 6767 } | 6765 } |
| 6768 | 6766 |
| 6769 void test_parseMultiplicativeExpression_normal() { | 6767 void test_parseMultiplicativeExpression_normal() { |
| 6770 BinaryExpression expression = ParserTestCase.parse4("parseMultiplicativeExpr
ession", "x * y", []); | 6768 BinaryExpression expression = ParserTestCase.parse4("parseMultiplicativeExpr
ession", "x * y"); |
| 6771 expect(expression.leftOperand, isNotNull); | 6769 expect(expression.leftOperand, isNotNull); |
| 6772 expect(expression.operator, isNotNull); | 6770 expect(expression.operator, isNotNull); |
| 6773 expect(expression.operator.type, TokenType.STAR); | 6771 expect(expression.operator.type, TokenType.STAR); |
| 6774 expect(expression.rightOperand, isNotNull); | 6772 expect(expression.rightOperand, isNotNull); |
| 6775 } | 6773 } |
| 6776 | 6774 |
| 6777 void test_parseMultiplicativeExpression_super() { | 6775 void test_parseMultiplicativeExpression_super() { |
| 6778 BinaryExpression expression = ParserTestCase.parse4("parseMultiplicativeExpr
ession", "super * y", []); | 6776 BinaryExpression expression = ParserTestCase.parse4("parseMultiplicativeExpr
ession", "super * y"); |
| 6779 EngineTestCase.assertInstanceOf((obj) => obj is SuperExpression, SuperExpres
sion, expression.leftOperand); | 6777 EngineTestCase.assertInstanceOf((obj) => obj is SuperExpression, SuperExpres
sion, expression.leftOperand); |
| 6780 expect(expression.operator, isNotNull); | 6778 expect(expression.operator, isNotNull); |
| 6781 expect(expression.operator.type, TokenType.STAR); | 6779 expect(expression.operator.type, TokenType.STAR); |
| 6782 expect(expression.rightOperand, isNotNull); | 6780 expect(expression.rightOperand, isNotNull); |
| 6783 } | 6781 } |
| 6784 | 6782 |
| 6785 void test_parseNewExpression() { | 6783 void test_parseNewExpression() { |
| 6786 InstanceCreationExpression expression = ParserTestCase.parse4("parseNewExpre
ssion", "new A()", []); | 6784 InstanceCreationExpression expression = ParserTestCase.parse4("parseNewExpre
ssion", "new A()"); |
| 6787 expect(expression.keyword, isNotNull); | 6785 expect(expression.keyword, isNotNull); |
| 6788 ConstructorName name = expression.constructorName; | 6786 ConstructorName name = expression.constructorName; |
| 6789 expect(name, isNotNull); | 6787 expect(name, isNotNull); |
| 6790 expect(name.type, isNotNull); | 6788 expect(name.type, isNotNull); |
| 6791 expect(name.period, isNull); | 6789 expect(name.period, isNull); |
| 6792 expect(name.name, isNull); | 6790 expect(name.name, isNull); |
| 6793 expect(expression.argumentList, isNotNull); | 6791 expect(expression.argumentList, isNotNull); |
| 6794 } | 6792 } |
| 6795 | 6793 |
| 6796 void test_parseNonLabeledStatement_const_list_empty() { | 6794 void test_parseNonLabeledStatement_const_list_empty() { |
| 6797 ExpressionStatement statement = ParserTestCase.parse4("parseNonLabeledStatem
ent", "const [];", []); | 6795 ExpressionStatement statement = ParserTestCase.parse4("parseNonLabeledStatem
ent", "const [];"); |
| 6798 expect(statement.expression, isNotNull); | 6796 expect(statement.expression, isNotNull); |
| 6799 } | 6797 } |
| 6800 | 6798 |
| 6801 void test_parseNonLabeledStatement_const_list_nonEmpty() { | 6799 void test_parseNonLabeledStatement_const_list_nonEmpty() { |
| 6802 ExpressionStatement statement = ParserTestCase.parse4("parseNonLabeledStatem
ent", "const [1, 2];", []); | 6800 ExpressionStatement statement = ParserTestCase.parse4("parseNonLabeledStatem
ent", "const [1, 2];"); |
| 6803 expect(statement.expression, isNotNull); | 6801 expect(statement.expression, isNotNull); |
| 6804 } | 6802 } |
| 6805 | 6803 |
| 6806 void test_parseNonLabeledStatement_const_map_empty() { | 6804 void test_parseNonLabeledStatement_const_map_empty() { |
| 6807 ExpressionStatement statement = ParserTestCase.parse4("parseNonLabeledStatem
ent", "const {};", []); | 6805 ExpressionStatement statement = ParserTestCase.parse4("parseNonLabeledStatem
ent", "const {};"); |
| 6808 expect(statement.expression, isNotNull); | 6806 expect(statement.expression, isNotNull); |
| 6809 } | 6807 } |
| 6810 | 6808 |
| 6811 void test_parseNonLabeledStatement_const_map_nonEmpty() { | 6809 void test_parseNonLabeledStatement_const_map_nonEmpty() { |
| 6812 // TODO(brianwilkerson) Implement more tests for this method. | 6810 // TODO(brianwilkerson) Implement more tests for this method. |
| 6813 ExpressionStatement statement = ParserTestCase.parse4("parseNonLabeledStatem
ent", "const {'a' : 1};", []); | 6811 ExpressionStatement statement = ParserTestCase.parse4("parseNonLabeledStatem
ent", "const {'a' : 1};"); |
| 6814 expect(statement.expression, isNotNull); | 6812 expect(statement.expression, isNotNull); |
| 6815 } | 6813 } |
| 6816 | 6814 |
| 6817 void test_parseNonLabeledStatement_const_object() { | 6815 void test_parseNonLabeledStatement_const_object() { |
| 6818 ExpressionStatement statement = ParserTestCase.parse4("parseNonLabeledStatem
ent", "const A();", []); | 6816 ExpressionStatement statement = ParserTestCase.parse4("parseNonLabeledStatem
ent", "const A();"); |
| 6819 expect(statement.expression, isNotNull); | 6817 expect(statement.expression, isNotNull); |
| 6820 } | 6818 } |
| 6821 | 6819 |
| 6822 void test_parseNonLabeledStatement_const_object_named_typeParameters() { | 6820 void test_parseNonLabeledStatement_const_object_named_typeParameters() { |
| 6823 ExpressionStatement statement = ParserTestCase.parse4("parseNonLabeledStatem
ent", "const A<B>.c();", []); | 6821 ExpressionStatement statement = ParserTestCase.parse4("parseNonLabeledStatem
ent", "const A<B>.c();"); |
| 6824 expect(statement.expression, isNotNull); | 6822 expect(statement.expression, isNotNull); |
| 6825 } | 6823 } |
| 6826 | 6824 |
| 6827 void test_parseNonLabeledStatement_constructorInvocation() { | 6825 void test_parseNonLabeledStatement_constructorInvocation() { |
| 6828 ExpressionStatement statement = ParserTestCase.parse4("parseNonLabeledStatem
ent", "new C().m();", []); | 6826 ExpressionStatement statement = ParserTestCase.parse4("parseNonLabeledStatem
ent", "new C().m();"); |
| 6829 expect(statement.expression, isNotNull); | 6827 expect(statement.expression, isNotNull); |
| 6830 } | 6828 } |
| 6831 | 6829 |
| 6832 void test_parseNonLabeledStatement_false() { | 6830 void test_parseNonLabeledStatement_false() { |
| 6833 ExpressionStatement statement = ParserTestCase.parse4("parseNonLabeledStatem
ent", "false;", []); | 6831 ExpressionStatement statement = ParserTestCase.parse4("parseNonLabeledStatem
ent", "false;"); |
| 6834 expect(statement.expression, isNotNull); | 6832 expect(statement.expression, isNotNull); |
| 6835 } | 6833 } |
| 6836 | 6834 |
| 6837 void test_parseNonLabeledStatement_functionDeclaration() { | 6835 void test_parseNonLabeledStatement_functionDeclaration() { |
| 6838 ParserTestCase.parse4("parseNonLabeledStatement", "f() {};", []); | 6836 ParserTestCase.parse4("parseNonLabeledStatement", "f() {};"); |
| 6839 } | 6837 } |
| 6840 | 6838 |
| 6841 void test_parseNonLabeledStatement_functionDeclaration_arguments() { | 6839 void test_parseNonLabeledStatement_functionDeclaration_arguments() { |
| 6842 ParserTestCase.parse4("parseNonLabeledStatement", "f(void g()) {};", []); | 6840 ParserTestCase.parse4("parseNonLabeledStatement", "f(void g()) {};"); |
| 6843 } | 6841 } |
| 6844 | 6842 |
| 6845 void test_parseNonLabeledStatement_functionExpressionIndex() { | 6843 void test_parseNonLabeledStatement_functionExpressionIndex() { |
| 6846 ParserTestCase.parse4("parseNonLabeledStatement", "() {}[0] = null;", []); | 6844 ParserTestCase.parse4("parseNonLabeledStatement", "() {}[0] = null;"); |
| 6847 } | 6845 } |
| 6848 | 6846 |
| 6849 void test_parseNonLabeledStatement_functionInvocation() { | 6847 void test_parseNonLabeledStatement_functionInvocation() { |
| 6850 ExpressionStatement statement = ParserTestCase.parse4("parseNonLabeledStatem
ent", "f();", []); | 6848 ExpressionStatement statement = ParserTestCase.parse4("parseNonLabeledStatem
ent", "f();"); |
| 6851 expect(statement.expression, isNotNull); | 6849 expect(statement.expression, isNotNull); |
| 6852 } | 6850 } |
| 6853 | 6851 |
| 6854 void test_parseNonLabeledStatement_invokeFunctionExpression() { | 6852 void test_parseNonLabeledStatement_invokeFunctionExpression() { |
| 6855 ExpressionStatement statement = ParserTestCase.parse4("parseNonLabeledStatem
ent", "(a) {return a + a;} (3);", []); | 6853 ExpressionStatement statement = ParserTestCase.parse4("parseNonLabeledStatem
ent", "(a) {return a + a;} (3);"); |
| 6856 EngineTestCase.assertInstanceOf((obj) => obj is FunctionExpressionInvocation
, FunctionExpressionInvocation, statement.expression); | 6854 EngineTestCase.assertInstanceOf((obj) => obj is FunctionExpressionInvocation
, FunctionExpressionInvocation, statement.expression); |
| 6857 FunctionExpressionInvocation invocation = statement.expression as FunctionEx
pressionInvocation; | 6855 FunctionExpressionInvocation invocation = statement.expression as FunctionEx
pressionInvocation; |
| 6858 EngineTestCase.assertInstanceOf((obj) => obj is FunctionExpression, Function
Expression, invocation.function); | 6856 EngineTestCase.assertInstanceOf((obj) => obj is FunctionExpression, Function
Expression, invocation.function); |
| 6859 FunctionExpression expression = invocation.function as FunctionExpression; | 6857 FunctionExpression expression = invocation.function as FunctionExpression; |
| 6860 expect(expression.parameters, isNotNull); | 6858 expect(expression.parameters, isNotNull); |
| 6861 expect(expression.body, isNotNull); | 6859 expect(expression.body, isNotNull); |
| 6862 ArgumentList list = invocation.argumentList; | 6860 ArgumentList list = invocation.argumentList; |
| 6863 expect(list, isNotNull); | 6861 expect(list, isNotNull); |
| 6864 expect(list.arguments, hasLength(1)); | 6862 expect(list.arguments, hasLength(1)); |
| 6865 } | 6863 } |
| 6866 | 6864 |
| 6867 void test_parseNonLabeledStatement_null() { | 6865 void test_parseNonLabeledStatement_null() { |
| 6868 ExpressionStatement statement = ParserTestCase.parse4("parseNonLabeledStatem
ent", "null;", []); | 6866 ExpressionStatement statement = ParserTestCase.parse4("parseNonLabeledStatem
ent", "null;"); |
| 6869 expect(statement.expression, isNotNull); | 6867 expect(statement.expression, isNotNull); |
| 6870 } | 6868 } |
| 6871 | 6869 |
| 6872 void test_parseNonLabeledStatement_startingWithBuiltInIdentifier() { | 6870 void test_parseNonLabeledStatement_startingWithBuiltInIdentifier() { |
| 6873 ExpressionStatement statement = ParserTestCase.parse4("parseNonLabeledStatem
ent", "library.getName();", []); | 6871 ExpressionStatement statement = ParserTestCase.parse4("parseNonLabeledStatem
ent", "library.getName();"); |
| 6874 expect(statement.expression, isNotNull); | 6872 expect(statement.expression, isNotNull); |
| 6875 } | 6873 } |
| 6876 | 6874 |
| 6877 void test_parseNonLabeledStatement_true() { | 6875 void test_parseNonLabeledStatement_true() { |
| 6878 ExpressionStatement statement = ParserTestCase.parse4("parseNonLabeledStatem
ent", "true;", []); | 6876 ExpressionStatement statement = ParserTestCase.parse4("parseNonLabeledStatem
ent", "true;"); |
| 6879 expect(statement.expression, isNotNull); | 6877 expect(statement.expression, isNotNull); |
| 6880 } | 6878 } |
| 6881 | 6879 |
| 6882 void test_parseNonLabeledStatement_typeCast() { | 6880 void test_parseNonLabeledStatement_typeCast() { |
| 6883 ExpressionStatement statement = ParserTestCase.parse4("parseNonLabeledStatem
ent", "double.NAN as num;", []); | 6881 ExpressionStatement statement = ParserTestCase.parse4("parseNonLabeledStatem
ent", "double.NAN as num;"); |
| 6884 expect(statement.expression, isNotNull); | 6882 expect(statement.expression, isNotNull); |
| 6885 } | 6883 } |
| 6886 | 6884 |
| 6887 void test_parseNormalFormalParameter_field_const_noType() { | 6885 void test_parseNormalFormalParameter_field_const_noType() { |
| 6888 FieldFormalParameter parameter = ParserTestCase.parse4("parseNormalFormalPar
ameter", "const this.a)", []); | 6886 FieldFormalParameter parameter = ParserTestCase.parse4("parseNormalFormalPar
ameter", "const this.a)"); |
| 6889 expect(parameter.keyword, isNotNull); | 6887 expect(parameter.keyword, isNotNull); |
| 6890 expect(parameter.type, isNull); | 6888 expect(parameter.type, isNull); |
| 6891 expect(parameter.identifier, isNotNull); | 6889 expect(parameter.identifier, isNotNull); |
| 6892 expect(parameter.parameters, isNull); | 6890 expect(parameter.parameters, isNull); |
| 6893 } | 6891 } |
| 6894 | 6892 |
| 6895 void test_parseNormalFormalParameter_field_const_type() { | 6893 void test_parseNormalFormalParameter_field_const_type() { |
| 6896 FieldFormalParameter parameter = ParserTestCase.parse4("parseNormalFormalPar
ameter", "const A this.a)", []); | 6894 FieldFormalParameter parameter = ParserTestCase.parse4("parseNormalFormalPar
ameter", "const A this.a)"); |
| 6897 expect(parameter.keyword, isNotNull); | 6895 expect(parameter.keyword, isNotNull); |
| 6898 expect(parameter.type, isNotNull); | 6896 expect(parameter.type, isNotNull); |
| 6899 expect(parameter.identifier, isNotNull); | 6897 expect(parameter.identifier, isNotNull); |
| 6900 expect(parameter.parameters, isNull); | 6898 expect(parameter.parameters, isNull); |
| 6901 } | 6899 } |
| 6902 | 6900 |
| 6903 void test_parseNormalFormalParameter_field_final_noType() { | 6901 void test_parseNormalFormalParameter_field_final_noType() { |
| 6904 FieldFormalParameter parameter = ParserTestCase.parse4("parseNormalFormalPar
ameter", "final this.a)", []); | 6902 FieldFormalParameter parameter = ParserTestCase.parse4("parseNormalFormalPar
ameter", "final this.a)"); |
| 6905 expect(parameter.keyword, isNotNull); | 6903 expect(parameter.keyword, isNotNull); |
| 6906 expect(parameter.type, isNull); | 6904 expect(parameter.type, isNull); |
| 6907 expect(parameter.identifier, isNotNull); | 6905 expect(parameter.identifier, isNotNull); |
| 6908 expect(parameter.parameters, isNull); | 6906 expect(parameter.parameters, isNull); |
| 6909 } | 6907 } |
| 6910 | 6908 |
| 6911 void test_parseNormalFormalParameter_field_final_type() { | 6909 void test_parseNormalFormalParameter_field_final_type() { |
| 6912 FieldFormalParameter parameter = ParserTestCase.parse4("parseNormalFormalPar
ameter", "final A this.a)", []); | 6910 FieldFormalParameter parameter = ParserTestCase.parse4("parseNormalFormalPar
ameter", "final A this.a)"); |
| 6913 expect(parameter.keyword, isNotNull); | 6911 expect(parameter.keyword, isNotNull); |
| 6914 expect(parameter.type, isNotNull); | 6912 expect(parameter.type, isNotNull); |
| 6915 expect(parameter.identifier, isNotNull); | 6913 expect(parameter.identifier, isNotNull); |
| 6916 expect(parameter.parameters, isNull); | 6914 expect(parameter.parameters, isNull); |
| 6917 } | 6915 } |
| 6918 | 6916 |
| 6919 void test_parseNormalFormalParameter_field_function_nested() { | 6917 void test_parseNormalFormalParameter_field_function_nested() { |
| 6920 FieldFormalParameter parameter = ParserTestCase.parse4("parseNormalFormalPar
ameter", "this.a(B b))", []); | 6918 FieldFormalParameter parameter = ParserTestCase.parse4("parseNormalFormalPar
ameter", "this.a(B b))"); |
| 6921 expect(parameter.keyword, isNull); | 6919 expect(parameter.keyword, isNull); |
| 6922 expect(parameter.type, isNull); | 6920 expect(parameter.type, isNull); |
| 6923 expect(parameter.identifier, isNotNull); | 6921 expect(parameter.identifier, isNotNull); |
| 6924 FormalParameterList parameterList = parameter.parameters; | 6922 FormalParameterList parameterList = parameter.parameters; |
| 6925 expect(parameterList, isNotNull); | 6923 expect(parameterList, isNotNull); |
| 6926 expect(parameterList.parameters, hasLength(1)); | 6924 expect(parameterList.parameters, hasLength(1)); |
| 6927 } | 6925 } |
| 6928 | 6926 |
| 6929 void test_parseNormalFormalParameter_field_function_noNested() { | 6927 void test_parseNormalFormalParameter_field_function_noNested() { |
| 6930 FieldFormalParameter parameter = ParserTestCase.parse4("parseNormalFormalPar
ameter", "this.a())", []); | 6928 FieldFormalParameter parameter = ParserTestCase.parse4("parseNormalFormalPar
ameter", "this.a())"); |
| 6931 expect(parameter.keyword, isNull); | 6929 expect(parameter.keyword, isNull); |
| 6932 expect(parameter.type, isNull); | 6930 expect(parameter.type, isNull); |
| 6933 expect(parameter.identifier, isNotNull); | 6931 expect(parameter.identifier, isNotNull); |
| 6934 FormalParameterList parameterList = parameter.parameters; | 6932 FormalParameterList parameterList = parameter.parameters; |
| 6935 expect(parameterList, isNotNull); | 6933 expect(parameterList, isNotNull); |
| 6936 expect(parameterList.parameters, hasLength(0)); | 6934 expect(parameterList.parameters, hasLength(0)); |
| 6937 } | 6935 } |
| 6938 | 6936 |
| 6939 void test_parseNormalFormalParameter_field_noType() { | 6937 void test_parseNormalFormalParameter_field_noType() { |
| 6940 FieldFormalParameter parameter = ParserTestCase.parse4("parseNormalFormalPar
ameter", "this.a)", []); | 6938 FieldFormalParameter parameter = ParserTestCase.parse4("parseNormalFormalPar
ameter", "this.a)"); |
| 6941 expect(parameter.keyword, isNull); | 6939 expect(parameter.keyword, isNull); |
| 6942 expect(parameter.type, isNull); | 6940 expect(parameter.type, isNull); |
| 6943 expect(parameter.identifier, isNotNull); | 6941 expect(parameter.identifier, isNotNull); |
| 6944 expect(parameter.parameters, isNull); | 6942 expect(parameter.parameters, isNull); |
| 6945 } | 6943 } |
| 6946 | 6944 |
| 6947 void test_parseNormalFormalParameter_field_type() { | 6945 void test_parseNormalFormalParameter_field_type() { |
| 6948 FieldFormalParameter parameter = ParserTestCase.parse4("parseNormalFormalPar
ameter", "A this.a)", []); | 6946 FieldFormalParameter parameter = ParserTestCase.parse4("parseNormalFormalPar
ameter", "A this.a)"); |
| 6949 expect(parameter.keyword, isNull); | 6947 expect(parameter.keyword, isNull); |
| 6950 expect(parameter.type, isNotNull); | 6948 expect(parameter.type, isNotNull); |
| 6951 expect(parameter.identifier, isNotNull); | 6949 expect(parameter.identifier, isNotNull); |
| 6952 expect(parameter.parameters, isNull); | 6950 expect(parameter.parameters, isNull); |
| 6953 } | 6951 } |
| 6954 | 6952 |
| 6955 void test_parseNormalFormalParameter_field_var() { | 6953 void test_parseNormalFormalParameter_field_var() { |
| 6956 FieldFormalParameter parameter = ParserTestCase.parse4("parseNormalFormalPar
ameter", "var this.a)", []); | 6954 FieldFormalParameter parameter = ParserTestCase.parse4("parseNormalFormalPar
ameter", "var this.a)"); |
| 6957 expect(parameter.keyword, isNotNull); | 6955 expect(parameter.keyword, isNotNull); |
| 6958 expect(parameter.type, isNull); | 6956 expect(parameter.type, isNull); |
| 6959 expect(parameter.identifier, isNotNull); | 6957 expect(parameter.identifier, isNotNull); |
| 6960 expect(parameter.parameters, isNull); | 6958 expect(parameter.parameters, isNull); |
| 6961 } | 6959 } |
| 6962 | 6960 |
| 6963 void test_parseNormalFormalParameter_function_noType() { | 6961 void test_parseNormalFormalParameter_function_noType() { |
| 6964 FunctionTypedFormalParameter parameter = ParserTestCase.parse4("parseNormalF
ormalParameter", "a())", []); | 6962 FunctionTypedFormalParameter parameter = ParserTestCase.parse4("parseNormalF
ormalParameter", "a())"); |
| 6965 expect(parameter.returnType, isNull); | 6963 expect(parameter.returnType, isNull); |
| 6966 expect(parameter.identifier, isNotNull); | 6964 expect(parameter.identifier, isNotNull); |
| 6967 expect(parameter.parameters, isNotNull); | 6965 expect(parameter.parameters, isNotNull); |
| 6968 } | 6966 } |
| 6969 | 6967 |
| 6970 void test_parseNormalFormalParameter_function_type() { | 6968 void test_parseNormalFormalParameter_function_type() { |
| 6971 FunctionTypedFormalParameter parameter = ParserTestCase.parse4("parseNormalF
ormalParameter", "A a())", []); | 6969 FunctionTypedFormalParameter parameter = ParserTestCase.parse4("parseNormalF
ormalParameter", "A a())"); |
| 6972 expect(parameter.returnType, isNotNull); | 6970 expect(parameter.returnType, isNotNull); |
| 6973 expect(parameter.identifier, isNotNull); | 6971 expect(parameter.identifier, isNotNull); |
| 6974 expect(parameter.parameters, isNotNull); | 6972 expect(parameter.parameters, isNotNull); |
| 6975 } | 6973 } |
| 6976 | 6974 |
| 6977 void test_parseNormalFormalParameter_function_void() { | 6975 void test_parseNormalFormalParameter_function_void() { |
| 6978 FunctionTypedFormalParameter parameter = ParserTestCase.parse4("parseNormalF
ormalParameter", "void a())", []); | 6976 FunctionTypedFormalParameter parameter = ParserTestCase.parse4("parseNormalF
ormalParameter", "void a())"); |
| 6979 expect(parameter.returnType, isNotNull); | 6977 expect(parameter.returnType, isNotNull); |
| 6980 expect(parameter.identifier, isNotNull); | 6978 expect(parameter.identifier, isNotNull); |
| 6981 expect(parameter.parameters, isNotNull); | 6979 expect(parameter.parameters, isNotNull); |
| 6982 } | 6980 } |
| 6983 | 6981 |
| 6984 void test_parseNormalFormalParameter_simple_const_noType() { | 6982 void test_parseNormalFormalParameter_simple_const_noType() { |
| 6985 SimpleFormalParameter parameter = ParserTestCase.parse4("parseNormalFormalPa
rameter", "const a)", []); | 6983 SimpleFormalParameter parameter = ParserTestCase.parse4("parseNormalFormalPa
rameter", "const a)"); |
| 6986 expect(parameter.keyword, isNotNull); | 6984 expect(parameter.keyword, isNotNull); |
| 6987 expect(parameter.type, isNull); | 6985 expect(parameter.type, isNull); |
| 6988 expect(parameter.identifier, isNotNull); | 6986 expect(parameter.identifier, isNotNull); |
| 6989 } | 6987 } |
| 6990 | 6988 |
| 6991 void test_parseNormalFormalParameter_simple_const_type() { | 6989 void test_parseNormalFormalParameter_simple_const_type() { |
| 6992 SimpleFormalParameter parameter = ParserTestCase.parse4("parseNormalFormalPa
rameter", "const A a)", []); | 6990 SimpleFormalParameter parameter = ParserTestCase.parse4("parseNormalFormalPa
rameter", "const A a)"); |
| 6993 expect(parameter.keyword, isNotNull); | 6991 expect(parameter.keyword, isNotNull); |
| 6994 expect(parameter.type, isNotNull); | 6992 expect(parameter.type, isNotNull); |
| 6995 expect(parameter.identifier, isNotNull); | 6993 expect(parameter.identifier, isNotNull); |
| 6996 } | 6994 } |
| 6997 | 6995 |
| 6998 void test_parseNormalFormalParameter_simple_final_noType() { | 6996 void test_parseNormalFormalParameter_simple_final_noType() { |
| 6999 SimpleFormalParameter parameter = ParserTestCase.parse4("parseNormalFormalPa
rameter", "final a)", []); | 6997 SimpleFormalParameter parameter = ParserTestCase.parse4("parseNormalFormalPa
rameter", "final a)"); |
| 7000 expect(parameter.keyword, isNotNull); | 6998 expect(parameter.keyword, isNotNull); |
| 7001 expect(parameter.type, isNull); | 6999 expect(parameter.type, isNull); |
| 7002 expect(parameter.identifier, isNotNull); | 7000 expect(parameter.identifier, isNotNull); |
| 7003 } | 7001 } |
| 7004 | 7002 |
| 7005 void test_parseNormalFormalParameter_simple_final_type() { | 7003 void test_parseNormalFormalParameter_simple_final_type() { |
| 7006 SimpleFormalParameter parameter = ParserTestCase.parse4("parseNormalFormalPa
rameter", "final A a)", []); | 7004 SimpleFormalParameter parameter = ParserTestCase.parse4("parseNormalFormalPa
rameter", "final A a)"); |
| 7007 expect(parameter.keyword, isNotNull); | 7005 expect(parameter.keyword, isNotNull); |
| 7008 expect(parameter.type, isNotNull); | 7006 expect(parameter.type, isNotNull); |
| 7009 expect(parameter.identifier, isNotNull); | 7007 expect(parameter.identifier, isNotNull); |
| 7010 } | 7008 } |
| 7011 | 7009 |
| 7012 void test_parseNormalFormalParameter_simple_noType() { | 7010 void test_parseNormalFormalParameter_simple_noType() { |
| 7013 SimpleFormalParameter parameter = ParserTestCase.parse4("parseNormalFormalPa
rameter", "a)", []); | 7011 SimpleFormalParameter parameter = ParserTestCase.parse4("parseNormalFormalPa
rameter", "a)"); |
| 7014 expect(parameter.keyword, isNull); | 7012 expect(parameter.keyword, isNull); |
| 7015 expect(parameter.type, isNull); | 7013 expect(parameter.type, isNull); |
| 7016 expect(parameter.identifier, isNotNull); | 7014 expect(parameter.identifier, isNotNull); |
| 7017 } | 7015 } |
| 7018 | 7016 |
| 7019 void test_parseNormalFormalParameter_simple_type() { | 7017 void test_parseNormalFormalParameter_simple_type() { |
| 7020 SimpleFormalParameter parameter = ParserTestCase.parse4("parseNormalFormalPa
rameter", "A a)", []); | 7018 SimpleFormalParameter parameter = ParserTestCase.parse4("parseNormalFormalPa
rameter", "A a)"); |
| 7021 expect(parameter.keyword, isNull); | 7019 expect(parameter.keyword, isNull); |
| 7022 expect(parameter.type, isNotNull); | 7020 expect(parameter.type, isNotNull); |
| 7023 expect(parameter.identifier, isNotNull); | 7021 expect(parameter.identifier, isNotNull); |
| 7024 } | 7022 } |
| 7025 | 7023 |
| 7026 void test_parseOperator() { | 7024 void test_parseOperator() { |
| 7027 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); | 7025 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); |
| 7028 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); | 7026 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); |
| 7029 MethodDeclaration method = ParserTestCase.parse("parseOperator", <Object> [c
ommentAndMetadata(comment, []), null, returnType], "operator +(A a);"); | 7027 MethodDeclaration method = ParserTestCase.parse("parseOperator", <Object> [c
ommentAndMetadata(comment), null, returnType], "operator +(A a);"); |
| 7030 expect(method.body, isNotNull); | 7028 expect(method.body, isNotNull); |
| 7031 expect(method.documentationComment, comment); | 7029 expect(method.documentationComment, comment); |
| 7032 expect(method.externalKeyword, isNull); | 7030 expect(method.externalKeyword, isNull); |
| 7033 expect(method.modifierKeyword, isNull); | 7031 expect(method.modifierKeyword, isNull); |
| 7034 expect(method.name, isNotNull); | 7032 expect(method.name, isNotNull); |
| 7035 expect(method.operatorKeyword, isNotNull); | 7033 expect(method.operatorKeyword, isNotNull); |
| 7036 expect(method.parameters, isNotNull); | 7034 expect(method.parameters, isNotNull); |
| 7037 expect(method.propertyKeyword, isNull); | 7035 expect(method.propertyKeyword, isNull); |
| 7038 expect(method.returnType, returnType); | 7036 expect(method.returnType, returnType); |
| 7039 } | 7037 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 7051 | 7049 |
| 7052 void test_parsePartDirective_partOf() { | 7050 void test_parsePartDirective_partOf() { |
| 7053 PartOfDirective directive = ParserTestCase.parse("parsePartDirective", <Obje
ct> [emptyCommentAndMetadata()], "part of l;"); | 7051 PartOfDirective directive = ParserTestCase.parse("parsePartDirective", <Obje
ct> [emptyCommentAndMetadata()], "part of l;"); |
| 7054 expect(directive.partToken, isNotNull); | 7052 expect(directive.partToken, isNotNull); |
| 7055 expect(directive.ofToken, isNotNull); | 7053 expect(directive.ofToken, isNotNull); |
| 7056 expect(directive.libraryName, isNotNull); | 7054 expect(directive.libraryName, isNotNull); |
| 7057 expect(directive.semicolon, isNotNull); | 7055 expect(directive.semicolon, isNotNull); |
| 7058 } | 7056 } |
| 7059 | 7057 |
| 7060 void test_parsePostfixExpression_decrement() { | 7058 void test_parsePostfixExpression_decrement() { |
| 7061 PostfixExpression expression = ParserTestCase.parse4("parsePostfixExpression
", "i--", []); | 7059 PostfixExpression expression = ParserTestCase.parse4("parsePostfixExpression
", "i--"); |
| 7062 expect(expression.operand, isNotNull); | 7060 expect(expression.operand, isNotNull); |
| 7063 expect(expression.operator, isNotNull); | 7061 expect(expression.operator, isNotNull); |
| 7064 expect(expression.operator.type, TokenType.MINUS_MINUS); | 7062 expect(expression.operator.type, TokenType.MINUS_MINUS); |
| 7065 } | 7063 } |
| 7066 | 7064 |
| 7067 void test_parsePostfixExpression_increment() { | 7065 void test_parsePostfixExpression_increment() { |
| 7068 PostfixExpression expression = ParserTestCase.parse4("parsePostfixExpression
", "i++", []); | 7066 PostfixExpression expression = ParserTestCase.parse4("parsePostfixExpression
", "i++"); |
| 7069 expect(expression.operand, isNotNull); | 7067 expect(expression.operand, isNotNull); |
| 7070 expect(expression.operator, isNotNull); | 7068 expect(expression.operator, isNotNull); |
| 7071 expect(expression.operator.type, TokenType.PLUS_PLUS); | 7069 expect(expression.operator.type, TokenType.PLUS_PLUS); |
| 7072 } | 7070 } |
| 7073 | 7071 |
| 7074 void test_parsePostfixExpression_none_indexExpression() { | 7072 void test_parsePostfixExpression_none_indexExpression() { |
| 7075 IndexExpression expression = ParserTestCase.parse4("parsePostfixExpression",
"a[0]", []); | 7073 IndexExpression expression = ParserTestCase.parse4("parsePostfixExpression",
"a[0]"); |
| 7076 expect(expression.target, isNotNull); | 7074 expect(expression.target, isNotNull); |
| 7077 expect(expression.index, isNotNull); | 7075 expect(expression.index, isNotNull); |
| 7078 } | 7076 } |
| 7079 | 7077 |
| 7080 void test_parsePostfixExpression_none_methodInvocation() { | 7078 void test_parsePostfixExpression_none_methodInvocation() { |
| 7081 MethodInvocation expression = ParserTestCase.parse4("parsePostfixExpression"
, "a.m()", []); | 7079 MethodInvocation expression = ParserTestCase.parse4("parsePostfixExpression"
, "a.m()"); |
| 7082 expect(expression.target, isNotNull); | 7080 expect(expression.target, isNotNull); |
| 7083 expect(expression.methodName, isNotNull); | 7081 expect(expression.methodName, isNotNull); |
| 7084 expect(expression.argumentList, isNotNull); | 7082 expect(expression.argumentList, isNotNull); |
| 7085 } | 7083 } |
| 7086 | 7084 |
| 7087 void test_parsePostfixExpression_none_propertyAccess() { | 7085 void test_parsePostfixExpression_none_propertyAccess() { |
| 7088 PrefixedIdentifier expression = ParserTestCase.parse4("parsePostfixExpressio
n", "a.b", []); | 7086 PrefixedIdentifier expression = ParserTestCase.parse4("parsePostfixExpressio
n", "a.b"); |
| 7089 expect(expression.prefix, isNotNull); | 7087 expect(expression.prefix, isNotNull); |
| 7090 expect(expression.identifier, isNotNull); | 7088 expect(expression.identifier, isNotNull); |
| 7091 } | 7089 } |
| 7092 | 7090 |
| 7093 void test_parsePrefixedIdentifier_noPrefix() { | 7091 void test_parsePrefixedIdentifier_noPrefix() { |
| 7094 String lexeme = "bar"; | 7092 String lexeme = "bar"; |
| 7095 SimpleIdentifier identifier = ParserTestCase.parse4("parsePrefixedIdentifier
", lexeme, []); | 7093 SimpleIdentifier identifier = ParserTestCase.parse4("parsePrefixedIdentifier
", lexeme); |
| 7096 expect(identifier.token, isNotNull); | 7094 expect(identifier.token, isNotNull); |
| 7097 expect(identifier.name, lexeme); | 7095 expect(identifier.name, lexeme); |
| 7098 } | 7096 } |
| 7099 | 7097 |
| 7100 void test_parsePrefixedIdentifier_prefix() { | 7098 void test_parsePrefixedIdentifier_prefix() { |
| 7101 String lexeme = "foo.bar"; | 7099 String lexeme = "foo.bar"; |
| 7102 PrefixedIdentifier identifier = ParserTestCase.parse4("parsePrefixedIdentifi
er", lexeme, []); | 7100 PrefixedIdentifier identifier = ParserTestCase.parse4("parsePrefixedIdentifi
er", lexeme); |
| 7103 expect(identifier.prefix.name, "foo"); | 7101 expect(identifier.prefix.name, "foo"); |
| 7104 expect(identifier.period, isNotNull); | 7102 expect(identifier.period, isNotNull); |
| 7105 expect(identifier.identifier.name, "bar"); | 7103 expect(identifier.identifier.name, "bar"); |
| 7106 } | 7104 } |
| 7107 | 7105 |
| 7108 void test_parsePrimaryExpression_const() { | 7106 void test_parsePrimaryExpression_const() { |
| 7109 InstanceCreationExpression expression = ParserTestCase.parse4("parsePrimaryE
xpression", "const A()", []); | 7107 InstanceCreationExpression expression = ParserTestCase.parse4("parsePrimaryE
xpression", "const A()"); |
| 7110 expect(expression, isNotNull); | 7108 expect(expression, isNotNull); |
| 7111 } | 7109 } |
| 7112 | 7110 |
| 7113 void test_parsePrimaryExpression_double() { | 7111 void test_parsePrimaryExpression_double() { |
| 7114 String doubleLiteral = "3.2e4"; | 7112 String doubleLiteral = "3.2e4"; |
| 7115 DoubleLiteral literal = ParserTestCase.parse4("parsePrimaryExpression", doub
leLiteral, []); | 7113 DoubleLiteral literal = ParserTestCase.parse4("parsePrimaryExpression", doub
leLiteral); |
| 7116 expect(literal.literal, isNotNull); | 7114 expect(literal.literal, isNotNull); |
| 7117 expect(literal.value, double.parse(doubleLiteral)); | 7115 expect(literal.value, double.parse(doubleLiteral)); |
| 7118 } | 7116 } |
| 7119 | 7117 |
| 7120 void test_parsePrimaryExpression_false() { | 7118 void test_parsePrimaryExpression_false() { |
| 7121 BooleanLiteral literal = ParserTestCase.parse4("parsePrimaryExpression", "fa
lse", []); | 7119 BooleanLiteral literal = ParserTestCase.parse4("parsePrimaryExpression", "fa
lse"); |
| 7122 expect(literal.literal, isNotNull); | 7120 expect(literal.literal, isNotNull); |
| 7123 expect(literal.value, isFalse); | 7121 expect(literal.value, isFalse); |
| 7124 } | 7122 } |
| 7125 | 7123 |
| 7126 void test_parsePrimaryExpression_function_arguments() { | 7124 void test_parsePrimaryExpression_function_arguments() { |
| 7127 FunctionExpression expression = ParserTestCase.parse4("parsePrimaryExpressio
n", "(int i) => i + 1", []); | 7125 FunctionExpression expression = ParserTestCase.parse4("parsePrimaryExpressio
n", "(int i) => i + 1"); |
| 7128 expect(expression.parameters, isNotNull); | 7126 expect(expression.parameters, isNotNull); |
| 7129 expect(expression.body, isNotNull); | 7127 expect(expression.body, isNotNull); |
| 7130 } | 7128 } |
| 7131 | 7129 |
| 7132 void test_parsePrimaryExpression_function_noArguments() { | 7130 void test_parsePrimaryExpression_function_noArguments() { |
| 7133 FunctionExpression expression = ParserTestCase.parse4("parsePrimaryExpressio
n", "() => 42", []); | 7131 FunctionExpression expression = ParserTestCase.parse4("parsePrimaryExpressio
n", "() => 42"); |
| 7134 expect(expression.parameters, isNotNull); | 7132 expect(expression.parameters, isNotNull); |
| 7135 expect(expression.body, isNotNull); | 7133 expect(expression.body, isNotNull); |
| 7136 } | 7134 } |
| 7137 | 7135 |
| 7138 void test_parsePrimaryExpression_hex() { | 7136 void test_parsePrimaryExpression_hex() { |
| 7139 String hexLiteral = "3F"; | 7137 String hexLiteral = "3F"; |
| 7140 IntegerLiteral literal = ParserTestCase.parse4("parsePrimaryExpression", "0x
$hexLiteral", []); | 7138 IntegerLiteral literal = ParserTestCase.parse4("parsePrimaryExpression", "0x
$hexLiteral"); |
| 7141 expect(literal.literal, isNotNull); | 7139 expect(literal.literal, isNotNull); |
| 7142 expect(literal.value, int.parse(hexLiteral, radix: 16)); | 7140 expect(literal.value, int.parse(hexLiteral, radix: 16)); |
| 7143 } | 7141 } |
| 7144 | 7142 |
| 7145 void test_parsePrimaryExpression_identifier() { | 7143 void test_parsePrimaryExpression_identifier() { |
| 7146 SimpleIdentifier identifier = ParserTestCase.parse4("parsePrimaryExpression"
, "a", []); | 7144 SimpleIdentifier identifier = ParserTestCase.parse4("parsePrimaryExpression"
, "a"); |
| 7147 expect(identifier, isNotNull); | 7145 expect(identifier, isNotNull); |
| 7148 } | 7146 } |
| 7149 | 7147 |
| 7150 void test_parsePrimaryExpression_int() { | 7148 void test_parsePrimaryExpression_int() { |
| 7151 String intLiteral = "472"; | 7149 String intLiteral = "472"; |
| 7152 IntegerLiteral literal = ParserTestCase.parse4("parsePrimaryExpression", int
Literal, []); | 7150 IntegerLiteral literal = ParserTestCase.parse4("parsePrimaryExpression", int
Literal); |
| 7153 expect(literal.literal, isNotNull); | 7151 expect(literal.literal, isNotNull); |
| 7154 expect(literal.value, int.parse(intLiteral)); | 7152 expect(literal.value, int.parse(intLiteral)); |
| 7155 } | 7153 } |
| 7156 | 7154 |
| 7157 void test_parsePrimaryExpression_listLiteral() { | 7155 void test_parsePrimaryExpression_listLiteral() { |
| 7158 ListLiteral literal = ParserTestCase.parse4("parsePrimaryExpression", "[ ]",
[]); | 7156 ListLiteral literal = ParserTestCase.parse4("parsePrimaryExpression", "[ ]")
; |
| 7159 expect(literal, isNotNull); | 7157 expect(literal, isNotNull); |
| 7160 } | 7158 } |
| 7161 | 7159 |
| 7162 void test_parsePrimaryExpression_listLiteral_index() { | 7160 void test_parsePrimaryExpression_listLiteral_index() { |
| 7163 ListLiteral literal = ParserTestCase.parse4("parsePrimaryExpression", "[]",
[]); | 7161 ListLiteral literal = ParserTestCase.parse4("parsePrimaryExpression", "[]"); |
| 7164 expect(literal, isNotNull); | 7162 expect(literal, isNotNull); |
| 7165 } | 7163 } |
| 7166 | 7164 |
| 7167 void test_parsePrimaryExpression_listLiteral_typed() { | 7165 void test_parsePrimaryExpression_listLiteral_typed() { |
| 7168 ListLiteral literal = ParserTestCase.parse4("parsePrimaryExpression", "<A>[
]", []); | 7166 ListLiteral literal = ParserTestCase.parse4("parsePrimaryExpression", "<A>[
]"); |
| 7169 expect(literal.typeArguments, isNotNull); | 7167 expect(literal.typeArguments, isNotNull); |
| 7170 expect(literal.typeArguments.arguments, hasLength(1)); | 7168 expect(literal.typeArguments.arguments, hasLength(1)); |
| 7171 } | 7169 } |
| 7172 | 7170 |
| 7173 void test_parsePrimaryExpression_mapLiteral() { | 7171 void test_parsePrimaryExpression_mapLiteral() { |
| 7174 MapLiteral literal = ParserTestCase.parse4("parsePrimaryExpression", "{}", [
]); | 7172 MapLiteral literal = ParserTestCase.parse4("parsePrimaryExpression", "{}"); |
| 7175 expect(literal, isNotNull); | 7173 expect(literal, isNotNull); |
| 7176 } | 7174 } |
| 7177 | 7175 |
| 7178 void test_parsePrimaryExpression_mapLiteral_typed() { | 7176 void test_parsePrimaryExpression_mapLiteral_typed() { |
| 7179 MapLiteral literal = ParserTestCase.parse4("parsePrimaryExpression", "<A, B>
{}", []); | 7177 MapLiteral literal = ParserTestCase.parse4("parsePrimaryExpression", "<A, B>
{}"); |
| 7180 expect(literal.typeArguments, isNotNull); | 7178 expect(literal.typeArguments, isNotNull); |
| 7181 expect(literal.typeArguments.arguments, hasLength(2)); | 7179 expect(literal.typeArguments.arguments, hasLength(2)); |
| 7182 } | 7180 } |
| 7183 | 7181 |
| 7184 void test_parsePrimaryExpression_new() { | 7182 void test_parsePrimaryExpression_new() { |
| 7185 InstanceCreationExpression expression = ParserTestCase.parse4("parsePrimaryE
xpression", "new A()", []); | 7183 InstanceCreationExpression expression = ParserTestCase.parse4("parsePrimaryE
xpression", "new A()"); |
| 7186 expect(expression, isNotNull); | 7184 expect(expression, isNotNull); |
| 7187 } | 7185 } |
| 7188 | 7186 |
| 7189 void test_parsePrimaryExpression_null() { | 7187 void test_parsePrimaryExpression_null() { |
| 7190 NullLiteral literal = ParserTestCase.parse4("parsePrimaryExpression", "null"
, []); | 7188 NullLiteral literal = ParserTestCase.parse4("parsePrimaryExpression", "null"
); |
| 7191 expect(literal.literal, isNotNull); | 7189 expect(literal.literal, isNotNull); |
| 7192 } | 7190 } |
| 7193 | 7191 |
| 7194 void test_parsePrimaryExpression_parenthesized() { | 7192 void test_parsePrimaryExpression_parenthesized() { |
| 7195 ParenthesizedExpression expression = ParserTestCase.parse4("parsePrimaryExpr
ession", "(x)", []); | 7193 ParenthesizedExpression expression = ParserTestCase.parse4("parsePrimaryExpr
ession", "(x)"); |
| 7196 expect(expression, isNotNull); | 7194 expect(expression, isNotNull); |
| 7197 } | 7195 } |
| 7198 | 7196 |
| 7199 void test_parsePrimaryExpression_string() { | 7197 void test_parsePrimaryExpression_string() { |
| 7200 SimpleStringLiteral literal = ParserTestCase.parse4("parsePrimaryExpression"
, "\"string\"", []); | 7198 SimpleStringLiteral literal = ParserTestCase.parse4("parsePrimaryExpression"
, "\"string\""); |
| 7201 expect(literal.isMultiline, isFalse); | 7199 expect(literal.isMultiline, isFalse); |
| 7202 expect(literal.isRaw, isFalse); | 7200 expect(literal.isRaw, isFalse); |
| 7203 expect(literal.value, "string"); | 7201 expect(literal.value, "string"); |
| 7204 } | 7202 } |
| 7205 | 7203 |
| 7206 void test_parsePrimaryExpression_string_multiline() { | 7204 void test_parsePrimaryExpression_string_multiline() { |
| 7207 SimpleStringLiteral literal = ParserTestCase.parse4("parsePrimaryExpression"
, "'''string'''", []); | 7205 SimpleStringLiteral literal = ParserTestCase.parse4("parsePrimaryExpression"
, "'''string'''"); |
| 7208 expect(literal.isMultiline, isTrue); | 7206 expect(literal.isMultiline, isTrue); |
| 7209 expect(literal.isRaw, isFalse); | 7207 expect(literal.isRaw, isFalse); |
| 7210 expect(literal.value, "string"); | 7208 expect(literal.value, "string"); |
| 7211 } | 7209 } |
| 7212 | 7210 |
| 7213 void test_parsePrimaryExpression_string_raw() { | 7211 void test_parsePrimaryExpression_string_raw() { |
| 7214 SimpleStringLiteral literal = ParserTestCase.parse4("parsePrimaryExpression"
, "r'string'", []); | 7212 SimpleStringLiteral literal = ParserTestCase.parse4("parsePrimaryExpression"
, "r'string'"); |
| 7215 expect(literal.isMultiline, isFalse); | 7213 expect(literal.isMultiline, isFalse); |
| 7216 expect(literal.isRaw, isTrue); | 7214 expect(literal.isRaw, isTrue); |
| 7217 expect(literal.value, "string"); | 7215 expect(literal.value, "string"); |
| 7218 } | 7216 } |
| 7219 | 7217 |
| 7220 void test_parsePrimaryExpression_super() { | 7218 void test_parsePrimaryExpression_super() { |
| 7221 PropertyAccess propertyAccess = ParserTestCase.parse4("parsePrimaryExpressio
n", "super.x", []); | 7219 PropertyAccess propertyAccess = ParserTestCase.parse4("parsePrimaryExpressio
n", "super.x"); |
| 7222 expect(propertyAccess.target is SuperExpression, isTrue); | 7220 expect(propertyAccess.target is SuperExpression, isTrue); |
| 7223 expect(propertyAccess.operator, isNotNull); | 7221 expect(propertyAccess.operator, isNotNull); |
| 7224 expect(propertyAccess.operator.type, TokenType.PERIOD); | 7222 expect(propertyAccess.operator.type, TokenType.PERIOD); |
| 7225 expect(propertyAccess.propertyName, isNotNull); | 7223 expect(propertyAccess.propertyName, isNotNull); |
| 7226 } | 7224 } |
| 7227 | 7225 |
| 7228 void test_parsePrimaryExpression_this() { | 7226 void test_parsePrimaryExpression_this() { |
| 7229 ThisExpression expression = ParserTestCase.parse4("parsePrimaryExpression",
"this", []); | 7227 ThisExpression expression = ParserTestCase.parse4("parsePrimaryExpression",
"this"); |
| 7230 expect(expression.keyword, isNotNull); | 7228 expect(expression.keyword, isNotNull); |
| 7231 } | 7229 } |
| 7232 | 7230 |
| 7233 void test_parsePrimaryExpression_true() { | 7231 void test_parsePrimaryExpression_true() { |
| 7234 BooleanLiteral literal = ParserTestCase.parse4("parsePrimaryExpression", "tr
ue", []); | 7232 BooleanLiteral literal = ParserTestCase.parse4("parsePrimaryExpression", "tr
ue"); |
| 7235 expect(literal.literal, isNotNull); | 7233 expect(literal.literal, isNotNull); |
| 7236 expect(literal.value, isTrue); | 7234 expect(literal.value, isTrue); |
| 7237 } | 7235 } |
| 7238 | 7236 |
| 7239 void test_Parser() { | 7237 void test_Parser() { |
| 7240 expect(new Parser(null, null), isNotNull); | 7238 expect(new Parser(null, null), isNotNull); |
| 7241 } | 7239 } |
| 7242 | 7240 |
| 7243 void test_parseRedirectingConstructorInvocation_named() { | 7241 void test_parseRedirectingConstructorInvocation_named() { |
| 7244 RedirectingConstructorInvocation invocation = ParserTestCase.parse4("parseRe
directingConstructorInvocation", "this.a()", []); | 7242 RedirectingConstructorInvocation invocation = ParserTestCase.parse4("parseRe
directingConstructorInvocation", "this.a()"); |
| 7245 expect(invocation.argumentList, isNotNull); | 7243 expect(invocation.argumentList, isNotNull); |
| 7246 expect(invocation.constructorName, isNotNull); | 7244 expect(invocation.constructorName, isNotNull); |
| 7247 expect(invocation.keyword, isNotNull); | 7245 expect(invocation.keyword, isNotNull); |
| 7248 expect(invocation.period, isNotNull); | 7246 expect(invocation.period, isNotNull); |
| 7249 } | 7247 } |
| 7250 | 7248 |
| 7251 void test_parseRedirectingConstructorInvocation_unnamed() { | 7249 void test_parseRedirectingConstructorInvocation_unnamed() { |
| 7252 RedirectingConstructorInvocation invocation = ParserTestCase.parse4("parseRe
directingConstructorInvocation", "this()", []); | 7250 RedirectingConstructorInvocation invocation = ParserTestCase.parse4("parseRe
directingConstructorInvocation", "this()"); |
| 7253 expect(invocation.argumentList, isNotNull); | 7251 expect(invocation.argumentList, isNotNull); |
| 7254 expect(invocation.constructorName, isNull); | 7252 expect(invocation.constructorName, isNull); |
| 7255 expect(invocation.keyword, isNotNull); | 7253 expect(invocation.keyword, isNotNull); |
| 7256 expect(invocation.period, isNull); | 7254 expect(invocation.period, isNull); |
| 7257 } | 7255 } |
| 7258 | 7256 |
| 7259 void test_parseRelationalExpression_as() { | 7257 void test_parseRelationalExpression_as() { |
| 7260 AsExpression expression = ParserTestCase.parse4("parseRelationalExpression",
"x as Y", []); | 7258 AsExpression expression = ParserTestCase.parse4("parseRelationalExpression",
"x as Y"); |
| 7261 expect(expression.expression, isNotNull); | 7259 expect(expression.expression, isNotNull); |
| 7262 expect(expression.asOperator, isNotNull); | 7260 expect(expression.asOperator, isNotNull); |
| 7263 expect(expression.type, isNotNull); | 7261 expect(expression.type, isNotNull); |
| 7264 } | 7262 } |
| 7265 | 7263 |
| 7266 void test_parseRelationalExpression_is() { | 7264 void test_parseRelationalExpression_is() { |
| 7267 IsExpression expression = ParserTestCase.parse4("parseRelationalExpression",
"x is y", []); | 7265 IsExpression expression = ParserTestCase.parse4("parseRelationalExpression",
"x is y"); |
| 7268 expect(expression.expression, isNotNull); | 7266 expect(expression.expression, isNotNull); |
| 7269 expect(expression.isOperator, isNotNull); | 7267 expect(expression.isOperator, isNotNull); |
| 7270 expect(expression.notOperator, isNull); | 7268 expect(expression.notOperator, isNull); |
| 7271 expect(expression.type, isNotNull); | 7269 expect(expression.type, isNotNull); |
| 7272 } | 7270 } |
| 7273 | 7271 |
| 7274 void test_parseRelationalExpression_isNot() { | 7272 void test_parseRelationalExpression_isNot() { |
| 7275 IsExpression expression = ParserTestCase.parse4("parseRelationalExpression",
"x is! y", []); | 7273 IsExpression expression = ParserTestCase.parse4("parseRelationalExpression",
"x is! y"); |
| 7276 expect(expression.expression, isNotNull); | 7274 expect(expression.expression, isNotNull); |
| 7277 expect(expression.isOperator, isNotNull); | 7275 expect(expression.isOperator, isNotNull); |
| 7278 expect(expression.notOperator, isNotNull); | 7276 expect(expression.notOperator, isNotNull); |
| 7279 expect(expression.type, isNotNull); | 7277 expect(expression.type, isNotNull); |
| 7280 } | 7278 } |
| 7281 | 7279 |
| 7282 void test_parseRelationalExpression_normal() { | 7280 void test_parseRelationalExpression_normal() { |
| 7283 BinaryExpression expression = ParserTestCase.parse4("parseRelationalExpressi
on", "x < y", []); | 7281 BinaryExpression expression = ParserTestCase.parse4("parseRelationalExpressi
on", "x < y"); |
| 7284 expect(expression.leftOperand, isNotNull); | 7282 expect(expression.leftOperand, isNotNull); |
| 7285 expect(expression.operator, isNotNull); | 7283 expect(expression.operator, isNotNull); |
| 7286 expect(expression.operator.type, TokenType.LT); | 7284 expect(expression.operator.type, TokenType.LT); |
| 7287 expect(expression.rightOperand, isNotNull); | 7285 expect(expression.rightOperand, isNotNull); |
| 7288 } | 7286 } |
| 7289 | 7287 |
| 7290 void test_parseRelationalExpression_super() { | 7288 void test_parseRelationalExpression_super() { |
| 7291 BinaryExpression expression = ParserTestCase.parse4("parseRelationalExpressi
on", "super < y", []); | 7289 BinaryExpression expression = ParserTestCase.parse4("parseRelationalExpressi
on", "super < y"); |
| 7292 expect(expression.leftOperand, isNotNull); | 7290 expect(expression.leftOperand, isNotNull); |
| 7293 expect(expression.operator, isNotNull); | 7291 expect(expression.operator, isNotNull); |
| 7294 expect(expression.operator.type, TokenType.LT); | 7292 expect(expression.operator.type, TokenType.LT); |
| 7295 expect(expression.rightOperand, isNotNull); | 7293 expect(expression.rightOperand, isNotNull); |
| 7296 } | 7294 } |
| 7297 | 7295 |
| 7298 void test_parseRethrowExpression() { | 7296 void test_parseRethrowExpression() { |
| 7299 RethrowExpression expression = ParserTestCase.parse4("parseRethrowExpression
", "rethrow;", []); | 7297 RethrowExpression expression = ParserTestCase.parse4("parseRethrowExpression
", "rethrow;"); |
| 7300 expect(expression.keyword, isNotNull); | 7298 expect(expression.keyword, isNotNull); |
| 7301 } | 7299 } |
| 7302 | 7300 |
| 7303 void test_parseReturnStatement_noValue() { | 7301 void test_parseReturnStatement_noValue() { |
| 7304 ReturnStatement statement = ParserTestCase.parse4("parseReturnStatement", "r
eturn;", []); | 7302 ReturnStatement statement = ParserTestCase.parse4("parseReturnStatement", "r
eturn;"); |
| 7305 expect(statement.keyword, isNotNull); | 7303 expect(statement.keyword, isNotNull); |
| 7306 expect(statement.expression, isNull); | 7304 expect(statement.expression, isNull); |
| 7307 expect(statement.semicolon, isNotNull); | 7305 expect(statement.semicolon, isNotNull); |
| 7308 } | 7306 } |
| 7309 | 7307 |
| 7310 void test_parseReturnStatement_value() { | 7308 void test_parseReturnStatement_value() { |
| 7311 ReturnStatement statement = ParserTestCase.parse4("parseReturnStatement", "r
eturn x;", []); | 7309 ReturnStatement statement = ParserTestCase.parse4("parseReturnStatement", "r
eturn x;"); |
| 7312 expect(statement.keyword, isNotNull); | 7310 expect(statement.keyword, isNotNull); |
| 7313 expect(statement.expression, isNotNull); | 7311 expect(statement.expression, isNotNull); |
| 7314 expect(statement.semicolon, isNotNull); | 7312 expect(statement.semicolon, isNotNull); |
| 7315 } | 7313 } |
| 7316 | 7314 |
| 7317 void test_parseReturnType_nonVoid() { | 7315 void test_parseReturnType_nonVoid() { |
| 7318 TypeName typeName = ParserTestCase.parse4("parseReturnType", "A<B>", []); | 7316 TypeName typeName = ParserTestCase.parse4("parseReturnType", "A<B>"); |
| 7319 expect(typeName.name, isNotNull); | 7317 expect(typeName.name, isNotNull); |
| 7320 expect(typeName.typeArguments, isNotNull); | 7318 expect(typeName.typeArguments, isNotNull); |
| 7321 } | 7319 } |
| 7322 | 7320 |
| 7323 void test_parseReturnType_void() { | 7321 void test_parseReturnType_void() { |
| 7324 TypeName typeName = ParserTestCase.parse4("parseReturnType", "void", []); | 7322 TypeName typeName = ParserTestCase.parse4("parseReturnType", "void"); |
| 7325 expect(typeName.name, isNotNull); | 7323 expect(typeName.name, isNotNull); |
| 7326 expect(typeName.typeArguments, isNull); | 7324 expect(typeName.typeArguments, isNull); |
| 7327 } | 7325 } |
| 7328 | 7326 |
| 7329 void test_parseSetter_nonStatic() { | 7327 void test_parseSetter_nonStatic() { |
| 7330 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); | 7328 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); |
| 7331 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); | 7329 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); |
| 7332 MethodDeclaration method = ParserTestCase.parse("parseSetter", <Object> [com
mentAndMetadata(comment, []), null, null, returnType], "set a(var x);"); | 7330 MethodDeclaration method = ParserTestCase.parse("parseSetter", <Object> [com
mentAndMetadata(comment), null, null, returnType], "set a(var x);"); |
| 7333 expect(method.body, isNotNull); | 7331 expect(method.body, isNotNull); |
| 7334 expect(method.documentationComment, comment); | 7332 expect(method.documentationComment, comment); |
| 7335 expect(method.externalKeyword, isNull); | 7333 expect(method.externalKeyword, isNull); |
| 7336 expect(method.modifierKeyword, isNull); | 7334 expect(method.modifierKeyword, isNull); |
| 7337 expect(method.name, isNotNull); | 7335 expect(method.name, isNotNull); |
| 7338 expect(method.operatorKeyword, isNull); | 7336 expect(method.operatorKeyword, isNull); |
| 7339 expect(method.parameters, isNotNull); | 7337 expect(method.parameters, isNotNull); |
| 7340 expect(method.propertyKeyword, isNotNull); | 7338 expect(method.propertyKeyword, isNotNull); |
| 7341 expect(method.returnType, returnType); | 7339 expect(method.returnType, returnType); |
| 7342 } | 7340 } |
| 7343 | 7341 |
| 7344 void test_parseSetter_static() { | 7342 void test_parseSetter_static() { |
| 7345 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); | 7343 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); |
| 7346 Token staticKeyword = TokenFactory.tokenFromKeyword(Keyword.STATIC); | 7344 Token staticKeyword = TokenFactory.tokenFromKeyword(Keyword.STATIC); |
| 7347 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); | 7345 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); |
| 7348 MethodDeclaration method = ParserTestCase.parse("parseSetter", <Object> [ | 7346 MethodDeclaration method = ParserTestCase.parse("parseSetter", <Object> [ |
| 7349 commentAndMetadata(comment, []), | 7347 commentAndMetadata(comment), |
| 7350 null, | 7348 null, |
| 7351 staticKeyword, | 7349 staticKeyword, |
| 7352 returnType], "set a(var x) {}"); | 7350 returnType], "set a(var x) {}"); |
| 7353 expect(method.body, isNotNull); | 7351 expect(method.body, isNotNull); |
| 7354 expect(method.documentationComment, comment); | 7352 expect(method.documentationComment, comment); |
| 7355 expect(method.externalKeyword, isNull); | 7353 expect(method.externalKeyword, isNull); |
| 7356 expect(method.modifierKeyword, staticKeyword); | 7354 expect(method.modifierKeyword, staticKeyword); |
| 7357 expect(method.name, isNotNull); | 7355 expect(method.name, isNotNull); |
| 7358 expect(method.operatorKeyword, isNull); | 7356 expect(method.operatorKeyword, isNull); |
| 7359 expect(method.parameters, isNotNull); | 7357 expect(method.parameters, isNotNull); |
| 7360 expect(method.propertyKeyword, isNotNull); | 7358 expect(method.propertyKeyword, isNotNull); |
| 7361 expect(method.returnType, returnType); | 7359 expect(method.returnType, returnType); |
| 7362 } | 7360 } |
| 7363 | 7361 |
| 7364 void test_parseShiftExpression_normal() { | 7362 void test_parseShiftExpression_normal() { |
| 7365 BinaryExpression expression = ParserTestCase.parse4("parseShiftExpression",
"x << y", []); | 7363 BinaryExpression expression = ParserTestCase.parse4("parseShiftExpression",
"x << y"); |
| 7366 expect(expression.leftOperand, isNotNull); | 7364 expect(expression.leftOperand, isNotNull); |
| 7367 expect(expression.operator, isNotNull); | 7365 expect(expression.operator, isNotNull); |
| 7368 expect(expression.operator.type, TokenType.LT_LT); | 7366 expect(expression.operator.type, TokenType.LT_LT); |
| 7369 expect(expression.rightOperand, isNotNull); | 7367 expect(expression.rightOperand, isNotNull); |
| 7370 } | 7368 } |
| 7371 | 7369 |
| 7372 void test_parseShiftExpression_super() { | 7370 void test_parseShiftExpression_super() { |
| 7373 BinaryExpression expression = ParserTestCase.parse4("parseShiftExpression",
"super << y", []); | 7371 BinaryExpression expression = ParserTestCase.parse4("parseShiftExpression",
"super << y"); |
| 7374 expect(expression.leftOperand, isNotNull); | 7372 expect(expression.leftOperand, isNotNull); |
| 7375 expect(expression.operator, isNotNull); | 7373 expect(expression.operator, isNotNull); |
| 7376 expect(expression.operator.type, TokenType.LT_LT); | 7374 expect(expression.operator.type, TokenType.LT_LT); |
| 7377 expect(expression.rightOperand, isNotNull); | 7375 expect(expression.rightOperand, isNotNull); |
| 7378 } | 7376 } |
| 7379 | 7377 |
| 7380 void test_parseSimpleIdentifier_builtInIdentifier() { | 7378 void test_parseSimpleIdentifier_builtInIdentifier() { |
| 7381 String lexeme = "as"; | 7379 String lexeme = "as"; |
| 7382 SimpleIdentifier identifier = ParserTestCase.parse4("parseSimpleIdentifier",
lexeme, []); | 7380 SimpleIdentifier identifier = ParserTestCase.parse4("parseSimpleIdentifier",
lexeme); |
| 7383 expect(identifier.token, isNotNull); | 7381 expect(identifier.token, isNotNull); |
| 7384 expect(identifier.name, lexeme); | 7382 expect(identifier.name, lexeme); |
| 7385 } | 7383 } |
| 7386 | 7384 |
| 7387 void test_parseSimpleIdentifier_normalIdentifier() { | 7385 void test_parseSimpleIdentifier_normalIdentifier() { |
| 7388 String lexeme = "foo"; | 7386 String lexeme = "foo"; |
| 7389 SimpleIdentifier identifier = ParserTestCase.parse4("parseSimpleIdentifier",
lexeme, []); | 7387 SimpleIdentifier identifier = ParserTestCase.parse4("parseSimpleIdentifier",
lexeme); |
| 7390 expect(identifier.token, isNotNull); | 7388 expect(identifier.token, isNotNull); |
| 7391 expect(identifier.name, lexeme); | 7389 expect(identifier.name, lexeme); |
| 7392 } | 7390 } |
| 7393 | 7391 |
| 7394 void test_parseSimpleIdentifier1_normalIdentifier() { | 7392 void test_parseSimpleIdentifier1_normalIdentifier() { |
| 7395 // TODO(brianwilkerson) Implement tests for this method. | 7393 // TODO(brianwilkerson) Implement tests for this method. |
| 7396 } | 7394 } |
| 7397 | 7395 |
| 7398 void test_parseStatement_functionDeclaration() { | 7396 void test_parseStatement_functionDeclaration() { |
| 7399 // TODO(brianwilkerson) Implement more tests for this method. | 7397 // TODO(brianwilkerson) Implement more tests for this method. |
| 7400 FunctionDeclarationStatement statement = ParserTestCase.parse4("parseStateme
nt", "int f(a, b) {};", []); | 7398 FunctionDeclarationStatement statement = ParserTestCase.parse4("parseStateme
nt", "int f(a, b) {};"); |
| 7401 expect(statement.functionDeclaration, isNotNull); | 7399 expect(statement.functionDeclaration, isNotNull); |
| 7402 } | 7400 } |
| 7403 | 7401 |
| 7404 void test_parseStatement_mulipleLabels() { | 7402 void test_parseStatement_mulipleLabels() { |
| 7405 LabeledStatement statement = ParserTestCase.parse4("parseStatement", "l: m:
return x;", []); | 7403 LabeledStatement statement = ParserTestCase.parse4("parseStatement", "l: m:
return x;"); |
| 7406 expect(statement.labels, hasLength(2)); | 7404 expect(statement.labels, hasLength(2)); |
| 7407 expect(statement.statement, isNotNull); | 7405 expect(statement.statement, isNotNull); |
| 7408 } | 7406 } |
| 7409 | 7407 |
| 7410 void test_parseStatement_noLabels() { | 7408 void test_parseStatement_noLabels() { |
| 7411 ParserTestCase.parse4("parseStatement", "return x;", []); | 7409 ParserTestCase.parse4("parseStatement", "return x;"); |
| 7412 } | 7410 } |
| 7413 | 7411 |
| 7414 void test_parseStatement_singleLabel() { | 7412 void test_parseStatement_singleLabel() { |
| 7415 LabeledStatement statement = ParserTestCase.parse4("parseStatement", "l: ret
urn x;", []); | 7413 LabeledStatement statement = ParserTestCase.parse4("parseStatement", "l: ret
urn x;"); |
| 7416 expect(statement.labels, hasLength(1)); | 7414 expect(statement.labels, hasLength(1)); |
| 7417 expect(statement.statement, isNotNull); | 7415 expect(statement.statement, isNotNull); |
| 7418 } | 7416 } |
| 7419 | 7417 |
| 7420 void test_parseStatements_multiple() { | 7418 void test_parseStatements_multiple() { |
| 7421 List<Statement> statements = ParserTestCase.parseStatements("return; return;
", 2, []); | 7419 List<Statement> statements = ParserTestCase.parseStatements("return; return;
", 2); |
| 7422 expect(statements, hasLength(2)); | 7420 expect(statements, hasLength(2)); |
| 7423 } | 7421 } |
| 7424 | 7422 |
| 7425 void test_parseStatements_single() { | 7423 void test_parseStatements_single() { |
| 7426 List<Statement> statements = ParserTestCase.parseStatements("return;", 1, []
); | 7424 List<Statement> statements = ParserTestCase.parseStatements("return;", 1); |
| 7427 expect(statements, hasLength(1)); | 7425 expect(statements, hasLength(1)); |
| 7428 } | 7426 } |
| 7429 | 7427 |
| 7430 void test_parseStringLiteral_adjacent() { | 7428 void test_parseStringLiteral_adjacent() { |
| 7431 AdjacentStrings literal = ParserTestCase.parse4("parseStringLiteral", "'a' '
b'", []); | 7429 AdjacentStrings literal = ParserTestCase.parse4("parseStringLiteral", "'a' '
b'"); |
| 7432 NodeList<StringLiteral> strings = literal.strings; | 7430 NodeList<StringLiteral> strings = literal.strings; |
| 7433 expect(strings, hasLength(2)); | 7431 expect(strings, hasLength(2)); |
| 7434 StringLiteral firstString = strings[0]; | 7432 StringLiteral firstString = strings[0]; |
| 7435 StringLiteral secondString = strings[1]; | 7433 StringLiteral secondString = strings[1]; |
| 7436 expect((firstString as SimpleStringLiteral).value, "a"); | 7434 expect((firstString as SimpleStringLiteral).value, "a"); |
| 7437 expect((secondString as SimpleStringLiteral).value, "b"); | 7435 expect((secondString as SimpleStringLiteral).value, "b"); |
| 7438 } | 7436 } |
| 7439 | 7437 |
| 7440 void test_parseStringLiteral_interpolated() { | 7438 void test_parseStringLiteral_interpolated() { |
| 7441 StringInterpolation literal = ParserTestCase.parse4("parseStringLiteral", "'
a \${b} c \$this d'", []); | 7439 StringInterpolation literal = ParserTestCase.parse4("parseStringLiteral", "'
a \${b} c \$this d'"); |
| 7442 NodeList<InterpolationElement> elements = literal.elements; | 7440 NodeList<InterpolationElement> elements = literal.elements; |
| 7443 expect(elements, hasLength(5)); | 7441 expect(elements, hasLength(5)); |
| 7444 expect(elements[0] is InterpolationString, isTrue); | 7442 expect(elements[0] is InterpolationString, isTrue); |
| 7445 expect(elements[1] is InterpolationExpression, isTrue); | 7443 expect(elements[1] is InterpolationExpression, isTrue); |
| 7446 expect(elements[2] is InterpolationString, isTrue); | 7444 expect(elements[2] is InterpolationString, isTrue); |
| 7447 expect(elements[3] is InterpolationExpression, isTrue); | 7445 expect(elements[3] is InterpolationExpression, isTrue); |
| 7448 expect(elements[4] is InterpolationString, isTrue); | 7446 expect(elements[4] is InterpolationString, isTrue); |
| 7449 } | 7447 } |
| 7450 | 7448 |
| 7451 void test_parseStringLiteral_single() { | 7449 void test_parseStringLiteral_single() { |
| 7452 SimpleStringLiteral literal = ParserTestCase.parse4("parseStringLiteral", "'
a'", []); | 7450 SimpleStringLiteral literal = ParserTestCase.parse4("parseStringLiteral", "'
a'"); |
| 7453 expect(literal.literal, isNotNull); | 7451 expect(literal.literal, isNotNull); |
| 7454 expect(literal.value, "a"); | 7452 expect(literal.value, "a"); |
| 7455 } | 7453 } |
| 7456 | 7454 |
| 7457 void test_parseSuperConstructorInvocation_named() { | 7455 void test_parseSuperConstructorInvocation_named() { |
| 7458 SuperConstructorInvocation invocation = ParserTestCase.parse4("parseSuperCon
structorInvocation", "super.a()", []); | 7456 SuperConstructorInvocation invocation = ParserTestCase.parse4("parseSuperCon
structorInvocation", "super.a()"); |
| 7459 expect(invocation.argumentList, isNotNull); | 7457 expect(invocation.argumentList, isNotNull); |
| 7460 expect(invocation.constructorName, isNotNull); | 7458 expect(invocation.constructorName, isNotNull); |
| 7461 expect(invocation.keyword, isNotNull); | 7459 expect(invocation.keyword, isNotNull); |
| 7462 expect(invocation.period, isNotNull); | 7460 expect(invocation.period, isNotNull); |
| 7463 } | 7461 } |
| 7464 | 7462 |
| 7465 void test_parseSuperConstructorInvocation_unnamed() { | 7463 void test_parseSuperConstructorInvocation_unnamed() { |
| 7466 SuperConstructorInvocation invocation = ParserTestCase.parse4("parseSuperCon
structorInvocation", "super()", []); | 7464 SuperConstructorInvocation invocation = ParserTestCase.parse4("parseSuperCon
structorInvocation", "super()"); |
| 7467 expect(invocation.argumentList, isNotNull); | 7465 expect(invocation.argumentList, isNotNull); |
| 7468 expect(invocation.constructorName, isNull); | 7466 expect(invocation.constructorName, isNull); |
| 7469 expect(invocation.keyword, isNotNull); | 7467 expect(invocation.keyword, isNotNull); |
| 7470 expect(invocation.period, isNull); | 7468 expect(invocation.period, isNull); |
| 7471 } | 7469 } |
| 7472 | 7470 |
| 7473 void test_parseSwitchStatement_case() { | 7471 void test_parseSwitchStatement_case() { |
| 7474 SwitchStatement statement = ParserTestCase.parse4("parseSwitchStatement", "s
witch (a) {case 1: return 'I';}", []); | 7472 SwitchStatement statement = ParserTestCase.parse4("parseSwitchStatement", "s
witch (a) {case 1: return 'I';}"); |
| 7475 expect(statement.keyword, isNotNull); | 7473 expect(statement.keyword, isNotNull); |
| 7476 expect(statement.leftParenthesis, isNotNull); | 7474 expect(statement.leftParenthesis, isNotNull); |
| 7477 expect(statement.expression, isNotNull); | 7475 expect(statement.expression, isNotNull); |
| 7478 expect(statement.rightParenthesis, isNotNull); | 7476 expect(statement.rightParenthesis, isNotNull); |
| 7479 expect(statement.leftBracket, isNotNull); | 7477 expect(statement.leftBracket, isNotNull); |
| 7480 expect(statement.members, hasLength(1)); | 7478 expect(statement.members, hasLength(1)); |
| 7481 expect(statement.rightBracket, isNotNull); | 7479 expect(statement.rightBracket, isNotNull); |
| 7482 } | 7480 } |
| 7483 | 7481 |
| 7484 void test_parseSwitchStatement_empty() { | 7482 void test_parseSwitchStatement_empty() { |
| 7485 SwitchStatement statement = ParserTestCase.parse4("parseSwitchStatement", "s
witch (a) {}", []); | 7483 SwitchStatement statement = ParserTestCase.parse4("parseSwitchStatement", "s
witch (a) {}"); |
| 7486 expect(statement.keyword, isNotNull); | 7484 expect(statement.keyword, isNotNull); |
| 7487 expect(statement.leftParenthesis, isNotNull); | 7485 expect(statement.leftParenthesis, isNotNull); |
| 7488 expect(statement.expression, isNotNull); | 7486 expect(statement.expression, isNotNull); |
| 7489 expect(statement.rightParenthesis, isNotNull); | 7487 expect(statement.rightParenthesis, isNotNull); |
| 7490 expect(statement.leftBracket, isNotNull); | 7488 expect(statement.leftBracket, isNotNull); |
| 7491 expect(statement.members, hasLength(0)); | 7489 expect(statement.members, hasLength(0)); |
| 7492 expect(statement.rightBracket, isNotNull); | 7490 expect(statement.rightBracket, isNotNull); |
| 7493 } | 7491 } |
| 7494 | 7492 |
| 7495 void test_parseSwitchStatement_labeledCase() { | 7493 void test_parseSwitchStatement_labeledCase() { |
| 7496 SwitchStatement statement = ParserTestCase.parse4("parseSwitchStatement", "s
witch (a) {l1: l2: l3: case(1):}", []); | 7494 SwitchStatement statement = ParserTestCase.parse4("parseSwitchStatement", "s
witch (a) {l1: l2: l3: case(1):}"); |
| 7497 expect(statement.keyword, isNotNull); | 7495 expect(statement.keyword, isNotNull); |
| 7498 expect(statement.leftParenthesis, isNotNull); | 7496 expect(statement.leftParenthesis, isNotNull); |
| 7499 expect(statement.expression, isNotNull); | 7497 expect(statement.expression, isNotNull); |
| 7500 expect(statement.rightParenthesis, isNotNull); | 7498 expect(statement.rightParenthesis, isNotNull); |
| 7501 expect(statement.leftBracket, isNotNull); | 7499 expect(statement.leftBracket, isNotNull); |
| 7502 expect(statement.members, hasLength(1)); | 7500 expect(statement.members, hasLength(1)); |
| 7503 expect(statement.members[0].labels, hasLength(3)); | 7501 expect(statement.members[0].labels, hasLength(3)); |
| 7504 expect(statement.rightBracket, isNotNull); | 7502 expect(statement.rightBracket, isNotNull); |
| 7505 } | 7503 } |
| 7506 | 7504 |
| 7507 void test_parseSwitchStatement_labeledStatementInCase() { | 7505 void test_parseSwitchStatement_labeledStatementInCase() { |
| 7508 SwitchStatement statement = ParserTestCase.parse4("parseSwitchStatement", "s
witch (a) {case 0: f(); l1: g(); break;}", []); | 7506 SwitchStatement statement = ParserTestCase.parse4("parseSwitchStatement", "s
witch (a) {case 0: f(); l1: g(); break;}"); |
| 7509 expect(statement.keyword, isNotNull); | 7507 expect(statement.keyword, isNotNull); |
| 7510 expect(statement.leftParenthesis, isNotNull); | 7508 expect(statement.leftParenthesis, isNotNull); |
| 7511 expect(statement.expression, isNotNull); | 7509 expect(statement.expression, isNotNull); |
| 7512 expect(statement.rightParenthesis, isNotNull); | 7510 expect(statement.rightParenthesis, isNotNull); |
| 7513 expect(statement.leftBracket, isNotNull); | 7511 expect(statement.leftBracket, isNotNull); |
| 7514 expect(statement.members, hasLength(1)); | 7512 expect(statement.members, hasLength(1)); |
| 7515 expect(statement.members[0].statements, hasLength(3)); | 7513 expect(statement.members[0].statements, hasLength(3)); |
| 7516 expect(statement.rightBracket, isNotNull); | 7514 expect(statement.rightBracket, isNotNull); |
| 7517 } | 7515 } |
| 7518 | 7516 |
| 7519 void test_parseSymbolLiteral_builtInIdentifier() { | 7517 void test_parseSymbolLiteral_builtInIdentifier() { |
| 7520 SymbolLiteral literal = ParserTestCase.parse4("parseSymbolLiteral", "#dynami
c.static.abstract", []); | 7518 SymbolLiteral literal = ParserTestCase.parse4("parseSymbolLiteral", "#dynami
c.static.abstract"); |
| 7521 expect(literal.poundSign, isNotNull); | 7519 expect(literal.poundSign, isNotNull); |
| 7522 List<Token> components = literal.components; | 7520 List<Token> components = literal.components; |
| 7523 expect(components, hasLength(3)); | 7521 expect(components, hasLength(3)); |
| 7524 expect(components[0].lexeme, "dynamic"); | 7522 expect(components[0].lexeme, "dynamic"); |
| 7525 expect(components[1].lexeme, "static"); | 7523 expect(components[1].lexeme, "static"); |
| 7526 expect(components[2].lexeme, "abstract"); | 7524 expect(components[2].lexeme, "abstract"); |
| 7527 } | 7525 } |
| 7528 | 7526 |
| 7529 void test_parseSymbolLiteral_multiple() { | 7527 void test_parseSymbolLiteral_multiple() { |
| 7530 SymbolLiteral literal = ParserTestCase.parse4("parseSymbolLiteral", "#a.b.c"
, []); | 7528 SymbolLiteral literal = ParserTestCase.parse4("parseSymbolLiteral", "#a.b.c"
); |
| 7531 expect(literal.poundSign, isNotNull); | 7529 expect(literal.poundSign, isNotNull); |
| 7532 List<Token> components = literal.components; | 7530 List<Token> components = literal.components; |
| 7533 expect(components, hasLength(3)); | 7531 expect(components, hasLength(3)); |
| 7534 expect(components[0].lexeme, "a"); | 7532 expect(components[0].lexeme, "a"); |
| 7535 expect(components[1].lexeme, "b"); | 7533 expect(components[1].lexeme, "b"); |
| 7536 expect(components[2].lexeme, "c"); | 7534 expect(components[2].lexeme, "c"); |
| 7537 } | 7535 } |
| 7538 | 7536 |
| 7539 void test_parseSymbolLiteral_operator() { | 7537 void test_parseSymbolLiteral_operator() { |
| 7540 SymbolLiteral literal = ParserTestCase.parse4("parseSymbolLiteral", "#==", [
]); | 7538 SymbolLiteral literal = ParserTestCase.parse4("parseSymbolLiteral", "#=="); |
| 7541 expect(literal.poundSign, isNotNull); | 7539 expect(literal.poundSign, isNotNull); |
| 7542 List<Token> components = literal.components; | 7540 List<Token> components = literal.components; |
| 7543 expect(components, hasLength(1)); | 7541 expect(components, hasLength(1)); |
| 7544 expect(components[0].lexeme, "=="); | 7542 expect(components[0].lexeme, "=="); |
| 7545 } | 7543 } |
| 7546 | 7544 |
| 7547 void test_parseSymbolLiteral_single() { | 7545 void test_parseSymbolLiteral_single() { |
| 7548 SymbolLiteral literal = ParserTestCase.parse4("parseSymbolLiteral", "#a", []
); | 7546 SymbolLiteral literal = ParserTestCase.parse4("parseSymbolLiteral", "#a"); |
| 7549 expect(literal.poundSign, isNotNull); | 7547 expect(literal.poundSign, isNotNull); |
| 7550 List<Token> components = literal.components; | 7548 List<Token> components = literal.components; |
| 7551 expect(components, hasLength(1)); | 7549 expect(components, hasLength(1)); |
| 7552 expect(components[0].lexeme, "a"); | 7550 expect(components[0].lexeme, "a"); |
| 7553 } | 7551 } |
| 7554 | 7552 |
| 7555 void test_parseSymbolLiteral_void() { | 7553 void test_parseSymbolLiteral_void() { |
| 7556 SymbolLiteral literal = ParserTestCase.parse4("parseSymbolLiteral", "#void",
[]); | 7554 SymbolLiteral literal = ParserTestCase.parse4("parseSymbolLiteral", "#void")
; |
| 7557 expect(literal.poundSign, isNotNull); | 7555 expect(literal.poundSign, isNotNull); |
| 7558 List<Token> components = literal.components; | 7556 List<Token> components = literal.components; |
| 7559 expect(components, hasLength(1)); | 7557 expect(components, hasLength(1)); |
| 7560 expect(components[0].lexeme, "void"); | 7558 expect(components[0].lexeme, "void"); |
| 7561 } | 7559 } |
| 7562 | 7560 |
| 7563 void test_parseThrowExpression() { | 7561 void test_parseThrowExpression() { |
| 7564 ThrowExpression expression = ParserTestCase.parse4("parseThrowExpression", "
throw x;", []); | 7562 ThrowExpression expression = ParserTestCase.parse4("parseThrowExpression", "
throw x;"); |
| 7565 expect(expression.keyword, isNotNull); | 7563 expect(expression.keyword, isNotNull); |
| 7566 expect(expression.expression, isNotNull); | 7564 expect(expression.expression, isNotNull); |
| 7567 } | 7565 } |
| 7568 | 7566 |
| 7569 void test_parseThrowExpressionWithoutCascade() { | 7567 void test_parseThrowExpressionWithoutCascade() { |
| 7570 ThrowExpression expression = ParserTestCase.parse4("parseThrowExpressionWith
outCascade", "throw x;", []); | 7568 ThrowExpression expression = ParserTestCase.parse4("parseThrowExpressionWith
outCascade", "throw x;"); |
| 7571 expect(expression.keyword, isNotNull); | 7569 expect(expression.keyword, isNotNull); |
| 7572 expect(expression.expression, isNotNull); | 7570 expect(expression.expression, isNotNull); |
| 7573 } | 7571 } |
| 7574 | 7572 |
| 7575 void test_parseTryStatement_catch() { | 7573 void test_parseTryStatement_catch() { |
| 7576 TryStatement statement = ParserTestCase.parse4("parseTryStatement", "try {}
catch (e) {}", []); | 7574 TryStatement statement = ParserTestCase.parse4("parseTryStatement", "try {}
catch (e) {}"); |
| 7577 expect(statement.tryKeyword, isNotNull); | 7575 expect(statement.tryKeyword, isNotNull); |
| 7578 expect(statement.body, isNotNull); | 7576 expect(statement.body, isNotNull); |
| 7579 NodeList<CatchClause> catchClauses = statement.catchClauses; | 7577 NodeList<CatchClause> catchClauses = statement.catchClauses; |
| 7580 expect(catchClauses, hasLength(1)); | 7578 expect(catchClauses, hasLength(1)); |
| 7581 CatchClause clause = catchClauses[0]; | 7579 CatchClause clause = catchClauses[0]; |
| 7582 expect(clause.onKeyword, isNull); | 7580 expect(clause.onKeyword, isNull); |
| 7583 expect(clause.exceptionType, isNull); | 7581 expect(clause.exceptionType, isNull); |
| 7584 expect(clause.catchKeyword, isNotNull); | 7582 expect(clause.catchKeyword, isNotNull); |
| 7585 expect(clause.exceptionParameter, isNotNull); | 7583 expect(clause.exceptionParameter, isNotNull); |
| 7586 expect(clause.comma, isNull); | 7584 expect(clause.comma, isNull); |
| 7587 expect(clause.stackTraceParameter, isNull); | 7585 expect(clause.stackTraceParameter, isNull); |
| 7588 expect(clause.body, isNotNull); | 7586 expect(clause.body, isNotNull); |
| 7589 expect(statement.finallyKeyword, isNull); | 7587 expect(statement.finallyKeyword, isNull); |
| 7590 expect(statement.finallyBlock, isNull); | 7588 expect(statement.finallyBlock, isNull); |
| 7591 } | 7589 } |
| 7592 | 7590 |
| 7593 void test_parseTryStatement_catch_finally() { | 7591 void test_parseTryStatement_catch_finally() { |
| 7594 TryStatement statement = ParserTestCase.parse4("parseTryStatement", "try {}
catch (e, s) {} finally {}", []); | 7592 TryStatement statement = ParserTestCase.parse4("parseTryStatement", "try {}
catch (e, s) {} finally {}"); |
| 7595 expect(statement.tryKeyword, isNotNull); | 7593 expect(statement.tryKeyword, isNotNull); |
| 7596 expect(statement.body, isNotNull); | 7594 expect(statement.body, isNotNull); |
| 7597 NodeList<CatchClause> catchClauses = statement.catchClauses; | 7595 NodeList<CatchClause> catchClauses = statement.catchClauses; |
| 7598 expect(catchClauses, hasLength(1)); | 7596 expect(catchClauses, hasLength(1)); |
| 7599 CatchClause clause = catchClauses[0]; | 7597 CatchClause clause = catchClauses[0]; |
| 7600 expect(clause.onKeyword, isNull); | 7598 expect(clause.onKeyword, isNull); |
| 7601 expect(clause.exceptionType, isNull); | 7599 expect(clause.exceptionType, isNull); |
| 7602 expect(clause.catchKeyword, isNotNull); | 7600 expect(clause.catchKeyword, isNotNull); |
| 7603 expect(clause.exceptionParameter, isNotNull); | 7601 expect(clause.exceptionParameter, isNotNull); |
| 7604 expect(clause.comma, isNotNull); | 7602 expect(clause.comma, isNotNull); |
| 7605 expect(clause.stackTraceParameter, isNotNull); | 7603 expect(clause.stackTraceParameter, isNotNull); |
| 7606 expect(clause.body, isNotNull); | 7604 expect(clause.body, isNotNull); |
| 7607 expect(statement.finallyKeyword, isNotNull); | 7605 expect(statement.finallyKeyword, isNotNull); |
| 7608 expect(statement.finallyBlock, isNotNull); | 7606 expect(statement.finallyBlock, isNotNull); |
| 7609 } | 7607 } |
| 7610 | 7608 |
| 7611 void test_parseTryStatement_finally() { | 7609 void test_parseTryStatement_finally() { |
| 7612 TryStatement statement = ParserTestCase.parse4("parseTryStatement", "try {}
finally {}", []); | 7610 TryStatement statement = ParserTestCase.parse4("parseTryStatement", "try {}
finally {}"); |
| 7613 expect(statement.tryKeyword, isNotNull); | 7611 expect(statement.tryKeyword, isNotNull); |
| 7614 expect(statement.body, isNotNull); | 7612 expect(statement.body, isNotNull); |
| 7615 expect(statement.catchClauses, hasLength(0)); | 7613 expect(statement.catchClauses, hasLength(0)); |
| 7616 expect(statement.finallyKeyword, isNotNull); | 7614 expect(statement.finallyKeyword, isNotNull); |
| 7617 expect(statement.finallyBlock, isNotNull); | 7615 expect(statement.finallyBlock, isNotNull); |
| 7618 } | 7616 } |
| 7619 | 7617 |
| 7620 void test_parseTryStatement_multiple() { | 7618 void test_parseTryStatement_multiple() { |
| 7621 TryStatement statement = ParserTestCase.parse4("parseTryStatement", "try {}
on NPE catch (e) {} on Error {} catch (e) {}", []); | 7619 TryStatement statement = ParserTestCase.parse4("parseTryStatement", "try {}
on NPE catch (e) {} on Error {} catch (e) {}"); |
| 7622 expect(statement.tryKeyword, isNotNull); | 7620 expect(statement.tryKeyword, isNotNull); |
| 7623 expect(statement.body, isNotNull); | 7621 expect(statement.body, isNotNull); |
| 7624 expect(statement.catchClauses, hasLength(3)); | 7622 expect(statement.catchClauses, hasLength(3)); |
| 7625 expect(statement.finallyKeyword, isNull); | 7623 expect(statement.finallyKeyword, isNull); |
| 7626 expect(statement.finallyBlock, isNull); | 7624 expect(statement.finallyBlock, isNull); |
| 7627 } | 7625 } |
| 7628 | 7626 |
| 7629 void test_parseTryStatement_on() { | 7627 void test_parseTryStatement_on() { |
| 7630 TryStatement statement = ParserTestCase.parse4("parseTryStatement", "try {}
on Error {}", []); | 7628 TryStatement statement = ParserTestCase.parse4("parseTryStatement", "try {}
on Error {}"); |
| 7631 expect(statement.tryKeyword, isNotNull); | 7629 expect(statement.tryKeyword, isNotNull); |
| 7632 expect(statement.body, isNotNull); | 7630 expect(statement.body, isNotNull); |
| 7633 NodeList<CatchClause> catchClauses = statement.catchClauses; | 7631 NodeList<CatchClause> catchClauses = statement.catchClauses; |
| 7634 expect(catchClauses, hasLength(1)); | 7632 expect(catchClauses, hasLength(1)); |
| 7635 CatchClause clause = catchClauses[0]; | 7633 CatchClause clause = catchClauses[0]; |
| 7636 expect(clause.onKeyword, isNotNull); | 7634 expect(clause.onKeyword, isNotNull); |
| 7637 expect(clause.exceptionType, isNotNull); | 7635 expect(clause.exceptionType, isNotNull); |
| 7638 expect(clause.catchKeyword, isNull); | 7636 expect(clause.catchKeyword, isNull); |
| 7639 expect(clause.exceptionParameter, isNull); | 7637 expect(clause.exceptionParameter, isNull); |
| 7640 expect(clause.comma, isNull); | 7638 expect(clause.comma, isNull); |
| 7641 expect(clause.stackTraceParameter, isNull); | 7639 expect(clause.stackTraceParameter, isNull); |
| 7642 expect(clause.body, isNotNull); | 7640 expect(clause.body, isNotNull); |
| 7643 expect(statement.finallyKeyword, isNull); | 7641 expect(statement.finallyKeyword, isNull); |
| 7644 expect(statement.finallyBlock, isNull); | 7642 expect(statement.finallyBlock, isNull); |
| 7645 } | 7643 } |
| 7646 | 7644 |
| 7647 void test_parseTryStatement_on_catch() { | 7645 void test_parseTryStatement_on_catch() { |
| 7648 TryStatement statement = ParserTestCase.parse4("parseTryStatement", "try {}
on Error catch (e, s) {}", []); | 7646 TryStatement statement = ParserTestCase.parse4("parseTryStatement", "try {}
on Error catch (e, s) {}"); |
| 7649 expect(statement.tryKeyword, isNotNull); | 7647 expect(statement.tryKeyword, isNotNull); |
| 7650 expect(statement.body, isNotNull); | 7648 expect(statement.body, isNotNull); |
| 7651 NodeList<CatchClause> catchClauses = statement.catchClauses; | 7649 NodeList<CatchClause> catchClauses = statement.catchClauses; |
| 7652 expect(catchClauses, hasLength(1)); | 7650 expect(catchClauses, hasLength(1)); |
| 7653 CatchClause clause = catchClauses[0]; | 7651 CatchClause clause = catchClauses[0]; |
| 7654 expect(clause.onKeyword, isNotNull); | 7652 expect(clause.onKeyword, isNotNull); |
| 7655 expect(clause.exceptionType, isNotNull); | 7653 expect(clause.exceptionType, isNotNull); |
| 7656 expect(clause.catchKeyword, isNotNull); | 7654 expect(clause.catchKeyword, isNotNull); |
| 7657 expect(clause.exceptionParameter, isNotNull); | 7655 expect(clause.exceptionParameter, isNotNull); |
| 7658 expect(clause.comma, isNotNull); | 7656 expect(clause.comma, isNotNull); |
| 7659 expect(clause.stackTraceParameter, isNotNull); | 7657 expect(clause.stackTraceParameter, isNotNull); |
| 7660 expect(clause.body, isNotNull); | 7658 expect(clause.body, isNotNull); |
| 7661 expect(statement.finallyKeyword, isNull); | 7659 expect(statement.finallyKeyword, isNull); |
| 7662 expect(statement.finallyBlock, isNull); | 7660 expect(statement.finallyBlock, isNull); |
| 7663 } | 7661 } |
| 7664 | 7662 |
| 7665 void test_parseTryStatement_on_catch_finally() { | 7663 void test_parseTryStatement_on_catch_finally() { |
| 7666 TryStatement statement = ParserTestCase.parse4("parseTryStatement", "try {}
on Error catch (e, s) {} finally {}", []); | 7664 TryStatement statement = ParserTestCase.parse4("parseTryStatement", "try {}
on Error catch (e, s) {} finally {}"); |
| 7667 expect(statement.tryKeyword, isNotNull); | 7665 expect(statement.tryKeyword, isNotNull); |
| 7668 expect(statement.body, isNotNull); | 7666 expect(statement.body, isNotNull); |
| 7669 NodeList<CatchClause> catchClauses = statement.catchClauses; | 7667 NodeList<CatchClause> catchClauses = statement.catchClauses; |
| 7670 expect(catchClauses, hasLength(1)); | 7668 expect(catchClauses, hasLength(1)); |
| 7671 CatchClause clause = catchClauses[0]; | 7669 CatchClause clause = catchClauses[0]; |
| 7672 expect(clause.onKeyword, isNotNull); | 7670 expect(clause.onKeyword, isNotNull); |
| 7673 expect(clause.exceptionType, isNotNull); | 7671 expect(clause.exceptionType, isNotNull); |
| 7674 expect(clause.catchKeyword, isNotNull); | 7672 expect(clause.catchKeyword, isNotNull); |
| 7675 expect(clause.exceptionParameter, isNotNull); | 7673 expect(clause.exceptionParameter, isNotNull); |
| 7676 expect(clause.comma, isNotNull); | 7674 expect(clause.comma, isNotNull); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7734 FunctionTypeAlias typeAlias = ParserTestCase.parse("parseTypeAlias", <Object
> [emptyCommentAndMetadata()], "typedef void F();"); | 7732 FunctionTypeAlias typeAlias = ParserTestCase.parse("parseTypeAlias", <Object
> [emptyCommentAndMetadata()], "typedef void F();"); |
| 7735 expect(typeAlias.keyword, isNotNull); | 7733 expect(typeAlias.keyword, isNotNull); |
| 7736 expect(typeAlias.name, isNotNull); | 7734 expect(typeAlias.name, isNotNull); |
| 7737 expect(typeAlias.parameters, isNotNull); | 7735 expect(typeAlias.parameters, isNotNull); |
| 7738 expect(typeAlias.returnType, isNotNull); | 7736 expect(typeAlias.returnType, isNotNull); |
| 7739 expect(typeAlias.semicolon, isNotNull); | 7737 expect(typeAlias.semicolon, isNotNull); |
| 7740 expect(typeAlias.typeParameters, isNull); | 7738 expect(typeAlias.typeParameters, isNull); |
| 7741 } | 7739 } |
| 7742 | 7740 |
| 7743 void test_parseTypeArgumentList_multiple() { | 7741 void test_parseTypeArgumentList_multiple() { |
| 7744 TypeArgumentList argumentList = ParserTestCase.parse4("parseTypeArgumentList
", "<int, int, int>", []); | 7742 TypeArgumentList argumentList = ParserTestCase.parse4("parseTypeArgumentList
", "<int, int, int>"); |
| 7745 expect(argumentList.leftBracket, isNotNull); | 7743 expect(argumentList.leftBracket, isNotNull); |
| 7746 expect(argumentList.arguments, hasLength(3)); | 7744 expect(argumentList.arguments, hasLength(3)); |
| 7747 expect(argumentList.rightBracket, isNotNull); | 7745 expect(argumentList.rightBracket, isNotNull); |
| 7748 } | 7746 } |
| 7749 | 7747 |
| 7750 void test_parseTypeArgumentList_nested() { | 7748 void test_parseTypeArgumentList_nested() { |
| 7751 TypeArgumentList argumentList = ParserTestCase.parse4("parseTypeArgumentList
", "<A<B>>", []); | 7749 TypeArgumentList argumentList = ParserTestCase.parse4("parseTypeArgumentList
", "<A<B>>"); |
| 7752 expect(argumentList.leftBracket, isNotNull); | 7750 expect(argumentList.leftBracket, isNotNull); |
| 7753 expect(argumentList.arguments, hasLength(1)); | 7751 expect(argumentList.arguments, hasLength(1)); |
| 7754 TypeName argument = argumentList.arguments[0]; | 7752 TypeName argument = argumentList.arguments[0]; |
| 7755 expect(argument, isNotNull); | 7753 expect(argument, isNotNull); |
| 7756 TypeArgumentList innerList = argument.typeArguments; | 7754 TypeArgumentList innerList = argument.typeArguments; |
| 7757 expect(innerList, isNotNull); | 7755 expect(innerList, isNotNull); |
| 7758 expect(innerList.arguments, hasLength(1)); | 7756 expect(innerList.arguments, hasLength(1)); |
| 7759 expect(argumentList.rightBracket, isNotNull); | 7757 expect(argumentList.rightBracket, isNotNull); |
| 7760 } | 7758 } |
| 7761 | 7759 |
| 7762 void test_parseTypeArgumentList_single() { | 7760 void test_parseTypeArgumentList_single() { |
| 7763 TypeArgumentList argumentList = ParserTestCase.parse4("parseTypeArgumentList
", "<int>", []); | 7761 TypeArgumentList argumentList = ParserTestCase.parse4("parseTypeArgumentList
", "<int>"); |
| 7764 expect(argumentList.leftBracket, isNotNull); | 7762 expect(argumentList.leftBracket, isNotNull); |
| 7765 expect(argumentList.arguments, hasLength(1)); | 7763 expect(argumentList.arguments, hasLength(1)); |
| 7766 expect(argumentList.rightBracket, isNotNull); | 7764 expect(argumentList.rightBracket, isNotNull); |
| 7767 } | 7765 } |
| 7768 | 7766 |
| 7769 void test_parseTypeName_parameterized() { | 7767 void test_parseTypeName_parameterized() { |
| 7770 TypeName typeName = ParserTestCase.parse4("parseTypeName", "List<int>", []); | 7768 TypeName typeName = ParserTestCase.parse4("parseTypeName", "List<int>"); |
| 7771 expect(typeName.name, isNotNull); | 7769 expect(typeName.name, isNotNull); |
| 7772 expect(typeName.typeArguments, isNotNull); | 7770 expect(typeName.typeArguments, isNotNull); |
| 7773 } | 7771 } |
| 7774 | 7772 |
| 7775 void test_parseTypeName_simple() { | 7773 void test_parseTypeName_simple() { |
| 7776 TypeName typeName = ParserTestCase.parse4("parseTypeName", "int", []); | 7774 TypeName typeName = ParserTestCase.parse4("parseTypeName", "int"); |
| 7777 expect(typeName.name, isNotNull); | 7775 expect(typeName.name, isNotNull); |
| 7778 expect(typeName.typeArguments, isNull); | 7776 expect(typeName.typeArguments, isNull); |
| 7779 } | 7777 } |
| 7780 | 7778 |
| 7781 void test_parseTypeParameter_bounded() { | 7779 void test_parseTypeParameter_bounded() { |
| 7782 TypeParameter parameter = ParserTestCase.parse4("parseTypeParameter", "A ext
ends B", []); | 7780 TypeParameter parameter = ParserTestCase.parse4("parseTypeParameter", "A ext
ends B"); |
| 7783 expect(parameter.bound, isNotNull); | 7781 expect(parameter.bound, isNotNull); |
| 7784 expect(parameter.keyword, isNotNull); | 7782 expect(parameter.keyword, isNotNull); |
| 7785 expect(parameter.name, isNotNull); | 7783 expect(parameter.name, isNotNull); |
| 7786 } | 7784 } |
| 7787 | 7785 |
| 7788 void test_parseTypeParameter_simple() { | 7786 void test_parseTypeParameter_simple() { |
| 7789 TypeParameter parameter = ParserTestCase.parse4("parseTypeParameter", "A", [
]); | 7787 TypeParameter parameter = ParserTestCase.parse4("parseTypeParameter", "A"); |
| 7790 expect(parameter.bound, isNull); | 7788 expect(parameter.bound, isNull); |
| 7791 expect(parameter.keyword, isNull); | 7789 expect(parameter.keyword, isNull); |
| 7792 expect(parameter.name, isNotNull); | 7790 expect(parameter.name, isNotNull); |
| 7793 } | 7791 } |
| 7794 | 7792 |
| 7795 void test_parseTypeParameterList_multiple() { | 7793 void test_parseTypeParameterList_multiple() { |
| 7796 TypeParameterList parameterList = ParserTestCase.parse4("parseTypeParameterL
ist", "<A, B extends C, D>", []); | 7794 TypeParameterList parameterList = ParserTestCase.parse4("parseTypeParameterL
ist", "<A, B extends C, D>"); |
| 7797 expect(parameterList.leftBracket, isNotNull); | 7795 expect(parameterList.leftBracket, isNotNull); |
| 7798 expect(parameterList.rightBracket, isNotNull); | 7796 expect(parameterList.rightBracket, isNotNull); |
| 7799 expect(parameterList.typeParameters, hasLength(3)); | 7797 expect(parameterList.typeParameters, hasLength(3)); |
| 7800 } | 7798 } |
| 7801 | 7799 |
| 7802 void test_parseTypeParameterList_parameterizedWithTrailingEquals() { | 7800 void test_parseTypeParameterList_parameterizedWithTrailingEquals() { |
| 7803 TypeParameterList parameterList = ParserTestCase.parse4("parseTypeParameterL
ist", "<A extends B<E>>=", []); | 7801 TypeParameterList parameterList = ParserTestCase.parse4("parseTypeParameterL
ist", "<A extends B<E>>="); |
| 7804 expect(parameterList.leftBracket, isNotNull); | 7802 expect(parameterList.leftBracket, isNotNull); |
| 7805 expect(parameterList.rightBracket, isNotNull); | 7803 expect(parameterList.rightBracket, isNotNull); |
| 7806 expect(parameterList.typeParameters, hasLength(1)); | 7804 expect(parameterList.typeParameters, hasLength(1)); |
| 7807 } | 7805 } |
| 7808 | 7806 |
| 7809 void test_parseTypeParameterList_single() { | 7807 void test_parseTypeParameterList_single() { |
| 7810 TypeParameterList parameterList = ParserTestCase.parse4("parseTypeParameterL
ist", "<A>", []); | 7808 TypeParameterList parameterList = ParserTestCase.parse4("parseTypeParameterL
ist", "<A>"); |
| 7811 expect(parameterList.leftBracket, isNotNull); | 7809 expect(parameterList.leftBracket, isNotNull); |
| 7812 expect(parameterList.rightBracket, isNotNull); | 7810 expect(parameterList.rightBracket, isNotNull); |
| 7813 expect(parameterList.typeParameters, hasLength(1)); | 7811 expect(parameterList.typeParameters, hasLength(1)); |
| 7814 } | 7812 } |
| 7815 | 7813 |
| 7816 void test_parseTypeParameterList_withTrailingEquals() { | 7814 void test_parseTypeParameterList_withTrailingEquals() { |
| 7817 TypeParameterList parameterList = ParserTestCase.parse4("parseTypeParameterL
ist", "<A>=", []); | 7815 TypeParameterList parameterList = ParserTestCase.parse4("parseTypeParameterL
ist", "<A>="); |
| 7818 expect(parameterList.leftBracket, isNotNull); | 7816 expect(parameterList.leftBracket, isNotNull); |
| 7819 expect(parameterList.rightBracket, isNotNull); | 7817 expect(parameterList.rightBracket, isNotNull); |
| 7820 expect(parameterList.typeParameters, hasLength(1)); | 7818 expect(parameterList.typeParameters, hasLength(1)); |
| 7821 } | 7819 } |
| 7822 | 7820 |
| 7823 void test_parseUnaryExpression_decrement_normal() { | 7821 void test_parseUnaryExpression_decrement_normal() { |
| 7824 PrefixExpression expression = ParserTestCase.parse4("parseUnaryExpression",
"--x", []); | 7822 PrefixExpression expression = ParserTestCase.parse4("parseUnaryExpression",
"--x"); |
| 7825 expect(expression.operator, isNotNull); | 7823 expect(expression.operator, isNotNull); |
| 7826 expect(expression.operator.type, TokenType.MINUS_MINUS); | 7824 expect(expression.operator.type, TokenType.MINUS_MINUS); |
| 7827 expect(expression.operand, isNotNull); | 7825 expect(expression.operand, isNotNull); |
| 7828 } | 7826 } |
| 7829 | 7827 |
| 7830 void test_parseUnaryExpression_decrement_super() { | 7828 void test_parseUnaryExpression_decrement_super() { |
| 7831 PrefixExpression expression = ParserTestCase.parse4("parseUnaryExpression",
"--super", []); | 7829 PrefixExpression expression = ParserTestCase.parse4("parseUnaryExpression",
"--super"); |
| 7832 expect(expression.operator, isNotNull); | 7830 expect(expression.operator, isNotNull); |
| 7833 expect(expression.operator.type, TokenType.MINUS); | 7831 expect(expression.operator.type, TokenType.MINUS); |
| 7834 Expression innerExpression = expression.operand; | 7832 Expression innerExpression = expression.operand; |
| 7835 expect(innerExpression, isNotNull); | 7833 expect(innerExpression, isNotNull); |
| 7836 expect(innerExpression is PrefixExpression, isTrue); | 7834 expect(innerExpression is PrefixExpression, isTrue); |
| 7837 PrefixExpression operand = innerExpression as PrefixExpression; | 7835 PrefixExpression operand = innerExpression as PrefixExpression; |
| 7838 expect(operand.operator, isNotNull); | 7836 expect(operand.operator, isNotNull); |
| 7839 expect(operand.operator.type, TokenType.MINUS); | 7837 expect(operand.operator.type, TokenType.MINUS); |
| 7840 expect(operand.operand, isNotNull); | 7838 expect(operand.operand, isNotNull); |
| 7841 } | 7839 } |
| 7842 | 7840 |
| 7843 void test_parseUnaryExpression_decrement_super_propertyAccess() { | 7841 void test_parseUnaryExpression_decrement_super_propertyAccess() { |
| 7844 PrefixExpression expression = ParserTestCase.parse4("parseUnaryExpression",
"--super.x", []); | 7842 PrefixExpression expression = ParserTestCase.parse4("parseUnaryExpression",
"--super.x"); |
| 7845 expect(expression.operator, isNotNull); | 7843 expect(expression.operator, isNotNull); |
| 7846 expect(expression.operator.type, TokenType.MINUS_MINUS); | 7844 expect(expression.operator.type, TokenType.MINUS_MINUS); |
| 7847 expect(expression.operand, isNotNull); | 7845 expect(expression.operand, isNotNull); |
| 7848 PropertyAccess operand = expression.operand as PropertyAccess; | 7846 PropertyAccess operand = expression.operand as PropertyAccess; |
| 7849 expect(operand.target is SuperExpression, isTrue); | 7847 expect(operand.target is SuperExpression, isTrue); |
| 7850 expect(operand.propertyName.name, "x"); | 7848 expect(operand.propertyName.name, "x"); |
| 7851 } | 7849 } |
| 7852 | 7850 |
| 7853 void test_parseUnaryExpression_increment_normal() { | 7851 void test_parseUnaryExpression_increment_normal() { |
| 7854 PrefixExpression expression = ParserTestCase.parse4("parseUnaryExpression",
"++x", []); | 7852 PrefixExpression expression = ParserTestCase.parse4("parseUnaryExpression",
"++x"); |
| 7855 expect(expression.operator, isNotNull); | 7853 expect(expression.operator, isNotNull); |
| 7856 expect(expression.operator.type, TokenType.PLUS_PLUS); | 7854 expect(expression.operator.type, TokenType.PLUS_PLUS); |
| 7857 expect(expression.operand, isNotNull); | 7855 expect(expression.operand, isNotNull); |
| 7858 } | 7856 } |
| 7859 | 7857 |
| 7860 void test_parseUnaryExpression_increment_super_index() { | 7858 void test_parseUnaryExpression_increment_super_index() { |
| 7861 PrefixExpression expression = ParserTestCase.parse4("parseUnaryExpression",
"++super[0]", []); | 7859 PrefixExpression expression = ParserTestCase.parse4("parseUnaryExpression",
"++super[0]"); |
| 7862 expect(expression.operator, isNotNull); | 7860 expect(expression.operator, isNotNull); |
| 7863 expect(expression.operator.type, TokenType.PLUS_PLUS); | 7861 expect(expression.operator.type, TokenType.PLUS_PLUS); |
| 7864 expect(expression.operand, isNotNull); | 7862 expect(expression.operand, isNotNull); |
| 7865 IndexExpression operand = expression.operand as IndexExpression; | 7863 IndexExpression operand = expression.operand as IndexExpression; |
| 7866 expect(operand.realTarget is SuperExpression, isTrue); | 7864 expect(operand.realTarget is SuperExpression, isTrue); |
| 7867 expect(operand.index is IntegerLiteral, isTrue); | 7865 expect(operand.index is IntegerLiteral, isTrue); |
| 7868 } | 7866 } |
| 7869 | 7867 |
| 7870 void test_parseUnaryExpression_increment_super_propertyAccess() { | 7868 void test_parseUnaryExpression_increment_super_propertyAccess() { |
| 7871 PrefixExpression expression = ParserTestCase.parse4("parseUnaryExpression",
"++super.x", []); | 7869 PrefixExpression expression = ParserTestCase.parse4("parseUnaryExpression",
"++super.x"); |
| 7872 expect(expression.operator, isNotNull); | 7870 expect(expression.operator, isNotNull); |
| 7873 expect(expression.operator.type, TokenType.PLUS_PLUS); | 7871 expect(expression.operator.type, TokenType.PLUS_PLUS); |
| 7874 expect(expression.operand, isNotNull); | 7872 expect(expression.operand, isNotNull); |
| 7875 PropertyAccess operand = expression.operand as PropertyAccess; | 7873 PropertyAccess operand = expression.operand as PropertyAccess; |
| 7876 expect(operand.target is SuperExpression, isTrue); | 7874 expect(operand.target is SuperExpression, isTrue); |
| 7877 expect(operand.propertyName.name, "x"); | 7875 expect(operand.propertyName.name, "x"); |
| 7878 } | 7876 } |
| 7879 | 7877 |
| 7880 void test_parseUnaryExpression_minus_normal() { | 7878 void test_parseUnaryExpression_minus_normal() { |
| 7881 PrefixExpression expression = ParserTestCase.parse4("parseUnaryExpression",
"-x", []); | 7879 PrefixExpression expression = ParserTestCase.parse4("parseUnaryExpression",
"-x"); |
| 7882 expect(expression.operator, isNotNull); | 7880 expect(expression.operator, isNotNull); |
| 7883 expect(expression.operator.type, TokenType.MINUS); | 7881 expect(expression.operator.type, TokenType.MINUS); |
| 7884 expect(expression.operand, isNotNull); | 7882 expect(expression.operand, isNotNull); |
| 7885 } | 7883 } |
| 7886 | 7884 |
| 7887 void test_parseUnaryExpression_minus_super() { | 7885 void test_parseUnaryExpression_minus_super() { |
| 7888 PrefixExpression expression = ParserTestCase.parse4("parseUnaryExpression",
"-super", []); | 7886 PrefixExpression expression = ParserTestCase.parse4("parseUnaryExpression",
"-super"); |
| 7889 expect(expression.operator, isNotNull); | 7887 expect(expression.operator, isNotNull); |
| 7890 expect(expression.operator.type, TokenType.MINUS); | 7888 expect(expression.operator.type, TokenType.MINUS); |
| 7891 expect(expression.operand, isNotNull); | 7889 expect(expression.operand, isNotNull); |
| 7892 } | 7890 } |
| 7893 | 7891 |
| 7894 void test_parseUnaryExpression_not_normal() { | 7892 void test_parseUnaryExpression_not_normal() { |
| 7895 PrefixExpression expression = ParserTestCase.parse4("parseUnaryExpression",
"!x", []); | 7893 PrefixExpression expression = ParserTestCase.parse4("parseUnaryExpression",
"!x"); |
| 7896 expect(expression.operator, isNotNull); | 7894 expect(expression.operator, isNotNull); |
| 7897 expect(expression.operator.type, TokenType.BANG); | 7895 expect(expression.operator.type, TokenType.BANG); |
| 7898 expect(expression.operand, isNotNull); | 7896 expect(expression.operand, isNotNull); |
| 7899 } | 7897 } |
| 7900 | 7898 |
| 7901 void test_parseUnaryExpression_not_super() { | 7899 void test_parseUnaryExpression_not_super() { |
| 7902 PrefixExpression expression = ParserTestCase.parse4("parseUnaryExpression",
"!super", []); | 7900 PrefixExpression expression = ParserTestCase.parse4("parseUnaryExpression",
"!super"); |
| 7903 expect(expression.operator, isNotNull); | 7901 expect(expression.operator, isNotNull); |
| 7904 expect(expression.operator.type, TokenType.BANG); | 7902 expect(expression.operator.type, TokenType.BANG); |
| 7905 expect(expression.operand, isNotNull); | 7903 expect(expression.operand, isNotNull); |
| 7906 } | 7904 } |
| 7907 | 7905 |
| 7908 void test_parseUnaryExpression_tilda_normal() { | 7906 void test_parseUnaryExpression_tilda_normal() { |
| 7909 PrefixExpression expression = ParserTestCase.parse4("parseUnaryExpression",
"~x", []); | 7907 PrefixExpression expression = ParserTestCase.parse4("parseUnaryExpression",
"~x"); |
| 7910 expect(expression.operator, isNotNull); | 7908 expect(expression.operator, isNotNull); |
| 7911 expect(expression.operator.type, TokenType.TILDE); | 7909 expect(expression.operator.type, TokenType.TILDE); |
| 7912 expect(expression.operand, isNotNull); | 7910 expect(expression.operand, isNotNull); |
| 7913 } | 7911 } |
| 7914 | 7912 |
| 7915 void test_parseUnaryExpression_tilda_super() { | 7913 void test_parseUnaryExpression_tilda_super() { |
| 7916 PrefixExpression expression = ParserTestCase.parse4("parseUnaryExpression",
"~super", []); | 7914 PrefixExpression expression = ParserTestCase.parse4("parseUnaryExpression",
"~super"); |
| 7917 expect(expression.operator, isNotNull); | 7915 expect(expression.operator, isNotNull); |
| 7918 expect(expression.operator.type, TokenType.TILDE); | 7916 expect(expression.operator.type, TokenType.TILDE); |
| 7919 expect(expression.operand, isNotNull); | 7917 expect(expression.operand, isNotNull); |
| 7920 } | 7918 } |
| 7921 | 7919 |
| 7922 void test_parseVariableDeclaration_equals() { | 7920 void test_parseVariableDeclaration_equals() { |
| 7923 VariableDeclaration declaration = ParserTestCase.parse4("parseVariableDeclar
ation", "a = b", []); | 7921 VariableDeclaration declaration = ParserTestCase.parse4("parseVariableDeclar
ation", "a = b"); |
| 7924 expect(declaration.name, isNotNull); | 7922 expect(declaration.name, isNotNull); |
| 7925 expect(declaration.equals, isNotNull); | 7923 expect(declaration.equals, isNotNull); |
| 7926 expect(declaration.initializer, isNotNull); | 7924 expect(declaration.initializer, isNotNull); |
| 7927 } | 7925 } |
| 7928 | 7926 |
| 7929 void test_parseVariableDeclaration_noEquals() { | 7927 void test_parseVariableDeclaration_noEquals() { |
| 7930 VariableDeclaration declaration = ParserTestCase.parse4("parseVariableDeclar
ation", "a", []); | 7928 VariableDeclaration declaration = ParserTestCase.parse4("parseVariableDeclar
ation", "a"); |
| 7931 expect(declaration.name, isNotNull); | 7929 expect(declaration.name, isNotNull); |
| 7932 expect(declaration.equals, isNull); | 7930 expect(declaration.equals, isNull); |
| 7933 expect(declaration.initializer, isNull); | 7931 expect(declaration.initializer, isNull); |
| 7934 } | 7932 } |
| 7935 | 7933 |
| 7936 void test_parseVariableDeclarationListAfterMetadata_const_noType() { | 7934 void test_parseVariableDeclarationListAfterMetadata_const_noType() { |
| 7937 VariableDeclarationList declarationList = ParserTestCase.parse("parseVariabl
eDeclarationListAfterMetadata", <Object> [emptyCommentAndMetadata()], "const a")
; | 7935 VariableDeclarationList declarationList = ParserTestCase.parse("parseVariabl
eDeclarationListAfterMetadata", <Object> [emptyCommentAndMetadata()], "const a")
; |
| 7938 expect(declarationList.keyword, isNotNull); | 7936 expect(declarationList.keyword, isNotNull); |
| 7939 expect(declarationList.type, isNull); | 7937 expect(declarationList.type, isNull); |
| 7940 expect(declarationList.variables, hasLength(1)); | 7938 expect(declarationList.variables, hasLength(1)); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8015 | 8013 |
| 8016 void test_parseVariableDeclarationStatementAfterMetadata_single() { | 8014 void test_parseVariableDeclarationStatementAfterMetadata_single() { |
| 8017 VariableDeclarationStatement statement = ParserTestCase.parse("parseVariable
DeclarationStatementAfterMetadata", <Object> [emptyCommentAndMetadata()], "var x
;"); | 8015 VariableDeclarationStatement statement = ParserTestCase.parse("parseVariable
DeclarationStatementAfterMetadata", <Object> [emptyCommentAndMetadata()], "var x
;"); |
| 8018 expect(statement.semicolon, isNotNull); | 8016 expect(statement.semicolon, isNotNull); |
| 8019 VariableDeclarationList variableList = statement.variables; | 8017 VariableDeclarationList variableList = statement.variables; |
| 8020 expect(variableList, isNotNull); | 8018 expect(variableList, isNotNull); |
| 8021 expect(variableList.variables, hasLength(1)); | 8019 expect(variableList.variables, hasLength(1)); |
| 8022 } | 8020 } |
| 8023 | 8021 |
| 8024 void test_parseWhileStatement() { | 8022 void test_parseWhileStatement() { |
| 8025 WhileStatement statement = ParserTestCase.parse4("parseWhileStatement", "whi
le (x) {}", []); | 8023 WhileStatement statement = ParserTestCase.parse4("parseWhileStatement", "whi
le (x) {}"); |
| 8026 expect(statement.keyword, isNotNull); | 8024 expect(statement.keyword, isNotNull); |
| 8027 expect(statement.leftParenthesis, isNotNull); | 8025 expect(statement.leftParenthesis, isNotNull); |
| 8028 expect(statement.condition, isNotNull); | 8026 expect(statement.condition, isNotNull); |
| 8029 expect(statement.rightParenthesis, isNotNull); | 8027 expect(statement.rightParenthesis, isNotNull); |
| 8030 expect(statement.body, isNotNull); | 8028 expect(statement.body, isNotNull); |
| 8031 } | 8029 } |
| 8032 | 8030 |
| 8033 void test_parseWithClause_multiple() { | 8031 void test_parseWithClause_multiple() { |
| 8034 WithClause clause = ParserTestCase.parse4("parseWithClause", "with A, B, C",
[]); | 8032 WithClause clause = ParserTestCase.parse4("parseWithClause", "with A, B, C")
; |
| 8035 expect(clause.withKeyword, isNotNull); | 8033 expect(clause.withKeyword, isNotNull); |
| 8036 expect(clause.mixinTypes, hasLength(3)); | 8034 expect(clause.mixinTypes, hasLength(3)); |
| 8037 } | 8035 } |
| 8038 | 8036 |
| 8039 void test_parseWithClause_single() { | 8037 void test_parseWithClause_single() { |
| 8040 WithClause clause = ParserTestCase.parse4("parseWithClause", "with M", []); | 8038 WithClause clause = ParserTestCase.parse4("parseWithClause", "with M"); |
| 8041 expect(clause.withKeyword, isNotNull); | 8039 expect(clause.withKeyword, isNotNull); |
| 8042 expect(clause.mixinTypes, hasLength(1)); | 8040 expect(clause.mixinTypes, hasLength(1)); |
| 8043 } | 8041 } |
| 8044 | 8042 |
| 8045 void test_parseYieldStatement_each() { | 8043 void test_parseYieldStatement_each() { |
| 8046 YieldStatement statement = ParserTestCase.parse4("parseYieldStatement", "yie
ld* x;", []); | 8044 YieldStatement statement = ParserTestCase.parse4("parseYieldStatement", "yie
ld* x;"); |
| 8047 expect(statement.yieldKeyword, isNotNull); | 8045 expect(statement.yieldKeyword, isNotNull); |
| 8048 expect(statement.star, isNotNull); | 8046 expect(statement.star, isNotNull); |
| 8049 expect(statement.expression, isNotNull); | 8047 expect(statement.expression, isNotNull); |
| 8050 expect(statement.semicolon, isNotNull); | 8048 expect(statement.semicolon, isNotNull); |
| 8051 } | 8049 } |
| 8052 | 8050 |
| 8053 void test_parseYieldStatement_normal() { | 8051 void test_parseYieldStatement_normal() { |
| 8054 YieldStatement statement = ParserTestCase.parse4("parseYieldStatement", "yie
ld x;", []); | 8052 YieldStatement statement = ParserTestCase.parse4("parseYieldStatement", "yie
ld x;"); |
| 8055 expect(statement.yieldKeyword, isNotNull); | 8053 expect(statement.yieldKeyword, isNotNull); |
| 8056 expect(statement.star, isNull); | 8054 expect(statement.star, isNull); |
| 8057 expect(statement.expression, isNotNull); | 8055 expect(statement.expression, isNotNull); |
| 8058 expect(statement.semicolon, isNotNull); | 8056 expect(statement.semicolon, isNotNull); |
| 8059 } | 8057 } |
| 8060 | 8058 |
| 8061 void test_skipPrefixedIdentifier_invalid() { | 8059 void test_skipPrefixedIdentifier_invalid() { |
| 8062 Token following = _skip("skipPrefixedIdentifier", "+"); | 8060 Token following = _skip("skipPrefixedIdentifier", "+"); |
| 8063 expect(following, isNull); | 8061 expect(following, isNull); |
| 8064 } | 8062 } |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8270 | 8268 |
| 8271 /** | 8269 /** |
| 8272 * Parse the given source as a compilation unit. | 8270 * Parse the given source as a compilation unit. |
| 8273 * | 8271 * |
| 8274 * @param source the source to be parsed | 8272 * @param source the source to be parsed |
| 8275 * @param errorCodes the error codes of the errors that are expected to be fou
nd | 8273 * @param errorCodes the error codes of the errors that are expected to be fou
nd |
| 8276 * @return the compilation unit that was parsed | 8274 * @return the compilation unit that was parsed |
| 8277 * @throws Exception if the source could not be parsed, if the compilation err
ors in the source do | 8275 * @throws Exception if the source could not be parsed, if the compilation err
ors in the source do |
| 8278 * not match those that are expected, or if the result would have be
en `null` | 8276 * not match those that are expected, or if the result would have be
en `null` |
| 8279 */ | 8277 */ |
| 8280 CompilationUnit _parseDirectives(String source, List<ErrorCode> errorCodes) { | 8278 CompilationUnit _parseDirectives(String source, [List<ErrorCode> errorCodes =
ErrorCode.EMPTY_LIST]) { |
| 8281 GatheringErrorListener listener = new GatheringErrorListener(); | 8279 GatheringErrorListener listener = new GatheringErrorListener(); |
| 8282 Scanner scanner = new Scanner(null, new CharSequenceReader(source), listener
); | 8280 Scanner scanner = new Scanner(null, new CharSequenceReader(source), listener
); |
| 8283 listener.setLineInfo(new TestSource(), scanner.lineStarts); | 8281 listener.setLineInfo(new TestSource(), scanner.lineStarts); |
| 8284 Token token = scanner.tokenize(); | 8282 Token token = scanner.tokenize(); |
| 8285 Parser parser = new Parser(null, listener); | 8283 Parser parser = new Parser(null, listener); |
| 8286 CompilationUnit unit = parser.parseDirectives(token); | 8284 CompilationUnit unit = parser.parseDirectives(token); |
| 8287 expect(unit, isNotNull); | 8285 expect(unit, isNotNull); |
| 8288 expect(unit.declarations, hasLength(0)); | 8286 expect(unit.declarations, hasLength(0)); |
| 8289 listener.assertErrorsWithCodes(errorCodes); | 8287 listener.assertErrorsWithCodes(errorCodes); |
| 8290 return unit; | 8288 return unit; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 8318 main() { | 8316 main() { |
| 8319 groupSep = ' | '; | 8317 groupSep = ' | '; |
| 8320 runReflectiveTests(ComplexParserTest); | 8318 runReflectiveTests(ComplexParserTest); |
| 8321 runReflectiveTests(ErrorParserTest); | 8319 runReflectiveTests(ErrorParserTest); |
| 8322 runReflectiveTests(IncrementalParserTest); | 8320 runReflectiveTests(IncrementalParserTest); |
| 8323 runReflectiveTests(NonErrorParserTest); | 8321 runReflectiveTests(NonErrorParserTest); |
| 8324 runReflectiveTests(RecoveryParserTest); | 8322 runReflectiveTests(RecoveryParserTest); |
| 8325 runReflectiveTests(ResolutionCopierTest); | 8323 runReflectiveTests(ResolutionCopierTest); |
| 8326 runReflectiveTests(SimpleParserTest); | 8324 runReflectiveTests(SimpleParserTest); |
| 8327 } | 8325 } |
| OLD | NEW |