| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library engine.parser_test; | 5 library engine.parser_test; |
| 6 | 6 |
| 7 import 'package:analyzer/src/generated/ast.dart'; | 7 import 'package:analyzer/src/generated/ast.dart'; |
| 8 import 'package:analyzer/src/generated/element.dart'; | 8 import 'package:analyzer/src/generated/element.dart'; |
| 9 import 'package:analyzer/src/generated/error.dart'; | 9 import 'package:analyzer/src/generated/error.dart'; |
| 10 import 'package:analyzer/src/generated/incremental_scanner.dart'; | 10 import 'package:analyzer/src/generated/incremental_scanner.dart'; |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 /** | 118 /** |
| 119 * The class `ComplexParserTest` defines parser tests that test the parsing of m
ore complex | 119 * The class `ComplexParserTest` defines parser tests that test the parsing of m
ore complex |
| 120 * code fragments or the interactions between multiple parsing methods. For exam
ple, tests to ensure | 120 * code fragments or the interactions between multiple parsing methods. For exam
ple, tests to ensure |
| 121 * that the precedence of operations is being handled correctly should be define
d in this class. | 121 * that the precedence of operations is being handled correctly should be define
d in this class. |
| 122 * | 122 * |
| 123 * Simpler tests should be defined in the class [SimpleParserTest]. | 123 * Simpler tests should be defined in the class [SimpleParserTest]. |
| 124 */ | 124 */ |
| 125 @reflectiveTest | 125 @reflectiveTest |
| 126 class ComplexParserTest extends ParserTestCase { | 126 class ComplexParserTest extends ParserTestCase { |
| 127 void test_additiveExpression_normal() { | 127 void test_additiveExpression_normal() { |
| 128 BinaryExpression expression = ParserTestCase.parseExpression("x + y - z"); | 128 BinaryExpression expression = parseExpression("x + y - z"); |
| 129 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | 129 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, |
| 130 BinaryExpression, expression.leftOperand); | 130 BinaryExpression, expression.leftOperand); |
| 131 } | 131 } |
| 132 | 132 |
| 133 void test_additiveExpression_noSpaces() { | 133 void test_additiveExpression_noSpaces() { |
| 134 BinaryExpression expression = ParserTestCase.parseExpression("i+1"); | 134 BinaryExpression expression = parseExpression("i+1"); |
| 135 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 135 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
| 136 SimpleIdentifier, expression.leftOperand); | 136 SimpleIdentifier, expression.leftOperand); |
| 137 EngineTestCase.assertInstanceOf((obj) => obj is IntegerLiteral, | 137 EngineTestCase.assertInstanceOf((obj) => obj is IntegerLiteral, |
| 138 IntegerLiteral, expression.rightOperand); | 138 IntegerLiteral, expression.rightOperand); |
| 139 } | 139 } |
| 140 | 140 |
| 141 void test_additiveExpression_precedence_multiplicative_left() { | 141 void test_additiveExpression_precedence_multiplicative_left() { |
| 142 BinaryExpression expression = ParserTestCase.parseExpression("x * y + z"); | 142 BinaryExpression expression = parseExpression("x * y + z"); |
| 143 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | 143 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, |
| 144 BinaryExpression, expression.leftOperand); | 144 BinaryExpression, expression.leftOperand); |
| 145 } | 145 } |
| 146 | 146 |
| 147 void test_additiveExpression_precedence_multiplicative_left_withSuper() { | 147 void test_additiveExpression_precedence_multiplicative_left_withSuper() { |
| 148 BinaryExpression expression = | 148 BinaryExpression expression = parseExpression("super * y - z"); |
| 149 ParserTestCase.parseExpression("super * y - z"); | |
| 150 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | 149 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, |
| 151 BinaryExpression, expression.leftOperand); | 150 BinaryExpression, expression.leftOperand); |
| 152 } | 151 } |
| 153 | 152 |
| 154 void test_additiveExpression_precedence_multiplicative_right() { | 153 void test_additiveExpression_precedence_multiplicative_right() { |
| 155 BinaryExpression expression = ParserTestCase.parseExpression("x + y * z"); | 154 BinaryExpression expression = parseExpression("x + y * z"); |
| 156 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | 155 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, |
| 157 BinaryExpression, expression.rightOperand); | 156 BinaryExpression, expression.rightOperand); |
| 158 } | 157 } |
| 159 | 158 |
| 160 void test_additiveExpression_super() { | 159 void test_additiveExpression_super() { |
| 161 BinaryExpression expression = | 160 BinaryExpression expression = parseExpression("super + y - z"); |
| 162 ParserTestCase.parseExpression("super + y - z"); | |
| 163 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | 161 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, |
| 164 BinaryExpression, expression.leftOperand); | 162 BinaryExpression, expression.leftOperand); |
| 165 } | 163 } |
| 166 | 164 |
| 167 void test_assignableExpression_arguments_normal_chain() { | 165 void test_assignableExpression_arguments_normal_chain() { |
| 168 PropertyAccess propertyAccess1 = | 166 PropertyAccess propertyAccess1 = parseExpression("a(b)(c).d(e).f"); |
| 169 ParserTestCase.parseExpression("a(b)(c).d(e).f"); | |
| 170 expect(propertyAccess1.propertyName.name, "f"); | 167 expect(propertyAccess1.propertyName.name, "f"); |
| 171 // | 168 // |
| 172 // a(b)(c).d(e) | 169 // a(b)(c).d(e) |
| 173 // | 170 // |
| 174 MethodInvocation invocation2 = EngineTestCase.assertInstanceOf( | 171 MethodInvocation invocation2 = EngineTestCase.assertInstanceOf( |
| 175 (obj) => obj is MethodInvocation, MethodInvocation, | 172 (obj) => obj is MethodInvocation, MethodInvocation, |
| 176 propertyAccess1.target); | 173 propertyAccess1.target); |
| 177 expect(invocation2.methodName.name, "d"); | 174 expect(invocation2.methodName.name, "d"); |
| 178 ArgumentList argumentList2 = invocation2.argumentList; | 175 ArgumentList argumentList2 = invocation2.argumentList; |
| 179 expect(argumentList2, isNotNull); | 176 expect(argumentList2, isNotNull); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 193 MethodInvocation invocation4 = EngineTestCase.assertInstanceOf( | 190 MethodInvocation invocation4 = EngineTestCase.assertInstanceOf( |
| 194 (obj) => obj is MethodInvocation, MethodInvocation, | 191 (obj) => obj is MethodInvocation, MethodInvocation, |
| 195 invocation3.function); | 192 invocation3.function); |
| 196 expect(invocation4.methodName.name, "a"); | 193 expect(invocation4.methodName.name, "a"); |
| 197 ArgumentList argumentList4 = invocation4.argumentList; | 194 ArgumentList argumentList4 = invocation4.argumentList; |
| 198 expect(argumentList4, isNotNull); | 195 expect(argumentList4, isNotNull); |
| 199 expect(argumentList4.arguments, hasLength(1)); | 196 expect(argumentList4.arguments, hasLength(1)); |
| 200 } | 197 } |
| 201 | 198 |
| 202 void test_assignmentExpression_compound() { | 199 void test_assignmentExpression_compound() { |
| 203 AssignmentExpression expression = | 200 AssignmentExpression expression = parseExpression("x = y = 0"); |
| 204 ParserTestCase.parseExpression("x = y = 0"); | |
| 205 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 201 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
| 206 SimpleIdentifier, expression.leftHandSide); | 202 SimpleIdentifier, expression.leftHandSide); |
| 207 EngineTestCase.assertInstanceOf((obj) => obj is AssignmentExpression, | 203 EngineTestCase.assertInstanceOf((obj) => obj is AssignmentExpression, |
| 208 AssignmentExpression, expression.rightHandSide); | 204 AssignmentExpression, expression.rightHandSide); |
| 209 } | 205 } |
| 210 | 206 |
| 211 void test_assignmentExpression_indexExpression() { | 207 void test_assignmentExpression_indexExpression() { |
| 212 AssignmentExpression expression = | 208 AssignmentExpression expression = parseExpression("x[1] = 0"); |
| 213 ParserTestCase.parseExpression("x[1] = 0"); | |
| 214 EngineTestCase.assertInstanceOf((obj) => obj is IndexExpression, | 209 EngineTestCase.assertInstanceOf((obj) => obj is IndexExpression, |
| 215 IndexExpression, expression.leftHandSide); | 210 IndexExpression, expression.leftHandSide); |
| 216 EngineTestCase.assertInstanceOf((obj) => obj is IntegerLiteral, | 211 EngineTestCase.assertInstanceOf((obj) => obj is IntegerLiteral, |
| 217 IntegerLiteral, expression.rightHandSide); | 212 IntegerLiteral, expression.rightHandSide); |
| 218 } | 213 } |
| 219 | 214 |
| 220 void test_assignmentExpression_prefixedIdentifier() { | 215 void test_assignmentExpression_prefixedIdentifier() { |
| 221 AssignmentExpression expression = ParserTestCase.parseExpression("x.y = 0"); | 216 AssignmentExpression expression = parseExpression("x.y = 0"); |
| 222 EngineTestCase.assertInstanceOf((obj) => obj is PrefixedIdentifier, | 217 EngineTestCase.assertInstanceOf((obj) => obj is PrefixedIdentifier, |
| 223 PrefixedIdentifier, expression.leftHandSide); | 218 PrefixedIdentifier, expression.leftHandSide); |
| 224 EngineTestCase.assertInstanceOf((obj) => obj is IntegerLiteral, | 219 EngineTestCase.assertInstanceOf((obj) => obj is IntegerLiteral, |
| 225 IntegerLiteral, expression.rightHandSide); | 220 IntegerLiteral, expression.rightHandSide); |
| 226 } | 221 } |
| 227 | 222 |
| 228 void test_assignmentExpression_propertyAccess() { | 223 void test_assignmentExpression_propertyAccess() { |
| 229 AssignmentExpression expression = | 224 AssignmentExpression expression = parseExpression("super.y = 0"); |
| 230 ParserTestCase.parseExpression("super.y = 0"); | |
| 231 EngineTestCase.assertInstanceOf((obj) => obj is PropertyAccess, | 225 EngineTestCase.assertInstanceOf((obj) => obj is PropertyAccess, |
| 232 PropertyAccess, expression.leftHandSide); | 226 PropertyAccess, expression.leftHandSide); |
| 233 EngineTestCase.assertInstanceOf((obj) => obj is IntegerLiteral, | 227 EngineTestCase.assertInstanceOf((obj) => obj is IntegerLiteral, |
| 234 IntegerLiteral, expression.rightHandSide); | 228 IntegerLiteral, expression.rightHandSide); |
| 235 } | 229 } |
| 236 | 230 |
| 237 void test_bitwiseAndExpression_normal() { | 231 void test_bitwiseAndExpression_normal() { |
| 238 BinaryExpression expression = ParserTestCase.parseExpression("x & y & z"); | 232 BinaryExpression expression = parseExpression("x & y & z"); |
| 239 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | 233 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, |
| 240 BinaryExpression, expression.leftOperand); | 234 BinaryExpression, expression.leftOperand); |
| 241 } | 235 } |
| 242 | 236 |
| 243 void test_bitwiseAndExpression_precedence_equality_left() { | 237 void test_bitwiseAndExpression_precedence_equality_left() { |
| 244 BinaryExpression expression = ParserTestCase.parseExpression("x == y && z"); | 238 BinaryExpression expression = parseExpression("x == y && z"); |
| 245 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | 239 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, |
| 246 BinaryExpression, expression.leftOperand); | 240 BinaryExpression, expression.leftOperand); |
| 247 } | 241 } |
| 248 | 242 |
| 249 void test_bitwiseAndExpression_precedence_equality_right() { | 243 void test_bitwiseAndExpression_precedence_equality_right() { |
| 250 BinaryExpression expression = ParserTestCase.parseExpression("x && y == z"); | 244 BinaryExpression expression = parseExpression("x && y == z"); |
| 251 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | 245 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, |
| 252 BinaryExpression, expression.rightOperand); | 246 BinaryExpression, expression.rightOperand); |
| 253 } | 247 } |
| 254 | 248 |
| 255 void test_bitwiseAndExpression_super() { | 249 void test_bitwiseAndExpression_super() { |
| 256 BinaryExpression expression = | 250 BinaryExpression expression = parseExpression("super & y & z"); |
| 257 ParserTestCase.parseExpression("super & y & z"); | |
| 258 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | 251 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, |
| 259 BinaryExpression, expression.leftOperand); | 252 BinaryExpression, expression.leftOperand); |
| 260 } | 253 } |
| 261 | 254 |
| 262 void test_bitwiseOrExpression_normal() { | 255 void test_bitwiseOrExpression_normal() { |
| 263 BinaryExpression expression = ParserTestCase.parseExpression("x | y | z"); | 256 BinaryExpression expression = parseExpression("x | y | z"); |
| 264 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | 257 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, |
| 265 BinaryExpression, expression.leftOperand); | 258 BinaryExpression, expression.leftOperand); |
| 266 } | 259 } |
| 267 | 260 |
| 268 void test_bitwiseOrExpression_precedence_xor_left() { | 261 void test_bitwiseOrExpression_precedence_xor_left() { |
| 269 BinaryExpression expression = ParserTestCase.parseExpression("x ^ y | z"); | 262 BinaryExpression expression = parseExpression("x ^ y | z"); |
| 270 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | 263 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, |
| 271 BinaryExpression, expression.leftOperand); | 264 BinaryExpression, expression.leftOperand); |
| 272 } | 265 } |
| 273 | 266 |
| 274 void test_bitwiseOrExpression_precedence_xor_right() { | 267 void test_bitwiseOrExpression_precedence_xor_right() { |
| 275 BinaryExpression expression = ParserTestCase.parseExpression("x | y ^ z"); | 268 BinaryExpression expression = parseExpression("x | y ^ z"); |
| 276 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | 269 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, |
| 277 BinaryExpression, expression.rightOperand); | 270 BinaryExpression, expression.rightOperand); |
| 278 } | 271 } |
| 279 | 272 |
| 280 void test_bitwiseOrExpression_super() { | 273 void test_bitwiseOrExpression_super() { |
| 281 BinaryExpression expression = | 274 BinaryExpression expression = parseExpression("super | y | z"); |
| 282 ParserTestCase.parseExpression("super | y | z"); | |
| 283 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | 275 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, |
| 284 BinaryExpression, expression.leftOperand); | 276 BinaryExpression, expression.leftOperand); |
| 285 } | 277 } |
| 286 | 278 |
| 287 void test_bitwiseXorExpression_normal() { | 279 void test_bitwiseXorExpression_normal() { |
| 288 BinaryExpression expression = ParserTestCase.parseExpression("x ^ y ^ z"); | 280 BinaryExpression expression = parseExpression("x ^ y ^ z"); |
| 289 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | 281 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, |
| 290 BinaryExpression, expression.leftOperand); | 282 BinaryExpression, expression.leftOperand); |
| 291 } | 283 } |
| 292 | 284 |
| 293 void test_bitwiseXorExpression_precedence_and_left() { | 285 void test_bitwiseXorExpression_precedence_and_left() { |
| 294 BinaryExpression expression = ParserTestCase.parseExpression("x & y ^ z"); | 286 BinaryExpression expression = parseExpression("x & y ^ z"); |
| 295 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | 287 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, |
| 296 BinaryExpression, expression.leftOperand); | 288 BinaryExpression, expression.leftOperand); |
| 297 } | 289 } |
| 298 | 290 |
| 299 void test_bitwiseXorExpression_precedence_and_right() { | 291 void test_bitwiseXorExpression_precedence_and_right() { |
| 300 BinaryExpression expression = ParserTestCase.parseExpression("x ^ y & z"); | 292 BinaryExpression expression = parseExpression("x ^ y & z"); |
| 301 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | 293 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, |
| 302 BinaryExpression, expression.rightOperand); | 294 BinaryExpression, expression.rightOperand); |
| 303 } | 295 } |
| 304 | 296 |
| 305 void test_bitwiseXorExpression_super() { | 297 void test_bitwiseXorExpression_super() { |
| 306 BinaryExpression expression = | 298 BinaryExpression expression = parseExpression("super ^ y ^ z"); |
| 307 ParserTestCase.parseExpression("super ^ y ^ z"); | |
| 308 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | 299 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, |
| 309 BinaryExpression, expression.leftOperand); | 300 BinaryExpression, expression.leftOperand); |
| 310 } | 301 } |
| 311 | 302 |
| 312 void test_cascade_withAssignment() { | 303 void test_cascade_withAssignment() { |
| 313 CascadeExpression cascade = | 304 CascadeExpression cascade = |
| 314 ParserTestCase.parseExpression("new Map()..[3] = 4 ..[0] = 11;"); | 305 parseExpression("new Map()..[3] = 4 ..[0] = 11;"); |
| 315 Expression target = cascade.target; | 306 Expression target = cascade.target; |
| 316 for (Expression section in cascade.cascadeSections) { | 307 for (Expression section in cascade.cascadeSections) { |
| 317 EngineTestCase.assertInstanceOf( | 308 EngineTestCase.assertInstanceOf( |
| 318 (obj) => obj is AssignmentExpression, AssignmentExpression, section); | 309 (obj) => obj is AssignmentExpression, AssignmentExpression, section); |
| 319 Expression lhs = (section as AssignmentExpression).leftHandSide; | 310 Expression lhs = (section as AssignmentExpression).leftHandSide; |
| 320 EngineTestCase.assertInstanceOf( | 311 EngineTestCase.assertInstanceOf( |
| 321 (obj) => obj is IndexExpression, IndexExpression, lhs); | 312 (obj) => obj is IndexExpression, IndexExpression, lhs); |
| 322 IndexExpression index = lhs as IndexExpression; | 313 IndexExpression index = lhs as IndexExpression; |
| 323 expect(index.isCascaded, isTrue); | 314 expect(index.isCascaded, isTrue); |
| 324 expect(index.realTarget, same(target)); | 315 expect(index.realTarget, same(target)); |
| 325 } | 316 } |
| 326 } | 317 } |
| 327 | 318 |
| 328 void test_conditionalExpression_precedence_logicalOrExpression() { | 319 void test_conditionalExpression_precedence_logicalOrExpression() { |
| 329 ConditionalExpression expression = | 320 ConditionalExpression expression = parseExpression("a | b ? y : z"); |
| 330 ParserTestCase.parseExpression("a | b ? y : z"); | |
| 331 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | 321 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, |
| 332 BinaryExpression, expression.condition); | 322 BinaryExpression, expression.condition); |
| 333 } | 323 } |
| 334 | 324 |
| 335 void test_constructor_initializer_withParenthesizedExpression() { | 325 void test_constructor_initializer_withParenthesizedExpression() { |
| 336 CompilationUnit unit = ParserTestCase.parseCompilationUnit(r''' | 326 CompilationUnit unit = ParserTestCase.parseCompilationUnit(r''' |
| 337 class C { | 327 class C { |
| 338 C() : | 328 C() : |
| 339 this.a = (b == null ? c : d) { | 329 this.a = (b == null ? c : d) { |
| 340 } | 330 } |
| 341 }'''); | 331 }'''); |
| 342 NodeList<CompilationUnitMember> declarations = unit.declarations; | 332 NodeList<CompilationUnitMember> declarations = unit.declarations; |
| 343 expect(declarations, hasLength(1)); | 333 expect(declarations, hasLength(1)); |
| 344 } | 334 } |
| 345 | 335 |
| 346 void test_equalityExpression_normal() { | 336 void test_equalityExpression_normal() { |
| 347 BinaryExpression expression = ParserTestCase.parseExpression( | 337 BinaryExpression expression = parseExpression( |
| 348 "x == y != z", [ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND]); | 338 "x == y != z", [ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND]); |
| 349 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | 339 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, |
| 350 BinaryExpression, expression.leftOperand); | 340 BinaryExpression, expression.leftOperand); |
| 351 } | 341 } |
| 352 | 342 |
| 353 void test_equalityExpression_precedence_relational_left() { | 343 void test_equalityExpression_precedence_relational_left() { |
| 354 BinaryExpression expression = ParserTestCase.parseExpression("x is y == z"); | 344 BinaryExpression expression = parseExpression("x is y == z"); |
| 355 EngineTestCase.assertInstanceOf( | 345 EngineTestCase.assertInstanceOf( |
| 356 (obj) => obj is IsExpression, IsExpression, expression.leftOperand); | 346 (obj) => obj is IsExpression, IsExpression, expression.leftOperand); |
| 357 } | 347 } |
| 358 | 348 |
| 359 void test_equalityExpression_precedence_relational_right() { | 349 void test_equalityExpression_precedence_relational_right() { |
| 360 BinaryExpression expression = ParserTestCase.parseExpression("x == y is z"); | 350 BinaryExpression expression = parseExpression("x == y is z"); |
| 361 EngineTestCase.assertInstanceOf( | 351 EngineTestCase.assertInstanceOf( |
| 362 (obj) => obj is IsExpression, IsExpression, expression.rightOperand); | 352 (obj) => obj is IsExpression, IsExpression, expression.rightOperand); |
| 363 } | 353 } |
| 364 | 354 |
| 365 void test_equalityExpression_super() { | 355 void test_equalityExpression_super() { |
| 366 BinaryExpression expression = ParserTestCase.parseExpression( | 356 BinaryExpression expression = parseExpression("super == y != z", |
| 367 "super == y != z", [ | 357 [ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND]); |
| 368 ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND | |
| 369 ]); | |
| 370 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | 358 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, |
| 371 BinaryExpression, expression.leftOperand); | 359 BinaryExpression, expression.leftOperand); |
| 372 } | 360 } |
| 373 | 361 |
| 374 void test_logicalAndExpression() { | 362 void test_logicalAndExpression() { |
| 375 BinaryExpression expression = ParserTestCase.parseExpression("x && y && z"); | 363 BinaryExpression expression = parseExpression("x && y && z"); |
| 376 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | 364 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, |
| 377 BinaryExpression, expression.leftOperand); | 365 BinaryExpression, expression.leftOperand); |
| 378 } | 366 } |
| 379 | 367 |
| 380 void test_logicalAndExpression_precedence_bitwiseOr_left() { | 368 void test_logicalAndExpression_precedence_bitwiseOr_left() { |
| 381 BinaryExpression expression = ParserTestCase.parseExpression("x | y < z"); | 369 BinaryExpression expression = parseExpression("x | y < z"); |
| 382 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | 370 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, |
| 383 BinaryExpression, expression.leftOperand); | 371 BinaryExpression, expression.leftOperand); |
| 384 } | 372 } |
| 385 | 373 |
| 386 void test_logicalAndExpression_precedence_bitwiseOr_right() { | 374 void test_logicalAndExpression_precedence_bitwiseOr_right() { |
| 387 BinaryExpression expression = ParserTestCase.parseExpression("x < y | z"); | 375 BinaryExpression expression = parseExpression("x < y | z"); |
| 388 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | 376 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, |
| 389 BinaryExpression, expression.rightOperand); | 377 BinaryExpression, expression.rightOperand); |
| 390 } | 378 } |
| 391 | 379 |
| 392 void test_logicalOrExpression() { | 380 void test_logicalOrExpression() { |
| 393 BinaryExpression expression = ParserTestCase.parseExpression("x || y || z"); | 381 BinaryExpression expression = parseExpression("x || y || z"); |
| 394 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | 382 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, |
| 395 BinaryExpression, expression.leftOperand); | 383 BinaryExpression, expression.leftOperand); |
| 396 } | 384 } |
| 397 | 385 |
| 398 void test_logicalOrExpression_precedence_logicalAnd_left() { | 386 void test_logicalOrExpression_precedence_logicalAnd_left() { |
| 399 BinaryExpression expression = ParserTestCase.parseExpression("x && y || z"); | 387 BinaryExpression expression = parseExpression("x && y || z"); |
| 400 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | 388 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, |
| 401 BinaryExpression, expression.leftOperand); | 389 BinaryExpression, expression.leftOperand); |
| 402 } | 390 } |
| 403 | 391 |
| 404 void test_logicalOrExpression_precedence_logicalAnd_right() { | 392 void test_logicalOrExpression_precedence_logicalAnd_right() { |
| 405 BinaryExpression expression = ParserTestCase.parseExpression("x || y && z"); | 393 BinaryExpression expression = parseExpression("x || y && z"); |
| 406 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | 394 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, |
| 407 BinaryExpression, expression.rightOperand); | 395 BinaryExpression, expression.rightOperand); |
| 408 } | 396 } |
| 409 | 397 |
| 410 void test_multipleLabels_statement() { | 398 void test_multipleLabels_statement() { |
| 411 LabeledStatement statement = | 399 LabeledStatement statement = |
| 412 ParserTestCase.parseStatement("a: b: c: return x;"); | 400 ParserTestCase.parseStatement("a: b: c: return x;"); |
| 413 expect(statement.labels, hasLength(3)); | 401 expect(statement.labels, hasLength(3)); |
| 414 EngineTestCase.assertInstanceOf( | 402 EngineTestCase.assertInstanceOf( |
| 415 (obj) => obj is ReturnStatement, ReturnStatement, statement.statement); | 403 (obj) => obj is ReturnStatement, ReturnStatement, statement.statement); |
| 416 } | 404 } |
| 417 | 405 |
| 418 void test_multiplicativeExpression_normal() { | 406 void test_multiplicativeExpression_normal() { |
| 419 BinaryExpression expression = ParserTestCase.parseExpression("x * y / z"); | 407 BinaryExpression expression = parseExpression("x * y / z"); |
| 420 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | 408 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, |
| 421 BinaryExpression, expression.leftOperand); | 409 BinaryExpression, expression.leftOperand); |
| 422 } | 410 } |
| 423 | 411 |
| 424 void test_multiplicativeExpression_precedence_unary_left() { | 412 void test_multiplicativeExpression_precedence_unary_left() { |
| 425 BinaryExpression expression = ParserTestCase.parseExpression("-x * y"); | 413 BinaryExpression expression = parseExpression("-x * y"); |
| 426 EngineTestCase.assertInstanceOf((obj) => obj is PrefixExpression, | 414 EngineTestCase.assertInstanceOf((obj) => obj is PrefixExpression, |
| 427 PrefixExpression, expression.leftOperand); | 415 PrefixExpression, expression.leftOperand); |
| 428 } | 416 } |
| 429 | 417 |
| 430 void test_multiplicativeExpression_precedence_unary_right() { | 418 void test_multiplicativeExpression_precedence_unary_right() { |
| 431 BinaryExpression expression = ParserTestCase.parseExpression("x * -y"); | 419 BinaryExpression expression = parseExpression("x * -y"); |
| 432 EngineTestCase.assertInstanceOf((obj) => obj is PrefixExpression, | 420 EngineTestCase.assertInstanceOf((obj) => obj is PrefixExpression, |
| 433 PrefixExpression, expression.rightOperand); | 421 PrefixExpression, expression.rightOperand); |
| 434 } | 422 } |
| 435 | 423 |
| 436 void test_multiplicativeExpression_super() { | 424 void test_multiplicativeExpression_super() { |
| 437 BinaryExpression expression = | 425 BinaryExpression expression = parseExpression("super * y / z"); |
| 438 ParserTestCase.parseExpression("super * y / z"); | |
| 439 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | 426 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, |
| 440 BinaryExpression, expression.leftOperand); | 427 BinaryExpression, expression.leftOperand); |
| 441 } | 428 } |
| 442 | 429 |
| 443 void test_relationalExpression_precedence_shift_right() { | 430 void test_relationalExpression_precedence_shift_right() { |
| 444 IsExpression expression = ParserTestCase.parseExpression("x << y is z"); | 431 IsExpression expression = parseExpression("x << y is z"); |
| 445 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | 432 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, |
| 446 BinaryExpression, expression.expression); | 433 BinaryExpression, expression.expression); |
| 447 } | 434 } |
| 448 | 435 |
| 449 void test_shiftExpression_normal() { | 436 void test_shiftExpression_normal() { |
| 450 BinaryExpression expression = ParserTestCase.parseExpression("x >> 4 << 3"); | 437 BinaryExpression expression = parseExpression("x >> 4 << 3"); |
| 451 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | 438 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, |
| 452 BinaryExpression, expression.leftOperand); | 439 BinaryExpression, expression.leftOperand); |
| 453 } | 440 } |
| 454 | 441 |
| 455 void test_shiftExpression_precedence_additive_left() { | 442 void test_shiftExpression_precedence_additive_left() { |
| 456 BinaryExpression expression = ParserTestCase.parseExpression("x + y << z"); | 443 BinaryExpression expression = parseExpression("x + y << z"); |
| 457 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | 444 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, |
| 458 BinaryExpression, expression.leftOperand); | 445 BinaryExpression, expression.leftOperand); |
| 459 } | 446 } |
| 460 | 447 |
| 461 void test_shiftExpression_precedence_additive_right() { | 448 void test_shiftExpression_precedence_additive_right() { |
| 462 BinaryExpression expression = ParserTestCase.parseExpression("x << y + z"); | 449 BinaryExpression expression = parseExpression("x << y + z"); |
| 463 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | 450 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, |
| 464 BinaryExpression, expression.rightOperand); | 451 BinaryExpression, expression.rightOperand); |
| 465 } | 452 } |
| 466 | 453 |
| 467 void test_shiftExpression_super() { | 454 void test_shiftExpression_super() { |
| 468 BinaryExpression expression = | 455 BinaryExpression expression = parseExpression("super >> 4 << 3"); |
| 469 ParserTestCase.parseExpression("super >> 4 << 3"); | |
| 470 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | 456 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, |
| 471 BinaryExpression, expression.leftOperand); | 457 BinaryExpression, expression.leftOperand); |
| 472 } | 458 } |
| 473 | 459 |
| 474 void test_topLevelVariable_withMetadata() { | 460 void test_topLevelVariable_withMetadata() { |
| 475 ParserTestCase.parseCompilationUnit("String @A string;"); | 461 ParserTestCase.parseCompilationUnit("String @A string;"); |
| 476 } | 462 } |
| 477 } | 463 } |
| 478 | 464 |
| 479 /** | 465 /** |
| 480 * The class `ErrorParserTest` defines parser tests that test the parsing of cod
e to ensure | 466 * The class `ErrorParserTest` defines parser tests that test the parsing of cod
e to ensure |
| 481 * that errors are correctly reported, and in some cases, not reported. | 467 * that errors are correctly reported, and in some cases, not reported. |
| 482 */ | 468 */ |
| 483 @reflectiveTest | 469 @reflectiveTest |
| 484 class ErrorParserTest extends ParserTestCase { | 470 class ErrorParserTest extends ParserTestCase { |
| 485 void fail_expectedListOrMapLiteral() { | 471 void fail_expectedListOrMapLiteral() { |
| 486 // It isn't clear that this test can ever pass. The parser is currently | 472 // It isn't clear that this test can ever pass. The parser is currently |
| 487 // create a synthetic list literal in this case, but isSynthetic() isn't | 473 // create a synthetic list literal in this case, but isSynthetic() isn't |
| 488 // overridden for ListLiteral. The problem is that the synthetic list | 474 // overridden for ListLiteral. The problem is that the synthetic list |
| 489 // literals that are being created are not always zero length (because they | 475 // literals that are being created are not always zero length (because they |
| 490 // could have type parameters), which violates the contract of | 476 // could have type parameters), which violates the contract of |
| 491 // isSynthetic(). | 477 // isSynthetic(). |
| 492 TypedLiteral literal = ParserTestCase.parse3("parseListOrMapLiteral", | 478 TypedLiteral literal = parse3("parseListOrMapLiteral", <Object>[null], "1", |
| 493 <Object>[null], "1", [ParserErrorCode.EXPECTED_LIST_OR_MAP_LITERAL]); | 479 [ParserErrorCode.EXPECTED_LIST_OR_MAP_LITERAL]); |
| 494 expect(literal.isSynthetic, isTrue); | 480 expect(literal.isSynthetic, isTrue); |
| 495 } | 481 } |
| 496 | 482 |
| 497 void fail_illegalAssignmentToNonAssignable_superAssigned() { | 483 void fail_illegalAssignmentToNonAssignable_superAssigned() { |
| 498 // TODO(brianwilkerson) When this test starts to pass, remove the test | 484 // TODO(brianwilkerson) When this test starts to pass, remove the test |
| 499 // test_illegalAssignmentToNonAssignable_superAssigned. | 485 // test_illegalAssignmentToNonAssignable_superAssigned. |
| 500 ParserTestCase.parseExpression( | 486 parseExpression( |
| 501 "super = x;", [ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE]); | 487 "super = x;", [ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE]); |
| 502 } | 488 } |
| 503 | 489 |
| 504 void fail_invalidCommentReference__new_nonIdentifier() { | 490 void fail_invalidCommentReference__new_nonIdentifier() { |
| 505 // This test fails because the method parseCommentReference returns null. | 491 // This test fails because the method parseCommentReference returns null. |
| 506 ParserTestCase.parse3("parseCommentReference", <Object>["new 42", 0], "", [ | 492 parse3("parseCommentReference", <Object>[ |
| 507 ParserErrorCode.INVALID_COMMENT_REFERENCE | 493 "new 42", |
| 508 ]); | 494 0 |
| 495 ], "", [ParserErrorCode.INVALID_COMMENT_REFERENCE]); |
| 509 } | 496 } |
| 510 | 497 |
| 511 void fail_invalidCommentReference__new_tooMuch() { | 498 void fail_invalidCommentReference__new_tooMuch() { |
| 512 ParserTestCase.parse3("parseCommentReference", <Object>[ | 499 parse3("parseCommentReference", <Object>[ |
| 513 "new a.b.c.d", | 500 "new a.b.c.d", |
| 514 0 | 501 0 |
| 515 ], "", [ParserErrorCode.INVALID_COMMENT_REFERENCE]); | 502 ], "", [ParserErrorCode.INVALID_COMMENT_REFERENCE]); |
| 516 } | 503 } |
| 517 | 504 |
| 518 void fail_invalidCommentReference__nonNew_nonIdentifier() { | 505 void fail_invalidCommentReference__nonNew_nonIdentifier() { |
| 519 // This test fails because the method parseCommentReference returns null. | 506 // This test fails because the method parseCommentReference returns null. |
| 520 ParserTestCase.parse3("parseCommentReference", <Object>["42", 0], "", [ | 507 parse3("parseCommentReference", <Object>[ |
| 521 ParserErrorCode.INVALID_COMMENT_REFERENCE | 508 "42", |
| 522 ]); | 509 0 |
| 510 ], "", [ParserErrorCode.INVALID_COMMENT_REFERENCE]); |
| 523 } | 511 } |
| 524 | 512 |
| 525 void fail_invalidCommentReference__nonNew_tooMuch() { | 513 void fail_invalidCommentReference__nonNew_tooMuch() { |
| 526 ParserTestCase.parse3("parseCommentReference", <Object>["a.b.c.d", 0], "", [ | 514 parse3("parseCommentReference", <Object>[ |
| 527 ParserErrorCode.INVALID_COMMENT_REFERENCE | 515 "a.b.c.d", |
| 528 ]); | 516 0 |
| 517 ], "", [ParserErrorCode.INVALID_COMMENT_REFERENCE]); |
| 529 } | 518 } |
| 530 | 519 |
| 531 void fail_missingClosingParenthesis() { | 520 void fail_missingClosingParenthesis() { |
| 532 // It is possible that it is not possible to generate this error (that it's | 521 // It is possible that it is not possible to generate this error (that it's |
| 533 // being reported in code that cannot actually be reached), but that hasn't | 522 // being reported in code that cannot actually be reached), but that hasn't |
| 534 // been proven yet. | 523 // been proven yet. |
| 535 ParserTestCase.parse4("parseFormalParameterList", "(int a, int b ;", [ | 524 parse4("parseFormalParameterList", "(int a, int b ;", |
| 536 ParserErrorCode.MISSING_CLOSING_PARENTHESIS | 525 [ParserErrorCode.MISSING_CLOSING_PARENTHESIS]); |
| 537 ]); | |
| 538 } | 526 } |
| 539 | 527 |
| 540 void fail_missingFunctionParameters_local_nonVoid_block() { | 528 void fail_missingFunctionParameters_local_nonVoid_block() { |
| 541 // The parser does not recognize this as a function declaration, so it tries | 529 // The parser does not recognize this as a function declaration, so it tries |
| 542 // to parse it as an expression statement. It isn't clear what the best | 530 // to parse it as an expression statement. It isn't clear what the best |
| 543 // error message is in this case. | 531 // error message is in this case. |
| 544 ParserTestCase.parseStatement( | 532 ParserTestCase.parseStatement( |
| 545 "int f { return x;}", [ParserErrorCode.MISSING_FUNCTION_PARAMETERS]); | 533 "int f { return x;}", [ParserErrorCode.MISSING_FUNCTION_PARAMETERS]); |
| 546 } | 534 } |
| 547 | 535 |
| 548 void fail_missingFunctionParameters_local_nonVoid_expression() { | 536 void fail_missingFunctionParameters_local_nonVoid_expression() { |
| 549 // The parser does not recognize this as a function declaration, so it tries | 537 // The parser does not recognize this as a function declaration, so it tries |
| 550 // to parse it as an expression statement. It isn't clear what the best | 538 // to parse it as an expression statement. It isn't clear what the best |
| 551 // error message is in this case. | 539 // error message is in this case. |
| 552 ParserTestCase.parseStatement( | 540 ParserTestCase.parseStatement( |
| 553 "int f => x;", [ParserErrorCode.MISSING_FUNCTION_PARAMETERS]); | 541 "int f => x;", [ParserErrorCode.MISSING_FUNCTION_PARAMETERS]); |
| 554 } | 542 } |
| 555 | 543 |
| 556 void fail_namedFunctionExpression() { | 544 void fail_namedFunctionExpression() { |
| 557 Expression expression = ParserTestCase.parse4("parsePrimaryExpression", | 545 Expression expression = parse4("parsePrimaryExpression", "f() {}", |
| 558 "f() {}", [ParserErrorCode.NAMED_FUNCTION_EXPRESSION]); | 546 [ParserErrorCode.NAMED_FUNCTION_EXPRESSION]); |
| 559 EngineTestCase.assertInstanceOf( | 547 EngineTestCase.assertInstanceOf( |
| 560 (obj) => obj is FunctionExpression, FunctionExpression, expression); | 548 (obj) => obj is FunctionExpression, FunctionExpression, expression); |
| 561 } | 549 } |
| 562 | 550 |
| 563 void fail_unexpectedToken_invalidPostfixExpression() { | 551 void fail_unexpectedToken_invalidPostfixExpression() { |
| 564 // Note: this might not be the right error to produce, but some error should | 552 // Note: this might not be the right error to produce, but some error should |
| 565 // be produced | 553 // be produced |
| 566 ParserTestCase.parseExpression("f()++", [ParserErrorCode.UNEXPECTED_TOKEN]); | 554 parseExpression("f()++", [ParserErrorCode.UNEXPECTED_TOKEN]); |
| 567 } | 555 } |
| 568 | 556 |
| 569 void fail_varAndType_local() { | 557 void fail_varAndType_local() { |
| 570 // This is currently reporting EXPECTED_TOKEN for a missing semicolon, but | 558 // This is currently reporting EXPECTED_TOKEN for a missing semicolon, but |
| 571 // this would be a better error message. | 559 // this would be a better error message. |
| 572 ParserTestCase.parseStatement("var int x;", [ParserErrorCode.VAR_AND_TYPE]); | 560 ParserTestCase.parseStatement("var int x;", [ParserErrorCode.VAR_AND_TYPE]); |
| 573 } | 561 } |
| 574 | 562 |
| 575 void fail_varAndType_parameter() { | 563 void fail_varAndType_parameter() { |
| 576 // This is currently reporting EXPECTED_TOKEN for a missing semicolon, but | 564 // This is currently reporting EXPECTED_TOKEN for a missing semicolon, but |
| 577 // this would be a better error message. | 565 // this would be a better error message. |
| 578 ParserTestCase.parse4("parseFormalParameterList", "(var int x)", [ | 566 parse4("parseFormalParameterList", "(var int x)", |
| 579 ParserErrorCode.VAR_AND_TYPE | 567 [ParserErrorCode.VAR_AND_TYPE]); |
| 580 ]); | |
| 581 } | 568 } |
| 582 | 569 |
| 583 void test_abstractClassMember_constructor() { | 570 void test_abstractClassMember_constructor() { |
| 584 ParserTestCase.parse3("parseClassMember", <Object>[ | 571 parse3("parseClassMember", <Object>["C"], "abstract C.c();", |
| 585 "C" | 572 [ParserErrorCode.ABSTRACT_CLASS_MEMBER]); |
| 586 ], "abstract C.c();", [ParserErrorCode.ABSTRACT_CLASS_MEMBER]); | |
| 587 } | 573 } |
| 588 | 574 |
| 589 void test_abstractClassMember_field() { | 575 void test_abstractClassMember_field() { |
| 590 ParserTestCase.parse3("parseClassMember", <Object>["C"], "abstract C f;", [ | 576 parse3("parseClassMember", <Object>["C"], "abstract C f;", |
| 591 ParserErrorCode.ABSTRACT_CLASS_MEMBER | 577 [ParserErrorCode.ABSTRACT_CLASS_MEMBER]); |
| 592 ]); | |
| 593 } | 578 } |
| 594 | 579 |
| 595 void test_abstractClassMember_getter() { | 580 void test_abstractClassMember_getter() { |
| 596 ParserTestCase.parse3("parseClassMember", <Object>[ | 581 parse3("parseClassMember", <Object>["C"], "abstract get m;", |
| 597 "C" | 582 [ParserErrorCode.ABSTRACT_CLASS_MEMBER]); |
| 598 ], "abstract get m;", [ParserErrorCode.ABSTRACT_CLASS_MEMBER]); | |
| 599 } | 583 } |
| 600 | 584 |
| 601 void test_abstractClassMember_method() { | 585 void test_abstractClassMember_method() { |
| 602 ParserTestCase.parse3("parseClassMember", <Object>["C"], "abstract m();", [ | 586 parse3("parseClassMember", <Object>["C"], "abstract m();", |
| 603 ParserErrorCode.ABSTRACT_CLASS_MEMBER | 587 [ParserErrorCode.ABSTRACT_CLASS_MEMBER]); |
| 604 ]); | |
| 605 } | 588 } |
| 606 | 589 |
| 607 void test_abstractClassMember_setter() { | 590 void test_abstractClassMember_setter() { |
| 608 ParserTestCase.parse3("parseClassMember", <Object>[ | 591 parse3("parseClassMember", <Object>["C"], "abstract set m(v);", |
| 609 "C" | 592 [ParserErrorCode.ABSTRACT_CLASS_MEMBER]); |
| 610 ], "abstract set m(v);", [ParserErrorCode.ABSTRACT_CLASS_MEMBER]); | |
| 611 } | 593 } |
| 612 | 594 |
| 613 void test_abstractEnum() { | 595 void test_abstractEnum() { |
| 614 ParserTestCase.parseCompilationUnit( | 596 ParserTestCase.parseCompilationUnit( |
| 615 "abstract enum E {ONE}", [ParserErrorCode.ABSTRACT_ENUM]); | 597 "abstract enum E {ONE}", [ParserErrorCode.ABSTRACT_ENUM]); |
| 616 } | 598 } |
| 617 | 599 |
| 618 void test_abstractTopLevelFunction_function() { | 600 void test_abstractTopLevelFunction_function() { |
| 619 ParserTestCase.parseCompilationUnit( | 601 ParserTestCase.parseCompilationUnit( |
| 620 "abstract f(v) {}", [ParserErrorCode.ABSTRACT_TOP_LEVEL_FUNCTION]); | 602 "abstract f(v) {}", [ParserErrorCode.ABSTRACT_TOP_LEVEL_FUNCTION]); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 634 ParserTestCase.parseCompilationUnit( | 616 ParserTestCase.parseCompilationUnit( |
| 635 "abstract C f;", [ParserErrorCode.ABSTRACT_TOP_LEVEL_VARIABLE]); | 617 "abstract C f;", [ParserErrorCode.ABSTRACT_TOP_LEVEL_VARIABLE]); |
| 636 } | 618 } |
| 637 | 619 |
| 638 void test_abstractTypeDef() { | 620 void test_abstractTypeDef() { |
| 639 ParserTestCase.parseCompilationUnit( | 621 ParserTestCase.parseCompilationUnit( |
| 640 "abstract typedef F();", [ParserErrorCode.ABSTRACT_TYPEDEF]); | 622 "abstract typedef F();", [ParserErrorCode.ABSTRACT_TYPEDEF]); |
| 641 } | 623 } |
| 642 | 624 |
| 643 void test_annotationOnEnumConstant_first() { | 625 void test_annotationOnEnumConstant_first() { |
| 644 ParserTestCase.parseCompilationUnit("enum E { @override C }", [ | 626 ParserTestCase.parseCompilationUnit("enum E { @override C }", |
| 645 ParserErrorCode.ANNOTATION_ON_ENUM_CONSTANT | 627 [ParserErrorCode.ANNOTATION_ON_ENUM_CONSTANT]); |
| 646 ]); | |
| 647 } | 628 } |
| 648 | 629 |
| 649 void test_annotationOnEnumConstant_middle() { | 630 void test_annotationOnEnumConstant_middle() { |
| 650 ParserTestCase.parseCompilationUnit("enum E { C, @override D, E }", [ | 631 ParserTestCase.parseCompilationUnit("enum E { C, @override D, E }", |
| 651 ParserErrorCode.ANNOTATION_ON_ENUM_CONSTANT | 632 [ParserErrorCode.ANNOTATION_ON_ENUM_CONSTANT]); |
| 652 ]); | |
| 653 } | 633 } |
| 654 | 634 |
| 655 void test_assertDoesNotTakeAssignment() { | 635 void test_assertDoesNotTakeAssignment() { |
| 656 ParserTestCase.parse4("parseAssertStatement", "assert(b = true);", [ | 636 parse4("parseAssertStatement", "assert(b = true);", |
| 657 ParserErrorCode.ASSERT_DOES_NOT_TAKE_ASSIGNMENT | 637 [ParserErrorCode.ASSERT_DOES_NOT_TAKE_ASSIGNMENT]); |
| 658 ]); | |
| 659 } | 638 } |
| 660 | 639 |
| 661 void test_assertDoesNotTakeCascades() { | 640 void test_assertDoesNotTakeCascades() { |
| 662 ParserTestCase.parse4("parseAssertStatement", "assert(new A()..m());", [ | 641 parse4("parseAssertStatement", "assert(new A()..m());", |
| 663 ParserErrorCode.ASSERT_DOES_NOT_TAKE_CASCADE | 642 [ParserErrorCode.ASSERT_DOES_NOT_TAKE_CASCADE]); |
| 664 ]); | |
| 665 } | 643 } |
| 666 | 644 |
| 667 void test_assertDoesNotTakeRethrow() { | 645 void test_assertDoesNotTakeRethrow() { |
| 668 ParserTestCase.parse4("parseAssertStatement", "assert(rethrow);", [ | 646 parse4("parseAssertStatement", "assert(rethrow);", |
| 669 ParserErrorCode.ASSERT_DOES_NOT_TAKE_RETHROW | 647 [ParserErrorCode.ASSERT_DOES_NOT_TAKE_RETHROW]); |
| 670 ]); | |
| 671 } | 648 } |
| 672 | 649 |
| 673 void test_assertDoesNotTakeThrow() { | 650 void test_assertDoesNotTakeThrow() { |
| 674 ParserTestCase.parse4("parseAssertStatement", "assert(throw x);", [ | 651 parse4("parseAssertStatement", "assert(throw x);", |
| 675 ParserErrorCode.ASSERT_DOES_NOT_TAKE_THROW | 652 [ParserErrorCode.ASSERT_DOES_NOT_TAKE_THROW]); |
| 676 ]); | |
| 677 } | 653 } |
| 678 | 654 |
| 679 void test_breakOutsideOfLoop_breakInDoStatement() { | 655 void test_breakOutsideOfLoop_breakInDoStatement() { |
| 680 ParserTestCase.parse4("parseDoStatement", "do {break;} while (x);"); | 656 parse4("parseDoStatement", "do {break;} while (x);"); |
| 681 } | 657 } |
| 682 | 658 |
| 683 void test_breakOutsideOfLoop_breakInForStatement() { | 659 void test_breakOutsideOfLoop_breakInForStatement() { |
| 684 ParserTestCase.parse4("parseForStatement", "for (; x;) {break;}"); | 660 parse4("parseForStatement", "for (; x;) {break;}"); |
| 685 } | 661 } |
| 686 | 662 |
| 687 void test_breakOutsideOfLoop_breakInIfStatement() { | 663 void test_breakOutsideOfLoop_breakInIfStatement() { |
| 688 ParserTestCase.parse4("parseIfStatement", "if (x) {break;}", [ | 664 parse4("parseIfStatement", "if (x) {break;}", |
| 689 ParserErrorCode.BREAK_OUTSIDE_OF_LOOP | 665 [ParserErrorCode.BREAK_OUTSIDE_OF_LOOP]); |
| 690 ]); | |
| 691 } | 666 } |
| 692 | 667 |
| 693 void test_breakOutsideOfLoop_breakInSwitchStatement() { | 668 void test_breakOutsideOfLoop_breakInSwitchStatement() { |
| 694 ParserTestCase.parse4( | 669 parse4("parseSwitchStatement", "switch (x) {case 1: break;}"); |
| 695 "parseSwitchStatement", "switch (x) {case 1: break;}"); | |
| 696 } | 670 } |
| 697 | 671 |
| 698 void test_breakOutsideOfLoop_breakInWhileStatement() { | 672 void test_breakOutsideOfLoop_breakInWhileStatement() { |
| 699 ParserTestCase.parse4("parseWhileStatement", "while (x) {break;}"); | 673 parse4("parseWhileStatement", "while (x) {break;}"); |
| 700 } | 674 } |
| 701 | 675 |
| 702 void test_breakOutsideOfLoop_functionExpression_inALoop() { | 676 void test_breakOutsideOfLoop_functionExpression_inALoop() { |
| 703 ParserTestCase.parseStatement( | 677 ParserTestCase.parseStatement( |
| 704 "for(; x;) {() {break;};}", [ParserErrorCode.BREAK_OUTSIDE_OF_LOOP]); | 678 "for(; x;) {() {break;};}", [ParserErrorCode.BREAK_OUTSIDE_OF_LOOP]); |
| 705 } | 679 } |
| 706 | 680 |
| 707 void test_breakOutsideOfLoop_functionExpression_withALoop() { | 681 void test_breakOutsideOfLoop_functionExpression_withALoop() { |
| 708 ParserTestCase.parseStatement("() {for (; x;) {break;}};"); | 682 ParserTestCase.parseStatement("() {for (; x;) {break;}};"); |
| 709 } | 683 } |
| 710 | 684 |
| 711 void test_classInClass_abstract() { | 685 void test_classInClass_abstract() { |
| 712 ParserTestCase.parseCompilationUnit( | 686 ParserTestCase.parseCompilationUnit( |
| 713 "class C { abstract class B {} }", [ParserErrorCode.CLASS_IN_CLASS]); | 687 "class C { abstract class B {} }", [ParserErrorCode.CLASS_IN_CLASS]); |
| 714 } | 688 } |
| 715 | 689 |
| 716 void test_classInClass_nonAbstract() { | 690 void test_classInClass_nonAbstract() { |
| 717 ParserTestCase.parseCompilationUnit( | 691 ParserTestCase.parseCompilationUnit( |
| 718 "class C { class B {} }", [ParserErrorCode.CLASS_IN_CLASS]); | 692 "class C { class B {} }", [ParserErrorCode.CLASS_IN_CLASS]); |
| 719 } | 693 } |
| 720 | 694 |
| 721 void test_classTypeAlias_abstractAfterEq() { | 695 void test_classTypeAlias_abstractAfterEq() { |
| 722 // This syntax has been removed from the language in favor of | 696 // This syntax has been removed from the language in favor of |
| 723 // "abstract class A = B with C;" (issue 18098). | 697 // "abstract class A = B with C;" (issue 18098). |
| 724 ParserTestCase.parse3("parseCompilationUnitMember", <Object>[ | 698 parse3("parseCompilationUnitMember", <Object>[emptyCommentAndMetadata()], |
| 725 emptyCommentAndMetadata() | 699 "class A = abstract B with C;", [ |
| 726 ], "class A = abstract B with C;", [ | |
| 727 ParserErrorCode.EXPECTED_TOKEN, | 700 ParserErrorCode.EXPECTED_TOKEN, |
| 728 ParserErrorCode.EXPECTED_TOKEN | 701 ParserErrorCode.EXPECTED_TOKEN |
| 729 ]); | 702 ]); |
| 730 } | 703 } |
| 731 | 704 |
| 732 void test_colonInPlaceOfIn() { | 705 void test_colonInPlaceOfIn() { |
| 733 ParserTestCase.parseStatement( | 706 ParserTestCase.parseStatement( |
| 734 "for (var x : list) {}", [ParserErrorCode.COLON_IN_PLACE_OF_IN]); | 707 "for (var x : list) {}", [ParserErrorCode.COLON_IN_PLACE_OF_IN]); |
| 735 } | 708 } |
| 736 | 709 |
| 737 void test_constAndFinal() { | 710 void test_constAndFinal() { |
| 738 ParserTestCase.parse3("parseClassMember", <Object>[ | 711 parse3("parseClassMember", <Object>["C"], "const final int x;", |
| 739 "C" | 712 [ParserErrorCode.CONST_AND_FINAL]); |
| 740 ], "const final int x;", [ParserErrorCode.CONST_AND_FINAL]); | |
| 741 } | 713 } |
| 742 | 714 |
| 743 void test_constAndVar() { | 715 void test_constAndVar() { |
| 744 ParserTestCase.parse3("parseClassMember", <Object>["C"], "const var x;", [ | 716 parse3("parseClassMember", <Object>["C"], "const var x;", |
| 745 ParserErrorCode.CONST_AND_VAR | 717 [ParserErrorCode.CONST_AND_VAR]); |
| 746 ]); | |
| 747 } | 718 } |
| 748 | 719 |
| 749 void test_constClass() { | 720 void test_constClass() { |
| 750 ParserTestCase.parseCompilationUnit( | 721 ParserTestCase.parseCompilationUnit( |
| 751 "const class C {}", [ParserErrorCode.CONST_CLASS]); | 722 "const class C {}", [ParserErrorCode.CONST_CLASS]); |
| 752 } | 723 } |
| 753 | 724 |
| 754 void test_constConstructorWithBody() { | 725 void test_constConstructorWithBody() { |
| 755 ParserTestCase.parse3("parseClassMember", <Object>["C"], "const C() {}", [ | 726 parse3("parseClassMember", <Object>["C"], "const C() {}", |
| 756 ParserErrorCode.CONST_CONSTRUCTOR_WITH_BODY | 727 [ParserErrorCode.CONST_CONSTRUCTOR_WITH_BODY]); |
| 757 ]); | |
| 758 } | 728 } |
| 759 | 729 |
| 760 void test_constEnum() { | 730 void test_constEnum() { |
| 761 ParserTestCase.parseCompilationUnit( | 731 ParserTestCase.parseCompilationUnit( |
| 762 "const enum E {ONE}", [ParserErrorCode.CONST_ENUM]); | 732 "const enum E {ONE}", [ParserErrorCode.CONST_ENUM]); |
| 763 } | 733 } |
| 764 | 734 |
| 765 void test_constFactory() { | 735 void test_constFactory() { |
| 766 ParserTestCase.parse3("parseClassMember", <Object>[ | 736 parse3("parseClassMember", <Object>["C"], "const factory C() {}", |
| 767 "C" | 737 [ParserErrorCode.CONST_FACTORY]); |
| 768 ], "const factory C() {}", [ParserErrorCode.CONST_FACTORY]); | |
| 769 } | 738 } |
| 770 | 739 |
| 771 void test_constMethod() { | 740 void test_constMethod() { |
| 772 ParserTestCase.parse3("parseClassMember", <Object>[ | 741 parse3("parseClassMember", <Object>["C"], "const int m() {}", |
| 773 "C" | 742 [ParserErrorCode.CONST_METHOD]); |
| 774 ], "const int m() {}", [ParserErrorCode.CONST_METHOD]); | |
| 775 } | 743 } |
| 776 | 744 |
| 777 void test_constructorWithReturnType() { | 745 void test_constructorWithReturnType() { |
| 778 ParserTestCase.parse3("parseClassMember", <Object>["C"], "C C() {}", [ | 746 parse3("parseClassMember", <Object>["C"], "C C() {}", |
| 779 ParserErrorCode.CONSTRUCTOR_WITH_RETURN_TYPE | 747 [ParserErrorCode.CONSTRUCTOR_WITH_RETURN_TYPE]); |
| 780 ]); | |
| 781 } | 748 } |
| 782 | 749 |
| 783 void test_constructorWithReturnType_var() { | 750 void test_constructorWithReturnType_var() { |
| 784 ParserTestCase.parse3("parseClassMember", <Object>["C"], "var C() {}", [ | 751 parse3("parseClassMember", <Object>["C"], "var C() {}", |
| 785 ParserErrorCode.CONSTRUCTOR_WITH_RETURN_TYPE | 752 [ParserErrorCode.CONSTRUCTOR_WITH_RETURN_TYPE]); |
| 786 ]); | |
| 787 } | 753 } |
| 788 | 754 |
| 789 void test_constTypedef() { | 755 void test_constTypedef() { |
| 790 ParserTestCase.parseCompilationUnit( | 756 ParserTestCase.parseCompilationUnit( |
| 791 "const typedef F();", [ParserErrorCode.CONST_TYPEDEF]); | 757 "const typedef F();", [ParserErrorCode.CONST_TYPEDEF]); |
| 792 } | 758 } |
| 793 | 759 |
| 794 void test_continueOutsideOfLoop_continueInDoStatement() { | 760 void test_continueOutsideOfLoop_continueInDoStatement() { |
| 795 ParserTestCase.parse4("parseDoStatement", "do {continue;} while (x);"); | 761 parse4("parseDoStatement", "do {continue;} while (x);"); |
| 796 } | 762 } |
| 797 | 763 |
| 798 void test_continueOutsideOfLoop_continueInForStatement() { | 764 void test_continueOutsideOfLoop_continueInForStatement() { |
| 799 ParserTestCase.parse4("parseForStatement", "for (; x;) {continue;}"); | 765 parse4("parseForStatement", "for (; x;) {continue;}"); |
| 800 } | 766 } |
| 801 | 767 |
| 802 void test_continueOutsideOfLoop_continueInIfStatement() { | 768 void test_continueOutsideOfLoop_continueInIfStatement() { |
| 803 ParserTestCase.parse4("parseIfStatement", "if (x) {continue;}", [ | 769 parse4("parseIfStatement", "if (x) {continue;}", |
| 804 ParserErrorCode.CONTINUE_OUTSIDE_OF_LOOP | 770 [ParserErrorCode.CONTINUE_OUTSIDE_OF_LOOP]); |
| 805 ]); | |
| 806 } | 771 } |
| 807 | 772 |
| 808 void test_continueOutsideOfLoop_continueInSwitchStatement() { | 773 void test_continueOutsideOfLoop_continueInSwitchStatement() { |
| 809 ParserTestCase.parse4( | 774 parse4("parseSwitchStatement", "switch (x) {case 1: continue a;}"); |
| 810 "parseSwitchStatement", "switch (x) {case 1: continue a;}"); | |
| 811 } | 775 } |
| 812 | 776 |
| 813 void test_continueOutsideOfLoop_continueInWhileStatement() { | 777 void test_continueOutsideOfLoop_continueInWhileStatement() { |
| 814 ParserTestCase.parse4("parseWhileStatement", "while (x) {continue;}"); | 778 parse4("parseWhileStatement", "while (x) {continue;}"); |
| 815 } | 779 } |
| 816 | 780 |
| 817 void test_continueOutsideOfLoop_functionExpression_inALoop() { | 781 void test_continueOutsideOfLoop_functionExpression_inALoop() { |
| 818 ParserTestCase.parseStatement("for(; x;) {() {continue;};}", [ | 782 ParserTestCase.parseStatement("for(; x;) {() {continue;};}", |
| 819 ParserErrorCode.CONTINUE_OUTSIDE_OF_LOOP | 783 [ParserErrorCode.CONTINUE_OUTSIDE_OF_LOOP]); |
| 820 ]); | |
| 821 } | 784 } |
| 822 | 785 |
| 823 void test_continueOutsideOfLoop_functionExpression_withALoop() { | 786 void test_continueOutsideOfLoop_functionExpression_withALoop() { |
| 824 ParserTestCase.parseStatement("() {for (; x;) {continue;}};"); | 787 ParserTestCase.parseStatement("() {for (; x;) {continue;}};"); |
| 825 } | 788 } |
| 826 | 789 |
| 827 void test_continueWithoutLabelInCase_error() { | 790 void test_continueWithoutLabelInCase_error() { |
| 828 ParserTestCase.parse4("parseSwitchStatement", | 791 parse4("parseSwitchStatement", "switch (x) {case 1: continue;}", |
| 829 "switch (x) {case 1: continue;}", [ | 792 [ParserErrorCode.CONTINUE_WITHOUT_LABEL_IN_CASE]); |
| 830 ParserErrorCode.CONTINUE_WITHOUT_LABEL_IN_CASE | |
| 831 ]); | |
| 832 } | 793 } |
| 833 | 794 |
| 834 void test_continueWithoutLabelInCase_noError() { | 795 void test_continueWithoutLabelInCase_noError() { |
| 835 ParserTestCase.parse4( | 796 parse4("parseSwitchStatement", "switch (x) {case 1: continue a;}"); |
| 836 "parseSwitchStatement", "switch (x) {case 1: continue a;}"); | |
| 837 } | 797 } |
| 838 | 798 |
| 839 void test_continueWithoutLabelInCase_noError_switchInLoop() { | 799 void test_continueWithoutLabelInCase_noError_switchInLoop() { |
| 840 ParserTestCase.parse4( | 800 parse4( |
| 841 "parseWhileStatement", "while (a) { switch (b) {default: continue;}}"); | 801 "parseWhileStatement", "while (a) { switch (b) {default: continue;}}"); |
| 842 } | 802 } |
| 843 | 803 |
| 844 void test_deprecatedClassTypeAlias() { | 804 void test_deprecatedClassTypeAlias() { |
| 845 ParserTestCase.parseCompilationUnit( | 805 ParserTestCase.parseCompilationUnit( |
| 846 "typedef C = S with M;", [ParserErrorCode.DEPRECATED_CLASS_TYPE_ALIAS]); | 806 "typedef C = S with M;", [ParserErrorCode.DEPRECATED_CLASS_TYPE_ALIAS]); |
| 847 } | 807 } |
| 848 | 808 |
| 849 void test_deprecatedClassTypeAlias_withGeneric() { | 809 void test_deprecatedClassTypeAlias_withGeneric() { |
| 850 ParserTestCase.parseCompilationUnit("typedef C<T> = S<T> with M;", [ | 810 ParserTestCase.parseCompilationUnit("typedef C<T> = S<T> with M;", |
| 851 ParserErrorCode.DEPRECATED_CLASS_TYPE_ALIAS | 811 [ParserErrorCode.DEPRECATED_CLASS_TYPE_ALIAS]); |
| 852 ]); | |
| 853 } | 812 } |
| 854 | 813 |
| 855 void test_directiveAfterDeclaration_classBeforeDirective() { | 814 void test_directiveAfterDeclaration_classBeforeDirective() { |
| 856 CompilationUnit unit = ParserTestCase.parseCompilationUnit( | 815 CompilationUnit unit = ParserTestCase.parseCompilationUnit( |
| 857 "class Foo{} library l;", [ | 816 "class Foo{} library l;", |
| 858 ParserErrorCode.DIRECTIVE_AFTER_DECLARATION | 817 [ParserErrorCode.DIRECTIVE_AFTER_DECLARATION]); |
| 859 ]); | |
| 860 expect(unit, isNotNull); | 818 expect(unit, isNotNull); |
| 861 } | 819 } |
| 862 | 820 |
| 863 void test_directiveAfterDeclaration_classBetweenDirectives() { | 821 void test_directiveAfterDeclaration_classBetweenDirectives() { |
| 864 CompilationUnit unit = ParserTestCase.parseCompilationUnit( | 822 CompilationUnit unit = ParserTestCase.parseCompilationUnit( |
| 865 "library l;\nclass Foo{}\npart 'a.dart';", [ | 823 "library l;\nclass Foo{}\npart 'a.dart';", |
| 866 ParserErrorCode.DIRECTIVE_AFTER_DECLARATION | 824 [ParserErrorCode.DIRECTIVE_AFTER_DECLARATION]); |
| 867 ]); | |
| 868 expect(unit, isNotNull); | 825 expect(unit, isNotNull); |
| 869 } | 826 } |
| 870 | 827 |
| 871 void test_duplicatedModifier_const() { | 828 void test_duplicatedModifier_const() { |
| 872 ParserTestCase.parse3("parseClassMember", <Object>["C"], "const const m;", [ | 829 parse3("parseClassMember", <Object>["C"], "const const m;", |
| 873 ParserErrorCode.DUPLICATED_MODIFIER | 830 [ParserErrorCode.DUPLICATED_MODIFIER]); |
| 874 ]); | |
| 875 } | 831 } |
| 876 | 832 |
| 877 void test_duplicatedModifier_external() { | 833 void test_duplicatedModifier_external() { |
| 878 ParserTestCase.parse3("parseClassMember", <Object>[ | 834 parse3("parseClassMember", <Object>["C"], "external external f();", |
| 879 "C" | 835 [ParserErrorCode.DUPLICATED_MODIFIER]); |
| 880 ], "external external f();", [ParserErrorCode.DUPLICATED_MODIFIER]); | |
| 881 } | 836 } |
| 882 | 837 |
| 883 void test_duplicatedModifier_factory() { | 838 void test_duplicatedModifier_factory() { |
| 884 ParserTestCase.parse3("parseClassMember", <Object>[ | 839 parse3("parseClassMember", <Object>["C"], "factory factory C() {}", |
| 885 "C" | 840 [ParserErrorCode.DUPLICATED_MODIFIER]); |
| 886 ], "factory factory C() {}", [ParserErrorCode.DUPLICATED_MODIFIER]); | |
| 887 } | 841 } |
| 888 | 842 |
| 889 void test_duplicatedModifier_final() { | 843 void test_duplicatedModifier_final() { |
| 890 ParserTestCase.parse3("parseClassMember", <Object>["C"], "final final m;", [ | 844 parse3("parseClassMember", <Object>["C"], "final final m;", |
| 891 ParserErrorCode.DUPLICATED_MODIFIER | 845 [ParserErrorCode.DUPLICATED_MODIFIER]); |
| 892 ]); | |
| 893 } | 846 } |
| 894 | 847 |
| 895 void test_duplicatedModifier_static() { | 848 void test_duplicatedModifier_static() { |
| 896 ParserTestCase.parse3("parseClassMember", <Object>[ | 849 parse3("parseClassMember", <Object>["C"], "static static var m;", |
| 897 "C" | 850 [ParserErrorCode.DUPLICATED_MODIFIER]); |
| 898 ], "static static var m;", [ParserErrorCode.DUPLICATED_MODIFIER]); | |
| 899 } | 851 } |
| 900 | 852 |
| 901 void test_duplicatedModifier_var() { | 853 void test_duplicatedModifier_var() { |
| 902 ParserTestCase.parse3("parseClassMember", <Object>["C"], "var var m;", [ | 854 parse3("parseClassMember", <Object>["C"], "var var m;", |
| 903 ParserErrorCode.DUPLICATED_MODIFIER | 855 [ParserErrorCode.DUPLICATED_MODIFIER]); |
| 904 ]); | |
| 905 } | 856 } |
| 906 | 857 |
| 907 void test_duplicateLabelInSwitchStatement() { | 858 void test_duplicateLabelInSwitchStatement() { |
| 908 ParserTestCase.parse4("parseSwitchStatement", | 859 parse4("parseSwitchStatement", |
| 909 "switch (e) {l1: case 0: break; l1: case 1: break;}", [ | 860 "switch (e) {l1: case 0: break; l1: case 1: break;}", |
| 910 ParserErrorCode.DUPLICATE_LABEL_IN_SWITCH_STATEMENT | 861 [ParserErrorCode.DUPLICATE_LABEL_IN_SWITCH_STATEMENT]); |
| 911 ]); | |
| 912 } | 862 } |
| 913 | 863 |
| 914 void test_emptyEnumBody() { | 864 void test_emptyEnumBody() { |
| 915 ParserTestCase.parse3("parseEnumDeclaration", <Object>[ | 865 parse3("parseEnumDeclaration", <Object>[emptyCommentAndMetadata()], |
| 916 emptyCommentAndMetadata() | 866 "enum E {}", [ParserErrorCode.EMPTY_ENUM_BODY]); |
| 917 ], "enum E {}", [ParserErrorCode.EMPTY_ENUM_BODY]); | |
| 918 } | 867 } |
| 919 | 868 |
| 920 void test_enumInClass() { | 869 void test_enumInClass() { |
| 921 ParserTestCase.parseCompilationUnit(r''' | 870 ParserTestCase.parseCompilationUnit(r''' |
| 922 class Foo { | 871 class Foo { |
| 923 enum Bar { | 872 enum Bar { |
| 924 Bar1, Bar2, Bar3 | 873 Bar1, Bar2, Bar3 |
| 925 } | 874 } |
| 926 } | 875 } |
| 927 ''', [ParserErrorCode.ENUM_IN_CLASS]); | 876 ''', [ParserErrorCode.ENUM_IN_CLASS]); |
| 928 } | 877 } |
| 929 | 878 |
| 930 void test_equalityCannotBeEqualityOperand_eq_eq() { | 879 void test_equalityCannotBeEqualityOperand_eq_eq() { |
| 931 ParserTestCase.parseExpression( | 880 parseExpression( |
| 932 "1 == 2 == 3", [ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND]); | 881 "1 == 2 == 3", [ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND]); |
| 933 } | 882 } |
| 934 | 883 |
| 935 void test_equalityCannotBeEqualityOperand_eq_neq() { | 884 void test_equalityCannotBeEqualityOperand_eq_neq() { |
| 936 ParserTestCase.parseExpression( | 885 parseExpression( |
| 937 "1 == 2 != 3", [ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND]); | 886 "1 == 2 != 3", [ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND]); |
| 938 } | 887 } |
| 939 | 888 |
| 940 void test_equalityCannotBeEqualityOperand_neq_eq() { | 889 void test_equalityCannotBeEqualityOperand_neq_eq() { |
| 941 ParserTestCase.parseExpression( | 890 parseExpression( |
| 942 "1 != 2 == 3", [ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND]); | 891 "1 != 2 == 3", [ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND]); |
| 943 } | 892 } |
| 944 | 893 |
| 945 void test_expectedCaseOrDefault() { | 894 void test_expectedCaseOrDefault() { |
| 946 ParserTestCase.parse4("parseSwitchStatement", "switch (e) {break;}", [ | 895 parse4("parseSwitchStatement", "switch (e) {break;}", |
| 947 ParserErrorCode.EXPECTED_CASE_OR_DEFAULT | 896 [ParserErrorCode.EXPECTED_CASE_OR_DEFAULT]); |
| 948 ]); | |
| 949 } | 897 } |
| 950 | 898 |
| 951 void test_expectedClassMember_inClass_afterType() { | 899 void test_expectedClassMember_inClass_afterType() { |
| 952 ParserTestCase.parse3("parseClassMember", <Object>["C"], "heart 2 heart", [ | 900 parse3("parseClassMember", <Object>["C"], "heart 2 heart", |
| 953 ParserErrorCode.EXPECTED_CLASS_MEMBER | 901 [ParserErrorCode.EXPECTED_CLASS_MEMBER]); |
| 954 ]); | |
| 955 } | 902 } |
| 956 | 903 |
| 957 void test_expectedClassMember_inClass_beforeType() { | 904 void test_expectedClassMember_inClass_beforeType() { |
| 958 ParserTestCase.parse3("parseClassMember", <Object>["C"], "4 score", [ | 905 parse3("parseClassMember", <Object>["C"], "4 score", |
| 959 ParserErrorCode.EXPECTED_CLASS_MEMBER | 906 [ParserErrorCode.EXPECTED_CLASS_MEMBER]); |
| 960 ]); | |
| 961 } | 907 } |
| 962 | 908 |
| 963 void test_expectedExecutable_inClass_afterVoid() { | 909 void test_expectedExecutable_inClass_afterVoid() { |
| 964 ParserTestCase.parse3("parseClassMember", <Object>["C"], "void 2 void", [ | 910 parse3("parseClassMember", <Object>["C"], "void 2 void", |
| 965 ParserErrorCode.EXPECTED_EXECUTABLE | 911 [ParserErrorCode.EXPECTED_EXECUTABLE]); |
| 966 ]); | |
| 967 } | 912 } |
| 968 | 913 |
| 969 void test_expectedExecutable_topLevel_afterType() { | 914 void test_expectedExecutable_topLevel_afterType() { |
| 970 ParserTestCase.parse3("parseCompilationUnitMember", <Object>[ | 915 parse3("parseCompilationUnitMember", <Object>[emptyCommentAndMetadata()], |
| 971 emptyCommentAndMetadata() | 916 "heart 2 heart", [ParserErrorCode.EXPECTED_EXECUTABLE]); |
| 972 ], "heart 2 heart", [ParserErrorCode.EXPECTED_EXECUTABLE]); | |
| 973 } | 917 } |
| 974 | 918 |
| 975 void test_expectedExecutable_topLevel_afterVoid() { | 919 void test_expectedExecutable_topLevel_afterVoid() { |
| 976 ParserTestCase.parse3("parseCompilationUnitMember", <Object>[ | 920 parse3("parseCompilationUnitMember", <Object>[emptyCommentAndMetadata()], |
| 977 emptyCommentAndMetadata() | 921 "void 2 void", [ParserErrorCode.EXPECTED_EXECUTABLE]); |
| 978 ], "void 2 void", [ParserErrorCode.EXPECTED_EXECUTABLE]); | |
| 979 } | 922 } |
| 980 | 923 |
| 981 void test_expectedExecutable_topLevel_beforeType() { | 924 void test_expectedExecutable_topLevel_beforeType() { |
| 982 ParserTestCase.parse3("parseCompilationUnitMember", <Object>[ | 925 parse3("parseCompilationUnitMember", <Object>[emptyCommentAndMetadata()], |
| 983 emptyCommentAndMetadata() | 926 "4 score", [ParserErrorCode.EXPECTED_EXECUTABLE]); |
| 984 ], "4 score", [ParserErrorCode.EXPECTED_EXECUTABLE]); | |
| 985 } | 927 } |
| 986 | 928 |
| 987 void test_expectedExecutable_topLevel_eof() { | 929 void test_expectedExecutable_topLevel_eof() { |
| 988 ParserTestCase.parse2("parseCompilationUnitMember", <Object>[ | 930 parse2("parseCompilationUnitMember", <Object>[emptyCommentAndMetadata()], |
| 989 emptyCommentAndMetadata() | 931 "x", [ |
| 990 ], "x", [ | |
| 991 new AnalysisError.con2(null, 0, 1, ParserErrorCode.EXPECTED_EXECUTABLE) | 932 new AnalysisError.con2(null, 0, 1, ParserErrorCode.EXPECTED_EXECUTABLE) |
| 992 ]); | 933 ]); |
| 993 } | 934 } |
| 994 | 935 |
| 995 void test_expectedInterpolationIdentifier() { | 936 void test_expectedInterpolationIdentifier() { |
| 996 ParserTestCase.parse4( | 937 parse4( |
| 997 "parseStringLiteral", "'\$x\$'", [ParserErrorCode.MISSING_IDENTIFIER]); | 938 "parseStringLiteral", "'\$x\$'", [ParserErrorCode.MISSING_IDENTIFIER]); |
| 998 } | 939 } |
| 999 | 940 |
| 1000 void test_expectedInterpolationIdentifier_emptyString() { | 941 void test_expectedInterpolationIdentifier_emptyString() { |
| 1001 // The scanner inserts an empty string token between the two $'s; we need to | 942 // The scanner inserts an empty string token between the two $'s; we need to |
| 1002 // make sure that the MISSING_IDENTIFIER error that is generated has a | 943 // make sure that the MISSING_IDENTIFIER error that is generated has a |
| 1003 // nonzero width so that it will show up in the editor UI. | 944 // nonzero width so that it will show up in the editor UI. |
| 1004 ParserTestCase.parse2("parseStringLiteral", <Object>[], "'\$\$foo'", [ | 945 parse2("parseStringLiteral", <Object>[], "'\$\$foo'", [ |
| 1005 new AnalysisError.con2(null, 2, 1, ParserErrorCode.MISSING_IDENTIFIER) | 946 new AnalysisError.con2(null, 2, 1, ParserErrorCode.MISSING_IDENTIFIER) |
| 1006 ]); | 947 ]); |
| 1007 } | 948 } |
| 1008 | 949 |
| 1009 void test_expectedStringLiteral() { | 950 void test_expectedStringLiteral() { |
| 1010 StringLiteral expression = ParserTestCase.parse4( | 951 StringLiteral expression = parse4( |
| 1011 "parseStringLiteral", "1", [ParserErrorCode.EXPECTED_STRING_LITERAL]); | 952 "parseStringLiteral", "1", [ParserErrorCode.EXPECTED_STRING_LITERAL]); |
| 1012 expect(expression.isSynthetic, isTrue); | 953 expect(expression.isSynthetic, isTrue); |
| 1013 } | 954 } |
| 1014 | 955 |
| 1015 void test_expectedToken_commaMissingInArgumentList() { | 956 void test_expectedToken_commaMissingInArgumentList() { |
| 1016 ParserTestCase.parse4( | 957 parse4("parseArgumentList", "(x, y z)", [ParserErrorCode.EXPECTED_TOKEN]); |
| 1017 "parseArgumentList", "(x, y z)", [ParserErrorCode.EXPECTED_TOKEN]); | |
| 1018 } | 958 } |
| 1019 | 959 |
| 1020 void test_expectedToken_parseStatement_afterVoid() { | 960 void test_expectedToken_parseStatement_afterVoid() { |
| 1021 ParserTestCase.parseStatement("void}", [ | 961 ParserTestCase.parseStatement("void}", [ |
| 1022 ParserErrorCode.EXPECTED_TOKEN, | 962 ParserErrorCode.EXPECTED_TOKEN, |
| 1023 ParserErrorCode.MISSING_IDENTIFIER | 963 ParserErrorCode.MISSING_IDENTIFIER |
| 1024 ]); | 964 ]); |
| 1025 } | 965 } |
| 1026 | 966 |
| 1027 void test_expectedToken_semicolonAfterClass() { | 967 void test_expectedToken_semicolonAfterClass() { |
| 1028 Token token = TokenFactory.tokenFromKeyword(Keyword.CLASS); | 968 Token token = TokenFactory.tokenFromKeyword(Keyword.CLASS); |
| 1029 ParserTestCase.parse3("parseClassTypeAlias", <Object>[ | 969 parse3("parseClassTypeAlias", <Object>[ |
| 1030 emptyCommentAndMetadata(), | 970 emptyCommentAndMetadata(), |
| 1031 null, | 971 null, |
| 1032 token | 972 token |
| 1033 ], "A = B with C", [ParserErrorCode.EXPECTED_TOKEN]); | 973 ], "A = B with C", [ParserErrorCode.EXPECTED_TOKEN]); |
| 1034 } | 974 } |
| 1035 | 975 |
| 1036 void test_expectedToken_semicolonMissingAfterExport() { | 976 void test_expectedToken_semicolonMissingAfterExport() { |
| 1037 CompilationUnit unit = ParserTestCase.parseCompilationUnit( | 977 CompilationUnit unit = ParserTestCase.parseCompilationUnit( |
| 1038 "export '' class A {}", [ParserErrorCode.EXPECTED_TOKEN]); | 978 "export '' class A {}", [ParserErrorCode.EXPECTED_TOKEN]); |
| 1039 ExportDirective directive = unit.directives[0] as ExportDirective; | 979 ExportDirective directive = unit.directives[0] as ExportDirective; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1054 expect(semicolon, isNotNull); | 994 expect(semicolon, isNotNull); |
| 1055 expect(semicolon.isSynthetic, isTrue); | 995 expect(semicolon.isSynthetic, isTrue); |
| 1056 } | 996 } |
| 1057 | 997 |
| 1058 void test_expectedToken_whileMissingInDoStatement() { | 998 void test_expectedToken_whileMissingInDoStatement() { |
| 1059 ParserTestCase.parseStatement( | 999 ParserTestCase.parseStatement( |
| 1060 "do {} (x);", [ParserErrorCode.EXPECTED_TOKEN]); | 1000 "do {} (x);", [ParserErrorCode.EXPECTED_TOKEN]); |
| 1061 } | 1001 } |
| 1062 | 1002 |
| 1063 void test_expectedTypeName_is() { | 1003 void test_expectedTypeName_is() { |
| 1064 ParserTestCase.parseExpression( | 1004 parseExpression("x is", [ParserErrorCode.EXPECTED_TYPE_NAME]); |
| 1065 "x is", [ParserErrorCode.EXPECTED_TYPE_NAME]); | |
| 1066 } | 1005 } |
| 1067 | 1006 |
| 1068 void test_exportDirectiveAfterPartDirective() { | 1007 void test_exportDirectiveAfterPartDirective() { |
| 1069 ParserTestCase.parseCompilationUnit("part 'a.dart'; export 'b.dart';", [ | 1008 ParserTestCase.parseCompilationUnit("part 'a.dart'; export 'b.dart';", |
| 1070 ParserErrorCode.EXPORT_DIRECTIVE_AFTER_PART_DIRECTIVE | 1009 [ParserErrorCode.EXPORT_DIRECTIVE_AFTER_PART_DIRECTIVE]); |
| 1071 ]); | |
| 1072 } | 1010 } |
| 1073 | 1011 |
| 1074 void test_externalAfterConst() { | 1012 void test_externalAfterConst() { |
| 1075 ParserTestCase.parse3("parseClassMember", <Object>[ | 1013 parse3("parseClassMember", <Object>["C"], "const external C();", |
| 1076 "C" | 1014 [ParserErrorCode.EXTERNAL_AFTER_CONST]); |
| 1077 ], "const external C();", [ParserErrorCode.EXTERNAL_AFTER_CONST]); | |
| 1078 } | 1015 } |
| 1079 | 1016 |
| 1080 void test_externalAfterFactory() { | 1017 void test_externalAfterFactory() { |
| 1081 ParserTestCase.parse3("parseClassMember", <Object>[ | 1018 parse3("parseClassMember", <Object>["C"], "factory external C();", |
| 1082 "C" | 1019 [ParserErrorCode.EXTERNAL_AFTER_FACTORY]); |
| 1083 ], "factory external C();", [ParserErrorCode.EXTERNAL_AFTER_FACTORY]); | |
| 1084 } | 1020 } |
| 1085 | 1021 |
| 1086 void test_externalAfterStatic() { | 1022 void test_externalAfterStatic() { |
| 1087 ParserTestCase.parse3("parseClassMember", <Object>[ | 1023 parse3("parseClassMember", <Object>["C"], "static external int m();", |
| 1088 "C" | 1024 [ParserErrorCode.EXTERNAL_AFTER_STATIC]); |
| 1089 ], "static external int m();", [ParserErrorCode.EXTERNAL_AFTER_STATIC]); | |
| 1090 } | 1025 } |
| 1091 | 1026 |
| 1092 void test_externalClass() { | 1027 void test_externalClass() { |
| 1093 ParserTestCase.parseCompilationUnit( | 1028 ParserTestCase.parseCompilationUnit( |
| 1094 "external class C {}", [ParserErrorCode.EXTERNAL_CLASS]); | 1029 "external class C {}", [ParserErrorCode.EXTERNAL_CLASS]); |
| 1095 } | 1030 } |
| 1096 | 1031 |
| 1097 void test_externalConstructorWithBody_factory() { | 1032 void test_externalConstructorWithBody_factory() { |
| 1098 ParserTestCase.parse3("parseClassMember", <Object>[ | 1033 parse3("parseClassMember", <Object>["C"], "external factory C() {}", |
| 1099 "C" | 1034 [ParserErrorCode.EXTERNAL_CONSTRUCTOR_WITH_BODY]); |
| 1100 ], "external factory C() {}", [ | |
| 1101 ParserErrorCode.EXTERNAL_CONSTRUCTOR_WITH_BODY | |
| 1102 ]); | |
| 1103 } | 1035 } |
| 1104 | 1036 |
| 1105 void test_externalConstructorWithBody_named() { | 1037 void test_externalConstructorWithBody_named() { |
| 1106 ParserTestCase.parse3("parseClassMember", <Object>[ | 1038 parse3("parseClassMember", <Object>["C"], "external C.c() {}", |
| 1107 "C" | 1039 [ParserErrorCode.EXTERNAL_CONSTRUCTOR_WITH_BODY]); |
| 1108 ], "external C.c() {}", [ParserErrorCode.EXTERNAL_CONSTRUCTOR_WITH_BODY]); | |
| 1109 } | 1040 } |
| 1110 | 1041 |
| 1111 void test_externalEnum() { | 1042 void test_externalEnum() { |
| 1112 ParserTestCase.parseCompilationUnit( | 1043 ParserTestCase.parseCompilationUnit( |
| 1113 "external enum E {ONE}", [ParserErrorCode.EXTERNAL_ENUM]); | 1044 "external enum E {ONE}", [ParserErrorCode.EXTERNAL_ENUM]); |
| 1114 } | 1045 } |
| 1115 | 1046 |
| 1116 void test_externalField_const() { | 1047 void test_externalField_const() { |
| 1117 ParserTestCase.parse3("parseClassMember", <Object>[ | 1048 parse3("parseClassMember", <Object>["C"], "external const A f;", |
| 1118 "C" | 1049 [ParserErrorCode.EXTERNAL_FIELD]); |
| 1119 ], "external const A f;", [ParserErrorCode.EXTERNAL_FIELD]); | |
| 1120 } | 1050 } |
| 1121 | 1051 |
| 1122 void test_externalField_final() { | 1052 void test_externalField_final() { |
| 1123 ParserTestCase.parse3("parseClassMember", <Object>[ | 1053 parse3("parseClassMember", <Object>["C"], "external final A f;", |
| 1124 "C" | 1054 [ParserErrorCode.EXTERNAL_FIELD]); |
| 1125 ], "external final A f;", [ParserErrorCode.EXTERNAL_FIELD]); | |
| 1126 } | 1055 } |
| 1127 | 1056 |
| 1128 void test_externalField_static() { | 1057 void test_externalField_static() { |
| 1129 ParserTestCase.parse3("parseClassMember", <Object>[ | 1058 parse3("parseClassMember", <Object>["C"], "external static A f;", |
| 1130 "C" | 1059 [ParserErrorCode.EXTERNAL_FIELD]); |
| 1131 ], "external static A f;", [ParserErrorCode.EXTERNAL_FIELD]); | |
| 1132 } | 1060 } |
| 1133 | 1061 |
| 1134 void test_externalField_typed() { | 1062 void test_externalField_typed() { |
| 1135 ParserTestCase.parse3("parseClassMember", <Object>["C"], "external A f;", [ | 1063 parse3("parseClassMember", <Object>["C"], "external A f;", |
| 1136 ParserErrorCode.EXTERNAL_FIELD | 1064 [ParserErrorCode.EXTERNAL_FIELD]); |
| 1137 ]); | |
| 1138 } | 1065 } |
| 1139 | 1066 |
| 1140 void test_externalField_untyped() { | 1067 void test_externalField_untyped() { |
| 1141 ParserTestCase.parse3("parseClassMember", <Object>[ | 1068 parse3("parseClassMember", <Object>["C"], "external var f;", |
| 1142 "C" | 1069 [ParserErrorCode.EXTERNAL_FIELD]); |
| 1143 ], "external var f;", [ParserErrorCode.EXTERNAL_FIELD]); | |
| 1144 } | 1070 } |
| 1145 | 1071 |
| 1146 void test_externalGetterWithBody() { | 1072 void test_externalGetterWithBody() { |
| 1147 ParserTestCase.parse3("parseClassMember", <Object>[ | 1073 parse3("parseClassMember", <Object>["C"], "external int get x {}", |
| 1148 "C" | 1074 [ParserErrorCode.EXTERNAL_GETTER_WITH_BODY]); |
| 1149 ], "external int get x {}", [ParserErrorCode.EXTERNAL_GETTER_WITH_BODY]); | |
| 1150 } | 1075 } |
| 1151 | 1076 |
| 1152 void test_externalMethodWithBody() { | 1077 void test_externalMethodWithBody() { |
| 1153 ParserTestCase.parse3("parseClassMember", <Object>[ | 1078 parse3("parseClassMember", <Object>["C"], "external m() {}", |
| 1154 "C" | 1079 [ParserErrorCode.EXTERNAL_METHOD_WITH_BODY]); |
| 1155 ], "external m() {}", [ParserErrorCode.EXTERNAL_METHOD_WITH_BODY]); | |
| 1156 } | 1080 } |
| 1157 | 1081 |
| 1158 void test_externalOperatorWithBody() { | 1082 void test_externalOperatorWithBody() { |
| 1159 ParserTestCase.parse3("parseClassMember", <Object>[ | 1083 parse3("parseClassMember", <Object>["C"], |
| 1160 "C" | 1084 "external operator +(int value) {}", |
| 1161 ], "external operator +(int value) {}", [ | 1085 [ParserErrorCode.EXTERNAL_OPERATOR_WITH_BODY]); |
| 1162 ParserErrorCode.EXTERNAL_OPERATOR_WITH_BODY | |
| 1163 ]); | |
| 1164 } | 1086 } |
| 1165 | 1087 |
| 1166 void test_externalSetterWithBody() { | 1088 void test_externalSetterWithBody() { |
| 1167 ParserTestCase.parse3("parseClassMember", <Object>[ | 1089 parse3("parseClassMember", <Object>["C"], "external set x(int value) {}", |
| 1168 "C" | 1090 [ParserErrorCode.EXTERNAL_SETTER_WITH_BODY]); |
| 1169 ], "external set x(int value) {}", [ | |
| 1170 ParserErrorCode.EXTERNAL_SETTER_WITH_BODY | |
| 1171 ]); | |
| 1172 } | 1091 } |
| 1173 | 1092 |
| 1174 void test_externalTypedef() { | 1093 void test_externalTypedef() { |
| 1175 ParserTestCase.parseCompilationUnit( | 1094 ParserTestCase.parseCompilationUnit( |
| 1176 "external typedef F();", [ParserErrorCode.EXTERNAL_TYPEDEF]); | 1095 "external typedef F();", [ParserErrorCode.EXTERNAL_TYPEDEF]); |
| 1177 } | 1096 } |
| 1178 | 1097 |
| 1179 void test_factoryTopLevelDeclaration_class() { | 1098 void test_factoryTopLevelDeclaration_class() { |
| 1180 ParserTestCase.parseCompilationUnit( | 1099 ParserTestCase.parseCompilationUnit( |
| 1181 "factory class C {}", [ParserErrorCode.FACTORY_TOP_LEVEL_DECLARATION]); | 1100 "factory class C {}", [ParserErrorCode.FACTORY_TOP_LEVEL_DECLARATION]); |
| 1182 } | 1101 } |
| 1183 | 1102 |
| 1184 void test_factoryTopLevelDeclaration_typedef() { | 1103 void test_factoryTopLevelDeclaration_typedef() { |
| 1185 ParserTestCase.parseCompilationUnit("factory typedef F();", [ | 1104 ParserTestCase.parseCompilationUnit("factory typedef F();", |
| 1186 ParserErrorCode.FACTORY_TOP_LEVEL_DECLARATION | 1105 [ParserErrorCode.FACTORY_TOP_LEVEL_DECLARATION]); |
| 1187 ]); | |
| 1188 } | 1106 } |
| 1189 | 1107 |
| 1190 void test_factoryWithInitializers() { | 1108 void test_factoryWithInitializers() { |
| 1191 ParserTestCase.parse3("parseClassMember", <Object>[ | 1109 parse3("parseClassMember", <Object>["C"], "factory C() : x = 3 {}", |
| 1192 "C" | 1110 [ParserErrorCode.FACTORY_WITH_INITIALIZERS]); |
| 1193 ], "factory C() : x = 3 {}", [ParserErrorCode.FACTORY_WITH_INITIALIZERS]); | |
| 1194 } | 1111 } |
| 1195 | 1112 |
| 1196 void test_factoryWithoutBody() { | 1113 void test_factoryWithoutBody() { |
| 1197 ParserTestCase.parse3("parseClassMember", <Object>["C"], "factory C();", [ | 1114 parse3("parseClassMember", <Object>["C"], "factory C();", |
| 1198 ParserErrorCode.FACTORY_WITHOUT_BODY | 1115 [ParserErrorCode.FACTORY_WITHOUT_BODY]); |
| 1199 ]); | |
| 1200 } | 1116 } |
| 1201 | 1117 |
| 1202 void test_fieldInitializerOutsideConstructor() { | 1118 void test_fieldInitializerOutsideConstructor() { |
| 1203 ParserTestCase.parse3("parseClassMember", <Object>["C"], "void m(this.x);", | 1119 parse3("parseClassMember", <Object>["C"], "void m(this.x);", |
| 1204 [ParserErrorCode.FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR]); | 1120 [ParserErrorCode.FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR]); |
| 1205 } | 1121 } |
| 1206 | 1122 |
| 1207 void test_finalAndVar() { | 1123 void test_finalAndVar() { |
| 1208 ParserTestCase.parse3("parseClassMember", <Object>["C"], "final var x;", [ | 1124 parse3("parseClassMember", <Object>["C"], "final var x;", |
| 1209 ParserErrorCode.FINAL_AND_VAR | 1125 [ParserErrorCode.FINAL_AND_VAR]); |
| 1210 ]); | |
| 1211 } | 1126 } |
| 1212 | 1127 |
| 1213 void test_finalClass() { | 1128 void test_finalClass() { |
| 1214 ParserTestCase.parseCompilationUnit( | 1129 ParserTestCase.parseCompilationUnit( |
| 1215 "final class C {}", [ParserErrorCode.FINAL_CLASS]); | 1130 "final class C {}", [ParserErrorCode.FINAL_CLASS]); |
| 1216 } | 1131 } |
| 1217 | 1132 |
| 1218 void test_finalConstructor() { | 1133 void test_finalConstructor() { |
| 1219 ParserTestCase.parse3("parseClassMember", <Object>["C"], "final C() {}", [ | 1134 parse3("parseClassMember", <Object>["C"], "final C() {}", |
| 1220 ParserErrorCode.FINAL_CONSTRUCTOR | 1135 [ParserErrorCode.FINAL_CONSTRUCTOR]); |
| 1221 ]); | |
| 1222 } | 1136 } |
| 1223 | 1137 |
| 1224 void test_finalEnum() { | 1138 void test_finalEnum() { |
| 1225 ParserTestCase.parseCompilationUnit( | 1139 ParserTestCase.parseCompilationUnit( |
| 1226 "final enum E {ONE}", [ParserErrorCode.FINAL_ENUM]); | 1140 "final enum E {ONE}", [ParserErrorCode.FINAL_ENUM]); |
| 1227 } | 1141 } |
| 1228 | 1142 |
| 1229 void test_finalMethod() { | 1143 void test_finalMethod() { |
| 1230 ParserTestCase.parse3("parseClassMember", <Object>[ | 1144 parse3("parseClassMember", <Object>["C"], "final int m() {}", |
| 1231 "C" | 1145 [ParserErrorCode.FINAL_METHOD]); |
| 1232 ], "final int m() {}", [ParserErrorCode.FINAL_METHOD]); | |
| 1233 } | 1146 } |
| 1234 | 1147 |
| 1235 void test_finalTypedef() { | 1148 void test_finalTypedef() { |
| 1236 ParserTestCase.parseCompilationUnit( | 1149 ParserTestCase.parseCompilationUnit( |
| 1237 "final typedef F();", [ParserErrorCode.FINAL_TYPEDEF]); | 1150 "final typedef F();", [ParserErrorCode.FINAL_TYPEDEF]); |
| 1238 } | 1151 } |
| 1239 | 1152 |
| 1240 void test_functionTypedParameter_const() { | 1153 void test_functionTypedParameter_const() { |
| 1241 ParserTestCase.parseCompilationUnit( | 1154 ParserTestCase.parseCompilationUnit( |
| 1242 "void f(const x()) {}", [ParserErrorCode.FUNCTION_TYPED_PARAMETER_VAR]); | 1155 "void f(const x()) {}", [ParserErrorCode.FUNCTION_TYPED_PARAMETER_VAR]); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1266 ParserTestCase.parseStatement( | 1179 ParserTestCase.parseStatement( |
| 1267 "get x => _x;", [ParserErrorCode.GETTER_IN_FUNCTION]); | 1180 "get x => _x;", [ParserErrorCode.GETTER_IN_FUNCTION]); |
| 1268 } | 1181 } |
| 1269 | 1182 |
| 1270 void test_getterInFunction_expression_returnType() { | 1183 void test_getterInFunction_expression_returnType() { |
| 1271 ParserTestCase.parseStatement( | 1184 ParserTestCase.parseStatement( |
| 1272 "int get x => _x;", [ParserErrorCode.GETTER_IN_FUNCTION]); | 1185 "int get x => _x;", [ParserErrorCode.GETTER_IN_FUNCTION]); |
| 1273 } | 1186 } |
| 1274 | 1187 |
| 1275 void test_getterWithParameters() { | 1188 void test_getterWithParameters() { |
| 1276 ParserTestCase.parse3("parseClassMember", <Object>["C"], "int get x() {}", [ | 1189 parse3("parseClassMember", <Object>["C"], "int get x() {}", |
| 1277 ParserErrorCode.GETTER_WITH_PARAMETERS | 1190 [ParserErrorCode.GETTER_WITH_PARAMETERS]); |
| 1278 ]); | |
| 1279 } | 1191 } |
| 1280 | 1192 |
| 1281 void test_illegalAssignmentToNonAssignable_postfix_minusMinus_literal() { | 1193 void test_illegalAssignmentToNonAssignable_postfix_minusMinus_literal() { |
| 1282 ParserTestCase.parseExpression( | 1194 parseExpression( |
| 1283 "0--", [ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE]); | 1195 "0--", [ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE]); |
| 1284 } | 1196 } |
| 1285 | 1197 |
| 1286 void test_illegalAssignmentToNonAssignable_postfix_plusPlus_literal() { | 1198 void test_illegalAssignmentToNonAssignable_postfix_plusPlus_literal() { |
| 1287 ParserTestCase.parseExpression( | 1199 parseExpression( |
| 1288 "0++", [ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE]); | 1200 "0++", [ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE]); |
| 1289 } | 1201 } |
| 1290 | 1202 |
| 1291 void test_illegalAssignmentToNonAssignable_postfix_plusPlus_parethesized() { | 1203 void test_illegalAssignmentToNonAssignable_postfix_plusPlus_parethesized() { |
| 1292 ParserTestCase.parseExpression( | 1204 parseExpression( |
| 1293 "(x)++", [ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE]); | 1205 "(x)++", [ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE]); |
| 1294 } | 1206 } |
| 1295 | 1207 |
| 1296 void test_illegalAssignmentToNonAssignable_primarySelectorPostfix() { | 1208 void test_illegalAssignmentToNonAssignable_primarySelectorPostfix() { |
| 1297 ParserTestCase.parseExpression( | 1209 parseExpression( |
| 1298 "x(y)(z)++", [ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE]); | 1210 "x(y)(z)++", [ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE]); |
| 1299 } | 1211 } |
| 1300 | 1212 |
| 1301 void test_illegalAssignmentToNonAssignable_superAssigned() { | 1213 void test_illegalAssignmentToNonAssignable_superAssigned() { |
| 1302 // TODO(brianwilkerson) When the test | 1214 // TODO(brianwilkerson) When the test |
| 1303 // fail_illegalAssignmentToNonAssignable_superAssigned starts to pass, | 1215 // fail_illegalAssignmentToNonAssignable_superAssigned starts to pass, |
| 1304 // remove this test (there should only be one error generated, but we're | 1216 // remove this test (there should only be one error generated, but we're |
| 1305 // keeping this test until that time so that we can catch other forms of | 1217 // keeping this test until that time so that we can catch other forms of |
| 1306 // regressions). | 1218 // regressions). |
| 1307 ParserTestCase.parseExpression("super = x;", [ | 1219 parseExpression("super = x;", [ |
| 1308 ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR, | 1220 ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR, |
| 1309 ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE | 1221 ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE |
| 1310 ]); | 1222 ]); |
| 1311 } | 1223 } |
| 1312 | 1224 |
| 1313 void test_implementsBeforeExtends() { | 1225 void test_implementsBeforeExtends() { |
| 1314 ParserTestCase.parseCompilationUnit("class A implements B extends C {}", [ | 1226 ParserTestCase.parseCompilationUnit("class A implements B extends C {}", |
| 1315 ParserErrorCode.IMPLEMENTS_BEFORE_EXTENDS | 1227 [ParserErrorCode.IMPLEMENTS_BEFORE_EXTENDS]); |
| 1316 ]); | |
| 1317 } | 1228 } |
| 1318 | 1229 |
| 1319 void test_implementsBeforeWith() { | 1230 void test_implementsBeforeWith() { |
| 1320 ParserTestCase.parseCompilationUnit( | 1231 ParserTestCase.parseCompilationUnit( |
| 1321 "class A extends B implements C with D {}", [ | 1232 "class A extends B implements C with D {}", |
| 1322 ParserErrorCode.IMPLEMENTS_BEFORE_WITH | 1233 [ParserErrorCode.IMPLEMENTS_BEFORE_WITH]); |
| 1323 ]); | |
| 1324 } | 1234 } |
| 1325 | 1235 |
| 1326 void test_importDirectiveAfterPartDirective() { | 1236 void test_importDirectiveAfterPartDirective() { |
| 1327 ParserTestCase.parseCompilationUnit("part 'a.dart'; import 'b.dart';", [ | 1237 ParserTestCase.parseCompilationUnit("part 'a.dart'; import 'b.dart';", |
| 1328 ParserErrorCode.IMPORT_DIRECTIVE_AFTER_PART_DIRECTIVE | 1238 [ParserErrorCode.IMPORT_DIRECTIVE_AFTER_PART_DIRECTIVE]); |
| 1329 ]); | |
| 1330 } | 1239 } |
| 1331 | 1240 |
| 1332 void test_initializedVariableInForEach() { | 1241 void test_initializedVariableInForEach() { |
| 1333 ParserTestCase.parse4("parseForStatement", "for (int a = 0 in foo) {}", [ | 1242 parse4("parseForStatement", "for (int a = 0 in foo) {}", |
| 1334 ParserErrorCode.INITIALIZED_VARIABLE_IN_FOR_EACH | 1243 [ParserErrorCode.INITIALIZED_VARIABLE_IN_FOR_EACH]); |
| 1335 ]); | |
| 1336 } | 1244 } |
| 1337 | 1245 |
| 1338 void test_invalidAwaitInFor() { | 1246 void test_invalidAwaitInFor() { |
| 1339 ParserTestCase.parse4("parseForStatement", "await for (; ;) {}", [ | 1247 parse4("parseForStatement", "await for (; ;) {}", |
| 1340 ParserErrorCode.INVALID_AWAIT_IN_FOR | 1248 [ParserErrorCode.INVALID_AWAIT_IN_FOR]); |
| 1341 ]); | |
| 1342 } | 1249 } |
| 1343 | 1250 |
| 1344 void test_invalidCodePoint() { | 1251 void test_invalidCodePoint() { |
| 1345 ParserTestCase.parse4("parseStringLiteral", "'\\uD900'", [ | 1252 parse4("parseStringLiteral", "'\\uD900'", |
| 1346 ParserErrorCode.INVALID_CODE_POINT | 1253 [ParserErrorCode.INVALID_CODE_POINT]); |
| 1347 ]); | |
| 1348 } | 1254 } |
| 1349 | 1255 |
| 1350 void test_invalidHexEscape_invalidDigit() { | 1256 void test_invalidHexEscape_invalidDigit() { |
| 1351 ParserTestCase.parse4( | 1257 parse4( |
| 1352 "parseStringLiteral", "'\\x0 a'", [ParserErrorCode.INVALID_HEX_ESCAPE]); | 1258 "parseStringLiteral", "'\\x0 a'", [ParserErrorCode.INVALID_HEX_ESCAPE]); |
| 1353 } | 1259 } |
| 1354 | 1260 |
| 1355 void test_invalidHexEscape_tooFewDigits() { | 1261 void test_invalidHexEscape_tooFewDigits() { |
| 1356 ParserTestCase.parse4( | 1262 parse4( |
| 1357 "parseStringLiteral", "'\\x0'", [ParserErrorCode.INVALID_HEX_ESCAPE]); | 1263 "parseStringLiteral", "'\\x0'", [ParserErrorCode.INVALID_HEX_ESCAPE]); |
| 1358 } | 1264 } |
| 1359 | 1265 |
| 1360 void test_invalidInterpolationIdentifier_startWithDigit() { | 1266 void test_invalidInterpolationIdentifier_startWithDigit() { |
| 1361 ParserTestCase.parse4( | 1267 parse4("parseStringLiteral", "'\$1'", [ParserErrorCode.MISSING_IDENTIFIER]); |
| 1362 "parseStringLiteral", "'\$1'", [ParserErrorCode.MISSING_IDENTIFIER]); | |
| 1363 } | 1268 } |
| 1364 | 1269 |
| 1365 void test_invalidOperator() { | 1270 void test_invalidOperator() { |
| 1366 ParserTestCase.parse3("parseClassMember", <Object>[ | 1271 parse3("parseClassMember", <Object>["C"], "void operator ===(x) {}", |
| 1367 "C" | 1272 [ParserErrorCode.INVALID_OPERATOR]); |
| 1368 ], "void operator ===(x) {}", [ParserErrorCode.INVALID_OPERATOR]); | |
| 1369 } | 1273 } |
| 1370 | 1274 |
| 1371 void test_invalidOperatorForSuper() { | 1275 void test_invalidOperatorForSuper() { |
| 1372 ParserTestCase.parse4("parseUnaryExpression", "++super", [ | 1276 parse4("parseUnaryExpression", "++super", |
| 1373 ParserErrorCode.INVALID_OPERATOR_FOR_SUPER | 1277 [ParserErrorCode.INVALID_OPERATOR_FOR_SUPER]); |
| 1374 ]); | |
| 1375 } | 1278 } |
| 1376 | 1279 |
| 1377 void test_invalidStarAfterAsync() { | 1280 void test_invalidStarAfterAsync() { |
| 1378 ParserTestCase.parse3("parseFunctionBody", <Object>[ | 1281 parse3("parseFunctionBody", <Object>[ |
| 1379 false, | 1282 false, |
| 1380 null, | 1283 null, |
| 1381 false | 1284 false |
| 1382 ], "async* => 0;", [ParserErrorCode.INVALID_STAR_AFTER_ASYNC]); | 1285 ], "async* => 0;", [ParserErrorCode.INVALID_STAR_AFTER_ASYNC]); |
| 1383 } | 1286 } |
| 1384 | 1287 |
| 1385 void test_invalidSync() { | 1288 void test_invalidSync() { |
| 1386 ParserTestCase.parse3("parseFunctionBody", <Object>[ | 1289 parse3("parseFunctionBody", <Object>[ |
| 1387 false, | 1290 false, |
| 1388 null, | 1291 null, |
| 1389 false | 1292 false |
| 1390 ], "sync* => 0;", [ParserErrorCode.INVALID_SYNC]); | 1293 ], "sync* => 0;", [ParserErrorCode.INVALID_SYNC]); |
| 1391 } | 1294 } |
| 1392 | 1295 |
| 1393 void test_invalidUnicodeEscape_incomplete_noDigits() { | 1296 void test_invalidUnicodeEscape_incomplete_noDigits() { |
| 1394 ParserTestCase.parse4("parseStringLiteral", "'\\u{'", [ | 1297 parse4("parseStringLiteral", "'\\u{'", |
| 1395 ParserErrorCode.INVALID_UNICODE_ESCAPE | 1298 [ParserErrorCode.INVALID_UNICODE_ESCAPE]); |
| 1396 ]); | |
| 1397 } | 1299 } |
| 1398 | 1300 |
| 1399 void test_invalidUnicodeEscape_incomplete_someDigits() { | 1301 void test_invalidUnicodeEscape_incomplete_someDigits() { |
| 1400 ParserTestCase.parse4("parseStringLiteral", "'\\u{0A'", [ | 1302 parse4("parseStringLiteral", "'\\u{0A'", |
| 1401 ParserErrorCode.INVALID_UNICODE_ESCAPE | 1303 [ParserErrorCode.INVALID_UNICODE_ESCAPE]); |
| 1402 ]); | |
| 1403 } | 1304 } |
| 1404 | 1305 |
| 1405 void test_invalidUnicodeEscape_invalidDigit() { | 1306 void test_invalidUnicodeEscape_invalidDigit() { |
| 1406 ParserTestCase.parse4("parseStringLiteral", "'\\u0 a'", [ | 1307 parse4("parseStringLiteral", "'\\u0 a'", |
| 1407 ParserErrorCode.INVALID_UNICODE_ESCAPE | 1308 [ParserErrorCode.INVALID_UNICODE_ESCAPE]); |
| 1408 ]); | |
| 1409 } | 1309 } |
| 1410 | 1310 |
| 1411 void test_invalidUnicodeEscape_tooFewDigits_fixed() { | 1311 void test_invalidUnicodeEscape_tooFewDigits_fixed() { |
| 1412 ParserTestCase.parse4("parseStringLiteral", "'\\u04'", [ | 1312 parse4("parseStringLiteral", "'\\u04'", |
| 1413 ParserErrorCode.INVALID_UNICODE_ESCAPE | 1313 [ParserErrorCode.INVALID_UNICODE_ESCAPE]); |
| 1414 ]); | |
| 1415 } | 1314 } |
| 1416 | 1315 |
| 1417 void test_invalidUnicodeEscape_tooFewDigits_variable() { | 1316 void test_invalidUnicodeEscape_tooFewDigits_variable() { |
| 1418 ParserTestCase.parse4("parseStringLiteral", "'\\u{}'", [ | 1317 parse4("parseStringLiteral", "'\\u{}'", |
| 1419 ParserErrorCode.INVALID_UNICODE_ESCAPE | 1318 [ParserErrorCode.INVALID_UNICODE_ESCAPE]); |
| 1420 ]); | |
| 1421 } | 1319 } |
| 1422 | 1320 |
| 1423 void test_invalidUnicodeEscape_tooManyDigits_variable() { | 1321 void test_invalidUnicodeEscape_tooManyDigits_variable() { |
| 1424 ParserTestCase.parse4("parseStringLiteral", "'\\u{12345678}'", [ | 1322 parse4("parseStringLiteral", "'\\u{12345678}'", [ |
| 1425 ParserErrorCode.INVALID_UNICODE_ESCAPE, | 1323 ParserErrorCode.INVALID_UNICODE_ESCAPE, |
| 1426 ParserErrorCode.INVALID_CODE_POINT | 1324 ParserErrorCode.INVALID_CODE_POINT |
| 1427 ]); | 1325 ]); |
| 1428 } | 1326 } |
| 1429 | 1327 |
| 1430 void test_libraryDirectiveNotFirst() { | 1328 void test_libraryDirectiveNotFirst() { |
| 1431 ParserTestCase.parseCompilationUnit("import 'x.dart'; library l;", [ | 1329 ParserTestCase.parseCompilationUnit("import 'x.dart'; library l;", |
| 1432 ParserErrorCode.LIBRARY_DIRECTIVE_NOT_FIRST | 1330 [ParserErrorCode.LIBRARY_DIRECTIVE_NOT_FIRST]); |
| 1433 ]); | |
| 1434 } | 1331 } |
| 1435 | 1332 |
| 1436 void test_libraryDirectiveNotFirst_afterPart() { | 1333 void test_libraryDirectiveNotFirst_afterPart() { |
| 1437 CompilationUnit unit = ParserTestCase.parseCompilationUnit( | 1334 CompilationUnit unit = ParserTestCase.parseCompilationUnit( |
| 1438 "part 'a.dart';\nlibrary l;", [ | 1335 "part 'a.dart';\nlibrary l;", |
| 1439 ParserErrorCode.LIBRARY_DIRECTIVE_NOT_FIRST | 1336 [ParserErrorCode.LIBRARY_DIRECTIVE_NOT_FIRST]); |
| 1440 ]); | |
| 1441 expect(unit, isNotNull); | 1337 expect(unit, isNotNull); |
| 1442 } | 1338 } |
| 1443 | 1339 |
| 1444 void test_localFunctionDeclarationModifier_abstract() { | 1340 void test_localFunctionDeclarationModifier_abstract() { |
| 1445 ParserTestCase.parseStatement("abstract f() {}", [ | 1341 ParserTestCase.parseStatement("abstract f() {}", |
| 1446 ParserErrorCode.LOCAL_FUNCTION_DECLARATION_MODIFIER | 1342 [ParserErrorCode.LOCAL_FUNCTION_DECLARATION_MODIFIER]); |
| 1447 ]); | |
| 1448 } | 1343 } |
| 1449 | 1344 |
| 1450 void test_localFunctionDeclarationModifier_external() { | 1345 void test_localFunctionDeclarationModifier_external() { |
| 1451 ParserTestCase.parseStatement("external f() {}", [ | 1346 ParserTestCase.parseStatement("external f() {}", |
| 1452 ParserErrorCode.LOCAL_FUNCTION_DECLARATION_MODIFIER | 1347 [ParserErrorCode.LOCAL_FUNCTION_DECLARATION_MODIFIER]); |
| 1453 ]); | |
| 1454 } | 1348 } |
| 1455 | 1349 |
| 1456 void test_localFunctionDeclarationModifier_factory() { | 1350 void test_localFunctionDeclarationModifier_factory() { |
| 1457 ParserTestCase.parseStatement("factory f() {}", [ | 1351 ParserTestCase.parseStatement("factory f() {}", |
| 1458 ParserErrorCode.LOCAL_FUNCTION_DECLARATION_MODIFIER | 1352 [ParserErrorCode.LOCAL_FUNCTION_DECLARATION_MODIFIER]); |
| 1459 ]); | |
| 1460 } | 1353 } |
| 1461 | 1354 |
| 1462 void test_localFunctionDeclarationModifier_static() { | 1355 void test_localFunctionDeclarationModifier_static() { |
| 1463 ParserTestCase.parseStatement( | 1356 ParserTestCase.parseStatement( |
| 1464 "static f() {}", [ParserErrorCode.LOCAL_FUNCTION_DECLARATION_MODIFIER]); | 1357 "static f() {}", [ParserErrorCode.LOCAL_FUNCTION_DECLARATION_MODIFIER]); |
| 1465 } | 1358 } |
| 1466 | 1359 |
| 1467 void test_missingAssignableSelector_identifiersAssigned() { | 1360 void test_missingAssignableSelector_identifiersAssigned() { |
| 1468 ParserTestCase.parseExpression("x.y = y;"); | 1361 parseExpression("x.y = y;"); |
| 1469 } | 1362 } |
| 1470 | 1363 |
| 1471 void test_missingAssignableSelector_prefix_minusMinus_literal() { | 1364 void test_missingAssignableSelector_prefix_minusMinus_literal() { |
| 1472 ParserTestCase.parseExpression( | 1365 parseExpression("--0", [ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR]); |
| 1473 "--0", [ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR]); | |
| 1474 } | 1366 } |
| 1475 | 1367 |
| 1476 void test_missingAssignableSelector_prefix_plusPlus_literal() { | 1368 void test_missingAssignableSelector_prefix_plusPlus_literal() { |
| 1477 ParserTestCase.parseExpression( | 1369 parseExpression("++0", [ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR]); |
| 1478 "++0", [ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR]); | |
| 1479 } | 1370 } |
| 1480 | 1371 |
| 1481 void test_missingAssignableSelector_selector() { | 1372 void test_missingAssignableSelector_selector() { |
| 1482 ParserTestCase.parseExpression("x(y)(z).a++"); | 1373 parseExpression("x(y)(z).a++"); |
| 1483 } | 1374 } |
| 1484 | 1375 |
| 1485 void test_missingAssignableSelector_superPrimaryExpression() { | 1376 void test_missingAssignableSelector_superPrimaryExpression() { |
| 1486 SuperExpression expression = ParserTestCase.parse4("parsePrimaryExpression", | 1377 SuperExpression expression = parse4("parsePrimaryExpression", "super", |
| 1487 "super", [ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR]); | 1378 [ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR]); |
| 1488 expect(expression.superKeyword, isNotNull); | 1379 expect(expression.superKeyword, isNotNull); |
| 1489 } | 1380 } |
| 1490 | 1381 |
| 1491 void test_missingAssignableSelector_superPropertyAccessAssigned() { | 1382 void test_missingAssignableSelector_superPropertyAccessAssigned() { |
| 1492 ParserTestCase.parseExpression("super.x = x;"); | 1383 parseExpression("super.x = x;"); |
| 1493 } | 1384 } |
| 1494 | 1385 |
| 1495 void test_missingCatchOrFinally() { | 1386 void test_missingCatchOrFinally() { |
| 1496 TryStatement statement = ParserTestCase.parse4("parseTryStatement", | 1387 TryStatement statement = parse4("parseTryStatement", "try {}", |
| 1497 "try {}", [ParserErrorCode.MISSING_CATCH_OR_FINALLY]); | 1388 [ParserErrorCode.MISSING_CATCH_OR_FINALLY]); |
| 1498 expect(statement, isNotNull); | 1389 expect(statement, isNotNull); |
| 1499 } | 1390 } |
| 1500 | 1391 |
| 1501 void test_missingClassBody() { | 1392 void test_missingClassBody() { |
| 1502 ParserTestCase.parseCompilationUnit( | 1393 ParserTestCase.parseCompilationUnit( |
| 1503 "class A class B {}", [ParserErrorCode.MISSING_CLASS_BODY]); | 1394 "class A class B {}", [ParserErrorCode.MISSING_CLASS_BODY]); |
| 1504 } | 1395 } |
| 1505 | 1396 |
| 1506 void test_missingConstFinalVarOrType_static() { | 1397 void test_missingConstFinalVarOrType_static() { |
| 1507 ParserTestCase.parseCompilationUnit("class A { static f; }", [ | 1398 ParserTestCase.parseCompilationUnit("class A { static f; }", |
| 1508 ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE | 1399 [ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE]); |
| 1509 ]); | |
| 1510 } | 1400 } |
| 1511 | 1401 |
| 1512 void test_missingConstFinalVarOrType_topLevel() { | 1402 void test_missingConstFinalVarOrType_topLevel() { |
| 1513 ParserTestCase.parse3("parseFinalConstVarOrType", <Object>[false], "a;", [ | 1403 parse3("parseFinalConstVarOrType", <Object>[false], "a;", |
| 1514 ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE | 1404 [ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE]); |
| 1515 ]); | |
| 1516 } | 1405 } |
| 1517 | 1406 |
| 1518 void test_missingEnumBody() { | 1407 void test_missingEnumBody() { |
| 1519 ParserTestCase.parse3("parseEnumDeclaration", <Object>[ | 1408 parse3("parseEnumDeclaration", <Object>[emptyCommentAndMetadata()], |
| 1520 emptyCommentAndMetadata() | 1409 "enum E;", [ParserErrorCode.MISSING_ENUM_BODY]); |
| 1521 ], "enum E;", [ParserErrorCode.MISSING_ENUM_BODY]); | |
| 1522 } | 1410 } |
| 1523 | 1411 |
| 1524 void test_missingExpressionInThrow_withCascade() { | 1412 void test_missingExpressionInThrow_withCascade() { |
| 1525 ParserTestCase.parse4("parseThrowExpression", "throw;", [ | 1413 parse4("parseThrowExpression", "throw;", |
| 1526 ParserErrorCode.MISSING_EXPRESSION_IN_THROW | 1414 [ParserErrorCode.MISSING_EXPRESSION_IN_THROW]); |
| 1527 ]); | |
| 1528 } | 1415 } |
| 1529 | 1416 |
| 1530 void test_missingExpressionInThrow_withoutCascade() { | 1417 void test_missingExpressionInThrow_withoutCascade() { |
| 1531 ParserTestCase.parse4("parseThrowExpressionWithoutCascade", "throw;", [ | 1418 parse4("parseThrowExpressionWithoutCascade", "throw;", |
| 1532 ParserErrorCode.MISSING_EXPRESSION_IN_THROW | 1419 [ParserErrorCode.MISSING_EXPRESSION_IN_THROW]); |
| 1533 ]); | |
| 1534 } | 1420 } |
| 1535 | 1421 |
| 1536 void test_missingFunctionBody_emptyNotAllowed() { | 1422 void test_missingFunctionBody_emptyNotAllowed() { |
| 1537 ParserTestCase.parse3("parseFunctionBody", <Object>[ | 1423 parse3("parseFunctionBody", <Object>[ |
| 1538 false, | 1424 false, |
| 1539 ParserErrorCode.MISSING_FUNCTION_BODY, | 1425 ParserErrorCode.MISSING_FUNCTION_BODY, |
| 1540 false | 1426 false |
| 1541 ], ";", [ParserErrorCode.MISSING_FUNCTION_BODY]); | 1427 ], ";", [ParserErrorCode.MISSING_FUNCTION_BODY]); |
| 1542 } | 1428 } |
| 1543 | 1429 |
| 1544 void test_missingFunctionBody_invalid() { | 1430 void test_missingFunctionBody_invalid() { |
| 1545 ParserTestCase.parse3("parseFunctionBody", <Object>[ | 1431 parse3("parseFunctionBody", <Object>[ |
| 1546 false, | 1432 false, |
| 1547 ParserErrorCode.MISSING_FUNCTION_BODY, | 1433 ParserErrorCode.MISSING_FUNCTION_BODY, |
| 1548 false | 1434 false |
| 1549 ], "return 0;", [ParserErrorCode.MISSING_FUNCTION_BODY]); | 1435 ], "return 0;", [ParserErrorCode.MISSING_FUNCTION_BODY]); |
| 1550 } | 1436 } |
| 1551 | 1437 |
| 1552 void test_missingFunctionParameters_local_void_block() { | 1438 void test_missingFunctionParameters_local_void_block() { |
| 1553 ParserTestCase.parseStatement( | 1439 ParserTestCase.parseStatement( |
| 1554 "void f { return x;}", [ParserErrorCode.MISSING_FUNCTION_PARAMETERS]); | 1440 "void f { return x;}", [ParserErrorCode.MISSING_FUNCTION_PARAMETERS]); |
| 1555 } | 1441 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1573 ParserTestCase.parseCompilationUnit( | 1459 ParserTestCase.parseCompilationUnit( |
| 1574 "void f { return x;}", [ParserErrorCode.MISSING_FUNCTION_PARAMETERS]); | 1460 "void f { return x;}", [ParserErrorCode.MISSING_FUNCTION_PARAMETERS]); |
| 1575 } | 1461 } |
| 1576 | 1462 |
| 1577 void test_missingFunctionParameters_topLevel_void_expression() { | 1463 void test_missingFunctionParameters_topLevel_void_expression() { |
| 1578 ParserTestCase.parseCompilationUnit( | 1464 ParserTestCase.parseCompilationUnit( |
| 1579 "void f => x;", [ParserErrorCode.MISSING_FUNCTION_PARAMETERS]); | 1465 "void f => x;", [ParserErrorCode.MISSING_FUNCTION_PARAMETERS]); |
| 1580 } | 1466 } |
| 1581 | 1467 |
| 1582 void test_missingIdentifier_afterOperator() { | 1468 void test_missingIdentifier_afterOperator() { |
| 1583 ParserTestCase.parse4("parseMultiplicativeExpression", "1 *", [ | 1469 parse4("parseMultiplicativeExpression", "1 *", |
| 1584 ParserErrorCode.MISSING_IDENTIFIER | 1470 [ParserErrorCode.MISSING_IDENTIFIER]); |
| 1585 ]); | |
| 1586 } | 1471 } |
| 1587 | 1472 |
| 1588 void test_missingIdentifier_beforeClosingCurly() { | 1473 void test_missingIdentifier_beforeClosingCurly() { |
| 1589 ParserTestCase.parse3("parseClassMember", <Object>["C"], "int}", [ | 1474 parse3("parseClassMember", <Object>["C"], "int}", [ |
| 1590 ParserErrorCode.MISSING_IDENTIFIER, | 1475 ParserErrorCode.MISSING_IDENTIFIER, |
| 1591 ParserErrorCode.EXPECTED_TOKEN | 1476 ParserErrorCode.EXPECTED_TOKEN |
| 1592 ]); | 1477 ]); |
| 1593 } | 1478 } |
| 1594 | 1479 |
| 1595 void test_missingIdentifier_functionDeclaration_returnTypeWithoutName() { | 1480 void test_missingIdentifier_functionDeclaration_returnTypeWithoutName() { |
| 1596 ParserTestCase.parse4("parseFunctionDeclarationStatement", "A<T> () {}", [ | 1481 parse4("parseFunctionDeclarationStatement", "A<T> () {}", |
| 1597 ParserErrorCode.MISSING_IDENTIFIER | 1482 [ParserErrorCode.MISSING_IDENTIFIER]); |
| 1598 ]); | |
| 1599 } | 1483 } |
| 1600 | 1484 |
| 1601 void test_missingIdentifier_inEnum() { | 1485 void test_missingIdentifier_inEnum() { |
| 1602 ParserTestCase.parse3("parseEnumDeclaration", <Object>[ | 1486 parse3("parseEnumDeclaration", <Object>[emptyCommentAndMetadata()], |
| 1603 emptyCommentAndMetadata() | 1487 "enum E {, TWO}", [ParserErrorCode.MISSING_IDENTIFIER]); |
| 1604 ], "enum E {, TWO}", [ParserErrorCode.MISSING_IDENTIFIER]); | |
| 1605 } | 1488 } |
| 1606 | 1489 |
| 1607 void test_missingIdentifier_inSymbol_afterPeriod() { | 1490 void test_missingIdentifier_inSymbol_afterPeriod() { |
| 1608 ParserTestCase.parse4( | 1491 parse4("parseSymbolLiteral", "#a.", [ParserErrorCode.MISSING_IDENTIFIER]); |
| 1609 "parseSymbolLiteral", "#a.", [ParserErrorCode.MISSING_IDENTIFIER]); | |
| 1610 } | 1492 } |
| 1611 | 1493 |
| 1612 void test_missingIdentifier_inSymbol_first() { | 1494 void test_missingIdentifier_inSymbol_first() { |
| 1613 ParserTestCase.parse4( | 1495 parse4("parseSymbolLiteral", "#", [ParserErrorCode.MISSING_IDENTIFIER]); |
| 1614 "parseSymbolLiteral", "#", [ParserErrorCode.MISSING_IDENTIFIER]); | |
| 1615 } | 1496 } |
| 1616 | 1497 |
| 1617 void test_missingIdentifier_number() { | 1498 void test_missingIdentifier_number() { |
| 1618 SimpleIdentifier expression = ParserTestCase.parse4( | 1499 SimpleIdentifier expression = parse4( |
| 1619 "parseSimpleIdentifier", "1", [ParserErrorCode.MISSING_IDENTIFIER]); | 1500 "parseSimpleIdentifier", "1", [ParserErrorCode.MISSING_IDENTIFIER]); |
| 1620 expect(expression.isSynthetic, isTrue); | 1501 expect(expression.isSynthetic, isTrue); |
| 1621 } | 1502 } |
| 1622 | 1503 |
| 1623 void test_missingKeywordOperator() { | 1504 void test_missingKeywordOperator() { |
| 1624 ParserTestCase.parse3("parseOperator", <Object>[ | 1505 parse3("parseOperator", <Object>[ |
| 1625 emptyCommentAndMetadata(), | 1506 emptyCommentAndMetadata(), |
| 1626 null, | 1507 null, |
| 1627 null | 1508 null |
| 1628 ], "+(x) {}", [ParserErrorCode.MISSING_KEYWORD_OPERATOR]); | 1509 ], "+(x) {}", [ParserErrorCode.MISSING_KEYWORD_OPERATOR]); |
| 1629 } | 1510 } |
| 1630 | 1511 |
| 1631 void test_missingKeywordOperator_parseClassMember() { | 1512 void test_missingKeywordOperator_parseClassMember() { |
| 1632 ParserTestCase.parse3("parseClassMember", <Object>["C"], "+() {}", [ | 1513 parse3("parseClassMember", <Object>["C"], "+() {}", |
| 1633 ParserErrorCode.MISSING_KEYWORD_OPERATOR | 1514 [ParserErrorCode.MISSING_KEYWORD_OPERATOR]); |
| 1634 ]); | |
| 1635 } | 1515 } |
| 1636 | 1516 |
| 1637 void test_missingKeywordOperator_parseClassMember_afterTypeName() { | 1517 void test_missingKeywordOperator_parseClassMember_afterTypeName() { |
| 1638 ParserTestCase.parse3("parseClassMember", <Object>["C"], "int +() {}", [ | 1518 parse3("parseClassMember", <Object>["C"], "int +() {}", |
| 1639 ParserErrorCode.MISSING_KEYWORD_OPERATOR | 1519 [ParserErrorCode.MISSING_KEYWORD_OPERATOR]); |
| 1640 ]); | |
| 1641 } | 1520 } |
| 1642 | 1521 |
| 1643 void test_missingKeywordOperator_parseClassMember_afterVoid() { | 1522 void test_missingKeywordOperator_parseClassMember_afterVoid() { |
| 1644 ParserTestCase.parse3("parseClassMember", <Object>["C"], "void +() {}", [ | 1523 parse3("parseClassMember", <Object>["C"], "void +() {}", |
| 1645 ParserErrorCode.MISSING_KEYWORD_OPERATOR | 1524 [ParserErrorCode.MISSING_KEYWORD_OPERATOR]); |
| 1646 ]); | |
| 1647 } | 1525 } |
| 1648 | 1526 |
| 1649 void test_missingMethodParameters_void_block() { | 1527 void test_missingMethodParameters_void_block() { |
| 1650 ParserTestCase.parse3("parseClassMember", <Object>["C"], "void m {} }", [ | 1528 parse3("parseClassMember", <Object>["C"], "void m {} }", |
| 1651 ParserErrorCode.MISSING_METHOD_PARAMETERS | 1529 [ParserErrorCode.MISSING_METHOD_PARAMETERS]); |
| 1652 ]); | |
| 1653 } | 1530 } |
| 1654 | 1531 |
| 1655 void test_missingMethodParameters_void_expression() { | 1532 void test_missingMethodParameters_void_expression() { |
| 1656 ParserTestCase.parse3("parseClassMember", <Object>[ | 1533 parse3("parseClassMember", <Object>["C"], "void m => null; }", |
| 1657 "C" | 1534 [ParserErrorCode.MISSING_METHOD_PARAMETERS]); |
| 1658 ], "void m => null; }", [ParserErrorCode.MISSING_METHOD_PARAMETERS]); | |
| 1659 } | 1535 } |
| 1660 | 1536 |
| 1661 void test_missingNameInLibraryDirective() { | 1537 void test_missingNameInLibraryDirective() { |
| 1662 CompilationUnit unit = ParserTestCase.parseCompilationUnit( | 1538 CompilationUnit unit = ParserTestCase.parseCompilationUnit( |
| 1663 "library;", [ParserErrorCode.MISSING_NAME_IN_LIBRARY_DIRECTIVE]); | 1539 "library;", [ParserErrorCode.MISSING_NAME_IN_LIBRARY_DIRECTIVE]); |
| 1664 expect(unit, isNotNull); | 1540 expect(unit, isNotNull); |
| 1665 } | 1541 } |
| 1666 | 1542 |
| 1667 void test_missingNameInPartOfDirective() { | 1543 void test_missingNameInPartOfDirective() { |
| 1668 CompilationUnit unit = ParserTestCase.parseCompilationUnit( | 1544 CompilationUnit unit = ParserTestCase.parseCompilationUnit( |
| 1669 "part of;", [ParserErrorCode.MISSING_NAME_IN_PART_OF_DIRECTIVE]); | 1545 "part of;", [ParserErrorCode.MISSING_NAME_IN_PART_OF_DIRECTIVE]); |
| 1670 expect(unit, isNotNull); | 1546 expect(unit, isNotNull); |
| 1671 } | 1547 } |
| 1672 | 1548 |
| 1673 void test_missingPrefixInDeferredImport() { | 1549 void test_missingPrefixInDeferredImport() { |
| 1674 ParserTestCase.parseCompilationUnit("import 'foo.dart' deferred;", [ | 1550 ParserTestCase.parseCompilationUnit("import 'foo.dart' deferred;", |
| 1675 ParserErrorCode.MISSING_PREFIX_IN_DEFERRED_IMPORT | 1551 [ParserErrorCode.MISSING_PREFIX_IN_DEFERRED_IMPORT]); |
| 1676 ]); | |
| 1677 } | 1552 } |
| 1678 | 1553 |
| 1679 void test_missingStartAfterSync() { | 1554 void test_missingStartAfterSync() { |
| 1680 ParserTestCase.parse3("parseFunctionBody", <Object>[ | 1555 parse3("parseFunctionBody", <Object>[ |
| 1681 false, | 1556 false, |
| 1682 null, | 1557 null, |
| 1683 false | 1558 false |
| 1684 ], "sync {}", [ParserErrorCode.MISSING_STAR_AFTER_SYNC]); | 1559 ], "sync {}", [ParserErrorCode.MISSING_STAR_AFTER_SYNC]); |
| 1685 } | 1560 } |
| 1686 | 1561 |
| 1687 void test_missingStatement() { | 1562 void test_missingStatement() { |
| 1688 ParserTestCase.parseStatement("is", [ParserErrorCode.MISSING_STATEMENT]); | 1563 ParserTestCase.parseStatement("is", [ParserErrorCode.MISSING_STATEMENT]); |
| 1689 } | 1564 } |
| 1690 | 1565 |
| 1691 void test_missingStatement_afterVoid() { | 1566 void test_missingStatement_afterVoid() { |
| 1692 ParserTestCase.parseStatement("void;", [ParserErrorCode.MISSING_STATEMENT]); | 1567 ParserTestCase.parseStatement("void;", [ParserErrorCode.MISSING_STATEMENT]); |
| 1693 } | 1568 } |
| 1694 | 1569 |
| 1695 void test_missingTerminatorForParameterGroup_named() { | 1570 void test_missingTerminatorForParameterGroup_named() { |
| 1696 ParserTestCase.parse4("parseFormalParameterList", "(a, {b: 0)", [ | 1571 parse4("parseFormalParameterList", "(a, {b: 0)", |
| 1697 ParserErrorCode.MISSING_TERMINATOR_FOR_PARAMETER_GROUP | 1572 [ParserErrorCode.MISSING_TERMINATOR_FOR_PARAMETER_GROUP]); |
| 1698 ]); | |
| 1699 } | 1573 } |
| 1700 | 1574 |
| 1701 void test_missingTerminatorForParameterGroup_optional() { | 1575 void test_missingTerminatorForParameterGroup_optional() { |
| 1702 ParserTestCase.parse4("parseFormalParameterList", "(a, [b = 0)", [ | 1576 parse4("parseFormalParameterList", "(a, [b = 0)", |
| 1703 ParserErrorCode.MISSING_TERMINATOR_FOR_PARAMETER_GROUP | 1577 [ParserErrorCode.MISSING_TERMINATOR_FOR_PARAMETER_GROUP]); |
| 1704 ]); | |
| 1705 } | 1578 } |
| 1706 | 1579 |
| 1707 void test_missingTypedefParameters_nonVoid() { | 1580 void test_missingTypedefParameters_nonVoid() { |
| 1708 ParserTestCase.parseCompilationUnit( | 1581 ParserTestCase.parseCompilationUnit( |
| 1709 "typedef int F;", [ParserErrorCode.MISSING_TYPEDEF_PARAMETERS]); | 1582 "typedef int F;", [ParserErrorCode.MISSING_TYPEDEF_PARAMETERS]); |
| 1710 } | 1583 } |
| 1711 | 1584 |
| 1712 void test_missingTypedefParameters_typeParameters() { | 1585 void test_missingTypedefParameters_typeParameters() { |
| 1713 ParserTestCase.parseCompilationUnit( | 1586 ParserTestCase.parseCompilationUnit( |
| 1714 "typedef F<E>;", [ParserErrorCode.MISSING_TYPEDEF_PARAMETERS]); | 1587 "typedef F<E>;", [ParserErrorCode.MISSING_TYPEDEF_PARAMETERS]); |
| 1715 } | 1588 } |
| 1716 | 1589 |
| 1717 void test_missingTypedefParameters_void() { | 1590 void test_missingTypedefParameters_void() { |
| 1718 ParserTestCase.parseCompilationUnit( | 1591 ParserTestCase.parseCompilationUnit( |
| 1719 "typedef void F;", [ParserErrorCode.MISSING_TYPEDEF_PARAMETERS]); | 1592 "typedef void F;", [ParserErrorCode.MISSING_TYPEDEF_PARAMETERS]); |
| 1720 } | 1593 } |
| 1721 | 1594 |
| 1722 void test_missingVariableInForEach() { | 1595 void test_missingVariableInForEach() { |
| 1723 ParserTestCase.parse4("parseForStatement", "for (a < b in foo) {}", [ | 1596 parse4("parseForStatement", "for (a < b in foo) {}", |
| 1724 ParserErrorCode.MISSING_VARIABLE_IN_FOR_EACH | 1597 [ParserErrorCode.MISSING_VARIABLE_IN_FOR_EACH]); |
| 1725 ]); | |
| 1726 } | 1598 } |
| 1727 | 1599 |
| 1728 void test_mixedParameterGroups_namedPositional() { | 1600 void test_mixedParameterGroups_namedPositional() { |
| 1729 ParserTestCase.parse4("parseFormalParameterList", "(a, {b}, [c])", [ | 1601 parse4("parseFormalParameterList", "(a, {b}, [c])", |
| 1730 ParserErrorCode.MIXED_PARAMETER_GROUPS | 1602 [ParserErrorCode.MIXED_PARAMETER_GROUPS]); |
| 1731 ]); | |
| 1732 } | 1603 } |
| 1733 | 1604 |
| 1734 void test_mixedParameterGroups_positionalNamed() { | 1605 void test_mixedParameterGroups_positionalNamed() { |
| 1735 ParserTestCase.parse4("parseFormalParameterList", "(a, [b], {c})", [ | 1606 parse4("parseFormalParameterList", "(a, [b], {c})", |
| 1736 ParserErrorCode.MIXED_PARAMETER_GROUPS | 1607 [ParserErrorCode.MIXED_PARAMETER_GROUPS]); |
| 1737 ]); | |
| 1738 } | 1608 } |
| 1739 | 1609 |
| 1740 void test_mixin_application_lacks_with_clause() { | 1610 void test_mixin_application_lacks_with_clause() { |
| 1741 ParserTestCase.parseCompilationUnit( | 1611 ParserTestCase.parseCompilationUnit( |
| 1742 "class Foo = Bar;", [ParserErrorCode.EXPECTED_TOKEN]); | 1612 "class Foo = Bar;", [ParserErrorCode.EXPECTED_TOKEN]); |
| 1743 } | 1613 } |
| 1744 | 1614 |
| 1745 void test_multipleExtendsClauses() { | 1615 void test_multipleExtendsClauses() { |
| 1746 ParserTestCase.parseCompilationUnit("class A extends B extends C {}", [ | 1616 ParserTestCase.parseCompilationUnit("class A extends B extends C {}", |
| 1747 ParserErrorCode.MULTIPLE_EXTENDS_CLAUSES | 1617 [ParserErrorCode.MULTIPLE_EXTENDS_CLAUSES]); |
| 1748 ]); | |
| 1749 } | 1618 } |
| 1750 | 1619 |
| 1751 void test_multipleImplementsClauses() { | 1620 void test_multipleImplementsClauses() { |
| 1752 ParserTestCase.parseCompilationUnit("class A implements B implements C {}", | 1621 ParserTestCase.parseCompilationUnit("class A implements B implements C {}", |
| 1753 [ParserErrorCode.MULTIPLE_IMPLEMENTS_CLAUSES]); | 1622 [ParserErrorCode.MULTIPLE_IMPLEMENTS_CLAUSES]); |
| 1754 } | 1623 } |
| 1755 | 1624 |
| 1756 void test_multipleLibraryDirectives() { | 1625 void test_multipleLibraryDirectives() { |
| 1757 ParserTestCase.parseCompilationUnit( | 1626 ParserTestCase.parseCompilationUnit( |
| 1758 "library l; library m;", [ParserErrorCode.MULTIPLE_LIBRARY_DIRECTIVES]); | 1627 "library l; library m;", [ParserErrorCode.MULTIPLE_LIBRARY_DIRECTIVES]); |
| 1759 } | 1628 } |
| 1760 | 1629 |
| 1761 void test_multipleNamedParameterGroups() { | 1630 void test_multipleNamedParameterGroups() { |
| 1762 ParserTestCase.parse4("parseFormalParameterList", "(a, {b}, {c})", [ | 1631 parse4("parseFormalParameterList", "(a, {b}, {c})", |
| 1763 ParserErrorCode.MULTIPLE_NAMED_PARAMETER_GROUPS | 1632 [ParserErrorCode.MULTIPLE_NAMED_PARAMETER_GROUPS]); |
| 1764 ]); | |
| 1765 } | 1633 } |
| 1766 | 1634 |
| 1767 void test_multiplePartOfDirectives() { | 1635 void test_multiplePartOfDirectives() { |
| 1768 ParserTestCase.parseCompilationUnit( | 1636 ParserTestCase.parseCompilationUnit( |
| 1769 "part of l; part of m;", [ParserErrorCode.MULTIPLE_PART_OF_DIRECTIVES]); | 1637 "part of l; part of m;", [ParserErrorCode.MULTIPLE_PART_OF_DIRECTIVES]); |
| 1770 } | 1638 } |
| 1771 | 1639 |
| 1772 void test_multiplePositionalParameterGroups() { | 1640 void test_multiplePositionalParameterGroups() { |
| 1773 ParserTestCase.parse4("parseFormalParameterList", "(a, [b], [c])", [ | 1641 parse4("parseFormalParameterList", "(a, [b], [c])", |
| 1774 ParserErrorCode.MULTIPLE_POSITIONAL_PARAMETER_GROUPS | 1642 [ParserErrorCode.MULTIPLE_POSITIONAL_PARAMETER_GROUPS]); |
| 1775 ]); | |
| 1776 } | 1643 } |
| 1777 | 1644 |
| 1778 void test_multipleVariablesInForEach() { | 1645 void test_multipleVariablesInForEach() { |
| 1779 ParserTestCase.parse4("parseForStatement", "for (int a, b in foo) {}", [ | 1646 parse4("parseForStatement", "for (int a, b in foo) {}", |
| 1780 ParserErrorCode.MULTIPLE_VARIABLES_IN_FOR_EACH | 1647 [ParserErrorCode.MULTIPLE_VARIABLES_IN_FOR_EACH]); |
| 1781 ]); | |
| 1782 } | 1648 } |
| 1783 | 1649 |
| 1784 void test_multipleWithClauses() { | 1650 void test_multipleWithClauses() { |
| 1785 ParserTestCase.parseCompilationUnit("class A extends B with C with D {}", [ | 1651 ParserTestCase.parseCompilationUnit("class A extends B with C with D {}", |
| 1786 ParserErrorCode.MULTIPLE_WITH_CLAUSES | 1652 [ParserErrorCode.MULTIPLE_WITH_CLAUSES]); |
| 1787 ]); | |
| 1788 } | 1653 } |
| 1789 | 1654 |
| 1790 void test_namedParameterOutsideGroup() { | 1655 void test_namedParameterOutsideGroup() { |
| 1791 ParserTestCase.parse4("parseFormalParameterList", "(a, b : 0)", [ | 1656 parse4("parseFormalParameterList", "(a, b : 0)", |
| 1792 ParserErrorCode.NAMED_PARAMETER_OUTSIDE_GROUP | 1657 [ParserErrorCode.NAMED_PARAMETER_OUTSIDE_GROUP]); |
| 1793 ]); | |
| 1794 } | 1658 } |
| 1795 | 1659 |
| 1796 void test_nonConstructorFactory_field() { | 1660 void test_nonConstructorFactory_field() { |
| 1797 ParserTestCase.parse3("parseClassMember", <Object>["C"], "factory int x;", [ | 1661 parse3("parseClassMember", <Object>["C"], "factory int x;", |
| 1798 ParserErrorCode.NON_CONSTRUCTOR_FACTORY | 1662 [ParserErrorCode.NON_CONSTRUCTOR_FACTORY]); |
| 1799 ]); | |
| 1800 } | 1663 } |
| 1801 | 1664 |
| 1802 void test_nonConstructorFactory_method() { | 1665 void test_nonConstructorFactory_method() { |
| 1803 ParserTestCase.parse3("parseClassMember", <Object>[ | 1666 parse3("parseClassMember", <Object>["C"], "factory int m() {}", |
| 1804 "C" | 1667 [ParserErrorCode.NON_CONSTRUCTOR_FACTORY]); |
| 1805 ], "factory int m() {}", [ParserErrorCode.NON_CONSTRUCTOR_FACTORY]); | |
| 1806 } | 1668 } |
| 1807 | 1669 |
| 1808 void test_nonIdentifierLibraryName_library() { | 1670 void test_nonIdentifierLibraryName_library() { |
| 1809 CompilationUnit unit = ParserTestCase.parseCompilationUnit( | 1671 CompilationUnit unit = ParserTestCase.parseCompilationUnit( |
| 1810 "library 'lib';", [ParserErrorCode.NON_IDENTIFIER_LIBRARY_NAME]); | 1672 "library 'lib';", [ParserErrorCode.NON_IDENTIFIER_LIBRARY_NAME]); |
| 1811 expect(unit, isNotNull); | 1673 expect(unit, isNotNull); |
| 1812 } | 1674 } |
| 1813 | 1675 |
| 1814 void test_nonIdentifierLibraryName_partOf() { | 1676 void test_nonIdentifierLibraryName_partOf() { |
| 1815 CompilationUnit unit = ParserTestCase.parseCompilationUnit( | 1677 CompilationUnit unit = ParserTestCase.parseCompilationUnit( |
| 1816 "part of 'lib';", [ParserErrorCode.NON_IDENTIFIER_LIBRARY_NAME]); | 1678 "part of 'lib';", [ParserErrorCode.NON_IDENTIFIER_LIBRARY_NAME]); |
| 1817 expect(unit, isNotNull); | 1679 expect(unit, isNotNull); |
| 1818 } | 1680 } |
| 1819 | 1681 |
| 1820 void test_nonPartOfDirectiveInPart_after() { | 1682 void test_nonPartOfDirectiveInPart_after() { |
| 1821 ParserTestCase.parseCompilationUnit("part of l; part 'f.dart';", [ | 1683 ParserTestCase.parseCompilationUnit("part of l; part 'f.dart';", |
| 1822 ParserErrorCode.NON_PART_OF_DIRECTIVE_IN_PART | 1684 [ParserErrorCode.NON_PART_OF_DIRECTIVE_IN_PART]); |
| 1823 ]); | |
| 1824 } | 1685 } |
| 1825 | 1686 |
| 1826 void test_nonPartOfDirectiveInPart_before() { | 1687 void test_nonPartOfDirectiveInPart_before() { |
| 1827 ParserTestCase.parseCompilationUnit("part 'f.dart'; part of m;", [ | 1688 ParserTestCase.parseCompilationUnit("part 'f.dart'; part of m;", |
| 1828 ParserErrorCode.NON_PART_OF_DIRECTIVE_IN_PART | 1689 [ParserErrorCode.NON_PART_OF_DIRECTIVE_IN_PART]); |
| 1829 ]); | |
| 1830 } | 1690 } |
| 1831 | 1691 |
| 1832 void test_nonUserDefinableOperator() { | 1692 void test_nonUserDefinableOperator() { |
| 1833 ParserTestCase.parse3("parseClassMember", <Object>[ | 1693 parse3("parseClassMember", <Object>["C"], "operator +=(int x) => x + 1;", |
| 1834 "C" | 1694 [ParserErrorCode.NON_USER_DEFINABLE_OPERATOR]); |
| 1835 ], "operator +=(int x) => x + 1;", [ | |
| 1836 ParserErrorCode.NON_USER_DEFINABLE_OPERATOR | |
| 1837 ]); | |
| 1838 } | 1695 } |
| 1839 | 1696 |
| 1840 void test_optionalAfterNormalParameters_named() { | 1697 void test_optionalAfterNormalParameters_named() { |
| 1841 ParserTestCase.parseCompilationUnit( | 1698 ParserTestCase.parseCompilationUnit( |
| 1842 "f({a}, b) {}", [ParserErrorCode.NORMAL_BEFORE_OPTIONAL_PARAMETERS]); | 1699 "f({a}, b) {}", [ParserErrorCode.NORMAL_BEFORE_OPTIONAL_PARAMETERS]); |
| 1843 } | 1700 } |
| 1844 | 1701 |
| 1845 void test_optionalAfterNormalParameters_positional() { | 1702 void test_optionalAfterNormalParameters_positional() { |
| 1846 ParserTestCase.parseCompilationUnit( | 1703 ParserTestCase.parseCompilationUnit( |
| 1847 "f([a], b) {}", [ParserErrorCode.NORMAL_BEFORE_OPTIONAL_PARAMETERS]); | 1704 "f([a], b) {}", [ParserErrorCode.NORMAL_BEFORE_OPTIONAL_PARAMETERS]); |
| 1848 } | 1705 } |
| 1849 | 1706 |
| 1850 void test_parseCascadeSection_missingIdentifier() { | 1707 void test_parseCascadeSection_missingIdentifier() { |
| 1851 MethodInvocation methodInvocation = ParserTestCase.parse4( | 1708 MethodInvocation methodInvocation = parse4( |
| 1852 "parseCascadeSection", "..()", [ParserErrorCode.MISSING_IDENTIFIER]); | 1709 "parseCascadeSection", "..()", [ParserErrorCode.MISSING_IDENTIFIER]); |
| 1853 expect(methodInvocation.target, isNull); | 1710 expect(methodInvocation.target, isNull); |
| 1854 expect(methodInvocation.methodName.name, ""); | 1711 expect(methodInvocation.methodName.name, ""); |
| 1855 expect(methodInvocation.argumentList.arguments, hasLength(0)); | 1712 expect(methodInvocation.argumentList.arguments, hasLength(0)); |
| 1856 } | 1713 } |
| 1857 | 1714 |
| 1858 void test_positionalAfterNamedArgument() { | 1715 void test_positionalAfterNamedArgument() { |
| 1859 ParserTestCase.parse4("parseArgumentList", "(x: 1, 2)", [ | 1716 parse4("parseArgumentList", "(x: 1, 2)", |
| 1860 ParserErrorCode.POSITIONAL_AFTER_NAMED_ARGUMENT | 1717 [ParserErrorCode.POSITIONAL_AFTER_NAMED_ARGUMENT]); |
| 1861 ]); | |
| 1862 } | 1718 } |
| 1863 | 1719 |
| 1864 void test_positionalParameterOutsideGroup() { | 1720 void test_positionalParameterOutsideGroup() { |
| 1865 ParserTestCase.parse4("parseFormalParameterList", "(a, b = 0)", [ | 1721 parse4("parseFormalParameterList", "(a, b = 0)", |
| 1866 ParserErrorCode.POSITIONAL_PARAMETER_OUTSIDE_GROUP | 1722 [ParserErrorCode.POSITIONAL_PARAMETER_OUTSIDE_GROUP]); |
| 1867 ]); | |
| 1868 } | 1723 } |
| 1869 | 1724 |
| 1870 void test_redirectionInNonFactoryConstructor() { | 1725 void test_redirectionInNonFactoryConstructor() { |
| 1871 ParserTestCase.parse3("parseClassMember", <Object>["C"], "C() = D;", [ | 1726 parse3("parseClassMember", <Object>["C"], "C() = D;", |
| 1872 ParserErrorCode.REDIRECTION_IN_NON_FACTORY_CONSTRUCTOR | 1727 [ParserErrorCode.REDIRECTION_IN_NON_FACTORY_CONSTRUCTOR]); |
| 1873 ]); | |
| 1874 } | 1728 } |
| 1875 | 1729 |
| 1876 void test_setterInFunction_block() { | 1730 void test_setterInFunction_block() { |
| 1877 ParserTestCase.parseStatement( | 1731 ParserTestCase.parseStatement( |
| 1878 "set x(v) {_x = v;}", [ParserErrorCode.SETTER_IN_FUNCTION]); | 1732 "set x(v) {_x = v;}", [ParserErrorCode.SETTER_IN_FUNCTION]); |
| 1879 } | 1733 } |
| 1880 | 1734 |
| 1881 void test_setterInFunction_expression() { | 1735 void test_setterInFunction_expression() { |
| 1882 ParserTestCase.parseStatement( | 1736 ParserTestCase.parseStatement( |
| 1883 "set x(v) => _x = v;", [ParserErrorCode.SETTER_IN_FUNCTION]); | 1737 "set x(v) => _x = v;", [ParserErrorCode.SETTER_IN_FUNCTION]); |
| 1884 } | 1738 } |
| 1885 | 1739 |
| 1886 void test_staticAfterConst() { | 1740 void test_staticAfterConst() { |
| 1887 ParserTestCase.parse3("parseClassMember", <Object>[ | 1741 parse3("parseClassMember", <Object>["C"], "final static int f;", |
| 1888 "C" | 1742 [ParserErrorCode.STATIC_AFTER_FINAL]); |
| 1889 ], "final static int f;", [ParserErrorCode.STATIC_AFTER_FINAL]); | |
| 1890 } | 1743 } |
| 1891 | 1744 |
| 1892 void test_staticAfterFinal() { | 1745 void test_staticAfterFinal() { |
| 1893 ParserTestCase.parse3("parseClassMember", <Object>[ | 1746 parse3("parseClassMember", <Object>["C"], "const static int f;", |
| 1894 "C" | 1747 [ParserErrorCode.STATIC_AFTER_CONST]); |
| 1895 ], "const static int f;", [ParserErrorCode.STATIC_AFTER_CONST]); | |
| 1896 } | 1748 } |
| 1897 | 1749 |
| 1898 void test_staticAfterVar() { | 1750 void test_staticAfterVar() { |
| 1899 ParserTestCase.parse3("parseClassMember", <Object>["C"], "var static f;", [ | 1751 parse3("parseClassMember", <Object>["C"], "var static f;", |
| 1900 ParserErrorCode.STATIC_AFTER_VAR | 1752 [ParserErrorCode.STATIC_AFTER_VAR]); |
| 1901 ]); | |
| 1902 } | 1753 } |
| 1903 | 1754 |
| 1904 void test_staticConstructor() { | 1755 void test_staticConstructor() { |
| 1905 ParserTestCase.parse3("parseClassMember", <Object>[ | 1756 parse3("parseClassMember", <Object>["C"], "static C.m() {}", |
| 1906 "C" | 1757 [ParserErrorCode.STATIC_CONSTRUCTOR]); |
| 1907 ], "static C.m() {}", [ParserErrorCode.STATIC_CONSTRUCTOR]); | |
| 1908 } | 1758 } |
| 1909 | 1759 |
| 1910 void test_staticGetterWithoutBody() { | 1760 void test_staticGetterWithoutBody() { |
| 1911 ParserTestCase.parse3("parseClassMember", <Object>["C"], "static get m;", [ | 1761 parse3("parseClassMember", <Object>["C"], "static get m;", |
| 1912 ParserErrorCode.STATIC_GETTER_WITHOUT_BODY | 1762 [ParserErrorCode.STATIC_GETTER_WITHOUT_BODY]); |
| 1913 ]); | |
| 1914 } | 1763 } |
| 1915 | 1764 |
| 1916 void test_staticOperator_noReturnType() { | 1765 void test_staticOperator_noReturnType() { |
| 1917 ParserTestCase.parse3("parseClassMember", <Object>[ | 1766 parse3("parseClassMember", <Object>["C"], |
| 1918 "C" | 1767 "static operator +(int x) => x + 1;", |
| 1919 ], "static operator +(int x) => x + 1;", [ParserErrorCode.STATIC_OPERATOR]); | 1768 [ParserErrorCode.STATIC_OPERATOR]); |
| 1920 } | 1769 } |
| 1921 | 1770 |
| 1922 void test_staticOperator_returnType() { | 1771 void test_staticOperator_returnType() { |
| 1923 ParserTestCase.parse3("parseClassMember", <Object>[ | 1772 parse3("parseClassMember", <Object>["C"], |
| 1924 "C" | 1773 "static int operator +(int x) => x + 1;", |
| 1925 ], "static int operator +(int x) => x + 1;", [ | 1774 [ParserErrorCode.STATIC_OPERATOR]); |
| 1926 ParserErrorCode.STATIC_OPERATOR | |
| 1927 ]); | |
| 1928 } | 1775 } |
| 1929 | 1776 |
| 1930 void test_staticSetterWithoutBody() { | 1777 void test_staticSetterWithoutBody() { |
| 1931 ParserTestCase.parse3("parseClassMember", <Object>[ | 1778 parse3("parseClassMember", <Object>["C"], "static set m(x);", |
| 1932 "C" | 1779 [ParserErrorCode.STATIC_SETTER_WITHOUT_BODY]); |
| 1933 ], "static set m(x);", [ParserErrorCode.STATIC_SETTER_WITHOUT_BODY]); | |
| 1934 } | 1780 } |
| 1935 | 1781 |
| 1936 void test_staticTopLevelDeclaration_class() { | 1782 void test_staticTopLevelDeclaration_class() { |
| 1937 ParserTestCase.parseCompilationUnit( | 1783 ParserTestCase.parseCompilationUnit( |
| 1938 "static class C {}", [ParserErrorCode.STATIC_TOP_LEVEL_DECLARATION]); | 1784 "static class C {}", [ParserErrorCode.STATIC_TOP_LEVEL_DECLARATION]); |
| 1939 } | 1785 } |
| 1940 | 1786 |
| 1941 void test_staticTopLevelDeclaration_function() { | 1787 void test_staticTopLevelDeclaration_function() { |
| 1942 ParserTestCase.parseCompilationUnit( | 1788 ParserTestCase.parseCompilationUnit( |
| 1943 "static f() {}", [ParserErrorCode.STATIC_TOP_LEVEL_DECLARATION]); | 1789 "static f() {}", [ParserErrorCode.STATIC_TOP_LEVEL_DECLARATION]); |
| 1944 } | 1790 } |
| 1945 | 1791 |
| 1946 void test_staticTopLevelDeclaration_typedef() { | 1792 void test_staticTopLevelDeclaration_typedef() { |
| 1947 ParserTestCase.parseCompilationUnit( | 1793 ParserTestCase.parseCompilationUnit( |
| 1948 "static typedef F();", [ParserErrorCode.STATIC_TOP_LEVEL_DECLARATION]); | 1794 "static typedef F();", [ParserErrorCode.STATIC_TOP_LEVEL_DECLARATION]); |
| 1949 } | 1795 } |
| 1950 | 1796 |
| 1951 void test_staticTopLevelDeclaration_variable() { | 1797 void test_staticTopLevelDeclaration_variable() { |
| 1952 ParserTestCase.parseCompilationUnit( | 1798 ParserTestCase.parseCompilationUnit( |
| 1953 "static var x;", [ParserErrorCode.STATIC_TOP_LEVEL_DECLARATION]); | 1799 "static var x;", [ParserErrorCode.STATIC_TOP_LEVEL_DECLARATION]); |
| 1954 } | 1800 } |
| 1955 | 1801 |
| 1956 void test_switchHasCaseAfterDefaultCase() { | 1802 void test_switchHasCaseAfterDefaultCase() { |
| 1957 ParserTestCase.parse4("parseSwitchStatement", | 1803 parse4("parseSwitchStatement", |
| 1958 "switch (a) {default: return 0; case 1: return 1;}", [ | 1804 "switch (a) {default: return 0; case 1: return 1;}", |
| 1959 ParserErrorCode.SWITCH_HAS_CASE_AFTER_DEFAULT_CASE | 1805 [ParserErrorCode.SWITCH_HAS_CASE_AFTER_DEFAULT_CASE]); |
| 1960 ]); | |
| 1961 } | 1806 } |
| 1962 | 1807 |
| 1963 void test_switchHasCaseAfterDefaultCase_repeated() { | 1808 void test_switchHasCaseAfterDefaultCase_repeated() { |
| 1964 ParserTestCase.parse4("parseSwitchStatement", | 1809 parse4("parseSwitchStatement", |
| 1965 "switch (a) {default: return 0; case 1: return 1; case 2: return 2;}", [ | 1810 "switch (a) {default: return 0; case 1: return 1; case 2: return 2;}", [ |
| 1966 ParserErrorCode.SWITCH_HAS_CASE_AFTER_DEFAULT_CASE, | 1811 ParserErrorCode.SWITCH_HAS_CASE_AFTER_DEFAULT_CASE, |
| 1967 ParserErrorCode.SWITCH_HAS_CASE_AFTER_DEFAULT_CASE | 1812 ParserErrorCode.SWITCH_HAS_CASE_AFTER_DEFAULT_CASE |
| 1968 ]); | 1813 ]); |
| 1969 } | 1814 } |
| 1970 | 1815 |
| 1971 void test_switchHasMultipleDefaultCases() { | 1816 void test_switchHasMultipleDefaultCases() { |
| 1972 ParserTestCase.parse4("parseSwitchStatement", | 1817 parse4("parseSwitchStatement", |
| 1973 "switch (a) {default: return 0; default: return 1;}", [ | 1818 "switch (a) {default: return 0; default: return 1;}", |
| 1974 ParserErrorCode.SWITCH_HAS_MULTIPLE_DEFAULT_CASES | 1819 [ParserErrorCode.SWITCH_HAS_MULTIPLE_DEFAULT_CASES]); |
| 1975 ]); | |
| 1976 } | 1820 } |
| 1977 | 1821 |
| 1978 void test_switchHasMultipleDefaultCases_repeated() { | 1822 void test_switchHasMultipleDefaultCases_repeated() { |
| 1979 ParserTestCase.parse4("parseSwitchStatement", | 1823 parse4("parseSwitchStatement", |
| 1980 "switch (a) {default: return 0; default: return 1; default: return 2;}", | 1824 "switch (a) {default: return 0; default: return 1; default: return 2;}", |
| 1981 [ | 1825 [ |
| 1982 ParserErrorCode.SWITCH_HAS_MULTIPLE_DEFAULT_CASES, | 1826 ParserErrorCode.SWITCH_HAS_MULTIPLE_DEFAULT_CASES, |
| 1983 ParserErrorCode.SWITCH_HAS_MULTIPLE_DEFAULT_CASES | 1827 ParserErrorCode.SWITCH_HAS_MULTIPLE_DEFAULT_CASES |
| 1984 ]); | 1828 ]); |
| 1985 } | 1829 } |
| 1986 | 1830 |
| 1987 void test_topLevelOperator_withoutType() { | 1831 void test_topLevelOperator_withoutType() { |
| 1988 ParserTestCase.parse3("parseCompilationUnitMember", <Object>[ | 1832 parse3("parseCompilationUnitMember", <Object>[emptyCommentAndMetadata()], |
| 1989 emptyCommentAndMetadata() | 1833 "operator +(bool x, bool y) => x | y;", |
| 1990 ], "operator +(bool x, bool y) => x | y;", [ | 1834 [ParserErrorCode.TOP_LEVEL_OPERATOR]); |
| 1991 ParserErrorCode.TOP_LEVEL_OPERATOR | |
| 1992 ]); | |
| 1993 } | 1835 } |
| 1994 | 1836 |
| 1995 void test_topLevelOperator_withType() { | 1837 void test_topLevelOperator_withType() { |
| 1996 ParserTestCase.parse3("parseCompilationUnitMember", <Object>[ | 1838 parse3("parseCompilationUnitMember", <Object>[emptyCommentAndMetadata()], |
| 1997 emptyCommentAndMetadata() | 1839 "bool operator +(bool x, bool y) => x | y;", |
| 1998 ], "bool operator +(bool x, bool y) => x | y;", [ | 1840 [ParserErrorCode.TOP_LEVEL_OPERATOR]); |
| 1999 ParserErrorCode.TOP_LEVEL_OPERATOR | |
| 2000 ]); | |
| 2001 } | 1841 } |
| 2002 | 1842 |
| 2003 void test_topLevelOperator_withVoid() { | 1843 void test_topLevelOperator_withVoid() { |
| 2004 ParserTestCase.parse3("parseCompilationUnitMember", <Object>[ | 1844 parse3("parseCompilationUnitMember", <Object>[emptyCommentAndMetadata()], |
| 2005 emptyCommentAndMetadata() | 1845 "void operator +(bool x, bool y) => x | y;", |
| 2006 ], "void operator +(bool x, bool y) => x | y;", [ | 1846 [ParserErrorCode.TOP_LEVEL_OPERATOR]); |
| 2007 ParserErrorCode.TOP_LEVEL_OPERATOR | |
| 2008 ]); | |
| 2009 } | 1847 } |
| 2010 | 1848 |
| 2011 void test_typedefInClass_withoutReturnType() { | 1849 void test_typedefInClass_withoutReturnType() { |
| 2012 ParserTestCase.parseCompilationUnit( | 1850 ParserTestCase.parseCompilationUnit( |
| 2013 "class C { typedef F(x); }", [ParserErrorCode.TYPEDEF_IN_CLASS]); | 1851 "class C { typedef F(x); }", [ParserErrorCode.TYPEDEF_IN_CLASS]); |
| 2014 } | 1852 } |
| 2015 | 1853 |
| 2016 void test_typedefInClass_withReturnType() { | 1854 void test_typedefInClass_withReturnType() { |
| 2017 ParserTestCase.parseCompilationUnit("class C { typedef int F(int x); }", [ | 1855 ParserTestCase.parseCompilationUnit("class C { typedef int F(int x); }", |
| 2018 ParserErrorCode.TYPEDEF_IN_CLASS | 1856 [ParserErrorCode.TYPEDEF_IN_CLASS]); |
| 2019 ]); | |
| 2020 } | 1857 } |
| 2021 | 1858 |
| 2022 void test_unexpectedTerminatorForParameterGroup_named() { | 1859 void test_unexpectedTerminatorForParameterGroup_named() { |
| 2023 ParserTestCase.parse4("parseFormalParameterList", "(a, b})", [ | 1860 parse4("parseFormalParameterList", "(a, b})", |
| 2024 ParserErrorCode.UNEXPECTED_TERMINATOR_FOR_PARAMETER_GROUP | 1861 [ParserErrorCode.UNEXPECTED_TERMINATOR_FOR_PARAMETER_GROUP]); |
| 2025 ]); | |
| 2026 } | 1862 } |
| 2027 | 1863 |
| 2028 void test_unexpectedTerminatorForParameterGroup_optional() { | 1864 void test_unexpectedTerminatorForParameterGroup_optional() { |
| 2029 ParserTestCase.parse4("parseFormalParameterList", "(a, b])", [ | 1865 parse4("parseFormalParameterList", "(a, b])", |
| 2030 ParserErrorCode.UNEXPECTED_TERMINATOR_FOR_PARAMETER_GROUP | 1866 [ParserErrorCode.UNEXPECTED_TERMINATOR_FOR_PARAMETER_GROUP]); |
| 2031 ]); | |
| 2032 } | 1867 } |
| 2033 | 1868 |
| 2034 void test_unexpectedToken_endOfFieldDeclarationStatement() { | 1869 void test_unexpectedToken_endOfFieldDeclarationStatement() { |
| 2035 ParserTestCase.parseStatement( | 1870 ParserTestCase.parseStatement( |
| 2036 "String s = (null));", [ParserErrorCode.UNEXPECTED_TOKEN]); | 1871 "String s = (null));", [ParserErrorCode.UNEXPECTED_TOKEN]); |
| 2037 } | 1872 } |
| 2038 | 1873 |
| 2039 void test_unexpectedToken_returnInExpressionFuntionBody() { | 1874 void test_unexpectedToken_returnInExpressionFuntionBody() { |
| 2040 ParserTestCase.parseCompilationUnit( | 1875 ParserTestCase.parseCompilationUnit( |
| 2041 "f() => return null;", [ParserErrorCode.UNEXPECTED_TOKEN]); | 1876 "f() => return null;", [ParserErrorCode.UNEXPECTED_TOKEN]); |
| 2042 } | 1877 } |
| 2043 | 1878 |
| 2044 void test_unexpectedToken_semicolonBetweenClassMembers() { | 1879 void test_unexpectedToken_semicolonBetweenClassMembers() { |
| 2045 ParserTestCase.parse3("parseClassDeclaration", <Object>[ | 1880 parse3("parseClassDeclaration", <Object>[ |
| 2046 emptyCommentAndMetadata(), | 1881 emptyCommentAndMetadata(), |
| 2047 null | 1882 null |
| 2048 ], "class C { int x; ; int y;}", [ParserErrorCode.UNEXPECTED_TOKEN]); | 1883 ], "class C { int x; ; int y;}", [ParserErrorCode.UNEXPECTED_TOKEN]); |
| 2049 } | 1884 } |
| 2050 | 1885 |
| 2051 void test_unexpectedToken_semicolonBetweenCompilationUnitMembers() { | 1886 void test_unexpectedToken_semicolonBetweenCompilationUnitMembers() { |
| 2052 ParserTestCase.parseCompilationUnit( | 1887 ParserTestCase.parseCompilationUnit( |
| 2053 "int x; ; int y;", [ParserErrorCode.UNEXPECTED_TOKEN]); | 1888 "int x; ; int y;", [ParserErrorCode.UNEXPECTED_TOKEN]); |
| 2054 } | 1889 } |
| 2055 | 1890 |
| 2056 void test_useOfUnaryPlusOperator() { | 1891 void test_useOfUnaryPlusOperator() { |
| 2057 SimpleIdentifier expression = ParserTestCase.parse4( | 1892 SimpleIdentifier expression = parse4( |
| 2058 "parseUnaryExpression", "+x", [ParserErrorCode.MISSING_IDENTIFIER]); | 1893 "parseUnaryExpression", "+x", [ParserErrorCode.MISSING_IDENTIFIER]); |
| 2059 EngineTestCase.assertInstanceOf( | 1894 EngineTestCase.assertInstanceOf( |
| 2060 (obj) => obj is SimpleIdentifier, SimpleIdentifier, expression); | 1895 (obj) => obj is SimpleIdentifier, SimpleIdentifier, expression); |
| 2061 expect(expression.isSynthetic, isTrue); | 1896 expect(expression.isSynthetic, isTrue); |
| 2062 } | 1897 } |
| 2063 | 1898 |
| 2064 void test_varAndType_field() { | 1899 void test_varAndType_field() { |
| 2065 ParserTestCase.parseCompilationUnit( | 1900 ParserTestCase.parseCompilationUnit( |
| 2066 "class C { var int x; }", [ParserErrorCode.VAR_AND_TYPE]); | 1901 "class C { var int x; }", [ParserErrorCode.VAR_AND_TYPE]); |
| 2067 } | 1902 } |
| 2068 | 1903 |
| 2069 void test_varAndType_topLevelVariable() { | 1904 void test_varAndType_topLevelVariable() { |
| 2070 ParserTestCase.parseCompilationUnit( | 1905 ParserTestCase.parseCompilationUnit( |
| 2071 "var int x;", [ParserErrorCode.VAR_AND_TYPE]); | 1906 "var int x;", [ParserErrorCode.VAR_AND_TYPE]); |
| 2072 } | 1907 } |
| 2073 | 1908 |
| 2074 void test_varAsTypeName_as() { | 1909 void test_varAsTypeName_as() { |
| 2075 ParserTestCase.parseExpression( | 1910 parseExpression("x as var", [ParserErrorCode.VAR_AS_TYPE_NAME]); |
| 2076 "x as var", [ParserErrorCode.VAR_AS_TYPE_NAME]); | |
| 2077 } | 1911 } |
| 2078 | 1912 |
| 2079 void test_varClass() { | 1913 void test_varClass() { |
| 2080 ParserTestCase.parseCompilationUnit( | 1914 ParserTestCase.parseCompilationUnit( |
| 2081 "var class C {}", [ParserErrorCode.VAR_CLASS]); | 1915 "var class C {}", [ParserErrorCode.VAR_CLASS]); |
| 2082 } | 1916 } |
| 2083 | 1917 |
| 2084 void test_varEnum() { | 1918 void test_varEnum() { |
| 2085 ParserTestCase.parseCompilationUnit( | 1919 ParserTestCase.parseCompilationUnit( |
| 2086 "var enum E {ONE}", [ParserErrorCode.VAR_ENUM]); | 1920 "var enum E {ONE}", [ParserErrorCode.VAR_ENUM]); |
| 2087 } | 1921 } |
| 2088 | 1922 |
| 2089 void test_varReturnType() { | 1923 void test_varReturnType() { |
| 2090 ParserTestCase.parse3("parseClassMember", <Object>["C"], "var m() {}", [ | 1924 parse3("parseClassMember", <Object>["C"], "var m() {}", |
| 2091 ParserErrorCode.VAR_RETURN_TYPE | 1925 [ParserErrorCode.VAR_RETURN_TYPE]); |
| 2092 ]); | |
| 2093 } | 1926 } |
| 2094 | 1927 |
| 2095 void test_varTypedef() { | 1928 void test_varTypedef() { |
| 2096 ParserTestCase.parseCompilationUnit( | 1929 ParserTestCase.parseCompilationUnit( |
| 2097 "var typedef F();", [ParserErrorCode.VAR_TYPEDEF]); | 1930 "var typedef F();", [ParserErrorCode.VAR_TYPEDEF]); |
| 2098 } | 1931 } |
| 2099 | 1932 |
| 2100 void test_voidParameter() { | 1933 void test_voidParameter() { |
| 2101 ParserTestCase.parse4("parseNormalFormalParameter", "void a)", [ | 1934 parse4("parseNormalFormalParameter", "void a)", |
| 2102 ParserErrorCode.VOID_PARAMETER | 1935 [ParserErrorCode.VOID_PARAMETER]); |
| 2103 ]); | |
| 2104 } | 1936 } |
| 2105 | 1937 |
| 2106 void test_voidVariable_parseClassMember_initializer() { | 1938 void test_voidVariable_parseClassMember_initializer() { |
| 2107 ParserTestCase.parse3("parseClassMember", <Object>["C"], "void x = 0;", [ | 1939 parse3("parseClassMember", <Object>["C"], "void x = 0;", |
| 2108 ParserErrorCode.VOID_VARIABLE | 1940 [ParserErrorCode.VOID_VARIABLE]); |
| 2109 ]); | |
| 2110 } | 1941 } |
| 2111 | 1942 |
| 2112 void test_voidVariable_parseClassMember_noInitializer() { | 1943 void test_voidVariable_parseClassMember_noInitializer() { |
| 2113 ParserTestCase.parse3("parseClassMember", <Object>["C"], "void x;", [ | 1944 parse3("parseClassMember", <Object>["C"], "void x;", |
| 2114 ParserErrorCode.VOID_VARIABLE | 1945 [ParserErrorCode.VOID_VARIABLE]); |
| 2115 ]); | |
| 2116 } | 1946 } |
| 2117 | 1947 |
| 2118 void test_voidVariable_parseCompilationUnit_initializer() { | 1948 void test_voidVariable_parseCompilationUnit_initializer() { |
| 2119 ParserTestCase.parseCompilationUnit( | 1949 ParserTestCase.parseCompilationUnit( |
| 2120 "void x = 0;", [ParserErrorCode.VOID_VARIABLE]); | 1950 "void x = 0;", [ParserErrorCode.VOID_VARIABLE]); |
| 2121 } | 1951 } |
| 2122 | 1952 |
| 2123 void test_voidVariable_parseCompilationUnit_noInitializer() { | 1953 void test_voidVariable_parseCompilationUnit_noInitializer() { |
| 2124 ParserTestCase.parseCompilationUnit( | 1954 ParserTestCase.parseCompilationUnit( |
| 2125 "void x;", [ParserErrorCode.VOID_VARIABLE]); | 1955 "void x;", [ParserErrorCode.VOID_VARIABLE]); |
| 2126 } | 1956 } |
| 2127 | 1957 |
| 2128 void test_voidVariable_parseCompilationUnitMember_initializer() { | 1958 void test_voidVariable_parseCompilationUnitMember_initializer() { |
| 2129 ParserTestCase.parse3("parseCompilationUnitMember", <Object>[ | 1959 parse3("parseCompilationUnitMember", <Object>[emptyCommentAndMetadata()], |
| 2130 emptyCommentAndMetadata() | 1960 "void a = 0;", [ParserErrorCode.VOID_VARIABLE]); |
| 2131 ], "void a = 0;", [ParserErrorCode.VOID_VARIABLE]); | |
| 2132 } | 1961 } |
| 2133 | 1962 |
| 2134 void test_voidVariable_parseCompilationUnitMember_noInitializer() { | 1963 void test_voidVariable_parseCompilationUnitMember_noInitializer() { |
| 2135 ParserTestCase.parse3("parseCompilationUnitMember", <Object>[ | 1964 parse3("parseCompilationUnitMember", <Object>[emptyCommentAndMetadata()], |
| 2136 emptyCommentAndMetadata() | 1965 "void a;", [ParserErrorCode.VOID_VARIABLE]); |
| 2137 ], "void a;", [ParserErrorCode.VOID_VARIABLE]); | |
| 2138 } | 1966 } |
| 2139 | 1967 |
| 2140 void test_voidVariable_statement_initializer() { | 1968 void test_voidVariable_statement_initializer() { |
| 2141 ParserTestCase.parseStatement("void x = 0;", [ | 1969 ParserTestCase.parseStatement("void x = 0;", [ |
| 2142 ParserErrorCode.VOID_VARIABLE, | 1970 ParserErrorCode.VOID_VARIABLE, |
| 2143 ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE | 1971 ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE |
| 2144 ]); | 1972 ]); |
| 2145 } | 1973 } |
| 2146 | 1974 |
| 2147 void test_voidVariable_statement_noInitializer() { | 1975 void test_voidVariable_statement_noInitializer() { |
| 2148 ParserTestCase.parseStatement("void x;", [ | 1976 ParserTestCase.parseStatement("void x;", [ |
| 2149 ParserErrorCode.VOID_VARIABLE, | 1977 ParserErrorCode.VOID_VARIABLE, |
| 2150 ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE | 1978 ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE |
| 2151 ]); | 1979 ]); |
| 2152 } | 1980 } |
| 2153 | 1981 |
| 2154 void test_withBeforeExtends() { | 1982 void test_withBeforeExtends() { |
| 2155 ParserTestCase.parseCompilationUnit( | 1983 ParserTestCase.parseCompilationUnit( |
| 2156 "class A with B extends C {}", [ParserErrorCode.WITH_BEFORE_EXTENDS]); | 1984 "class A with B extends C {}", [ParserErrorCode.WITH_BEFORE_EXTENDS]); |
| 2157 } | 1985 } |
| 2158 | 1986 |
| 2159 void test_withWithoutExtends() { | 1987 void test_withWithoutExtends() { |
| 2160 ParserTestCase.parse3("parseClassDeclaration", <Object>[ | 1988 parse3("parseClassDeclaration", <Object>[ |
| 2161 emptyCommentAndMetadata(), | 1989 emptyCommentAndMetadata(), |
| 2162 null | 1990 null |
| 2163 ], "class A with B, C {}", [ParserErrorCode.WITH_WITHOUT_EXTENDS]); | 1991 ], "class A with B, C {}", [ParserErrorCode.WITH_WITHOUT_EXTENDS]); |
| 2164 } | 1992 } |
| 2165 | 1993 |
| 2166 void test_wrongSeparatorForNamedParameter() { | 1994 void test_wrongSeparatorForNamedParameter() { |
| 2167 ParserTestCase.parse4("parseFormalParameterList", "(a, {b = 0})", [ | 1995 parse4("parseFormalParameterList", "(a, {b = 0})", |
| 2168 ParserErrorCode.WRONG_SEPARATOR_FOR_NAMED_PARAMETER | 1996 [ParserErrorCode.WRONG_SEPARATOR_FOR_NAMED_PARAMETER]); |
| 2169 ]); | |
| 2170 } | 1997 } |
| 2171 | 1998 |
| 2172 void test_wrongSeparatorForPositionalParameter() { | 1999 void test_wrongSeparatorForPositionalParameter() { |
| 2173 ParserTestCase.parse4("parseFormalParameterList", "(a, [b : 0])", [ | 2000 parse4("parseFormalParameterList", "(a, [b : 0])", |
| 2174 ParserErrorCode.WRONG_SEPARATOR_FOR_POSITIONAL_PARAMETER | 2001 [ParserErrorCode.WRONG_SEPARATOR_FOR_POSITIONAL_PARAMETER]); |
| 2175 ]); | |
| 2176 } | 2002 } |
| 2177 | 2003 |
| 2178 void test_wrongTerminatorForParameterGroup_named() { | 2004 void test_wrongTerminatorForParameterGroup_named() { |
| 2179 ParserTestCase.parse4("parseFormalParameterList", "(a, {b, c])", [ | 2005 parse4("parseFormalParameterList", "(a, {b, c])", |
| 2180 ParserErrorCode.WRONG_TERMINATOR_FOR_PARAMETER_GROUP | 2006 [ParserErrorCode.WRONG_TERMINATOR_FOR_PARAMETER_GROUP]); |
| 2181 ]); | |
| 2182 } | 2007 } |
| 2183 | 2008 |
| 2184 void test_wrongTerminatorForParameterGroup_optional() { | 2009 void test_wrongTerminatorForParameterGroup_optional() { |
| 2185 ParserTestCase.parse4("parseFormalParameterList", "(a, [b, c})", [ | 2010 parse4("parseFormalParameterList", "(a, [b, c})", |
| 2186 ParserErrorCode.WRONG_TERMINATOR_FOR_PARAMETER_GROUP | 2011 [ParserErrorCode.WRONG_TERMINATOR_FOR_PARAMETER_GROUP]); |
| 2187 ]); | |
| 2188 } | 2012 } |
| 2189 } | 2013 } |
| 2190 | 2014 |
| 2191 @reflectiveTest | 2015 @reflectiveTest |
| 2192 class IncrementalParserTest extends EngineTestCase { | 2016 class IncrementalParserTest extends EngineTestCase { |
| 2193 void fail_replace_identifier_with_functionLiteral_in_initializer_interp() { | 2017 void fail_replace_identifier_with_functionLiteral_in_initializer_interp() { |
| 2194 // TODO(paulberry, brianwilkerson): broken due to incremental scanning bugs | 2018 // TODO(paulberry, brianwilkerson): broken due to incremental scanning bugs |
| 2195 | 2019 |
| 2196 // Function literals are allowed inside interpolation expressions in | 2020 // Function literals are allowed inside interpolation expressions in |
| 2197 // initializers. | 2021 // initializers. |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2552 // full parse of the modified source. | 2376 // full parse of the modified source. |
| 2553 // | 2377 // |
| 2554 expect(AstComparator.equalNodes(modifiedUnit, incrementalUnit), isTrue); | 2378 expect(AstComparator.equalNodes(modifiedUnit, incrementalUnit), isTrue); |
| 2555 // TODO(brianwilkerson) Verify that the errors are correct? | 2379 // TODO(brianwilkerson) Verify that the errors are correct? |
| 2556 } | 2380 } |
| 2557 } | 2381 } |
| 2558 | 2382 |
| 2559 @reflectiveTest | 2383 @reflectiveTest |
| 2560 class NonErrorParserTest extends ParserTestCase { | 2384 class NonErrorParserTest extends ParserTestCase { |
| 2561 void test_constFactory_external() { | 2385 void test_constFactory_external() { |
| 2562 ParserTestCase.parse( | 2386 parse("parseClassMember", <Object>["C"], "external const factory C();"); |
| 2563 "parseClassMember", <Object>["C"], "external const factory C();"); | |
| 2564 } | 2387 } |
| 2565 } | 2388 } |
| 2566 | 2389 |
| 2567 class ParserTestCase extends EngineTestCase { | 2390 class ParserTestCase extends EngineTestCase { |
| 2568 /** | 2391 /** |
| 2569 * An empty list of objects used as arguments to zero-argument methods. | 2392 * An empty list of objects used as arguments to zero-argument methods. |
| 2570 */ | 2393 */ |
| 2571 static const List<Object> _EMPTY_ARGUMENTS = const <Object>[]; | 2394 static const List<Object> _EMPTY_ARGUMENTS = const <Object>[]; |
| 2572 | 2395 |
| 2573 /** | 2396 /** |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2588 } | 2411 } |
| 2589 | 2412 |
| 2590 /** | 2413 /** |
| 2591 * Return an empty CommentAndMetadata object that can be used for testing. | 2414 * Return an empty CommentAndMetadata object that can be used for testing. |
| 2592 * | 2415 * |
| 2593 * @return an empty CommentAndMetadata object that can be used for testing | 2416 * @return an empty CommentAndMetadata object that can be used for testing |
| 2594 */ | 2417 */ |
| 2595 CommentAndMetadata emptyCommentAndMetadata() => | 2418 CommentAndMetadata emptyCommentAndMetadata() => |
| 2596 new CommentAndMetadata(null, null); | 2419 new CommentAndMetadata(null, null); |
| 2597 | 2420 |
| 2598 @override | |
| 2599 void setUp() { | |
| 2600 super.setUp(); | |
| 2601 parseFunctionBodies = true; | |
| 2602 } | |
| 2603 | |
| 2604 /** | |
| 2605 * Create a parser. | |
| 2606 * | |
| 2607 * @param listener the listener to be passed to the parser | |
| 2608 * @return the parser that was created | |
| 2609 */ | |
| 2610 static Parser createParser(GatheringErrorListener listener) { | |
| 2611 return new Parser(null, listener); | |
| 2612 } | |
| 2613 | |
| 2614 /** | 2421 /** |
| 2615 * Invoke a method in [Parser]. The method is assumed to have the given number
and type of | 2422 * Invoke a method in [Parser]. The method is assumed to have the given number
and type of |
| 2616 * parameters and will be invoked with the given arguments. | 2423 * parameters and will be invoked with the given arguments. |
| 2617 * | 2424 * |
| 2618 * The given source is scanned and the parser is initialized to start with the
first token in the | 2425 * The given source is scanned and the parser is initialized to start with the
first token in the |
| 2619 * source before the method is invoked. | 2426 * source before the method is invoked. |
| 2620 * | 2427 * |
| 2621 * @param methodName the name of the method that should be invoked | 2428 * @param methodName the name of the method that should be invoked |
| 2622 * @param objects the values of the arguments to the method | 2429 * @param objects the values of the arguments to the method |
| 2623 * @param source the source to be processed by the parse method | 2430 * @param source the source to be processed by the parse method |
| 2624 * @param listener the error listener that will be used for both scanning and
parsing | 2431 * @param listener the error listener that will be used for both scanning and
parsing |
| 2625 * @return the result of invoking the method | 2432 * @return the result of invoking the method |
| 2626 * @throws Exception if the method could not be invoked or throws an exception | 2433 * @throws Exception if the method could not be invoked or throws an exception |
| 2627 * @throws AssertionFailedError if the result is `null` or the errors produced
while | 2434 * @throws AssertionFailedError if the result is `null` or the errors produced
while |
| 2628 * scanning and parsing the source do not match the expected errors | 2435 * scanning and parsing the source do not match the expected errors |
| 2629 */ | 2436 */ |
| 2630 static Object invokeParserMethod(String methodName, List<Object> objects, | 2437 Object invokeParserMethod(String methodName, List<Object> objects, |
| 2631 String source, GatheringErrorListener listener) { | 2438 String source, GatheringErrorListener listener) { |
| 2632 // | 2439 // |
| 2633 // Scan the source. | 2440 // Scan the source. |
| 2634 // | 2441 // |
| 2635 Scanner scanner = | 2442 Scanner scanner = |
| 2636 new Scanner(null, new CharSequenceReader(source), listener); | 2443 new Scanner(null, new CharSequenceReader(source), listener); |
| 2637 Token tokenStream = scanner.tokenize(); | 2444 Token tokenStream = scanner.tokenize(); |
| 2638 listener.setLineInfo(new TestSource(), scanner.lineStarts); | 2445 listener.setLineInfo(new TestSource(), scanner.lineStarts); |
| 2639 // | 2446 // |
| 2640 // Parse the source. | 2447 // Parse the source. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 2659 * source before the method is invoked. | 2466 * source before the method is invoked. |
| 2660 * | 2467 * |
| 2661 * @param methodName the name of the method that should be invoked | 2468 * @param methodName the name of the method that should be invoked |
| 2662 * @param source the source to be processed by the parse method | 2469 * @param source the source to be processed by the parse method |
| 2663 * @param listener the error listener that will be used for both scanning and
parsing | 2470 * @param listener the error listener that will be used for both scanning and
parsing |
| 2664 * @return the result of invoking the method | 2471 * @return the result of invoking the method |
| 2665 * @throws Exception if the method could not be invoked or throws an exception | 2472 * @throws Exception if the method could not be invoked or throws an exception |
| 2666 * @throws AssertionFailedError if the result is `null` or the errors produced
while | 2473 * @throws AssertionFailedError if the result is `null` or the errors produced
while |
| 2667 * scanning and parsing the source do not match the expected errors | 2474 * scanning and parsing the source do not match the expected errors |
| 2668 */ | 2475 */ |
| 2669 static Object invokeParserMethod2( | 2476 Object invokeParserMethod2( |
| 2670 String methodName, String source, GatheringErrorListener listener) => | 2477 String methodName, String source, GatheringErrorListener listener) => |
| 2671 invokeParserMethod(methodName, _EMPTY_ARGUMENTS, source, listener); | 2478 invokeParserMethod(methodName, _EMPTY_ARGUMENTS, source, listener); |
| 2672 | 2479 |
| 2673 /** | 2480 /** |
| 2674 * Invoke a parse method in [Parser]. The method is assumed to have the given
number and | 2481 * Invoke a parse method in [Parser]. The method is assumed to have the given
number and |
| 2675 * type of parameters and will be invoked with the given arguments. | 2482 * type of parameters and will be invoked with the given arguments. |
| 2676 * | 2483 * |
| 2677 * The given source is scanned and the parser is initialized to start with the
first token in the | 2484 * The given source is scanned and the parser is initialized to start with the
first token in the |
| 2678 * source before the parse method is invoked. | 2485 * source before the parse method is invoked. |
| 2679 * | 2486 * |
| 2680 * @param methodName the name of the parse method that should be invoked to pa
rse the source | 2487 * @param methodName the name of the parse method that should be invoked to pa
rse the source |
| 2681 * @param objects the values of the arguments to the method | 2488 * @param objects the values of the arguments to the method |
| 2682 * @param source the source to be parsed by the parse method | 2489 * @param source the source to be parsed by the parse method |
| 2683 * @return the result of invoking the method | 2490 * @return the result of invoking the method |
| 2684 * @throws Exception if the method could not be invoked or throws an exception | 2491 * @throws Exception if the method could not be invoked or throws an exception |
| 2685 * @throws AssertionFailedError if the result is `null` or if any errors are p
roduced | 2492 * @throws AssertionFailedError if the result is `null` or if any errors are p
roduced |
| 2686 */ | 2493 */ |
| 2687 static Object parse(String methodName, List<Object> objects, String source) => | 2494 Object parse(String methodName, List<Object> objects, String source) => |
| 2688 parse2(methodName, objects, source); | 2495 parse2(methodName, objects, source); |
| 2689 | 2496 |
| 2690 /** | 2497 /** |
| 2691 * Invoke a parse method in [Parser]. The method is assumed to have the given
number and | 2498 * Invoke a parse method in [Parser]. The method is assumed to have the given
number and |
| 2692 * type of parameters and will be invoked with the given arguments. | 2499 * type of parameters and will be invoked with the given arguments. |
| 2693 * | 2500 * |
| 2694 * The given source is scanned and the parser is initialized to start with the
first token in the | 2501 * The given source is scanned and the parser is initialized to start with the
first token in the |
| 2695 * source before the parse method is invoked. | 2502 * source before the parse method is invoked. |
| 2696 * | 2503 * |
| 2697 * @param methodName the name of the parse method that should be invoked to pa
rse the source | 2504 * @param methodName the name of the parse method that should be invoked to pa
rse the source |
| 2698 * @param objects the values of the arguments to the method | 2505 * @param objects the values of the arguments to the method |
| 2699 * @param source the source to be parsed by the parse method | 2506 * @param source the source to be parsed by the parse method |
| 2700 * @param errors the errors that should be generated | 2507 * @param errors the errors that should be generated |
| 2701 * @return the result of invoking the method | 2508 * @return the result of invoking the method |
| 2702 * @throws Exception if the method could not be invoked or throws an exception | 2509 * @throws Exception if the method could not be invoked or throws an exception |
| 2703 * @throws AssertionFailedError if the result is `null` or the errors produced
while | 2510 * @throws AssertionFailedError if the result is `null` or the errors produced
while |
| 2704 * scanning and parsing the source do not match the expected errors | 2511 * scanning and parsing the source do not match the expected errors |
| 2705 */ | 2512 */ |
| 2706 static Object parse2(String methodName, List<Object> objects, String source, | 2513 Object parse2(String methodName, List<Object> objects, String source, |
| 2707 [List<AnalysisError> errors = AnalysisError.NO_ERRORS]) { | 2514 [List<AnalysisError> errors = AnalysisError.NO_ERRORS]) { |
| 2708 GatheringErrorListener listener = new GatheringErrorListener(); | 2515 GatheringErrorListener listener = new GatheringErrorListener(); |
| 2709 Object result = invokeParserMethod(methodName, objects, source, listener); | 2516 Object result = invokeParserMethod(methodName, objects, source, listener); |
| 2710 listener.assertErrors(errors); | 2517 listener.assertErrors(errors); |
| 2711 return result; | 2518 return result; |
| 2712 } | 2519 } |
| 2713 | 2520 |
| 2714 /** | 2521 /** |
| 2715 * Invoke a parse method in [Parser]. The method is assumed to have the given
number and | 2522 * Invoke a parse method in [Parser]. The method is assumed to have the given
number and |
| 2716 * type of parameters and will be invoked with the given arguments. | 2523 * type of parameters and will be invoked with the given arguments. |
| 2717 * | 2524 * |
| 2718 * The given source is scanned and the parser is initialized to start with the
first token in the | 2525 * The given source is scanned and the parser is initialized to start with the
first token in the |
| 2719 * source before the parse method is invoked. | 2526 * source before the parse method is invoked. |
| 2720 * | 2527 * |
| 2721 * @param methodName the name of the parse method that should be invoked to pa
rse the source | 2528 * @param methodName the name of the parse method that should be invoked to pa
rse the source |
| 2722 * @param objects the values of the arguments to the method | 2529 * @param objects the values of the arguments to the method |
| 2723 * @param source the source to be parsed by the parse method | 2530 * @param source the source to be parsed by the parse method |
| 2724 * @param errorCodes the error codes of the errors that should be generated | 2531 * @param errorCodes the error codes of the errors that should be generated |
| 2725 * @return the result of invoking the method | 2532 * @return the result of invoking the method |
| 2726 * @throws Exception if the method could not be invoked or throws an exception | 2533 * @throws Exception if the method could not be invoked or throws an exception |
| 2727 * @throws AssertionFailedError if the result is `null` or the errors produced
while | 2534 * @throws AssertionFailedError if the result is `null` or the errors produced
while |
| 2728 * scanning and parsing the source do not match the expected errors | 2535 * scanning and parsing the source do not match the expected errors |
| 2729 */ | 2536 */ |
| 2730 static Object parse3(String methodName, List<Object> objects, String source, | 2537 Object parse3(String methodName, List<Object> objects, String source, |
| 2731 [List<ErrorCode> errorCodes = ErrorCode.EMPTY_LIST]) { | 2538 [List<ErrorCode> errorCodes = ErrorCode.EMPTY_LIST]) { |
| 2732 GatheringErrorListener listener = new GatheringErrorListener(); | 2539 GatheringErrorListener listener = new GatheringErrorListener(); |
| 2733 Object result = invokeParserMethod(methodName, objects, source, listener); | 2540 Object result = invokeParserMethod(methodName, objects, source, listener); |
| 2734 listener.assertErrorsWithCodes(errorCodes); | 2541 listener.assertErrorsWithCodes(errorCodes); |
| 2735 return result; | 2542 return result; |
| 2736 } | 2543 } |
| 2737 | 2544 |
| 2738 /** | 2545 /** |
| 2739 * Invoke a parse method in [Parser]. The method is assumed to have no argumen
ts. | 2546 * Invoke a parse method in [Parser]. The method is assumed to have no argumen
ts. |
| 2740 * | 2547 * |
| 2741 * The given source is scanned and the parser is initialized to start with the
first token in the | 2548 * The given source is scanned and the parser is initialized to start with the
first token in the |
| 2742 * source before the parse method is invoked. | 2549 * source before the parse method is invoked. |
| 2743 * | 2550 * |
| 2744 * @param methodName the name of the parse method that should be invoked to pa
rse the source | 2551 * @param methodName the name of the parse method that should be invoked to pa
rse the source |
| 2745 * @param source the source to be parsed by the parse method | 2552 * @param source the source to be parsed by the parse method |
| 2746 * @param errorCodes the error codes of the errors that should be generated | 2553 * @param errorCodes the error codes of the errors that should be generated |
| 2747 * @return the result of invoking the method | 2554 * @return the result of invoking the method |
| 2748 * @throws Exception if the method could not be invoked or throws an exception | 2555 * @throws Exception if the method could not be invoked or throws an exception |
| 2749 * @throws AssertionFailedError if the result is `null` or the errors produced
while | 2556 * @throws AssertionFailedError if the result is `null` or the errors produced
while |
| 2750 * scanning and parsing the source do not match the expected errors | 2557 * scanning and parsing the source do not match the expected errors |
| 2751 */ | 2558 */ |
| 2752 static Object parse4(String methodName, String source, | 2559 Object parse4(String methodName, String source, |
| 2753 [List<ErrorCode> errorCodes = ErrorCode.EMPTY_LIST]) => | 2560 [List<ErrorCode> errorCodes = ErrorCode.EMPTY_LIST]) => |
| 2754 parse3(methodName, _EMPTY_ARGUMENTS, source, errorCodes); | 2561 parse3(methodName, _EMPTY_ARGUMENTS, source, errorCodes); |
| 2755 | 2562 |
| 2756 /** | 2563 /** |
| 2757 * Parse the given source as a compilation unit. | 2564 * Parse the given source as an expression. |
| 2758 * | 2565 * |
| 2759 * @param source the source to be parsed | 2566 * @param source the source to be parsed |
| 2760 * @param errorCodes the error codes of the errors that are expected to be fou
nd | 2567 * @param errorCodes the error codes of the errors that are expected to be fou
nd |
| 2761 * @return the compilation unit that was parsed | 2568 * @return the expression that was parsed |
| 2762 * @throws Exception if the source could not be parsed, if the compilation err
ors in the source do | 2569 * @throws Exception if the source could not be parsed, if the compilation err
ors in the source do |
| 2763 * not match those that are expected, or if the result would have be
en `null` | 2570 * not match those that are expected, or if the result would have be
en `null` |
| 2764 */ | 2571 */ |
| 2765 static CompilationUnit parseCompilationUnit(String source, | 2572 Expression parseExpression(String source, |
| 2766 [List<ErrorCode> errorCodes = ErrorCode.EMPTY_LIST]) { | 2573 [List<ErrorCode> errorCodes = ErrorCode.EMPTY_LIST]) { |
| 2767 GatheringErrorListener listener = new GatheringErrorListener(); | 2574 GatheringErrorListener listener = new GatheringErrorListener(); |
| 2768 Scanner scanner = | 2575 Scanner scanner = |
| 2769 new Scanner(null, new CharSequenceReader(source), listener); | 2576 new Scanner(null, new CharSequenceReader(source), listener); |
| 2770 listener.setLineInfo(new TestSource(), scanner.lineStarts); | 2577 listener.setLineInfo(new TestSource(), scanner.lineStarts); |
| 2771 Token token = scanner.tokenize(); | 2578 Token token = scanner.tokenize(); |
| 2772 Parser parser = createParser(listener); | 2579 Parser parser = createParser(listener); |
| 2773 CompilationUnit unit = parser.parseCompilationUnit(token); | 2580 Expression expression = parser.parseExpression(token); |
| 2774 expect(unit, isNotNull); | 2581 expect(expression, isNotNull); |
| 2775 listener.assertErrorsWithCodes(errorCodes); | 2582 listener.assertErrorsWithCodes(errorCodes); |
| 2776 return unit; | 2583 return expression; |
| 2584 } |
| 2585 |
| 2586 @override |
| 2587 void setUp() { |
| 2588 super.setUp(); |
| 2589 parseFunctionBodies = true; |
| 2777 } | 2590 } |
| 2778 | 2591 |
| 2779 /** | 2592 /** |
| 2780 * Parse the given source as an expression. | 2593 * Create a parser. |
| 2594 * |
| 2595 * @param listener the listener to be passed to the parser |
| 2596 * @return the parser that was created |
| 2597 */ |
| 2598 static Parser createParser(GatheringErrorListener listener) { |
| 2599 return new Parser(null, listener); |
| 2600 } |
| 2601 |
| 2602 /** |
| 2603 * Parse the given source as a compilation unit. |
| 2781 * | 2604 * |
| 2782 * @param source the source to be parsed | 2605 * @param source the source to be parsed |
| 2783 * @param errorCodes the error codes of the errors that are expected to be fou
nd | 2606 * @param errorCodes the error codes of the errors that are expected to be fou
nd |
| 2784 * @return the expression that was parsed | 2607 * @return the compilation unit that was parsed |
| 2785 * @throws Exception if the source could not be parsed, if the compilation err
ors in the source do | 2608 * @throws Exception if the source could not be parsed, if the compilation err
ors in the source do |
| 2786 * not match those that are expected, or if the result would have be
en `null` | 2609 * not match those that are expected, or if the result would have be
en `null` |
| 2787 */ | 2610 */ |
| 2788 static Expression parseExpression(String source, | 2611 static CompilationUnit parseCompilationUnit(String source, |
| 2789 [List<ErrorCode> errorCodes = ErrorCode.EMPTY_LIST]) { | 2612 [List<ErrorCode> errorCodes = ErrorCode.EMPTY_LIST]) { |
| 2790 GatheringErrorListener listener = new GatheringErrorListener(); | 2613 GatheringErrorListener listener = new GatheringErrorListener(); |
| 2791 Scanner scanner = | 2614 Scanner scanner = |
| 2792 new Scanner(null, new CharSequenceReader(source), listener); | 2615 new Scanner(null, new CharSequenceReader(source), listener); |
| 2793 listener.setLineInfo(new TestSource(), scanner.lineStarts); | 2616 listener.setLineInfo(new TestSource(), scanner.lineStarts); |
| 2794 Token token = scanner.tokenize(); | 2617 Token token = scanner.tokenize(); |
| 2795 Parser parser = createParser(listener); | 2618 Parser parser = createParser(listener); |
| 2796 Expression expression = parser.parseExpression(token); | 2619 CompilationUnit unit = parser.parseCompilationUnit(token); |
| 2797 expect(expression, isNotNull); | 2620 expect(unit, isNotNull); |
| 2798 listener.assertErrorsWithCodes(errorCodes); | 2621 listener.assertErrorsWithCodes(errorCodes); |
| 2799 return expression; | 2622 return unit; |
| 2800 } | 2623 } |
| 2801 | 2624 |
| 2802 /** | 2625 /** |
| 2803 * Parse the given source as a statement. | 2626 * Parse the given source as a statement. |
| 2804 * | 2627 * |
| 2805 * @param source the source to be parsed | 2628 * @param source the source to be parsed |
| 2806 * @param errorCodes the error codes of the errors that are expected to be fou
nd | 2629 * @param errorCodes the error codes of the errors that are expected to be fou
nd |
| 2807 * @return the statement that was parsed | 2630 * @return the statement that was parsed |
| 2808 * @throws Exception if the source could not be parsed, if the compilation err
ors in the source do | 2631 * @throws Exception if the source could not be parsed, if the compilation err
ors in the source do |
| 2809 * not match those that are expected, or if the result would have be
en `null` | 2632 * not match those that are expected, or if the result would have be
en `null` |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2860 if (map == null) return null; | 2683 if (map == null) return null; |
| 2861 Map<Symbol, dynamic> result = new Map<Symbol, dynamic>(); | 2684 Map<Symbol, dynamic> result = new Map<Symbol, dynamic>(); |
| 2862 map.forEach((name, value) { | 2685 map.forEach((name, value) { |
| 2863 result[new Symbol(name)] = value; | 2686 result[new Symbol(name)] = value; |
| 2864 }); | 2687 }); |
| 2865 return result; | 2688 return result; |
| 2866 }'''); | 2689 }'''); |
| 2867 } | 2690 } |
| 2868 | 2691 |
| 2869 void test_additiveExpression_missing_LHS() { | 2692 void test_additiveExpression_missing_LHS() { |
| 2870 BinaryExpression expression = ParserTestCase.parseExpression( | 2693 BinaryExpression expression = |
| 2871 "+ y", [ParserErrorCode.MISSING_IDENTIFIER]); | 2694 parseExpression("+ y", [ParserErrorCode.MISSING_IDENTIFIER]); |
| 2872 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 2695 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
| 2873 SimpleIdentifier, expression.leftOperand); | 2696 SimpleIdentifier, expression.leftOperand); |
| 2874 expect(expression.leftOperand.isSynthetic, isTrue); | 2697 expect(expression.leftOperand.isSynthetic, isTrue); |
| 2875 } | 2698 } |
| 2876 | 2699 |
| 2877 void test_additiveExpression_missing_LHS_RHS() { | 2700 void test_additiveExpression_missing_LHS_RHS() { |
| 2878 BinaryExpression expression = ParserTestCase.parseExpression("+", [ | 2701 BinaryExpression expression = parseExpression("+", [ |
| 2879 ParserErrorCode.MISSING_IDENTIFIER, | 2702 ParserErrorCode.MISSING_IDENTIFIER, |
| 2880 ParserErrorCode.MISSING_IDENTIFIER | 2703 ParserErrorCode.MISSING_IDENTIFIER |
| 2881 ]); | 2704 ]); |
| 2882 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 2705 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
| 2883 SimpleIdentifier, expression.leftOperand); | 2706 SimpleIdentifier, expression.leftOperand); |
| 2884 expect(expression.leftOperand.isSynthetic, isTrue); | 2707 expect(expression.leftOperand.isSynthetic, isTrue); |
| 2885 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 2708 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
| 2886 SimpleIdentifier, expression.rightOperand); | 2709 SimpleIdentifier, expression.rightOperand); |
| 2887 expect(expression.rightOperand.isSynthetic, isTrue); | 2710 expect(expression.rightOperand.isSynthetic, isTrue); |
| 2888 } | 2711 } |
| 2889 | 2712 |
| 2890 void test_additiveExpression_missing_RHS() { | 2713 void test_additiveExpression_missing_RHS() { |
| 2891 BinaryExpression expression = ParserTestCase.parseExpression( | 2714 BinaryExpression expression = |
| 2892 "x +", [ParserErrorCode.MISSING_IDENTIFIER]); | 2715 parseExpression("x +", [ParserErrorCode.MISSING_IDENTIFIER]); |
| 2893 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 2716 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
| 2894 SimpleIdentifier, expression.rightOperand); | 2717 SimpleIdentifier, expression.rightOperand); |
| 2895 expect(expression.rightOperand.isSynthetic, isTrue); | 2718 expect(expression.rightOperand.isSynthetic, isTrue); |
| 2896 } | 2719 } |
| 2897 | 2720 |
| 2898 void test_additiveExpression_missing_RHS_super() { | 2721 void test_additiveExpression_missing_RHS_super() { |
| 2899 BinaryExpression expression = ParserTestCase.parseExpression( | 2722 BinaryExpression expression = |
| 2900 "super +", [ParserErrorCode.MISSING_IDENTIFIER]); | 2723 parseExpression("super +", [ParserErrorCode.MISSING_IDENTIFIER]); |
| 2901 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 2724 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
| 2902 SimpleIdentifier, expression.rightOperand); | 2725 SimpleIdentifier, expression.rightOperand); |
| 2903 expect(expression.rightOperand.isSynthetic, isTrue); | 2726 expect(expression.rightOperand.isSynthetic, isTrue); |
| 2904 } | 2727 } |
| 2905 | 2728 |
| 2906 void test_additiveExpression_precedence_multiplicative_left() { | 2729 void test_additiveExpression_precedence_multiplicative_left() { |
| 2907 BinaryExpression expression = ParserTestCase.parseExpression("* +", [ | 2730 BinaryExpression expression = parseExpression("* +", [ |
| 2908 ParserErrorCode.MISSING_IDENTIFIER, | 2731 ParserErrorCode.MISSING_IDENTIFIER, |
| 2909 ParserErrorCode.MISSING_IDENTIFIER, | 2732 ParserErrorCode.MISSING_IDENTIFIER, |
| 2910 ParserErrorCode.MISSING_IDENTIFIER | 2733 ParserErrorCode.MISSING_IDENTIFIER |
| 2911 ]); | 2734 ]); |
| 2912 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | 2735 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, |
| 2913 BinaryExpression, expression.leftOperand); | 2736 BinaryExpression, expression.leftOperand); |
| 2914 } | 2737 } |
| 2915 | 2738 |
| 2916 void test_additiveExpression_precedence_multiplicative_right() { | 2739 void test_additiveExpression_precedence_multiplicative_right() { |
| 2917 BinaryExpression expression = ParserTestCase.parseExpression("+ *", [ | 2740 BinaryExpression expression = parseExpression("+ *", [ |
| 2918 ParserErrorCode.MISSING_IDENTIFIER, | 2741 ParserErrorCode.MISSING_IDENTIFIER, |
| 2919 ParserErrorCode.MISSING_IDENTIFIER, | 2742 ParserErrorCode.MISSING_IDENTIFIER, |
| 2920 ParserErrorCode.MISSING_IDENTIFIER | 2743 ParserErrorCode.MISSING_IDENTIFIER |
| 2921 ]); | 2744 ]); |
| 2922 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | 2745 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, |
| 2923 BinaryExpression, expression.rightOperand); | 2746 BinaryExpression, expression.rightOperand); |
| 2924 } | 2747 } |
| 2925 | 2748 |
| 2926 void test_additiveExpression_super() { | 2749 void test_additiveExpression_super() { |
| 2927 BinaryExpression expression = ParserTestCase.parseExpression("super + +", [ | 2750 BinaryExpression expression = parseExpression("super + +", [ |
| 2928 ParserErrorCode.MISSING_IDENTIFIER, | 2751 ParserErrorCode.MISSING_IDENTIFIER, |
| 2929 ParserErrorCode.MISSING_IDENTIFIER | 2752 ParserErrorCode.MISSING_IDENTIFIER |
| 2930 ]); | 2753 ]); |
| 2931 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | 2754 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, |
| 2932 BinaryExpression, expression.leftOperand); | 2755 BinaryExpression, expression.leftOperand); |
| 2933 } | 2756 } |
| 2934 | 2757 |
| 2935 void test_assignmentExpression_missing_compound1() { | 2758 void test_assignmentExpression_missing_compound1() { |
| 2936 AssignmentExpression expression = ParserTestCase.parseExpression( | 2759 AssignmentExpression expression = |
| 2937 "= y = 0", [ParserErrorCode.MISSING_IDENTIFIER]); | 2760 parseExpression("= y = 0", [ParserErrorCode.MISSING_IDENTIFIER]); |
| 2938 Expression syntheticExpression = expression.leftHandSide; | 2761 Expression syntheticExpression = expression.leftHandSide; |
| 2939 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 2762 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
| 2940 SimpleIdentifier, syntheticExpression); | 2763 SimpleIdentifier, syntheticExpression); |
| 2941 expect(syntheticExpression.isSynthetic, isTrue); | 2764 expect(syntheticExpression.isSynthetic, isTrue); |
| 2942 } | 2765 } |
| 2943 | 2766 |
| 2944 void test_assignmentExpression_missing_compound2() { | 2767 void test_assignmentExpression_missing_compound2() { |
| 2945 AssignmentExpression expression = ParserTestCase.parseExpression( | 2768 AssignmentExpression expression = |
| 2946 "x = = 0", [ParserErrorCode.MISSING_IDENTIFIER]); | 2769 parseExpression("x = = 0", [ParserErrorCode.MISSING_IDENTIFIER]); |
| 2947 Expression syntheticExpression = | 2770 Expression syntheticExpression = |
| 2948 (expression.rightHandSide as AssignmentExpression).leftHandSide; | 2771 (expression.rightHandSide as AssignmentExpression).leftHandSide; |
| 2949 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 2772 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
| 2950 SimpleIdentifier, syntheticExpression); | 2773 SimpleIdentifier, syntheticExpression); |
| 2951 expect(syntheticExpression.isSynthetic, isTrue); | 2774 expect(syntheticExpression.isSynthetic, isTrue); |
| 2952 } | 2775 } |
| 2953 | 2776 |
| 2954 void test_assignmentExpression_missing_compound3() { | 2777 void test_assignmentExpression_missing_compound3() { |
| 2955 AssignmentExpression expression = ParserTestCase.parseExpression( | 2778 AssignmentExpression expression = |
| 2956 "x = y =", [ParserErrorCode.MISSING_IDENTIFIER]); | 2779 parseExpression("x = y =", [ParserErrorCode.MISSING_IDENTIFIER]); |
| 2957 Expression syntheticExpression = | 2780 Expression syntheticExpression = |
| 2958 (expression.rightHandSide as AssignmentExpression).rightHandSide; | 2781 (expression.rightHandSide as AssignmentExpression).rightHandSide; |
| 2959 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 2782 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
| 2960 SimpleIdentifier, syntheticExpression); | 2783 SimpleIdentifier, syntheticExpression); |
| 2961 expect(syntheticExpression.isSynthetic, isTrue); | 2784 expect(syntheticExpression.isSynthetic, isTrue); |
| 2962 } | 2785 } |
| 2963 | 2786 |
| 2964 void test_assignmentExpression_missing_LHS() { | 2787 void test_assignmentExpression_missing_LHS() { |
| 2965 AssignmentExpression expression = ParserTestCase.parseExpression( | 2788 AssignmentExpression expression = |
| 2966 "= 0", [ParserErrorCode.MISSING_IDENTIFIER]); | 2789 parseExpression("= 0", [ParserErrorCode.MISSING_IDENTIFIER]); |
| 2967 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 2790 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
| 2968 SimpleIdentifier, expression.leftHandSide); | 2791 SimpleIdentifier, expression.leftHandSide); |
| 2969 expect(expression.leftHandSide.isSynthetic, isTrue); | 2792 expect(expression.leftHandSide.isSynthetic, isTrue); |
| 2970 } | 2793 } |
| 2971 | 2794 |
| 2972 void test_assignmentExpression_missing_RHS() { | 2795 void test_assignmentExpression_missing_RHS() { |
| 2973 AssignmentExpression expression = ParserTestCase.parseExpression( | 2796 AssignmentExpression expression = |
| 2974 "x =", [ParserErrorCode.MISSING_IDENTIFIER]); | 2797 parseExpression("x =", [ParserErrorCode.MISSING_IDENTIFIER]); |
| 2975 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 2798 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
| 2976 SimpleIdentifier, expression.leftHandSide); | 2799 SimpleIdentifier, expression.leftHandSide); |
| 2977 expect(expression.rightHandSide.isSynthetic, isTrue); | 2800 expect(expression.rightHandSide.isSynthetic, isTrue); |
| 2978 } | 2801 } |
| 2979 | 2802 |
| 2980 void test_bitwiseAndExpression_missing_LHS() { | 2803 void test_bitwiseAndExpression_missing_LHS() { |
| 2981 BinaryExpression expression = ParserTestCase.parseExpression( | 2804 BinaryExpression expression = |
| 2982 "& y", [ParserErrorCode.MISSING_IDENTIFIER]); | 2805 parseExpression("& y", [ParserErrorCode.MISSING_IDENTIFIER]); |
| 2983 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 2806 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
| 2984 SimpleIdentifier, expression.leftOperand); | 2807 SimpleIdentifier, expression.leftOperand); |
| 2985 expect(expression.leftOperand.isSynthetic, isTrue); | 2808 expect(expression.leftOperand.isSynthetic, isTrue); |
| 2986 } | 2809 } |
| 2987 | 2810 |
| 2988 void test_bitwiseAndExpression_missing_LHS_RHS() { | 2811 void test_bitwiseAndExpression_missing_LHS_RHS() { |
| 2989 BinaryExpression expression = ParserTestCase.parseExpression("&", [ | 2812 BinaryExpression expression = parseExpression("&", [ |
| 2990 ParserErrorCode.MISSING_IDENTIFIER, | 2813 ParserErrorCode.MISSING_IDENTIFIER, |
| 2991 ParserErrorCode.MISSING_IDENTIFIER | 2814 ParserErrorCode.MISSING_IDENTIFIER |
| 2992 ]); | 2815 ]); |
| 2993 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 2816 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
| 2994 SimpleIdentifier, expression.leftOperand); | 2817 SimpleIdentifier, expression.leftOperand); |
| 2995 expect(expression.leftOperand.isSynthetic, isTrue); | 2818 expect(expression.leftOperand.isSynthetic, isTrue); |
| 2996 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 2819 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
| 2997 SimpleIdentifier, expression.rightOperand); | 2820 SimpleIdentifier, expression.rightOperand); |
| 2998 expect(expression.rightOperand.isSynthetic, isTrue); | 2821 expect(expression.rightOperand.isSynthetic, isTrue); |
| 2999 } | 2822 } |
| 3000 | 2823 |
| 3001 void test_bitwiseAndExpression_missing_RHS() { | 2824 void test_bitwiseAndExpression_missing_RHS() { |
| 3002 BinaryExpression expression = ParserTestCase.parseExpression( | 2825 BinaryExpression expression = |
| 3003 "x &", [ParserErrorCode.MISSING_IDENTIFIER]); | 2826 parseExpression("x &", [ParserErrorCode.MISSING_IDENTIFIER]); |
| 3004 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 2827 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
| 3005 SimpleIdentifier, expression.rightOperand); | 2828 SimpleIdentifier, expression.rightOperand); |
| 3006 expect(expression.rightOperand.isSynthetic, isTrue); | 2829 expect(expression.rightOperand.isSynthetic, isTrue); |
| 3007 } | 2830 } |
| 3008 | 2831 |
| 3009 void test_bitwiseAndExpression_missing_RHS_super() { | 2832 void test_bitwiseAndExpression_missing_RHS_super() { |
| 3010 BinaryExpression expression = ParserTestCase.parseExpression( | 2833 BinaryExpression expression = |
| 3011 "super &", [ParserErrorCode.MISSING_IDENTIFIER]); | 2834 parseExpression("super &", [ParserErrorCode.MISSING_IDENTIFIER]); |
| 3012 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 2835 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
| 3013 SimpleIdentifier, expression.rightOperand); | 2836 SimpleIdentifier, expression.rightOperand); |
| 3014 expect(expression.rightOperand.isSynthetic, isTrue); | 2837 expect(expression.rightOperand.isSynthetic, isTrue); |
| 3015 } | 2838 } |
| 3016 | 2839 |
| 3017 void test_bitwiseAndExpression_precedence_equality_left() { | 2840 void test_bitwiseAndExpression_precedence_equality_left() { |
| 3018 BinaryExpression expression = ParserTestCase.parseExpression("== &&", [ | 2841 BinaryExpression expression = parseExpression("== &&", [ |
| 3019 ParserErrorCode.MISSING_IDENTIFIER, | 2842 ParserErrorCode.MISSING_IDENTIFIER, |
| 3020 ParserErrorCode.MISSING_IDENTIFIER, | 2843 ParserErrorCode.MISSING_IDENTIFIER, |
| 3021 ParserErrorCode.MISSING_IDENTIFIER | 2844 ParserErrorCode.MISSING_IDENTIFIER |
| 3022 ]); | 2845 ]); |
| 3023 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | 2846 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, |
| 3024 BinaryExpression, expression.leftOperand); | 2847 BinaryExpression, expression.leftOperand); |
| 3025 } | 2848 } |
| 3026 | 2849 |
| 3027 void test_bitwiseAndExpression_precedence_equality_right() { | 2850 void test_bitwiseAndExpression_precedence_equality_right() { |
| 3028 BinaryExpression expression = ParserTestCase.parseExpression("&& ==", [ | 2851 BinaryExpression expression = parseExpression("&& ==", [ |
| 3029 ParserErrorCode.MISSING_IDENTIFIER, | 2852 ParserErrorCode.MISSING_IDENTIFIER, |
| 3030 ParserErrorCode.MISSING_IDENTIFIER, | 2853 ParserErrorCode.MISSING_IDENTIFIER, |
| 3031 ParserErrorCode.MISSING_IDENTIFIER | 2854 ParserErrorCode.MISSING_IDENTIFIER |
| 3032 ]); | 2855 ]); |
| 3033 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | 2856 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, |
| 3034 BinaryExpression, expression.rightOperand); | 2857 BinaryExpression, expression.rightOperand); |
| 3035 } | 2858 } |
| 3036 | 2859 |
| 3037 void test_bitwiseAndExpression_super() { | 2860 void test_bitwiseAndExpression_super() { |
| 3038 BinaryExpression expression = ParserTestCase.parseExpression("super & &", [ | 2861 BinaryExpression expression = parseExpression("super & &", [ |
| 3039 ParserErrorCode.MISSING_IDENTIFIER, | 2862 ParserErrorCode.MISSING_IDENTIFIER, |
| 3040 ParserErrorCode.MISSING_IDENTIFIER | 2863 ParserErrorCode.MISSING_IDENTIFIER |
| 3041 ]); | 2864 ]); |
| 3042 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | 2865 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, |
| 3043 BinaryExpression, expression.leftOperand); | 2866 BinaryExpression, expression.leftOperand); |
| 3044 } | 2867 } |
| 3045 | 2868 |
| 3046 void test_bitwiseOrExpression_missing_LHS() { | 2869 void test_bitwiseOrExpression_missing_LHS() { |
| 3047 BinaryExpression expression = ParserTestCase.parseExpression( | 2870 BinaryExpression expression = |
| 3048 "| y", [ParserErrorCode.MISSING_IDENTIFIER]); | 2871 parseExpression("| y", [ParserErrorCode.MISSING_IDENTIFIER]); |
| 3049 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 2872 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
| 3050 SimpleIdentifier, expression.leftOperand); | 2873 SimpleIdentifier, expression.leftOperand); |
| 3051 expect(expression.leftOperand.isSynthetic, isTrue); | 2874 expect(expression.leftOperand.isSynthetic, isTrue); |
| 3052 } | 2875 } |
| 3053 | 2876 |
| 3054 void test_bitwiseOrExpression_missing_LHS_RHS() { | 2877 void test_bitwiseOrExpression_missing_LHS_RHS() { |
| 3055 BinaryExpression expression = ParserTestCase.parseExpression("|", [ | 2878 BinaryExpression expression = parseExpression("|", [ |
| 3056 ParserErrorCode.MISSING_IDENTIFIER, | 2879 ParserErrorCode.MISSING_IDENTIFIER, |
| 3057 ParserErrorCode.MISSING_IDENTIFIER | 2880 ParserErrorCode.MISSING_IDENTIFIER |
| 3058 ]); | 2881 ]); |
| 3059 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 2882 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
| 3060 SimpleIdentifier, expression.leftOperand); | 2883 SimpleIdentifier, expression.leftOperand); |
| 3061 expect(expression.leftOperand.isSynthetic, isTrue); | 2884 expect(expression.leftOperand.isSynthetic, isTrue); |
| 3062 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 2885 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
| 3063 SimpleIdentifier, expression.rightOperand); | 2886 SimpleIdentifier, expression.rightOperand); |
| 3064 expect(expression.rightOperand.isSynthetic, isTrue); | 2887 expect(expression.rightOperand.isSynthetic, isTrue); |
| 3065 } | 2888 } |
| 3066 | 2889 |
| 3067 void test_bitwiseOrExpression_missing_RHS() { | 2890 void test_bitwiseOrExpression_missing_RHS() { |
| 3068 BinaryExpression expression = ParserTestCase.parseExpression( | 2891 BinaryExpression expression = |
| 3069 "x |", [ParserErrorCode.MISSING_IDENTIFIER]); | 2892 parseExpression("x |", [ParserErrorCode.MISSING_IDENTIFIER]); |
| 3070 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 2893 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
| 3071 SimpleIdentifier, expression.rightOperand); | 2894 SimpleIdentifier, expression.rightOperand); |
| 3072 expect(expression.rightOperand.isSynthetic, isTrue); | 2895 expect(expression.rightOperand.isSynthetic, isTrue); |
| 3073 } | 2896 } |
| 3074 | 2897 |
| 3075 void test_bitwiseOrExpression_missing_RHS_super() { | 2898 void test_bitwiseOrExpression_missing_RHS_super() { |
| 3076 BinaryExpression expression = ParserTestCase.parseExpression( | 2899 BinaryExpression expression = |
| 3077 "super |", [ParserErrorCode.MISSING_IDENTIFIER]); | 2900 parseExpression("super |", [ParserErrorCode.MISSING_IDENTIFIER]); |
| 3078 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 2901 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
| 3079 SimpleIdentifier, expression.rightOperand); | 2902 SimpleIdentifier, expression.rightOperand); |
| 3080 expect(expression.rightOperand.isSynthetic, isTrue); | 2903 expect(expression.rightOperand.isSynthetic, isTrue); |
| 3081 } | 2904 } |
| 3082 | 2905 |
| 3083 void test_bitwiseOrExpression_precedence_xor_left() { | 2906 void test_bitwiseOrExpression_precedence_xor_left() { |
| 3084 BinaryExpression expression = ParserTestCase.parseExpression("^ |", [ | 2907 BinaryExpression expression = parseExpression("^ |", [ |
| 3085 ParserErrorCode.MISSING_IDENTIFIER, | 2908 ParserErrorCode.MISSING_IDENTIFIER, |
| 3086 ParserErrorCode.MISSING_IDENTIFIER, | 2909 ParserErrorCode.MISSING_IDENTIFIER, |
| 3087 ParserErrorCode.MISSING_IDENTIFIER | 2910 ParserErrorCode.MISSING_IDENTIFIER |
| 3088 ]); | 2911 ]); |
| 3089 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | 2912 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, |
| 3090 BinaryExpression, expression.leftOperand); | 2913 BinaryExpression, expression.leftOperand); |
| 3091 } | 2914 } |
| 3092 | 2915 |
| 3093 void test_bitwiseOrExpression_precedence_xor_right() { | 2916 void test_bitwiseOrExpression_precedence_xor_right() { |
| 3094 BinaryExpression expression = ParserTestCase.parseExpression("| ^", [ | 2917 BinaryExpression expression = parseExpression("| ^", [ |
| 3095 ParserErrorCode.MISSING_IDENTIFIER, | 2918 ParserErrorCode.MISSING_IDENTIFIER, |
| 3096 ParserErrorCode.MISSING_IDENTIFIER, | 2919 ParserErrorCode.MISSING_IDENTIFIER, |
| 3097 ParserErrorCode.MISSING_IDENTIFIER | 2920 ParserErrorCode.MISSING_IDENTIFIER |
| 3098 ]); | 2921 ]); |
| 3099 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | 2922 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, |
| 3100 BinaryExpression, expression.rightOperand); | 2923 BinaryExpression, expression.rightOperand); |
| 3101 } | 2924 } |
| 3102 | 2925 |
| 3103 void test_bitwiseOrExpression_super() { | 2926 void test_bitwiseOrExpression_super() { |
| 3104 BinaryExpression expression = ParserTestCase.parseExpression("super | |", [ | 2927 BinaryExpression expression = parseExpression("super | |", [ |
| 3105 ParserErrorCode.MISSING_IDENTIFIER, | 2928 ParserErrorCode.MISSING_IDENTIFIER, |
| 3106 ParserErrorCode.MISSING_IDENTIFIER | 2929 ParserErrorCode.MISSING_IDENTIFIER |
| 3107 ]); | 2930 ]); |
| 3108 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | 2931 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, |
| 3109 BinaryExpression, expression.leftOperand); | 2932 BinaryExpression, expression.leftOperand); |
| 3110 } | 2933 } |
| 3111 | 2934 |
| 3112 void test_bitwiseXorExpression_missing_LHS() { | 2935 void test_bitwiseXorExpression_missing_LHS() { |
| 3113 BinaryExpression expression = ParserTestCase.parseExpression( | 2936 BinaryExpression expression = |
| 3114 "^ y", [ParserErrorCode.MISSING_IDENTIFIER]); | 2937 parseExpression("^ y", [ParserErrorCode.MISSING_IDENTIFIER]); |
| 3115 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 2938 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
| 3116 SimpleIdentifier, expression.leftOperand); | 2939 SimpleIdentifier, expression.leftOperand); |
| 3117 expect(expression.leftOperand.isSynthetic, isTrue); | 2940 expect(expression.leftOperand.isSynthetic, isTrue); |
| 3118 } | 2941 } |
| 3119 | 2942 |
| 3120 void test_bitwiseXorExpression_missing_LHS_RHS() { | 2943 void test_bitwiseXorExpression_missing_LHS_RHS() { |
| 3121 BinaryExpression expression = ParserTestCase.parseExpression("^", [ | 2944 BinaryExpression expression = parseExpression("^", [ |
| 3122 ParserErrorCode.MISSING_IDENTIFIER, | 2945 ParserErrorCode.MISSING_IDENTIFIER, |
| 3123 ParserErrorCode.MISSING_IDENTIFIER | 2946 ParserErrorCode.MISSING_IDENTIFIER |
| 3124 ]); | 2947 ]); |
| 3125 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 2948 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
| 3126 SimpleIdentifier, expression.leftOperand); | 2949 SimpleIdentifier, expression.leftOperand); |
| 3127 expect(expression.leftOperand.isSynthetic, isTrue); | 2950 expect(expression.leftOperand.isSynthetic, isTrue); |
| 3128 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 2951 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
| 3129 SimpleIdentifier, expression.rightOperand); | 2952 SimpleIdentifier, expression.rightOperand); |
| 3130 expect(expression.rightOperand.isSynthetic, isTrue); | 2953 expect(expression.rightOperand.isSynthetic, isTrue); |
| 3131 } | 2954 } |
| 3132 | 2955 |
| 3133 void test_bitwiseXorExpression_missing_RHS() { | 2956 void test_bitwiseXorExpression_missing_RHS() { |
| 3134 BinaryExpression expression = ParserTestCase.parseExpression( | 2957 BinaryExpression expression = |
| 3135 "x ^", [ParserErrorCode.MISSING_IDENTIFIER]); | 2958 parseExpression("x ^", [ParserErrorCode.MISSING_IDENTIFIER]); |
| 3136 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 2959 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
| 3137 SimpleIdentifier, expression.rightOperand); | 2960 SimpleIdentifier, expression.rightOperand); |
| 3138 expect(expression.rightOperand.isSynthetic, isTrue); | 2961 expect(expression.rightOperand.isSynthetic, isTrue); |
| 3139 } | 2962 } |
| 3140 | 2963 |
| 3141 void test_bitwiseXorExpression_missing_RHS_super() { | 2964 void test_bitwiseXorExpression_missing_RHS_super() { |
| 3142 BinaryExpression expression = ParserTestCase.parseExpression( | 2965 BinaryExpression expression = |
| 3143 "super ^", [ParserErrorCode.MISSING_IDENTIFIER]); | 2966 parseExpression("super ^", [ParserErrorCode.MISSING_IDENTIFIER]); |
| 3144 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 2967 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
| 3145 SimpleIdentifier, expression.rightOperand); | 2968 SimpleIdentifier, expression.rightOperand); |
| 3146 expect(expression.rightOperand.isSynthetic, isTrue); | 2969 expect(expression.rightOperand.isSynthetic, isTrue); |
| 3147 } | 2970 } |
| 3148 | 2971 |
| 3149 void test_bitwiseXorExpression_precedence_and_left() { | 2972 void test_bitwiseXorExpression_precedence_and_left() { |
| 3150 BinaryExpression expression = ParserTestCase.parseExpression("& ^", [ | 2973 BinaryExpression expression = parseExpression("& ^", [ |
| 3151 ParserErrorCode.MISSING_IDENTIFIER, | 2974 ParserErrorCode.MISSING_IDENTIFIER, |
| 3152 ParserErrorCode.MISSING_IDENTIFIER, | 2975 ParserErrorCode.MISSING_IDENTIFIER, |
| 3153 ParserErrorCode.MISSING_IDENTIFIER | 2976 ParserErrorCode.MISSING_IDENTIFIER |
| 3154 ]); | 2977 ]); |
| 3155 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | 2978 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, |
| 3156 BinaryExpression, expression.leftOperand); | 2979 BinaryExpression, expression.leftOperand); |
| 3157 } | 2980 } |
| 3158 | 2981 |
| 3159 void test_bitwiseXorExpression_precedence_and_right() { | 2982 void test_bitwiseXorExpression_precedence_and_right() { |
| 3160 BinaryExpression expression = ParserTestCase.parseExpression("^ &", [ | 2983 BinaryExpression expression = parseExpression("^ &", [ |
| 3161 ParserErrorCode.MISSING_IDENTIFIER, | 2984 ParserErrorCode.MISSING_IDENTIFIER, |
| 3162 ParserErrorCode.MISSING_IDENTIFIER, | 2985 ParserErrorCode.MISSING_IDENTIFIER, |
| 3163 ParserErrorCode.MISSING_IDENTIFIER | 2986 ParserErrorCode.MISSING_IDENTIFIER |
| 3164 ]); | 2987 ]); |
| 3165 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | 2988 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, |
| 3166 BinaryExpression, expression.rightOperand); | 2989 BinaryExpression, expression.rightOperand); |
| 3167 } | 2990 } |
| 3168 | 2991 |
| 3169 void test_bitwiseXorExpression_super() { | 2992 void test_bitwiseXorExpression_super() { |
| 3170 BinaryExpression expression = ParserTestCase.parseExpression("super ^ ^", [ | 2993 BinaryExpression expression = parseExpression("super ^ ^", [ |
| 3171 ParserErrorCode.MISSING_IDENTIFIER, | 2994 ParserErrorCode.MISSING_IDENTIFIER, |
| 3172 ParserErrorCode.MISSING_IDENTIFIER | 2995 ParserErrorCode.MISSING_IDENTIFIER |
| 3173 ]); | 2996 ]); |
| 3174 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | 2997 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, |
| 3175 BinaryExpression, expression.leftOperand); | 2998 BinaryExpression, expression.leftOperand); |
| 3176 } | 2999 } |
| 3177 | 3000 |
| 3178 void test_classTypeAlias_withBody() { | 3001 void test_classTypeAlias_withBody() { |
| 3179 ParserTestCase.parseCompilationUnit(r''' | 3002 ParserTestCase.parseCompilationUnit(r''' |
| 3180 class A {} | 3003 class A {} |
| 3181 class B = Object with A {}''', [ParserErrorCode.EXPECTED_TOKEN]); | 3004 class B = Object with A {}''', [ParserErrorCode.EXPECTED_TOKEN]); |
| 3182 } | 3005 } |
| 3183 | 3006 |
| 3184 void test_conditionalExpression_missingElse() { | 3007 void test_conditionalExpression_missingElse() { |
| 3185 ConditionalExpression expression = ParserTestCase.parse4( | 3008 ConditionalExpression expression = parse4("parseConditionalExpression", |
| 3186 "parseConditionalExpression", "x ? y :", [ | 3009 "x ? y :", [ParserErrorCode.MISSING_IDENTIFIER]); |
| 3187 ParserErrorCode.MISSING_IDENTIFIER | |
| 3188 ]); | |
| 3189 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 3010 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
| 3190 SimpleIdentifier, expression.elseExpression); | 3011 SimpleIdentifier, expression.elseExpression); |
| 3191 expect(expression.elseExpression.isSynthetic, isTrue); | 3012 expect(expression.elseExpression.isSynthetic, isTrue); |
| 3192 } | 3013 } |
| 3193 | 3014 |
| 3194 void test_conditionalExpression_missingThen() { | 3015 void test_conditionalExpression_missingThen() { |
| 3195 ConditionalExpression expression = ParserTestCase.parse4( | 3016 ConditionalExpression expression = parse4("parseConditionalExpression", |
| 3196 "parseConditionalExpression", "x ? : z", [ | 3017 "x ? : z", [ParserErrorCode.MISSING_IDENTIFIER]); |
| 3197 ParserErrorCode.MISSING_IDENTIFIER | |
| 3198 ]); | |
| 3199 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 3018 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
| 3200 SimpleIdentifier, expression.thenExpression); | 3019 SimpleIdentifier, expression.thenExpression); |
| 3201 expect(expression.thenExpression.isSynthetic, isTrue); | 3020 expect(expression.thenExpression.isSynthetic, isTrue); |
| 3202 } | 3021 } |
| 3203 | 3022 |
| 3204 void test_equalityExpression_missing_LHS() { | 3023 void test_equalityExpression_missing_LHS() { |
| 3205 BinaryExpression expression = ParserTestCase.parseExpression( | 3024 BinaryExpression expression = |
| 3206 "== y", [ParserErrorCode.MISSING_IDENTIFIER]); | 3025 parseExpression("== y", [ParserErrorCode.MISSING_IDENTIFIER]); |
| 3207 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 3026 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
| 3208 SimpleIdentifier, expression.leftOperand); | 3027 SimpleIdentifier, expression.leftOperand); |
| 3209 expect(expression.leftOperand.isSynthetic, isTrue); | 3028 expect(expression.leftOperand.isSynthetic, isTrue); |
| 3210 } | 3029 } |
| 3211 | 3030 |
| 3212 void test_equalityExpression_missing_LHS_RHS() { | 3031 void test_equalityExpression_missing_LHS_RHS() { |
| 3213 BinaryExpression expression = ParserTestCase.parseExpression("==", [ | 3032 BinaryExpression expression = parseExpression("==", [ |
| 3214 ParserErrorCode.MISSING_IDENTIFIER, | 3033 ParserErrorCode.MISSING_IDENTIFIER, |
| 3215 ParserErrorCode.MISSING_IDENTIFIER | 3034 ParserErrorCode.MISSING_IDENTIFIER |
| 3216 ]); | 3035 ]); |
| 3217 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 3036 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
| 3218 SimpleIdentifier, expression.leftOperand); | 3037 SimpleIdentifier, expression.leftOperand); |
| 3219 expect(expression.leftOperand.isSynthetic, isTrue); | 3038 expect(expression.leftOperand.isSynthetic, isTrue); |
| 3220 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 3039 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
| 3221 SimpleIdentifier, expression.rightOperand); | 3040 SimpleIdentifier, expression.rightOperand); |
| 3222 expect(expression.rightOperand.isSynthetic, isTrue); | 3041 expect(expression.rightOperand.isSynthetic, isTrue); |
| 3223 } | 3042 } |
| 3224 | 3043 |
| 3225 void test_equalityExpression_missing_RHS() { | 3044 void test_equalityExpression_missing_RHS() { |
| 3226 BinaryExpression expression = ParserTestCase.parseExpression( | 3045 BinaryExpression expression = |
| 3227 "x ==", [ParserErrorCode.MISSING_IDENTIFIER]); | 3046 parseExpression("x ==", [ParserErrorCode.MISSING_IDENTIFIER]); |
| 3228 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 3047 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
| 3229 SimpleIdentifier, expression.rightOperand); | 3048 SimpleIdentifier, expression.rightOperand); |
| 3230 expect(expression.rightOperand.isSynthetic, isTrue); | 3049 expect(expression.rightOperand.isSynthetic, isTrue); |
| 3231 } | 3050 } |
| 3232 | 3051 |
| 3233 void test_equalityExpression_missing_RHS_super() { | 3052 void test_equalityExpression_missing_RHS_super() { |
| 3234 BinaryExpression expression = ParserTestCase.parseExpression( | 3053 BinaryExpression expression = |
| 3235 "super ==", [ParserErrorCode.MISSING_IDENTIFIER]); | 3054 parseExpression("super ==", [ParserErrorCode.MISSING_IDENTIFIER]); |
| 3236 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 3055 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
| 3237 SimpleIdentifier, expression.rightOperand); | 3056 SimpleIdentifier, expression.rightOperand); |
| 3238 expect(expression.rightOperand.isSynthetic, isTrue); | 3057 expect(expression.rightOperand.isSynthetic, isTrue); |
| 3239 } | 3058 } |
| 3240 | 3059 |
| 3241 void test_equalityExpression_precedence_relational_left() { | 3060 void test_equalityExpression_precedence_relational_left() { |
| 3242 BinaryExpression expression = ParserTestCase.parseExpression("is ==", [ | 3061 BinaryExpression expression = parseExpression("is ==", [ |
| 3243 ParserErrorCode.EXPECTED_TYPE_NAME, | 3062 ParserErrorCode.EXPECTED_TYPE_NAME, |
| 3244 ParserErrorCode.MISSING_IDENTIFIER, | 3063 ParserErrorCode.MISSING_IDENTIFIER, |
| 3245 ParserErrorCode.MISSING_IDENTIFIER | 3064 ParserErrorCode.MISSING_IDENTIFIER |
| 3246 ]); | 3065 ]); |
| 3247 EngineTestCase.assertInstanceOf( | 3066 EngineTestCase.assertInstanceOf( |
| 3248 (obj) => obj is IsExpression, IsExpression, expression.leftOperand); | 3067 (obj) => obj is IsExpression, IsExpression, expression.leftOperand); |
| 3249 } | 3068 } |
| 3250 | 3069 |
| 3251 void test_equalityExpression_precedence_relational_right() { | 3070 void test_equalityExpression_precedence_relational_right() { |
| 3252 BinaryExpression expression = ParserTestCase.parseExpression("== is", [ | 3071 BinaryExpression expression = parseExpression("== is", [ |
| 3253 ParserErrorCode.EXPECTED_TYPE_NAME, | 3072 ParserErrorCode.EXPECTED_TYPE_NAME, |
| 3254 ParserErrorCode.MISSING_IDENTIFIER, | 3073 ParserErrorCode.MISSING_IDENTIFIER, |
| 3255 ParserErrorCode.MISSING_IDENTIFIER | 3074 ParserErrorCode.MISSING_IDENTIFIER |
| 3256 ]); | 3075 ]); |
| 3257 EngineTestCase.assertInstanceOf( | 3076 EngineTestCase.assertInstanceOf( |
| 3258 (obj) => obj is IsExpression, IsExpression, expression.rightOperand); | 3077 (obj) => obj is IsExpression, IsExpression, expression.rightOperand); |
| 3259 } | 3078 } |
| 3260 | 3079 |
| 3261 void test_equalityExpression_super() { | 3080 void test_equalityExpression_super() { |
| 3262 BinaryExpression expression = ParserTestCase.parseExpression("super == ==", | 3081 BinaryExpression expression = parseExpression("super == ==", [ |
| 3263 [ | |
| 3264 ParserErrorCode.MISSING_IDENTIFIER, | 3082 ParserErrorCode.MISSING_IDENTIFIER, |
| 3265 ParserErrorCode.MISSING_IDENTIFIER, | 3083 ParserErrorCode.MISSING_IDENTIFIER, |
| 3266 ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND | 3084 ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND |
| 3267 ]); | 3085 ]); |
| 3268 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | 3086 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, |
| 3269 BinaryExpression, expression.leftOperand); | 3087 BinaryExpression, expression.leftOperand); |
| 3270 } | 3088 } |
| 3271 | 3089 |
| 3272 void test_expressionList_multiple_end() { | 3090 void test_expressionList_multiple_end() { |
| 3273 List<Expression> result = ParserTestCase.parse4("parseExpressionList", | 3091 List<Expression> result = parse4("parseExpressionList", ", 2, 3, 4", |
| 3274 ", 2, 3, 4", [ParserErrorCode.MISSING_IDENTIFIER]); | 3092 [ParserErrorCode.MISSING_IDENTIFIER]); |
| 3275 expect(result, hasLength(4)); | 3093 expect(result, hasLength(4)); |
| 3276 Expression syntheticExpression = result[0]; | 3094 Expression syntheticExpression = result[0]; |
| 3277 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 3095 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
| 3278 SimpleIdentifier, syntheticExpression); | 3096 SimpleIdentifier, syntheticExpression); |
| 3279 expect(syntheticExpression.isSynthetic, isTrue); | 3097 expect(syntheticExpression.isSynthetic, isTrue); |
| 3280 } | 3098 } |
| 3281 | 3099 |
| 3282 void test_expressionList_multiple_middle() { | 3100 void test_expressionList_multiple_middle() { |
| 3283 List<Expression> result = ParserTestCase.parse4("parseExpressionList", | 3101 List<Expression> result = parse4("parseExpressionList", "1, 2, , 4", |
| 3284 "1, 2, , 4", [ParserErrorCode.MISSING_IDENTIFIER]); | 3102 [ParserErrorCode.MISSING_IDENTIFIER]); |
| 3285 expect(result, hasLength(4)); | 3103 expect(result, hasLength(4)); |
| 3286 Expression syntheticExpression = result[2]; | 3104 Expression syntheticExpression = result[2]; |
| 3287 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 3105 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
| 3288 SimpleIdentifier, syntheticExpression); | 3106 SimpleIdentifier, syntheticExpression); |
| 3289 expect(syntheticExpression.isSynthetic, isTrue); | 3107 expect(syntheticExpression.isSynthetic, isTrue); |
| 3290 } | 3108 } |
| 3291 | 3109 |
| 3292 void test_expressionList_multiple_start() { | 3110 void test_expressionList_multiple_start() { |
| 3293 List<Expression> result = ParserTestCase.parse4("parseExpressionList", | 3111 List<Expression> result = parse4("parseExpressionList", "1, 2, 3,", |
| 3294 "1, 2, 3,", [ParserErrorCode.MISSING_IDENTIFIER]); | 3112 [ParserErrorCode.MISSING_IDENTIFIER]); |
| 3295 expect(result, hasLength(4)); | 3113 expect(result, hasLength(4)); |
| 3296 Expression syntheticExpression = result[3]; | 3114 Expression syntheticExpression = result[3]; |
| 3297 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 3115 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
| 3298 SimpleIdentifier, syntheticExpression); | 3116 SimpleIdentifier, syntheticExpression); |
| 3299 expect(syntheticExpression.isSynthetic, isTrue); | 3117 expect(syntheticExpression.isSynthetic, isTrue); |
| 3300 } | 3118 } |
| 3301 | 3119 |
| 3302 void test_functionExpression_in_ConstructorFieldInitializer() { | 3120 void test_functionExpression_in_ConstructorFieldInitializer() { |
| 3303 CompilationUnit unit = ParserTestCase.parseCompilationUnit( | 3121 CompilationUnit unit = ParserTestCase.parseCompilationUnit( |
| 3304 "class A { A() : a = (){}; var v; }", [ | 3122 "class A { A() : a = (){}; var v; }", [ |
| 3305 ParserErrorCode.MISSING_IDENTIFIER, | 3123 ParserErrorCode.MISSING_IDENTIFIER, |
| 3306 ParserErrorCode.UNEXPECTED_TOKEN | 3124 ParserErrorCode.UNEXPECTED_TOKEN |
| 3307 ]); | 3125 ]); |
| 3308 // Make sure we recovered and parsed "var v" correctly | 3126 // Make sure we recovered and parsed "var v" correctly |
| 3309 ClassDeclaration declaration = unit.declarations[0] as ClassDeclaration; | 3127 ClassDeclaration declaration = unit.declarations[0] as ClassDeclaration; |
| 3310 NodeList<ClassMember> members = declaration.members; | 3128 NodeList<ClassMember> members = declaration.members; |
| 3311 ClassMember fieldDecl = members[1]; | 3129 ClassMember fieldDecl = members[1]; |
| 3312 EngineTestCase.assertInstanceOf( | 3130 EngineTestCase.assertInstanceOf( |
| 3313 (obj) => obj is FieldDeclaration, FieldDeclaration, fieldDecl); | 3131 (obj) => obj is FieldDeclaration, FieldDeclaration, fieldDecl); |
| 3314 NodeList<VariableDeclaration> vars = | 3132 NodeList<VariableDeclaration> vars = |
| 3315 (fieldDecl as FieldDeclaration).fields.variables; | 3133 (fieldDecl as FieldDeclaration).fields.variables; |
| 3316 expect(vars, hasLength(1)); | 3134 expect(vars, hasLength(1)); |
| 3317 expect(vars[0].name.name, "v"); | 3135 expect(vars[0].name.name, "v"); |
| 3318 } | 3136 } |
| 3319 | 3137 |
| 3320 void test_functionExpression_named() { | 3138 void test_functionExpression_named() { |
| 3321 ParserTestCase.parseExpression( | 3139 parseExpression("m(f() => 0);", [ParserErrorCode.EXPECTED_TOKEN]); |
| 3322 "m(f() => 0);", [ParserErrorCode.EXPECTED_TOKEN]); | |
| 3323 } | 3140 } |
| 3324 | 3141 |
| 3325 void test_incomplete_conditionalExpression() { | 3142 void test_incomplete_conditionalExpression() { |
| 3326 ParserTestCase.parseExpression("x ? 0", [ | 3143 parseExpression("x ? 0", [ |
| 3327 ParserErrorCode.EXPECTED_TOKEN, | 3144 ParserErrorCode.EXPECTED_TOKEN, |
| 3328 ParserErrorCode.MISSING_IDENTIFIER | 3145 ParserErrorCode.MISSING_IDENTIFIER |
| 3329 ]); | 3146 ]); |
| 3330 } | 3147 } |
| 3331 | 3148 |
| 3332 void test_incomplete_constructorInitializers_empty() { | 3149 void test_incomplete_constructorInitializers_empty() { |
| 3333 ParserTestCase.parse3("parseClassMember", ["C"], "C() : {}", [ | 3150 parse3("parseClassMember", ["C"], "C() : {}", |
| 3334 ParserErrorCode.MISSING_INITIALIZER | 3151 [ParserErrorCode.MISSING_INITIALIZER]); |
| 3335 ]); | |
| 3336 } | 3152 } |
| 3337 | 3153 |
| 3338 void test_incomplete_constructorInitializers_missingEquals() { | 3154 void test_incomplete_constructorInitializers_missingEquals() { |
| 3339 ClassMember member = ParserTestCase.parse3("parseClassMember", [ | 3155 ClassMember member = parse3("parseClassMember", ["C"], "C() : x(3) {}", |
| 3340 "C" | 3156 [ParserErrorCode.MISSING_ASSIGNMENT_IN_INITIALIZER]); |
| 3341 ], "C() : x(3) {}", [ParserErrorCode.MISSING_ASSIGNMENT_IN_INITIALIZER]); | |
| 3342 expect(member, new isInstanceOf<ConstructorDeclaration>()); | 3157 expect(member, new isInstanceOf<ConstructorDeclaration>()); |
| 3343 NodeList<ConstructorInitializer> initializers = | 3158 NodeList<ConstructorInitializer> initializers = |
| 3344 (member as ConstructorDeclaration).initializers; | 3159 (member as ConstructorDeclaration).initializers; |
| 3345 expect(initializers, hasLength(1)); | 3160 expect(initializers, hasLength(1)); |
| 3346 ConstructorInitializer initializer = initializers[0]; | 3161 ConstructorInitializer initializer = initializers[0]; |
| 3347 expect(initializer, new isInstanceOf<ConstructorFieldInitializer>()); | 3162 expect(initializer, new isInstanceOf<ConstructorFieldInitializer>()); |
| 3348 Expression expression = | 3163 Expression expression = |
| 3349 (initializer as ConstructorFieldInitializer).expression; | 3164 (initializer as ConstructorFieldInitializer).expression; |
| 3350 expect(expression, isNotNull); | 3165 expect(expression, isNotNull); |
| 3351 expect(expression, new isInstanceOf<ParenthesizedExpression>()); | 3166 expect(expression, new isInstanceOf<ParenthesizedExpression>()); |
| 3352 } | 3167 } |
| 3353 | 3168 |
| 3354 void test_incomplete_constructorInitializers_variable() { | 3169 void test_incomplete_constructorInitializers_variable() { |
| 3355 ParserTestCase.parse3("parseClassMember", ["C"], "C() : x {}", [ | 3170 parse3("parseClassMember", ["C"], "C() : x {}", |
| 3356 ParserErrorCode.MISSING_ASSIGNMENT_IN_INITIALIZER | 3171 [ParserErrorCode.MISSING_ASSIGNMENT_IN_INITIALIZER]); |
| 3357 ]); | |
| 3358 } | 3172 } |
| 3359 | 3173 |
| 3360 void test_incomplete_topLevelFunction() { | 3174 void test_incomplete_topLevelFunction() { |
| 3361 ParserTestCase.parseCompilationUnit( | 3175 ParserTestCase.parseCompilationUnit( |
| 3362 "foo();", [ParserErrorCode.MISSING_FUNCTION_BODY]); | 3176 "foo();", [ParserErrorCode.MISSING_FUNCTION_BODY]); |
| 3363 } | 3177 } |
| 3364 | 3178 |
| 3365 void test_incomplete_topLevelVariable() { | 3179 void test_incomplete_topLevelVariable() { |
| 3366 CompilationUnit unit = ParserTestCase.parseCompilationUnit( | 3180 CompilationUnit unit = ParserTestCase.parseCompilationUnit( |
| 3367 "String", [ParserErrorCode.EXPECTED_EXECUTABLE]); | 3181 "String", [ParserErrorCode.EXPECTED_EXECUTABLE]); |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3529 | 3343 |
| 3530 void test_keywordInPlaceOfIdentifier() { | 3344 void test_keywordInPlaceOfIdentifier() { |
| 3531 // TODO(brianwilkerson) We could do better with this. | 3345 // TODO(brianwilkerson) We could do better with this. |
| 3532 ParserTestCase.parseCompilationUnit("do() {}", [ | 3346 ParserTestCase.parseCompilationUnit("do() {}", [ |
| 3533 ParserErrorCode.EXPECTED_EXECUTABLE, | 3347 ParserErrorCode.EXPECTED_EXECUTABLE, |
| 3534 ParserErrorCode.UNEXPECTED_TOKEN | 3348 ParserErrorCode.UNEXPECTED_TOKEN |
| 3535 ]); | 3349 ]); |
| 3536 } | 3350 } |
| 3537 | 3351 |
| 3538 void test_logicalAndExpression_missing_LHS() { | 3352 void test_logicalAndExpression_missing_LHS() { |
| 3539 BinaryExpression expression = ParserTestCase.parseExpression( | 3353 BinaryExpression expression = |
| 3540 "&& y", [ParserErrorCode.MISSING_IDENTIFIER]); | 3354 parseExpression("&& y", [ParserErrorCode.MISSING_IDENTIFIER]); |
| 3541 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 3355 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
| 3542 SimpleIdentifier, expression.leftOperand); | 3356 SimpleIdentifier, expression.leftOperand); |
| 3543 expect(expression.leftOperand.isSynthetic, isTrue); | 3357 expect(expression.leftOperand.isSynthetic, isTrue); |
| 3544 } | 3358 } |
| 3545 | 3359 |
| 3546 void test_logicalAndExpression_missing_LHS_RHS() { | 3360 void test_logicalAndExpression_missing_LHS_RHS() { |
| 3547 BinaryExpression expression = ParserTestCase.parseExpression("&&", [ | 3361 BinaryExpression expression = parseExpression("&&", [ |
| 3548 ParserErrorCode.MISSING_IDENTIFIER, | 3362 ParserErrorCode.MISSING_IDENTIFIER, |
| 3549 ParserErrorCode.MISSING_IDENTIFIER | 3363 ParserErrorCode.MISSING_IDENTIFIER |
| 3550 ]); | 3364 ]); |
| 3551 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 3365 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
| 3552 SimpleIdentifier, expression.leftOperand); | 3366 SimpleIdentifier, expression.leftOperand); |
| 3553 expect(expression.leftOperand.isSynthetic, isTrue); | 3367 expect(expression.leftOperand.isSynthetic, isTrue); |
| 3554 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 3368 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
| 3555 SimpleIdentifier, expression.rightOperand); | 3369 SimpleIdentifier, expression.rightOperand); |
| 3556 expect(expression.rightOperand.isSynthetic, isTrue); | 3370 expect(expression.rightOperand.isSynthetic, isTrue); |
| 3557 } | 3371 } |
| 3558 | 3372 |
| 3559 void test_logicalAndExpression_missing_RHS() { | 3373 void test_logicalAndExpression_missing_RHS() { |
| 3560 BinaryExpression expression = ParserTestCase.parseExpression( | 3374 BinaryExpression expression = |
| 3561 "x &&", [ParserErrorCode.MISSING_IDENTIFIER]); | 3375 parseExpression("x &&", [ParserErrorCode.MISSING_IDENTIFIER]); |
| 3562 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 3376 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
| 3563 SimpleIdentifier, expression.rightOperand); | 3377 SimpleIdentifier, expression.rightOperand); |
| 3564 expect(expression.rightOperand.isSynthetic, isTrue); | 3378 expect(expression.rightOperand.isSynthetic, isTrue); |
| 3565 } | 3379 } |
| 3566 | 3380 |
| 3567 void test_logicalAndExpression_precedence_bitwiseOr_left() { | 3381 void test_logicalAndExpression_precedence_bitwiseOr_left() { |
| 3568 BinaryExpression expression = ParserTestCase.parseExpression("| &&", [ | 3382 BinaryExpression expression = parseExpression("| &&", [ |
| 3569 ParserErrorCode.MISSING_IDENTIFIER, | 3383 ParserErrorCode.MISSING_IDENTIFIER, |
| 3570 ParserErrorCode.MISSING_IDENTIFIER, | 3384 ParserErrorCode.MISSING_IDENTIFIER, |
| 3571 ParserErrorCode.MISSING_IDENTIFIER | 3385 ParserErrorCode.MISSING_IDENTIFIER |
| 3572 ]); | 3386 ]); |
| 3573 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | 3387 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, |
| 3574 BinaryExpression, expression.leftOperand); | 3388 BinaryExpression, expression.leftOperand); |
| 3575 } | 3389 } |
| 3576 | 3390 |
| 3577 void test_logicalAndExpression_precedence_bitwiseOr_right() { | 3391 void test_logicalAndExpression_precedence_bitwiseOr_right() { |
| 3578 BinaryExpression expression = ParserTestCase.parseExpression("&& |", [ | 3392 BinaryExpression expression = parseExpression("&& |", [ |
| 3579 ParserErrorCode.MISSING_IDENTIFIER, | 3393 ParserErrorCode.MISSING_IDENTIFIER, |
| 3580 ParserErrorCode.MISSING_IDENTIFIER, | 3394 ParserErrorCode.MISSING_IDENTIFIER, |
| 3581 ParserErrorCode.MISSING_IDENTIFIER | 3395 ParserErrorCode.MISSING_IDENTIFIER |
| 3582 ]); | 3396 ]); |
| 3583 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | 3397 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, |
| 3584 BinaryExpression, expression.rightOperand); | 3398 BinaryExpression, expression.rightOperand); |
| 3585 } | 3399 } |
| 3586 | 3400 |
| 3587 void test_logicalOrExpression_missing_LHS() { | 3401 void test_logicalOrExpression_missing_LHS() { |
| 3588 BinaryExpression expression = ParserTestCase.parseExpression( | 3402 BinaryExpression expression = |
| 3589 "|| y", [ParserErrorCode.MISSING_IDENTIFIER]); | 3403 parseExpression("|| y", [ParserErrorCode.MISSING_IDENTIFIER]); |
| 3590 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 3404 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
| 3591 SimpleIdentifier, expression.leftOperand); | 3405 SimpleIdentifier, expression.leftOperand); |
| 3592 expect(expression.leftOperand.isSynthetic, isTrue); | 3406 expect(expression.leftOperand.isSynthetic, isTrue); |
| 3593 } | 3407 } |
| 3594 | 3408 |
| 3595 void test_logicalOrExpression_missing_LHS_RHS() { | 3409 void test_logicalOrExpression_missing_LHS_RHS() { |
| 3596 BinaryExpression expression = ParserTestCase.parseExpression("||", [ | 3410 BinaryExpression expression = parseExpression("||", [ |
| 3597 ParserErrorCode.MISSING_IDENTIFIER, | 3411 ParserErrorCode.MISSING_IDENTIFIER, |
| 3598 ParserErrorCode.MISSING_IDENTIFIER | 3412 ParserErrorCode.MISSING_IDENTIFIER |
| 3599 ]); | 3413 ]); |
| 3600 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 3414 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
| 3601 SimpleIdentifier, expression.leftOperand); | 3415 SimpleIdentifier, expression.leftOperand); |
| 3602 expect(expression.leftOperand.isSynthetic, isTrue); | 3416 expect(expression.leftOperand.isSynthetic, isTrue); |
| 3603 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 3417 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
| 3604 SimpleIdentifier, expression.rightOperand); | 3418 SimpleIdentifier, expression.rightOperand); |
| 3605 expect(expression.rightOperand.isSynthetic, isTrue); | 3419 expect(expression.rightOperand.isSynthetic, isTrue); |
| 3606 } | 3420 } |
| 3607 | 3421 |
| 3608 void test_logicalOrExpression_missing_RHS() { | 3422 void test_logicalOrExpression_missing_RHS() { |
| 3609 BinaryExpression expression = ParserTestCase.parseExpression( | 3423 BinaryExpression expression = |
| 3610 "x ||", [ParserErrorCode.MISSING_IDENTIFIER]); | 3424 parseExpression("x ||", [ParserErrorCode.MISSING_IDENTIFIER]); |
| 3611 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 3425 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
| 3612 SimpleIdentifier, expression.rightOperand); | 3426 SimpleIdentifier, expression.rightOperand); |
| 3613 expect(expression.rightOperand.isSynthetic, isTrue); | 3427 expect(expression.rightOperand.isSynthetic, isTrue); |
| 3614 } | 3428 } |
| 3615 | 3429 |
| 3616 void test_logicalOrExpression_precedence_logicalAnd_left() { | 3430 void test_logicalOrExpression_precedence_logicalAnd_left() { |
| 3617 BinaryExpression expression = ParserTestCase.parseExpression("&& ||", [ | 3431 BinaryExpression expression = parseExpression("&& ||", [ |
| 3618 ParserErrorCode.MISSING_IDENTIFIER, | 3432 ParserErrorCode.MISSING_IDENTIFIER, |
| 3619 ParserErrorCode.MISSING_IDENTIFIER, | 3433 ParserErrorCode.MISSING_IDENTIFIER, |
| 3620 ParserErrorCode.MISSING_IDENTIFIER | 3434 ParserErrorCode.MISSING_IDENTIFIER |
| 3621 ]); | 3435 ]); |
| 3622 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | 3436 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, |
| 3623 BinaryExpression, expression.leftOperand); | 3437 BinaryExpression, expression.leftOperand); |
| 3624 } | 3438 } |
| 3625 | 3439 |
| 3626 void test_logicalOrExpression_precedence_logicalAnd_right() { | 3440 void test_logicalOrExpression_precedence_logicalAnd_right() { |
| 3627 BinaryExpression expression = ParserTestCase.parseExpression("|| &&", [ | 3441 BinaryExpression expression = parseExpression("|| &&", [ |
| 3628 ParserErrorCode.MISSING_IDENTIFIER, | 3442 ParserErrorCode.MISSING_IDENTIFIER, |
| 3629 ParserErrorCode.MISSING_IDENTIFIER, | 3443 ParserErrorCode.MISSING_IDENTIFIER, |
| 3630 ParserErrorCode.MISSING_IDENTIFIER | 3444 ParserErrorCode.MISSING_IDENTIFIER |
| 3631 ]); | 3445 ]); |
| 3632 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | 3446 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, |
| 3633 BinaryExpression, expression.rightOperand); | 3447 BinaryExpression, expression.rightOperand); |
| 3634 } | 3448 } |
| 3635 | 3449 |
| 3636 void test_missing_commaInArgumentList() { | 3450 void test_missing_commaInArgumentList() { |
| 3637 ParserTestCase.parseExpression( | 3451 parseExpression("f(x: 1 y: 2)", [ParserErrorCode.EXPECTED_TOKEN]); |
| 3638 "f(x: 1 y: 2)", [ParserErrorCode.EXPECTED_TOKEN]); | |
| 3639 } | 3452 } |
| 3640 | 3453 |
| 3641 void test_missingGet() { | 3454 void test_missingGet() { |
| 3642 CompilationUnit unit = ParserTestCase.parseCompilationUnit(r''' | 3455 CompilationUnit unit = ParserTestCase.parseCompilationUnit(r''' |
| 3643 class C { | 3456 class C { |
| 3644 int length {} | 3457 int length {} |
| 3645 void foo() {} | 3458 void foo() {} |
| 3646 }''', [ParserErrorCode.MISSING_GET]); | 3459 }''', [ParserErrorCode.MISSING_GET]); |
| 3647 expect(unit, isNotNull); | 3460 expect(unit, isNotNull); |
| 3648 ClassDeclaration classDeclaration = | 3461 ClassDeclaration classDeclaration = |
| 3649 unit.declarations[0] as ClassDeclaration; | 3462 unit.declarations[0] as ClassDeclaration; |
| 3650 NodeList<ClassMember> members = classDeclaration.members; | 3463 NodeList<ClassMember> members = classDeclaration.members; |
| 3651 expect(members, hasLength(2)); | 3464 expect(members, hasLength(2)); |
| 3652 EngineTestCase.assertInstanceOf( | 3465 EngineTestCase.assertInstanceOf( |
| 3653 (obj) => obj is MethodDeclaration, MethodDeclaration, members[0]); | 3466 (obj) => obj is MethodDeclaration, MethodDeclaration, members[0]); |
| 3654 ClassMember member = members[1]; | 3467 ClassMember member = members[1]; |
| 3655 EngineTestCase.assertInstanceOf( | 3468 EngineTestCase.assertInstanceOf( |
| 3656 (obj) => obj is MethodDeclaration, MethodDeclaration, member); | 3469 (obj) => obj is MethodDeclaration, MethodDeclaration, member); |
| 3657 expect((member as MethodDeclaration).name.name, "foo"); | 3470 expect((member as MethodDeclaration).name.name, "foo"); |
| 3658 } | 3471 } |
| 3659 | 3472 |
| 3660 void test_missingIdentifier_afterAnnotation() { | 3473 void test_missingIdentifier_afterAnnotation() { |
| 3661 MethodDeclaration method = ParserTestCase.parse3("parseClassMember", | 3474 MethodDeclaration method = parse3("parseClassMember", <Object>["C"], |
| 3662 <Object>["C"], "@override }", [ParserErrorCode.EXPECTED_CLASS_MEMBER]); | 3475 "@override }", [ParserErrorCode.EXPECTED_CLASS_MEMBER]); |
| 3663 expect(method.documentationComment, isNull); | 3476 expect(method.documentationComment, isNull); |
| 3664 NodeList<Annotation> metadata = method.metadata; | 3477 NodeList<Annotation> metadata = method.metadata; |
| 3665 expect(metadata, hasLength(1)); | 3478 expect(metadata, hasLength(1)); |
| 3666 expect(metadata[0].name.name, "override"); | 3479 expect(metadata[0].name.name, "override"); |
| 3667 } | 3480 } |
| 3668 | 3481 |
| 3669 void test_multiplicativeExpression_missing_LHS() { | 3482 void test_multiplicativeExpression_missing_LHS() { |
| 3670 BinaryExpression expression = ParserTestCase.parseExpression( | 3483 BinaryExpression expression = |
| 3671 "* y", [ParserErrorCode.MISSING_IDENTIFIER]); | 3484 parseExpression("* y", [ParserErrorCode.MISSING_IDENTIFIER]); |
| 3672 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 3485 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
| 3673 SimpleIdentifier, expression.leftOperand); | 3486 SimpleIdentifier, expression.leftOperand); |
| 3674 expect(expression.leftOperand.isSynthetic, isTrue); | 3487 expect(expression.leftOperand.isSynthetic, isTrue); |
| 3675 } | 3488 } |
| 3676 | 3489 |
| 3677 void test_multiplicativeExpression_missing_LHS_RHS() { | 3490 void test_multiplicativeExpression_missing_LHS_RHS() { |
| 3678 BinaryExpression expression = ParserTestCase.parseExpression("*", [ | 3491 BinaryExpression expression = parseExpression("*", [ |
| 3679 ParserErrorCode.MISSING_IDENTIFIER, | 3492 ParserErrorCode.MISSING_IDENTIFIER, |
| 3680 ParserErrorCode.MISSING_IDENTIFIER | 3493 ParserErrorCode.MISSING_IDENTIFIER |
| 3681 ]); | 3494 ]); |
| 3682 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 3495 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
| 3683 SimpleIdentifier, expression.leftOperand); | 3496 SimpleIdentifier, expression.leftOperand); |
| 3684 expect(expression.leftOperand.isSynthetic, isTrue); | 3497 expect(expression.leftOperand.isSynthetic, isTrue); |
| 3685 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 3498 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
| 3686 SimpleIdentifier, expression.rightOperand); | 3499 SimpleIdentifier, expression.rightOperand); |
| 3687 expect(expression.rightOperand.isSynthetic, isTrue); | 3500 expect(expression.rightOperand.isSynthetic, isTrue); |
| 3688 } | 3501 } |
| 3689 | 3502 |
| 3690 void test_multiplicativeExpression_missing_RHS() { | 3503 void test_multiplicativeExpression_missing_RHS() { |
| 3691 BinaryExpression expression = ParserTestCase.parseExpression( | 3504 BinaryExpression expression = |
| 3692 "x *", [ParserErrorCode.MISSING_IDENTIFIER]); | 3505 parseExpression("x *", [ParserErrorCode.MISSING_IDENTIFIER]); |
| 3693 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 3506 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
| 3694 SimpleIdentifier, expression.rightOperand); | 3507 SimpleIdentifier, expression.rightOperand); |
| 3695 expect(expression.rightOperand.isSynthetic, isTrue); | 3508 expect(expression.rightOperand.isSynthetic, isTrue); |
| 3696 } | 3509 } |
| 3697 | 3510 |
| 3698 void test_multiplicativeExpression_missing_RHS_super() { | 3511 void test_multiplicativeExpression_missing_RHS_super() { |
| 3699 BinaryExpression expression = ParserTestCase.parseExpression( | 3512 BinaryExpression expression = |
| 3700 "super *", [ParserErrorCode.MISSING_IDENTIFIER]); | 3513 parseExpression("super *", [ParserErrorCode.MISSING_IDENTIFIER]); |
| 3701 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 3514 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
| 3702 SimpleIdentifier, expression.rightOperand); | 3515 SimpleIdentifier, expression.rightOperand); |
| 3703 expect(expression.rightOperand.isSynthetic, isTrue); | 3516 expect(expression.rightOperand.isSynthetic, isTrue); |
| 3704 } | 3517 } |
| 3705 | 3518 |
| 3706 void test_multiplicativeExpression_precedence_unary_left() { | 3519 void test_multiplicativeExpression_precedence_unary_left() { |
| 3707 BinaryExpression expression = ParserTestCase.parseExpression( | 3520 BinaryExpression expression = |
| 3708 "-x *", [ParserErrorCode.MISSING_IDENTIFIER]); | 3521 parseExpression("-x *", [ParserErrorCode.MISSING_IDENTIFIER]); |
| 3709 EngineTestCase.assertInstanceOf((obj) => obj is PrefixExpression, | 3522 EngineTestCase.assertInstanceOf((obj) => obj is PrefixExpression, |
| 3710 PrefixExpression, expression.leftOperand); | 3523 PrefixExpression, expression.leftOperand); |
| 3711 } | 3524 } |
| 3712 | 3525 |
| 3713 void test_multiplicativeExpression_precedence_unary_right() { | 3526 void test_multiplicativeExpression_precedence_unary_right() { |
| 3714 BinaryExpression expression = ParserTestCase.parseExpression( | 3527 BinaryExpression expression = |
| 3715 "* -y", [ParserErrorCode.MISSING_IDENTIFIER]); | 3528 parseExpression("* -y", [ParserErrorCode.MISSING_IDENTIFIER]); |
| 3716 EngineTestCase.assertInstanceOf((obj) => obj is PrefixExpression, | 3529 EngineTestCase.assertInstanceOf((obj) => obj is PrefixExpression, |
| 3717 PrefixExpression, expression.rightOperand); | 3530 PrefixExpression, expression.rightOperand); |
| 3718 } | 3531 } |
| 3719 | 3532 |
| 3720 void test_multiplicativeExpression_super() { | 3533 void test_multiplicativeExpression_super() { |
| 3721 BinaryExpression expression = ParserTestCase.parseExpression("super == ==", | 3534 BinaryExpression expression = parseExpression("super == ==", [ |
| 3722 [ | |
| 3723 ParserErrorCode.MISSING_IDENTIFIER, | 3535 ParserErrorCode.MISSING_IDENTIFIER, |
| 3724 ParserErrorCode.MISSING_IDENTIFIER, | 3536 ParserErrorCode.MISSING_IDENTIFIER, |
| 3725 ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND | 3537 ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND |
| 3726 ]); | 3538 ]); |
| 3727 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | 3539 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, |
| 3728 BinaryExpression, expression.leftOperand); | 3540 BinaryExpression, expression.leftOperand); |
| 3729 } | 3541 } |
| 3730 | 3542 |
| 3731 void test_nonStringLiteralUri_import() { | 3543 void test_nonStringLiteralUri_import() { |
| 3732 ParserTestCase.parseCompilationUnit("import dart:io; class C {}", [ | 3544 ParserTestCase.parseCompilationUnit("import dart:io; class C {}", |
| 3733 ParserErrorCode.NON_STRING_LITERAL_AS_URI | 3545 [ParserErrorCode.NON_STRING_LITERAL_AS_URI]); |
| 3734 ]); | |
| 3735 } | 3546 } |
| 3736 | 3547 |
| 3737 void test_prefixExpression_missing_operand_minus() { | 3548 void test_prefixExpression_missing_operand_minus() { |
| 3738 PrefixExpression expression = ParserTestCase.parseExpression( | 3549 PrefixExpression expression = |
| 3739 "-", [ParserErrorCode.MISSING_IDENTIFIER]); | 3550 parseExpression("-", [ParserErrorCode.MISSING_IDENTIFIER]); |
| 3740 EngineTestCase.assertInstanceOf( | 3551 EngineTestCase.assertInstanceOf( |
| 3741 (obj) => obj is SimpleIdentifier, SimpleIdentifier, expression.operand); | 3552 (obj) => obj is SimpleIdentifier, SimpleIdentifier, expression.operand); |
| 3742 expect(expression.operand.isSynthetic, isTrue); | 3553 expect(expression.operand.isSynthetic, isTrue); |
| 3743 expect(expression.operator.type, TokenType.MINUS); | 3554 expect(expression.operator.type, TokenType.MINUS); |
| 3744 } | 3555 } |
| 3745 | 3556 |
| 3746 void test_primaryExpression_argumentDefinitionTest() { | 3557 void test_primaryExpression_argumentDefinitionTest() { |
| 3747 Expression expression = ParserTestCase.parse4( | 3558 Expression expression = parse4( |
| 3748 "parsePrimaryExpression", "?a", [ParserErrorCode.UNEXPECTED_TOKEN]); | 3559 "parsePrimaryExpression", "?a", [ParserErrorCode.UNEXPECTED_TOKEN]); |
| 3749 EngineTestCase.assertInstanceOf( | 3560 EngineTestCase.assertInstanceOf( |
| 3750 (obj) => obj is SimpleIdentifier, SimpleIdentifier, expression); | 3561 (obj) => obj is SimpleIdentifier, SimpleIdentifier, expression); |
| 3751 } | 3562 } |
| 3752 | 3563 |
| 3753 void test_relationalExpression_missing_LHS() { | 3564 void test_relationalExpression_missing_LHS() { |
| 3754 IsExpression expression = ParserTestCase.parseExpression( | 3565 IsExpression expression = |
| 3755 "is y", [ParserErrorCode.MISSING_IDENTIFIER]); | 3566 parseExpression("is y", [ParserErrorCode.MISSING_IDENTIFIER]); |
| 3756 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 3567 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
| 3757 SimpleIdentifier, expression.expression); | 3568 SimpleIdentifier, expression.expression); |
| 3758 expect(expression.expression.isSynthetic, isTrue); | 3569 expect(expression.expression.isSynthetic, isTrue); |
| 3759 } | 3570 } |
| 3760 | 3571 |
| 3761 void test_relationalExpression_missing_LHS_RHS() { | 3572 void test_relationalExpression_missing_LHS_RHS() { |
| 3762 IsExpression expression = ParserTestCase.parseExpression("is", [ | 3573 IsExpression expression = parseExpression("is", [ |
| 3763 ParserErrorCode.EXPECTED_TYPE_NAME, | 3574 ParserErrorCode.EXPECTED_TYPE_NAME, |
| 3764 ParserErrorCode.MISSING_IDENTIFIER | 3575 ParserErrorCode.MISSING_IDENTIFIER |
| 3765 ]); | 3576 ]); |
| 3766 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 3577 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
| 3767 SimpleIdentifier, expression.expression); | 3578 SimpleIdentifier, expression.expression); |
| 3768 expect(expression.expression.isSynthetic, isTrue); | 3579 expect(expression.expression.isSynthetic, isTrue); |
| 3769 EngineTestCase.assertInstanceOf( | 3580 EngineTestCase.assertInstanceOf( |
| 3770 (obj) => obj is TypeName, TypeName, expression.type); | 3581 (obj) => obj is TypeName, TypeName, expression.type); |
| 3771 expect(expression.type.isSynthetic, isTrue); | 3582 expect(expression.type.isSynthetic, isTrue); |
| 3772 } | 3583 } |
| 3773 | 3584 |
| 3774 void test_relationalExpression_missing_RHS() { | 3585 void test_relationalExpression_missing_RHS() { |
| 3775 IsExpression expression = ParserTestCase.parseExpression( | 3586 IsExpression expression = |
| 3776 "x is", [ParserErrorCode.EXPECTED_TYPE_NAME]); | 3587 parseExpression("x is", [ParserErrorCode.EXPECTED_TYPE_NAME]); |
| 3777 EngineTestCase.assertInstanceOf( | 3588 EngineTestCase.assertInstanceOf( |
| 3778 (obj) => obj is TypeName, TypeName, expression.type); | 3589 (obj) => obj is TypeName, TypeName, expression.type); |
| 3779 expect(expression.type.isSynthetic, isTrue); | 3590 expect(expression.type.isSynthetic, isTrue); |
| 3780 } | 3591 } |
| 3781 | 3592 |
| 3782 void test_relationalExpression_precedence_shift_right() { | 3593 void test_relationalExpression_precedence_shift_right() { |
| 3783 IsExpression expression = ParserTestCase.parseExpression("<< is", [ | 3594 IsExpression expression = parseExpression("<< is", [ |
| 3784 ParserErrorCode.EXPECTED_TYPE_NAME, | 3595 ParserErrorCode.EXPECTED_TYPE_NAME, |
| 3785 ParserErrorCode.MISSING_IDENTIFIER, | 3596 ParserErrorCode.MISSING_IDENTIFIER, |
| 3786 ParserErrorCode.MISSING_IDENTIFIER | 3597 ParserErrorCode.MISSING_IDENTIFIER |
| 3787 ]); | 3598 ]); |
| 3788 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | 3599 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, |
| 3789 BinaryExpression, expression.expression); | 3600 BinaryExpression, expression.expression); |
| 3790 } | 3601 } |
| 3791 | 3602 |
| 3792 void test_shiftExpression_missing_LHS() { | 3603 void test_shiftExpression_missing_LHS() { |
| 3793 BinaryExpression expression = ParserTestCase.parseExpression( | 3604 BinaryExpression expression = |
| 3794 "<< y", [ParserErrorCode.MISSING_IDENTIFIER]); | 3605 parseExpression("<< y", [ParserErrorCode.MISSING_IDENTIFIER]); |
| 3795 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 3606 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
| 3796 SimpleIdentifier, expression.leftOperand); | 3607 SimpleIdentifier, expression.leftOperand); |
| 3797 expect(expression.leftOperand.isSynthetic, isTrue); | 3608 expect(expression.leftOperand.isSynthetic, isTrue); |
| 3798 } | 3609 } |
| 3799 | 3610 |
| 3800 void test_shiftExpression_missing_LHS_RHS() { | 3611 void test_shiftExpression_missing_LHS_RHS() { |
| 3801 BinaryExpression expression = ParserTestCase.parseExpression("<<", [ | 3612 BinaryExpression expression = parseExpression("<<", [ |
| 3802 ParserErrorCode.MISSING_IDENTIFIER, | 3613 ParserErrorCode.MISSING_IDENTIFIER, |
| 3803 ParserErrorCode.MISSING_IDENTIFIER | 3614 ParserErrorCode.MISSING_IDENTIFIER |
| 3804 ]); | 3615 ]); |
| 3805 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 3616 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
| 3806 SimpleIdentifier, expression.leftOperand); | 3617 SimpleIdentifier, expression.leftOperand); |
| 3807 expect(expression.leftOperand.isSynthetic, isTrue); | 3618 expect(expression.leftOperand.isSynthetic, isTrue); |
| 3808 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 3619 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
| 3809 SimpleIdentifier, expression.rightOperand); | 3620 SimpleIdentifier, expression.rightOperand); |
| 3810 expect(expression.rightOperand.isSynthetic, isTrue); | 3621 expect(expression.rightOperand.isSynthetic, isTrue); |
| 3811 } | 3622 } |
| 3812 | 3623 |
| 3813 void test_shiftExpression_missing_RHS() { | 3624 void test_shiftExpression_missing_RHS() { |
| 3814 BinaryExpression expression = ParserTestCase.parseExpression( | 3625 BinaryExpression expression = |
| 3815 "x <<", [ParserErrorCode.MISSING_IDENTIFIER]); | 3626 parseExpression("x <<", [ParserErrorCode.MISSING_IDENTIFIER]); |
| 3816 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 3627 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
| 3817 SimpleIdentifier, expression.rightOperand); | 3628 SimpleIdentifier, expression.rightOperand); |
| 3818 expect(expression.rightOperand.isSynthetic, isTrue); | 3629 expect(expression.rightOperand.isSynthetic, isTrue); |
| 3819 } | 3630 } |
| 3820 | 3631 |
| 3821 void test_shiftExpression_missing_RHS_super() { | 3632 void test_shiftExpression_missing_RHS_super() { |
| 3822 BinaryExpression expression = ParserTestCase.parseExpression( | 3633 BinaryExpression expression = |
| 3823 "super <<", [ParserErrorCode.MISSING_IDENTIFIER]); | 3634 parseExpression("super <<", [ParserErrorCode.MISSING_IDENTIFIER]); |
| 3824 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 3635 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
| 3825 SimpleIdentifier, expression.rightOperand); | 3636 SimpleIdentifier, expression.rightOperand); |
| 3826 expect(expression.rightOperand.isSynthetic, isTrue); | 3637 expect(expression.rightOperand.isSynthetic, isTrue); |
| 3827 } | 3638 } |
| 3828 | 3639 |
| 3829 void test_shiftExpression_precedence_unary_left() { | 3640 void test_shiftExpression_precedence_unary_left() { |
| 3830 BinaryExpression expression = ParserTestCase.parseExpression("+ <<", [ | 3641 BinaryExpression expression = parseExpression("+ <<", [ |
| 3831 ParserErrorCode.MISSING_IDENTIFIER, | 3642 ParserErrorCode.MISSING_IDENTIFIER, |
| 3832 ParserErrorCode.MISSING_IDENTIFIER, | 3643 ParserErrorCode.MISSING_IDENTIFIER, |
| 3833 ParserErrorCode.MISSING_IDENTIFIER | 3644 ParserErrorCode.MISSING_IDENTIFIER |
| 3834 ]); | 3645 ]); |
| 3835 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | 3646 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, |
| 3836 BinaryExpression, expression.leftOperand); | 3647 BinaryExpression, expression.leftOperand); |
| 3837 } | 3648 } |
| 3838 | 3649 |
| 3839 void test_shiftExpression_precedence_unary_right() { | 3650 void test_shiftExpression_precedence_unary_right() { |
| 3840 BinaryExpression expression = ParserTestCase.parseExpression("<< +", [ | 3651 BinaryExpression expression = parseExpression("<< +", [ |
| 3841 ParserErrorCode.MISSING_IDENTIFIER, | 3652 ParserErrorCode.MISSING_IDENTIFIER, |
| 3842 ParserErrorCode.MISSING_IDENTIFIER, | 3653 ParserErrorCode.MISSING_IDENTIFIER, |
| 3843 ParserErrorCode.MISSING_IDENTIFIER | 3654 ParserErrorCode.MISSING_IDENTIFIER |
| 3844 ]); | 3655 ]); |
| 3845 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | 3656 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, |
| 3846 BinaryExpression, expression.rightOperand); | 3657 BinaryExpression, expression.rightOperand); |
| 3847 } | 3658 } |
| 3848 | 3659 |
| 3849 void test_shiftExpression_super() { | 3660 void test_shiftExpression_super() { |
| 3850 BinaryExpression expression = ParserTestCase.parseExpression("super << <<", | 3661 BinaryExpression expression = parseExpression("super << <<", [ |
| 3851 [ | |
| 3852 ParserErrorCode.MISSING_IDENTIFIER, | 3662 ParserErrorCode.MISSING_IDENTIFIER, |
| 3853 ParserErrorCode.MISSING_IDENTIFIER | 3663 ParserErrorCode.MISSING_IDENTIFIER |
| 3854 ]); | 3664 ]); |
| 3855 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | 3665 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, |
| 3856 BinaryExpression, expression.leftOperand); | 3666 BinaryExpression, expression.leftOperand); |
| 3857 } | 3667 } |
| 3858 | 3668 |
| 3859 void test_typedef_eof() { | 3669 void test_typedef_eof() { |
| 3860 CompilationUnit unit = ParserTestCase.parseCompilationUnit("typedef n", [ | 3670 CompilationUnit unit = ParserTestCase.parseCompilationUnit("typedef n", [ |
| 3861 ParserErrorCode.EXPECTED_TOKEN, | 3671 ParserErrorCode.EXPECTED_TOKEN, |
| 3862 ParserErrorCode.MISSING_TYPEDEF_PARAMETERS | 3672 ParserErrorCode.MISSING_TYPEDEF_PARAMETERS |
| 3863 ]); | 3673 ]); |
| 3864 NodeList<CompilationUnitMember> declarations = unit.declarations; | 3674 NodeList<CompilationUnitMember> declarations = unit.declarations; |
| 3865 expect(declarations, hasLength(1)); | 3675 expect(declarations, hasLength(1)); |
| 3866 CompilationUnitMember member = declarations[0]; | 3676 CompilationUnitMember member = declarations[0]; |
| 3867 EngineTestCase.assertInstanceOf( | 3677 EngineTestCase.assertInstanceOf( |
| 3868 (obj) => obj is FunctionTypeAlias, FunctionTypeAlias, member); | 3678 (obj) => obj is FunctionTypeAlias, FunctionTypeAlias, member); |
| 3869 } | 3679 } |
| 3870 | 3680 |
| 3871 void test_unaryPlus() { | 3681 void test_unaryPlus() { |
| 3872 ParserTestCase.parseExpression("+2", [ParserErrorCode.MISSING_IDENTIFIER]); | 3682 parseExpression("+2", [ParserErrorCode.MISSING_IDENTIFIER]); |
| 3873 } | 3683 } |
| 3874 } | 3684 } |
| 3875 | 3685 |
| 3876 @reflectiveTest | 3686 @reflectiveTest |
| 3877 class ResolutionCopierTest extends EngineTestCase { | 3687 class ResolutionCopierTest extends EngineTestCase { |
| 3878 void test_visitAnnotation() { | 3688 void test_visitAnnotation() { |
| 3879 String annotationName = "proxy"; | 3689 String annotationName = "proxy"; |
| 3880 Annotation fromNode = | 3690 Annotation fromNode = |
| 3881 AstFactory.annotation(AstFactory.identifier3(annotationName)); | 3691 AstFactory.annotation(AstFactory.identifier3(annotationName)); |
| 3882 Element element = ElementFactory.topLevelVariableElement2(annotationName); | 3692 Element element = ElementFactory.topLevelVariableElement2(annotationName); |
| (...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4499 * the interactions between the method under test and other methods. | 4309 * the interactions between the method under test and other methods. |
| 4500 * | 4310 * |
| 4501 * More complex tests should be defined in the class [ComplexParserTest]. | 4311 * More complex tests should be defined in the class [ComplexParserTest]. |
| 4502 */ | 4312 */ |
| 4503 @reflectiveTest | 4313 @reflectiveTest |
| 4504 class SimpleParserTest extends ParserTestCase { | 4314 class SimpleParserTest extends ParserTestCase { |
| 4505 void fail_parseAwaitExpression_inSync() { | 4315 void fail_parseAwaitExpression_inSync() { |
| 4506 // This test requires better error recovery than we currently have. In | 4316 // This test requires better error recovery than we currently have. In |
| 4507 // particular, we need to be able to distinguish between an await expression | 4317 // particular, we need to be able to distinguish between an await expression |
| 4508 // in the wrong context, and the use of 'await' as an identifier. | 4318 // in the wrong context, and the use of 'await' as an identifier. |
| 4509 MethodDeclaration method = ParserTestCase.parse( | 4319 MethodDeclaration method = parse( |
| 4510 "parseClassMember", <Object>["C"], "m() { return await x + await y; }"); | 4320 "parseClassMember", <Object>["C"], "m() { return await x + await y; }"); |
| 4511 FunctionBody body = method.body; | 4321 FunctionBody body = method.body; |
| 4512 EngineTestCase.assertInstanceOf( | 4322 EngineTestCase.assertInstanceOf( |
| 4513 (obj) => obj is BlockFunctionBody, BlockFunctionBody, body); | 4323 (obj) => obj is BlockFunctionBody, BlockFunctionBody, body); |
| 4514 Statement statement = (body as BlockFunctionBody).block.statements[0]; | 4324 Statement statement = (body as BlockFunctionBody).block.statements[0]; |
| 4515 EngineTestCase.assertInstanceOf( | 4325 EngineTestCase.assertInstanceOf( |
| 4516 (obj) => obj is ReturnStatement, ReturnStatement, statement); | 4326 (obj) => obj is ReturnStatement, ReturnStatement, statement); |
| 4517 Expression expression = (statement as ReturnStatement).expression; | 4327 Expression expression = (statement as ReturnStatement).expression; |
| 4518 EngineTestCase.assertInstanceOf( | 4328 EngineTestCase.assertInstanceOf( |
| 4519 (obj) => obj is BinaryExpression, BinaryExpression, expression); | 4329 (obj) => obj is BinaryExpression, BinaryExpression, expression); |
| 4520 EngineTestCase.assertInstanceOf((obj) => obj is AwaitExpression, | 4330 EngineTestCase.assertInstanceOf((obj) => obj is AwaitExpression, |
| 4521 AwaitExpression, (expression as BinaryExpression).leftOperand); | 4331 AwaitExpression, (expression as BinaryExpression).leftOperand); |
| 4522 EngineTestCase.assertInstanceOf((obj) => obj is AwaitExpression, | 4332 EngineTestCase.assertInstanceOf((obj) => obj is AwaitExpression, |
| 4523 AwaitExpression, (expression as BinaryExpression).rightOperand); | 4333 AwaitExpression, (expression as BinaryExpression).rightOperand); |
| 4524 } | 4334 } |
| 4525 | 4335 |
| 4526 void fail_parseCommentReference_this() { | 4336 void fail_parseCommentReference_this() { |
| 4527 // This fails because we are returning null from the method and asserting | 4337 // This fails because we are returning null from the method and asserting |
| 4528 // that the return value is not null. | 4338 // that the return value is not null. |
| 4529 CommentReference reference = | 4339 CommentReference reference = |
| 4530 ParserTestCase.parse("parseCommentReference", <Object>["this", 5], ""); | 4340 parse("parseCommentReference", <Object>["this", 5], ""); |
| 4531 SimpleIdentifier identifier = EngineTestCase.assertInstanceOf( | 4341 SimpleIdentifier identifier = EngineTestCase.assertInstanceOf( |
| 4532 (obj) => obj is SimpleIdentifier, SimpleIdentifier, | 4342 (obj) => obj is SimpleIdentifier, SimpleIdentifier, |
| 4533 reference.identifier); | 4343 reference.identifier); |
| 4534 expect(identifier.token, isNotNull); | 4344 expect(identifier.token, isNotNull); |
| 4535 expect(identifier.name, "a"); | 4345 expect(identifier.name, "a"); |
| 4536 expect(identifier.offset, 5); | 4346 expect(identifier.offset, 5); |
| 4537 } | 4347 } |
| 4538 | 4348 |
| 4539 void test_computeStringValue_emptyInterpolationPrefix() { | 4349 void test_computeStringValue_emptyInterpolationPrefix() { |
| 4540 expect(_computeStringValue("'''", true, false), ""); | 4350 expect(_computeStringValue("'''", true, false), ""); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4610 | 4420 |
| 4611 void test_computeStringValue_triple_internalQuote_last_empty() { | 4421 void test_computeStringValue_triple_internalQuote_last_empty() { |
| 4612 expect(_computeStringValue("'''", false, true), ""); | 4422 expect(_computeStringValue("'''", false, true), ""); |
| 4613 } | 4423 } |
| 4614 | 4424 |
| 4615 void test_computeStringValue_triple_internalQuote_last_nonEmpty() { | 4425 void test_computeStringValue_triple_internalQuote_last_nonEmpty() { |
| 4616 expect(_computeStringValue("text'''", false, true), "text"); | 4426 expect(_computeStringValue("text'''", false, true), "text"); |
| 4617 } | 4427 } |
| 4618 | 4428 |
| 4619 void test_constFactory() { | 4429 void test_constFactory() { |
| 4620 ParserTestCase.parse( | 4430 parse("parseClassMember", <Object>["C"], "const factory C() = A;"); |
| 4621 "parseClassMember", <Object>["C"], "const factory C() = A;"); | |
| 4622 } | 4431 } |
| 4623 | 4432 |
| 4624 void test_createSyntheticIdentifier() { | 4433 void test_createSyntheticIdentifier() { |
| 4625 SimpleIdentifier identifier = _createSyntheticIdentifier(); | 4434 SimpleIdentifier identifier = _createSyntheticIdentifier(); |
| 4626 expect(identifier.isSynthetic, isTrue); | 4435 expect(identifier.isSynthetic, isTrue); |
| 4627 } | 4436 } |
| 4628 | 4437 |
| 4629 void test_createSyntheticStringLiteral() { | 4438 void test_createSyntheticStringLiteral() { |
| 4630 SimpleStringLiteral literal = _createSyntheticStringLiteral(); | 4439 SimpleStringLiteral literal = _createSyntheticStringLiteral(); |
| 4631 expect(literal.isSynthetic, isTrue); | 4440 expect(literal.isSynthetic, isTrue); |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4816 | 4625 |
| 4817 void test_isSwitchMember_default_unlabeled() { | 4626 void test_isSwitchMember_default_unlabeled() { |
| 4818 expect(_isSwitchMember("default"), isTrue); | 4627 expect(_isSwitchMember("default"), isTrue); |
| 4819 } | 4628 } |
| 4820 | 4629 |
| 4821 void test_isSwitchMember_false() { | 4630 void test_isSwitchMember_false() { |
| 4822 expect(_isSwitchMember("break;"), isFalse); | 4631 expect(_isSwitchMember("break;"), isFalse); |
| 4823 } | 4632 } |
| 4824 | 4633 |
| 4825 void test_parseAdditiveExpression_normal() { | 4634 void test_parseAdditiveExpression_normal() { |
| 4826 BinaryExpression expression = | 4635 BinaryExpression expression = parse4("parseAdditiveExpression", "x + y"); |
| 4827 ParserTestCase.parse4("parseAdditiveExpression", "x + y"); | |
| 4828 expect(expression.leftOperand, isNotNull); | 4636 expect(expression.leftOperand, isNotNull); |
| 4829 expect(expression.operator, isNotNull); | 4637 expect(expression.operator, isNotNull); |
| 4830 expect(expression.operator.type, TokenType.PLUS); | 4638 expect(expression.operator.type, TokenType.PLUS); |
| 4831 expect(expression.rightOperand, isNotNull); | 4639 expect(expression.rightOperand, isNotNull); |
| 4832 } | 4640 } |
| 4833 | 4641 |
| 4834 void test_parseAdditiveExpression_super() { | 4642 void test_parseAdditiveExpression_super() { |
| 4835 BinaryExpression expression = | 4643 BinaryExpression expression = |
| 4836 ParserTestCase.parse4("parseAdditiveExpression", "super + y"); | 4644 parse4("parseAdditiveExpression", "super + y"); |
| 4837 EngineTestCase.assertInstanceOf((obj) => obj is SuperExpression, | 4645 EngineTestCase.assertInstanceOf((obj) => obj is SuperExpression, |
| 4838 SuperExpression, expression.leftOperand); | 4646 SuperExpression, expression.leftOperand); |
| 4839 expect(expression.operator, isNotNull); | 4647 expect(expression.operator, isNotNull); |
| 4840 expect(expression.operator.type, TokenType.PLUS); | 4648 expect(expression.operator.type, TokenType.PLUS); |
| 4841 expect(expression.rightOperand, isNotNull); | 4649 expect(expression.rightOperand, isNotNull); |
| 4842 } | 4650 } |
| 4843 | 4651 |
| 4844 void test_parseAnnotation_n1() { | 4652 void test_parseAnnotation_n1() { |
| 4845 Annotation annotation = ParserTestCase.parse4("parseAnnotation", "@A"); | 4653 Annotation annotation = parse4("parseAnnotation", "@A"); |
| 4846 expect(annotation.atSign, isNotNull); | 4654 expect(annotation.atSign, isNotNull); |
| 4847 expect(annotation.name, isNotNull); | 4655 expect(annotation.name, isNotNull); |
| 4848 expect(annotation.period, isNull); | 4656 expect(annotation.period, isNull); |
| 4849 expect(annotation.constructorName, isNull); | 4657 expect(annotation.constructorName, isNull); |
| 4850 expect(annotation.arguments, isNull); | 4658 expect(annotation.arguments, isNull); |
| 4851 } | 4659 } |
| 4852 | 4660 |
| 4853 void test_parseAnnotation_n1_a() { | 4661 void test_parseAnnotation_n1_a() { |
| 4854 Annotation annotation = ParserTestCase.parse4("parseAnnotation", "@A(x,y)"); | 4662 Annotation annotation = parse4("parseAnnotation", "@A(x,y)"); |
| 4855 expect(annotation.atSign, isNotNull); | 4663 expect(annotation.atSign, isNotNull); |
| 4856 expect(annotation.name, isNotNull); | 4664 expect(annotation.name, isNotNull); |
| 4857 expect(annotation.period, isNull); | 4665 expect(annotation.period, isNull); |
| 4858 expect(annotation.constructorName, isNull); | 4666 expect(annotation.constructorName, isNull); |
| 4859 expect(annotation.arguments, isNotNull); | 4667 expect(annotation.arguments, isNotNull); |
| 4860 } | 4668 } |
| 4861 | 4669 |
| 4862 void test_parseAnnotation_n2() { | 4670 void test_parseAnnotation_n2() { |
| 4863 Annotation annotation = ParserTestCase.parse4("parseAnnotation", "@A.B"); | 4671 Annotation annotation = parse4("parseAnnotation", "@A.B"); |
| 4864 expect(annotation.atSign, isNotNull); | 4672 expect(annotation.atSign, isNotNull); |
| 4865 expect(annotation.name, isNotNull); | 4673 expect(annotation.name, isNotNull); |
| 4866 expect(annotation.period, isNull); | 4674 expect(annotation.period, isNull); |
| 4867 expect(annotation.constructorName, isNull); | 4675 expect(annotation.constructorName, isNull); |
| 4868 expect(annotation.arguments, isNull); | 4676 expect(annotation.arguments, isNull); |
| 4869 } | 4677 } |
| 4870 | 4678 |
| 4871 void test_parseAnnotation_n2_a() { | 4679 void test_parseAnnotation_n2_a() { |
| 4872 Annotation annotation = | 4680 Annotation annotation = parse4("parseAnnotation", "@A.B(x,y)"); |
| 4873 ParserTestCase.parse4("parseAnnotation", "@A.B(x,y)"); | |
| 4874 expect(annotation.atSign, isNotNull); | 4681 expect(annotation.atSign, isNotNull); |
| 4875 expect(annotation.name, isNotNull); | 4682 expect(annotation.name, isNotNull); |
| 4876 expect(annotation.period, isNull); | 4683 expect(annotation.period, isNull); |
| 4877 expect(annotation.constructorName, isNull); | 4684 expect(annotation.constructorName, isNull); |
| 4878 expect(annotation.arguments, isNotNull); | 4685 expect(annotation.arguments, isNotNull); |
| 4879 } | 4686 } |
| 4880 | 4687 |
| 4881 void test_parseAnnotation_n3() { | 4688 void test_parseAnnotation_n3() { |
| 4882 Annotation annotation = ParserTestCase.parse4("parseAnnotation", "@A.B.C"); | 4689 Annotation annotation = parse4("parseAnnotation", "@A.B.C"); |
| 4883 expect(annotation.atSign, isNotNull); | 4690 expect(annotation.atSign, isNotNull); |
| 4884 expect(annotation.name, isNotNull); | 4691 expect(annotation.name, isNotNull); |
| 4885 expect(annotation.period, isNotNull); | 4692 expect(annotation.period, isNotNull); |
| 4886 expect(annotation.constructorName, isNotNull); | 4693 expect(annotation.constructorName, isNotNull); |
| 4887 expect(annotation.arguments, isNull); | 4694 expect(annotation.arguments, isNull); |
| 4888 } | 4695 } |
| 4889 | 4696 |
| 4890 void test_parseAnnotation_n3_a() { | 4697 void test_parseAnnotation_n3_a() { |
| 4891 Annotation annotation = | 4698 Annotation annotation = parse4("parseAnnotation", "@A.B.C(x,y)"); |
| 4892 ParserTestCase.parse4("parseAnnotation", "@A.B.C(x,y)"); | |
| 4893 expect(annotation.atSign, isNotNull); | 4699 expect(annotation.atSign, isNotNull); |
| 4894 expect(annotation.name, isNotNull); | 4700 expect(annotation.name, isNotNull); |
| 4895 expect(annotation.period, isNotNull); | 4701 expect(annotation.period, isNotNull); |
| 4896 expect(annotation.constructorName, isNotNull); | 4702 expect(annotation.constructorName, isNotNull); |
| 4897 expect(annotation.arguments, isNotNull); | 4703 expect(annotation.arguments, isNotNull); |
| 4898 } | 4704 } |
| 4899 | 4705 |
| 4900 void test_parseArgument_named() { | 4706 void test_parseArgument_named() { |
| 4901 NamedExpression expression = ParserTestCase.parse4("parseArgument", "n: x"); | 4707 NamedExpression expression = parse4("parseArgument", "n: x"); |
| 4902 Label name = expression.name; | 4708 Label name = expression.name; |
| 4903 expect(name, isNotNull); | 4709 expect(name, isNotNull); |
| 4904 expect(name.label, isNotNull); | 4710 expect(name.label, isNotNull); |
| 4905 expect(name.colon, isNotNull); | 4711 expect(name.colon, isNotNull); |
| 4906 expect(expression.expression, isNotNull); | 4712 expect(expression.expression, isNotNull); |
| 4907 } | 4713 } |
| 4908 | 4714 |
| 4909 void test_parseArgument_unnamed() { | 4715 void test_parseArgument_unnamed() { |
| 4910 String lexeme = "x"; | 4716 String lexeme = "x"; |
| 4911 SimpleIdentifier identifier = | 4717 SimpleIdentifier identifier = parse4("parseArgument", lexeme); |
| 4912 ParserTestCase.parse4("parseArgument", lexeme); | |
| 4913 expect(identifier.name, lexeme); | 4718 expect(identifier.name, lexeme); |
| 4914 } | 4719 } |
| 4915 | 4720 |
| 4916 void test_parseArgumentList_empty() { | 4721 void test_parseArgumentList_empty() { |
| 4917 ArgumentList argumentList = | 4722 ArgumentList argumentList = parse4("parseArgumentList", "()"); |
| 4918 ParserTestCase.parse4("parseArgumentList", "()"); | |
| 4919 NodeList<Expression> arguments = argumentList.arguments; | 4723 NodeList<Expression> arguments = argumentList.arguments; |
| 4920 expect(arguments, hasLength(0)); | 4724 expect(arguments, hasLength(0)); |
| 4921 } | 4725 } |
| 4922 | 4726 |
| 4923 void test_parseArgumentList_mixed() { | 4727 void test_parseArgumentList_mixed() { |
| 4924 ArgumentList argumentList = | 4728 ArgumentList argumentList = |
| 4925 ParserTestCase.parse4("parseArgumentList", "(w, x, y: y, z: z)"); | 4729 parse4("parseArgumentList", "(w, x, y: y, z: z)"); |
| 4926 NodeList<Expression> arguments = argumentList.arguments; | 4730 NodeList<Expression> arguments = argumentList.arguments; |
| 4927 expect(arguments, hasLength(4)); | 4731 expect(arguments, hasLength(4)); |
| 4928 } | 4732 } |
| 4929 | 4733 |
| 4930 void test_parseArgumentList_noNamed() { | 4734 void test_parseArgumentList_noNamed() { |
| 4931 ArgumentList argumentList = | 4735 ArgumentList argumentList = parse4("parseArgumentList", "(x, y, z)"); |
| 4932 ParserTestCase.parse4("parseArgumentList", "(x, y, z)"); | |
| 4933 NodeList<Expression> arguments = argumentList.arguments; | 4736 NodeList<Expression> arguments = argumentList.arguments; |
| 4934 expect(arguments, hasLength(3)); | 4737 expect(arguments, hasLength(3)); |
| 4935 } | 4738 } |
| 4936 | 4739 |
| 4937 void test_parseArgumentList_onlyNamed() { | 4740 void test_parseArgumentList_onlyNamed() { |
| 4938 ArgumentList argumentList = | 4741 ArgumentList argumentList = parse4("parseArgumentList", "(x: x, y: y)"); |
| 4939 ParserTestCase.parse4("parseArgumentList", "(x: x, y: y)"); | |
| 4940 NodeList<Expression> arguments = argumentList.arguments; | 4742 NodeList<Expression> arguments = argumentList.arguments; |
| 4941 expect(arguments, hasLength(2)); | 4743 expect(arguments, hasLength(2)); |
| 4942 } | 4744 } |
| 4943 | 4745 |
| 4944 void test_parseAssertStatement() { | 4746 void test_parseAssertStatement() { |
| 4945 AssertStatement statement = | 4747 AssertStatement statement = parse4("parseAssertStatement", "assert (x);"); |
| 4946 ParserTestCase.parse4("parseAssertStatement", "assert (x);"); | |
| 4947 expect(statement.assertKeyword, isNotNull); | 4748 expect(statement.assertKeyword, isNotNull); |
| 4948 expect(statement.leftParenthesis, isNotNull); | 4749 expect(statement.leftParenthesis, isNotNull); |
| 4949 expect(statement.condition, isNotNull); | 4750 expect(statement.condition, isNotNull); |
| 4950 expect(statement.rightParenthesis, isNotNull); | 4751 expect(statement.rightParenthesis, isNotNull); |
| 4951 expect(statement.semicolon, isNotNull); | 4752 expect(statement.semicolon, isNotNull); |
| 4952 } | 4753 } |
| 4953 | 4754 |
| 4954 void test_parseAssignableExpression_expression_args_dot() { | 4755 void test_parseAssignableExpression_expression_args_dot() { |
| 4955 PropertyAccess propertyAccess = ParserTestCase.parse( | 4756 PropertyAccess propertyAccess = |
| 4956 "parseAssignableExpression", <Object>[false], "(x)(y).z"); | 4757 parse("parseAssignableExpression", <Object>[false], "(x)(y).z"); |
| 4957 FunctionExpressionInvocation invocation = | 4758 FunctionExpressionInvocation invocation = |
| 4958 propertyAccess.target as FunctionExpressionInvocation; | 4759 propertyAccess.target as FunctionExpressionInvocation; |
| 4959 expect(invocation.function, isNotNull); | 4760 expect(invocation.function, isNotNull); |
| 4960 ArgumentList argumentList = invocation.argumentList; | 4761 ArgumentList argumentList = invocation.argumentList; |
| 4961 expect(argumentList, isNotNull); | 4762 expect(argumentList, isNotNull); |
| 4962 expect(argumentList.arguments, hasLength(1)); | 4763 expect(argumentList.arguments, hasLength(1)); |
| 4963 expect(propertyAccess.operator, isNotNull); | 4764 expect(propertyAccess.operator, isNotNull); |
| 4964 expect(propertyAccess.propertyName, isNotNull); | 4765 expect(propertyAccess.propertyName, isNotNull); |
| 4965 } | 4766 } |
| 4966 | 4767 |
| 4967 void test_parseAssignableExpression_expression_dot() { | 4768 void test_parseAssignableExpression_expression_dot() { |
| 4968 PropertyAccess propertyAccess = ParserTestCase.parse( | 4769 PropertyAccess propertyAccess = |
| 4969 "parseAssignableExpression", <Object>[false], "(x).y"); | 4770 parse("parseAssignableExpression", <Object>[false], "(x).y"); |
| 4970 expect(propertyAccess.target, isNotNull); | 4771 expect(propertyAccess.target, isNotNull); |
| 4971 expect(propertyAccess.operator, isNotNull); | 4772 expect(propertyAccess.operator, isNotNull); |
| 4972 expect(propertyAccess.propertyName, isNotNull); | 4773 expect(propertyAccess.propertyName, isNotNull); |
| 4973 } | 4774 } |
| 4974 | 4775 |
| 4975 void test_parseAssignableExpression_expression_index() { | 4776 void test_parseAssignableExpression_expression_index() { |
| 4976 IndexExpression expression = ParserTestCase.parse( | 4777 IndexExpression expression = |
| 4977 "parseAssignableExpression", <Object>[false], "(x)[y]"); | 4778 parse("parseAssignableExpression", <Object>[false], "(x)[y]"); |
| 4978 expect(expression.target, isNotNull); | 4779 expect(expression.target, isNotNull); |
| 4979 expect(expression.leftBracket, isNotNull); | 4780 expect(expression.leftBracket, isNotNull); |
| 4980 expect(expression.index, isNotNull); | 4781 expect(expression.index, isNotNull); |
| 4981 expect(expression.rightBracket, isNotNull); | 4782 expect(expression.rightBracket, isNotNull); |
| 4982 } | 4783 } |
| 4983 | 4784 |
| 4984 void test_parseAssignableExpression_identifier() { | 4785 void test_parseAssignableExpression_identifier() { |
| 4985 SimpleIdentifier identifier = | 4786 SimpleIdentifier identifier = |
| 4986 ParserTestCase.parse("parseAssignableExpression", <Object>[false], "x"); | 4787 parse("parseAssignableExpression", <Object>[false], "x"); |
| 4987 expect(identifier, isNotNull); | 4788 expect(identifier, isNotNull); |
| 4988 } | 4789 } |
| 4989 | 4790 |
| 4990 void test_parseAssignableExpression_identifier_args_dot() { | 4791 void test_parseAssignableExpression_identifier_args_dot() { |
| 4991 PropertyAccess propertyAccess = ParserTestCase.parse( | 4792 PropertyAccess propertyAccess = |
| 4992 "parseAssignableExpression", <Object>[false], "x(y).z"); | 4793 parse("parseAssignableExpression", <Object>[false], "x(y).z"); |
| 4993 MethodInvocation invocation = propertyAccess.target as MethodInvocation; | 4794 MethodInvocation invocation = propertyAccess.target as MethodInvocation; |
| 4994 expect(invocation.methodName.name, "x"); | 4795 expect(invocation.methodName.name, "x"); |
| 4995 ArgumentList argumentList = invocation.argumentList; | 4796 ArgumentList argumentList = invocation.argumentList; |
| 4996 expect(argumentList, isNotNull); | 4797 expect(argumentList, isNotNull); |
| 4997 expect(argumentList.arguments, hasLength(1)); | 4798 expect(argumentList.arguments, hasLength(1)); |
| 4998 expect(propertyAccess.operator, isNotNull); | 4799 expect(propertyAccess.operator, isNotNull); |
| 4999 expect(propertyAccess.propertyName, isNotNull); | 4800 expect(propertyAccess.propertyName, isNotNull); |
| 5000 } | 4801 } |
| 5001 | 4802 |
| 5002 void test_parseAssignableExpression_identifier_dot() { | 4803 void test_parseAssignableExpression_identifier_dot() { |
| 5003 PropertyAccess propertyAccess = ParserTestCase.parse( | 4804 PropertyAccess propertyAccess = |
| 5004 "parseAssignableExpression", <Object>[false], "x.y"); | 4805 parse("parseAssignableExpression", <Object>[false], "x.y"); |
| 5005 expect(propertyAccess.target, isNotNull); | 4806 expect(propertyAccess.target, isNotNull); |
| 5006 expect(propertyAccess.operator, isNotNull); | 4807 expect(propertyAccess.operator, isNotNull); |
| 5007 expect(propertyAccess.propertyName, isNotNull); | 4808 expect(propertyAccess.propertyName, isNotNull); |
| 5008 } | 4809 } |
| 5009 | 4810 |
| 5010 void test_parseAssignableExpression_identifier_index() { | 4811 void test_parseAssignableExpression_identifier_index() { |
| 5011 IndexExpression expression = ParserTestCase.parse( | 4812 IndexExpression expression = |
| 5012 "parseAssignableExpression", <Object>[false], "x[y]"); | 4813 parse("parseAssignableExpression", <Object>[false], "x[y]"); |
| 5013 expect(expression.target, isNotNull); | 4814 expect(expression.target, isNotNull); |
| 5014 expect(expression.leftBracket, isNotNull); | 4815 expect(expression.leftBracket, isNotNull); |
| 5015 expect(expression.index, isNotNull); | 4816 expect(expression.index, isNotNull); |
| 5016 expect(expression.rightBracket, isNotNull); | 4817 expect(expression.rightBracket, isNotNull); |
| 5017 } | 4818 } |
| 5018 | 4819 |
| 5019 void test_parseAssignableExpression_super_dot() { | 4820 void test_parseAssignableExpression_super_dot() { |
| 5020 PropertyAccess propertyAccess = ParserTestCase.parse( | 4821 PropertyAccess propertyAccess = |
| 5021 "parseAssignableExpression", <Object>[false], "super.y"); | 4822 parse("parseAssignableExpression", <Object>[false], "super.y"); |
| 5022 EngineTestCase.assertInstanceOf((obj) => obj is SuperExpression, | 4823 EngineTestCase.assertInstanceOf((obj) => obj is SuperExpression, |
| 5023 SuperExpression, propertyAccess.target); | 4824 SuperExpression, propertyAccess.target); |
| 5024 expect(propertyAccess.operator, isNotNull); | 4825 expect(propertyAccess.operator, isNotNull); |
| 5025 expect(propertyAccess.propertyName, isNotNull); | 4826 expect(propertyAccess.propertyName, isNotNull); |
| 5026 } | 4827 } |
| 5027 | 4828 |
| 5028 void test_parseAssignableExpression_super_index() { | 4829 void test_parseAssignableExpression_super_index() { |
| 5029 IndexExpression expression = ParserTestCase.parse( | 4830 IndexExpression expression = |
| 5030 "parseAssignableExpression", <Object>[false], "super[y]"); | 4831 parse("parseAssignableExpression", <Object>[false], "super[y]"); |
| 5031 EngineTestCase.assertInstanceOf( | 4832 EngineTestCase.assertInstanceOf( |
| 5032 (obj) => obj is SuperExpression, SuperExpression, expression.target); | 4833 (obj) => obj is SuperExpression, SuperExpression, expression.target); |
| 5033 expect(expression.leftBracket, isNotNull); | 4834 expect(expression.leftBracket, isNotNull); |
| 5034 expect(expression.index, isNotNull); | 4835 expect(expression.index, isNotNull); |
| 5035 expect(expression.rightBracket, isNotNull); | 4836 expect(expression.rightBracket, isNotNull); |
| 5036 } | 4837 } |
| 5037 | 4838 |
| 5038 void test_parseAssignableSelector_dot() { | 4839 void test_parseAssignableSelector_dot() { |
| 5039 PropertyAccess selector = ParserTestCase.parse( | 4840 PropertyAccess selector = |
| 5040 "parseAssignableSelector", <Object>[null, true], ".x"); | 4841 parse("parseAssignableSelector", <Object>[null, true], ".x"); |
| 5041 expect(selector.operator, isNotNull); | 4842 expect(selector.operator, isNotNull); |
| 5042 expect(selector.propertyName, isNotNull); | 4843 expect(selector.propertyName, isNotNull); |
| 5043 } | 4844 } |
| 5044 | 4845 |
| 5045 void test_parseAssignableSelector_index() { | 4846 void test_parseAssignableSelector_index() { |
| 5046 IndexExpression selector = ParserTestCase.parse( | 4847 IndexExpression selector = |
| 5047 "parseAssignableSelector", <Object>[null, true], "[x]"); | 4848 parse("parseAssignableSelector", <Object>[null, true], "[x]"); |
| 5048 expect(selector.leftBracket, isNotNull); | 4849 expect(selector.leftBracket, isNotNull); |
| 5049 expect(selector.index, isNotNull); | 4850 expect(selector.index, isNotNull); |
| 5050 expect(selector.rightBracket, isNotNull); | 4851 expect(selector.rightBracket, isNotNull); |
| 5051 } | 4852 } |
| 5052 | 4853 |
| 5053 void test_parseAssignableSelector_none() { | 4854 void test_parseAssignableSelector_none() { |
| 5054 SimpleIdentifier selector = ParserTestCase.parse("parseAssignableSelector", | 4855 SimpleIdentifier selector = parse("parseAssignableSelector", <Object>[ |
| 5055 <Object>[new SimpleIdentifier(null), true], ";"); | 4856 new SimpleIdentifier(null), |
| 4857 true |
| 4858 ], ";"); |
| 5056 expect(selector, isNotNull); | 4859 expect(selector, isNotNull); |
| 5057 } | 4860 } |
| 5058 | 4861 |
| 5059 void test_parseAwaitExpression() { | 4862 void test_parseAwaitExpression() { |
| 5060 AwaitExpression expression = | 4863 AwaitExpression expression = parse4("parseAwaitExpression", "await x;"); |
| 5061 ParserTestCase.parse4("parseAwaitExpression", "await x;"); | |
| 5062 expect(expression.awaitKeyword, isNotNull); | 4864 expect(expression.awaitKeyword, isNotNull); |
| 5063 expect(expression.expression, isNotNull); | 4865 expect(expression.expression, isNotNull); |
| 5064 } | 4866 } |
| 5065 | 4867 |
| 5066 void test_parseAwaitExpression_asStatement_inAsync() { | 4868 void test_parseAwaitExpression_asStatement_inAsync() { |
| 5067 MethodDeclaration method = ParserTestCase.parse( | 4869 MethodDeclaration method = |
| 5068 "parseClassMember", <Object>["C"], "m() async { await x; }"); | 4870 parse("parseClassMember", <Object>["C"], "m() async { await x; }"); |
| 5069 FunctionBody body = method.body; | 4871 FunctionBody body = method.body; |
| 5070 EngineTestCase.assertInstanceOf( | 4872 EngineTestCase.assertInstanceOf( |
| 5071 (obj) => obj is BlockFunctionBody, BlockFunctionBody, body); | 4873 (obj) => obj is BlockFunctionBody, BlockFunctionBody, body); |
| 5072 Statement statement = (body as BlockFunctionBody).block.statements[0]; | 4874 Statement statement = (body as BlockFunctionBody).block.statements[0]; |
| 5073 EngineTestCase.assertInstanceOf( | 4875 EngineTestCase.assertInstanceOf( |
| 5074 (obj) => obj is ExpressionStatement, ExpressionStatement, statement); | 4876 (obj) => obj is ExpressionStatement, ExpressionStatement, statement); |
| 5075 Expression expression = (statement as ExpressionStatement).expression; | 4877 Expression expression = (statement as ExpressionStatement).expression; |
| 5076 EngineTestCase.assertInstanceOf( | 4878 EngineTestCase.assertInstanceOf( |
| 5077 (obj) => obj is AwaitExpression, AwaitExpression, expression); | 4879 (obj) => obj is AwaitExpression, AwaitExpression, expression); |
| 5078 expect((expression as AwaitExpression).awaitKeyword, isNotNull); | 4880 expect((expression as AwaitExpression).awaitKeyword, isNotNull); |
| 5079 expect((expression as AwaitExpression).expression, isNotNull); | 4881 expect((expression as AwaitExpression).expression, isNotNull); |
| 5080 } | 4882 } |
| 5081 | 4883 |
| 5082 void test_parseAwaitExpression_asStatement_inSync() { | 4884 void test_parseAwaitExpression_asStatement_inSync() { |
| 5083 MethodDeclaration method = ParserTestCase.parse( | 4885 MethodDeclaration method = |
| 5084 "parseClassMember", <Object>["C"], "m() { await x; }"); | 4886 parse("parseClassMember", <Object>["C"], "m() { await x; }"); |
| 5085 FunctionBody body = method.body; | 4887 FunctionBody body = method.body; |
| 5086 EngineTestCase.assertInstanceOf( | 4888 EngineTestCase.assertInstanceOf( |
| 5087 (obj) => obj is BlockFunctionBody, BlockFunctionBody, body); | 4889 (obj) => obj is BlockFunctionBody, BlockFunctionBody, body); |
| 5088 Statement statement = (body as BlockFunctionBody).block.statements[0]; | 4890 Statement statement = (body as BlockFunctionBody).block.statements[0]; |
| 5089 EngineTestCase.assertInstanceOf( | 4891 EngineTestCase.assertInstanceOf( |
| 5090 (obj) => obj is VariableDeclarationStatement, | 4892 (obj) => obj is VariableDeclarationStatement, |
| 5091 VariableDeclarationStatement, statement); | 4893 VariableDeclarationStatement, statement); |
| 5092 } | 4894 } |
| 5093 | 4895 |
| 5094 void test_parseBitwiseAndExpression_normal() { | 4896 void test_parseBitwiseAndExpression_normal() { |
| 5095 BinaryExpression expression = | 4897 BinaryExpression expression = parse4("parseBitwiseAndExpression", "x & y"); |
| 5096 ParserTestCase.parse4("parseBitwiseAndExpression", "x & y"); | |
| 5097 expect(expression.leftOperand, isNotNull); | 4898 expect(expression.leftOperand, isNotNull); |
| 5098 expect(expression.operator, isNotNull); | 4899 expect(expression.operator, isNotNull); |
| 5099 expect(expression.operator.type, TokenType.AMPERSAND); | 4900 expect(expression.operator.type, TokenType.AMPERSAND); |
| 5100 expect(expression.rightOperand, isNotNull); | 4901 expect(expression.rightOperand, isNotNull); |
| 5101 } | 4902 } |
| 5102 | 4903 |
| 5103 void test_parseBitwiseAndExpression_super() { | 4904 void test_parseBitwiseAndExpression_super() { |
| 5104 BinaryExpression expression = | 4905 BinaryExpression expression = |
| 5105 ParserTestCase.parse4("parseBitwiseAndExpression", "super & y"); | 4906 parse4("parseBitwiseAndExpression", "super & y"); |
| 5106 EngineTestCase.assertInstanceOf((obj) => obj is SuperExpression, | 4907 EngineTestCase.assertInstanceOf((obj) => obj is SuperExpression, |
| 5107 SuperExpression, expression.leftOperand); | 4908 SuperExpression, expression.leftOperand); |
| 5108 expect(expression.operator, isNotNull); | 4909 expect(expression.operator, isNotNull); |
| 5109 expect(expression.operator.type, TokenType.AMPERSAND); | 4910 expect(expression.operator.type, TokenType.AMPERSAND); |
| 5110 expect(expression.rightOperand, isNotNull); | 4911 expect(expression.rightOperand, isNotNull); |
| 5111 } | 4912 } |
| 5112 | 4913 |
| 5113 void test_parseBitwiseOrExpression_normal() { | 4914 void test_parseBitwiseOrExpression_normal() { |
| 5114 BinaryExpression expression = | 4915 BinaryExpression expression = parse4("parseBitwiseOrExpression", "x | y"); |
| 5115 ParserTestCase.parse4("parseBitwiseOrExpression", "x | y"); | |
| 5116 expect(expression.leftOperand, isNotNull); | 4916 expect(expression.leftOperand, isNotNull); |
| 5117 expect(expression.operator, isNotNull); | 4917 expect(expression.operator, isNotNull); |
| 5118 expect(expression.operator.type, TokenType.BAR); | 4918 expect(expression.operator.type, TokenType.BAR); |
| 5119 expect(expression.rightOperand, isNotNull); | 4919 expect(expression.rightOperand, isNotNull); |
| 5120 } | 4920 } |
| 5121 | 4921 |
| 5122 void test_parseBitwiseOrExpression_super() { | 4922 void test_parseBitwiseOrExpression_super() { |
| 5123 BinaryExpression expression = | 4923 BinaryExpression expression = |
| 5124 ParserTestCase.parse4("parseBitwiseOrExpression", "super | y"); | 4924 parse4("parseBitwiseOrExpression", "super | y"); |
| 5125 EngineTestCase.assertInstanceOf((obj) => obj is SuperExpression, | 4925 EngineTestCase.assertInstanceOf((obj) => obj is SuperExpression, |
| 5126 SuperExpression, expression.leftOperand); | 4926 SuperExpression, expression.leftOperand); |
| 5127 expect(expression.operator, isNotNull); | 4927 expect(expression.operator, isNotNull); |
| 5128 expect(expression.operator.type, TokenType.BAR); | 4928 expect(expression.operator.type, TokenType.BAR); |
| 5129 expect(expression.rightOperand, isNotNull); | 4929 expect(expression.rightOperand, isNotNull); |
| 5130 } | 4930 } |
| 5131 | 4931 |
| 5132 void test_parseBitwiseXorExpression_normal() { | 4932 void test_parseBitwiseXorExpression_normal() { |
| 5133 BinaryExpression expression = | 4933 BinaryExpression expression = parse4("parseBitwiseXorExpression", "x ^ y"); |
| 5134 ParserTestCase.parse4("parseBitwiseXorExpression", "x ^ y"); | |
| 5135 expect(expression.leftOperand, isNotNull); | 4934 expect(expression.leftOperand, isNotNull); |
| 5136 expect(expression.operator, isNotNull); | 4935 expect(expression.operator, isNotNull); |
| 5137 expect(expression.operator.type, TokenType.CARET); | 4936 expect(expression.operator.type, TokenType.CARET); |
| 5138 expect(expression.rightOperand, isNotNull); | 4937 expect(expression.rightOperand, isNotNull); |
| 5139 } | 4938 } |
| 5140 | 4939 |
| 5141 void test_parseBitwiseXorExpression_super() { | 4940 void test_parseBitwiseXorExpression_super() { |
| 5142 BinaryExpression expression = | 4941 BinaryExpression expression = |
| 5143 ParserTestCase.parse4("parseBitwiseXorExpression", "super ^ y"); | 4942 parse4("parseBitwiseXorExpression", "super ^ y"); |
| 5144 EngineTestCase.assertInstanceOf((obj) => obj is SuperExpression, | 4943 EngineTestCase.assertInstanceOf((obj) => obj is SuperExpression, |
| 5145 SuperExpression, expression.leftOperand); | 4944 SuperExpression, expression.leftOperand); |
| 5146 expect(expression.operator, isNotNull); | 4945 expect(expression.operator, isNotNull); |
| 5147 expect(expression.operator.type, TokenType.CARET); | 4946 expect(expression.operator.type, TokenType.CARET); |
| 5148 expect(expression.rightOperand, isNotNull); | 4947 expect(expression.rightOperand, isNotNull); |
| 5149 } | 4948 } |
| 5150 | 4949 |
| 5151 void test_parseBlock_empty() { | 4950 void test_parseBlock_empty() { |
| 5152 Block block = ParserTestCase.parse4("parseBlock", "{}"); | 4951 Block block = parse4("parseBlock", "{}"); |
| 5153 expect(block.leftBracket, isNotNull); | 4952 expect(block.leftBracket, isNotNull); |
| 5154 expect(block.statements, hasLength(0)); | 4953 expect(block.statements, hasLength(0)); |
| 5155 expect(block.rightBracket, isNotNull); | 4954 expect(block.rightBracket, isNotNull); |
| 5156 } | 4955 } |
| 5157 | 4956 |
| 5158 void test_parseBlock_nonEmpty() { | 4957 void test_parseBlock_nonEmpty() { |
| 5159 Block block = ParserTestCase.parse4("parseBlock", "{;}"); | 4958 Block block = parse4("parseBlock", "{;}"); |
| 5160 expect(block.leftBracket, isNotNull); | 4959 expect(block.leftBracket, isNotNull); |
| 5161 expect(block.statements, hasLength(1)); | 4960 expect(block.statements, hasLength(1)); |
| 5162 expect(block.rightBracket, isNotNull); | 4961 expect(block.rightBracket, isNotNull); |
| 5163 } | 4962 } |
| 5164 | 4963 |
| 5165 void test_parseBreakStatement_label() { | 4964 void test_parseBreakStatement_label() { |
| 5166 BreakStatement statement = | 4965 BreakStatement statement = parse4("parseBreakStatement", "break foo;"); |
| 5167 ParserTestCase.parse4("parseBreakStatement", "break foo;"); | |
| 5168 expect(statement.breakKeyword, isNotNull); | 4966 expect(statement.breakKeyword, isNotNull); |
| 5169 expect(statement.label, isNotNull); | 4967 expect(statement.label, isNotNull); |
| 5170 expect(statement.semicolon, isNotNull); | 4968 expect(statement.semicolon, isNotNull); |
| 5171 } | 4969 } |
| 5172 | 4970 |
| 5173 void test_parseBreakStatement_noLabel() { | 4971 void test_parseBreakStatement_noLabel() { |
| 5174 BreakStatement statement = ParserTestCase.parse4("parseBreakStatement", | 4972 BreakStatement statement = parse4("parseBreakStatement", "break;", |
| 5175 "break;", [ParserErrorCode.BREAK_OUTSIDE_OF_LOOP]); | 4973 [ParserErrorCode.BREAK_OUTSIDE_OF_LOOP]); |
| 5176 expect(statement.breakKeyword, isNotNull); | 4974 expect(statement.breakKeyword, isNotNull); |
| 5177 expect(statement.label, isNull); | 4975 expect(statement.label, isNull); |
| 5178 expect(statement.semicolon, isNotNull); | 4976 expect(statement.semicolon, isNotNull); |
| 5179 } | 4977 } |
| 5180 | 4978 |
| 5181 void test_parseCascadeSection_i() { | 4979 void test_parseCascadeSection_i() { |
| 5182 IndexExpression section = | 4980 IndexExpression section = parse4("parseCascadeSection", "..[i]"); |
| 5183 ParserTestCase.parse4("parseCascadeSection", "..[i]"); | |
| 5184 expect(section.target, isNull); | 4981 expect(section.target, isNull); |
| 5185 expect(section.leftBracket, isNotNull); | 4982 expect(section.leftBracket, isNotNull); |
| 5186 expect(section.index, isNotNull); | 4983 expect(section.index, isNotNull); |
| 5187 expect(section.rightBracket, isNotNull); | 4984 expect(section.rightBracket, isNotNull); |
| 5188 } | 4985 } |
| 5189 | 4986 |
| 5190 void test_parseCascadeSection_ia() { | 4987 void test_parseCascadeSection_ia() { |
| 5191 FunctionExpressionInvocation section = | 4988 FunctionExpressionInvocation section = |
| 5192 ParserTestCase.parse4("parseCascadeSection", "..[i](b)"); | 4989 parse4("parseCascadeSection", "..[i](b)"); |
| 5193 EngineTestCase.assertInstanceOf( | 4990 EngineTestCase.assertInstanceOf( |
| 5194 (obj) => obj is IndexExpression, IndexExpression, section.function); | 4991 (obj) => obj is IndexExpression, IndexExpression, section.function); |
| 5195 expect(section.argumentList, isNotNull); | 4992 expect(section.argumentList, isNotNull); |
| 5196 } | 4993 } |
| 5197 | 4994 |
| 5198 void test_parseCascadeSection_ii() { | 4995 void test_parseCascadeSection_ii() { |
| 5199 MethodInvocation section = | 4996 MethodInvocation section = parse4("parseCascadeSection", "..a(b).c(d)"); |
| 5200 ParserTestCase.parse4("parseCascadeSection", "..a(b).c(d)"); | |
| 5201 EngineTestCase.assertInstanceOf( | 4997 EngineTestCase.assertInstanceOf( |
| 5202 (obj) => obj is MethodInvocation, MethodInvocation, section.target); | 4998 (obj) => obj is MethodInvocation, MethodInvocation, section.target); |
| 5203 expect(section.period, isNotNull); | 4999 expect(section.period, isNotNull); |
| 5204 expect(section.methodName, isNotNull); | 5000 expect(section.methodName, isNotNull); |
| 5205 expect(section.argumentList, isNotNull); | 5001 expect(section.argumentList, isNotNull); |
| 5206 expect(section.argumentList.arguments, hasLength(1)); | 5002 expect(section.argumentList.arguments, hasLength(1)); |
| 5207 } | 5003 } |
| 5208 | 5004 |
| 5209 void test_parseCascadeSection_p() { | 5005 void test_parseCascadeSection_p() { |
| 5210 PropertyAccess section = | 5006 PropertyAccess section = parse4("parseCascadeSection", "..a"); |
| 5211 ParserTestCase.parse4("parseCascadeSection", "..a"); | |
| 5212 expect(section.target, isNull); | 5007 expect(section.target, isNull); |
| 5213 expect(section.operator, isNotNull); | 5008 expect(section.operator, isNotNull); |
| 5214 expect(section.propertyName, isNotNull); | 5009 expect(section.propertyName, isNotNull); |
| 5215 } | 5010 } |
| 5216 | 5011 |
| 5217 void test_parseCascadeSection_p_assign() { | 5012 void test_parseCascadeSection_p_assign() { |
| 5218 AssignmentExpression section = | 5013 AssignmentExpression section = parse4("parseCascadeSection", "..a = 3"); |
| 5219 ParserTestCase.parse4("parseCascadeSection", "..a = 3"); | |
| 5220 expect(section.leftHandSide, isNotNull); | 5014 expect(section.leftHandSide, isNotNull); |
| 5221 expect(section.operator, isNotNull); | 5015 expect(section.operator, isNotNull); |
| 5222 Expression rhs = section.rightHandSide; | 5016 Expression rhs = section.rightHandSide; |
| 5223 expect(rhs, isNotNull); | 5017 expect(rhs, isNotNull); |
| 5224 } | 5018 } |
| 5225 | 5019 |
| 5226 void test_parseCascadeSection_p_assign_withCascade() { | 5020 void test_parseCascadeSection_p_assign_withCascade() { |
| 5227 AssignmentExpression section = | 5021 AssignmentExpression section = |
| 5228 ParserTestCase.parse4("parseCascadeSection", "..a = 3..m()"); | 5022 parse4("parseCascadeSection", "..a = 3..m()"); |
| 5229 expect(section.leftHandSide, isNotNull); | 5023 expect(section.leftHandSide, isNotNull); |
| 5230 expect(section.operator, isNotNull); | 5024 expect(section.operator, isNotNull); |
| 5231 Expression rhs = section.rightHandSide; | 5025 Expression rhs = section.rightHandSide; |
| 5232 EngineTestCase | 5026 EngineTestCase.assertInstanceOf( |
| 5233 .assertInstanceOf((obj) => obj is IntegerLiteral, IntegerLiteral, rhs); | 5027 (obj) => obj is IntegerLiteral, IntegerLiteral, rhs); |
| 5234 } | 5028 } |
| 5235 | 5029 |
| 5236 void test_parseCascadeSection_p_builtIn() { | 5030 void test_parseCascadeSection_p_builtIn() { |
| 5237 PropertyAccess section = | 5031 PropertyAccess section = parse4("parseCascadeSection", "..as"); |
| 5238 ParserTestCase.parse4("parseCascadeSection", "..as"); | |
| 5239 expect(section.target, isNull); | 5032 expect(section.target, isNull); |
| 5240 expect(section.operator, isNotNull); | 5033 expect(section.operator, isNotNull); |
| 5241 expect(section.propertyName, isNotNull); | 5034 expect(section.propertyName, isNotNull); |
| 5242 } | 5035 } |
| 5243 | 5036 |
| 5244 void test_parseCascadeSection_pa() { | 5037 void test_parseCascadeSection_pa() { |
| 5245 MethodInvocation section = | 5038 MethodInvocation section = parse4("parseCascadeSection", "..a(b)"); |
| 5246 ParserTestCase.parse4("parseCascadeSection", "..a(b)"); | |
| 5247 expect(section.target, isNull); | 5039 expect(section.target, isNull); |
| 5248 expect(section.period, isNotNull); | 5040 expect(section.period, isNotNull); |
| 5249 expect(section.methodName, isNotNull); | 5041 expect(section.methodName, isNotNull); |
| 5250 expect(section.argumentList, isNotNull); | 5042 expect(section.argumentList, isNotNull); |
| 5251 expect(section.argumentList.arguments, hasLength(1)); | 5043 expect(section.argumentList.arguments, hasLength(1)); |
| 5252 } | 5044 } |
| 5253 | 5045 |
| 5254 void test_parseCascadeSection_paa() { | 5046 void test_parseCascadeSection_paa() { |
| 5255 FunctionExpressionInvocation section = | 5047 FunctionExpressionInvocation section = |
| 5256 ParserTestCase.parse4("parseCascadeSection", "..a(b)(c)"); | 5048 parse4("parseCascadeSection", "..a(b)(c)"); |
| 5257 EngineTestCase.assertInstanceOf( | 5049 EngineTestCase.assertInstanceOf( |
| 5258 (obj) => obj is MethodInvocation, MethodInvocation, section.function); | 5050 (obj) => obj is MethodInvocation, MethodInvocation, section.function); |
| 5259 expect(section.argumentList, isNotNull); | 5051 expect(section.argumentList, isNotNull); |
| 5260 expect(section.argumentList.arguments, hasLength(1)); | 5052 expect(section.argumentList.arguments, hasLength(1)); |
| 5261 } | 5053 } |
| 5262 | 5054 |
| 5263 void test_parseCascadeSection_paapaa() { | 5055 void test_parseCascadeSection_paapaa() { |
| 5264 FunctionExpressionInvocation section = | 5056 FunctionExpressionInvocation section = |
| 5265 ParserTestCase.parse4("parseCascadeSection", "..a(b)(c).d(e)(f)"); | 5057 parse4("parseCascadeSection", "..a(b)(c).d(e)(f)"); |
| 5266 EngineTestCase.assertInstanceOf( | 5058 EngineTestCase.assertInstanceOf( |
| 5267 (obj) => obj is MethodInvocation, MethodInvocation, section.function); | 5059 (obj) => obj is MethodInvocation, MethodInvocation, section.function); |
| 5268 expect(section.argumentList, isNotNull); | 5060 expect(section.argumentList, isNotNull); |
| 5269 expect(section.argumentList.arguments, hasLength(1)); | 5061 expect(section.argumentList.arguments, hasLength(1)); |
| 5270 } | 5062 } |
| 5271 | 5063 |
| 5272 void test_parseCascadeSection_pap() { | 5064 void test_parseCascadeSection_pap() { |
| 5273 PropertyAccess section = | 5065 PropertyAccess section = parse4("parseCascadeSection", "..a(b).c"); |
| 5274 ParserTestCase.parse4("parseCascadeSection", "..a(b).c"); | |
| 5275 expect(section.target, isNotNull); | 5066 expect(section.target, isNotNull); |
| 5276 expect(section.operator, isNotNull); | 5067 expect(section.operator, isNotNull); |
| 5277 expect(section.propertyName, isNotNull); | 5068 expect(section.propertyName, isNotNull); |
| 5278 } | 5069 } |
| 5279 | 5070 |
| 5280 void test_parseClassDeclaration_abstract() { | 5071 void test_parseClassDeclaration_abstract() { |
| 5281 ClassDeclaration declaration = ParserTestCase.parse("parseClassDeclaration", | 5072 ClassDeclaration declaration = parse("parseClassDeclaration", <Object>[ |
| 5282 <Object>[ | |
| 5283 emptyCommentAndMetadata(), | 5073 emptyCommentAndMetadata(), |
| 5284 TokenFactory.tokenFromKeyword(Keyword.ABSTRACT) | 5074 TokenFactory.tokenFromKeyword(Keyword.ABSTRACT) |
| 5285 ], "class A {}"); | 5075 ], "class A {}"); |
| 5286 expect(declaration.documentationComment, isNull); | 5076 expect(declaration.documentationComment, isNull); |
| 5287 expect(declaration.abstractKeyword, isNotNull); | 5077 expect(declaration.abstractKeyword, isNotNull); |
| 5288 expect(declaration.extendsClause, isNull); | 5078 expect(declaration.extendsClause, isNull); |
| 5289 expect(declaration.implementsClause, isNull); | 5079 expect(declaration.implementsClause, isNull); |
| 5290 expect(declaration.classKeyword, isNotNull); | 5080 expect(declaration.classKeyword, isNotNull); |
| 5291 expect(declaration.leftBracket, isNotNull); | 5081 expect(declaration.leftBracket, isNotNull); |
| 5292 expect(declaration.name, isNotNull); | 5082 expect(declaration.name, isNotNull); |
| 5293 expect(declaration.members, hasLength(0)); | 5083 expect(declaration.members, hasLength(0)); |
| 5294 expect(declaration.rightBracket, isNotNull); | 5084 expect(declaration.rightBracket, isNotNull); |
| 5295 expect(declaration.typeParameters, isNull); | 5085 expect(declaration.typeParameters, isNull); |
| 5296 } | 5086 } |
| 5297 | 5087 |
| 5298 void test_parseClassDeclaration_empty() { | 5088 void test_parseClassDeclaration_empty() { |
| 5299 ClassDeclaration declaration = ParserTestCase.parse("parseClassDeclaration", | 5089 ClassDeclaration declaration = parse("parseClassDeclaration", <Object>[ |
| 5300 <Object>[emptyCommentAndMetadata(), null], "class A {}"); | 5090 emptyCommentAndMetadata(), |
| 5091 null |
| 5092 ], "class A {}"); |
| 5301 expect(declaration.documentationComment, isNull); | 5093 expect(declaration.documentationComment, isNull); |
| 5302 expect(declaration.abstractKeyword, isNull); | 5094 expect(declaration.abstractKeyword, isNull); |
| 5303 expect(declaration.extendsClause, isNull); | 5095 expect(declaration.extendsClause, isNull); |
| 5304 expect(declaration.implementsClause, isNull); | 5096 expect(declaration.implementsClause, isNull); |
| 5305 expect(declaration.classKeyword, isNotNull); | 5097 expect(declaration.classKeyword, isNotNull); |
| 5306 expect(declaration.leftBracket, isNotNull); | 5098 expect(declaration.leftBracket, isNotNull); |
| 5307 expect(declaration.name, isNotNull); | 5099 expect(declaration.name, isNotNull); |
| 5308 expect(declaration.members, hasLength(0)); | 5100 expect(declaration.members, hasLength(0)); |
| 5309 expect(declaration.rightBracket, isNotNull); | 5101 expect(declaration.rightBracket, isNotNull); |
| 5310 expect(declaration.typeParameters, isNull); | 5102 expect(declaration.typeParameters, isNull); |
| 5311 } | 5103 } |
| 5312 | 5104 |
| 5313 void test_parseClassDeclaration_extends() { | 5105 void test_parseClassDeclaration_extends() { |
| 5314 ClassDeclaration declaration = ParserTestCase.parse("parseClassDeclaration", | 5106 ClassDeclaration declaration = parse("parseClassDeclaration", <Object>[ |
| 5315 <Object>[emptyCommentAndMetadata(), null], "class A extends B {}"); | 5107 emptyCommentAndMetadata(), |
| 5108 null |
| 5109 ], "class A extends B {}"); |
| 5316 expect(declaration.documentationComment, isNull); | 5110 expect(declaration.documentationComment, isNull); |
| 5317 expect(declaration.abstractKeyword, isNull); | 5111 expect(declaration.abstractKeyword, isNull); |
| 5318 expect(declaration.extendsClause, isNotNull); | 5112 expect(declaration.extendsClause, isNotNull); |
| 5319 expect(declaration.implementsClause, isNull); | 5113 expect(declaration.implementsClause, isNull); |
| 5320 expect(declaration.classKeyword, isNotNull); | 5114 expect(declaration.classKeyword, isNotNull); |
| 5321 expect(declaration.leftBracket, isNotNull); | 5115 expect(declaration.leftBracket, isNotNull); |
| 5322 expect(declaration.name, isNotNull); | 5116 expect(declaration.name, isNotNull); |
| 5323 expect(declaration.members, hasLength(0)); | 5117 expect(declaration.members, hasLength(0)); |
| 5324 expect(declaration.rightBracket, isNotNull); | 5118 expect(declaration.rightBracket, isNotNull); |
| 5325 expect(declaration.typeParameters, isNull); | 5119 expect(declaration.typeParameters, isNull); |
| 5326 } | 5120 } |
| 5327 | 5121 |
| 5328 void test_parseClassDeclaration_extendsAndImplements() { | 5122 void test_parseClassDeclaration_extendsAndImplements() { |
| 5329 ClassDeclaration declaration = ParserTestCase.parse("parseClassDeclaration", | 5123 ClassDeclaration declaration = parse("parseClassDeclaration", <Object>[ |
| 5330 <Object>[ | |
| 5331 emptyCommentAndMetadata(), | 5124 emptyCommentAndMetadata(), |
| 5332 null | 5125 null |
| 5333 ], "class A extends B implements C {}"); | 5126 ], "class A extends B implements C {}"); |
| 5334 expect(declaration.documentationComment, isNull); | 5127 expect(declaration.documentationComment, isNull); |
| 5335 expect(declaration.abstractKeyword, isNull); | 5128 expect(declaration.abstractKeyword, isNull); |
| 5336 expect(declaration.extendsClause, isNotNull); | 5129 expect(declaration.extendsClause, isNotNull); |
| 5337 expect(declaration.implementsClause, isNotNull); | 5130 expect(declaration.implementsClause, isNotNull); |
| 5338 expect(declaration.classKeyword, isNotNull); | 5131 expect(declaration.classKeyword, isNotNull); |
| 5339 expect(declaration.leftBracket, isNotNull); | 5132 expect(declaration.leftBracket, isNotNull); |
| 5340 expect(declaration.name, isNotNull); | 5133 expect(declaration.name, isNotNull); |
| 5341 expect(declaration.members, hasLength(0)); | 5134 expect(declaration.members, hasLength(0)); |
| 5342 expect(declaration.rightBracket, isNotNull); | 5135 expect(declaration.rightBracket, isNotNull); |
| 5343 expect(declaration.typeParameters, isNull); | 5136 expect(declaration.typeParameters, isNull); |
| 5344 } | 5137 } |
| 5345 | 5138 |
| 5346 void test_parseClassDeclaration_extendsAndWith() { | 5139 void test_parseClassDeclaration_extendsAndWith() { |
| 5347 ClassDeclaration declaration = ParserTestCase.parse("parseClassDeclaration", | 5140 ClassDeclaration declaration = parse("parseClassDeclaration", <Object>[ |
| 5348 <Object>[ | |
| 5349 emptyCommentAndMetadata(), | 5141 emptyCommentAndMetadata(), |
| 5350 null | 5142 null |
| 5351 ], "class A extends B with C {}"); | 5143 ], "class A extends B with C {}"); |
| 5352 expect(declaration.documentationComment, isNull); | 5144 expect(declaration.documentationComment, isNull); |
| 5353 expect(declaration.abstractKeyword, isNull); | 5145 expect(declaration.abstractKeyword, isNull); |
| 5354 expect(declaration.classKeyword, isNotNull); | 5146 expect(declaration.classKeyword, isNotNull); |
| 5355 expect(declaration.name, isNotNull); | 5147 expect(declaration.name, isNotNull); |
| 5356 expect(declaration.typeParameters, isNull); | 5148 expect(declaration.typeParameters, isNull); |
| 5357 expect(declaration.extendsClause, isNotNull); | 5149 expect(declaration.extendsClause, isNotNull); |
| 5358 expect(declaration.withClause, isNotNull); | 5150 expect(declaration.withClause, isNotNull); |
| 5359 expect(declaration.implementsClause, isNull); | 5151 expect(declaration.implementsClause, isNull); |
| 5360 expect(declaration.leftBracket, isNotNull); | 5152 expect(declaration.leftBracket, isNotNull); |
| 5361 expect(declaration.members, hasLength(0)); | 5153 expect(declaration.members, hasLength(0)); |
| 5362 expect(declaration.rightBracket, isNotNull); | 5154 expect(declaration.rightBracket, isNotNull); |
| 5363 } | 5155 } |
| 5364 | 5156 |
| 5365 void test_parseClassDeclaration_extendsAndWithAndImplements() { | 5157 void test_parseClassDeclaration_extendsAndWithAndImplements() { |
| 5366 ClassDeclaration declaration = ParserTestCase.parse("parseClassDeclaration", | 5158 ClassDeclaration declaration = parse("parseClassDeclaration", <Object>[ |
| 5367 <Object>[ | |
| 5368 emptyCommentAndMetadata(), | 5159 emptyCommentAndMetadata(), |
| 5369 null | 5160 null |
| 5370 ], "class A extends B with C implements D {}"); | 5161 ], "class A extends B with C implements D {}"); |
| 5371 expect(declaration.documentationComment, isNull); | 5162 expect(declaration.documentationComment, isNull); |
| 5372 expect(declaration.abstractKeyword, isNull); | 5163 expect(declaration.abstractKeyword, isNull); |
| 5373 expect(declaration.classKeyword, isNotNull); | 5164 expect(declaration.classKeyword, isNotNull); |
| 5374 expect(declaration.name, isNotNull); | 5165 expect(declaration.name, isNotNull); |
| 5375 expect(declaration.typeParameters, isNull); | 5166 expect(declaration.typeParameters, isNull); |
| 5376 expect(declaration.extendsClause, isNotNull); | 5167 expect(declaration.extendsClause, isNotNull); |
| 5377 expect(declaration.withClause, isNotNull); | 5168 expect(declaration.withClause, isNotNull); |
| 5378 expect(declaration.implementsClause, isNotNull); | 5169 expect(declaration.implementsClause, isNotNull); |
| 5379 expect(declaration.leftBracket, isNotNull); | 5170 expect(declaration.leftBracket, isNotNull); |
| 5380 expect(declaration.members, hasLength(0)); | 5171 expect(declaration.members, hasLength(0)); |
| 5381 expect(declaration.rightBracket, isNotNull); | 5172 expect(declaration.rightBracket, isNotNull); |
| 5382 } | 5173 } |
| 5383 | 5174 |
| 5384 void test_parseClassDeclaration_implements() { | 5175 void test_parseClassDeclaration_implements() { |
| 5385 ClassDeclaration declaration = ParserTestCase.parse("parseClassDeclaration", | 5176 ClassDeclaration declaration = parse("parseClassDeclaration", <Object>[ |
| 5386 <Object>[emptyCommentAndMetadata(), null], "class A implements C {}"); | 5177 emptyCommentAndMetadata(), |
| 5178 null |
| 5179 ], "class A implements C {}"); |
| 5387 expect(declaration.documentationComment, isNull); | 5180 expect(declaration.documentationComment, isNull); |
| 5388 expect(declaration.abstractKeyword, isNull); | 5181 expect(declaration.abstractKeyword, isNull); |
| 5389 expect(declaration.extendsClause, isNull); | 5182 expect(declaration.extendsClause, isNull); |
| 5390 expect(declaration.implementsClause, isNotNull); | 5183 expect(declaration.implementsClause, isNotNull); |
| 5391 expect(declaration.classKeyword, isNotNull); | 5184 expect(declaration.classKeyword, isNotNull); |
| 5392 expect(declaration.leftBracket, isNotNull); | 5185 expect(declaration.leftBracket, isNotNull); |
| 5393 expect(declaration.name, isNotNull); | 5186 expect(declaration.name, isNotNull); |
| 5394 expect(declaration.members, hasLength(0)); | 5187 expect(declaration.members, hasLength(0)); |
| 5395 expect(declaration.rightBracket, isNotNull); | 5188 expect(declaration.rightBracket, isNotNull); |
| 5396 expect(declaration.typeParameters, isNull); | 5189 expect(declaration.typeParameters, isNull); |
| 5397 } | 5190 } |
| 5398 | 5191 |
| 5399 void test_parseClassDeclaration_native() { | 5192 void test_parseClassDeclaration_native() { |
| 5400 ClassDeclaration declaration = ParserTestCase.parse("parseClassDeclaration", | 5193 ClassDeclaration declaration = parse("parseClassDeclaration", <Object>[ |
| 5401 <Object>[ | |
| 5402 emptyCommentAndMetadata(), | 5194 emptyCommentAndMetadata(), |
| 5403 null | 5195 null |
| 5404 ], "class A native 'nativeValue' {}"); | 5196 ], "class A native 'nativeValue' {}"); |
| 5405 NativeClause nativeClause = declaration.nativeClause; | 5197 NativeClause nativeClause = declaration.nativeClause; |
| 5406 expect(nativeClause, isNotNull); | 5198 expect(nativeClause, isNotNull); |
| 5407 expect(nativeClause.nativeKeyword, isNotNull); | 5199 expect(nativeClause.nativeKeyword, isNotNull); |
| 5408 expect(nativeClause.name.stringValue, "nativeValue"); | 5200 expect(nativeClause.name.stringValue, "nativeValue"); |
| 5409 expect(nativeClause.beginToken, same(nativeClause.nativeKeyword)); | 5201 expect(nativeClause.beginToken, same(nativeClause.nativeKeyword)); |
| 5410 expect(nativeClause.endToken, same(nativeClause.name.endToken)); | 5202 expect(nativeClause.endToken, same(nativeClause.name.endToken)); |
| 5411 } | 5203 } |
| 5412 | 5204 |
| 5413 void test_parseClassDeclaration_nonEmpty() { | 5205 void test_parseClassDeclaration_nonEmpty() { |
| 5414 ClassDeclaration declaration = ParserTestCase.parse("parseClassDeclaration", | 5206 ClassDeclaration declaration = parse("parseClassDeclaration", <Object>[ |
| 5415 <Object>[emptyCommentAndMetadata(), null], "class A {var f;}"); | 5207 emptyCommentAndMetadata(), |
| 5208 null |
| 5209 ], "class A {var f;}"); |
| 5416 expect(declaration.documentationComment, isNull); | 5210 expect(declaration.documentationComment, isNull); |
| 5417 expect(declaration.abstractKeyword, isNull); | 5211 expect(declaration.abstractKeyword, isNull); |
| 5418 expect(declaration.extendsClause, isNull); | 5212 expect(declaration.extendsClause, isNull); |
| 5419 expect(declaration.implementsClause, isNull); | 5213 expect(declaration.implementsClause, isNull); |
| 5420 expect(declaration.classKeyword, isNotNull); | 5214 expect(declaration.classKeyword, isNotNull); |
| 5421 expect(declaration.leftBracket, isNotNull); | 5215 expect(declaration.leftBracket, isNotNull); |
| 5422 expect(declaration.name, isNotNull); | 5216 expect(declaration.name, isNotNull); |
| 5423 expect(declaration.members, hasLength(1)); | 5217 expect(declaration.members, hasLength(1)); |
| 5424 expect(declaration.rightBracket, isNotNull); | 5218 expect(declaration.rightBracket, isNotNull); |
| 5425 expect(declaration.typeParameters, isNull); | 5219 expect(declaration.typeParameters, isNull); |
| 5426 } | 5220 } |
| 5427 | 5221 |
| 5428 void test_parseClassDeclaration_typeAlias_implementsC() { | 5222 void test_parseClassDeclaration_typeAlias_implementsC() { |
| 5429 ClassTypeAlias typeAlias = ParserTestCase.parse("parseClassDeclaration", | 5223 ClassTypeAlias typeAlias = parse("parseClassDeclaration", <Object>[ |
| 5430 <Object>[ | |
| 5431 emptyCommentAndMetadata(), | 5224 emptyCommentAndMetadata(), |
| 5432 null | 5225 null |
| 5433 ], "class A = Object with B implements C;"); | 5226 ], "class A = Object with B implements C;"); |
| 5434 expect(typeAlias.typedefKeyword, isNotNull); | 5227 expect(typeAlias.typedefKeyword, isNotNull); |
| 5435 expect(typeAlias.name, isNotNull); | 5228 expect(typeAlias.name, isNotNull); |
| 5436 expect(typeAlias.typeParameters, isNull); | 5229 expect(typeAlias.typeParameters, isNull); |
| 5437 expect(typeAlias.withClause, isNotNull); | 5230 expect(typeAlias.withClause, isNotNull); |
| 5438 expect(typeAlias.implementsClause, isNotNull); | 5231 expect(typeAlias.implementsClause, isNotNull); |
| 5439 expect(typeAlias.implementsClause.implementsKeyword, isNotNull); | 5232 expect(typeAlias.implementsClause.implementsKeyword, isNotNull); |
| 5440 expect(typeAlias.implementsClause.interfaces.length, 1); | 5233 expect(typeAlias.implementsClause.interfaces.length, 1); |
| 5441 expect(typeAlias.semicolon, isNotNull); | 5234 expect(typeAlias.semicolon, isNotNull); |
| 5442 } | 5235 } |
| 5443 | 5236 |
| 5444 void test_parseClassDeclaration_typeAlias_withB() { | 5237 void test_parseClassDeclaration_typeAlias_withB() { |
| 5445 ClassTypeAlias typeAlias = ParserTestCase.parse("parseClassDeclaration", | 5238 ClassTypeAlias typeAlias = parse("parseClassDeclaration", <Object>[ |
| 5446 <Object>[emptyCommentAndMetadata(), null], "class A = Object with B;"); | 5239 emptyCommentAndMetadata(), |
| 5240 null |
| 5241 ], "class A = Object with B;"); |
| 5447 expect(typeAlias.typedefKeyword, isNotNull); | 5242 expect(typeAlias.typedefKeyword, isNotNull); |
| 5448 expect(typeAlias.name, isNotNull); | 5243 expect(typeAlias.name, isNotNull); |
| 5449 expect(typeAlias.typeParameters, isNull); | 5244 expect(typeAlias.typeParameters, isNull); |
| 5450 expect(typeAlias.withClause, isNotNull); | 5245 expect(typeAlias.withClause, isNotNull); |
| 5451 expect(typeAlias.withClause.withKeyword, isNotNull); | 5246 expect(typeAlias.withClause.withKeyword, isNotNull); |
| 5452 expect(typeAlias.withClause.mixinTypes.length, 1); | 5247 expect(typeAlias.withClause.mixinTypes.length, 1); |
| 5453 expect(typeAlias.implementsClause, isNull); | 5248 expect(typeAlias.implementsClause, isNull); |
| 5454 expect(typeAlias.semicolon, isNotNull); | 5249 expect(typeAlias.semicolon, isNotNull); |
| 5455 } | 5250 } |
| 5456 | 5251 |
| 5457 void test_parseClassDeclaration_typeParameters() { | 5252 void test_parseClassDeclaration_typeParameters() { |
| 5458 ClassDeclaration declaration = ParserTestCase.parse("parseClassDeclaration", | 5253 ClassDeclaration declaration = parse("parseClassDeclaration", <Object>[ |
| 5459 <Object>[emptyCommentAndMetadata(), null], "class A<B> {}"); | 5254 emptyCommentAndMetadata(), |
| 5255 null |
| 5256 ], "class A<B> {}"); |
| 5460 expect(declaration.documentationComment, isNull); | 5257 expect(declaration.documentationComment, isNull); |
| 5461 expect(declaration.abstractKeyword, isNull); | 5258 expect(declaration.abstractKeyword, isNull); |
| 5462 expect(declaration.extendsClause, isNull); | 5259 expect(declaration.extendsClause, isNull); |
| 5463 expect(declaration.implementsClause, isNull); | 5260 expect(declaration.implementsClause, isNull); |
| 5464 expect(declaration.classKeyword, isNotNull); | 5261 expect(declaration.classKeyword, isNotNull); |
| 5465 expect(declaration.leftBracket, isNotNull); | 5262 expect(declaration.leftBracket, isNotNull); |
| 5466 expect(declaration.name, isNotNull); | 5263 expect(declaration.name, isNotNull); |
| 5467 expect(declaration.members, hasLength(0)); | 5264 expect(declaration.members, hasLength(0)); |
| 5468 expect(declaration.rightBracket, isNotNull); | 5265 expect(declaration.rightBracket, isNotNull); |
| 5469 expect(declaration.typeParameters, isNotNull); | 5266 expect(declaration.typeParameters, isNotNull); |
| 5470 expect(declaration.typeParameters.typeParameters, hasLength(1)); | 5267 expect(declaration.typeParameters.typeParameters, hasLength(1)); |
| 5471 } | 5268 } |
| 5472 | 5269 |
| 5473 void test_parseClassMember_constructor_withInitializers() { | 5270 void test_parseClassMember_constructor_withInitializers() { |
| 5474 // TODO(brianwilkerson) Test other kinds of class members: fields, getters | 5271 // TODO(brianwilkerson) Test other kinds of class members: fields, getters |
| 5475 // and setters. | 5272 // and setters. |
| 5476 ConstructorDeclaration constructor = ParserTestCase.parse( | 5273 ConstructorDeclaration constructor = parse("parseClassMember", |
| 5477 "parseClassMember", <Object>[ | 5274 <Object>["C"], "C(_, _\$, this.__) : _a = _ + _\$ {}"); |
| 5478 "C" | |
| 5479 ], "C(_, _\$, this.__) : _a = _ + _\$ {}"); | |
| 5480 expect(constructor.body, isNotNull); | 5275 expect(constructor.body, isNotNull); |
| 5481 expect(constructor.separator, isNotNull); | 5276 expect(constructor.separator, isNotNull); |
| 5482 expect(constructor.externalKeyword, isNull); | 5277 expect(constructor.externalKeyword, isNull); |
| 5483 expect(constructor.constKeyword, isNull); | 5278 expect(constructor.constKeyword, isNull); |
| 5484 expect(constructor.factoryKeyword, isNull); | 5279 expect(constructor.factoryKeyword, isNull); |
| 5485 expect(constructor.name, isNull); | 5280 expect(constructor.name, isNull); |
| 5486 expect(constructor.parameters, isNotNull); | 5281 expect(constructor.parameters, isNotNull); |
| 5487 expect(constructor.period, isNull); | 5282 expect(constructor.period, isNull); |
| 5488 expect(constructor.returnType, isNotNull); | 5283 expect(constructor.returnType, isNotNull); |
| 5489 expect(constructor.initializers, hasLength(1)); | 5284 expect(constructor.initializers, hasLength(1)); |
| 5490 } | 5285 } |
| 5491 | 5286 |
| 5492 void test_parseClassMember_field_instance_prefixedType() { | 5287 void test_parseClassMember_field_instance_prefixedType() { |
| 5493 FieldDeclaration field = | 5288 FieldDeclaration field = parse("parseClassMember", <Object>["C"], "p.A f;"); |
| 5494 ParserTestCase.parse("parseClassMember", <Object>["C"], "p.A f;"); | |
| 5495 expect(field.documentationComment, isNull); | 5289 expect(field.documentationComment, isNull); |
| 5496 expect(field.metadata, hasLength(0)); | 5290 expect(field.metadata, hasLength(0)); |
| 5497 expect(field.staticKeyword, isNull); | 5291 expect(field.staticKeyword, isNull); |
| 5498 VariableDeclarationList list = field.fields; | 5292 VariableDeclarationList list = field.fields; |
| 5499 expect(list, isNotNull); | 5293 expect(list, isNotNull); |
| 5500 NodeList<VariableDeclaration> variables = list.variables; | 5294 NodeList<VariableDeclaration> variables = list.variables; |
| 5501 expect(variables, hasLength(1)); | 5295 expect(variables, hasLength(1)); |
| 5502 VariableDeclaration variable = variables[0]; | 5296 VariableDeclaration variable = variables[0]; |
| 5503 expect(variable.name, isNotNull); | 5297 expect(variable.name, isNotNull); |
| 5504 } | 5298 } |
| 5505 | 5299 |
| 5506 void test_parseClassMember_field_namedGet() { | 5300 void test_parseClassMember_field_namedGet() { |
| 5507 FieldDeclaration field = | 5301 FieldDeclaration field = |
| 5508 ParserTestCase.parse("parseClassMember", <Object>["C"], "var get;"); | 5302 parse("parseClassMember", <Object>["C"], "var get;"); |
| 5509 expect(field.documentationComment, isNull); | 5303 expect(field.documentationComment, isNull); |
| 5510 expect(field.metadata, hasLength(0)); | 5304 expect(field.metadata, hasLength(0)); |
| 5511 expect(field.staticKeyword, isNull); | 5305 expect(field.staticKeyword, isNull); |
| 5512 VariableDeclarationList list = field.fields; | 5306 VariableDeclarationList list = field.fields; |
| 5513 expect(list, isNotNull); | 5307 expect(list, isNotNull); |
| 5514 NodeList<VariableDeclaration> variables = list.variables; | 5308 NodeList<VariableDeclaration> variables = list.variables; |
| 5515 expect(variables, hasLength(1)); | 5309 expect(variables, hasLength(1)); |
| 5516 VariableDeclaration variable = variables[0]; | 5310 VariableDeclaration variable = variables[0]; |
| 5517 expect(variable.name, isNotNull); | 5311 expect(variable.name, isNotNull); |
| 5518 } | 5312 } |
| 5519 | 5313 |
| 5520 void test_parseClassMember_field_namedOperator() { | 5314 void test_parseClassMember_field_namedOperator() { |
| 5521 FieldDeclaration field = ParserTestCase.parse( | 5315 FieldDeclaration field = |
| 5522 "parseClassMember", <Object>["C"], "var operator;"); | 5316 parse("parseClassMember", <Object>["C"], "var operator;"); |
| 5523 expect(field.documentationComment, isNull); | 5317 expect(field.documentationComment, isNull); |
| 5524 expect(field.metadata, hasLength(0)); | 5318 expect(field.metadata, hasLength(0)); |
| 5525 expect(field.staticKeyword, isNull); | 5319 expect(field.staticKeyword, isNull); |
| 5526 VariableDeclarationList list = field.fields; | 5320 VariableDeclarationList list = field.fields; |
| 5527 expect(list, isNotNull); | 5321 expect(list, isNotNull); |
| 5528 NodeList<VariableDeclaration> variables = list.variables; | 5322 NodeList<VariableDeclaration> variables = list.variables; |
| 5529 expect(variables, hasLength(1)); | 5323 expect(variables, hasLength(1)); |
| 5530 VariableDeclaration variable = variables[0]; | 5324 VariableDeclaration variable = variables[0]; |
| 5531 expect(variable.name, isNotNull); | 5325 expect(variable.name, isNotNull); |
| 5532 } | 5326 } |
| 5533 | 5327 |
| 5534 void test_parseClassMember_field_namedOperator_withAssignment() { | 5328 void test_parseClassMember_field_namedOperator_withAssignment() { |
| 5535 FieldDeclaration field = ParserTestCase.parse( | 5329 FieldDeclaration field = |
| 5536 "parseClassMember", <Object>["C"], "var operator = (5);"); | 5330 parse("parseClassMember", <Object>["C"], "var operator = (5);"); |
| 5537 expect(field.documentationComment, isNull); | 5331 expect(field.documentationComment, isNull); |
| 5538 expect(field.metadata, hasLength(0)); | 5332 expect(field.metadata, hasLength(0)); |
| 5539 expect(field.staticKeyword, isNull); | 5333 expect(field.staticKeyword, isNull); |
| 5540 VariableDeclarationList list = field.fields; | 5334 VariableDeclarationList list = field.fields; |
| 5541 expect(list, isNotNull); | 5335 expect(list, isNotNull); |
| 5542 NodeList<VariableDeclaration> variables = list.variables; | 5336 NodeList<VariableDeclaration> variables = list.variables; |
| 5543 expect(variables, hasLength(1)); | 5337 expect(variables, hasLength(1)); |
| 5544 VariableDeclaration variable = variables[0]; | 5338 VariableDeclaration variable = variables[0]; |
| 5545 expect(variable.name, isNotNull); | 5339 expect(variable.name, isNotNull); |
| 5546 expect(variable.initializer, isNotNull); | 5340 expect(variable.initializer, isNotNull); |
| 5547 } | 5341 } |
| 5548 | 5342 |
| 5549 void test_parseClassMember_field_namedSet() { | 5343 void test_parseClassMember_field_namedSet() { |
| 5550 FieldDeclaration field = | 5344 FieldDeclaration field = |
| 5551 ParserTestCase.parse("parseClassMember", <Object>["C"], "var set;"); | 5345 parse("parseClassMember", <Object>["C"], "var set;"); |
| 5552 expect(field.documentationComment, isNull); | 5346 expect(field.documentationComment, isNull); |
| 5553 expect(field.metadata, hasLength(0)); | 5347 expect(field.metadata, hasLength(0)); |
| 5554 expect(field.staticKeyword, isNull); | 5348 expect(field.staticKeyword, isNull); |
| 5555 VariableDeclarationList list = field.fields; | 5349 VariableDeclarationList list = field.fields; |
| 5556 expect(list, isNotNull); | 5350 expect(list, isNotNull); |
| 5557 NodeList<VariableDeclaration> variables = list.variables; | 5351 NodeList<VariableDeclaration> variables = list.variables; |
| 5558 expect(variables, hasLength(1)); | 5352 expect(variables, hasLength(1)); |
| 5559 VariableDeclaration variable = variables[0]; | 5353 VariableDeclaration variable = variables[0]; |
| 5560 expect(variable.name, isNotNull); | 5354 expect(variable.name, isNotNull); |
| 5561 } | 5355 } |
| 5562 | 5356 |
| 5563 void test_parseClassMember_getter_void() { | 5357 void test_parseClassMember_getter_void() { |
| 5564 MethodDeclaration method = ParserTestCase.parse( | 5358 MethodDeclaration method = |
| 5565 "parseClassMember", <Object>["C"], "void get g {}"); | 5359 parse("parseClassMember", <Object>["C"], "void get g {}"); |
| 5566 expect(method.documentationComment, isNull); | 5360 expect(method.documentationComment, isNull); |
| 5567 expect(method.externalKeyword, isNull); | 5361 expect(method.externalKeyword, isNull); |
| 5568 expect(method.modifierKeyword, isNull); | 5362 expect(method.modifierKeyword, isNull); |
| 5569 expect(method.propertyKeyword, isNotNull); | 5363 expect(method.propertyKeyword, isNotNull); |
| 5570 expect(method.returnType, isNotNull); | 5364 expect(method.returnType, isNotNull); |
| 5571 expect(method.name, isNotNull); | 5365 expect(method.name, isNotNull); |
| 5572 expect(method.operatorKeyword, isNull); | 5366 expect(method.operatorKeyword, isNull); |
| 5573 expect(method.body, isNotNull); | 5367 expect(method.body, isNotNull); |
| 5574 } | 5368 } |
| 5575 | 5369 |
| 5576 void test_parseClassMember_method_external() { | 5370 void test_parseClassMember_method_external() { |
| 5577 MethodDeclaration method = ParserTestCase.parse( | 5371 MethodDeclaration method = |
| 5578 "parseClassMember", <Object>["C"], "external m();"); | 5372 parse("parseClassMember", <Object>["C"], "external m();"); |
| 5579 expect(method.body, isNotNull); | 5373 expect(method.body, isNotNull); |
| 5580 expect(method.documentationComment, isNull); | 5374 expect(method.documentationComment, isNull); |
| 5581 expect(method.externalKeyword, isNotNull); | 5375 expect(method.externalKeyword, isNotNull); |
| 5582 expect(method.modifierKeyword, isNull); | 5376 expect(method.modifierKeyword, isNull); |
| 5583 expect(method.name, isNotNull); | 5377 expect(method.name, isNotNull); |
| 5584 expect(method.operatorKeyword, isNull); | 5378 expect(method.operatorKeyword, isNull); |
| 5585 expect(method.parameters, isNotNull); | 5379 expect(method.parameters, isNotNull); |
| 5586 expect(method.propertyKeyword, isNull); | 5380 expect(method.propertyKeyword, isNull); |
| 5587 expect(method.returnType, isNull); | 5381 expect(method.returnType, isNull); |
| 5588 } | 5382 } |
| 5589 | 5383 |
| 5590 void test_parseClassMember_method_external_withTypeAndArgs() { | 5384 void test_parseClassMember_method_external_withTypeAndArgs() { |
| 5591 MethodDeclaration method = ParserTestCase.parse( | 5385 MethodDeclaration method = |
| 5592 "parseClassMember", <Object>["C"], "external int m(int a);"); | 5386 parse("parseClassMember", <Object>["C"], "external int m(int a);"); |
| 5593 expect(method.body, isNotNull); | 5387 expect(method.body, isNotNull); |
| 5594 expect(method.documentationComment, isNull); | 5388 expect(method.documentationComment, isNull); |
| 5595 expect(method.externalKeyword, isNotNull); | 5389 expect(method.externalKeyword, isNotNull); |
| 5596 expect(method.modifierKeyword, isNull); | 5390 expect(method.modifierKeyword, isNull); |
| 5597 expect(method.name, isNotNull); | 5391 expect(method.name, isNotNull); |
| 5598 expect(method.operatorKeyword, isNull); | 5392 expect(method.operatorKeyword, isNull); |
| 5599 expect(method.parameters, isNotNull); | 5393 expect(method.parameters, isNotNull); |
| 5600 expect(method.propertyKeyword, isNull); | 5394 expect(method.propertyKeyword, isNull); |
| 5601 expect(method.returnType, isNotNull); | 5395 expect(method.returnType, isNotNull); |
| 5602 } | 5396 } |
| 5603 | 5397 |
| 5604 void test_parseClassMember_method_get_noType() { | 5398 void test_parseClassMember_method_get_noType() { |
| 5605 MethodDeclaration method = | 5399 MethodDeclaration method = |
| 5606 ParserTestCase.parse("parseClassMember", <Object>["C"], "get() {}"); | 5400 parse("parseClassMember", <Object>["C"], "get() {}"); |
| 5607 expect(method.documentationComment, isNull); | 5401 expect(method.documentationComment, isNull); |
| 5608 expect(method.externalKeyword, isNull); | 5402 expect(method.externalKeyword, isNull); |
| 5609 expect(method.modifierKeyword, isNull); | 5403 expect(method.modifierKeyword, isNull); |
| 5610 expect(method.propertyKeyword, isNull); | 5404 expect(method.propertyKeyword, isNull); |
| 5611 expect(method.returnType, isNull); | 5405 expect(method.returnType, isNull); |
| 5612 expect(method.name, isNotNull); | 5406 expect(method.name, isNotNull); |
| 5613 expect(method.operatorKeyword, isNull); | 5407 expect(method.operatorKeyword, isNull); |
| 5614 expect(method.parameters, isNotNull); | 5408 expect(method.parameters, isNotNull); |
| 5615 expect(method.body, isNotNull); | 5409 expect(method.body, isNotNull); |
| 5616 } | 5410 } |
| 5617 | 5411 |
| 5618 void test_parseClassMember_method_get_type() { | 5412 void test_parseClassMember_method_get_type() { |
| 5619 MethodDeclaration method = | 5413 MethodDeclaration method = |
| 5620 ParserTestCase.parse("parseClassMember", <Object>["C"], "int get() {}"); | 5414 parse("parseClassMember", <Object>["C"], "int get() {}"); |
| 5621 expect(method.documentationComment, isNull); | 5415 expect(method.documentationComment, isNull); |
| 5622 expect(method.externalKeyword, isNull); | 5416 expect(method.externalKeyword, isNull); |
| 5623 expect(method.modifierKeyword, isNull); | 5417 expect(method.modifierKeyword, isNull); |
| 5624 expect(method.propertyKeyword, isNull); | 5418 expect(method.propertyKeyword, isNull); |
| 5625 expect(method.returnType, isNotNull); | 5419 expect(method.returnType, isNotNull); |
| 5626 expect(method.name, isNotNull); | 5420 expect(method.name, isNotNull); |
| 5627 expect(method.operatorKeyword, isNull); | 5421 expect(method.operatorKeyword, isNull); |
| 5628 expect(method.parameters, isNotNull); | 5422 expect(method.parameters, isNotNull); |
| 5629 expect(method.body, isNotNull); | 5423 expect(method.body, isNotNull); |
| 5630 } | 5424 } |
| 5631 | 5425 |
| 5632 void test_parseClassMember_method_get_void() { | 5426 void test_parseClassMember_method_get_void() { |
| 5633 MethodDeclaration method = ParserTestCase.parse( | 5427 MethodDeclaration method = |
| 5634 "parseClassMember", <Object>["C"], "void get() {}"); | 5428 parse("parseClassMember", <Object>["C"], "void get() {}"); |
| 5635 expect(method.documentationComment, isNull); | 5429 expect(method.documentationComment, isNull); |
| 5636 expect(method.externalKeyword, isNull); | 5430 expect(method.externalKeyword, isNull); |
| 5637 expect(method.modifierKeyword, isNull); | 5431 expect(method.modifierKeyword, isNull); |
| 5638 expect(method.propertyKeyword, isNull); | 5432 expect(method.propertyKeyword, isNull); |
| 5639 expect(method.returnType, isNotNull); | 5433 expect(method.returnType, isNotNull); |
| 5640 expect(method.name, isNotNull); | 5434 expect(method.name, isNotNull); |
| 5641 expect(method.operatorKeyword, isNull); | 5435 expect(method.operatorKeyword, isNull); |
| 5642 expect(method.parameters, isNotNull); | 5436 expect(method.parameters, isNotNull); |
| 5643 expect(method.body, isNotNull); | 5437 expect(method.body, isNotNull); |
| 5644 } | 5438 } |
| 5645 | 5439 |
| 5646 void test_parseClassMember_method_operator_noType() { | 5440 void test_parseClassMember_method_operator_noType() { |
| 5647 MethodDeclaration method = ParserTestCase.parse( | 5441 MethodDeclaration method = |
| 5648 "parseClassMember", <Object>["C"], "operator() {}"); | 5442 parse("parseClassMember", <Object>["C"], "operator() {}"); |
| 5649 expect(method.documentationComment, isNull); | 5443 expect(method.documentationComment, isNull); |
| 5650 expect(method.externalKeyword, isNull); | 5444 expect(method.externalKeyword, isNull); |
| 5651 expect(method.modifierKeyword, isNull); | 5445 expect(method.modifierKeyword, isNull); |
| 5652 expect(method.propertyKeyword, isNull); | 5446 expect(method.propertyKeyword, isNull); |
| 5653 expect(method.returnType, isNull); | 5447 expect(method.returnType, isNull); |
| 5654 expect(method.name, isNotNull); | 5448 expect(method.name, isNotNull); |
| 5655 expect(method.operatorKeyword, isNull); | 5449 expect(method.operatorKeyword, isNull); |
| 5656 expect(method.parameters, isNotNull); | 5450 expect(method.parameters, isNotNull); |
| 5657 expect(method.body, isNotNull); | 5451 expect(method.body, isNotNull); |
| 5658 } | 5452 } |
| 5659 | 5453 |
| 5660 void test_parseClassMember_method_operator_type() { | 5454 void test_parseClassMember_method_operator_type() { |
| 5661 MethodDeclaration method = ParserTestCase.parse( | 5455 MethodDeclaration method = |
| 5662 "parseClassMember", <Object>["C"], "int operator() {}"); | 5456 parse("parseClassMember", <Object>["C"], "int operator() {}"); |
| 5663 expect(method.documentationComment, isNull); | 5457 expect(method.documentationComment, isNull); |
| 5664 expect(method.externalKeyword, isNull); | 5458 expect(method.externalKeyword, isNull); |
| 5665 expect(method.modifierKeyword, isNull); | 5459 expect(method.modifierKeyword, isNull); |
| 5666 expect(method.propertyKeyword, isNull); | 5460 expect(method.propertyKeyword, isNull); |
| 5667 expect(method.returnType, isNotNull); | 5461 expect(method.returnType, isNotNull); |
| 5668 expect(method.name, isNotNull); | 5462 expect(method.name, isNotNull); |
| 5669 expect(method.operatorKeyword, isNull); | 5463 expect(method.operatorKeyword, isNull); |
| 5670 expect(method.parameters, isNotNull); | 5464 expect(method.parameters, isNotNull); |
| 5671 expect(method.body, isNotNull); | 5465 expect(method.body, isNotNull); |
| 5672 } | 5466 } |
| 5673 | 5467 |
| 5674 void test_parseClassMember_method_operator_void() { | 5468 void test_parseClassMember_method_operator_void() { |
| 5675 MethodDeclaration method = ParserTestCase.parse( | 5469 MethodDeclaration method = |
| 5676 "parseClassMember", <Object>["C"], "void operator() {}"); | 5470 parse("parseClassMember", <Object>["C"], "void operator() {}"); |
| 5677 expect(method.documentationComment, isNull); | 5471 expect(method.documentationComment, isNull); |
| 5678 expect(method.externalKeyword, isNull); | 5472 expect(method.externalKeyword, isNull); |
| 5679 expect(method.modifierKeyword, isNull); | 5473 expect(method.modifierKeyword, isNull); |
| 5680 expect(method.propertyKeyword, isNull); | 5474 expect(method.propertyKeyword, isNull); |
| 5681 expect(method.returnType, isNotNull); | 5475 expect(method.returnType, isNotNull); |
| 5682 expect(method.name, isNotNull); | 5476 expect(method.name, isNotNull); |
| 5683 expect(method.operatorKeyword, isNull); | 5477 expect(method.operatorKeyword, isNull); |
| 5684 expect(method.parameters, isNotNull); | 5478 expect(method.parameters, isNotNull); |
| 5685 expect(method.body, isNotNull); | 5479 expect(method.body, isNotNull); |
| 5686 } | 5480 } |
| 5687 | 5481 |
| 5688 void test_parseClassMember_method_returnType_parameterized() { | 5482 void test_parseClassMember_method_returnType_parameterized() { |
| 5689 MethodDeclaration method = | 5483 MethodDeclaration method = |
| 5690 ParserTestCase.parse("parseClassMember", <Object>["C"], "p.A m() {}"); | 5484 parse("parseClassMember", <Object>["C"], "p.A m() {}"); |
| 5691 expect(method.documentationComment, isNull); | 5485 expect(method.documentationComment, isNull); |
| 5692 expect(method.externalKeyword, isNull); | 5486 expect(method.externalKeyword, isNull); |
| 5693 expect(method.modifierKeyword, isNull); | 5487 expect(method.modifierKeyword, isNull); |
| 5694 expect(method.propertyKeyword, isNull); | 5488 expect(method.propertyKeyword, isNull); |
| 5695 expect(method.returnType, isNotNull); | 5489 expect(method.returnType, isNotNull); |
| 5696 expect(method.name, isNotNull); | 5490 expect(method.name, isNotNull); |
| 5697 expect(method.operatorKeyword, isNull); | 5491 expect(method.operatorKeyword, isNull); |
| 5698 expect(method.parameters, isNotNull); | 5492 expect(method.parameters, isNotNull); |
| 5699 expect(method.body, isNotNull); | 5493 expect(method.body, isNotNull); |
| 5700 } | 5494 } |
| 5701 | 5495 |
| 5702 void test_parseClassMember_method_set_noType() { | 5496 void test_parseClassMember_method_set_noType() { |
| 5703 MethodDeclaration method = | 5497 MethodDeclaration method = |
| 5704 ParserTestCase.parse("parseClassMember", <Object>["C"], "set() {}"); | 5498 parse("parseClassMember", <Object>["C"], "set() {}"); |
| 5705 expect(method.documentationComment, isNull); | 5499 expect(method.documentationComment, isNull); |
| 5706 expect(method.externalKeyword, isNull); | 5500 expect(method.externalKeyword, isNull); |
| 5707 expect(method.modifierKeyword, isNull); | 5501 expect(method.modifierKeyword, isNull); |
| 5708 expect(method.propertyKeyword, isNull); | 5502 expect(method.propertyKeyword, isNull); |
| 5709 expect(method.returnType, isNull); | 5503 expect(method.returnType, isNull); |
| 5710 expect(method.name, isNotNull); | 5504 expect(method.name, isNotNull); |
| 5711 expect(method.operatorKeyword, isNull); | 5505 expect(method.operatorKeyword, isNull); |
| 5712 expect(method.parameters, isNotNull); | 5506 expect(method.parameters, isNotNull); |
| 5713 expect(method.body, isNotNull); | 5507 expect(method.body, isNotNull); |
| 5714 } | 5508 } |
| 5715 | 5509 |
| 5716 void test_parseClassMember_method_set_type() { | 5510 void test_parseClassMember_method_set_type() { |
| 5717 MethodDeclaration method = | 5511 MethodDeclaration method = |
| 5718 ParserTestCase.parse("parseClassMember", <Object>["C"], "int set() {}"); | 5512 parse("parseClassMember", <Object>["C"], "int set() {}"); |
| 5719 expect(method.documentationComment, isNull); | 5513 expect(method.documentationComment, isNull); |
| 5720 expect(method.externalKeyword, isNull); | 5514 expect(method.externalKeyword, isNull); |
| 5721 expect(method.modifierKeyword, isNull); | 5515 expect(method.modifierKeyword, isNull); |
| 5722 expect(method.propertyKeyword, isNull); | 5516 expect(method.propertyKeyword, isNull); |
| 5723 expect(method.returnType, isNotNull); | 5517 expect(method.returnType, isNotNull); |
| 5724 expect(method.name, isNotNull); | 5518 expect(method.name, isNotNull); |
| 5725 expect(method.operatorKeyword, isNull); | 5519 expect(method.operatorKeyword, isNull); |
| 5726 expect(method.parameters, isNotNull); | 5520 expect(method.parameters, isNotNull); |
| 5727 expect(method.body, isNotNull); | 5521 expect(method.body, isNotNull); |
| 5728 } | 5522 } |
| 5729 | 5523 |
| 5730 void test_parseClassMember_method_set_void() { | 5524 void test_parseClassMember_method_set_void() { |
| 5731 MethodDeclaration method = ParserTestCase.parse( | 5525 MethodDeclaration method = |
| 5732 "parseClassMember", <Object>["C"], "void set() {}"); | 5526 parse("parseClassMember", <Object>["C"], "void set() {}"); |
| 5733 expect(method.documentationComment, isNull); | 5527 expect(method.documentationComment, isNull); |
| 5734 expect(method.externalKeyword, isNull); | 5528 expect(method.externalKeyword, isNull); |
| 5735 expect(method.modifierKeyword, isNull); | 5529 expect(method.modifierKeyword, isNull); |
| 5736 expect(method.propertyKeyword, isNull); | 5530 expect(method.propertyKeyword, isNull); |
| 5737 expect(method.returnType, isNotNull); | 5531 expect(method.returnType, isNotNull); |
| 5738 expect(method.name, isNotNull); | 5532 expect(method.name, isNotNull); |
| 5739 expect(method.operatorKeyword, isNull); | 5533 expect(method.operatorKeyword, isNull); |
| 5740 expect(method.parameters, isNotNull); | 5534 expect(method.parameters, isNotNull); |
| 5741 expect(method.body, isNotNull); | 5535 expect(method.body, isNotNull); |
| 5742 } | 5536 } |
| 5743 | 5537 |
| 5744 void test_parseClassMember_operator_index() { | 5538 void test_parseClassMember_operator_index() { |
| 5745 MethodDeclaration method = ParserTestCase.parse( | 5539 MethodDeclaration method = |
| 5746 "parseClassMember", <Object>["C"], "int operator [](int i) {}"); | 5540 parse("parseClassMember", <Object>["C"], "int operator [](int i) {}"); |
| 5747 expect(method.documentationComment, isNull); | 5541 expect(method.documentationComment, isNull); |
| 5748 expect(method.externalKeyword, isNull); | 5542 expect(method.externalKeyword, isNull); |
| 5749 expect(method.modifierKeyword, isNull); | 5543 expect(method.modifierKeyword, isNull); |
| 5750 expect(method.propertyKeyword, isNull); | 5544 expect(method.propertyKeyword, isNull); |
| 5751 expect(method.returnType, isNotNull); | 5545 expect(method.returnType, isNotNull); |
| 5752 expect(method.name, isNotNull); | 5546 expect(method.name, isNotNull); |
| 5753 expect(method.operatorKeyword, isNotNull); | 5547 expect(method.operatorKeyword, isNotNull); |
| 5754 expect(method.parameters, isNotNull); | 5548 expect(method.parameters, isNotNull); |
| 5755 expect(method.body, isNotNull); | 5549 expect(method.body, isNotNull); |
| 5756 } | 5550 } |
| 5757 | 5551 |
| 5758 void test_parseClassMember_operator_indexAssign() { | 5552 void test_parseClassMember_operator_indexAssign() { |
| 5759 MethodDeclaration method = ParserTestCase.parse( | 5553 MethodDeclaration method = |
| 5760 "parseClassMember", <Object>["C"], "int operator []=(int i) {}"); | 5554 parse("parseClassMember", <Object>["C"], "int operator []=(int i) {}"); |
| 5761 expect(method.documentationComment, isNull); | 5555 expect(method.documentationComment, isNull); |
| 5762 expect(method.externalKeyword, isNull); | 5556 expect(method.externalKeyword, isNull); |
| 5763 expect(method.modifierKeyword, isNull); | 5557 expect(method.modifierKeyword, isNull); |
| 5764 expect(method.propertyKeyword, isNull); | 5558 expect(method.propertyKeyword, isNull); |
| 5765 expect(method.returnType, isNotNull); | 5559 expect(method.returnType, isNotNull); |
| 5766 expect(method.name, isNotNull); | 5560 expect(method.name, isNotNull); |
| 5767 expect(method.operatorKeyword, isNotNull); | 5561 expect(method.operatorKeyword, isNotNull); |
| 5768 expect(method.parameters, isNotNull); | 5562 expect(method.parameters, isNotNull); |
| 5769 expect(method.body, isNotNull); | 5563 expect(method.body, isNotNull); |
| 5770 } | 5564 } |
| 5771 | 5565 |
| 5772 void test_parseClassMember_redirectingFactory_const() { | 5566 void test_parseClassMember_redirectingFactory_const() { |
| 5773 ConstructorDeclaration constructor = ParserTestCase.parse( | 5567 ConstructorDeclaration constructor = |
| 5774 "parseClassMember", <Object>["C"], "const factory C() = B;"); | 5568 parse("parseClassMember", <Object>["C"], "const factory C() = B;"); |
| 5775 expect(constructor.externalKeyword, isNull); | 5569 expect(constructor.externalKeyword, isNull); |
| 5776 expect(constructor.constKeyword, isNotNull); | 5570 expect(constructor.constKeyword, isNotNull); |
| 5777 expect(constructor.factoryKeyword, isNotNull); | 5571 expect(constructor.factoryKeyword, isNotNull); |
| 5778 expect(constructor.returnType, isNotNull); | 5572 expect(constructor.returnType, isNotNull); |
| 5779 expect(constructor.period, isNull); | 5573 expect(constructor.period, isNull); |
| 5780 expect(constructor.name, isNull); | 5574 expect(constructor.name, isNull); |
| 5781 expect(constructor.parameters, isNotNull); | 5575 expect(constructor.parameters, isNotNull); |
| 5782 expect(constructor.separator, isNotNull); | 5576 expect(constructor.separator, isNotNull); |
| 5783 expect(constructor.initializers, hasLength(0)); | 5577 expect(constructor.initializers, hasLength(0)); |
| 5784 expect(constructor.redirectedConstructor, isNotNull); | 5578 expect(constructor.redirectedConstructor, isNotNull); |
| 5785 expect(constructor.body, isNotNull); | 5579 expect(constructor.body, isNotNull); |
| 5786 } | 5580 } |
| 5787 | 5581 |
| 5788 void test_parseClassMember_redirectingFactory_nonConst() { | 5582 void test_parseClassMember_redirectingFactory_nonConst() { |
| 5789 ConstructorDeclaration constructor = ParserTestCase.parse( | 5583 ConstructorDeclaration constructor = |
| 5790 "parseClassMember", <Object>["C"], "factory C() = B;"); | 5584 parse("parseClassMember", <Object>["C"], "factory C() = B;"); |
| 5791 expect(constructor.externalKeyword, isNull); | 5585 expect(constructor.externalKeyword, isNull); |
| 5792 expect(constructor.constKeyword, isNull); | 5586 expect(constructor.constKeyword, isNull); |
| 5793 expect(constructor.factoryKeyword, isNotNull); | 5587 expect(constructor.factoryKeyword, isNotNull); |
| 5794 expect(constructor.returnType, isNotNull); | 5588 expect(constructor.returnType, isNotNull); |
| 5795 expect(constructor.period, isNull); | 5589 expect(constructor.period, isNull); |
| 5796 expect(constructor.name, isNull); | 5590 expect(constructor.name, isNull); |
| 5797 expect(constructor.parameters, isNotNull); | 5591 expect(constructor.parameters, isNotNull); |
| 5798 expect(constructor.separator, isNotNull); | 5592 expect(constructor.separator, isNotNull); |
| 5799 expect(constructor.initializers, hasLength(0)); | 5593 expect(constructor.initializers, hasLength(0)); |
| 5800 expect(constructor.redirectedConstructor, isNotNull); | 5594 expect(constructor.redirectedConstructor, isNotNull); |
| 5801 expect(constructor.body, isNotNull); | 5595 expect(constructor.body, isNotNull); |
| 5802 } | 5596 } |
| 5803 | 5597 |
| 5804 void test_parseClassTypeAlias_abstract() { | 5598 void test_parseClassTypeAlias_abstract() { |
| 5805 Token classToken = TokenFactory.tokenFromKeyword(Keyword.CLASS); | 5599 Token classToken = TokenFactory.tokenFromKeyword(Keyword.CLASS); |
| 5806 Token abstractToken = TokenFactory.tokenFromKeyword(Keyword.ABSTRACT); | 5600 Token abstractToken = TokenFactory.tokenFromKeyword(Keyword.ABSTRACT); |
| 5807 ClassTypeAlias classTypeAlias = ParserTestCase.parse("parseClassTypeAlias", | 5601 ClassTypeAlias classTypeAlias = parse("parseClassTypeAlias", <Object>[ |
| 5808 <Object>[ | |
| 5809 emptyCommentAndMetadata(), | 5602 emptyCommentAndMetadata(), |
| 5810 abstractToken, | 5603 abstractToken, |
| 5811 classToken | 5604 classToken |
| 5812 ], "A = B with C;"); | 5605 ], "A = B with C;"); |
| 5813 expect(classTypeAlias.typedefKeyword, isNotNull); | 5606 expect(classTypeAlias.typedefKeyword, isNotNull); |
| 5814 expect(classTypeAlias.name.name, "A"); | 5607 expect(classTypeAlias.name.name, "A"); |
| 5815 expect(classTypeAlias.equals, isNotNull); | 5608 expect(classTypeAlias.equals, isNotNull); |
| 5816 expect(classTypeAlias.abstractKeyword, isNotNull); | 5609 expect(classTypeAlias.abstractKeyword, isNotNull); |
| 5817 expect(classTypeAlias.superclass.name.name, isNotNull, reason: "B"); | 5610 expect(classTypeAlias.superclass.name.name, isNotNull, reason: "B"); |
| 5818 expect(classTypeAlias.withClause, isNotNull); | 5611 expect(classTypeAlias.withClause, isNotNull); |
| 5819 expect(classTypeAlias.implementsClause, isNull); | 5612 expect(classTypeAlias.implementsClause, isNull); |
| 5820 expect(classTypeAlias.semicolon, isNotNull); | 5613 expect(classTypeAlias.semicolon, isNotNull); |
| 5821 } | 5614 } |
| 5822 | 5615 |
| 5823 void test_parseClassTypeAlias_implements() { | 5616 void test_parseClassTypeAlias_implements() { |
| 5824 Token token = TokenFactory.tokenFromKeyword(Keyword.CLASS); | 5617 Token token = TokenFactory.tokenFromKeyword(Keyword.CLASS); |
| 5825 ClassTypeAlias classTypeAlias = ParserTestCase.parse("parseClassTypeAlias", | 5618 ClassTypeAlias classTypeAlias = parse("parseClassTypeAlias", <Object>[ |
| 5826 <Object>[ | |
| 5827 emptyCommentAndMetadata(), | 5619 emptyCommentAndMetadata(), |
| 5828 null, | 5620 null, |
| 5829 token | 5621 token |
| 5830 ], "A = B with C implements D;"); | 5622 ], "A = B with C implements D;"); |
| 5831 expect(classTypeAlias.typedefKeyword, isNotNull); | 5623 expect(classTypeAlias.typedefKeyword, isNotNull); |
| 5832 expect(classTypeAlias.name.name, "A"); | 5624 expect(classTypeAlias.name.name, "A"); |
| 5833 expect(classTypeAlias.equals, isNotNull); | 5625 expect(classTypeAlias.equals, isNotNull); |
| 5834 expect(classTypeAlias.abstractKeyword, isNull); | 5626 expect(classTypeAlias.abstractKeyword, isNull); |
| 5835 expect(classTypeAlias.superclass.name.name, isNotNull, reason: "B"); | 5627 expect(classTypeAlias.superclass.name.name, isNotNull, reason: "B"); |
| 5836 expect(classTypeAlias.withClause, isNotNull); | 5628 expect(classTypeAlias.withClause, isNotNull); |
| 5837 expect(classTypeAlias.implementsClause, isNotNull); | 5629 expect(classTypeAlias.implementsClause, isNotNull); |
| 5838 expect(classTypeAlias.semicolon, isNotNull); | 5630 expect(classTypeAlias.semicolon, isNotNull); |
| 5839 } | 5631 } |
| 5840 | 5632 |
| 5841 void test_parseClassTypeAlias_with() { | 5633 void test_parseClassTypeAlias_with() { |
| 5842 Token token = TokenFactory.tokenFromKeyword(Keyword.CLASS); | 5634 Token token = TokenFactory.tokenFromKeyword(Keyword.CLASS); |
| 5843 ClassTypeAlias classTypeAlias = ParserTestCase.parse("parseClassTypeAlias", | 5635 ClassTypeAlias classTypeAlias = parse("parseClassTypeAlias", <Object>[ |
| 5844 <Object>[emptyCommentAndMetadata(), null, token], "A = B with C;"); | 5636 emptyCommentAndMetadata(), |
| 5637 null, |
| 5638 token |
| 5639 ], "A = B with C;"); |
| 5845 expect(classTypeAlias.typedefKeyword, isNotNull); | 5640 expect(classTypeAlias.typedefKeyword, isNotNull); |
| 5846 expect(classTypeAlias.name.name, "A"); | 5641 expect(classTypeAlias.name.name, "A"); |
| 5847 expect(classTypeAlias.equals, isNotNull); | 5642 expect(classTypeAlias.equals, isNotNull); |
| 5848 expect(classTypeAlias.abstractKeyword, isNull); | 5643 expect(classTypeAlias.abstractKeyword, isNull); |
| 5849 expect(classTypeAlias.superclass.name.name, isNotNull, reason: "B"); | 5644 expect(classTypeAlias.superclass.name.name, isNotNull, reason: "B"); |
| 5850 expect(classTypeAlias.withClause, isNotNull); | 5645 expect(classTypeAlias.withClause, isNotNull); |
| 5851 expect(classTypeAlias.implementsClause, isNull); | 5646 expect(classTypeAlias.implementsClause, isNull); |
| 5852 expect(classTypeAlias.semicolon, isNotNull); | 5647 expect(classTypeAlias.semicolon, isNotNull); |
| 5853 } | 5648 } |
| 5854 | 5649 |
| 5855 void test_parseClassTypeAlias_with_implements() { | 5650 void test_parseClassTypeAlias_with_implements() { |
| 5856 Token token = TokenFactory.tokenFromKeyword(Keyword.CLASS); | 5651 Token token = TokenFactory.tokenFromKeyword(Keyword.CLASS); |
| 5857 ClassTypeAlias classTypeAlias = ParserTestCase.parse("parseClassTypeAlias", | 5652 ClassTypeAlias classTypeAlias = parse("parseClassTypeAlias", <Object>[ |
| 5858 <Object>[ | |
| 5859 emptyCommentAndMetadata(), | 5653 emptyCommentAndMetadata(), |
| 5860 null, | 5654 null, |
| 5861 token | 5655 token |
| 5862 ], "A = B with C implements D;"); | 5656 ], "A = B with C implements D;"); |
| 5863 expect(classTypeAlias.typedefKeyword, isNotNull); | 5657 expect(classTypeAlias.typedefKeyword, isNotNull); |
| 5864 expect(classTypeAlias.name.name, "A"); | 5658 expect(classTypeAlias.name.name, "A"); |
| 5865 expect(classTypeAlias.equals, isNotNull); | 5659 expect(classTypeAlias.equals, isNotNull); |
| 5866 expect(classTypeAlias.abstractKeyword, isNull); | 5660 expect(classTypeAlias.abstractKeyword, isNull); |
| 5867 expect(classTypeAlias.superclass.name.name, isNotNull, reason: "B"); | 5661 expect(classTypeAlias.superclass.name.name, isNotNull, reason: "B"); |
| 5868 expect(classTypeAlias.withClause, isNotNull); | 5662 expect(classTypeAlias.withClause, isNotNull); |
| 5869 expect(classTypeAlias.implementsClause, isNotNull); | 5663 expect(classTypeAlias.implementsClause, isNotNull); |
| 5870 expect(classTypeAlias.semicolon, isNotNull); | 5664 expect(classTypeAlias.semicolon, isNotNull); |
| 5871 } | 5665 } |
| 5872 | 5666 |
| 5873 void test_parseCombinator_hide() { | 5667 void test_parseCombinator_hide() { |
| 5874 HideCombinator combinator = | 5668 HideCombinator combinator = parse4('parseCombinator', 'hide a;'); |
| 5875 ParserTestCase.parse4('parseCombinator', 'hide a;'); | |
| 5876 expect(combinator, new isInstanceOf<HideCombinator>()); | 5669 expect(combinator, new isInstanceOf<HideCombinator>()); |
| 5877 expect(combinator.keyword, isNotNull); | 5670 expect(combinator.keyword, isNotNull); |
| 5878 expect(combinator.hiddenNames, hasLength(1)); | 5671 expect(combinator.hiddenNames, hasLength(1)); |
| 5879 } | 5672 } |
| 5880 | 5673 |
| 5881 void test_parseCombinator_show() { | 5674 void test_parseCombinator_show() { |
| 5882 ShowCombinator combinator = | 5675 ShowCombinator combinator = parse4('parseCombinator', 'show a;'); |
| 5883 ParserTestCase.parse4('parseCombinator', 'show a;'); | |
| 5884 expect(combinator, new isInstanceOf<ShowCombinator>()); | 5676 expect(combinator, new isInstanceOf<ShowCombinator>()); |
| 5885 expect(combinator.keyword, isNotNull); | 5677 expect(combinator.keyword, isNotNull); |
| 5886 expect(combinator.shownNames, hasLength(1)); | 5678 expect(combinator.shownNames, hasLength(1)); |
| 5887 } | 5679 } |
| 5888 | 5680 |
| 5889 void test_parseCombinators_h() { | 5681 void test_parseCombinators_h() { |
| 5890 List<Combinator> combinators = | 5682 List<Combinator> combinators = parse4("parseCombinators", "hide a;"); |
| 5891 ParserTestCase.parse4("parseCombinators", "hide a;"); | |
| 5892 expect(combinators, hasLength(1)); | 5683 expect(combinators, hasLength(1)); |
| 5893 HideCombinator combinator = combinators[0] as HideCombinator; | 5684 HideCombinator combinator = combinators[0] as HideCombinator; |
| 5894 expect(combinator, isNotNull); | 5685 expect(combinator, isNotNull); |
| 5895 expect(combinator.keyword, isNotNull); | 5686 expect(combinator.keyword, isNotNull); |
| 5896 expect(combinator.hiddenNames, hasLength(1)); | 5687 expect(combinator.hiddenNames, hasLength(1)); |
| 5897 } | 5688 } |
| 5898 | 5689 |
| 5899 void test_parseCombinators_hs() { | 5690 void test_parseCombinators_hs() { |
| 5900 List<Combinator> combinators = | 5691 List<Combinator> combinators = parse4("parseCombinators", "hide a show b;"); |
| 5901 ParserTestCase.parse4("parseCombinators", "hide a show b;"); | |
| 5902 expect(combinators, hasLength(2)); | 5692 expect(combinators, hasLength(2)); |
| 5903 HideCombinator hideCombinator = combinators[0] as HideCombinator; | 5693 HideCombinator hideCombinator = combinators[0] as HideCombinator; |
| 5904 expect(hideCombinator, isNotNull); | 5694 expect(hideCombinator, isNotNull); |
| 5905 expect(hideCombinator.keyword, isNotNull); | 5695 expect(hideCombinator.keyword, isNotNull); |
| 5906 expect(hideCombinator.hiddenNames, hasLength(1)); | 5696 expect(hideCombinator.hiddenNames, hasLength(1)); |
| 5907 ShowCombinator showCombinator = combinators[1] as ShowCombinator; | 5697 ShowCombinator showCombinator = combinators[1] as ShowCombinator; |
| 5908 expect(showCombinator, isNotNull); | 5698 expect(showCombinator, isNotNull); |
| 5909 expect(showCombinator.keyword, isNotNull); | 5699 expect(showCombinator.keyword, isNotNull); |
| 5910 expect(showCombinator.shownNames, hasLength(1)); | 5700 expect(showCombinator.shownNames, hasLength(1)); |
| 5911 } | 5701 } |
| 5912 | 5702 |
| 5913 void test_parseCombinators_hshs() { | 5703 void test_parseCombinators_hshs() { |
| 5914 List<Combinator> combinators = ParserTestCase.parse4( | 5704 List<Combinator> combinators = |
| 5915 "parseCombinators", "hide a show b hide c show d;"); | 5705 parse4("parseCombinators", "hide a show b hide c show d;"); |
| 5916 expect(combinators, hasLength(4)); | 5706 expect(combinators, hasLength(4)); |
| 5917 } | 5707 } |
| 5918 | 5708 |
| 5919 void test_parseCombinators_s() { | 5709 void test_parseCombinators_s() { |
| 5920 List<Combinator> combinators = | 5710 List<Combinator> combinators = parse4("parseCombinators", "show a;"); |
| 5921 ParserTestCase.parse4("parseCombinators", "show a;"); | |
| 5922 expect(combinators, hasLength(1)); | 5711 expect(combinators, hasLength(1)); |
| 5923 ShowCombinator combinator = combinators[0] as ShowCombinator; | 5712 ShowCombinator combinator = combinators[0] as ShowCombinator; |
| 5924 expect(combinator, isNotNull); | 5713 expect(combinator, isNotNull); |
| 5925 expect(combinator.keyword, isNotNull); | 5714 expect(combinator.keyword, isNotNull); |
| 5926 expect(combinator.shownNames, hasLength(1)); | 5715 expect(combinator.shownNames, hasLength(1)); |
| 5927 } | 5716 } |
| 5928 | 5717 |
| 5929 void test_parseCommentAndMetadata_c() { | 5718 void test_parseCommentAndMetadata_c() { |
| 5930 CommentAndMetadata commentAndMetadata = | 5719 CommentAndMetadata commentAndMetadata = |
| 5931 ParserTestCase.parse4("parseCommentAndMetadata", "/** 1 */ void"); | 5720 parse4("parseCommentAndMetadata", "/** 1 */ void"); |
| 5932 expect(commentAndMetadata.comment, isNotNull); | 5721 expect(commentAndMetadata.comment, isNotNull); |
| 5933 expect(commentAndMetadata.metadata, hasLength(0)); | 5722 expect(commentAndMetadata.metadata, hasLength(0)); |
| 5934 } | 5723 } |
| 5935 | 5724 |
| 5936 void test_parseCommentAndMetadata_cmc() { | 5725 void test_parseCommentAndMetadata_cmc() { |
| 5937 CommentAndMetadata commentAndMetadata = ParserTestCase.parse4( | 5726 CommentAndMetadata commentAndMetadata = |
| 5938 "parseCommentAndMetadata", "/** 1 */ @A /** 2 */ void"); | 5727 parse4("parseCommentAndMetadata", "/** 1 */ @A /** 2 */ void"); |
| 5939 expect(commentAndMetadata.comment, isNotNull); | 5728 expect(commentAndMetadata.comment, isNotNull); |
| 5940 expect(commentAndMetadata.metadata, hasLength(1)); | 5729 expect(commentAndMetadata.metadata, hasLength(1)); |
| 5941 } | 5730 } |
| 5942 | 5731 |
| 5943 void test_parseCommentAndMetadata_cmcm() { | 5732 void test_parseCommentAndMetadata_cmcm() { |
| 5944 CommentAndMetadata commentAndMetadata = ParserTestCase.parse4( | 5733 CommentAndMetadata commentAndMetadata = |
| 5945 "parseCommentAndMetadata", "/** 1 */ @A /** 2 */ @B void"); | 5734 parse4("parseCommentAndMetadata", "/** 1 */ @A /** 2 */ @B void"); |
| 5946 expect(commentAndMetadata.comment, isNotNull); | 5735 expect(commentAndMetadata.comment, isNotNull); |
| 5947 expect(commentAndMetadata.metadata, hasLength(2)); | 5736 expect(commentAndMetadata.metadata, hasLength(2)); |
| 5948 } | 5737 } |
| 5949 | 5738 |
| 5950 void test_parseCommentAndMetadata_cmm() { | 5739 void test_parseCommentAndMetadata_cmm() { |
| 5951 CommentAndMetadata commentAndMetadata = | 5740 CommentAndMetadata commentAndMetadata = |
| 5952 ParserTestCase.parse4("parseCommentAndMetadata", "/** 1 */ @A @B void"); | 5741 parse4("parseCommentAndMetadata", "/** 1 */ @A @B void"); |
| 5953 expect(commentAndMetadata.comment, isNotNull); | 5742 expect(commentAndMetadata.comment, isNotNull); |
| 5954 expect(commentAndMetadata.metadata, hasLength(2)); | 5743 expect(commentAndMetadata.metadata, hasLength(2)); |
| 5955 } | 5744 } |
| 5956 | 5745 |
| 5957 void test_parseCommentAndMetadata_m() { | 5746 void test_parseCommentAndMetadata_m() { |
| 5958 CommentAndMetadata commentAndMetadata = | 5747 CommentAndMetadata commentAndMetadata = |
| 5959 ParserTestCase.parse4("parseCommentAndMetadata", "@A void"); | 5748 parse4("parseCommentAndMetadata", "@A void"); |
| 5960 expect(commentAndMetadata.comment, isNull); | 5749 expect(commentAndMetadata.comment, isNull); |
| 5961 expect(commentAndMetadata.metadata, hasLength(1)); | 5750 expect(commentAndMetadata.metadata, hasLength(1)); |
| 5962 } | 5751 } |
| 5963 | 5752 |
| 5964 void test_parseCommentAndMetadata_mcm() { | 5753 void test_parseCommentAndMetadata_mcm() { |
| 5965 CommentAndMetadata commentAndMetadata = | 5754 CommentAndMetadata commentAndMetadata = |
| 5966 ParserTestCase.parse4("parseCommentAndMetadata", "@A /** 1 */ @B void"); | 5755 parse4("parseCommentAndMetadata", "@A /** 1 */ @B void"); |
| 5967 expect(commentAndMetadata.comment, isNotNull); | 5756 expect(commentAndMetadata.comment, isNotNull); |
| 5968 expect(commentAndMetadata.metadata, hasLength(2)); | 5757 expect(commentAndMetadata.metadata, hasLength(2)); |
| 5969 } | 5758 } |
| 5970 | 5759 |
| 5971 void test_parseCommentAndMetadata_mcmc() { | 5760 void test_parseCommentAndMetadata_mcmc() { |
| 5972 CommentAndMetadata commentAndMetadata = ParserTestCase.parse4( | 5761 CommentAndMetadata commentAndMetadata = |
| 5973 "parseCommentAndMetadata", "@A /** 1 */ @B /** 2 */ void"); | 5762 parse4("parseCommentAndMetadata", "@A /** 1 */ @B /** 2 */ void"); |
| 5974 expect(commentAndMetadata.comment, isNotNull); | 5763 expect(commentAndMetadata.comment, isNotNull); |
| 5975 expect(commentAndMetadata.metadata, hasLength(2)); | 5764 expect(commentAndMetadata.metadata, hasLength(2)); |
| 5976 } | 5765 } |
| 5977 | 5766 |
| 5978 void test_parseCommentAndMetadata_mm() { | 5767 void test_parseCommentAndMetadata_mm() { |
| 5979 CommentAndMetadata commentAndMetadata = | 5768 CommentAndMetadata commentAndMetadata = |
| 5980 ParserTestCase.parse4("parseCommentAndMetadata", "@A @B(x) void"); | 5769 parse4("parseCommentAndMetadata", "@A @B(x) void"); |
| 5981 expect(commentAndMetadata.comment, isNull); | 5770 expect(commentAndMetadata.comment, isNull); |
| 5982 expect(commentAndMetadata.metadata, hasLength(2)); | 5771 expect(commentAndMetadata.metadata, hasLength(2)); |
| 5983 } | 5772 } |
| 5984 | 5773 |
| 5985 void test_parseCommentAndMetadata_none() { | 5774 void test_parseCommentAndMetadata_none() { |
| 5986 CommentAndMetadata commentAndMetadata = | 5775 CommentAndMetadata commentAndMetadata = |
| 5987 ParserTestCase.parse4("parseCommentAndMetadata", "void"); | 5776 parse4("parseCommentAndMetadata", "void"); |
| 5988 expect(commentAndMetadata.comment, isNull); | 5777 expect(commentAndMetadata.comment, isNull); |
| 5989 expect(commentAndMetadata.metadata, hasLength(0)); | 5778 expect(commentAndMetadata.metadata, hasLength(0)); |
| 5990 } | 5779 } |
| 5991 | 5780 |
| 5992 void test_parseCommentAndMetadata_singleLine() { | 5781 void test_parseCommentAndMetadata_singleLine() { |
| 5993 CommentAndMetadata commentAndMetadata = ParserTestCase.parse4( | 5782 CommentAndMetadata commentAndMetadata = parse4("parseCommentAndMetadata", |
| 5994 "parseCommentAndMetadata", r''' | 5783 r''' |
| 5995 /// 1 | 5784 /// 1 |
| 5996 /// 2 | 5785 /// 2 |
| 5997 void'''); | 5786 void'''); |
| 5998 expect(commentAndMetadata.comment, isNotNull); | 5787 expect(commentAndMetadata.comment, isNotNull); |
| 5999 expect(commentAndMetadata.metadata, hasLength(0)); | 5788 expect(commentAndMetadata.metadata, hasLength(0)); |
| 6000 } | 5789 } |
| 6001 | 5790 |
| 6002 void test_parseCommentReference_new_prefixed() { | 5791 void test_parseCommentReference_new_prefixed() { |
| 6003 CommentReference reference = ParserTestCase.parse( | 5792 CommentReference reference = |
| 6004 "parseCommentReference", <Object>["new a.b", 7], ""); | 5793 parse("parseCommentReference", <Object>["new a.b", 7], ""); |
| 6005 PrefixedIdentifier prefixedIdentifier = EngineTestCase.assertInstanceOf( | 5794 PrefixedIdentifier prefixedIdentifier = EngineTestCase.assertInstanceOf( |
| 6006 (obj) => obj is PrefixedIdentifier, PrefixedIdentifier, | 5795 (obj) => obj is PrefixedIdentifier, PrefixedIdentifier, |
| 6007 reference.identifier); | 5796 reference.identifier); |
| 6008 SimpleIdentifier prefix = prefixedIdentifier.prefix; | 5797 SimpleIdentifier prefix = prefixedIdentifier.prefix; |
| 6009 expect(prefix.token, isNotNull); | 5798 expect(prefix.token, isNotNull); |
| 6010 expect(prefix.name, "a"); | 5799 expect(prefix.name, "a"); |
| 6011 expect(prefix.offset, 11); | 5800 expect(prefix.offset, 11); |
| 6012 expect(prefixedIdentifier.period, isNotNull); | 5801 expect(prefixedIdentifier.period, isNotNull); |
| 6013 SimpleIdentifier identifier = prefixedIdentifier.identifier; | 5802 SimpleIdentifier identifier = prefixedIdentifier.identifier; |
| 6014 expect(identifier.token, isNotNull); | 5803 expect(identifier.token, isNotNull); |
| 6015 expect(identifier.name, "b"); | 5804 expect(identifier.name, "b"); |
| 6016 expect(identifier.offset, 13); | 5805 expect(identifier.offset, 13); |
| 6017 } | 5806 } |
| 6018 | 5807 |
| 6019 void test_parseCommentReference_new_simple() { | 5808 void test_parseCommentReference_new_simple() { |
| 6020 CommentReference reference = | 5809 CommentReference reference = |
| 6021 ParserTestCase.parse("parseCommentReference", <Object>["new a", 5], ""); | 5810 parse("parseCommentReference", <Object>["new a", 5], ""); |
| 6022 SimpleIdentifier identifier = EngineTestCase.assertInstanceOf( | 5811 SimpleIdentifier identifier = EngineTestCase.assertInstanceOf( |
| 6023 (obj) => obj is SimpleIdentifier, SimpleIdentifier, | 5812 (obj) => obj is SimpleIdentifier, SimpleIdentifier, |
| 6024 reference.identifier); | 5813 reference.identifier); |
| 6025 expect(identifier.token, isNotNull); | 5814 expect(identifier.token, isNotNull); |
| 6026 expect(identifier.name, "a"); | 5815 expect(identifier.name, "a"); |
| 6027 expect(identifier.offset, 9); | 5816 expect(identifier.offset, 9); |
| 6028 } | 5817 } |
| 6029 | 5818 |
| 6030 void test_parseCommentReference_prefixed() { | 5819 void test_parseCommentReference_prefixed() { |
| 6031 CommentReference reference = | 5820 CommentReference reference = |
| 6032 ParserTestCase.parse("parseCommentReference", <Object>["a.b", 7], ""); | 5821 parse("parseCommentReference", <Object>["a.b", 7], ""); |
| 6033 PrefixedIdentifier prefixedIdentifier = EngineTestCase.assertInstanceOf( | 5822 PrefixedIdentifier prefixedIdentifier = EngineTestCase.assertInstanceOf( |
| 6034 (obj) => obj is PrefixedIdentifier, PrefixedIdentifier, | 5823 (obj) => obj is PrefixedIdentifier, PrefixedIdentifier, |
| 6035 reference.identifier); | 5824 reference.identifier); |
| 6036 SimpleIdentifier prefix = prefixedIdentifier.prefix; | 5825 SimpleIdentifier prefix = prefixedIdentifier.prefix; |
| 6037 expect(prefix.token, isNotNull); | 5826 expect(prefix.token, isNotNull); |
| 6038 expect(prefix.name, "a"); | 5827 expect(prefix.name, "a"); |
| 6039 expect(prefix.offset, 7); | 5828 expect(prefix.offset, 7); |
| 6040 expect(prefixedIdentifier.period, isNotNull); | 5829 expect(prefixedIdentifier.period, isNotNull); |
| 6041 SimpleIdentifier identifier = prefixedIdentifier.identifier; | 5830 SimpleIdentifier identifier = prefixedIdentifier.identifier; |
| 6042 expect(identifier.token, isNotNull); | 5831 expect(identifier.token, isNotNull); |
| 6043 expect(identifier.name, "b"); | 5832 expect(identifier.name, "b"); |
| 6044 expect(identifier.offset, 9); | 5833 expect(identifier.offset, 9); |
| 6045 } | 5834 } |
| 6046 | 5835 |
| 6047 void test_parseCommentReference_simple() { | 5836 void test_parseCommentReference_simple() { |
| 6048 CommentReference reference = | 5837 CommentReference reference = |
| 6049 ParserTestCase.parse("parseCommentReference", <Object>["a", 5], ""); | 5838 parse("parseCommentReference", <Object>["a", 5], ""); |
| 6050 SimpleIdentifier identifier = EngineTestCase.assertInstanceOf( | 5839 SimpleIdentifier identifier = EngineTestCase.assertInstanceOf( |
| 6051 (obj) => obj is SimpleIdentifier, SimpleIdentifier, | 5840 (obj) => obj is SimpleIdentifier, SimpleIdentifier, |
| 6052 reference.identifier); | 5841 reference.identifier); |
| 6053 expect(identifier.token, isNotNull); | 5842 expect(identifier.token, isNotNull); |
| 6054 expect(identifier.name, "a"); | 5843 expect(identifier.name, "a"); |
| 6055 expect(identifier.offset, 5); | 5844 expect(identifier.offset, 5); |
| 6056 } | 5845 } |
| 6057 | 5846 |
| 6058 void test_parseCommentReference_synthetic() { | 5847 void test_parseCommentReference_synthetic() { |
| 6059 CommentReference reference = | 5848 CommentReference reference = |
| 6060 ParserTestCase.parse("parseCommentReference", <Object>["", 5], ""); | 5849 parse("parseCommentReference", <Object>["", 5], ""); |
| 6061 SimpleIdentifier identifier = EngineTestCase.assertInstanceOf( | 5850 SimpleIdentifier identifier = EngineTestCase.assertInstanceOf( |
| 6062 (obj) => obj is SimpleIdentifier, SimpleIdentifier, | 5851 (obj) => obj is SimpleIdentifier, SimpleIdentifier, |
| 6063 reference.identifier); | 5852 reference.identifier); |
| 6064 expect(identifier, isNotNull); | 5853 expect(identifier, isNotNull); |
| 6065 expect(identifier.isSynthetic, isTrue); | 5854 expect(identifier.isSynthetic, isTrue); |
| 6066 expect(identifier.token, isNotNull); | 5855 expect(identifier.token, isNotNull); |
| 6067 expect(identifier.name, ""); | 5856 expect(identifier.name, ""); |
| 6068 expect(identifier.offset, 5); | 5857 expect(identifier.offset, 5); |
| 6069 } | 5858 } |
| 6070 | 5859 |
| 6071 void test_parseCommentReferences_multiLine() { | 5860 void test_parseCommentReferences_multiLine() { |
| 6072 DocumentationCommentToken token = new DocumentationCommentToken( | 5861 DocumentationCommentToken token = new DocumentationCommentToken( |
| 6073 TokenType.MULTI_LINE_COMMENT, "/** xxx [a] yyy [bb] zzz */", 3); | 5862 TokenType.MULTI_LINE_COMMENT, "/** xxx [a] yyy [bb] zzz */", 3); |
| 6074 List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[token]; | 5863 List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[token]; |
| 6075 List<CommentReference> references = | 5864 List<CommentReference> references = |
| 6076 ParserTestCase.parse("parseCommentReferences", <Object>[tokens], ""); | 5865 parse("parseCommentReferences", <Object>[tokens], ""); |
| 6077 List<Token> tokenReferences = token.references; | 5866 List<Token> tokenReferences = token.references; |
| 6078 expect(references, hasLength(2)); | 5867 expect(references, hasLength(2)); |
| 6079 expect(tokenReferences, hasLength(2)); | 5868 expect(tokenReferences, hasLength(2)); |
| 6080 { | 5869 { |
| 6081 CommentReference reference = references[0]; | 5870 CommentReference reference = references[0]; |
| 6082 expect(reference, isNotNull); | 5871 expect(reference, isNotNull); |
| 6083 expect(reference.identifier, isNotNull); | 5872 expect(reference.identifier, isNotNull); |
| 6084 expect(reference.offset, 12); | 5873 expect(reference.offset, 12); |
| 6085 // the reference is recorded in the comment token | 5874 // the reference is recorded in the comment token |
| 6086 Token referenceToken = tokenReferences[0]; | 5875 Token referenceToken = tokenReferences[0]; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 6098 expect(referenceToken.lexeme, 'bb'); | 5887 expect(referenceToken.lexeme, 'bb'); |
| 6099 } | 5888 } |
| 6100 } | 5889 } |
| 6101 | 5890 |
| 6102 void test_parseCommentReferences_notClosed_noIdentifier() { | 5891 void test_parseCommentReferences_notClosed_noIdentifier() { |
| 6103 List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[ | 5892 List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[ |
| 6104 new DocumentationCommentToken( | 5893 new DocumentationCommentToken( |
| 6105 TokenType.MULTI_LINE_COMMENT, "/** [ some text", 5) | 5894 TokenType.MULTI_LINE_COMMENT, "/** [ some text", 5) |
| 6106 ]; | 5895 ]; |
| 6107 List<CommentReference> references = | 5896 List<CommentReference> references = |
| 6108 ParserTestCase.parse("parseCommentReferences", <Object>[tokens], ""); | 5897 parse("parseCommentReferences", <Object>[tokens], ""); |
| 6109 expect(references, hasLength(1)); | 5898 expect(references, hasLength(1)); |
| 6110 CommentReference reference = references[0]; | 5899 CommentReference reference = references[0]; |
| 6111 expect(reference, isNotNull); | 5900 expect(reference, isNotNull); |
| 6112 expect(reference.identifier, isNotNull); | 5901 expect(reference.identifier, isNotNull); |
| 6113 expect(reference.identifier.isSynthetic, isTrue); | 5902 expect(reference.identifier.isSynthetic, isTrue); |
| 6114 expect(reference.identifier.name, ""); | 5903 expect(reference.identifier.name, ""); |
| 6115 } | 5904 } |
| 6116 | 5905 |
| 6117 void test_parseCommentReferences_notClosed_withIdentifier() { | 5906 void test_parseCommentReferences_notClosed_withIdentifier() { |
| 6118 List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[ | 5907 List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[ |
| 6119 new DocumentationCommentToken( | 5908 new DocumentationCommentToken( |
| 6120 TokenType.MULTI_LINE_COMMENT, "/** [namePrefix some text", 5) | 5909 TokenType.MULTI_LINE_COMMENT, "/** [namePrefix some text", 5) |
| 6121 ]; | 5910 ]; |
| 6122 List<CommentReference> references = | 5911 List<CommentReference> references = |
| 6123 ParserTestCase.parse("parseCommentReferences", <Object>[tokens], ""); | 5912 parse("parseCommentReferences", <Object>[tokens], ""); |
| 6124 expect(references, hasLength(1)); | 5913 expect(references, hasLength(1)); |
| 6125 CommentReference reference = references[0]; | 5914 CommentReference reference = references[0]; |
| 6126 expect(reference, isNotNull); | 5915 expect(reference, isNotNull); |
| 6127 expect(reference.identifier, isNotNull); | 5916 expect(reference.identifier, isNotNull); |
| 6128 expect(reference.identifier.isSynthetic, isFalse); | 5917 expect(reference.identifier.isSynthetic, isFalse); |
| 6129 expect(reference.identifier.name, "namePrefix"); | 5918 expect(reference.identifier.name, "namePrefix"); |
| 6130 } | 5919 } |
| 6131 | 5920 |
| 6132 void test_parseCommentReferences_singleLine() { | 5921 void test_parseCommentReferences_singleLine() { |
| 6133 List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[ | 5922 List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[ |
| 6134 new DocumentationCommentToken( | 5923 new DocumentationCommentToken( |
| 6135 TokenType.SINGLE_LINE_COMMENT, "/// xxx [a] yyy [b] zzz", 3), | 5924 TokenType.SINGLE_LINE_COMMENT, "/// xxx [a] yyy [b] zzz", 3), |
| 6136 new DocumentationCommentToken( | 5925 new DocumentationCommentToken( |
| 6137 TokenType.SINGLE_LINE_COMMENT, "/// x [c]", 28) | 5926 TokenType.SINGLE_LINE_COMMENT, "/// x [c]", 28) |
| 6138 ]; | 5927 ]; |
| 6139 List<CommentReference> references = | 5928 List<CommentReference> references = |
| 6140 ParserTestCase.parse("parseCommentReferences", <Object>[tokens], ""); | 5929 parse("parseCommentReferences", <Object>[tokens], ""); |
| 6141 expect(references, hasLength(3)); | 5930 expect(references, hasLength(3)); |
| 6142 CommentReference reference = references[0]; | 5931 CommentReference reference = references[0]; |
| 6143 expect(reference, isNotNull); | 5932 expect(reference, isNotNull); |
| 6144 expect(reference.identifier, isNotNull); | 5933 expect(reference.identifier, isNotNull); |
| 6145 expect(reference.offset, 12); | 5934 expect(reference.offset, 12); |
| 6146 reference = references[1]; | 5935 reference = references[1]; |
| 6147 expect(reference, isNotNull); | 5936 expect(reference, isNotNull); |
| 6148 expect(reference.identifier, isNotNull); | 5937 expect(reference.identifier, isNotNull); |
| 6149 expect(reference.offset, 20); | 5938 expect(reference.offset, 20); |
| 6150 reference = references[2]; | 5939 reference = references[2]; |
| 6151 expect(reference, isNotNull); | 5940 expect(reference, isNotNull); |
| 6152 expect(reference.identifier, isNotNull); | 5941 expect(reference.identifier, isNotNull); |
| 6153 expect(reference.offset, 35); | 5942 expect(reference.offset, 35); |
| 6154 } | 5943 } |
| 6155 | 5944 |
| 6156 void test_parseCommentReferences_skipCodeBlock_bracketed() { | 5945 void test_parseCommentReferences_skipCodeBlock_bracketed() { |
| 6157 List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[ | 5946 List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[ |
| 6158 new DocumentationCommentToken( | 5947 new DocumentationCommentToken( |
| 6159 TokenType.MULTI_LINE_COMMENT, "/** [:xxx [a] yyy:] [b] zzz */", 3) | 5948 TokenType.MULTI_LINE_COMMENT, "/** [:xxx [a] yyy:] [b] zzz */", 3) |
| 6160 ]; | 5949 ]; |
| 6161 List<CommentReference> references = | 5950 List<CommentReference> references = |
| 6162 ParserTestCase.parse("parseCommentReferences", <Object>[tokens], ""); | 5951 parse("parseCommentReferences", <Object>[tokens], ""); |
| 6163 expect(references, hasLength(1)); | 5952 expect(references, hasLength(1)); |
| 6164 CommentReference reference = references[0]; | 5953 CommentReference reference = references[0]; |
| 6165 expect(reference, isNotNull); | 5954 expect(reference, isNotNull); |
| 6166 expect(reference.identifier, isNotNull); | 5955 expect(reference.identifier, isNotNull); |
| 6167 expect(reference.offset, 24); | 5956 expect(reference.offset, 24); |
| 6168 } | 5957 } |
| 6169 | 5958 |
| 6170 void test_parseCommentReferences_skipCodeBlock_spaces() { | 5959 void test_parseCommentReferences_skipCodeBlock_spaces() { |
| 6171 List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[ | 5960 List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[ |
| 6172 new DocumentationCommentToken(TokenType.MULTI_LINE_COMMENT, | 5961 new DocumentationCommentToken(TokenType.MULTI_LINE_COMMENT, |
| 6173 "/**\n * a[i]\n * xxx [i] zzz\n */", 3) | 5962 "/**\n * a[i]\n * xxx [i] zzz\n */", 3) |
| 6174 ]; | 5963 ]; |
| 6175 List<CommentReference> references = | 5964 List<CommentReference> references = |
| 6176 ParserTestCase.parse("parseCommentReferences", <Object>[tokens], ""); | 5965 parse("parseCommentReferences", <Object>[tokens], ""); |
| 6177 expect(references, hasLength(1)); | 5966 expect(references, hasLength(1)); |
| 6178 CommentReference reference = references[0]; | 5967 CommentReference reference = references[0]; |
| 6179 expect(reference, isNotNull); | 5968 expect(reference, isNotNull); |
| 6180 expect(reference.identifier, isNotNull); | 5969 expect(reference.identifier, isNotNull); |
| 6181 expect(reference.offset, 27); | 5970 expect(reference.offset, 27); |
| 6182 } | 5971 } |
| 6183 | 5972 |
| 6184 void test_parseCommentReferences_skipLinkDefinition() { | 5973 void test_parseCommentReferences_skipLinkDefinition() { |
| 6185 List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[ | 5974 List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[ |
| 6186 new DocumentationCommentToken(TokenType.MULTI_LINE_COMMENT, | 5975 new DocumentationCommentToken(TokenType.MULTI_LINE_COMMENT, |
| 6187 "/** [a]: http://www.google.com (Google) [b] zzz */", 3) | 5976 "/** [a]: http://www.google.com (Google) [b] zzz */", 3) |
| 6188 ]; | 5977 ]; |
| 6189 List<CommentReference> references = | 5978 List<CommentReference> references = |
| 6190 ParserTestCase.parse("parseCommentReferences", <Object>[tokens], ""); | 5979 parse("parseCommentReferences", <Object>[tokens], ""); |
| 6191 expect(references, hasLength(1)); | 5980 expect(references, hasLength(1)); |
| 6192 CommentReference reference = references[0]; | 5981 CommentReference reference = references[0]; |
| 6193 expect(reference, isNotNull); | 5982 expect(reference, isNotNull); |
| 6194 expect(reference.identifier, isNotNull); | 5983 expect(reference.identifier, isNotNull); |
| 6195 expect(reference.offset, 44); | 5984 expect(reference.offset, 44); |
| 6196 } | 5985 } |
| 6197 | 5986 |
| 6198 void test_parseCommentReferences_skipLinked() { | 5987 void test_parseCommentReferences_skipLinked() { |
| 6199 List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[ | 5988 List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[ |
| 6200 new DocumentationCommentToken(TokenType.MULTI_LINE_COMMENT, | 5989 new DocumentationCommentToken(TokenType.MULTI_LINE_COMMENT, |
| 6201 "/** [a](http://www.google.com) [b] zzz */", 3) | 5990 "/** [a](http://www.google.com) [b] zzz */", 3) |
| 6202 ]; | 5991 ]; |
| 6203 List<CommentReference> references = | 5992 List<CommentReference> references = |
| 6204 ParserTestCase.parse("parseCommentReferences", <Object>[tokens], ""); | 5993 parse("parseCommentReferences", <Object>[tokens], ""); |
| 6205 expect(references, hasLength(1)); | 5994 expect(references, hasLength(1)); |
| 6206 CommentReference reference = references[0]; | 5995 CommentReference reference = references[0]; |
| 6207 expect(reference, isNotNull); | 5996 expect(reference, isNotNull); |
| 6208 expect(reference.identifier, isNotNull); | 5997 expect(reference.identifier, isNotNull); |
| 6209 expect(reference.offset, 35); | 5998 expect(reference.offset, 35); |
| 6210 } | 5999 } |
| 6211 | 6000 |
| 6212 void test_parseCommentReferences_skipReferenceLink() { | 6001 void test_parseCommentReferences_skipReferenceLink() { |
| 6213 List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[ | 6002 List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[ |
| 6214 new DocumentationCommentToken( | 6003 new DocumentationCommentToken( |
| 6215 TokenType.MULTI_LINE_COMMENT, "/** [a][c] [b] zzz */", 3) | 6004 TokenType.MULTI_LINE_COMMENT, "/** [a][c] [b] zzz */", 3) |
| 6216 ]; | 6005 ]; |
| 6217 List<CommentReference> references = | 6006 List<CommentReference> references = |
| 6218 ParserTestCase.parse("parseCommentReferences", <Object>[tokens], ""); | 6007 parse("parseCommentReferences", <Object>[tokens], ""); |
| 6219 expect(references, hasLength(1)); | 6008 expect(references, hasLength(1)); |
| 6220 CommentReference reference = references[0]; | 6009 CommentReference reference = references[0]; |
| 6221 expect(reference, isNotNull); | 6010 expect(reference, isNotNull); |
| 6222 expect(reference.identifier, isNotNull); | 6011 expect(reference.identifier, isNotNull); |
| 6223 expect(reference.offset, 15); | 6012 expect(reference.offset, 15); |
| 6224 } | 6013 } |
| 6225 | 6014 |
| 6226 void test_parseCompilationUnit_abstractAsPrefix_parameterized() { | 6015 void test_parseCompilationUnit_abstractAsPrefix_parameterized() { |
| 6227 CompilationUnit unit = ParserTestCase.parse4("parseCompilationUnit", | 6016 CompilationUnit unit = parse4("parseCompilationUnit", |
| 6228 "abstract<dynamic> _abstract = new abstract.A();"); | 6017 "abstract<dynamic> _abstract = new abstract.A();"); |
| 6229 expect(unit.scriptTag, isNull); | 6018 expect(unit.scriptTag, isNull); |
| 6230 expect(unit.directives, hasLength(0)); | 6019 expect(unit.directives, hasLength(0)); |
| 6231 expect(unit.declarations, hasLength(1)); | 6020 expect(unit.declarations, hasLength(1)); |
| 6232 } | 6021 } |
| 6233 | 6022 |
| 6234 void test_parseCompilationUnit_builtIn_asFunctionName() { | 6023 void test_parseCompilationUnit_builtIn_asFunctionName() { |
| 6235 ParserTestCase.parse4("parseCompilationUnit", "abstract(x) => 0;"); | 6024 parse4("parseCompilationUnit", "abstract(x) => 0;"); |
| 6236 ParserTestCase.parse4("parseCompilationUnit", "as(x) => 0;"); | 6025 parse4("parseCompilationUnit", "as(x) => 0;"); |
| 6237 ParserTestCase.parse4("parseCompilationUnit", "dynamic(x) => 0;"); | 6026 parse4("parseCompilationUnit", "dynamic(x) => 0;"); |
| 6238 ParserTestCase.parse4("parseCompilationUnit", "export(x) => 0;"); | 6027 parse4("parseCompilationUnit", "export(x) => 0;"); |
| 6239 ParserTestCase.parse4("parseCompilationUnit", "external(x) => 0;"); | 6028 parse4("parseCompilationUnit", "external(x) => 0;"); |
| 6240 ParserTestCase.parse4("parseCompilationUnit", "factory(x) => 0;"); | 6029 parse4("parseCompilationUnit", "factory(x) => 0;"); |
| 6241 ParserTestCase.parse4("parseCompilationUnit", "get(x) => 0;"); | 6030 parse4("parseCompilationUnit", "get(x) => 0;"); |
| 6242 ParserTestCase.parse4("parseCompilationUnit", "implements(x) => 0;"); | 6031 parse4("parseCompilationUnit", "implements(x) => 0;"); |
| 6243 ParserTestCase.parse4("parseCompilationUnit", "import(x) => 0;"); | 6032 parse4("parseCompilationUnit", "import(x) => 0;"); |
| 6244 ParserTestCase.parse4("parseCompilationUnit", "library(x) => 0;"); | 6033 parse4("parseCompilationUnit", "library(x) => 0;"); |
| 6245 ParserTestCase.parse4("parseCompilationUnit", "operator(x) => 0;"); | 6034 parse4("parseCompilationUnit", "operator(x) => 0;"); |
| 6246 ParserTestCase.parse4("parseCompilationUnit", "part(x) => 0;"); | 6035 parse4("parseCompilationUnit", "part(x) => 0;"); |
| 6247 ParserTestCase.parse4("parseCompilationUnit", "set(x) => 0;"); | 6036 parse4("parseCompilationUnit", "set(x) => 0;"); |
| 6248 ParserTestCase.parse4("parseCompilationUnit", "static(x) => 0;"); | 6037 parse4("parseCompilationUnit", "static(x) => 0;"); |
| 6249 ParserTestCase.parse4("parseCompilationUnit", "typedef(x) => 0;"); | 6038 parse4("parseCompilationUnit", "typedef(x) => 0;"); |
| 6250 } | 6039 } |
| 6251 | 6040 |
| 6252 void test_parseCompilationUnit_directives_multiple() { | 6041 void test_parseCompilationUnit_directives_multiple() { |
| 6253 CompilationUnit unit = ParserTestCase.parse4( | 6042 CompilationUnit unit = |
| 6254 "parseCompilationUnit", "library l;\npart 'a.dart';"); | 6043 parse4("parseCompilationUnit", "library l;\npart 'a.dart';"); |
| 6255 expect(unit.scriptTag, isNull); | 6044 expect(unit.scriptTag, isNull); |
| 6256 expect(unit.directives, hasLength(2)); | 6045 expect(unit.directives, hasLength(2)); |
| 6257 expect(unit.declarations, hasLength(0)); | 6046 expect(unit.declarations, hasLength(0)); |
| 6258 } | 6047 } |
| 6259 | 6048 |
| 6260 void test_parseCompilationUnit_directives_single() { | 6049 void test_parseCompilationUnit_directives_single() { |
| 6261 CompilationUnit unit = | 6050 CompilationUnit unit = parse4("parseCompilationUnit", "library l;"); |
| 6262 ParserTestCase.parse4("parseCompilationUnit", "library l;"); | |
| 6263 expect(unit.scriptTag, isNull); | 6051 expect(unit.scriptTag, isNull); |
| 6264 expect(unit.directives, hasLength(1)); | 6052 expect(unit.directives, hasLength(1)); |
| 6265 expect(unit.declarations, hasLength(0)); | 6053 expect(unit.declarations, hasLength(0)); |
| 6266 } | 6054 } |
| 6267 | 6055 |
| 6268 void test_parseCompilationUnit_empty() { | 6056 void test_parseCompilationUnit_empty() { |
| 6269 CompilationUnit unit = ParserTestCase.parse4("parseCompilationUnit", ""); | 6057 CompilationUnit unit = parse4("parseCompilationUnit", ""); |
| 6270 expect(unit.scriptTag, isNull); | 6058 expect(unit.scriptTag, isNull); |
| 6271 expect(unit.directives, hasLength(0)); | 6059 expect(unit.directives, hasLength(0)); |
| 6272 expect(unit.declarations, hasLength(0)); | 6060 expect(unit.declarations, hasLength(0)); |
| 6273 } | 6061 } |
| 6274 | 6062 |
| 6275 void test_parseCompilationUnit_exportAsPrefix() { | 6063 void test_parseCompilationUnit_exportAsPrefix() { |
| 6276 CompilationUnit unit = ParserTestCase.parse4( | 6064 CompilationUnit unit = |
| 6277 "parseCompilationUnit", "export.A _export = new export.A();"); | 6065 parse4("parseCompilationUnit", "export.A _export = new export.A();"); |
| 6278 expect(unit.scriptTag, isNull); | 6066 expect(unit.scriptTag, isNull); |
| 6279 expect(unit.directives, hasLength(0)); | 6067 expect(unit.directives, hasLength(0)); |
| 6280 expect(unit.declarations, hasLength(1)); | 6068 expect(unit.declarations, hasLength(1)); |
| 6281 } | 6069 } |
| 6282 | 6070 |
| 6283 void test_parseCompilationUnit_exportAsPrefix_parameterized() { | 6071 void test_parseCompilationUnit_exportAsPrefix_parameterized() { |
| 6284 CompilationUnit unit = ParserTestCase.parse4( | 6072 CompilationUnit unit = parse4( |
| 6285 "parseCompilationUnit", "export<dynamic> _export = new export.A();"); | 6073 "parseCompilationUnit", "export<dynamic> _export = new export.A();"); |
| 6286 expect(unit.scriptTag, isNull); | 6074 expect(unit.scriptTag, isNull); |
| 6287 expect(unit.directives, hasLength(0)); | 6075 expect(unit.directives, hasLength(0)); |
| 6288 expect(unit.declarations, hasLength(1)); | 6076 expect(unit.declarations, hasLength(1)); |
| 6289 } | 6077 } |
| 6290 | 6078 |
| 6291 void test_parseCompilationUnit_operatorAsPrefix_parameterized() { | 6079 void test_parseCompilationUnit_operatorAsPrefix_parameterized() { |
| 6292 CompilationUnit unit = ParserTestCase.parse4("parseCompilationUnit", | 6080 CompilationUnit unit = parse4("parseCompilationUnit", |
| 6293 "operator<dynamic> _operator = new operator.A();"); | 6081 "operator<dynamic> _operator = new operator.A();"); |
| 6294 expect(unit.scriptTag, isNull); | 6082 expect(unit.scriptTag, isNull); |
| 6295 expect(unit.directives, hasLength(0)); | 6083 expect(unit.directives, hasLength(0)); |
| 6296 expect(unit.declarations, hasLength(1)); | 6084 expect(unit.declarations, hasLength(1)); |
| 6297 } | 6085 } |
| 6298 | 6086 |
| 6299 void test_parseCompilationUnit_script() { | 6087 void test_parseCompilationUnit_script() { |
| 6300 CompilationUnit unit = | 6088 CompilationUnit unit = parse4("parseCompilationUnit", "#! /bin/dart"); |
| 6301 ParserTestCase.parse4("parseCompilationUnit", "#! /bin/dart"); | |
| 6302 expect(unit.scriptTag, isNotNull); | 6089 expect(unit.scriptTag, isNotNull); |
| 6303 expect(unit.directives, hasLength(0)); | 6090 expect(unit.directives, hasLength(0)); |
| 6304 expect(unit.declarations, hasLength(0)); | 6091 expect(unit.declarations, hasLength(0)); |
| 6305 } | 6092 } |
| 6306 | 6093 |
| 6307 void test_parseCompilationUnit_skipFunctionBody_withInterpolation() { | 6094 void test_parseCompilationUnit_skipFunctionBody_withInterpolation() { |
| 6308 ParserTestCase.parseFunctionBodies = false; | 6095 ParserTestCase.parseFunctionBodies = false; |
| 6309 CompilationUnit unit = | 6096 CompilationUnit unit = parse4("parseCompilationUnit", "f() { '\${n}'; }"); |
| 6310 ParserTestCase.parse4("parseCompilationUnit", "f() { '\${n}'; }"); | |
| 6311 expect(unit.scriptTag, isNull); | 6097 expect(unit.scriptTag, isNull); |
| 6312 expect(unit.declarations, hasLength(1)); | 6098 expect(unit.declarations, hasLength(1)); |
| 6313 } | 6099 } |
| 6314 | 6100 |
| 6315 void test_parseCompilationUnit_topLevelDeclaration() { | 6101 void test_parseCompilationUnit_topLevelDeclaration() { |
| 6316 CompilationUnit unit = | 6102 CompilationUnit unit = parse4("parseCompilationUnit", "class A {}"); |
| 6317 ParserTestCase.parse4("parseCompilationUnit", "class A {}"); | |
| 6318 expect(unit.scriptTag, isNull); | 6103 expect(unit.scriptTag, isNull); |
| 6319 expect(unit.directives, hasLength(0)); | 6104 expect(unit.directives, hasLength(0)); |
| 6320 expect(unit.declarations, hasLength(1)); | 6105 expect(unit.declarations, hasLength(1)); |
| 6321 } | 6106 } |
| 6322 | 6107 |
| 6323 void test_parseCompilationUnit_typedefAsPrefix() { | 6108 void test_parseCompilationUnit_typedefAsPrefix() { |
| 6324 CompilationUnit unit = ParserTestCase.parse4( | 6109 CompilationUnit unit = |
| 6325 "parseCompilationUnit", "typedef.A _typedef = new typedef.A();"); | 6110 parse4("parseCompilationUnit", "typedef.A _typedef = new typedef.A();"); |
| 6326 expect(unit.scriptTag, isNull); | 6111 expect(unit.scriptTag, isNull); |
| 6327 expect(unit.directives, hasLength(0)); | 6112 expect(unit.directives, hasLength(0)); |
| 6328 expect(unit.declarations, hasLength(1)); | 6113 expect(unit.declarations, hasLength(1)); |
| 6329 } | 6114 } |
| 6330 | 6115 |
| 6331 void test_parseCompilationUnitMember_abstractAsPrefix() { | 6116 void test_parseCompilationUnitMember_abstractAsPrefix() { |
| 6332 TopLevelVariableDeclaration declaration = ParserTestCase.parse( | 6117 TopLevelVariableDeclaration declaration = parse( |
| 6333 "parseCompilationUnitMember", <Object>[ | 6118 "parseCompilationUnitMember", <Object>[emptyCommentAndMetadata()], |
| 6334 emptyCommentAndMetadata() | 6119 "abstract.A _abstract = new abstract.A();"); |
| 6335 ], "abstract.A _abstract = new abstract.A();"); | |
| 6336 expect(declaration.semicolon, isNotNull); | 6120 expect(declaration.semicolon, isNotNull); |
| 6337 expect(declaration.variables, isNotNull); | 6121 expect(declaration.variables, isNotNull); |
| 6338 } | 6122 } |
| 6339 | 6123 |
| 6340 void test_parseCompilationUnitMember_class() { | 6124 void test_parseCompilationUnitMember_class() { |
| 6341 ClassDeclaration declaration = ParserTestCase.parse( | 6125 ClassDeclaration declaration = parse("parseCompilationUnitMember", |
| 6342 "parseCompilationUnitMember", <Object>[ | 6126 <Object>[emptyCommentAndMetadata()], "class A {}"); |
| 6343 emptyCommentAndMetadata() | |
| 6344 ], "class A {}"); | |
| 6345 expect(declaration.name.name, "A"); | 6127 expect(declaration.name.name, "A"); |
| 6346 expect(declaration.members, hasLength(0)); | 6128 expect(declaration.members, hasLength(0)); |
| 6347 } | 6129 } |
| 6348 | 6130 |
| 6349 void test_parseCompilationUnitMember_classTypeAlias() { | 6131 void test_parseCompilationUnitMember_classTypeAlias() { |
| 6350 ClassTypeAlias alias = ParserTestCase.parse("parseCompilationUnitMember", | 6132 ClassTypeAlias alias = parse("parseCompilationUnitMember", |
| 6351 <Object>[emptyCommentAndMetadata()], "abstract class A = B with C;"); | 6133 <Object>[emptyCommentAndMetadata()], "abstract class A = B with C;"); |
| 6352 expect(alias.name.name, "A"); | 6134 expect(alias.name.name, "A"); |
| 6353 expect(alias.abstractKeyword, isNotNull); | 6135 expect(alias.abstractKeyword, isNotNull); |
| 6354 } | 6136 } |
| 6355 | 6137 |
| 6356 void test_parseCompilationUnitMember_constVariable() { | 6138 void test_parseCompilationUnitMember_constVariable() { |
| 6357 TopLevelVariableDeclaration declaration = ParserTestCase.parse( | 6139 TopLevelVariableDeclaration declaration = parse( |
| 6358 "parseCompilationUnitMember", <Object>[ | 6140 "parseCompilationUnitMember", <Object>[emptyCommentAndMetadata()], |
| 6359 emptyCommentAndMetadata() | 6141 "const int x = 0;"); |
| 6360 ], "const int x = 0;"); | |
| 6361 expect(declaration.semicolon, isNotNull); | 6142 expect(declaration.semicolon, isNotNull); |
| 6362 expect(declaration.variables, isNotNull); | 6143 expect(declaration.variables, isNotNull); |
| 6363 } | 6144 } |
| 6364 | 6145 |
| 6365 void test_parseCompilationUnitMember_finalVariable() { | 6146 void test_parseCompilationUnitMember_finalVariable() { |
| 6366 TopLevelVariableDeclaration declaration = ParserTestCase.parse( | 6147 TopLevelVariableDeclaration declaration = parse( |
| 6367 "parseCompilationUnitMember", <Object>[ | 6148 "parseCompilationUnitMember", <Object>[emptyCommentAndMetadata()], |
| 6368 emptyCommentAndMetadata() | 6149 "final x = 0;"); |
| 6369 ], "final x = 0;"); | |
| 6370 expect(declaration.semicolon, isNotNull); | 6150 expect(declaration.semicolon, isNotNull); |
| 6371 expect(declaration.variables, isNotNull); | 6151 expect(declaration.variables, isNotNull); |
| 6372 } | 6152 } |
| 6373 | 6153 |
| 6374 void test_parseCompilationUnitMember_function_external_noType() { | 6154 void test_parseCompilationUnitMember_function_external_noType() { |
| 6375 FunctionDeclaration declaration = ParserTestCase.parse( | 6155 FunctionDeclaration declaration = parse("parseCompilationUnitMember", |
| 6376 "parseCompilationUnitMember", <Object>[ | 6156 <Object>[emptyCommentAndMetadata()], "external f();"); |
| 6377 emptyCommentAndMetadata() | |
| 6378 ], "external f();"); | |
| 6379 expect(declaration.externalKeyword, isNotNull); | 6157 expect(declaration.externalKeyword, isNotNull); |
| 6380 expect(declaration.functionExpression, isNotNull); | 6158 expect(declaration.functionExpression, isNotNull); |
| 6381 expect(declaration.propertyKeyword, isNull); | 6159 expect(declaration.propertyKeyword, isNull); |
| 6382 } | 6160 } |
| 6383 | 6161 |
| 6384 void test_parseCompilationUnitMember_function_external_type() { | 6162 void test_parseCompilationUnitMember_function_external_type() { |
| 6385 FunctionDeclaration declaration = ParserTestCase.parse( | 6163 FunctionDeclaration declaration = parse("parseCompilationUnitMember", |
| 6386 "parseCompilationUnitMember", <Object>[ | 6164 <Object>[emptyCommentAndMetadata()], "external int f();"); |
| 6387 emptyCommentAndMetadata() | |
| 6388 ], "external int f();"); | |
| 6389 expect(declaration.externalKeyword, isNotNull); | 6165 expect(declaration.externalKeyword, isNotNull); |
| 6390 expect(declaration.functionExpression, isNotNull); | 6166 expect(declaration.functionExpression, isNotNull); |
| 6391 expect(declaration.propertyKeyword, isNull); | 6167 expect(declaration.propertyKeyword, isNull); |
| 6392 } | 6168 } |
| 6393 | 6169 |
| 6394 void test_parseCompilationUnitMember_function_noType() { | 6170 void test_parseCompilationUnitMember_function_noType() { |
| 6395 FunctionDeclaration declaration = ParserTestCase.parse( | 6171 FunctionDeclaration declaration = parse("parseCompilationUnitMember", |
| 6396 "parseCompilationUnitMember", <Object>[ | 6172 <Object>[emptyCommentAndMetadata()], "f() {}"); |
| 6397 emptyCommentAndMetadata() | |
| 6398 ], "f() {}"); | |
| 6399 expect(declaration.functionExpression, isNotNull); | 6173 expect(declaration.functionExpression, isNotNull); |
| 6400 expect(declaration.propertyKeyword, isNull); | 6174 expect(declaration.propertyKeyword, isNull); |
| 6401 } | 6175 } |
| 6402 | 6176 |
| 6403 void test_parseCompilationUnitMember_function_type() { | 6177 void test_parseCompilationUnitMember_function_type() { |
| 6404 FunctionDeclaration declaration = ParserTestCase.parse( | 6178 FunctionDeclaration declaration = parse("parseCompilationUnitMember", |
| 6405 "parseCompilationUnitMember", <Object>[ | 6179 <Object>[emptyCommentAndMetadata()], "int f() {}"); |
| 6406 emptyCommentAndMetadata() | |
| 6407 ], "int f() {}"); | |
| 6408 expect(declaration.functionExpression, isNotNull); | 6180 expect(declaration.functionExpression, isNotNull); |
| 6409 expect(declaration.propertyKeyword, isNull); | 6181 expect(declaration.propertyKeyword, isNull); |
| 6410 } | 6182 } |
| 6411 | 6183 |
| 6412 void test_parseCompilationUnitMember_function_void() { | 6184 void test_parseCompilationUnitMember_function_void() { |
| 6413 FunctionDeclaration declaration = ParserTestCase.parse( | 6185 FunctionDeclaration declaration = parse("parseCompilationUnitMember", |
| 6414 "parseCompilationUnitMember", <Object>[ | 6186 <Object>[emptyCommentAndMetadata()], "void f() {}"); |
| 6415 emptyCommentAndMetadata() | |
| 6416 ], "void f() {}"); | |
| 6417 expect(declaration.returnType, isNotNull); | 6187 expect(declaration.returnType, isNotNull); |
| 6418 } | 6188 } |
| 6419 | 6189 |
| 6420 void test_parseCompilationUnitMember_getter_external_noType() { | 6190 void test_parseCompilationUnitMember_getter_external_noType() { |
| 6421 FunctionDeclaration declaration = ParserTestCase.parse( | 6191 FunctionDeclaration declaration = parse("parseCompilationUnitMember", |
| 6422 "parseCompilationUnitMember", <Object>[ | 6192 <Object>[emptyCommentAndMetadata()], "external get p;"); |
| 6423 emptyCommentAndMetadata() | |
| 6424 ], "external get p;"); | |
| 6425 expect(declaration.externalKeyword, isNotNull); | 6193 expect(declaration.externalKeyword, isNotNull); |
| 6426 expect(declaration.functionExpression, isNotNull); | 6194 expect(declaration.functionExpression, isNotNull); |
| 6427 expect(declaration.propertyKeyword, isNotNull); | 6195 expect(declaration.propertyKeyword, isNotNull); |
| 6428 } | 6196 } |
| 6429 | 6197 |
| 6430 void test_parseCompilationUnitMember_getter_external_type() { | 6198 void test_parseCompilationUnitMember_getter_external_type() { |
| 6431 FunctionDeclaration declaration = ParserTestCase.parse( | 6199 FunctionDeclaration declaration = parse("parseCompilationUnitMember", |
| 6432 "parseCompilationUnitMember", <Object>[ | 6200 <Object>[emptyCommentAndMetadata()], "external int get p;"); |
| 6433 emptyCommentAndMetadata() | |
| 6434 ], "external int get p;"); | |
| 6435 expect(declaration.externalKeyword, isNotNull); | 6201 expect(declaration.externalKeyword, isNotNull); |
| 6436 expect(declaration.functionExpression, isNotNull); | 6202 expect(declaration.functionExpression, isNotNull); |
| 6437 expect(declaration.propertyKeyword, isNotNull); | 6203 expect(declaration.propertyKeyword, isNotNull); |
| 6438 } | 6204 } |
| 6439 | 6205 |
| 6440 void test_parseCompilationUnitMember_getter_noType() { | 6206 void test_parseCompilationUnitMember_getter_noType() { |
| 6441 FunctionDeclaration declaration = ParserTestCase.parse( | 6207 FunctionDeclaration declaration = parse("parseCompilationUnitMember", |
| 6442 "parseCompilationUnitMember", <Object>[ | 6208 <Object>[emptyCommentAndMetadata()], "get p => 0;"); |
| 6443 emptyCommentAndMetadata() | |
| 6444 ], "get p => 0;"); | |
| 6445 expect(declaration.functionExpression, isNotNull); | 6209 expect(declaration.functionExpression, isNotNull); |
| 6446 expect(declaration.propertyKeyword, isNotNull); | 6210 expect(declaration.propertyKeyword, isNotNull); |
| 6447 } | 6211 } |
| 6448 | 6212 |
| 6449 void test_parseCompilationUnitMember_getter_type() { | 6213 void test_parseCompilationUnitMember_getter_type() { |
| 6450 FunctionDeclaration declaration = ParserTestCase.parse( | 6214 FunctionDeclaration declaration = parse("parseCompilationUnitMember", |
| 6451 "parseCompilationUnitMember", <Object>[ | 6215 <Object>[emptyCommentAndMetadata()], "int get p => 0;"); |
| 6452 emptyCommentAndMetadata() | |
| 6453 ], "int get p => 0;"); | |
| 6454 expect(declaration.functionExpression, isNotNull); | 6216 expect(declaration.functionExpression, isNotNull); |
| 6455 expect(declaration.propertyKeyword, isNotNull); | 6217 expect(declaration.propertyKeyword, isNotNull); |
| 6456 } | 6218 } |
| 6457 | 6219 |
| 6458 void test_parseCompilationUnitMember_setter_external_noType() { | 6220 void test_parseCompilationUnitMember_setter_external_noType() { |
| 6459 FunctionDeclaration declaration = ParserTestCase.parse( | 6221 FunctionDeclaration declaration = parse("parseCompilationUnitMember", |
| 6460 "parseCompilationUnitMember", <Object>[ | 6222 <Object>[emptyCommentAndMetadata()], "external set p(v);"); |
| 6461 emptyCommentAndMetadata() | |
| 6462 ], "external set p(v);"); | |
| 6463 expect(declaration.externalKeyword, isNotNull); | 6223 expect(declaration.externalKeyword, isNotNull); |
| 6464 expect(declaration.functionExpression, isNotNull); | 6224 expect(declaration.functionExpression, isNotNull); |
| 6465 expect(declaration.propertyKeyword, isNotNull); | 6225 expect(declaration.propertyKeyword, isNotNull); |
| 6466 } | 6226 } |
| 6467 | 6227 |
| 6468 void test_parseCompilationUnitMember_setter_external_type() { | 6228 void test_parseCompilationUnitMember_setter_external_type() { |
| 6469 FunctionDeclaration declaration = ParserTestCase.parse( | 6229 FunctionDeclaration declaration = parse("parseCompilationUnitMember", |
| 6470 "parseCompilationUnitMember", <Object>[ | 6230 <Object>[emptyCommentAndMetadata()], "external void set p(int v);"); |
| 6471 emptyCommentAndMetadata() | |
| 6472 ], "external void set p(int v);"); | |
| 6473 expect(declaration.externalKeyword, isNotNull); | 6231 expect(declaration.externalKeyword, isNotNull); |
| 6474 expect(declaration.functionExpression, isNotNull); | 6232 expect(declaration.functionExpression, isNotNull); |
| 6475 expect(declaration.propertyKeyword, isNotNull); | 6233 expect(declaration.propertyKeyword, isNotNull); |
| 6476 } | 6234 } |
| 6477 | 6235 |
| 6478 void test_parseCompilationUnitMember_setter_noType() { | 6236 void test_parseCompilationUnitMember_setter_noType() { |
| 6479 FunctionDeclaration declaration = ParserTestCase.parse( | 6237 FunctionDeclaration declaration = parse("parseCompilationUnitMember", |
| 6480 "parseCompilationUnitMember", <Object>[ | 6238 <Object>[emptyCommentAndMetadata()], "set p(v) {}"); |
| 6481 emptyCommentAndMetadata() | |
| 6482 ], "set p(v) {}"); | |
| 6483 expect(declaration.functionExpression, isNotNull); | 6239 expect(declaration.functionExpression, isNotNull); |
| 6484 expect(declaration.propertyKeyword, isNotNull); | 6240 expect(declaration.propertyKeyword, isNotNull); |
| 6485 } | 6241 } |
| 6486 | 6242 |
| 6487 void test_parseCompilationUnitMember_setter_type() { | 6243 void test_parseCompilationUnitMember_setter_type() { |
| 6488 FunctionDeclaration declaration = ParserTestCase.parse( | 6244 FunctionDeclaration declaration = parse("parseCompilationUnitMember", |
| 6489 "parseCompilationUnitMember", <Object>[ | 6245 <Object>[emptyCommentAndMetadata()], "void set p(int v) {}"); |
| 6490 emptyCommentAndMetadata() | |
| 6491 ], "void set p(int v) {}"); | |
| 6492 expect(declaration.functionExpression, isNotNull); | 6246 expect(declaration.functionExpression, isNotNull); |
| 6493 expect(declaration.propertyKeyword, isNotNull); | 6247 expect(declaration.propertyKeyword, isNotNull); |
| 6494 expect(declaration.returnType, isNotNull); | 6248 expect(declaration.returnType, isNotNull); |
| 6495 } | 6249 } |
| 6496 | 6250 |
| 6497 void test_parseCompilationUnitMember_typeAlias_abstract() { | 6251 void test_parseCompilationUnitMember_typeAlias_abstract() { |
| 6498 ClassTypeAlias typeAlias = ParserTestCase.parse( | 6252 ClassTypeAlias typeAlias = parse("parseCompilationUnitMember", |
| 6499 "parseCompilationUnitMember", <Object>[ | 6253 <Object>[emptyCommentAndMetadata()], "abstract class C = S with M;"); |
| 6500 emptyCommentAndMetadata() | |
| 6501 ], "abstract class C = S with M;"); | |
| 6502 expect(typeAlias.typedefKeyword, isNotNull); | 6254 expect(typeAlias.typedefKeyword, isNotNull); |
| 6503 expect(typeAlias.name.name, "C"); | 6255 expect(typeAlias.name.name, "C"); |
| 6504 expect(typeAlias.typeParameters, isNull); | 6256 expect(typeAlias.typeParameters, isNull); |
| 6505 expect(typeAlias.equals, isNotNull); | 6257 expect(typeAlias.equals, isNotNull); |
| 6506 expect(typeAlias.abstractKeyword, isNotNull); | 6258 expect(typeAlias.abstractKeyword, isNotNull); |
| 6507 expect(typeAlias.superclass.name.name, "S"); | 6259 expect(typeAlias.superclass.name.name, "S"); |
| 6508 expect(typeAlias.withClause, isNotNull); | 6260 expect(typeAlias.withClause, isNotNull); |
| 6509 expect(typeAlias.implementsClause, isNull); | 6261 expect(typeAlias.implementsClause, isNull); |
| 6510 expect(typeAlias.semicolon, isNotNull); | 6262 expect(typeAlias.semicolon, isNotNull); |
| 6511 } | 6263 } |
| 6512 | 6264 |
| 6513 void test_parseCompilationUnitMember_typeAlias_generic() { | 6265 void test_parseCompilationUnitMember_typeAlias_generic() { |
| 6514 ClassTypeAlias typeAlias = ParserTestCase.parse( | 6266 ClassTypeAlias typeAlias = parse("parseCompilationUnitMember", |
| 6515 "parseCompilationUnitMember", <Object>[ | 6267 <Object>[emptyCommentAndMetadata()], |
| 6516 emptyCommentAndMetadata() | 6268 "class C<E> = S<E> with M<E> implements I<E>;"); |
| 6517 ], "class C<E> = S<E> with M<E> implements I<E>;"); | |
| 6518 expect(typeAlias.typedefKeyword, isNotNull); | 6269 expect(typeAlias.typedefKeyword, isNotNull); |
| 6519 expect(typeAlias.name.name, "C"); | 6270 expect(typeAlias.name.name, "C"); |
| 6520 expect(typeAlias.typeParameters.typeParameters, hasLength(1)); | 6271 expect(typeAlias.typeParameters.typeParameters, hasLength(1)); |
| 6521 expect(typeAlias.equals, isNotNull); | 6272 expect(typeAlias.equals, isNotNull); |
| 6522 expect(typeAlias.abstractKeyword, isNull); | 6273 expect(typeAlias.abstractKeyword, isNull); |
| 6523 expect(typeAlias.superclass.name.name, "S"); | 6274 expect(typeAlias.superclass.name.name, "S"); |
| 6524 expect(typeAlias.withClause, isNotNull); | 6275 expect(typeAlias.withClause, isNotNull); |
| 6525 expect(typeAlias.implementsClause, isNotNull); | 6276 expect(typeAlias.implementsClause, isNotNull); |
| 6526 expect(typeAlias.semicolon, isNotNull); | 6277 expect(typeAlias.semicolon, isNotNull); |
| 6527 } | 6278 } |
| 6528 | 6279 |
| 6529 void test_parseCompilationUnitMember_typeAlias_implements() { | 6280 void test_parseCompilationUnitMember_typeAlias_implements() { |
| 6530 ClassTypeAlias typeAlias = ParserTestCase.parse( | 6281 ClassTypeAlias typeAlias = parse("parseCompilationUnitMember", |
| 6531 "parseCompilationUnitMember", <Object>[ | 6282 <Object>[emptyCommentAndMetadata()], |
| 6532 emptyCommentAndMetadata() | 6283 "class C = S with M implements I;"); |
| 6533 ], "class C = S with M implements I;"); | |
| 6534 expect(typeAlias.typedefKeyword, isNotNull); | 6284 expect(typeAlias.typedefKeyword, isNotNull); |
| 6535 expect(typeAlias.name.name, "C"); | 6285 expect(typeAlias.name.name, "C"); |
| 6536 expect(typeAlias.typeParameters, isNull); | 6286 expect(typeAlias.typeParameters, isNull); |
| 6537 expect(typeAlias.equals, isNotNull); | 6287 expect(typeAlias.equals, isNotNull); |
| 6538 expect(typeAlias.abstractKeyword, isNull); | 6288 expect(typeAlias.abstractKeyword, isNull); |
| 6539 expect(typeAlias.superclass.name.name, "S"); | 6289 expect(typeAlias.superclass.name.name, "S"); |
| 6540 expect(typeAlias.withClause, isNotNull); | 6290 expect(typeAlias.withClause, isNotNull); |
| 6541 expect(typeAlias.implementsClause, isNotNull); | 6291 expect(typeAlias.implementsClause, isNotNull); |
| 6542 expect(typeAlias.semicolon, isNotNull); | 6292 expect(typeAlias.semicolon, isNotNull); |
| 6543 } | 6293 } |
| 6544 | 6294 |
| 6545 void test_parseCompilationUnitMember_typeAlias_noImplements() { | 6295 void test_parseCompilationUnitMember_typeAlias_noImplements() { |
| 6546 ClassTypeAlias typeAlias = ParserTestCase.parse( | 6296 ClassTypeAlias typeAlias = parse("parseCompilationUnitMember", |
| 6547 "parseCompilationUnitMember", <Object>[ | 6297 <Object>[emptyCommentAndMetadata()], "class C = S with M;"); |
| 6548 emptyCommentAndMetadata() | |
| 6549 ], "class C = S with M;"); | |
| 6550 expect(typeAlias.typedefKeyword, isNotNull); | 6298 expect(typeAlias.typedefKeyword, isNotNull); |
| 6551 expect(typeAlias.name.name, "C"); | 6299 expect(typeAlias.name.name, "C"); |
| 6552 expect(typeAlias.typeParameters, isNull); | 6300 expect(typeAlias.typeParameters, isNull); |
| 6553 expect(typeAlias.equals, isNotNull); | 6301 expect(typeAlias.equals, isNotNull); |
| 6554 expect(typeAlias.abstractKeyword, isNull); | 6302 expect(typeAlias.abstractKeyword, isNull); |
| 6555 expect(typeAlias.superclass.name.name, "S"); | 6303 expect(typeAlias.superclass.name.name, "S"); |
| 6556 expect(typeAlias.withClause, isNotNull); | 6304 expect(typeAlias.withClause, isNotNull); |
| 6557 expect(typeAlias.implementsClause, isNull); | 6305 expect(typeAlias.implementsClause, isNull); |
| 6558 expect(typeAlias.semicolon, isNotNull); | 6306 expect(typeAlias.semicolon, isNotNull); |
| 6559 } | 6307 } |
| 6560 | 6308 |
| 6561 void test_parseCompilationUnitMember_typedef() { | 6309 void test_parseCompilationUnitMember_typedef() { |
| 6562 FunctionTypeAlias typeAlias = ParserTestCase.parse( | 6310 FunctionTypeAlias typeAlias = parse("parseCompilationUnitMember", |
| 6563 "parseCompilationUnitMember", <Object>[ | 6311 <Object>[emptyCommentAndMetadata()], "typedef F();"); |
| 6564 emptyCommentAndMetadata() | |
| 6565 ], "typedef F();"); | |
| 6566 expect(typeAlias.name.name, "F"); | 6312 expect(typeAlias.name.name, "F"); |
| 6567 expect(typeAlias.parameters.parameters, hasLength(0)); | 6313 expect(typeAlias.parameters.parameters, hasLength(0)); |
| 6568 } | 6314 } |
| 6569 | 6315 |
| 6570 void test_parseCompilationUnitMember_variable() { | 6316 void test_parseCompilationUnitMember_variable() { |
| 6571 TopLevelVariableDeclaration declaration = ParserTestCase.parse( | 6317 TopLevelVariableDeclaration declaration = parse( |
| 6572 "parseCompilationUnitMember", <Object>[ | 6318 "parseCompilationUnitMember", <Object>[emptyCommentAndMetadata()], |
| 6573 emptyCommentAndMetadata() | 6319 "var x = 0;"); |
| 6574 ], "var x = 0;"); | |
| 6575 expect(declaration.semicolon, isNotNull); | 6320 expect(declaration.semicolon, isNotNull); |
| 6576 expect(declaration.variables, isNotNull); | 6321 expect(declaration.variables, isNotNull); |
| 6577 } | 6322 } |
| 6578 | 6323 |
| 6579 void test_parseCompilationUnitMember_variableGet() { | 6324 void test_parseCompilationUnitMember_variableGet() { |
| 6580 TopLevelVariableDeclaration declaration = ParserTestCase.parse( | 6325 TopLevelVariableDeclaration declaration = parse( |
| 6581 "parseCompilationUnitMember", <Object>[ | 6326 "parseCompilationUnitMember", <Object>[emptyCommentAndMetadata()], |
| 6582 emptyCommentAndMetadata() | 6327 "String get = null;"); |
| 6583 ], "String get = null;"); | |
| 6584 expect(declaration.semicolon, isNotNull); | 6328 expect(declaration.semicolon, isNotNull); |
| 6585 expect(declaration.variables, isNotNull); | 6329 expect(declaration.variables, isNotNull); |
| 6586 } | 6330 } |
| 6587 | 6331 |
| 6588 void test_parseCompilationUnitMember_variableSet() { | 6332 void test_parseCompilationUnitMember_variableSet() { |
| 6589 TopLevelVariableDeclaration declaration = ParserTestCase.parse( | 6333 TopLevelVariableDeclaration declaration = parse( |
| 6590 "parseCompilationUnitMember", <Object>[ | 6334 "parseCompilationUnitMember", <Object>[emptyCommentAndMetadata()], |
| 6591 emptyCommentAndMetadata() | 6335 "String set = null;"); |
| 6592 ], "String set = null;"); | |
| 6593 expect(declaration.semicolon, isNotNull); | 6336 expect(declaration.semicolon, isNotNull); |
| 6594 expect(declaration.variables, isNotNull); | 6337 expect(declaration.variables, isNotNull); |
| 6595 } | 6338 } |
| 6596 | 6339 |
| 6597 void test_parseConditionalExpression() { | 6340 void test_parseConditionalExpression() { |
| 6598 ConditionalExpression expression = | 6341 ConditionalExpression expression = |
| 6599 ParserTestCase.parse4("parseConditionalExpression", "x ? y : z"); | 6342 parse4("parseConditionalExpression", "x ? y : z"); |
| 6600 expect(expression.condition, isNotNull); | 6343 expect(expression.condition, isNotNull); |
| 6601 expect(expression.question, isNotNull); | 6344 expect(expression.question, isNotNull); |
| 6602 expect(expression.thenExpression, isNotNull); | 6345 expect(expression.thenExpression, isNotNull); |
| 6603 expect(expression.colon, isNotNull); | 6346 expect(expression.colon, isNotNull); |
| 6604 expect(expression.elseExpression, isNotNull); | 6347 expect(expression.elseExpression, isNotNull); |
| 6605 } | 6348 } |
| 6606 | 6349 |
| 6607 void test_parseConstExpression_instanceCreation() { | 6350 void test_parseConstExpression_instanceCreation() { |
| 6608 InstanceCreationExpression expression = | 6351 InstanceCreationExpression expression = |
| 6609 ParserTestCase.parse4("parseConstExpression", "const A()"); | 6352 parse4("parseConstExpression", "const A()"); |
| 6610 expect(expression.keyword, isNotNull); | 6353 expect(expression.keyword, isNotNull); |
| 6611 ConstructorName name = expression.constructorName; | 6354 ConstructorName name = expression.constructorName; |
| 6612 expect(name, isNotNull); | 6355 expect(name, isNotNull); |
| 6613 expect(name.type, isNotNull); | 6356 expect(name.type, isNotNull); |
| 6614 expect(name.period, isNull); | 6357 expect(name.period, isNull); |
| 6615 expect(name.name, isNull); | 6358 expect(name.name, isNull); |
| 6616 expect(expression.argumentList, isNotNull); | 6359 expect(expression.argumentList, isNotNull); |
| 6617 } | 6360 } |
| 6618 | 6361 |
| 6619 void test_parseConstExpression_listLiteral_typed() { | 6362 void test_parseConstExpression_listLiteral_typed() { |
| 6620 ListLiteral literal = | 6363 ListLiteral literal = parse4("parseConstExpression", "const <A> []"); |
| 6621 ParserTestCase.parse4("parseConstExpression", "const <A> []"); | |
| 6622 expect(literal.constKeyword, isNotNull); | 6364 expect(literal.constKeyword, isNotNull); |
| 6623 expect(literal.typeArguments, isNotNull); | 6365 expect(literal.typeArguments, isNotNull); |
| 6624 expect(literal.leftBracket, isNotNull); | 6366 expect(literal.leftBracket, isNotNull); |
| 6625 expect(literal.elements, hasLength(0)); | 6367 expect(literal.elements, hasLength(0)); |
| 6626 expect(literal.rightBracket, isNotNull); | 6368 expect(literal.rightBracket, isNotNull); |
| 6627 } | 6369 } |
| 6628 | 6370 |
| 6629 void test_parseConstExpression_listLiteral_untyped() { | 6371 void test_parseConstExpression_listLiteral_untyped() { |
| 6630 ListLiteral literal = | 6372 ListLiteral literal = parse4("parseConstExpression", "const []"); |
| 6631 ParserTestCase.parse4("parseConstExpression", "const []"); | |
| 6632 expect(literal.constKeyword, isNotNull); | 6373 expect(literal.constKeyword, isNotNull); |
| 6633 expect(literal.typeArguments, isNull); | 6374 expect(literal.typeArguments, isNull); |
| 6634 expect(literal.leftBracket, isNotNull); | 6375 expect(literal.leftBracket, isNotNull); |
| 6635 expect(literal.elements, hasLength(0)); | 6376 expect(literal.elements, hasLength(0)); |
| 6636 expect(literal.rightBracket, isNotNull); | 6377 expect(literal.rightBracket, isNotNull); |
| 6637 } | 6378 } |
| 6638 | 6379 |
| 6639 void test_parseConstExpression_mapLiteral_typed() { | 6380 void test_parseConstExpression_mapLiteral_typed() { |
| 6640 MapLiteral literal = | 6381 MapLiteral literal = parse4("parseConstExpression", "const <A, B> {}"); |
| 6641 ParserTestCase.parse4("parseConstExpression", "const <A, B> {}"); | |
| 6642 expect(literal.leftBracket, isNotNull); | 6382 expect(literal.leftBracket, isNotNull); |
| 6643 expect(literal.entries, hasLength(0)); | 6383 expect(literal.entries, hasLength(0)); |
| 6644 expect(literal.rightBracket, isNotNull); | 6384 expect(literal.rightBracket, isNotNull); |
| 6645 expect(literal.typeArguments, isNotNull); | 6385 expect(literal.typeArguments, isNotNull); |
| 6646 } | 6386 } |
| 6647 | 6387 |
| 6648 void test_parseConstExpression_mapLiteral_untyped() { | 6388 void test_parseConstExpression_mapLiteral_untyped() { |
| 6649 MapLiteral literal = | 6389 MapLiteral literal = parse4("parseConstExpression", "const {}"); |
| 6650 ParserTestCase.parse4("parseConstExpression", "const {}"); | |
| 6651 expect(literal.leftBracket, isNotNull); | 6390 expect(literal.leftBracket, isNotNull); |
| 6652 expect(literal.entries, hasLength(0)); | 6391 expect(literal.entries, hasLength(0)); |
| 6653 expect(literal.rightBracket, isNotNull); | 6392 expect(literal.rightBracket, isNotNull); |
| 6654 expect(literal.typeArguments, isNull); | 6393 expect(literal.typeArguments, isNull); |
| 6655 } | 6394 } |
| 6656 | 6395 |
| 6657 void test_parseConstructor() { | 6396 void test_parseConstructor() { |
| 6658 // TODO(brianwilkerson) Implement tests for this method. | 6397 // TODO(brianwilkerson) Implement tests for this method. |
| 6659 // parse("parseConstructor", new Class[] {Parser.CommentAndMetadata.class, | 6398 // parse("parseConstructor", new Class[] {Parser.CommentAndMetadata.class, |
| 6660 // Token.class, Token.class, SimpleIdentifier.class, Token.class, | 6399 // Token.class, Token.class, SimpleIdentifier.class, Token.class, |
| 6661 // SimpleIdentifier.class, FormalParameterList.class}, new Object[] {empt
yCommentAndMetadata(), | 6400 // SimpleIdentifier.class, FormalParameterList.class}, new Object[] {empt
yCommentAndMetadata(), |
| 6662 // null, null, null, null, null, null}, ""); | 6401 // null, null, null, null, null, null}, ""); |
| 6663 } | 6402 } |
| 6664 | 6403 |
| 6665 void test_parseConstructor_with_pseudo_function_literal() { | 6404 void test_parseConstructor_with_pseudo_function_literal() { |
| 6666 // "(b) {}" should not be misinterpreted as a function literal even though | 6405 // "(b) {}" should not be misinterpreted as a function literal even though |
| 6667 // it looks like one. | 6406 // it looks like one. |
| 6668 ClassMember classMember = ParserTestCase.parse( | 6407 ClassMember classMember = |
| 6669 "parseClassMember", <Object>["C"], "C() : a = (b) {}"); | 6408 parse("parseClassMember", <Object>["C"], "C() : a = (b) {}"); |
| 6670 EngineTestCase.assertInstanceOf((obj) => obj is ConstructorDeclaration, | 6409 EngineTestCase.assertInstanceOf((obj) => obj is ConstructorDeclaration, |
| 6671 ConstructorDeclaration, classMember); | 6410 ConstructorDeclaration, classMember); |
| 6672 ConstructorDeclaration constructor = classMember as ConstructorDeclaration; | 6411 ConstructorDeclaration constructor = classMember as ConstructorDeclaration; |
| 6673 NodeList<ConstructorInitializer> initializers = constructor.initializers; | 6412 NodeList<ConstructorInitializer> initializers = constructor.initializers; |
| 6674 expect(initializers, hasLength(1)); | 6413 expect(initializers, hasLength(1)); |
| 6675 ConstructorInitializer initializer = initializers[0]; | 6414 ConstructorInitializer initializer = initializers[0]; |
| 6676 EngineTestCase.assertInstanceOf((obj) => obj is ConstructorFieldInitializer, | 6415 EngineTestCase.assertInstanceOf((obj) => obj is ConstructorFieldInitializer, |
| 6677 ConstructorFieldInitializer, initializer); | 6416 ConstructorFieldInitializer, initializer); |
| 6678 EngineTestCase.assertInstanceOf((obj) => obj is ParenthesizedExpression, | 6417 EngineTestCase.assertInstanceOf((obj) => obj is ParenthesizedExpression, |
| 6679 ParenthesizedExpression, | 6418 ParenthesizedExpression, |
| 6680 (initializer as ConstructorFieldInitializer).expression); | 6419 (initializer as ConstructorFieldInitializer).expression); |
| 6681 EngineTestCase.assertInstanceOf( | 6420 EngineTestCase.assertInstanceOf( |
| 6682 (obj) => obj is BlockFunctionBody, BlockFunctionBody, constructor.body); | 6421 (obj) => obj is BlockFunctionBody, BlockFunctionBody, constructor.body); |
| 6683 } | 6422 } |
| 6684 | 6423 |
| 6685 void test_parseConstructorFieldInitializer_qualified() { | 6424 void test_parseConstructorFieldInitializer_qualified() { |
| 6686 ConstructorFieldInitializer invocation = | 6425 ConstructorFieldInitializer invocation = |
| 6687 ParserTestCase.parse4("parseConstructorFieldInitializer", "this.a = b"); | 6426 parse4("parseConstructorFieldInitializer", "this.a = b"); |
| 6688 expect(invocation.equals, isNotNull); | 6427 expect(invocation.equals, isNotNull); |
| 6689 expect(invocation.expression, isNotNull); | 6428 expect(invocation.expression, isNotNull); |
| 6690 expect(invocation.fieldName, isNotNull); | 6429 expect(invocation.fieldName, isNotNull); |
| 6691 expect(invocation.thisKeyword, isNotNull); | 6430 expect(invocation.thisKeyword, isNotNull); |
| 6692 expect(invocation.period, isNotNull); | 6431 expect(invocation.period, isNotNull); |
| 6693 } | 6432 } |
| 6694 | 6433 |
| 6695 void test_parseConstructorFieldInitializer_unqualified() { | 6434 void test_parseConstructorFieldInitializer_unqualified() { |
| 6696 ConstructorFieldInitializer invocation = | 6435 ConstructorFieldInitializer invocation = |
| 6697 ParserTestCase.parse4("parseConstructorFieldInitializer", "a = b"); | 6436 parse4("parseConstructorFieldInitializer", "a = b"); |
| 6698 expect(invocation.equals, isNotNull); | 6437 expect(invocation.equals, isNotNull); |
| 6699 expect(invocation.expression, isNotNull); | 6438 expect(invocation.expression, isNotNull); |
| 6700 expect(invocation.fieldName, isNotNull); | 6439 expect(invocation.fieldName, isNotNull); |
| 6701 expect(invocation.thisKeyword, isNull); | 6440 expect(invocation.thisKeyword, isNull); |
| 6702 expect(invocation.period, isNull); | 6441 expect(invocation.period, isNull); |
| 6703 } | 6442 } |
| 6704 | 6443 |
| 6705 void test_parseConstructorName_named_noPrefix() { | 6444 void test_parseConstructorName_named_noPrefix() { |
| 6706 ConstructorName name = | 6445 ConstructorName name = parse4("parseConstructorName", "A.n;"); |
| 6707 ParserTestCase.parse4("parseConstructorName", "A.n;"); | |
| 6708 expect(name.type, isNotNull); | 6446 expect(name.type, isNotNull); |
| 6709 expect(name.period, isNull); | 6447 expect(name.period, isNull); |
| 6710 expect(name.name, isNull); | 6448 expect(name.name, isNull); |
| 6711 } | 6449 } |
| 6712 | 6450 |
| 6713 void test_parseConstructorName_named_prefixed() { | 6451 void test_parseConstructorName_named_prefixed() { |
| 6714 ConstructorName name = | 6452 ConstructorName name = parse4("parseConstructorName", "p.A.n;"); |
| 6715 ParserTestCase.parse4("parseConstructorName", "p.A.n;"); | |
| 6716 expect(name.type, isNotNull); | 6453 expect(name.type, isNotNull); |
| 6717 expect(name.period, isNotNull); | 6454 expect(name.period, isNotNull); |
| 6718 expect(name.name, isNotNull); | 6455 expect(name.name, isNotNull); |
| 6719 } | 6456 } |
| 6720 | 6457 |
| 6721 void test_parseConstructorName_unnamed_noPrefix() { | 6458 void test_parseConstructorName_unnamed_noPrefix() { |
| 6722 ConstructorName name = ParserTestCase.parse4("parseConstructorName", "A;"); | 6459 ConstructorName name = parse4("parseConstructorName", "A;"); |
| 6723 expect(name.type, isNotNull); | 6460 expect(name.type, isNotNull); |
| 6724 expect(name.period, isNull); | 6461 expect(name.period, isNull); |
| 6725 expect(name.name, isNull); | 6462 expect(name.name, isNull); |
| 6726 } | 6463 } |
| 6727 | 6464 |
| 6728 void test_parseConstructorName_unnamed_prefixed() { | 6465 void test_parseConstructorName_unnamed_prefixed() { |
| 6729 ConstructorName name = | 6466 ConstructorName name = parse4("parseConstructorName", "p.A;"); |
| 6730 ParserTestCase.parse4("parseConstructorName", "p.A;"); | |
| 6731 expect(name.type, isNotNull); | 6467 expect(name.type, isNotNull); |
| 6732 expect(name.period, isNull); | 6468 expect(name.period, isNull); |
| 6733 expect(name.name, isNull); | 6469 expect(name.name, isNull); |
| 6734 } | 6470 } |
| 6735 | 6471 |
| 6736 void test_parseContinueStatement_label() { | 6472 void test_parseContinueStatement_label() { |
| 6737 ContinueStatement statement = ParserTestCase.parse4( | 6473 ContinueStatement statement = parse4("parseContinueStatement", |
| 6738 "parseContinueStatement", "continue foo;", [ | 6474 "continue foo;", [ParserErrorCode.CONTINUE_OUTSIDE_OF_LOOP]); |
| 6739 ParserErrorCode.CONTINUE_OUTSIDE_OF_LOOP | |
| 6740 ]); | |
| 6741 expect(statement.continueKeyword, isNotNull); | 6475 expect(statement.continueKeyword, isNotNull); |
| 6742 expect(statement.label, isNotNull); | 6476 expect(statement.label, isNotNull); |
| 6743 expect(statement.semicolon, isNotNull); | 6477 expect(statement.semicolon, isNotNull); |
| 6744 } | 6478 } |
| 6745 | 6479 |
| 6746 void test_parseContinueStatement_noLabel() { | 6480 void test_parseContinueStatement_noLabel() { |
| 6747 ContinueStatement statement = ParserTestCase.parse4( | 6481 ContinueStatement statement = parse4("parseContinueStatement", "continue;", |
| 6748 "parseContinueStatement", "continue;", [ | 6482 [ParserErrorCode.CONTINUE_OUTSIDE_OF_LOOP]); |
| 6749 ParserErrorCode.CONTINUE_OUTSIDE_OF_LOOP | |
| 6750 ]); | |
| 6751 expect(statement.continueKeyword, isNotNull); | 6483 expect(statement.continueKeyword, isNotNull); |
| 6752 expect(statement.label, isNull); | 6484 expect(statement.label, isNull); |
| 6753 expect(statement.semicolon, isNotNull); | 6485 expect(statement.semicolon, isNotNull); |
| 6754 } | 6486 } |
| 6755 | 6487 |
| 6756 void test_parseDirective_export() { | 6488 void test_parseDirective_export() { |
| 6757 ExportDirective directive = ParserTestCase.parse("parseDirective", <Object>[ | 6489 ExportDirective directive = parse("parseDirective", |
| 6758 emptyCommentAndMetadata() | 6490 <Object>[emptyCommentAndMetadata()], "export 'lib/lib.dart';"); |
| 6759 ], "export 'lib/lib.dart';"); | |
| 6760 expect(directive.keyword, isNotNull); | 6491 expect(directive.keyword, isNotNull); |
| 6761 expect(directive.uri, isNotNull); | 6492 expect(directive.uri, isNotNull); |
| 6762 expect(directive.combinators, hasLength(0)); | 6493 expect(directive.combinators, hasLength(0)); |
| 6763 expect(directive.semicolon, isNotNull); | 6494 expect(directive.semicolon, isNotNull); |
| 6764 } | 6495 } |
| 6765 | 6496 |
| 6766 void test_parseDirective_import() { | 6497 void test_parseDirective_import() { |
| 6767 ImportDirective directive = ParserTestCase.parse("parseDirective", <Object>[ | 6498 ImportDirective directive = parse("parseDirective", |
| 6768 emptyCommentAndMetadata() | 6499 <Object>[emptyCommentAndMetadata()], "import 'lib/lib.dart';"); |
| 6769 ], "import 'lib/lib.dart';"); | |
| 6770 expect(directive.keyword, isNotNull); | 6500 expect(directive.keyword, isNotNull); |
| 6771 expect(directive.uri, isNotNull); | 6501 expect(directive.uri, isNotNull); |
| 6772 expect(directive.asKeyword, isNull); | 6502 expect(directive.asKeyword, isNull); |
| 6773 expect(directive.prefix, isNull); | 6503 expect(directive.prefix, isNull); |
| 6774 expect(directive.combinators, hasLength(0)); | 6504 expect(directive.combinators, hasLength(0)); |
| 6775 expect(directive.semicolon, isNotNull); | 6505 expect(directive.semicolon, isNotNull); |
| 6776 } | 6506 } |
| 6777 | 6507 |
| 6778 void test_parseDirective_library() { | 6508 void test_parseDirective_library() { |
| 6779 LibraryDirective directive = ParserTestCase.parse( | 6509 LibraryDirective directive = parse( |
| 6780 "parseDirective", <Object>[emptyCommentAndMetadata()], "library l;"); | 6510 "parseDirective", <Object>[emptyCommentAndMetadata()], "library l;"); |
| 6781 expect(directive.libraryKeyword, isNotNull); | 6511 expect(directive.libraryKeyword, isNotNull); |
| 6782 expect(directive.name, isNotNull); | 6512 expect(directive.name, isNotNull); |
| 6783 expect(directive.semicolon, isNotNull); | 6513 expect(directive.semicolon, isNotNull); |
| 6784 } | 6514 } |
| 6785 | 6515 |
| 6786 void test_parseDirective_part() { | 6516 void test_parseDirective_part() { |
| 6787 PartDirective directive = ParserTestCase.parse("parseDirective", <Object>[ | 6517 PartDirective directive = parse("parseDirective", |
| 6788 emptyCommentAndMetadata() | 6518 <Object>[emptyCommentAndMetadata()], "part 'lib/lib.dart';"); |
| 6789 ], "part 'lib/lib.dart';"); | |
| 6790 expect(directive.partKeyword, isNotNull); | 6519 expect(directive.partKeyword, isNotNull); |
| 6791 expect(directive.uri, isNotNull); | 6520 expect(directive.uri, isNotNull); |
| 6792 expect(directive.semicolon, isNotNull); | 6521 expect(directive.semicolon, isNotNull); |
| 6793 } | 6522 } |
| 6794 | 6523 |
| 6795 void test_parseDirective_partOf() { | 6524 void test_parseDirective_partOf() { |
| 6796 PartOfDirective directive = ParserTestCase.parse( | 6525 PartOfDirective directive = parse( |
| 6797 "parseDirective", <Object>[emptyCommentAndMetadata()], "part of l;"); | 6526 "parseDirective", <Object>[emptyCommentAndMetadata()], "part of l;"); |
| 6798 expect(directive.partKeyword, isNotNull); | 6527 expect(directive.partKeyword, isNotNull); |
| 6799 expect(directive.ofKeyword, isNotNull); | 6528 expect(directive.ofKeyword, isNotNull); |
| 6800 expect(directive.libraryName, isNotNull); | 6529 expect(directive.libraryName, isNotNull); |
| 6801 expect(directive.semicolon, isNotNull); | 6530 expect(directive.semicolon, isNotNull); |
| 6802 } | 6531 } |
| 6803 | 6532 |
| 6804 void test_parseDirectives_complete() { | 6533 void test_parseDirectives_complete() { |
| 6805 CompilationUnit unit = | 6534 CompilationUnit unit = |
| 6806 _parseDirectives("#! /bin/dart\nlibrary l;\nclass A {}"); | 6535 _parseDirectives("#! /bin/dart\nlibrary l;\nclass A {}"); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6839 expect(unit.directives, hasLength(1)); | 6568 expect(unit.directives, hasLength(1)); |
| 6840 } | 6569 } |
| 6841 | 6570 |
| 6842 void test_parseDirectives_topLevelDeclaration() { | 6571 void test_parseDirectives_topLevelDeclaration() { |
| 6843 CompilationUnit unit = _parseDirectives("class A {}"); | 6572 CompilationUnit unit = _parseDirectives("class A {}"); |
| 6844 expect(unit.scriptTag, isNull); | 6573 expect(unit.scriptTag, isNull); |
| 6845 expect(unit.directives, hasLength(0)); | 6574 expect(unit.directives, hasLength(0)); |
| 6846 } | 6575 } |
| 6847 | 6576 |
| 6848 void test_parseDocumentationComment_block() { | 6577 void test_parseDocumentationComment_block() { |
| 6849 Comment comment = | 6578 Comment comment = parse4("parseDocumentationComment", "/** */ class"); |
| 6850 ParserTestCase.parse4("parseDocumentationComment", "/** */ class"); | |
| 6851 expect(comment.isBlock, isFalse); | 6579 expect(comment.isBlock, isFalse); |
| 6852 expect(comment.isDocumentation, isTrue); | 6580 expect(comment.isDocumentation, isTrue); |
| 6853 expect(comment.isEndOfLine, isFalse); | 6581 expect(comment.isEndOfLine, isFalse); |
| 6854 } | 6582 } |
| 6855 | 6583 |
| 6856 void test_parseDocumentationComment_block_withReference() { | 6584 void test_parseDocumentationComment_block_withReference() { |
| 6857 Comment comment = | 6585 Comment comment = parse4("parseDocumentationComment", "/** [a] */ class"); |
| 6858 ParserTestCase.parse4("parseDocumentationComment", "/** [a] */ class"); | |
| 6859 expect(comment.isBlock, isFalse); | 6586 expect(comment.isBlock, isFalse); |
| 6860 expect(comment.isDocumentation, isTrue); | 6587 expect(comment.isDocumentation, isTrue); |
| 6861 expect(comment.isEndOfLine, isFalse); | 6588 expect(comment.isEndOfLine, isFalse); |
| 6862 NodeList<CommentReference> references = comment.references; | 6589 NodeList<CommentReference> references = comment.references; |
| 6863 expect(references, hasLength(1)); | 6590 expect(references, hasLength(1)); |
| 6864 CommentReference reference = references[0]; | 6591 CommentReference reference = references[0]; |
| 6865 expect(reference, isNotNull); | 6592 expect(reference, isNotNull); |
| 6866 expect(reference.offset, 5); | 6593 expect(reference.offset, 5); |
| 6867 } | 6594 } |
| 6868 | 6595 |
| 6869 void test_parseDocumentationComment_endOfLine() { | 6596 void test_parseDocumentationComment_endOfLine() { |
| 6870 Comment comment = ParserTestCase.parse4( | 6597 Comment comment = parse4("parseDocumentationComment", "/// \n/// \n class"); |
| 6871 "parseDocumentationComment", "/// \n/// \n class"); | |
| 6872 expect(comment.isBlock, isFalse); | 6598 expect(comment.isBlock, isFalse); |
| 6873 expect(comment.isDocumentation, isTrue); | 6599 expect(comment.isDocumentation, isTrue); |
| 6874 expect(comment.isEndOfLine, isFalse); | 6600 expect(comment.isEndOfLine, isFalse); |
| 6875 } | 6601 } |
| 6876 | 6602 |
| 6877 void test_parseDoStatement() { | 6603 void test_parseDoStatement() { |
| 6878 DoStatement statement = | 6604 DoStatement statement = parse4("parseDoStatement", "do {} while (x);"); |
| 6879 ParserTestCase.parse4("parseDoStatement", "do {} while (x);"); | |
| 6880 expect(statement.doKeyword, isNotNull); | 6605 expect(statement.doKeyword, isNotNull); |
| 6881 expect(statement.body, isNotNull); | 6606 expect(statement.body, isNotNull); |
| 6882 expect(statement.whileKeyword, isNotNull); | 6607 expect(statement.whileKeyword, isNotNull); |
| 6883 expect(statement.leftParenthesis, isNotNull); | 6608 expect(statement.leftParenthesis, isNotNull); |
| 6884 expect(statement.condition, isNotNull); | 6609 expect(statement.condition, isNotNull); |
| 6885 expect(statement.rightParenthesis, isNotNull); | 6610 expect(statement.rightParenthesis, isNotNull); |
| 6886 expect(statement.semicolon, isNotNull); | 6611 expect(statement.semicolon, isNotNull); |
| 6887 } | 6612 } |
| 6888 | 6613 |
| 6889 void test_parseEmptyStatement() { | 6614 void test_parseEmptyStatement() { |
| 6890 EmptyStatement statement = | 6615 EmptyStatement statement = parse4("parseEmptyStatement", ";"); |
| 6891 ParserTestCase.parse4("parseEmptyStatement", ";"); | |
| 6892 expect(statement.semicolon, isNotNull); | 6616 expect(statement.semicolon, isNotNull); |
| 6893 } | 6617 } |
| 6894 | 6618 |
| 6895 void test_parseEnumDeclaration_one() { | 6619 void test_parseEnumDeclaration_one() { |
| 6896 EnumDeclaration declaration = ParserTestCase.parse("parseEnumDeclaration", | 6620 EnumDeclaration declaration = parse("parseEnumDeclaration", |
| 6897 <Object>[emptyCommentAndMetadata()], "enum E {ONE}"); | 6621 <Object>[emptyCommentAndMetadata()], "enum E {ONE}"); |
| 6898 expect(declaration.documentationComment, isNull); | 6622 expect(declaration.documentationComment, isNull); |
| 6899 expect(declaration.enumKeyword, isNotNull); | 6623 expect(declaration.enumKeyword, isNotNull); |
| 6900 expect(declaration.leftBracket, isNotNull); | 6624 expect(declaration.leftBracket, isNotNull); |
| 6901 expect(declaration.name, isNotNull); | 6625 expect(declaration.name, isNotNull); |
| 6902 expect(declaration.constants, hasLength(1)); | 6626 expect(declaration.constants, hasLength(1)); |
| 6903 expect(declaration.rightBracket, isNotNull); | 6627 expect(declaration.rightBracket, isNotNull); |
| 6904 } | 6628 } |
| 6905 | 6629 |
| 6906 void test_parseEnumDeclaration_trailingComma() { | 6630 void test_parseEnumDeclaration_trailingComma() { |
| 6907 EnumDeclaration declaration = ParserTestCase.parse("parseEnumDeclaration", | 6631 EnumDeclaration declaration = parse("parseEnumDeclaration", |
| 6908 <Object>[emptyCommentAndMetadata()], "enum E {ONE,}"); | 6632 <Object>[emptyCommentAndMetadata()], "enum E {ONE,}"); |
| 6909 expect(declaration.documentationComment, isNull); | 6633 expect(declaration.documentationComment, isNull); |
| 6910 expect(declaration.enumKeyword, isNotNull); | 6634 expect(declaration.enumKeyword, isNotNull); |
| 6911 expect(declaration.leftBracket, isNotNull); | 6635 expect(declaration.leftBracket, isNotNull); |
| 6912 expect(declaration.name, isNotNull); | 6636 expect(declaration.name, isNotNull); |
| 6913 expect(declaration.constants, hasLength(1)); | 6637 expect(declaration.constants, hasLength(1)); |
| 6914 expect(declaration.rightBracket, isNotNull); | 6638 expect(declaration.rightBracket, isNotNull); |
| 6915 } | 6639 } |
| 6916 | 6640 |
| 6917 void test_parseEnumDeclaration_two() { | 6641 void test_parseEnumDeclaration_two() { |
| 6918 EnumDeclaration declaration = ParserTestCase.parse("parseEnumDeclaration", | 6642 EnumDeclaration declaration = parse("parseEnumDeclaration", |
| 6919 <Object>[emptyCommentAndMetadata()], "enum E {ONE, TWO}"); | 6643 <Object>[emptyCommentAndMetadata()], "enum E {ONE, TWO}"); |
| 6920 expect(declaration.documentationComment, isNull); | 6644 expect(declaration.documentationComment, isNull); |
| 6921 expect(declaration.enumKeyword, isNotNull); | 6645 expect(declaration.enumKeyword, isNotNull); |
| 6922 expect(declaration.leftBracket, isNotNull); | 6646 expect(declaration.leftBracket, isNotNull); |
| 6923 expect(declaration.name, isNotNull); | 6647 expect(declaration.name, isNotNull); |
| 6924 expect(declaration.constants, hasLength(2)); | 6648 expect(declaration.constants, hasLength(2)); |
| 6925 expect(declaration.rightBracket, isNotNull); | 6649 expect(declaration.rightBracket, isNotNull); |
| 6926 } | 6650 } |
| 6927 | 6651 |
| 6928 void test_parseEqualityExpression_normal() { | 6652 void test_parseEqualityExpression_normal() { |
| 6929 BinaryExpression expression = | 6653 BinaryExpression expression = parse4("parseEqualityExpression", "x == y"); |
| 6930 ParserTestCase.parse4("parseEqualityExpression", "x == y"); | |
| 6931 expect(expression.leftOperand, isNotNull); | 6654 expect(expression.leftOperand, isNotNull); |
| 6932 expect(expression.operator, isNotNull); | 6655 expect(expression.operator, isNotNull); |
| 6933 expect(expression.operator.type, TokenType.EQ_EQ); | 6656 expect(expression.operator.type, TokenType.EQ_EQ); |
| 6934 expect(expression.rightOperand, isNotNull); | 6657 expect(expression.rightOperand, isNotNull); |
| 6935 } | 6658 } |
| 6936 | 6659 |
| 6937 void test_parseEqualityExpression_super() { | 6660 void test_parseEqualityExpression_super() { |
| 6938 BinaryExpression expression = | 6661 BinaryExpression expression = |
| 6939 ParserTestCase.parse4("parseEqualityExpression", "super == y"); | 6662 parse4("parseEqualityExpression", "super == y"); |
| 6940 EngineTestCase.assertInstanceOf((obj) => obj is SuperExpression, | 6663 EngineTestCase.assertInstanceOf((obj) => obj is SuperExpression, |
| 6941 SuperExpression, expression.leftOperand); | 6664 SuperExpression, expression.leftOperand); |
| 6942 expect(expression.operator, isNotNull); | 6665 expect(expression.operator, isNotNull); |
| 6943 expect(expression.operator.type, TokenType.EQ_EQ); | 6666 expect(expression.operator.type, TokenType.EQ_EQ); |
| 6944 expect(expression.rightOperand, isNotNull); | 6667 expect(expression.rightOperand, isNotNull); |
| 6945 } | 6668 } |
| 6946 | 6669 |
| 6947 void test_parseExportDirective_hide() { | 6670 void test_parseExportDirective_hide() { |
| 6948 ExportDirective directive = ParserTestCase.parse("parseExportDirective", | 6671 ExportDirective directive = parse("parseExportDirective", |
| 6949 <Object>[ | 6672 <Object>[emptyCommentAndMetadata()], |
| 6950 emptyCommentAndMetadata() | 6673 "export 'lib/lib.dart' hide A, B;"); |
| 6951 ], "export 'lib/lib.dart' hide A, B;"); | |
| 6952 expect(directive.keyword, isNotNull); | 6674 expect(directive.keyword, isNotNull); |
| 6953 expect(directive.uri, isNotNull); | 6675 expect(directive.uri, isNotNull); |
| 6954 expect(directive.combinators, hasLength(1)); | 6676 expect(directive.combinators, hasLength(1)); |
| 6955 expect(directive.semicolon, isNotNull); | 6677 expect(directive.semicolon, isNotNull); |
| 6956 } | 6678 } |
| 6957 | 6679 |
| 6958 void test_parseExportDirective_hide_show() { | 6680 void test_parseExportDirective_hide_show() { |
| 6959 ExportDirective directive = ParserTestCase.parse("parseExportDirective", | 6681 ExportDirective directive = parse("parseExportDirective", |
| 6960 <Object>[ | 6682 <Object>[emptyCommentAndMetadata()], |
| 6961 emptyCommentAndMetadata() | 6683 "export 'lib/lib.dart' hide A show B;"); |
| 6962 ], "export 'lib/lib.dart' hide A show B;"); | |
| 6963 expect(directive.keyword, isNotNull); | 6684 expect(directive.keyword, isNotNull); |
| 6964 expect(directive.uri, isNotNull); | 6685 expect(directive.uri, isNotNull); |
| 6965 expect(directive.combinators, hasLength(2)); | 6686 expect(directive.combinators, hasLength(2)); |
| 6966 expect(directive.semicolon, isNotNull); | 6687 expect(directive.semicolon, isNotNull); |
| 6967 } | 6688 } |
| 6968 | 6689 |
| 6969 void test_parseExportDirective_noCombinator() { | 6690 void test_parseExportDirective_noCombinator() { |
| 6970 ExportDirective directive = ParserTestCase.parse("parseExportDirective", | 6691 ExportDirective directive = parse("parseExportDirective", |
| 6971 <Object>[emptyCommentAndMetadata()], "export 'lib/lib.dart';"); | 6692 <Object>[emptyCommentAndMetadata()], "export 'lib/lib.dart';"); |
| 6972 expect(directive.keyword, isNotNull); | 6693 expect(directive.keyword, isNotNull); |
| 6973 expect(directive.uri, isNotNull); | 6694 expect(directive.uri, isNotNull); |
| 6974 expect(directive.combinators, hasLength(0)); | 6695 expect(directive.combinators, hasLength(0)); |
| 6975 expect(directive.semicolon, isNotNull); | 6696 expect(directive.semicolon, isNotNull); |
| 6976 } | 6697 } |
| 6977 | 6698 |
| 6978 void test_parseExportDirective_show() { | 6699 void test_parseExportDirective_show() { |
| 6979 ExportDirective directive = ParserTestCase.parse("parseExportDirective", | 6700 ExportDirective directive = parse("parseExportDirective", |
| 6980 <Object>[ | 6701 <Object>[emptyCommentAndMetadata()], |
| 6981 emptyCommentAndMetadata() | 6702 "export 'lib/lib.dart' show A, B;"); |
| 6982 ], "export 'lib/lib.dart' show A, B;"); | |
| 6983 expect(directive.keyword, isNotNull); | 6703 expect(directive.keyword, isNotNull); |
| 6984 expect(directive.uri, isNotNull); | 6704 expect(directive.uri, isNotNull); |
| 6985 expect(directive.combinators, hasLength(1)); | 6705 expect(directive.combinators, hasLength(1)); |
| 6986 expect(directive.semicolon, isNotNull); | 6706 expect(directive.semicolon, isNotNull); |
| 6987 } | 6707 } |
| 6988 | 6708 |
| 6989 void test_parseExportDirective_show_hide() { | 6709 void test_parseExportDirective_show_hide() { |
| 6990 ExportDirective directive = ParserTestCase.parse("parseExportDirective", | 6710 ExportDirective directive = parse("parseExportDirective", |
| 6991 <Object>[ | 6711 <Object>[emptyCommentAndMetadata()], |
| 6992 emptyCommentAndMetadata() | 6712 "export 'lib/lib.dart' show B hide A;"); |
| 6993 ], "export 'lib/lib.dart' show B hide A;"); | |
| 6994 expect(directive.keyword, isNotNull); | 6713 expect(directive.keyword, isNotNull); |
| 6995 expect(directive.uri, isNotNull); | 6714 expect(directive.uri, isNotNull); |
| 6996 expect(directive.combinators, hasLength(2)); | 6715 expect(directive.combinators, hasLength(2)); |
| 6997 expect(directive.semicolon, isNotNull); | 6716 expect(directive.semicolon, isNotNull); |
| 6998 } | 6717 } |
| 6999 | 6718 |
| 7000 void test_parseExpression_assign() { | 6719 void test_parseExpression_assign() { |
| 7001 // TODO(brianwilkerson) Implement more tests for this method. | 6720 // TODO(brianwilkerson) Implement more tests for this method. |
| 7002 AssignmentExpression expression = | 6721 AssignmentExpression expression = parse4("parseExpression", "x = y"); |
| 7003 ParserTestCase.parse4("parseExpression", "x = y"); | |
| 7004 expect(expression.leftHandSide, isNotNull); | 6722 expect(expression.leftHandSide, isNotNull); |
| 7005 expect(expression.operator, isNotNull); | 6723 expect(expression.operator, isNotNull); |
| 7006 expect(expression.operator.type, TokenType.EQ); | 6724 expect(expression.operator.type, TokenType.EQ); |
| 7007 expect(expression.rightHandSide, isNotNull); | 6725 expect(expression.rightHandSide, isNotNull); |
| 7008 } | 6726 } |
| 7009 | 6727 |
| 7010 void test_parseExpression_comparison() { | 6728 void test_parseExpression_comparison() { |
| 7011 BinaryExpression expression = | 6729 BinaryExpression expression = parse4("parseExpression", "--a.b == c"); |
| 7012 ParserTestCase.parse4("parseExpression", "--a.b == c"); | |
| 7013 expect(expression.leftOperand, isNotNull); | 6730 expect(expression.leftOperand, isNotNull); |
| 7014 expect(expression.operator, isNotNull); | 6731 expect(expression.operator, isNotNull); |
| 7015 expect(expression.operator.type, TokenType.EQ_EQ); | 6732 expect(expression.operator.type, TokenType.EQ_EQ); |
| 7016 expect(expression.rightOperand, isNotNull); | 6733 expect(expression.rightOperand, isNotNull); |
| 7017 } | 6734 } |
| 7018 | 6735 |
| 7019 void test_parseExpression_function_async() { | 6736 void test_parseExpression_function_async() { |
| 7020 FunctionExpression expression = | 6737 FunctionExpression expression = parseExpression("() async {}"); |
| 7021 ParserTestCase.parseExpression("() async {}"); | |
| 7022 expect(expression.body, isNotNull); | 6738 expect(expression.body, isNotNull); |
| 7023 expect(expression.body.isAsynchronous, isTrue); | 6739 expect(expression.body.isAsynchronous, isTrue); |
| 7024 expect(expression.body.isGenerator, isFalse); | 6740 expect(expression.body.isGenerator, isFalse); |
| 7025 expect(expression.parameters, isNotNull); | 6741 expect(expression.parameters, isNotNull); |
| 7026 } | 6742 } |
| 7027 | 6743 |
| 7028 void test_parseExpression_function_asyncStar() { | 6744 void test_parseExpression_function_asyncStar() { |
| 7029 FunctionExpression expression = | 6745 FunctionExpression expression = parseExpression("() async* {}"); |
| 7030 ParserTestCase.parseExpression("() async* {}"); | |
| 7031 expect(expression.body, isNotNull); | 6746 expect(expression.body, isNotNull); |
| 7032 expect(expression.body.isAsynchronous, isTrue); | 6747 expect(expression.body.isAsynchronous, isTrue); |
| 7033 expect(expression.body.isGenerator, isTrue); | 6748 expect(expression.body.isGenerator, isTrue); |
| 7034 expect(expression.parameters, isNotNull); | 6749 expect(expression.parameters, isNotNull); |
| 7035 } | 6750 } |
| 7036 | 6751 |
| 7037 void test_parseExpression_function_sync() { | 6752 void test_parseExpression_function_sync() { |
| 7038 FunctionExpression expression = ParserTestCase.parseExpression("() {}"); | 6753 FunctionExpression expression = parseExpression("() {}"); |
| 7039 expect(expression.body, isNotNull); | 6754 expect(expression.body, isNotNull); |
| 7040 expect(expression.body.isAsynchronous, isFalse); | 6755 expect(expression.body.isAsynchronous, isFalse); |
| 7041 expect(expression.body.isGenerator, isFalse); | 6756 expect(expression.body.isGenerator, isFalse); |
| 7042 expect(expression.parameters, isNotNull); | 6757 expect(expression.parameters, isNotNull); |
| 7043 } | 6758 } |
| 7044 | 6759 |
| 7045 void test_parseExpression_function_syncStar() { | 6760 void test_parseExpression_function_syncStar() { |
| 7046 FunctionExpression expression = | 6761 FunctionExpression expression = parseExpression("() sync* {}"); |
| 7047 ParserTestCase.parseExpression("() sync* {}"); | |
| 7048 expect(expression.body, isNotNull); | 6762 expect(expression.body, isNotNull); |
| 7049 expect(expression.body.isAsynchronous, isFalse); | 6763 expect(expression.body.isAsynchronous, isFalse); |
| 7050 expect(expression.body.isGenerator, isTrue); | 6764 expect(expression.body.isGenerator, isTrue); |
| 7051 expect(expression.parameters, isNotNull); | 6765 expect(expression.parameters, isNotNull); |
| 7052 } | 6766 } |
| 7053 | 6767 |
| 7054 void test_parseExpression_invokeFunctionExpression() { | 6768 void test_parseExpression_invokeFunctionExpression() { |
| 7055 FunctionExpressionInvocation invocation = | 6769 FunctionExpressionInvocation invocation = |
| 7056 ParserTestCase.parse4("parseExpression", "(a) {return a + a;} (3)"); | 6770 parse4("parseExpression", "(a) {return a + a;} (3)"); |
| 7057 EngineTestCase.assertInstanceOf((obj) => obj is FunctionExpression, | 6771 EngineTestCase.assertInstanceOf((obj) => obj is FunctionExpression, |
| 7058 FunctionExpression, invocation.function); | 6772 FunctionExpression, invocation.function); |
| 7059 FunctionExpression expression = invocation.function as FunctionExpression; | 6773 FunctionExpression expression = invocation.function as FunctionExpression; |
| 7060 expect(expression.parameters, isNotNull); | 6774 expect(expression.parameters, isNotNull); |
| 7061 expect(expression.body, isNotNull); | 6775 expect(expression.body, isNotNull); |
| 7062 ArgumentList list = invocation.argumentList; | 6776 ArgumentList list = invocation.argumentList; |
| 7063 expect(list, isNotNull); | 6777 expect(list, isNotNull); |
| 7064 expect(list.arguments, hasLength(1)); | 6778 expect(list.arguments, hasLength(1)); |
| 7065 } | 6779 } |
| 7066 | 6780 |
| 7067 void test_parseExpression_nonAwait() { | 6781 void test_parseExpression_nonAwait() { |
| 7068 MethodInvocation expression = ParserTestCase.parseExpression("await()"); | 6782 MethodInvocation expression = parseExpression("await()"); |
| 7069 expect(expression.methodName.name, 'await'); | 6783 expect(expression.methodName.name, 'await'); |
| 7070 } | 6784 } |
| 7071 | 6785 |
| 7072 void test_parseExpression_superMethodInvocation() { | 6786 void test_parseExpression_superMethodInvocation() { |
| 7073 MethodInvocation invocation = | 6787 MethodInvocation invocation = parse4("parseExpression", "super.m()"); |
| 7074 ParserTestCase.parse4("parseExpression", "super.m()"); | |
| 7075 expect(invocation.target, isNotNull); | 6788 expect(invocation.target, isNotNull); |
| 7076 expect(invocation.methodName, isNotNull); | 6789 expect(invocation.methodName, isNotNull); |
| 7077 expect(invocation.argumentList, isNotNull); | 6790 expect(invocation.argumentList, isNotNull); |
| 7078 } | 6791 } |
| 7079 | 6792 |
| 7080 void test_parseExpressionList_multiple() { | 6793 void test_parseExpressionList_multiple() { |
| 7081 List<Expression> result = | 6794 List<Expression> result = parse4("parseExpressionList", "1, 2, 3"); |
| 7082 ParserTestCase.parse4("parseExpressionList", "1, 2, 3"); | |
| 7083 expect(result, hasLength(3)); | 6795 expect(result, hasLength(3)); |
| 7084 } | 6796 } |
| 7085 | 6797 |
| 7086 void test_parseExpressionList_single() { | 6798 void test_parseExpressionList_single() { |
| 7087 List<Expression> result = ParserTestCase.parse4("parseExpressionList", "1"); | 6799 List<Expression> result = parse4("parseExpressionList", "1"); |
| 7088 expect(result, hasLength(1)); | 6800 expect(result, hasLength(1)); |
| 7089 } | 6801 } |
| 7090 | 6802 |
| 7091 void test_parseExpressionWithoutCascade_assign() { | 6803 void test_parseExpressionWithoutCascade_assign() { |
| 7092 // TODO(brianwilkerson) Implement more tests for this method. | 6804 // TODO(brianwilkerson) Implement more tests for this method. |
| 7093 AssignmentExpression expression = | 6805 AssignmentExpression expression = |
| 7094 ParserTestCase.parse4("parseExpressionWithoutCascade", "x = y"); | 6806 parse4("parseExpressionWithoutCascade", "x = y"); |
| 7095 expect(expression.leftHandSide, isNotNull); | 6807 expect(expression.leftHandSide, isNotNull); |
| 7096 expect(expression.operator, isNotNull); | 6808 expect(expression.operator, isNotNull); |
| 7097 expect(expression.operator.type, TokenType.EQ); | 6809 expect(expression.operator.type, TokenType.EQ); |
| 7098 expect(expression.rightHandSide, isNotNull); | 6810 expect(expression.rightHandSide, isNotNull); |
| 7099 } | 6811 } |
| 7100 | 6812 |
| 7101 void test_parseExpressionWithoutCascade_comparison() { | 6813 void test_parseExpressionWithoutCascade_comparison() { |
| 7102 BinaryExpression expression = | 6814 BinaryExpression expression = |
| 7103 ParserTestCase.parse4("parseExpressionWithoutCascade", "--a.b == c"); | 6815 parse4("parseExpressionWithoutCascade", "--a.b == c"); |
| 7104 expect(expression.leftOperand, isNotNull); | 6816 expect(expression.leftOperand, isNotNull); |
| 7105 expect(expression.operator, isNotNull); | 6817 expect(expression.operator, isNotNull); |
| 7106 expect(expression.operator.type, TokenType.EQ_EQ); | 6818 expect(expression.operator.type, TokenType.EQ_EQ); |
| 7107 expect(expression.rightOperand, isNotNull); | 6819 expect(expression.rightOperand, isNotNull); |
| 7108 } | 6820 } |
| 7109 | 6821 |
| 7110 void test_parseExpressionWithoutCascade_superMethodInvocation() { | 6822 void test_parseExpressionWithoutCascade_superMethodInvocation() { |
| 7111 MethodInvocation invocation = | 6823 MethodInvocation invocation = |
| 7112 ParserTestCase.parse4("parseExpressionWithoutCascade", "super.m()"); | 6824 parse4("parseExpressionWithoutCascade", "super.m()"); |
| 7113 expect(invocation.target, isNotNull); | 6825 expect(invocation.target, isNotNull); |
| 7114 expect(invocation.methodName, isNotNull); | 6826 expect(invocation.methodName, isNotNull); |
| 7115 expect(invocation.argumentList, isNotNull); | 6827 expect(invocation.argumentList, isNotNull); |
| 7116 } | 6828 } |
| 7117 | 6829 |
| 7118 void test_parseExtendsClause() { | 6830 void test_parseExtendsClause() { |
| 7119 ExtendsClause clause = | 6831 ExtendsClause clause = parse4("parseExtendsClause", "extends B"); |
| 7120 ParserTestCase.parse4("parseExtendsClause", "extends B"); | |
| 7121 expect(clause.extendsKeyword, isNotNull); | 6832 expect(clause.extendsKeyword, isNotNull); |
| 7122 expect(clause.superclass, isNotNull); | 6833 expect(clause.superclass, isNotNull); |
| 7123 EngineTestCase.assertInstanceOf( | 6834 EngineTestCase.assertInstanceOf( |
| 7124 (obj) => obj is TypeName, TypeName, clause.superclass); | 6835 (obj) => obj is TypeName, TypeName, clause.superclass); |
| 7125 } | 6836 } |
| 7126 | 6837 |
| 7127 void test_parseFinalConstVarOrType_const_noType() { | 6838 void test_parseFinalConstVarOrType_const_noType() { |
| 7128 FinalConstVarOrType result = ParserTestCase.parse( | 6839 FinalConstVarOrType result = |
| 7129 "parseFinalConstVarOrType", <Object>[false], "const"); | 6840 parse("parseFinalConstVarOrType", <Object>[false], "const"); |
| 7130 Token keyword = result.keyword; | 6841 Token keyword = result.keyword; |
| 7131 expect(keyword, isNotNull); | 6842 expect(keyword, isNotNull); |
| 7132 expect(keyword.type, TokenType.KEYWORD); | 6843 expect(keyword.type, TokenType.KEYWORD); |
| 7133 expect((keyword as KeywordToken).keyword, Keyword.CONST); | 6844 expect((keyword as KeywordToken).keyword, Keyword.CONST); |
| 7134 expect(result.type, isNull); | 6845 expect(result.type, isNull); |
| 7135 } | 6846 } |
| 7136 | 6847 |
| 7137 void test_parseFinalConstVarOrType_const_type() { | 6848 void test_parseFinalConstVarOrType_const_type() { |
| 7138 FinalConstVarOrType result = ParserTestCase.parse( | 6849 FinalConstVarOrType result = |
| 7139 "parseFinalConstVarOrType", <Object>[false], "const A a"); | 6850 parse("parseFinalConstVarOrType", <Object>[false], "const A a"); |
| 7140 Token keyword = result.keyword; | 6851 Token keyword = result.keyword; |
| 7141 expect(keyword, isNotNull); | 6852 expect(keyword, isNotNull); |
| 7142 expect(keyword.type, TokenType.KEYWORD); | 6853 expect(keyword.type, TokenType.KEYWORD); |
| 7143 expect((keyword as KeywordToken).keyword, Keyword.CONST); | 6854 expect((keyword as KeywordToken).keyword, Keyword.CONST); |
| 7144 expect(result.type, isNotNull); | 6855 expect(result.type, isNotNull); |
| 7145 } | 6856 } |
| 7146 | 6857 |
| 7147 void test_parseFinalConstVarOrType_final_noType() { | 6858 void test_parseFinalConstVarOrType_final_noType() { |
| 7148 FinalConstVarOrType result = ParserTestCase.parse( | 6859 FinalConstVarOrType result = |
| 7149 "parseFinalConstVarOrType", <Object>[false], "final"); | 6860 parse("parseFinalConstVarOrType", <Object>[false], "final"); |
| 7150 Token keyword = result.keyword; | 6861 Token keyword = result.keyword; |
| 7151 expect(keyword, isNotNull); | 6862 expect(keyword, isNotNull); |
| 7152 expect(keyword.type, TokenType.KEYWORD); | 6863 expect(keyword.type, TokenType.KEYWORD); |
| 7153 expect((keyword as KeywordToken).keyword, Keyword.FINAL); | 6864 expect((keyword as KeywordToken).keyword, Keyword.FINAL); |
| 7154 expect(result.type, isNull); | 6865 expect(result.type, isNull); |
| 7155 } | 6866 } |
| 7156 | 6867 |
| 7157 void test_parseFinalConstVarOrType_final_prefixedType() { | 6868 void test_parseFinalConstVarOrType_final_prefixedType() { |
| 7158 FinalConstVarOrType result = ParserTestCase.parse( | 6869 FinalConstVarOrType result = |
| 7159 "parseFinalConstVarOrType", <Object>[false], "final p.A a"); | 6870 parse("parseFinalConstVarOrType", <Object>[false], "final p.A a"); |
| 7160 Token keyword = result.keyword; | 6871 Token keyword = result.keyword; |
| 7161 expect(keyword, isNotNull); | 6872 expect(keyword, isNotNull); |
| 7162 expect(keyword.type, TokenType.KEYWORD); | 6873 expect(keyword.type, TokenType.KEYWORD); |
| 7163 expect((keyword as KeywordToken).keyword, Keyword.FINAL); | 6874 expect((keyword as KeywordToken).keyword, Keyword.FINAL); |
| 7164 expect(result.type, isNotNull); | 6875 expect(result.type, isNotNull); |
| 7165 } | 6876 } |
| 7166 | 6877 |
| 7167 void test_parseFinalConstVarOrType_final_type() { | 6878 void test_parseFinalConstVarOrType_final_type() { |
| 7168 FinalConstVarOrType result = ParserTestCase.parse( | 6879 FinalConstVarOrType result = |
| 7169 "parseFinalConstVarOrType", <Object>[false], "final A a"); | 6880 parse("parseFinalConstVarOrType", <Object>[false], "final A a"); |
| 7170 Token keyword = result.keyword; | 6881 Token keyword = result.keyword; |
| 7171 expect(keyword, isNotNull); | 6882 expect(keyword, isNotNull); |
| 7172 expect(keyword.type, TokenType.KEYWORD); | 6883 expect(keyword.type, TokenType.KEYWORD); |
| 7173 expect((keyword as KeywordToken).keyword, Keyword.FINAL); | 6884 expect((keyword as KeywordToken).keyword, Keyword.FINAL); |
| 7174 expect(result.type, isNotNull); | 6885 expect(result.type, isNotNull); |
| 7175 } | 6886 } |
| 7176 | 6887 |
| 7177 void test_parseFinalConstVarOrType_type_parameterized() { | 6888 void test_parseFinalConstVarOrType_type_parameterized() { |
| 7178 FinalConstVarOrType result = ParserTestCase.parse( | 6889 FinalConstVarOrType result = |
| 7179 "parseFinalConstVarOrType", <Object>[false], "A<B> a"); | 6890 parse("parseFinalConstVarOrType", <Object>[false], "A<B> a"); |
| 7180 expect(result.keyword, isNull); | 6891 expect(result.keyword, isNull); |
| 7181 expect(result.type, isNotNull); | 6892 expect(result.type, isNotNull); |
| 7182 } | 6893 } |
| 7183 | 6894 |
| 7184 void test_parseFinalConstVarOrType_type_prefixed() { | 6895 void test_parseFinalConstVarOrType_type_prefixed() { |
| 7185 FinalConstVarOrType result = ParserTestCase.parse( | 6896 FinalConstVarOrType result = |
| 7186 "parseFinalConstVarOrType", <Object>[false], "p.A a"); | 6897 parse("parseFinalConstVarOrType", <Object>[false], "p.A a"); |
| 7187 expect(result.keyword, isNull); | 6898 expect(result.keyword, isNull); |
| 7188 expect(result.type, isNotNull); | 6899 expect(result.type, isNotNull); |
| 7189 } | 6900 } |
| 7190 | 6901 |
| 7191 void test_parseFinalConstVarOrType_type_prefixed_noIdentifier() { | 6902 void test_parseFinalConstVarOrType_type_prefixed_noIdentifier() { |
| 7192 FinalConstVarOrType result = ParserTestCase.parse( | 6903 FinalConstVarOrType result = |
| 7193 "parseFinalConstVarOrType", <Object>[false], "p.A,"); | 6904 parse("parseFinalConstVarOrType", <Object>[false], "p.A,"); |
| 7194 expect(result.keyword, isNull); | 6905 expect(result.keyword, isNull); |
| 7195 expect(result.type, isNotNull); | 6906 expect(result.type, isNotNull); |
| 7196 } | 6907 } |
| 7197 | 6908 |
| 7198 void test_parseFinalConstVarOrType_type_prefixedAndParameterized() { | 6909 void test_parseFinalConstVarOrType_type_prefixedAndParameterized() { |
| 7199 FinalConstVarOrType result = ParserTestCase.parse( | 6910 FinalConstVarOrType result = |
| 7200 "parseFinalConstVarOrType", <Object>[false], "p.A<B> a"); | 6911 parse("parseFinalConstVarOrType", <Object>[false], "p.A<B> a"); |
| 7201 expect(result.keyword, isNull); | 6912 expect(result.keyword, isNull); |
| 7202 expect(result.type, isNotNull); | 6913 expect(result.type, isNotNull); |
| 7203 } | 6914 } |
| 7204 | 6915 |
| 7205 void test_parseFinalConstVarOrType_type_simple() { | 6916 void test_parseFinalConstVarOrType_type_simple() { |
| 7206 FinalConstVarOrType result = ParserTestCase.parse( | 6917 FinalConstVarOrType result = |
| 7207 "parseFinalConstVarOrType", <Object>[false], "A a"); | 6918 parse("parseFinalConstVarOrType", <Object>[false], "A a"); |
| 7208 expect(result.keyword, isNull); | 6919 expect(result.keyword, isNull); |
| 7209 expect(result.type, isNotNull); | 6920 expect(result.type, isNotNull); |
| 7210 } | 6921 } |
| 7211 | 6922 |
| 7212 void test_parseFinalConstVarOrType_var() { | 6923 void test_parseFinalConstVarOrType_var() { |
| 7213 FinalConstVarOrType result = ParserTestCase.parse( | 6924 FinalConstVarOrType result = |
| 7214 "parseFinalConstVarOrType", <Object>[false], "var"); | 6925 parse("parseFinalConstVarOrType", <Object>[false], "var"); |
| 7215 Token keyword = result.keyword; | 6926 Token keyword = result.keyword; |
| 7216 expect(keyword, isNotNull); | 6927 expect(keyword, isNotNull); |
| 7217 expect(keyword.type, TokenType.KEYWORD); | 6928 expect(keyword.type, TokenType.KEYWORD); |
| 7218 expect((keyword as KeywordToken).keyword, Keyword.VAR); | 6929 expect((keyword as KeywordToken).keyword, Keyword.VAR); |
| 7219 expect(result.type, isNull); | 6930 expect(result.type, isNull); |
| 7220 } | 6931 } |
| 7221 | 6932 |
| 7222 void test_parseFinalConstVarOrType_void() { | 6933 void test_parseFinalConstVarOrType_void() { |
| 7223 FinalConstVarOrType result = ParserTestCase.parse( | 6934 FinalConstVarOrType result = |
| 7224 "parseFinalConstVarOrType", <Object>[false], "void f()"); | 6935 parse("parseFinalConstVarOrType", <Object>[false], "void f()"); |
| 7225 expect(result.keyword, isNull); | 6936 expect(result.keyword, isNull); |
| 7226 expect(result.type, isNotNull); | 6937 expect(result.type, isNotNull); |
| 7227 } | 6938 } |
| 7228 | 6939 |
| 7229 void test_parseFinalConstVarOrType_void_noIdentifier() { | 6940 void test_parseFinalConstVarOrType_void_noIdentifier() { |
| 7230 FinalConstVarOrType result = ParserTestCase.parse( | 6941 FinalConstVarOrType result = |
| 7231 "parseFinalConstVarOrType", <Object>[false], "void,"); | 6942 parse("parseFinalConstVarOrType", <Object>[false], "void,"); |
| 7232 expect(result.keyword, isNull); | 6943 expect(result.keyword, isNull); |
| 7233 expect(result.type, isNotNull); | 6944 expect(result.type, isNotNull); |
| 7234 } | 6945 } |
| 7235 | 6946 |
| 7236 void test_parseFormalParameter_final_withType_named() { | 6947 void test_parseFormalParameter_final_withType_named() { |
| 7237 ParameterKind kind = ParameterKind.NAMED; | 6948 ParameterKind kind = ParameterKind.NAMED; |
| 7238 DefaultFormalParameter parameter = ParserTestCase.parse( | 6949 DefaultFormalParameter parameter = |
| 7239 "parseFormalParameter", <Object>[kind], "final A a : null"); | 6950 parse("parseFormalParameter", <Object>[kind], "final A a : null"); |
| 7240 SimpleFormalParameter simpleParameter = | 6951 SimpleFormalParameter simpleParameter = |
| 7241 parameter.parameter as SimpleFormalParameter; | 6952 parameter.parameter as SimpleFormalParameter; |
| 7242 expect(simpleParameter.identifier, isNotNull); | 6953 expect(simpleParameter.identifier, isNotNull); |
| 7243 expect(simpleParameter.keyword, isNotNull); | 6954 expect(simpleParameter.keyword, isNotNull); |
| 7244 expect(simpleParameter.type, isNotNull); | 6955 expect(simpleParameter.type, isNotNull); |
| 7245 expect(simpleParameter.kind, kind); | 6956 expect(simpleParameter.kind, kind); |
| 7246 expect(parameter.separator, isNotNull); | 6957 expect(parameter.separator, isNotNull); |
| 7247 expect(parameter.defaultValue, isNotNull); | 6958 expect(parameter.defaultValue, isNotNull); |
| 7248 expect(parameter.kind, kind); | 6959 expect(parameter.kind, kind); |
| 7249 } | 6960 } |
| 7250 | 6961 |
| 7251 void test_parseFormalParameter_final_withType_normal() { | 6962 void test_parseFormalParameter_final_withType_normal() { |
| 7252 ParameterKind kind = ParameterKind.REQUIRED; | 6963 ParameterKind kind = ParameterKind.REQUIRED; |
| 7253 SimpleFormalParameter parameter = ParserTestCase.parse( | 6964 SimpleFormalParameter parameter = |
| 7254 "parseFormalParameter", <Object>[kind], "final A a"); | 6965 parse("parseFormalParameter", <Object>[kind], "final A a"); |
| 7255 expect(parameter.identifier, isNotNull); | 6966 expect(parameter.identifier, isNotNull); |
| 7256 expect(parameter.keyword, isNotNull); | 6967 expect(parameter.keyword, isNotNull); |
| 7257 expect(parameter.type, isNotNull); | 6968 expect(parameter.type, isNotNull); |
| 7258 expect(parameter.kind, kind); | 6969 expect(parameter.kind, kind); |
| 7259 } | 6970 } |
| 7260 | 6971 |
| 7261 void test_parseFormalParameter_final_withType_positional() { | 6972 void test_parseFormalParameter_final_withType_positional() { |
| 7262 ParameterKind kind = ParameterKind.POSITIONAL; | 6973 ParameterKind kind = ParameterKind.POSITIONAL; |
| 7263 DefaultFormalParameter parameter = ParserTestCase.parse( | 6974 DefaultFormalParameter parameter = |
| 7264 "parseFormalParameter", <Object>[kind], "final A a = null"); | 6975 parse("parseFormalParameter", <Object>[kind], "final A a = null"); |
| 7265 SimpleFormalParameter simpleParameter = | 6976 SimpleFormalParameter simpleParameter = |
| 7266 parameter.parameter as SimpleFormalParameter; | 6977 parameter.parameter as SimpleFormalParameter; |
| 7267 expect(simpleParameter.identifier, isNotNull); | 6978 expect(simpleParameter.identifier, isNotNull); |
| 7268 expect(simpleParameter.keyword, isNotNull); | 6979 expect(simpleParameter.keyword, isNotNull); |
| 7269 expect(simpleParameter.type, isNotNull); | 6980 expect(simpleParameter.type, isNotNull); |
| 7270 expect(simpleParameter.kind, kind); | 6981 expect(simpleParameter.kind, kind); |
| 7271 expect(parameter.separator, isNotNull); | 6982 expect(parameter.separator, isNotNull); |
| 7272 expect(parameter.defaultValue, isNotNull); | 6983 expect(parameter.defaultValue, isNotNull); |
| 7273 expect(parameter.kind, kind); | 6984 expect(parameter.kind, kind); |
| 7274 } | 6985 } |
| 7275 | 6986 |
| 7276 void test_parseFormalParameter_nonFinal_withType_named() { | 6987 void test_parseFormalParameter_nonFinal_withType_named() { |
| 7277 ParameterKind kind = ParameterKind.NAMED; | 6988 ParameterKind kind = ParameterKind.NAMED; |
| 7278 DefaultFormalParameter parameter = ParserTestCase.parse( | 6989 DefaultFormalParameter parameter = |
| 7279 "parseFormalParameter", <Object>[kind], "A a : null"); | 6990 parse("parseFormalParameter", <Object>[kind], "A a : null"); |
| 7280 SimpleFormalParameter simpleParameter = | 6991 SimpleFormalParameter simpleParameter = |
| 7281 parameter.parameter as SimpleFormalParameter; | 6992 parameter.parameter as SimpleFormalParameter; |
| 7282 expect(simpleParameter.identifier, isNotNull); | 6993 expect(simpleParameter.identifier, isNotNull); |
| 7283 expect(simpleParameter.keyword, isNull); | 6994 expect(simpleParameter.keyword, isNull); |
| 7284 expect(simpleParameter.type, isNotNull); | 6995 expect(simpleParameter.type, isNotNull); |
| 7285 expect(simpleParameter.kind, kind); | 6996 expect(simpleParameter.kind, kind); |
| 7286 expect(parameter.separator, isNotNull); | 6997 expect(parameter.separator, isNotNull); |
| 7287 expect(parameter.defaultValue, isNotNull); | 6998 expect(parameter.defaultValue, isNotNull); |
| 7288 expect(parameter.kind, kind); | 6999 expect(parameter.kind, kind); |
| 7289 } | 7000 } |
| 7290 | 7001 |
| 7291 void test_parseFormalParameter_nonFinal_withType_normal() { | 7002 void test_parseFormalParameter_nonFinal_withType_normal() { |
| 7292 ParameterKind kind = ParameterKind.REQUIRED; | 7003 ParameterKind kind = ParameterKind.REQUIRED; |
| 7293 SimpleFormalParameter parameter = | 7004 SimpleFormalParameter parameter = |
| 7294 ParserTestCase.parse("parseFormalParameter", <Object>[kind], "A a"); | 7005 parse("parseFormalParameter", <Object>[kind], "A a"); |
| 7295 expect(parameter.identifier, isNotNull); | 7006 expect(parameter.identifier, isNotNull); |
| 7296 expect(parameter.keyword, isNull); | 7007 expect(parameter.keyword, isNull); |
| 7297 expect(parameter.type, isNotNull); | 7008 expect(parameter.type, isNotNull); |
| 7298 expect(parameter.kind, kind); | 7009 expect(parameter.kind, kind); |
| 7299 } | 7010 } |
| 7300 | 7011 |
| 7301 void test_parseFormalParameter_nonFinal_withType_positional() { | 7012 void test_parseFormalParameter_nonFinal_withType_positional() { |
| 7302 ParameterKind kind = ParameterKind.POSITIONAL; | 7013 ParameterKind kind = ParameterKind.POSITIONAL; |
| 7303 DefaultFormalParameter parameter = ParserTestCase.parse( | 7014 DefaultFormalParameter parameter = |
| 7304 "parseFormalParameter", <Object>[kind], "A a = null"); | 7015 parse("parseFormalParameter", <Object>[kind], "A a = null"); |
| 7305 SimpleFormalParameter simpleParameter = | 7016 SimpleFormalParameter simpleParameter = |
| 7306 parameter.parameter as SimpleFormalParameter; | 7017 parameter.parameter as SimpleFormalParameter; |
| 7307 expect(simpleParameter.identifier, isNotNull); | 7018 expect(simpleParameter.identifier, isNotNull); |
| 7308 expect(simpleParameter.keyword, isNull); | 7019 expect(simpleParameter.keyword, isNull); |
| 7309 expect(simpleParameter.type, isNotNull); | 7020 expect(simpleParameter.type, isNotNull); |
| 7310 expect(simpleParameter.kind, kind); | 7021 expect(simpleParameter.kind, kind); |
| 7311 expect(parameter.separator, isNotNull); | 7022 expect(parameter.separator, isNotNull); |
| 7312 expect(parameter.defaultValue, isNotNull); | 7023 expect(parameter.defaultValue, isNotNull); |
| 7313 expect(parameter.kind, kind); | 7024 expect(parameter.kind, kind); |
| 7314 } | 7025 } |
| 7315 | 7026 |
| 7316 void test_parseFormalParameter_var() { | 7027 void test_parseFormalParameter_var() { |
| 7317 ParameterKind kind = ParameterKind.REQUIRED; | 7028 ParameterKind kind = ParameterKind.REQUIRED; |
| 7318 SimpleFormalParameter parameter = | 7029 SimpleFormalParameter parameter = |
| 7319 ParserTestCase.parse("parseFormalParameter", <Object>[kind], "var a"); | 7030 parse("parseFormalParameter", <Object>[kind], "var a"); |
| 7320 expect(parameter.identifier, isNotNull); | 7031 expect(parameter.identifier, isNotNull); |
| 7321 expect(parameter.keyword, isNotNull); | 7032 expect(parameter.keyword, isNotNull); |
| 7322 expect(parameter.type, isNull); | 7033 expect(parameter.type, isNull); |
| 7323 expect(parameter.kind, kind); | 7034 expect(parameter.kind, kind); |
| 7324 } | 7035 } |
| 7325 | 7036 |
| 7326 void test_parseFormalParameter_var_named() { | 7037 void test_parseFormalParameter_var_named() { |
| 7327 ParameterKind kind = ParameterKind.NAMED; | 7038 ParameterKind kind = ParameterKind.NAMED; |
| 7328 DefaultFormalParameter parameter = ParserTestCase.parse( | 7039 DefaultFormalParameter parameter = |
| 7329 "parseFormalParameter", <Object>[kind], "var a : null"); | 7040 parse("parseFormalParameter", <Object>[kind], "var a : null"); |
| 7330 SimpleFormalParameter simpleParameter = | 7041 SimpleFormalParameter simpleParameter = |
| 7331 parameter.parameter as SimpleFormalParameter; | 7042 parameter.parameter as SimpleFormalParameter; |
| 7332 expect(simpleParameter.identifier, isNotNull); | 7043 expect(simpleParameter.identifier, isNotNull); |
| 7333 expect(simpleParameter.keyword, isNotNull); | 7044 expect(simpleParameter.keyword, isNotNull); |
| 7334 expect(simpleParameter.type, isNull); | 7045 expect(simpleParameter.type, isNull); |
| 7335 expect(simpleParameter.kind, kind); | 7046 expect(simpleParameter.kind, kind); |
| 7336 expect(parameter.separator, isNotNull); | 7047 expect(parameter.separator, isNotNull); |
| 7337 expect(parameter.defaultValue, isNotNull); | 7048 expect(parameter.defaultValue, isNotNull); |
| 7338 expect(parameter.kind, kind); | 7049 expect(parameter.kind, kind); |
| 7339 } | 7050 } |
| 7340 | 7051 |
| 7341 void test_parseFormalParameter_var_positional() { | 7052 void test_parseFormalParameter_var_positional() { |
| 7342 ParameterKind kind = ParameterKind.POSITIONAL; | 7053 ParameterKind kind = ParameterKind.POSITIONAL; |
| 7343 DefaultFormalParameter parameter = ParserTestCase.parse( | 7054 DefaultFormalParameter parameter = |
| 7344 "parseFormalParameter", <Object>[kind], "var a = null"); | 7055 parse("parseFormalParameter", <Object>[kind], "var a = null"); |
| 7345 SimpleFormalParameter simpleParameter = | 7056 SimpleFormalParameter simpleParameter = |
| 7346 parameter.parameter as SimpleFormalParameter; | 7057 parameter.parameter as SimpleFormalParameter; |
| 7347 expect(simpleParameter.identifier, isNotNull); | 7058 expect(simpleParameter.identifier, isNotNull); |
| 7348 expect(simpleParameter.keyword, isNotNull); | 7059 expect(simpleParameter.keyword, isNotNull); |
| 7349 expect(simpleParameter.type, isNull); | 7060 expect(simpleParameter.type, isNull); |
| 7350 expect(simpleParameter.kind, kind); | 7061 expect(simpleParameter.kind, kind); |
| 7351 expect(parameter.separator, isNotNull); | 7062 expect(parameter.separator, isNotNull); |
| 7352 expect(parameter.defaultValue, isNotNull); | 7063 expect(parameter.defaultValue, isNotNull); |
| 7353 expect(parameter.kind, kind); | 7064 expect(parameter.kind, kind); |
| 7354 } | 7065 } |
| 7355 | 7066 |
| 7356 void test_parseFormalParameterList_empty() { | 7067 void test_parseFormalParameterList_empty() { |
| 7357 FormalParameterList parameterList = | 7068 FormalParameterList parameterList = |
| 7358 ParserTestCase.parse4("parseFormalParameterList", "()"); | 7069 parse4("parseFormalParameterList", "()"); |
| 7359 expect(parameterList.leftParenthesis, isNotNull); | 7070 expect(parameterList.leftParenthesis, isNotNull); |
| 7360 expect(parameterList.leftDelimiter, isNull); | 7071 expect(parameterList.leftDelimiter, isNull); |
| 7361 expect(parameterList.parameters, hasLength(0)); | 7072 expect(parameterList.parameters, hasLength(0)); |
| 7362 expect(parameterList.rightDelimiter, isNull); | 7073 expect(parameterList.rightDelimiter, isNull); |
| 7363 expect(parameterList.rightParenthesis, isNotNull); | 7074 expect(parameterList.rightParenthesis, isNotNull); |
| 7364 } | 7075 } |
| 7365 | 7076 |
| 7366 void test_parseFormalParameterList_named_multiple() { | 7077 void test_parseFormalParameterList_named_multiple() { |
| 7367 FormalParameterList parameterList = ParserTestCase.parse4( | 7078 FormalParameterList parameterList = |
| 7368 "parseFormalParameterList", "({A a : 1, B b, C c : 3})"); | 7079 parse4("parseFormalParameterList", "({A a : 1, B b, C c : 3})"); |
| 7369 expect(parameterList.leftParenthesis, isNotNull); | 7080 expect(parameterList.leftParenthesis, isNotNull); |
| 7370 expect(parameterList.leftDelimiter, isNotNull); | 7081 expect(parameterList.leftDelimiter, isNotNull); |
| 7371 expect(parameterList.parameters, hasLength(3)); | 7082 expect(parameterList.parameters, hasLength(3)); |
| 7372 expect(parameterList.rightDelimiter, isNotNull); | 7083 expect(parameterList.rightDelimiter, isNotNull); |
| 7373 expect(parameterList.rightParenthesis, isNotNull); | 7084 expect(parameterList.rightParenthesis, isNotNull); |
| 7374 } | 7085 } |
| 7375 | 7086 |
| 7376 void test_parseFormalParameterList_named_single() { | 7087 void test_parseFormalParameterList_named_single() { |
| 7377 FormalParameterList parameterList = | 7088 FormalParameterList parameterList = |
| 7378 ParserTestCase.parse4("parseFormalParameterList", "({A a})"); | 7089 parse4("parseFormalParameterList", "({A a})"); |
| 7379 expect(parameterList.leftParenthesis, isNotNull); | 7090 expect(parameterList.leftParenthesis, isNotNull); |
| 7380 expect(parameterList.leftDelimiter, isNotNull); | 7091 expect(parameterList.leftDelimiter, isNotNull); |
| 7381 expect(parameterList.parameters, hasLength(1)); | 7092 expect(parameterList.parameters, hasLength(1)); |
| 7382 expect(parameterList.rightDelimiter, isNotNull); | 7093 expect(parameterList.rightDelimiter, isNotNull); |
| 7383 expect(parameterList.rightParenthesis, isNotNull); | 7094 expect(parameterList.rightParenthesis, isNotNull); |
| 7384 } | 7095 } |
| 7385 | 7096 |
| 7386 void test_parseFormalParameterList_normal_multiple() { | 7097 void test_parseFormalParameterList_normal_multiple() { |
| 7387 FormalParameterList parameterList = | 7098 FormalParameterList parameterList = |
| 7388 ParserTestCase.parse4("parseFormalParameterList", "(A a, B b, C c)"); | 7099 parse4("parseFormalParameterList", "(A a, B b, C c)"); |
| 7389 expect(parameterList.leftParenthesis, isNotNull); | 7100 expect(parameterList.leftParenthesis, isNotNull); |
| 7390 expect(parameterList.leftDelimiter, isNull); | 7101 expect(parameterList.leftDelimiter, isNull); |
| 7391 expect(parameterList.parameters, hasLength(3)); | 7102 expect(parameterList.parameters, hasLength(3)); |
| 7392 expect(parameterList.rightDelimiter, isNull); | 7103 expect(parameterList.rightDelimiter, isNull); |
| 7393 expect(parameterList.rightParenthesis, isNotNull); | 7104 expect(parameterList.rightParenthesis, isNotNull); |
| 7394 } | 7105 } |
| 7395 | 7106 |
| 7396 void test_parseFormalParameterList_normal_named() { | 7107 void test_parseFormalParameterList_normal_named() { |
| 7397 FormalParameterList parameterList = | 7108 FormalParameterList parameterList = |
| 7398 ParserTestCase.parse4("parseFormalParameterList", "(A a, {B b})"); | 7109 parse4("parseFormalParameterList", "(A a, {B b})"); |
| 7399 expect(parameterList.leftParenthesis, isNotNull); | 7110 expect(parameterList.leftParenthesis, isNotNull); |
| 7400 expect(parameterList.leftDelimiter, isNotNull); | 7111 expect(parameterList.leftDelimiter, isNotNull); |
| 7401 expect(parameterList.parameters, hasLength(2)); | 7112 expect(parameterList.parameters, hasLength(2)); |
| 7402 expect(parameterList.rightDelimiter, isNotNull); | 7113 expect(parameterList.rightDelimiter, isNotNull); |
| 7403 expect(parameterList.rightParenthesis, isNotNull); | 7114 expect(parameterList.rightParenthesis, isNotNull); |
| 7404 } | 7115 } |
| 7405 | 7116 |
| 7406 void test_parseFormalParameterList_normal_positional() { | 7117 void test_parseFormalParameterList_normal_positional() { |
| 7407 FormalParameterList parameterList = | 7118 FormalParameterList parameterList = |
| 7408 ParserTestCase.parse4("parseFormalParameterList", "(A a, [B b])"); | 7119 parse4("parseFormalParameterList", "(A a, [B b])"); |
| 7409 expect(parameterList.leftParenthesis, isNotNull); | 7120 expect(parameterList.leftParenthesis, isNotNull); |
| 7410 expect(parameterList.leftDelimiter, isNotNull); | 7121 expect(parameterList.leftDelimiter, isNotNull); |
| 7411 expect(parameterList.parameters, hasLength(2)); | 7122 expect(parameterList.parameters, hasLength(2)); |
| 7412 expect(parameterList.rightDelimiter, isNotNull); | 7123 expect(parameterList.rightDelimiter, isNotNull); |
| 7413 expect(parameterList.rightParenthesis, isNotNull); | 7124 expect(parameterList.rightParenthesis, isNotNull); |
| 7414 } | 7125 } |
| 7415 | 7126 |
| 7416 void test_parseFormalParameterList_normal_single() { | 7127 void test_parseFormalParameterList_normal_single() { |
| 7417 FormalParameterList parameterList = | 7128 FormalParameterList parameterList = |
| 7418 ParserTestCase.parse4("parseFormalParameterList", "(A a)"); | 7129 parse4("parseFormalParameterList", "(A a)"); |
| 7419 expect(parameterList.leftParenthesis, isNotNull); | 7130 expect(parameterList.leftParenthesis, isNotNull); |
| 7420 expect(parameterList.leftDelimiter, isNull); | 7131 expect(parameterList.leftDelimiter, isNull); |
| 7421 expect(parameterList.parameters, hasLength(1)); | 7132 expect(parameterList.parameters, hasLength(1)); |
| 7422 expect(parameterList.rightDelimiter, isNull); | 7133 expect(parameterList.rightDelimiter, isNull); |
| 7423 expect(parameterList.rightParenthesis, isNotNull); | 7134 expect(parameterList.rightParenthesis, isNotNull); |
| 7424 } | 7135 } |
| 7425 | 7136 |
| 7426 void test_parseFormalParameterList_positional_multiple() { | 7137 void test_parseFormalParameterList_positional_multiple() { |
| 7427 FormalParameterList parameterList = ParserTestCase.parse4( | 7138 FormalParameterList parameterList = |
| 7428 "parseFormalParameterList", "([A a = null, B b, C c = null])"); | 7139 parse4("parseFormalParameterList", "([A a = null, B b, C c = null])"); |
| 7429 expect(parameterList.leftParenthesis, isNotNull); | 7140 expect(parameterList.leftParenthesis, isNotNull); |
| 7430 expect(parameterList.leftDelimiter, isNotNull); | 7141 expect(parameterList.leftDelimiter, isNotNull); |
| 7431 expect(parameterList.parameters, hasLength(3)); | 7142 expect(parameterList.parameters, hasLength(3)); |
| 7432 expect(parameterList.rightDelimiter, isNotNull); | 7143 expect(parameterList.rightDelimiter, isNotNull); |
| 7433 expect(parameterList.rightParenthesis, isNotNull); | 7144 expect(parameterList.rightParenthesis, isNotNull); |
| 7434 } | 7145 } |
| 7435 | 7146 |
| 7436 void test_parseFormalParameterList_positional_single() { | 7147 void test_parseFormalParameterList_positional_single() { |
| 7437 FormalParameterList parameterList = | 7148 FormalParameterList parameterList = |
| 7438 ParserTestCase.parse4("parseFormalParameterList", "([A a = null])"); | 7149 parse4("parseFormalParameterList", "([A a = null])"); |
| 7439 expect(parameterList.leftParenthesis, isNotNull); | 7150 expect(parameterList.leftParenthesis, isNotNull); |
| 7440 expect(parameterList.leftDelimiter, isNotNull); | 7151 expect(parameterList.leftDelimiter, isNotNull); |
| 7441 expect(parameterList.parameters, hasLength(1)); | 7152 expect(parameterList.parameters, hasLength(1)); |
| 7442 expect(parameterList.rightDelimiter, isNotNull); | 7153 expect(parameterList.rightDelimiter, isNotNull); |
| 7443 expect(parameterList.rightParenthesis, isNotNull); | 7154 expect(parameterList.rightParenthesis, isNotNull); |
| 7444 } | 7155 } |
| 7445 | 7156 |
| 7446 void test_parseForStatement_each_await() { | 7157 void test_parseForStatement_each_await() { |
| 7447 ForEachStatement statement = ParserTestCase.parse4( | 7158 ForEachStatement statement = |
| 7448 "parseForStatement", "await for (element in list) {}"); | 7159 parse4("parseForStatement", "await for (element in list) {}"); |
| 7449 expect(statement.awaitKeyword, isNotNull); | 7160 expect(statement.awaitKeyword, isNotNull); |
| 7450 expect(statement.forKeyword, isNotNull); | 7161 expect(statement.forKeyword, isNotNull); |
| 7451 expect(statement.leftParenthesis, isNotNull); | 7162 expect(statement.leftParenthesis, isNotNull); |
| 7452 expect(statement.loopVariable, isNull); | 7163 expect(statement.loopVariable, isNull); |
| 7453 expect(statement.identifier, isNotNull); | 7164 expect(statement.identifier, isNotNull); |
| 7454 expect(statement.inKeyword, isNotNull); | 7165 expect(statement.inKeyword, isNotNull); |
| 7455 expect(statement.iterable, isNotNull); | 7166 expect(statement.iterable, isNotNull); |
| 7456 expect(statement.rightParenthesis, isNotNull); | 7167 expect(statement.rightParenthesis, isNotNull); |
| 7457 expect(statement.body, isNotNull); | 7168 expect(statement.body, isNotNull); |
| 7458 } | 7169 } |
| 7459 | 7170 |
| 7460 void test_parseForStatement_each_identifier() { | 7171 void test_parseForStatement_each_identifier() { |
| 7461 ForEachStatement statement = | 7172 ForEachStatement statement = |
| 7462 ParserTestCase.parse4("parseForStatement", "for (element in list) {}"); | 7173 parse4("parseForStatement", "for (element in list) {}"); |
| 7463 expect(statement.awaitKeyword, isNull); | 7174 expect(statement.awaitKeyword, isNull); |
| 7464 expect(statement.forKeyword, isNotNull); | 7175 expect(statement.forKeyword, isNotNull); |
| 7465 expect(statement.leftParenthesis, isNotNull); | 7176 expect(statement.leftParenthesis, isNotNull); |
| 7466 expect(statement.loopVariable, isNull); | 7177 expect(statement.loopVariable, isNull); |
| 7467 expect(statement.identifier, isNotNull); | 7178 expect(statement.identifier, isNotNull); |
| 7468 expect(statement.inKeyword, isNotNull); | 7179 expect(statement.inKeyword, isNotNull); |
| 7469 expect(statement.iterable, isNotNull); | 7180 expect(statement.iterable, isNotNull); |
| 7470 expect(statement.rightParenthesis, isNotNull); | 7181 expect(statement.rightParenthesis, isNotNull); |
| 7471 expect(statement.body, isNotNull); | 7182 expect(statement.body, isNotNull); |
| 7472 } | 7183 } |
| 7473 | 7184 |
| 7474 void test_parseForStatement_each_noType_metadata() { | 7185 void test_parseForStatement_each_noType_metadata() { |
| 7475 ForEachStatement statement = ParserTestCase.parse4( | 7186 ForEachStatement statement = |
| 7476 "parseForStatement", "for (@A var element in list) {}"); | 7187 parse4("parseForStatement", "for (@A var element in list) {}"); |
| 7477 expect(statement.awaitKeyword, isNull); | 7188 expect(statement.awaitKeyword, isNull); |
| 7478 expect(statement.forKeyword, isNotNull); | 7189 expect(statement.forKeyword, isNotNull); |
| 7479 expect(statement.leftParenthesis, isNotNull); | 7190 expect(statement.leftParenthesis, isNotNull); |
| 7480 expect(statement.loopVariable, isNotNull); | 7191 expect(statement.loopVariable, isNotNull); |
| 7481 expect(statement.loopVariable.metadata, hasLength(1)); | 7192 expect(statement.loopVariable.metadata, hasLength(1)); |
| 7482 expect(statement.identifier, isNull); | 7193 expect(statement.identifier, isNull); |
| 7483 expect(statement.inKeyword, isNotNull); | 7194 expect(statement.inKeyword, isNotNull); |
| 7484 expect(statement.iterable, isNotNull); | 7195 expect(statement.iterable, isNotNull); |
| 7485 expect(statement.rightParenthesis, isNotNull); | 7196 expect(statement.rightParenthesis, isNotNull); |
| 7486 expect(statement.body, isNotNull); | 7197 expect(statement.body, isNotNull); |
| 7487 } | 7198 } |
| 7488 | 7199 |
| 7489 void test_parseForStatement_each_type() { | 7200 void test_parseForStatement_each_type() { |
| 7490 ForEachStatement statement = ParserTestCase.parse4( | 7201 ForEachStatement statement = |
| 7491 "parseForStatement", "for (A element in list) {}"); | 7202 parse4("parseForStatement", "for (A element in list) {}"); |
| 7492 expect(statement.awaitKeyword, isNull); | 7203 expect(statement.awaitKeyword, isNull); |
| 7493 expect(statement.forKeyword, isNotNull); | 7204 expect(statement.forKeyword, isNotNull); |
| 7494 expect(statement.leftParenthesis, isNotNull); | 7205 expect(statement.leftParenthesis, isNotNull); |
| 7495 expect(statement.loopVariable, isNotNull); | 7206 expect(statement.loopVariable, isNotNull); |
| 7496 expect(statement.identifier, isNull); | 7207 expect(statement.identifier, isNull); |
| 7497 expect(statement.inKeyword, isNotNull); | 7208 expect(statement.inKeyword, isNotNull); |
| 7498 expect(statement.iterable, isNotNull); | 7209 expect(statement.iterable, isNotNull); |
| 7499 expect(statement.rightParenthesis, isNotNull); | 7210 expect(statement.rightParenthesis, isNotNull); |
| 7500 expect(statement.body, isNotNull); | 7211 expect(statement.body, isNotNull); |
| 7501 } | 7212 } |
| 7502 | 7213 |
| 7503 void test_parseForStatement_each_var() { | 7214 void test_parseForStatement_each_var() { |
| 7504 ForEachStatement statement = ParserTestCase.parse4( | 7215 ForEachStatement statement = |
| 7505 "parseForStatement", "for (var element in list) {}"); | 7216 parse4("parseForStatement", "for (var element in list) {}"); |
| 7506 expect(statement.awaitKeyword, isNull); | 7217 expect(statement.awaitKeyword, isNull); |
| 7507 expect(statement.forKeyword, isNotNull); | 7218 expect(statement.forKeyword, isNotNull); |
| 7508 expect(statement.leftParenthesis, isNotNull); | 7219 expect(statement.leftParenthesis, isNotNull); |
| 7509 expect(statement.loopVariable, isNotNull); | 7220 expect(statement.loopVariable, isNotNull); |
| 7510 expect(statement.identifier, isNull); | 7221 expect(statement.identifier, isNull); |
| 7511 expect(statement.inKeyword, isNotNull); | 7222 expect(statement.inKeyword, isNotNull); |
| 7512 expect(statement.iterable, isNotNull); | 7223 expect(statement.iterable, isNotNull); |
| 7513 expect(statement.rightParenthesis, isNotNull); | 7224 expect(statement.rightParenthesis, isNotNull); |
| 7514 expect(statement.body, isNotNull); | 7225 expect(statement.body, isNotNull); |
| 7515 } | 7226 } |
| 7516 | 7227 |
| 7517 void test_parseForStatement_loop_c() { | 7228 void test_parseForStatement_loop_c() { |
| 7518 ForStatement statement = | 7229 ForStatement statement = |
| 7519 ParserTestCase.parse4("parseForStatement", "for (; i < count;) {}"); | 7230 parse4("parseForStatement", "for (; i < count;) {}"); |
| 7520 expect(statement.forKeyword, isNotNull); | 7231 expect(statement.forKeyword, isNotNull); |
| 7521 expect(statement.leftParenthesis, isNotNull); | 7232 expect(statement.leftParenthesis, isNotNull); |
| 7522 expect(statement.variables, isNull); | 7233 expect(statement.variables, isNull); |
| 7523 expect(statement.initialization, isNull); | 7234 expect(statement.initialization, isNull); |
| 7524 expect(statement.leftSeparator, isNotNull); | 7235 expect(statement.leftSeparator, isNotNull); |
| 7525 expect(statement.condition, isNotNull); | 7236 expect(statement.condition, isNotNull); |
| 7526 expect(statement.rightSeparator, isNotNull); | 7237 expect(statement.rightSeparator, isNotNull); |
| 7527 expect(statement.updaters, hasLength(0)); | 7238 expect(statement.updaters, hasLength(0)); |
| 7528 expect(statement.rightParenthesis, isNotNull); | 7239 expect(statement.rightParenthesis, isNotNull); |
| 7529 expect(statement.body, isNotNull); | 7240 expect(statement.body, isNotNull); |
| 7530 } | 7241 } |
| 7531 | 7242 |
| 7532 void test_parseForStatement_loop_cu() { | 7243 void test_parseForStatement_loop_cu() { |
| 7533 ForStatement statement = | 7244 ForStatement statement = |
| 7534 ParserTestCase.parse4("parseForStatement", "for (; i < count; i++) {}"); | 7245 parse4("parseForStatement", "for (; i < count; i++) {}"); |
| 7535 expect(statement.forKeyword, isNotNull); | 7246 expect(statement.forKeyword, isNotNull); |
| 7536 expect(statement.leftParenthesis, isNotNull); | 7247 expect(statement.leftParenthesis, isNotNull); |
| 7537 expect(statement.variables, isNull); | 7248 expect(statement.variables, isNull); |
| 7538 expect(statement.initialization, isNull); | 7249 expect(statement.initialization, isNull); |
| 7539 expect(statement.leftSeparator, isNotNull); | 7250 expect(statement.leftSeparator, isNotNull); |
| 7540 expect(statement.condition, isNotNull); | 7251 expect(statement.condition, isNotNull); |
| 7541 expect(statement.rightSeparator, isNotNull); | 7252 expect(statement.rightSeparator, isNotNull); |
| 7542 expect(statement.updaters, hasLength(1)); | 7253 expect(statement.updaters, hasLength(1)); |
| 7543 expect(statement.rightParenthesis, isNotNull); | 7254 expect(statement.rightParenthesis, isNotNull); |
| 7544 expect(statement.body, isNotNull); | 7255 expect(statement.body, isNotNull); |
| 7545 } | 7256 } |
| 7546 | 7257 |
| 7547 void test_parseForStatement_loop_ecu() { | 7258 void test_parseForStatement_loop_ecu() { |
| 7548 ForStatement statement = ParserTestCase.parse4( | 7259 ForStatement statement = |
| 7549 "parseForStatement", "for (i--; i < count; i++) {}"); | 7260 parse4("parseForStatement", "for (i--; i < count; i++) {}"); |
| 7550 expect(statement.forKeyword, isNotNull); | 7261 expect(statement.forKeyword, isNotNull); |
| 7551 expect(statement.leftParenthesis, isNotNull); | 7262 expect(statement.leftParenthesis, isNotNull); |
| 7552 expect(statement.variables, isNull); | 7263 expect(statement.variables, isNull); |
| 7553 expect(statement.initialization, isNotNull); | 7264 expect(statement.initialization, isNotNull); |
| 7554 expect(statement.leftSeparator, isNotNull); | 7265 expect(statement.leftSeparator, isNotNull); |
| 7555 expect(statement.condition, isNotNull); | 7266 expect(statement.condition, isNotNull); |
| 7556 expect(statement.rightSeparator, isNotNull); | 7267 expect(statement.rightSeparator, isNotNull); |
| 7557 expect(statement.updaters, hasLength(1)); | 7268 expect(statement.updaters, hasLength(1)); |
| 7558 expect(statement.rightParenthesis, isNotNull); | 7269 expect(statement.rightParenthesis, isNotNull); |
| 7559 expect(statement.body, isNotNull); | 7270 expect(statement.body, isNotNull); |
| 7560 } | 7271 } |
| 7561 | 7272 |
| 7562 void test_parseForStatement_loop_i() { | 7273 void test_parseForStatement_loop_i() { |
| 7563 ForStatement statement = | 7274 ForStatement statement = |
| 7564 ParserTestCase.parse4("parseForStatement", "for (var i = 0;;) {}"); | 7275 parse4("parseForStatement", "for (var i = 0;;) {}"); |
| 7565 expect(statement.forKeyword, isNotNull); | 7276 expect(statement.forKeyword, isNotNull); |
| 7566 expect(statement.leftParenthesis, isNotNull); | 7277 expect(statement.leftParenthesis, isNotNull); |
| 7567 VariableDeclarationList variables = statement.variables; | 7278 VariableDeclarationList variables = statement.variables; |
| 7568 expect(variables, isNotNull); | 7279 expect(variables, isNotNull); |
| 7569 expect(variables.metadata, hasLength(0)); | 7280 expect(variables.metadata, hasLength(0)); |
| 7570 expect(variables.variables, hasLength(1)); | 7281 expect(variables.variables, hasLength(1)); |
| 7571 expect(statement.initialization, isNull); | 7282 expect(statement.initialization, isNull); |
| 7572 expect(statement.leftSeparator, isNotNull); | 7283 expect(statement.leftSeparator, isNotNull); |
| 7573 expect(statement.condition, isNull); | 7284 expect(statement.condition, isNull); |
| 7574 expect(statement.rightSeparator, isNotNull); | 7285 expect(statement.rightSeparator, isNotNull); |
| 7575 expect(statement.updaters, hasLength(0)); | 7286 expect(statement.updaters, hasLength(0)); |
| 7576 expect(statement.rightParenthesis, isNotNull); | 7287 expect(statement.rightParenthesis, isNotNull); |
| 7577 expect(statement.body, isNotNull); | 7288 expect(statement.body, isNotNull); |
| 7578 } | 7289 } |
| 7579 | 7290 |
| 7580 void test_parseForStatement_loop_i_withMetadata() { | 7291 void test_parseForStatement_loop_i_withMetadata() { |
| 7581 ForStatement statement = | 7292 ForStatement statement = |
| 7582 ParserTestCase.parse4("parseForStatement", "for (@A var i = 0;;) {}"); | 7293 parse4("parseForStatement", "for (@A var i = 0;;) {}"); |
| 7583 expect(statement.forKeyword, isNotNull); | 7294 expect(statement.forKeyword, isNotNull); |
| 7584 expect(statement.leftParenthesis, isNotNull); | 7295 expect(statement.leftParenthesis, isNotNull); |
| 7585 VariableDeclarationList variables = statement.variables; | 7296 VariableDeclarationList variables = statement.variables; |
| 7586 expect(variables, isNotNull); | 7297 expect(variables, isNotNull); |
| 7587 expect(variables.metadata, hasLength(1)); | 7298 expect(variables.metadata, hasLength(1)); |
| 7588 expect(variables.variables, hasLength(1)); | 7299 expect(variables.variables, hasLength(1)); |
| 7589 expect(statement.initialization, isNull); | 7300 expect(statement.initialization, isNull); |
| 7590 expect(statement.leftSeparator, isNotNull); | 7301 expect(statement.leftSeparator, isNotNull); |
| 7591 expect(statement.condition, isNull); | 7302 expect(statement.condition, isNull); |
| 7592 expect(statement.rightSeparator, isNotNull); | 7303 expect(statement.rightSeparator, isNotNull); |
| 7593 expect(statement.updaters, hasLength(0)); | 7304 expect(statement.updaters, hasLength(0)); |
| 7594 expect(statement.rightParenthesis, isNotNull); | 7305 expect(statement.rightParenthesis, isNotNull); |
| 7595 expect(statement.body, isNotNull); | 7306 expect(statement.body, isNotNull); |
| 7596 } | 7307 } |
| 7597 | 7308 |
| 7598 void test_parseForStatement_loop_ic() { | 7309 void test_parseForStatement_loop_ic() { |
| 7599 ForStatement statement = ParserTestCase.parse4( | 7310 ForStatement statement = |
| 7600 "parseForStatement", "for (var i = 0; i < count;) {}"); | 7311 parse4("parseForStatement", "for (var i = 0; i < count;) {}"); |
| 7601 expect(statement.forKeyword, isNotNull); | 7312 expect(statement.forKeyword, isNotNull); |
| 7602 expect(statement.leftParenthesis, isNotNull); | 7313 expect(statement.leftParenthesis, isNotNull); |
| 7603 VariableDeclarationList variables = statement.variables; | 7314 VariableDeclarationList variables = statement.variables; |
| 7604 expect(variables, isNotNull); | 7315 expect(variables, isNotNull); |
| 7605 expect(variables.variables, hasLength(1)); | 7316 expect(variables.variables, hasLength(1)); |
| 7606 expect(statement.initialization, isNull); | 7317 expect(statement.initialization, isNull); |
| 7607 expect(statement.leftSeparator, isNotNull); | 7318 expect(statement.leftSeparator, isNotNull); |
| 7608 expect(statement.condition, isNotNull); | 7319 expect(statement.condition, isNotNull); |
| 7609 expect(statement.rightSeparator, isNotNull); | 7320 expect(statement.rightSeparator, isNotNull); |
| 7610 expect(statement.updaters, hasLength(0)); | 7321 expect(statement.updaters, hasLength(0)); |
| 7611 expect(statement.rightParenthesis, isNotNull); | 7322 expect(statement.rightParenthesis, isNotNull); |
| 7612 expect(statement.body, isNotNull); | 7323 expect(statement.body, isNotNull); |
| 7613 } | 7324 } |
| 7614 | 7325 |
| 7615 void test_parseForStatement_loop_icu() { | 7326 void test_parseForStatement_loop_icu() { |
| 7616 ForStatement statement = ParserTestCase.parse4( | 7327 ForStatement statement = |
| 7617 "parseForStatement", "for (var i = 0; i < count; i++) {}"); | 7328 parse4("parseForStatement", "for (var i = 0; i < count; i++) {}"); |
| 7618 expect(statement.forKeyword, isNotNull); | 7329 expect(statement.forKeyword, isNotNull); |
| 7619 expect(statement.leftParenthesis, isNotNull); | 7330 expect(statement.leftParenthesis, isNotNull); |
| 7620 VariableDeclarationList variables = statement.variables; | 7331 VariableDeclarationList variables = statement.variables; |
| 7621 expect(variables, isNotNull); | 7332 expect(variables, isNotNull); |
| 7622 expect(variables.variables, hasLength(1)); | 7333 expect(variables.variables, hasLength(1)); |
| 7623 expect(statement.initialization, isNull); | 7334 expect(statement.initialization, isNull); |
| 7624 expect(statement.leftSeparator, isNotNull); | 7335 expect(statement.leftSeparator, isNotNull); |
| 7625 expect(statement.condition, isNotNull); | 7336 expect(statement.condition, isNotNull); |
| 7626 expect(statement.rightSeparator, isNotNull); | 7337 expect(statement.rightSeparator, isNotNull); |
| 7627 expect(statement.updaters, hasLength(1)); | 7338 expect(statement.updaters, hasLength(1)); |
| 7628 expect(statement.rightParenthesis, isNotNull); | 7339 expect(statement.rightParenthesis, isNotNull); |
| 7629 expect(statement.body, isNotNull); | 7340 expect(statement.body, isNotNull); |
| 7630 } | 7341 } |
| 7631 | 7342 |
| 7632 void test_parseForStatement_loop_iicuu() { | 7343 void test_parseForStatement_loop_iicuu() { |
| 7633 ForStatement statement = ParserTestCase.parse4( | 7344 ForStatement statement = parse4( |
| 7634 "parseForStatement", "for (int i = 0, j = count; i < j; i++, j--) {}"); | 7345 "parseForStatement", "for (int i = 0, j = count; i < j; i++, j--) {}"); |
| 7635 expect(statement.forKeyword, isNotNull); | 7346 expect(statement.forKeyword, isNotNull); |
| 7636 expect(statement.leftParenthesis, isNotNull); | 7347 expect(statement.leftParenthesis, isNotNull); |
| 7637 VariableDeclarationList variables = statement.variables; | 7348 VariableDeclarationList variables = statement.variables; |
| 7638 expect(variables, isNotNull); | 7349 expect(variables, isNotNull); |
| 7639 expect(variables.variables, hasLength(2)); | 7350 expect(variables.variables, hasLength(2)); |
| 7640 expect(statement.initialization, isNull); | 7351 expect(statement.initialization, isNull); |
| 7641 expect(statement.leftSeparator, isNotNull); | 7352 expect(statement.leftSeparator, isNotNull); |
| 7642 expect(statement.condition, isNotNull); | 7353 expect(statement.condition, isNotNull); |
| 7643 expect(statement.rightSeparator, isNotNull); | 7354 expect(statement.rightSeparator, isNotNull); |
| 7644 expect(statement.updaters, hasLength(2)); | 7355 expect(statement.updaters, hasLength(2)); |
| 7645 expect(statement.rightParenthesis, isNotNull); | 7356 expect(statement.rightParenthesis, isNotNull); |
| 7646 expect(statement.body, isNotNull); | 7357 expect(statement.body, isNotNull); |
| 7647 } | 7358 } |
| 7648 | 7359 |
| 7649 void test_parseForStatement_loop_iu() { | 7360 void test_parseForStatement_loop_iu() { |
| 7650 ForStatement statement = | 7361 ForStatement statement = |
| 7651 ParserTestCase.parse4("parseForStatement", "for (var i = 0;; i++) {}"); | 7362 parse4("parseForStatement", "for (var i = 0;; i++) {}"); |
| 7652 expect(statement.forKeyword, isNotNull); | 7363 expect(statement.forKeyword, isNotNull); |
| 7653 expect(statement.leftParenthesis, isNotNull); | 7364 expect(statement.leftParenthesis, isNotNull); |
| 7654 VariableDeclarationList variables = statement.variables; | 7365 VariableDeclarationList variables = statement.variables; |
| 7655 expect(variables, isNotNull); | 7366 expect(variables, isNotNull); |
| 7656 expect(variables.variables, hasLength(1)); | 7367 expect(variables.variables, hasLength(1)); |
| 7657 expect(statement.initialization, isNull); | 7368 expect(statement.initialization, isNull); |
| 7658 expect(statement.leftSeparator, isNotNull); | 7369 expect(statement.leftSeparator, isNotNull); |
| 7659 expect(statement.condition, isNull); | 7370 expect(statement.condition, isNull); |
| 7660 expect(statement.rightSeparator, isNotNull); | 7371 expect(statement.rightSeparator, isNotNull); |
| 7661 expect(statement.updaters, hasLength(1)); | 7372 expect(statement.updaters, hasLength(1)); |
| 7662 expect(statement.rightParenthesis, isNotNull); | 7373 expect(statement.rightParenthesis, isNotNull); |
| 7663 expect(statement.body, isNotNull); | 7374 expect(statement.body, isNotNull); |
| 7664 } | 7375 } |
| 7665 | 7376 |
| 7666 void test_parseForStatement_loop_u() { | 7377 void test_parseForStatement_loop_u() { |
| 7667 ForStatement statement = | 7378 ForStatement statement = parse4("parseForStatement", "for (;; i++) {}"); |
| 7668 ParserTestCase.parse4("parseForStatement", "for (;; i++) {}"); | |
| 7669 expect(statement.forKeyword, isNotNull); | 7379 expect(statement.forKeyword, isNotNull); |
| 7670 expect(statement.leftParenthesis, isNotNull); | 7380 expect(statement.leftParenthesis, isNotNull); |
| 7671 expect(statement.variables, isNull); | 7381 expect(statement.variables, isNull); |
| 7672 expect(statement.initialization, isNull); | 7382 expect(statement.initialization, isNull); |
| 7673 expect(statement.leftSeparator, isNotNull); | 7383 expect(statement.leftSeparator, isNotNull); |
| 7674 expect(statement.condition, isNull); | 7384 expect(statement.condition, isNull); |
| 7675 expect(statement.rightSeparator, isNotNull); | 7385 expect(statement.rightSeparator, isNotNull); |
| 7676 expect(statement.updaters, hasLength(1)); | 7386 expect(statement.updaters, hasLength(1)); |
| 7677 expect(statement.rightParenthesis, isNotNull); | 7387 expect(statement.rightParenthesis, isNotNull); |
| 7678 expect(statement.body, isNotNull); | 7388 expect(statement.body, isNotNull); |
| 7679 } | 7389 } |
| 7680 | 7390 |
| 7681 void test_parseFunctionBody_block() { | 7391 void test_parseFunctionBody_block() { |
| 7682 BlockFunctionBody functionBody = ParserTestCase.parse( | 7392 BlockFunctionBody functionBody = |
| 7683 "parseFunctionBody", <Object>[false, null, false], "{}"); | 7393 parse("parseFunctionBody", <Object>[false, null, false], "{}"); |
| 7684 expect(functionBody.keyword, isNull); | 7394 expect(functionBody.keyword, isNull); |
| 7685 expect(functionBody.star, isNull); | 7395 expect(functionBody.star, isNull); |
| 7686 expect(functionBody.block, isNotNull); | 7396 expect(functionBody.block, isNotNull); |
| 7687 expect(functionBody.isAsynchronous, isFalse); | 7397 expect(functionBody.isAsynchronous, isFalse); |
| 7688 expect(functionBody.isGenerator, isFalse); | 7398 expect(functionBody.isGenerator, isFalse); |
| 7689 expect(functionBody.isSynchronous, isTrue); | 7399 expect(functionBody.isSynchronous, isTrue); |
| 7690 } | 7400 } |
| 7691 | 7401 |
| 7692 void test_parseFunctionBody_block_async() { | 7402 void test_parseFunctionBody_block_async() { |
| 7693 BlockFunctionBody functionBody = ParserTestCase.parse( | 7403 BlockFunctionBody functionBody = |
| 7694 "parseFunctionBody", <Object>[false, null, false], "async {}"); | 7404 parse("parseFunctionBody", <Object>[false, null, false], "async {}"); |
| 7695 expect(functionBody.keyword, isNotNull); | 7405 expect(functionBody.keyword, isNotNull); |
| 7696 expect(functionBody.keyword.lexeme, Parser.ASYNC); | 7406 expect(functionBody.keyword.lexeme, Parser.ASYNC); |
| 7697 expect(functionBody.star, isNull); | 7407 expect(functionBody.star, isNull); |
| 7698 expect(functionBody.block, isNotNull); | 7408 expect(functionBody.block, isNotNull); |
| 7699 expect(functionBody.isAsynchronous, isTrue); | 7409 expect(functionBody.isAsynchronous, isTrue); |
| 7700 expect(functionBody.isGenerator, isFalse); | 7410 expect(functionBody.isGenerator, isFalse); |
| 7701 expect(functionBody.isSynchronous, isFalse); | 7411 expect(functionBody.isSynchronous, isFalse); |
| 7702 } | 7412 } |
| 7703 | 7413 |
| 7704 void test_parseFunctionBody_block_asyncGenerator() { | 7414 void test_parseFunctionBody_block_asyncGenerator() { |
| 7705 BlockFunctionBody functionBody = ParserTestCase.parse( | 7415 BlockFunctionBody functionBody = |
| 7706 "parseFunctionBody", <Object>[false, null, false], "async* {}"); | 7416 parse("parseFunctionBody", <Object>[false, null, false], "async* {}"); |
| 7707 expect(functionBody.keyword, isNotNull); | 7417 expect(functionBody.keyword, isNotNull); |
| 7708 expect(functionBody.keyword.lexeme, Parser.ASYNC); | 7418 expect(functionBody.keyword.lexeme, Parser.ASYNC); |
| 7709 expect(functionBody.star, isNotNull); | 7419 expect(functionBody.star, isNotNull); |
| 7710 expect(functionBody.block, isNotNull); | 7420 expect(functionBody.block, isNotNull); |
| 7711 expect(functionBody.isAsynchronous, isTrue); | 7421 expect(functionBody.isAsynchronous, isTrue); |
| 7712 expect(functionBody.isGenerator, isTrue); | 7422 expect(functionBody.isGenerator, isTrue); |
| 7713 expect(functionBody.isSynchronous, isFalse); | 7423 expect(functionBody.isSynchronous, isFalse); |
| 7714 } | 7424 } |
| 7715 | 7425 |
| 7716 void test_parseFunctionBody_block_syncGenerator() { | 7426 void test_parseFunctionBody_block_syncGenerator() { |
| 7717 BlockFunctionBody functionBody = ParserTestCase.parse( | 7427 BlockFunctionBody functionBody = |
| 7718 "parseFunctionBody", <Object>[false, null, false], "sync* {}"); | 7428 parse("parseFunctionBody", <Object>[false, null, false], "sync* {}"); |
| 7719 expect(functionBody.keyword, isNotNull); | 7429 expect(functionBody.keyword, isNotNull); |
| 7720 expect(functionBody.keyword.lexeme, Parser.SYNC); | 7430 expect(functionBody.keyword.lexeme, Parser.SYNC); |
| 7721 expect(functionBody.star, isNotNull); | 7431 expect(functionBody.star, isNotNull); |
| 7722 expect(functionBody.block, isNotNull); | 7432 expect(functionBody.block, isNotNull); |
| 7723 expect(functionBody.isAsynchronous, isFalse); | 7433 expect(functionBody.isAsynchronous, isFalse); |
| 7724 expect(functionBody.isGenerator, isTrue); | 7434 expect(functionBody.isGenerator, isTrue); |
| 7725 expect(functionBody.isSynchronous, isTrue); | 7435 expect(functionBody.isSynchronous, isTrue); |
| 7726 } | 7436 } |
| 7727 | 7437 |
| 7728 void test_parseFunctionBody_empty() { | 7438 void test_parseFunctionBody_empty() { |
| 7729 EmptyFunctionBody functionBody = ParserTestCase.parse( | 7439 EmptyFunctionBody functionBody = |
| 7730 "parseFunctionBody", <Object>[true, null, false], ";"); | 7440 parse("parseFunctionBody", <Object>[true, null, false], ";"); |
| 7731 expect(functionBody.semicolon, isNotNull); | 7441 expect(functionBody.semicolon, isNotNull); |
| 7732 } | 7442 } |
| 7733 | 7443 |
| 7734 void test_parseFunctionBody_expression() { | 7444 void test_parseFunctionBody_expression() { |
| 7735 ExpressionFunctionBody functionBody = ParserTestCase.parse( | 7445 ExpressionFunctionBody functionBody = |
| 7736 "parseFunctionBody", <Object>[false, null, false], "=> y;"); | 7446 parse("parseFunctionBody", <Object>[false, null, false], "=> y;"); |
| 7737 expect(functionBody.keyword, isNull); | 7447 expect(functionBody.keyword, isNull); |
| 7738 expect(functionBody.functionDefinition, isNotNull); | 7448 expect(functionBody.functionDefinition, isNotNull); |
| 7739 expect(functionBody.expression, isNotNull); | 7449 expect(functionBody.expression, isNotNull); |
| 7740 expect(functionBody.semicolon, isNotNull); | 7450 expect(functionBody.semicolon, isNotNull); |
| 7741 expect(functionBody.isAsynchronous, isFalse); | 7451 expect(functionBody.isAsynchronous, isFalse); |
| 7742 expect(functionBody.isGenerator, isFalse); | 7452 expect(functionBody.isGenerator, isFalse); |
| 7743 expect(functionBody.isSynchronous, isTrue); | 7453 expect(functionBody.isSynchronous, isTrue); |
| 7744 } | 7454 } |
| 7745 | 7455 |
| 7746 void test_parseFunctionBody_expression_async() { | 7456 void test_parseFunctionBody_expression_async() { |
| 7747 ExpressionFunctionBody functionBody = ParserTestCase.parse( | 7457 ExpressionFunctionBody functionBody = |
| 7748 "parseFunctionBody", <Object>[false, null, false], "async => y;"); | 7458 parse("parseFunctionBody", <Object>[false, null, false], "async => y;"); |
| 7749 expect(functionBody.keyword, isNotNull); | 7459 expect(functionBody.keyword, isNotNull); |
| 7750 expect(functionBody.keyword.lexeme, Parser.ASYNC); | 7460 expect(functionBody.keyword.lexeme, Parser.ASYNC); |
| 7751 expect(functionBody.functionDefinition, isNotNull); | 7461 expect(functionBody.functionDefinition, isNotNull); |
| 7752 expect(functionBody.expression, isNotNull); | 7462 expect(functionBody.expression, isNotNull); |
| 7753 expect(functionBody.semicolon, isNotNull); | 7463 expect(functionBody.semicolon, isNotNull); |
| 7754 expect(functionBody.isAsynchronous, isTrue); | 7464 expect(functionBody.isAsynchronous, isTrue); |
| 7755 expect(functionBody.isGenerator, isFalse); | 7465 expect(functionBody.isGenerator, isFalse); |
| 7756 expect(functionBody.isSynchronous, isFalse); | 7466 expect(functionBody.isSynchronous, isFalse); |
| 7757 } | 7467 } |
| 7758 | 7468 |
| 7759 void test_parseFunctionBody_nativeFunctionBody() { | 7469 void test_parseFunctionBody_nativeFunctionBody() { |
| 7760 NativeFunctionBody functionBody = ParserTestCase.parse( | 7470 NativeFunctionBody functionBody = parse( |
| 7761 "parseFunctionBody", <Object>[false, null, false], "native 'str';"); | 7471 "parseFunctionBody", <Object>[false, null, false], "native 'str';"); |
| 7762 expect(functionBody.nativeKeyword, isNotNull); | 7472 expect(functionBody.nativeKeyword, isNotNull); |
| 7763 expect(functionBody.stringLiteral, isNotNull); | 7473 expect(functionBody.stringLiteral, isNotNull); |
| 7764 expect(functionBody.semicolon, isNotNull); | 7474 expect(functionBody.semicolon, isNotNull); |
| 7765 } | 7475 } |
| 7766 | 7476 |
| 7767 void test_parseFunctionBody_skip_block() { | 7477 void test_parseFunctionBody_skip_block() { |
| 7768 ParserTestCase.parseFunctionBodies = false; | 7478 ParserTestCase.parseFunctionBodies = false; |
| 7769 FunctionBody functionBody = ParserTestCase.parse( | 7479 FunctionBody functionBody = |
| 7770 "parseFunctionBody", <Object>[false, null, false], "{}"); | 7480 parse("parseFunctionBody", <Object>[false, null, false], "{}"); |
| 7771 EngineTestCase.assertInstanceOf( | 7481 EngineTestCase.assertInstanceOf( |
| 7772 (obj) => obj is EmptyFunctionBody, EmptyFunctionBody, functionBody); | 7482 (obj) => obj is EmptyFunctionBody, EmptyFunctionBody, functionBody); |
| 7773 } | 7483 } |
| 7774 | 7484 |
| 7775 void test_parseFunctionBody_skip_block_invalid() { | 7485 void test_parseFunctionBody_skip_block_invalid() { |
| 7776 ParserTestCase.parseFunctionBodies = false; | 7486 ParserTestCase.parseFunctionBodies = false; |
| 7777 FunctionBody functionBody = ParserTestCase.parse3("parseFunctionBody", | 7487 FunctionBody functionBody = parse3("parseFunctionBody", <Object>[ |
| 7778 <Object>[false, null, false], "{", [ParserErrorCode.EXPECTED_TOKEN]); | 7488 false, |
| 7489 null, |
| 7490 false |
| 7491 ], "{", [ParserErrorCode.EXPECTED_TOKEN]); |
| 7779 EngineTestCase.assertInstanceOf( | 7492 EngineTestCase.assertInstanceOf( |
| 7780 (obj) => obj is EmptyFunctionBody, EmptyFunctionBody, functionBody); | 7493 (obj) => obj is EmptyFunctionBody, EmptyFunctionBody, functionBody); |
| 7781 } | 7494 } |
| 7782 | 7495 |
| 7783 void test_parseFunctionBody_skip_blocks() { | 7496 void test_parseFunctionBody_skip_blocks() { |
| 7784 ParserTestCase.parseFunctionBodies = false; | 7497 ParserTestCase.parseFunctionBodies = false; |
| 7785 FunctionBody functionBody = ParserTestCase.parse( | 7498 FunctionBody functionBody = |
| 7786 "parseFunctionBody", <Object>[false, null, false], "{ {} }"); | 7499 parse("parseFunctionBody", <Object>[false, null, false], "{ {} }"); |
| 7787 EngineTestCase.assertInstanceOf( | 7500 EngineTestCase.assertInstanceOf( |
| 7788 (obj) => obj is EmptyFunctionBody, EmptyFunctionBody, functionBody); | 7501 (obj) => obj is EmptyFunctionBody, EmptyFunctionBody, functionBody); |
| 7789 } | 7502 } |
| 7790 | 7503 |
| 7791 void test_parseFunctionBody_skip_expression() { | 7504 void test_parseFunctionBody_skip_expression() { |
| 7792 ParserTestCase.parseFunctionBodies = false; | 7505 ParserTestCase.parseFunctionBodies = false; |
| 7793 FunctionBody functionBody = ParserTestCase.parse( | 7506 FunctionBody functionBody = |
| 7794 "parseFunctionBody", <Object>[false, null, false], "=> y;"); | 7507 parse("parseFunctionBody", <Object>[false, null, false], "=> y;"); |
| 7795 EngineTestCase.assertInstanceOf( | 7508 EngineTestCase.assertInstanceOf( |
| 7796 (obj) => obj is EmptyFunctionBody, EmptyFunctionBody, functionBody); | 7509 (obj) => obj is EmptyFunctionBody, EmptyFunctionBody, functionBody); |
| 7797 } | 7510 } |
| 7798 | 7511 |
| 7799 void test_parseFunctionDeclaration_function() { | 7512 void test_parseFunctionDeclaration_function() { |
| 7800 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); | 7513 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); |
| 7801 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); | 7514 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); |
| 7802 FunctionDeclaration declaration = ParserTestCase.parse( | 7515 FunctionDeclaration declaration = parse("parseFunctionDeclaration", |
| 7803 "parseFunctionDeclaration", <Object>[ | 7516 <Object>[commentAndMetadata(comment), null, returnType], "f() {}"); |
| 7804 commentAndMetadata(comment), | |
| 7805 null, | |
| 7806 returnType | |
| 7807 ], "f() {}"); | |
| 7808 expect(declaration.documentationComment, comment); | 7517 expect(declaration.documentationComment, comment); |
| 7809 expect(declaration.returnType, returnType); | 7518 expect(declaration.returnType, returnType); |
| 7810 expect(declaration.name, isNotNull); | 7519 expect(declaration.name, isNotNull); |
| 7811 FunctionExpression expression = declaration.functionExpression; | 7520 FunctionExpression expression = declaration.functionExpression; |
| 7812 expect(expression, isNotNull); | 7521 expect(expression, isNotNull); |
| 7813 expect(expression.body, isNotNull); | 7522 expect(expression.body, isNotNull); |
| 7814 expect(expression.parameters, isNotNull); | 7523 expect(expression.parameters, isNotNull); |
| 7815 expect(declaration.propertyKeyword, isNull); | 7524 expect(declaration.propertyKeyword, isNull); |
| 7816 } | 7525 } |
| 7817 | 7526 |
| 7818 void test_parseFunctionDeclaration_getter() { | 7527 void test_parseFunctionDeclaration_getter() { |
| 7819 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); | 7528 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); |
| 7820 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); | 7529 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); |
| 7821 FunctionDeclaration declaration = ParserTestCase.parse( | 7530 FunctionDeclaration declaration = parse("parseFunctionDeclaration", |
| 7822 "parseFunctionDeclaration", <Object>[ | 7531 <Object>[commentAndMetadata(comment), null, returnType], "get p => 0;"); |
| 7823 commentAndMetadata(comment), | |
| 7824 null, | |
| 7825 returnType | |
| 7826 ], "get p => 0;"); | |
| 7827 expect(declaration.documentationComment, comment); | 7532 expect(declaration.documentationComment, comment); |
| 7828 expect(declaration.returnType, returnType); | 7533 expect(declaration.returnType, returnType); |
| 7829 expect(declaration.name, isNotNull); | 7534 expect(declaration.name, isNotNull); |
| 7830 FunctionExpression expression = declaration.functionExpression; | 7535 FunctionExpression expression = declaration.functionExpression; |
| 7831 expect(expression, isNotNull); | 7536 expect(expression, isNotNull); |
| 7832 expect(expression.body, isNotNull); | 7537 expect(expression.body, isNotNull); |
| 7833 expect(expression.parameters, isNull); | 7538 expect(expression.parameters, isNull); |
| 7834 expect(declaration.propertyKeyword, isNotNull); | 7539 expect(declaration.propertyKeyword, isNotNull); |
| 7835 } | 7540 } |
| 7836 | 7541 |
| 7837 void test_parseFunctionDeclaration_setter() { | 7542 void test_parseFunctionDeclaration_setter() { |
| 7838 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); | 7543 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); |
| 7839 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); | 7544 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); |
| 7840 FunctionDeclaration declaration = ParserTestCase.parse( | 7545 FunctionDeclaration declaration = parse("parseFunctionDeclaration", |
| 7841 "parseFunctionDeclaration", <Object>[ | 7546 <Object>[commentAndMetadata(comment), null, returnType], "set p(v) {}"); |
| 7842 commentAndMetadata(comment), | |
| 7843 null, | |
| 7844 returnType | |
| 7845 ], "set p(v) {}"); | |
| 7846 expect(declaration.documentationComment, comment); | 7547 expect(declaration.documentationComment, comment); |
| 7847 expect(declaration.returnType, returnType); | 7548 expect(declaration.returnType, returnType); |
| 7848 expect(declaration.name, isNotNull); | 7549 expect(declaration.name, isNotNull); |
| 7849 FunctionExpression expression = declaration.functionExpression; | 7550 FunctionExpression expression = declaration.functionExpression; |
| 7850 expect(expression, isNotNull); | 7551 expect(expression, isNotNull); |
| 7851 expect(expression.body, isNotNull); | 7552 expect(expression.body, isNotNull); |
| 7852 expect(expression.parameters, isNotNull); | 7553 expect(expression.parameters, isNotNull); |
| 7853 expect(declaration.propertyKeyword, isNotNull); | 7554 expect(declaration.propertyKeyword, isNotNull); |
| 7854 } | 7555 } |
| 7855 | 7556 |
| 7856 void test_parseFunctionDeclarationStatement() { | 7557 void test_parseFunctionDeclarationStatement() { |
| 7857 FunctionDeclarationStatement statement = ParserTestCase.parse4( | 7558 FunctionDeclarationStatement statement = |
| 7858 "parseFunctionDeclarationStatement", "void f(int p) => p * 2;"); | 7559 parse4("parseFunctionDeclarationStatement", "void f(int p) => p * 2;"); |
| 7859 expect(statement.functionDeclaration, isNotNull); | 7560 expect(statement.functionDeclaration, isNotNull); |
| 7860 } | 7561 } |
| 7861 | 7562 |
| 7862 void test_parseFunctionExpression_body_inExpression() { | 7563 void test_parseFunctionExpression_body_inExpression() { |
| 7863 FunctionExpression expression = | 7564 FunctionExpression expression = |
| 7864 ParserTestCase.parse4("parseFunctionExpression", "(int i) => i++"); | 7565 parse4("parseFunctionExpression", "(int i) => i++"); |
| 7865 expect(expression.body, isNotNull); | 7566 expect(expression.body, isNotNull); |
| 7866 expect(expression.parameters, isNotNull); | 7567 expect(expression.parameters, isNotNull); |
| 7867 expect((expression.body as ExpressionFunctionBody).semicolon, isNull); | 7568 expect((expression.body as ExpressionFunctionBody).semicolon, isNull); |
| 7868 } | 7569 } |
| 7869 | 7570 |
| 7870 void test_parseGetter_nonStatic() { | 7571 void test_parseGetter_nonStatic() { |
| 7871 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); | 7572 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); |
| 7872 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); | 7573 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); |
| 7873 MethodDeclaration method = ParserTestCase.parse("parseGetter", <Object>[ | 7574 MethodDeclaration method = parse("parseGetter", <Object>[ |
| 7874 commentAndMetadata(comment), | 7575 commentAndMetadata(comment), |
| 7875 null, | 7576 null, |
| 7876 null, | 7577 null, |
| 7877 returnType | 7578 returnType |
| 7878 ], "get a;"); | 7579 ], "get a;"); |
| 7879 expect(method.body, isNotNull); | 7580 expect(method.body, isNotNull); |
| 7880 expect(method.documentationComment, comment); | 7581 expect(method.documentationComment, comment); |
| 7881 expect(method.externalKeyword, isNull); | 7582 expect(method.externalKeyword, isNull); |
| 7882 expect(method.modifierKeyword, isNull); | 7583 expect(method.modifierKeyword, isNull); |
| 7883 expect(method.name, isNotNull); | 7584 expect(method.name, isNotNull); |
| 7884 expect(method.operatorKeyword, isNull); | 7585 expect(method.operatorKeyword, isNull); |
| 7885 expect(method.parameters, isNull); | 7586 expect(method.parameters, isNull); |
| 7886 expect(method.propertyKeyword, isNotNull); | 7587 expect(method.propertyKeyword, isNotNull); |
| 7887 expect(method.returnType, returnType); | 7588 expect(method.returnType, returnType); |
| 7888 } | 7589 } |
| 7889 | 7590 |
| 7890 void test_parseGetter_static() { | 7591 void test_parseGetter_static() { |
| 7891 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); | 7592 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); |
| 7892 Token staticKeyword = TokenFactory.tokenFromKeyword(Keyword.STATIC); | 7593 Token staticKeyword = TokenFactory.tokenFromKeyword(Keyword.STATIC); |
| 7893 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); | 7594 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); |
| 7894 MethodDeclaration method = ParserTestCase.parse("parseGetter", <Object>[ | 7595 MethodDeclaration method = parse("parseGetter", <Object>[ |
| 7895 commentAndMetadata(comment), | 7596 commentAndMetadata(comment), |
| 7896 null, | 7597 null, |
| 7897 staticKeyword, | 7598 staticKeyword, |
| 7898 returnType | 7599 returnType |
| 7899 ], "get a => 42;"); | 7600 ], "get a => 42;"); |
| 7900 expect(method.body, isNotNull); | 7601 expect(method.body, isNotNull); |
| 7901 expect(method.documentationComment, comment); | 7602 expect(method.documentationComment, comment); |
| 7902 expect(method.externalKeyword, isNull); | 7603 expect(method.externalKeyword, isNull); |
| 7903 expect(method.modifierKeyword, staticKeyword); | 7604 expect(method.modifierKeyword, staticKeyword); |
| 7904 expect(method.name, isNotNull); | 7605 expect(method.name, isNotNull); |
| 7905 expect(method.operatorKeyword, isNull); | 7606 expect(method.operatorKeyword, isNull); |
| 7906 expect(method.parameters, isNull); | 7607 expect(method.parameters, isNull); |
| 7907 expect(method.propertyKeyword, isNotNull); | 7608 expect(method.propertyKeyword, isNotNull); |
| 7908 expect(method.returnType, returnType); | 7609 expect(method.returnType, returnType); |
| 7909 } | 7610 } |
| 7910 | 7611 |
| 7911 void test_parseIdentifierList_multiple() { | 7612 void test_parseIdentifierList_multiple() { |
| 7912 List<SimpleIdentifier> list = | 7613 List<SimpleIdentifier> list = parse4("parseIdentifierList", "a, b, c"); |
| 7913 ParserTestCase.parse4("parseIdentifierList", "a, b, c"); | |
| 7914 expect(list, hasLength(3)); | 7614 expect(list, hasLength(3)); |
| 7915 } | 7615 } |
| 7916 | 7616 |
| 7917 void test_parseIdentifierList_single() { | 7617 void test_parseIdentifierList_single() { |
| 7918 List<SimpleIdentifier> list = | 7618 List<SimpleIdentifier> list = parse4("parseIdentifierList", "a"); |
| 7919 ParserTestCase.parse4("parseIdentifierList", "a"); | |
| 7920 expect(list, hasLength(1)); | 7619 expect(list, hasLength(1)); |
| 7921 } | 7620 } |
| 7922 | 7621 |
| 7923 void test_parseIfStatement_else_block() { | 7622 void test_parseIfStatement_else_block() { |
| 7924 IfStatement statement = | 7623 IfStatement statement = parse4("parseIfStatement", "if (x) {} else {}"); |
| 7925 ParserTestCase.parse4("parseIfStatement", "if (x) {} else {}"); | |
| 7926 expect(statement.ifKeyword, isNotNull); | 7624 expect(statement.ifKeyword, isNotNull); |
| 7927 expect(statement.leftParenthesis, isNotNull); | 7625 expect(statement.leftParenthesis, isNotNull); |
| 7928 expect(statement.condition, isNotNull); | 7626 expect(statement.condition, isNotNull); |
| 7929 expect(statement.rightParenthesis, isNotNull); | 7627 expect(statement.rightParenthesis, isNotNull); |
| 7930 expect(statement.thenStatement, isNotNull); | 7628 expect(statement.thenStatement, isNotNull); |
| 7931 expect(statement.elseKeyword, isNotNull); | 7629 expect(statement.elseKeyword, isNotNull); |
| 7932 expect(statement.elseStatement, isNotNull); | 7630 expect(statement.elseStatement, isNotNull); |
| 7933 } | 7631 } |
| 7934 | 7632 |
| 7935 void test_parseIfStatement_else_statement() { | 7633 void test_parseIfStatement_else_statement() { |
| 7936 IfStatement statement = | 7634 IfStatement statement = |
| 7937 ParserTestCase.parse4("parseIfStatement", "if (x) f(x); else f(y);"); | 7635 parse4("parseIfStatement", "if (x) f(x); else f(y);"); |
| 7938 expect(statement.ifKeyword, isNotNull); | 7636 expect(statement.ifKeyword, isNotNull); |
| 7939 expect(statement.leftParenthesis, isNotNull); | 7637 expect(statement.leftParenthesis, isNotNull); |
| 7940 expect(statement.condition, isNotNull); | 7638 expect(statement.condition, isNotNull); |
| 7941 expect(statement.rightParenthesis, isNotNull); | 7639 expect(statement.rightParenthesis, isNotNull); |
| 7942 expect(statement.thenStatement, isNotNull); | 7640 expect(statement.thenStatement, isNotNull); |
| 7943 expect(statement.elseKeyword, isNotNull); | 7641 expect(statement.elseKeyword, isNotNull); |
| 7944 expect(statement.elseStatement, isNotNull); | 7642 expect(statement.elseStatement, isNotNull); |
| 7945 } | 7643 } |
| 7946 | 7644 |
| 7947 void test_parseIfStatement_noElse_block() { | 7645 void test_parseIfStatement_noElse_block() { |
| 7948 IfStatement statement = | 7646 IfStatement statement = parse4("parseIfStatement", "if (x) {}"); |
| 7949 ParserTestCase.parse4("parseIfStatement", "if (x) {}"); | |
| 7950 expect(statement.ifKeyword, isNotNull); | 7647 expect(statement.ifKeyword, isNotNull); |
| 7951 expect(statement.leftParenthesis, isNotNull); | 7648 expect(statement.leftParenthesis, isNotNull); |
| 7952 expect(statement.condition, isNotNull); | 7649 expect(statement.condition, isNotNull); |
| 7953 expect(statement.rightParenthesis, isNotNull); | 7650 expect(statement.rightParenthesis, isNotNull); |
| 7954 expect(statement.thenStatement, isNotNull); | 7651 expect(statement.thenStatement, isNotNull); |
| 7955 expect(statement.elseKeyword, isNull); | 7652 expect(statement.elseKeyword, isNull); |
| 7956 expect(statement.elseStatement, isNull); | 7653 expect(statement.elseStatement, isNull); |
| 7957 } | 7654 } |
| 7958 | 7655 |
| 7959 void test_parseIfStatement_noElse_statement() { | 7656 void test_parseIfStatement_noElse_statement() { |
| 7960 IfStatement statement = | 7657 IfStatement statement = parse4("parseIfStatement", "if (x) f(x);"); |
| 7961 ParserTestCase.parse4("parseIfStatement", "if (x) f(x);"); | |
| 7962 expect(statement.ifKeyword, isNotNull); | 7658 expect(statement.ifKeyword, isNotNull); |
| 7963 expect(statement.leftParenthesis, isNotNull); | 7659 expect(statement.leftParenthesis, isNotNull); |
| 7964 expect(statement.condition, isNotNull); | 7660 expect(statement.condition, isNotNull); |
| 7965 expect(statement.rightParenthesis, isNotNull); | 7661 expect(statement.rightParenthesis, isNotNull); |
| 7966 expect(statement.thenStatement, isNotNull); | 7662 expect(statement.thenStatement, isNotNull); |
| 7967 expect(statement.elseKeyword, isNull); | 7663 expect(statement.elseKeyword, isNull); |
| 7968 expect(statement.elseStatement, isNull); | 7664 expect(statement.elseStatement, isNull); |
| 7969 } | 7665 } |
| 7970 | 7666 |
| 7971 void test_parseImplementsClause_multiple() { | 7667 void test_parseImplementsClause_multiple() { |
| 7972 ImplementsClause clause = | 7668 ImplementsClause clause = |
| 7973 ParserTestCase.parse4("parseImplementsClause", "implements A, B, C"); | 7669 parse4("parseImplementsClause", "implements A, B, C"); |
| 7974 expect(clause.interfaces, hasLength(3)); | 7670 expect(clause.interfaces, hasLength(3)); |
| 7975 expect(clause.implementsKeyword, isNotNull); | 7671 expect(clause.implementsKeyword, isNotNull); |
| 7976 } | 7672 } |
| 7977 | 7673 |
| 7978 void test_parseImplementsClause_single() { | 7674 void test_parseImplementsClause_single() { |
| 7979 ImplementsClause clause = | 7675 ImplementsClause clause = parse4("parseImplementsClause", "implements A"); |
| 7980 ParserTestCase.parse4("parseImplementsClause", "implements A"); | |
| 7981 expect(clause.interfaces, hasLength(1)); | 7676 expect(clause.interfaces, hasLength(1)); |
| 7982 expect(clause.implementsKeyword, isNotNull); | 7677 expect(clause.implementsKeyword, isNotNull); |
| 7983 } | 7678 } |
| 7984 | 7679 |
| 7985 void test_parseImportDirective_deferred() { | 7680 void test_parseImportDirective_deferred() { |
| 7986 ImportDirective directive = ParserTestCase.parse("parseImportDirective", | 7681 ImportDirective directive = parse("parseImportDirective", |
| 7987 <Object>[ | 7682 <Object>[emptyCommentAndMetadata()], |
| 7988 emptyCommentAndMetadata() | 7683 "import 'lib/lib.dart' deferred as a;"); |
| 7989 ], "import 'lib/lib.dart' deferred as a;"); | |
| 7990 expect(directive.keyword, isNotNull); | 7684 expect(directive.keyword, isNotNull); |
| 7991 expect(directive.uri, isNotNull); | 7685 expect(directive.uri, isNotNull); |
| 7992 expect(directive.deferredKeyword, isNotNull); | 7686 expect(directive.deferredKeyword, isNotNull); |
| 7993 expect(directive.asKeyword, isNotNull); | 7687 expect(directive.asKeyword, isNotNull); |
| 7994 expect(directive.prefix, isNotNull); | 7688 expect(directive.prefix, isNotNull); |
| 7995 expect(directive.combinators, hasLength(0)); | 7689 expect(directive.combinators, hasLength(0)); |
| 7996 expect(directive.semicolon, isNotNull); | 7690 expect(directive.semicolon, isNotNull); |
| 7997 } | 7691 } |
| 7998 | 7692 |
| 7999 void test_parseImportDirective_hide() { | 7693 void test_parseImportDirective_hide() { |
| 8000 ImportDirective directive = ParserTestCase.parse("parseImportDirective", | 7694 ImportDirective directive = parse("parseImportDirective", |
| 8001 <Object>[ | 7695 <Object>[emptyCommentAndMetadata()], |
| 8002 emptyCommentAndMetadata() | 7696 "import 'lib/lib.dart' hide A, B;"); |
| 8003 ], "import 'lib/lib.dart' hide A, B;"); | |
| 8004 expect(directive.keyword, isNotNull); | 7697 expect(directive.keyword, isNotNull); |
| 8005 expect(directive.uri, isNotNull); | 7698 expect(directive.uri, isNotNull); |
| 8006 expect(directive.deferredKeyword, isNull); | 7699 expect(directive.deferredKeyword, isNull); |
| 8007 expect(directive.asKeyword, isNull); | 7700 expect(directive.asKeyword, isNull); |
| 8008 expect(directive.prefix, isNull); | 7701 expect(directive.prefix, isNull); |
| 8009 expect(directive.combinators, hasLength(1)); | 7702 expect(directive.combinators, hasLength(1)); |
| 8010 expect(directive.semicolon, isNotNull); | 7703 expect(directive.semicolon, isNotNull); |
| 8011 } | 7704 } |
| 8012 | 7705 |
| 8013 void test_parseImportDirective_noCombinator() { | 7706 void test_parseImportDirective_noCombinator() { |
| 8014 ImportDirective directive = ParserTestCase.parse("parseImportDirective", | 7707 ImportDirective directive = parse("parseImportDirective", |
| 8015 <Object>[emptyCommentAndMetadata()], "import 'lib/lib.dart';"); | 7708 <Object>[emptyCommentAndMetadata()], "import 'lib/lib.dart';"); |
| 8016 expect(directive.keyword, isNotNull); | 7709 expect(directive.keyword, isNotNull); |
| 8017 expect(directive.uri, isNotNull); | 7710 expect(directive.uri, isNotNull); |
| 8018 expect(directive.deferredKeyword, isNull); | 7711 expect(directive.deferredKeyword, isNull); |
| 8019 expect(directive.asKeyword, isNull); | 7712 expect(directive.asKeyword, isNull); |
| 8020 expect(directive.prefix, isNull); | 7713 expect(directive.prefix, isNull); |
| 8021 expect(directive.combinators, hasLength(0)); | 7714 expect(directive.combinators, hasLength(0)); |
| 8022 expect(directive.semicolon, isNotNull); | 7715 expect(directive.semicolon, isNotNull); |
| 8023 } | 7716 } |
| 8024 | 7717 |
| 8025 void test_parseImportDirective_prefix() { | 7718 void test_parseImportDirective_prefix() { |
| 8026 ImportDirective directive = ParserTestCase.parse("parseImportDirective", | 7719 ImportDirective directive = parse("parseImportDirective", |
| 8027 <Object>[emptyCommentAndMetadata()], "import 'lib/lib.dart' as a;"); | 7720 <Object>[emptyCommentAndMetadata()], "import 'lib/lib.dart' as a;"); |
| 8028 expect(directive.keyword, isNotNull); | 7721 expect(directive.keyword, isNotNull); |
| 8029 expect(directive.uri, isNotNull); | 7722 expect(directive.uri, isNotNull); |
| 8030 expect(directive.deferredKeyword, isNull); | 7723 expect(directive.deferredKeyword, isNull); |
| 8031 expect(directive.asKeyword, isNotNull); | 7724 expect(directive.asKeyword, isNotNull); |
| 8032 expect(directive.prefix, isNotNull); | 7725 expect(directive.prefix, isNotNull); |
| 8033 expect(directive.combinators, hasLength(0)); | 7726 expect(directive.combinators, hasLength(0)); |
| 8034 expect(directive.semicolon, isNotNull); | 7727 expect(directive.semicolon, isNotNull); |
| 8035 } | 7728 } |
| 8036 | 7729 |
| 8037 void test_parseImportDirective_prefix_hide_show() { | 7730 void test_parseImportDirective_prefix_hide_show() { |
| 8038 ImportDirective directive = ParserTestCase.parse("parseImportDirective", | 7731 ImportDirective directive = parse("parseImportDirective", |
| 8039 <Object>[ | 7732 <Object>[emptyCommentAndMetadata()], |
| 8040 emptyCommentAndMetadata() | 7733 "import 'lib/lib.dart' as a hide A show B;"); |
| 8041 ], "import 'lib/lib.dart' as a hide A show B;"); | |
| 8042 expect(directive.keyword, isNotNull); | 7734 expect(directive.keyword, isNotNull); |
| 8043 expect(directive.uri, isNotNull); | 7735 expect(directive.uri, isNotNull); |
| 8044 expect(directive.deferredKeyword, isNull); | 7736 expect(directive.deferredKeyword, isNull); |
| 8045 expect(directive.asKeyword, isNotNull); | 7737 expect(directive.asKeyword, isNotNull); |
| 8046 expect(directive.prefix, isNotNull); | 7738 expect(directive.prefix, isNotNull); |
| 8047 expect(directive.combinators, hasLength(2)); | 7739 expect(directive.combinators, hasLength(2)); |
| 8048 expect(directive.semicolon, isNotNull); | 7740 expect(directive.semicolon, isNotNull); |
| 8049 } | 7741 } |
| 8050 | 7742 |
| 8051 void test_parseImportDirective_prefix_show_hide() { | 7743 void test_parseImportDirective_prefix_show_hide() { |
| 8052 ImportDirective directive = ParserTestCase.parse("parseImportDirective", | 7744 ImportDirective directive = parse("parseImportDirective", |
| 8053 <Object>[ | 7745 <Object>[emptyCommentAndMetadata()], |
| 8054 emptyCommentAndMetadata() | 7746 "import 'lib/lib.dart' as a show B hide A;"); |
| 8055 ], "import 'lib/lib.dart' as a show B hide A;"); | |
| 8056 expect(directive.keyword, isNotNull); | 7747 expect(directive.keyword, isNotNull); |
| 8057 expect(directive.uri, isNotNull); | 7748 expect(directive.uri, isNotNull); |
| 8058 expect(directive.deferredKeyword, isNull); | 7749 expect(directive.deferredKeyword, isNull); |
| 8059 expect(directive.asKeyword, isNotNull); | 7750 expect(directive.asKeyword, isNotNull); |
| 8060 expect(directive.prefix, isNotNull); | 7751 expect(directive.prefix, isNotNull); |
| 8061 expect(directive.combinators, hasLength(2)); | 7752 expect(directive.combinators, hasLength(2)); |
| 8062 expect(directive.semicolon, isNotNull); | 7753 expect(directive.semicolon, isNotNull); |
| 8063 } | 7754 } |
| 8064 | 7755 |
| 8065 void test_parseImportDirective_show() { | 7756 void test_parseImportDirective_show() { |
| 8066 ImportDirective directive = ParserTestCase.parse("parseImportDirective", | 7757 ImportDirective directive = parse("parseImportDirective", |
| 8067 <Object>[ | 7758 <Object>[emptyCommentAndMetadata()], |
| 8068 emptyCommentAndMetadata() | 7759 "import 'lib/lib.dart' show A, B;"); |
| 8069 ], "import 'lib/lib.dart' show A, B;"); | |
| 8070 expect(directive.keyword, isNotNull); | 7760 expect(directive.keyword, isNotNull); |
| 8071 expect(directive.uri, isNotNull); | 7761 expect(directive.uri, isNotNull); |
| 8072 expect(directive.deferredKeyword, isNull); | 7762 expect(directive.deferredKeyword, isNull); |
| 8073 expect(directive.asKeyword, isNull); | 7763 expect(directive.asKeyword, isNull); |
| 8074 expect(directive.prefix, isNull); | 7764 expect(directive.prefix, isNull); |
| 8075 expect(directive.combinators, hasLength(1)); | 7765 expect(directive.combinators, hasLength(1)); |
| 8076 expect(directive.semicolon, isNotNull); | 7766 expect(directive.semicolon, isNotNull); |
| 8077 } | 7767 } |
| 8078 | 7768 |
| 8079 void test_parseInitializedIdentifierList_type() { | 7769 void test_parseInitializedIdentifierList_type() { |
| 8080 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); | 7770 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); |
| 8081 Token staticKeyword = TokenFactory.tokenFromKeyword(Keyword.STATIC); | 7771 Token staticKeyword = TokenFactory.tokenFromKeyword(Keyword.STATIC); |
| 8082 TypeName type = new TypeName(new SimpleIdentifier(null), null); | 7772 TypeName type = new TypeName(new SimpleIdentifier(null), null); |
| 8083 FieldDeclaration declaration = ParserTestCase.parse( | 7773 FieldDeclaration declaration = parse("parseInitializedIdentifierList", |
| 8084 "parseInitializedIdentifierList", <Object>[ | 7774 <Object>[ |
| 8085 commentAndMetadata(comment), | 7775 commentAndMetadata(comment), |
| 8086 staticKeyword, | 7776 staticKeyword, |
| 8087 null, | 7777 null, |
| 8088 type | 7778 type |
| 8089 ], "a = 1, b, c = 3;"); | 7779 ], "a = 1, b, c = 3;"); |
| 8090 expect(declaration.documentationComment, comment); | 7780 expect(declaration.documentationComment, comment); |
| 8091 VariableDeclarationList fields = declaration.fields; | 7781 VariableDeclarationList fields = declaration.fields; |
| 8092 expect(fields, isNotNull); | 7782 expect(fields, isNotNull); |
| 8093 expect(fields.keyword, isNull); | 7783 expect(fields.keyword, isNull); |
| 8094 expect(fields.type, type); | 7784 expect(fields.type, type); |
| 8095 expect(fields.variables, hasLength(3)); | 7785 expect(fields.variables, hasLength(3)); |
| 8096 expect(declaration.staticKeyword, staticKeyword); | 7786 expect(declaration.staticKeyword, staticKeyword); |
| 8097 expect(declaration.semicolon, isNotNull); | 7787 expect(declaration.semicolon, isNotNull); |
| 8098 } | 7788 } |
| 8099 | 7789 |
| 8100 void test_parseInitializedIdentifierList_var() { | 7790 void test_parseInitializedIdentifierList_var() { |
| 8101 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); | 7791 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); |
| 8102 Token staticKeyword = TokenFactory.tokenFromKeyword(Keyword.STATIC); | 7792 Token staticKeyword = TokenFactory.tokenFromKeyword(Keyword.STATIC); |
| 8103 Token varKeyword = TokenFactory.tokenFromKeyword(Keyword.VAR); | 7793 Token varKeyword = TokenFactory.tokenFromKeyword(Keyword.VAR); |
| 8104 FieldDeclaration declaration = ParserTestCase.parse( | 7794 FieldDeclaration declaration = parse("parseInitializedIdentifierList", |
| 8105 "parseInitializedIdentifierList", <Object>[ | 7795 <Object>[ |
| 8106 commentAndMetadata(comment), | 7796 commentAndMetadata(comment), |
| 8107 staticKeyword, | 7797 staticKeyword, |
| 8108 varKeyword, | 7798 varKeyword, |
| 8109 null | 7799 null |
| 8110 ], "a = 1, b, c = 3;"); | 7800 ], "a = 1, b, c = 3;"); |
| 8111 expect(declaration.documentationComment, comment); | 7801 expect(declaration.documentationComment, comment); |
| 8112 VariableDeclarationList fields = declaration.fields; | 7802 VariableDeclarationList fields = declaration.fields; |
| 8113 expect(fields, isNotNull); | 7803 expect(fields, isNotNull); |
| 8114 expect(fields.keyword, varKeyword); | 7804 expect(fields.keyword, varKeyword); |
| 8115 expect(fields.type, isNull); | 7805 expect(fields.type, isNull); |
| 8116 expect(fields.variables, hasLength(3)); | 7806 expect(fields.variables, hasLength(3)); |
| 8117 expect(declaration.staticKeyword, staticKeyword); | 7807 expect(declaration.staticKeyword, staticKeyword); |
| 8118 expect(declaration.semicolon, isNotNull); | 7808 expect(declaration.semicolon, isNotNull); |
| 8119 } | 7809 } |
| 8120 | 7810 |
| 8121 void test_parseInstanceCreationExpression_qualifiedType() { | 7811 void test_parseInstanceCreationExpression_qualifiedType() { |
| 8122 Token token = TokenFactory.tokenFromKeyword(Keyword.NEW); | 7812 Token token = TokenFactory.tokenFromKeyword(Keyword.NEW); |
| 8123 InstanceCreationExpression expression = ParserTestCase.parse( | 7813 InstanceCreationExpression expression = |
| 8124 "parseInstanceCreationExpression", <Object>[token], "A.B()"); | 7814 parse("parseInstanceCreationExpression", <Object>[token], "A.B()"); |
| 8125 expect(expression.keyword, token); | 7815 expect(expression.keyword, token); |
| 8126 ConstructorName name = expression.constructorName; | 7816 ConstructorName name = expression.constructorName; |
| 8127 expect(name, isNotNull); | 7817 expect(name, isNotNull); |
| 8128 expect(name.type, isNotNull); | 7818 expect(name.type, isNotNull); |
| 8129 expect(name.period, isNull); | 7819 expect(name.period, isNull); |
| 8130 expect(name.name, isNull); | 7820 expect(name.name, isNull); |
| 8131 expect(expression.argumentList, isNotNull); | 7821 expect(expression.argumentList, isNotNull); |
| 8132 } | 7822 } |
| 8133 | 7823 |
| 8134 void test_parseInstanceCreationExpression_qualifiedType_named() { | 7824 void test_parseInstanceCreationExpression_qualifiedType_named() { |
| 8135 Token token = TokenFactory.tokenFromKeyword(Keyword.NEW); | 7825 Token token = TokenFactory.tokenFromKeyword(Keyword.NEW); |
| 8136 InstanceCreationExpression expression = ParserTestCase.parse( | 7826 InstanceCreationExpression expression = |
| 8137 "parseInstanceCreationExpression", <Object>[token], "A.B.c()"); | 7827 parse("parseInstanceCreationExpression", <Object>[token], "A.B.c()"); |
| 8138 expect(expression.keyword, token); | 7828 expect(expression.keyword, token); |
| 8139 ConstructorName name = expression.constructorName; | 7829 ConstructorName name = expression.constructorName; |
| 8140 expect(name, isNotNull); | 7830 expect(name, isNotNull); |
| 8141 expect(name.type, isNotNull); | 7831 expect(name.type, isNotNull); |
| 8142 expect(name.period, isNotNull); | 7832 expect(name.period, isNotNull); |
| 8143 expect(name.name, isNotNull); | 7833 expect(name.name, isNotNull); |
| 8144 expect(expression.argumentList, isNotNull); | 7834 expect(expression.argumentList, isNotNull); |
| 8145 } | 7835 } |
| 8146 | 7836 |
| 8147 void test_parseInstanceCreationExpression_type() { | 7837 void test_parseInstanceCreationExpression_type() { |
| 8148 Token token = TokenFactory.tokenFromKeyword(Keyword.NEW); | 7838 Token token = TokenFactory.tokenFromKeyword(Keyword.NEW); |
| 8149 InstanceCreationExpression expression = ParserTestCase.parse( | 7839 InstanceCreationExpression expression = |
| 8150 "parseInstanceCreationExpression", <Object>[token], "A()"); | 7840 parse("parseInstanceCreationExpression", <Object>[token], "A()"); |
| 8151 expect(expression.keyword, token); | 7841 expect(expression.keyword, token); |
| 8152 ConstructorName name = expression.constructorName; | 7842 ConstructorName name = expression.constructorName; |
| 8153 expect(name, isNotNull); | 7843 expect(name, isNotNull); |
| 8154 expect(name.type, isNotNull); | 7844 expect(name.type, isNotNull); |
| 8155 expect(name.period, isNull); | 7845 expect(name.period, isNull); |
| 8156 expect(name.name, isNull); | 7846 expect(name.name, isNull); |
| 8157 expect(expression.argumentList, isNotNull); | 7847 expect(expression.argumentList, isNotNull); |
| 8158 } | 7848 } |
| 8159 | 7849 |
| 8160 void test_parseInstanceCreationExpression_type_named() { | 7850 void test_parseInstanceCreationExpression_type_named() { |
| 8161 Token token = TokenFactory.tokenFromKeyword(Keyword.NEW); | 7851 Token token = TokenFactory.tokenFromKeyword(Keyword.NEW); |
| 8162 InstanceCreationExpression expression = ParserTestCase.parse( | 7852 InstanceCreationExpression expression = |
| 8163 "parseInstanceCreationExpression", <Object>[token], "A<B>.c()"); | 7853 parse("parseInstanceCreationExpression", <Object>[token], "A<B>.c()"); |
| 8164 expect(expression.keyword, token); | 7854 expect(expression.keyword, token); |
| 8165 ConstructorName name = expression.constructorName; | 7855 ConstructorName name = expression.constructorName; |
| 8166 expect(name, isNotNull); | 7856 expect(name, isNotNull); |
| 8167 expect(name.type, isNotNull); | 7857 expect(name.type, isNotNull); |
| 8168 expect(name.period, isNotNull); | 7858 expect(name.period, isNotNull); |
| 8169 expect(name.name, isNotNull); | 7859 expect(name.name, isNotNull); |
| 8170 expect(expression.argumentList, isNotNull); | 7860 expect(expression.argumentList, isNotNull); |
| 8171 } | 7861 } |
| 8172 | 7862 |
| 8173 void test_parseLibraryDirective() { | 7863 void test_parseLibraryDirective() { |
| 8174 LibraryDirective directive = ParserTestCase.parse("parseLibraryDirective", | 7864 LibraryDirective directive = parse("parseLibraryDirective", |
| 8175 <Object>[emptyCommentAndMetadata()], "library l;"); | 7865 <Object>[emptyCommentAndMetadata()], "library l;"); |
| 8176 expect(directive.libraryKeyword, isNotNull); | 7866 expect(directive.libraryKeyword, isNotNull); |
| 8177 expect(directive.name, isNotNull); | 7867 expect(directive.name, isNotNull); |
| 8178 expect(directive.semicolon, isNotNull); | 7868 expect(directive.semicolon, isNotNull); |
| 8179 } | 7869 } |
| 8180 | 7870 |
| 8181 void test_parseLibraryIdentifier_multiple() { | 7871 void test_parseLibraryIdentifier_multiple() { |
| 8182 String name = "a.b.c"; | 7872 String name = "a.b.c"; |
| 8183 LibraryIdentifier identifier = | 7873 LibraryIdentifier identifier = parse4("parseLibraryIdentifier", name); |
| 8184 ParserTestCase.parse4("parseLibraryIdentifier", name); | |
| 8185 expect(identifier.name, name); | 7874 expect(identifier.name, name); |
| 8186 } | 7875 } |
| 8187 | 7876 |
| 8188 void test_parseLibraryIdentifier_single() { | 7877 void test_parseLibraryIdentifier_single() { |
| 8189 String name = "a"; | 7878 String name = "a"; |
| 8190 LibraryIdentifier identifier = | 7879 LibraryIdentifier identifier = parse4("parseLibraryIdentifier", name); |
| 8191 ParserTestCase.parse4("parseLibraryIdentifier", name); | |
| 8192 expect(identifier.name, name); | 7880 expect(identifier.name, name); |
| 8193 } | 7881 } |
| 8194 | 7882 |
| 8195 void test_parseListLiteral_empty_oneToken() { | 7883 void test_parseListLiteral_empty_oneToken() { |
| 8196 Token token = TokenFactory.tokenFromKeyword(Keyword.CONST); | 7884 Token token = TokenFactory.tokenFromKeyword(Keyword.CONST); |
| 8197 TypeArgumentList typeArguments = null; | 7885 TypeArgumentList typeArguments = null; |
| 8198 ListLiteral literal = ParserTestCase.parse( | 7886 ListLiteral literal = |
| 8199 "parseListLiteral", <Object>[token, typeArguments], "[]"); | 7887 parse("parseListLiteral", <Object>[token, typeArguments], "[]"); |
| 8200 expect(literal.constKeyword, token); | 7888 expect(literal.constKeyword, token); |
| 8201 expect(literal.typeArguments, typeArguments); | 7889 expect(literal.typeArguments, typeArguments); |
| 8202 expect(literal.leftBracket, isNotNull); | 7890 expect(literal.leftBracket, isNotNull); |
| 8203 expect(literal.elements, hasLength(0)); | 7891 expect(literal.elements, hasLength(0)); |
| 8204 expect(literal.rightBracket, isNotNull); | 7892 expect(literal.rightBracket, isNotNull); |
| 8205 } | 7893 } |
| 8206 | 7894 |
| 8207 void test_parseListLiteral_empty_oneToken_withComment() { | 7895 void test_parseListLiteral_empty_oneToken_withComment() { |
| 8208 Token constToken = null; | 7896 Token constToken = null; |
| 8209 TypeArgumentList typeArguments = null; | 7897 TypeArgumentList typeArguments = null; |
| 8210 ListLiteral literal = ParserTestCase.parse( | 7898 ListLiteral literal = parse( |
| 8211 "parseListLiteral", <Object>[constToken, typeArguments], "/* 0 */ []"); | 7899 "parseListLiteral", <Object>[constToken, typeArguments], "/* 0 */ []"); |
| 8212 expect(literal.constKeyword, constToken); | 7900 expect(literal.constKeyword, constToken); |
| 8213 expect(literal.typeArguments, typeArguments); | 7901 expect(literal.typeArguments, typeArguments); |
| 8214 Token leftBracket = literal.leftBracket; | 7902 Token leftBracket = literal.leftBracket; |
| 8215 expect(leftBracket, isNotNull); | 7903 expect(leftBracket, isNotNull); |
| 8216 expect(leftBracket.precedingComments, isNotNull); | 7904 expect(leftBracket.precedingComments, isNotNull); |
| 8217 expect(literal.elements, hasLength(0)); | 7905 expect(literal.elements, hasLength(0)); |
| 8218 expect(literal.rightBracket, isNotNull); | 7906 expect(literal.rightBracket, isNotNull); |
| 8219 } | 7907 } |
| 8220 | 7908 |
| 8221 void test_parseListLiteral_empty_twoTokens() { | 7909 void test_parseListLiteral_empty_twoTokens() { |
| 8222 Token token = TokenFactory.tokenFromKeyword(Keyword.CONST); | 7910 Token token = TokenFactory.tokenFromKeyword(Keyword.CONST); |
| 8223 TypeArgumentList typeArguments = null; | 7911 TypeArgumentList typeArguments = null; |
| 8224 ListLiteral literal = ParserTestCase.parse( | 7912 ListLiteral literal = |
| 8225 "parseListLiteral", <Object>[token, typeArguments], "[ ]"); | 7913 parse("parseListLiteral", <Object>[token, typeArguments], "[ ]"); |
| 8226 expect(literal.constKeyword, token); | 7914 expect(literal.constKeyword, token); |
| 8227 expect(literal.typeArguments, typeArguments); | 7915 expect(literal.typeArguments, typeArguments); |
| 8228 expect(literal.leftBracket, isNotNull); | 7916 expect(literal.leftBracket, isNotNull); |
| 8229 expect(literal.elements, hasLength(0)); | 7917 expect(literal.elements, hasLength(0)); |
| 8230 expect(literal.rightBracket, isNotNull); | 7918 expect(literal.rightBracket, isNotNull); |
| 8231 } | 7919 } |
| 8232 | 7920 |
| 8233 void test_parseListLiteral_multiple() { | 7921 void test_parseListLiteral_multiple() { |
| 8234 ListLiteral literal = ParserTestCase.parse( | 7922 ListLiteral literal = |
| 8235 "parseListLiteral", <Object>[null, null], "[1, 2, 3]"); | 7923 parse("parseListLiteral", <Object>[null, null], "[1, 2, 3]"); |
| 8236 expect(literal.constKeyword, isNull); | 7924 expect(literal.constKeyword, isNull); |
| 8237 expect(literal.typeArguments, isNull); | 7925 expect(literal.typeArguments, isNull); |
| 8238 expect(literal.leftBracket, isNotNull); | 7926 expect(literal.leftBracket, isNotNull); |
| 8239 expect(literal.elements, hasLength(3)); | 7927 expect(literal.elements, hasLength(3)); |
| 8240 expect(literal.rightBracket, isNotNull); | 7928 expect(literal.rightBracket, isNotNull); |
| 8241 } | 7929 } |
| 8242 | 7930 |
| 8243 void test_parseListLiteral_single() { | 7931 void test_parseListLiteral_single() { |
| 8244 ListLiteral literal = | 7932 ListLiteral literal = |
| 8245 ParserTestCase.parse("parseListLiteral", <Object>[null, null], "[1]"); | 7933 parse("parseListLiteral", <Object>[null, null], "[1]"); |
| 8246 expect(literal.constKeyword, isNull); | 7934 expect(literal.constKeyword, isNull); |
| 8247 expect(literal.typeArguments, isNull); | 7935 expect(literal.typeArguments, isNull); |
| 8248 expect(literal.leftBracket, isNotNull); | 7936 expect(literal.leftBracket, isNotNull); |
| 8249 expect(literal.elements, hasLength(1)); | 7937 expect(literal.elements, hasLength(1)); |
| 8250 expect(literal.rightBracket, isNotNull); | 7938 expect(literal.rightBracket, isNotNull); |
| 8251 } | 7939 } |
| 8252 | 7940 |
| 8253 void test_parseListOrMapLiteral_list_noType() { | 7941 void test_parseListOrMapLiteral_list_noType() { |
| 8254 ListLiteral literal = | 7942 ListLiteral literal = parse("parseListOrMapLiteral", <Object>[null], "[1]"); |
| 8255 ParserTestCase.parse("parseListOrMapLiteral", <Object>[null], "[1]"); | |
| 8256 expect(literal.constKeyword, isNull); | 7943 expect(literal.constKeyword, isNull); |
| 8257 expect(literal.typeArguments, isNull); | 7944 expect(literal.typeArguments, isNull); |
| 8258 expect(literal.leftBracket, isNotNull); | 7945 expect(literal.leftBracket, isNotNull); |
| 8259 expect(literal.elements, hasLength(1)); | 7946 expect(literal.elements, hasLength(1)); |
| 8260 expect(literal.rightBracket, isNotNull); | 7947 expect(literal.rightBracket, isNotNull); |
| 8261 } | 7948 } |
| 8262 | 7949 |
| 8263 void test_parseListOrMapLiteral_list_type() { | 7950 void test_parseListOrMapLiteral_list_type() { |
| 8264 ListLiteral literal = ParserTestCase.parse( | 7951 ListLiteral literal = |
| 8265 "parseListOrMapLiteral", <Object>[null], "<int> [1]"); | 7952 parse("parseListOrMapLiteral", <Object>[null], "<int> [1]"); |
| 8266 expect(literal.constKeyword, isNull); | 7953 expect(literal.constKeyword, isNull); |
| 8267 expect(literal.typeArguments, isNotNull); | 7954 expect(literal.typeArguments, isNotNull); |
| 8268 expect(literal.leftBracket, isNotNull); | 7955 expect(literal.leftBracket, isNotNull); |
| 8269 expect(literal.elements, hasLength(1)); | 7956 expect(literal.elements, hasLength(1)); |
| 8270 expect(literal.rightBracket, isNotNull); | 7957 expect(literal.rightBracket, isNotNull); |
| 8271 } | 7958 } |
| 8272 | 7959 |
| 8273 void test_parseListOrMapLiteral_map_noType() { | 7960 void test_parseListOrMapLiteral_map_noType() { |
| 8274 MapLiteral literal = ParserTestCase.parse( | 7961 MapLiteral literal = |
| 8275 "parseListOrMapLiteral", <Object>[null], "{'1' : 1}"); | 7962 parse("parseListOrMapLiteral", <Object>[null], "{'1' : 1}"); |
| 8276 expect(literal.constKeyword, isNull); | 7963 expect(literal.constKeyword, isNull); |
| 8277 expect(literal.typeArguments, isNull); | 7964 expect(literal.typeArguments, isNull); |
| 8278 expect(literal.leftBracket, isNotNull); | 7965 expect(literal.leftBracket, isNotNull); |
| 8279 expect(literal.entries, hasLength(1)); | 7966 expect(literal.entries, hasLength(1)); |
| 8280 expect(literal.rightBracket, isNotNull); | 7967 expect(literal.rightBracket, isNotNull); |
| 8281 } | 7968 } |
| 8282 | 7969 |
| 8283 void test_parseListOrMapLiteral_map_type() { | 7970 void test_parseListOrMapLiteral_map_type() { |
| 8284 MapLiteral literal = ParserTestCase.parse( | 7971 MapLiteral literal = parse( |
| 8285 "parseListOrMapLiteral", <Object>[null], "<String, int> {'1' : 1}"); | 7972 "parseListOrMapLiteral", <Object>[null], "<String, int> {'1' : 1}"); |
| 8286 expect(literal.constKeyword, isNull); | 7973 expect(literal.constKeyword, isNull); |
| 8287 expect(literal.typeArguments, isNotNull); | 7974 expect(literal.typeArguments, isNotNull); |
| 8288 expect(literal.leftBracket, isNotNull); | 7975 expect(literal.leftBracket, isNotNull); |
| 8289 expect(literal.entries, hasLength(1)); | 7976 expect(literal.entries, hasLength(1)); |
| 8290 expect(literal.rightBracket, isNotNull); | 7977 expect(literal.rightBracket, isNotNull); |
| 8291 } | 7978 } |
| 8292 | 7979 |
| 8293 void test_parseLogicalAndExpression() { | 7980 void test_parseLogicalAndExpression() { |
| 8294 BinaryExpression expression = | 7981 BinaryExpression expression = parse4("parseLogicalAndExpression", "x && y"); |
| 8295 ParserTestCase.parse4("parseLogicalAndExpression", "x && y"); | |
| 8296 expect(expression.leftOperand, isNotNull); | 7982 expect(expression.leftOperand, isNotNull); |
| 8297 expect(expression.operator, isNotNull); | 7983 expect(expression.operator, isNotNull); |
| 8298 expect(expression.operator.type, TokenType.AMPERSAND_AMPERSAND); | 7984 expect(expression.operator.type, TokenType.AMPERSAND_AMPERSAND); |
| 8299 expect(expression.rightOperand, isNotNull); | 7985 expect(expression.rightOperand, isNotNull); |
| 8300 } | 7986 } |
| 8301 | 7987 |
| 8302 void test_parseLogicalOrExpression() { | 7988 void test_parseLogicalOrExpression() { |
| 8303 BinaryExpression expression = | 7989 BinaryExpression expression = parse4("parseLogicalOrExpression", "x || y"); |
| 8304 ParserTestCase.parse4("parseLogicalOrExpression", "x || y"); | |
| 8305 expect(expression.leftOperand, isNotNull); | 7990 expect(expression.leftOperand, isNotNull); |
| 8306 expect(expression.operator, isNotNull); | 7991 expect(expression.operator, isNotNull); |
| 8307 expect(expression.operator.type, TokenType.BAR_BAR); | 7992 expect(expression.operator.type, TokenType.BAR_BAR); |
| 8308 expect(expression.rightOperand, isNotNull); | 7993 expect(expression.rightOperand, isNotNull); |
| 8309 } | 7994 } |
| 8310 | 7995 |
| 8311 void test_parseMapLiteral_empty() { | 7996 void test_parseMapLiteral_empty() { |
| 8312 Token token = TokenFactory.tokenFromKeyword(Keyword.CONST); | 7997 Token token = TokenFactory.tokenFromKeyword(Keyword.CONST); |
| 8313 TypeArgumentList typeArguments = AstFactory.typeArgumentList( | 7998 TypeArgumentList typeArguments = AstFactory.typeArgumentList( |
| 8314 [AstFactory.typeName4("String"), AstFactory.typeName4("int")]); | 7999 [AstFactory.typeName4("String"), AstFactory.typeName4("int")]); |
| 8315 MapLiteral literal = ParserTestCase.parse( | 8000 MapLiteral literal = |
| 8316 "parseMapLiteral", <Object>[token, typeArguments], "{}"); | 8001 parse("parseMapLiteral", <Object>[token, typeArguments], "{}"); |
| 8317 expect(literal.constKeyword, token); | 8002 expect(literal.constKeyword, token); |
| 8318 expect(literal.typeArguments, typeArguments); | 8003 expect(literal.typeArguments, typeArguments); |
| 8319 expect(literal.leftBracket, isNotNull); | 8004 expect(literal.leftBracket, isNotNull); |
| 8320 expect(literal.entries, hasLength(0)); | 8005 expect(literal.entries, hasLength(0)); |
| 8321 expect(literal.rightBracket, isNotNull); | 8006 expect(literal.rightBracket, isNotNull); |
| 8322 } | 8007 } |
| 8323 | 8008 |
| 8324 void test_parseMapLiteral_multiple() { | 8009 void test_parseMapLiteral_multiple() { |
| 8325 MapLiteral literal = ParserTestCase.parse( | 8010 MapLiteral literal = |
| 8326 "parseMapLiteral", <Object>[null, null], "{'a' : b, 'x' : y}"); | 8011 parse("parseMapLiteral", <Object>[null, null], "{'a' : b, 'x' : y}"); |
| 8327 expect(literal.leftBracket, isNotNull); | 8012 expect(literal.leftBracket, isNotNull); |
| 8328 expect(literal.entries, hasLength(2)); | 8013 expect(literal.entries, hasLength(2)); |
| 8329 expect(literal.rightBracket, isNotNull); | 8014 expect(literal.rightBracket, isNotNull); |
| 8330 } | 8015 } |
| 8331 | 8016 |
| 8332 void test_parseMapLiteral_single() { | 8017 void test_parseMapLiteral_single() { |
| 8333 MapLiteral literal = ParserTestCase.parse( | 8018 MapLiteral literal = |
| 8334 "parseMapLiteral", <Object>[null, null], "{'x' : y}"); | 8019 parse("parseMapLiteral", <Object>[null, null], "{'x' : y}"); |
| 8335 expect(literal.leftBracket, isNotNull); | 8020 expect(literal.leftBracket, isNotNull); |
| 8336 expect(literal.entries, hasLength(1)); | 8021 expect(literal.entries, hasLength(1)); |
| 8337 expect(literal.rightBracket, isNotNull); | 8022 expect(literal.rightBracket, isNotNull); |
| 8338 } | 8023 } |
| 8339 | 8024 |
| 8340 void test_parseMapLiteralEntry_complex() { | 8025 void test_parseMapLiteralEntry_complex() { |
| 8341 MapLiteralEntry entry = | 8026 MapLiteralEntry entry = parse4("parseMapLiteralEntry", "2 + 2 : y"); |
| 8342 ParserTestCase.parse4("parseMapLiteralEntry", "2 + 2 : y"); | |
| 8343 expect(entry.key, isNotNull); | 8027 expect(entry.key, isNotNull); |
| 8344 expect(entry.separator, isNotNull); | 8028 expect(entry.separator, isNotNull); |
| 8345 expect(entry.value, isNotNull); | 8029 expect(entry.value, isNotNull); |
| 8346 } | 8030 } |
| 8347 | 8031 |
| 8348 void test_parseMapLiteralEntry_int() { | 8032 void test_parseMapLiteralEntry_int() { |
| 8349 MapLiteralEntry entry = | 8033 MapLiteralEntry entry = parse4("parseMapLiteralEntry", "0 : y"); |
| 8350 ParserTestCase.parse4("parseMapLiteralEntry", "0 : y"); | |
| 8351 expect(entry.key, isNotNull); | 8034 expect(entry.key, isNotNull); |
| 8352 expect(entry.separator, isNotNull); | 8035 expect(entry.separator, isNotNull); |
| 8353 expect(entry.value, isNotNull); | 8036 expect(entry.value, isNotNull); |
| 8354 } | 8037 } |
| 8355 | 8038 |
| 8356 void test_parseMapLiteralEntry_string() { | 8039 void test_parseMapLiteralEntry_string() { |
| 8357 MapLiteralEntry entry = | 8040 MapLiteralEntry entry = parse4("parseMapLiteralEntry", "'x' : y"); |
| 8358 ParserTestCase.parse4("parseMapLiteralEntry", "'x' : y"); | |
| 8359 expect(entry.key, isNotNull); | 8041 expect(entry.key, isNotNull); |
| 8360 expect(entry.separator, isNotNull); | 8042 expect(entry.separator, isNotNull); |
| 8361 expect(entry.value, isNotNull); | 8043 expect(entry.value, isNotNull); |
| 8362 } | 8044 } |
| 8363 | 8045 |
| 8364 void test_parseModifiers_abstract() { | 8046 void test_parseModifiers_abstract() { |
| 8365 Modifiers modifiers = ParserTestCase.parse4("parseModifiers", "abstract A"); | 8047 Modifiers modifiers = parse4("parseModifiers", "abstract A"); |
| 8366 expect(modifiers.abstractKeyword, isNotNull); | 8048 expect(modifiers.abstractKeyword, isNotNull); |
| 8367 } | 8049 } |
| 8368 | 8050 |
| 8369 void test_parseModifiers_const() { | 8051 void test_parseModifiers_const() { |
| 8370 Modifiers modifiers = ParserTestCase.parse4("parseModifiers", "const A"); | 8052 Modifiers modifiers = parse4("parseModifiers", "const A"); |
| 8371 expect(modifiers.constKeyword, isNotNull); | 8053 expect(modifiers.constKeyword, isNotNull); |
| 8372 } | 8054 } |
| 8373 | 8055 |
| 8374 void test_parseModifiers_external() { | 8056 void test_parseModifiers_external() { |
| 8375 Modifiers modifiers = ParserTestCase.parse4("parseModifiers", "external A"); | 8057 Modifiers modifiers = parse4("parseModifiers", "external A"); |
| 8376 expect(modifiers.externalKeyword, isNotNull); | 8058 expect(modifiers.externalKeyword, isNotNull); |
| 8377 } | 8059 } |
| 8378 | 8060 |
| 8379 void test_parseModifiers_factory() { | 8061 void test_parseModifiers_factory() { |
| 8380 Modifiers modifiers = ParserTestCase.parse4("parseModifiers", "factory A"); | 8062 Modifiers modifiers = parse4("parseModifiers", "factory A"); |
| 8381 expect(modifiers.factoryKeyword, isNotNull); | 8063 expect(modifiers.factoryKeyword, isNotNull); |
| 8382 } | 8064 } |
| 8383 | 8065 |
| 8384 void test_parseModifiers_final() { | 8066 void test_parseModifiers_final() { |
| 8385 Modifiers modifiers = ParserTestCase.parse4("parseModifiers", "final A"); | 8067 Modifiers modifiers = parse4("parseModifiers", "final A"); |
| 8386 expect(modifiers.finalKeyword, isNotNull); | 8068 expect(modifiers.finalKeyword, isNotNull); |
| 8387 } | 8069 } |
| 8388 | 8070 |
| 8389 void test_parseModifiers_static() { | 8071 void test_parseModifiers_static() { |
| 8390 Modifiers modifiers = ParserTestCase.parse4("parseModifiers", "static A"); | 8072 Modifiers modifiers = parse4("parseModifiers", "static A"); |
| 8391 expect(modifiers.staticKeyword, isNotNull); | 8073 expect(modifiers.staticKeyword, isNotNull); |
| 8392 } | 8074 } |
| 8393 | 8075 |
| 8394 void test_parseModifiers_var() { | 8076 void test_parseModifiers_var() { |
| 8395 Modifiers modifiers = ParserTestCase.parse4("parseModifiers", "var A"); | 8077 Modifiers modifiers = parse4("parseModifiers", "var A"); |
| 8396 expect(modifiers.varKeyword, isNotNull); | 8078 expect(modifiers.varKeyword, isNotNull); |
| 8397 } | 8079 } |
| 8398 | 8080 |
| 8399 void test_parseMultiplicativeExpression_normal() { | 8081 void test_parseMultiplicativeExpression_normal() { |
| 8400 BinaryExpression expression = | 8082 BinaryExpression expression = |
| 8401 ParserTestCase.parse4("parseMultiplicativeExpression", "x * y"); | 8083 parse4("parseMultiplicativeExpression", "x * y"); |
| 8402 expect(expression.leftOperand, isNotNull); | 8084 expect(expression.leftOperand, isNotNull); |
| 8403 expect(expression.operator, isNotNull); | 8085 expect(expression.operator, isNotNull); |
| 8404 expect(expression.operator.type, TokenType.STAR); | 8086 expect(expression.operator.type, TokenType.STAR); |
| 8405 expect(expression.rightOperand, isNotNull); | 8087 expect(expression.rightOperand, isNotNull); |
| 8406 } | 8088 } |
| 8407 | 8089 |
| 8408 void test_parseMultiplicativeExpression_super() { | 8090 void test_parseMultiplicativeExpression_super() { |
| 8409 BinaryExpression expression = | 8091 BinaryExpression expression = |
| 8410 ParserTestCase.parse4("parseMultiplicativeExpression", "super * y"); | 8092 parse4("parseMultiplicativeExpression", "super * y"); |
| 8411 EngineTestCase.assertInstanceOf((obj) => obj is SuperExpression, | 8093 EngineTestCase.assertInstanceOf((obj) => obj is SuperExpression, |
| 8412 SuperExpression, expression.leftOperand); | 8094 SuperExpression, expression.leftOperand); |
| 8413 expect(expression.operator, isNotNull); | 8095 expect(expression.operator, isNotNull); |
| 8414 expect(expression.operator.type, TokenType.STAR); | 8096 expect(expression.operator.type, TokenType.STAR); |
| 8415 expect(expression.rightOperand, isNotNull); | 8097 expect(expression.rightOperand, isNotNull); |
| 8416 } | 8098 } |
| 8417 | 8099 |
| 8418 void test_parseNewExpression() { | 8100 void test_parseNewExpression() { |
| 8419 InstanceCreationExpression expression = | 8101 InstanceCreationExpression expression = |
| 8420 ParserTestCase.parse4("parseNewExpression", "new A()"); | 8102 parse4("parseNewExpression", "new A()"); |
| 8421 expect(expression.keyword, isNotNull); | 8103 expect(expression.keyword, isNotNull); |
| 8422 ConstructorName name = expression.constructorName; | 8104 ConstructorName name = expression.constructorName; |
| 8423 expect(name, isNotNull); | 8105 expect(name, isNotNull); |
| 8424 expect(name.type, isNotNull); | 8106 expect(name.type, isNotNull); |
| 8425 expect(name.period, isNull); | 8107 expect(name.period, isNull); |
| 8426 expect(name.name, isNull); | 8108 expect(name.name, isNull); |
| 8427 expect(expression.argumentList, isNotNull); | 8109 expect(expression.argumentList, isNotNull); |
| 8428 } | 8110 } |
| 8429 | 8111 |
| 8430 void test_parseNonLabeledStatement_const_list_empty() { | 8112 void test_parseNonLabeledStatement_const_list_empty() { |
| 8431 ExpressionStatement statement = | 8113 ExpressionStatement statement = |
| 8432 ParserTestCase.parse4("parseNonLabeledStatement", "const [];"); | 8114 parse4("parseNonLabeledStatement", "const [];"); |
| 8433 expect(statement.expression, isNotNull); | 8115 expect(statement.expression, isNotNull); |
| 8434 } | 8116 } |
| 8435 | 8117 |
| 8436 void test_parseNonLabeledStatement_const_list_nonEmpty() { | 8118 void test_parseNonLabeledStatement_const_list_nonEmpty() { |
| 8437 ExpressionStatement statement = | 8119 ExpressionStatement statement = |
| 8438 ParserTestCase.parse4("parseNonLabeledStatement", "const [1, 2];"); | 8120 parse4("parseNonLabeledStatement", "const [1, 2];"); |
| 8439 expect(statement.expression, isNotNull); | 8121 expect(statement.expression, isNotNull); |
| 8440 } | 8122 } |
| 8441 | 8123 |
| 8442 void test_parseNonLabeledStatement_const_map_empty() { | 8124 void test_parseNonLabeledStatement_const_map_empty() { |
| 8443 ExpressionStatement statement = | 8125 ExpressionStatement statement = |
| 8444 ParserTestCase.parse4("parseNonLabeledStatement", "const {};"); | 8126 parse4("parseNonLabeledStatement", "const {};"); |
| 8445 expect(statement.expression, isNotNull); | 8127 expect(statement.expression, isNotNull); |
| 8446 } | 8128 } |
| 8447 | 8129 |
| 8448 void test_parseNonLabeledStatement_const_map_nonEmpty() { | 8130 void test_parseNonLabeledStatement_const_map_nonEmpty() { |
| 8449 // TODO(brianwilkerson) Implement more tests for this method. | 8131 // TODO(brianwilkerson) Implement more tests for this method. |
| 8450 ExpressionStatement statement = | 8132 ExpressionStatement statement = |
| 8451 ParserTestCase.parse4("parseNonLabeledStatement", "const {'a' : 1};"); | 8133 parse4("parseNonLabeledStatement", "const {'a' : 1};"); |
| 8452 expect(statement.expression, isNotNull); | 8134 expect(statement.expression, isNotNull); |
| 8453 } | 8135 } |
| 8454 | 8136 |
| 8455 void test_parseNonLabeledStatement_const_object() { | 8137 void test_parseNonLabeledStatement_const_object() { |
| 8456 ExpressionStatement statement = | 8138 ExpressionStatement statement = |
| 8457 ParserTestCase.parse4("parseNonLabeledStatement", "const A();"); | 8139 parse4("parseNonLabeledStatement", "const A();"); |
| 8458 expect(statement.expression, isNotNull); | 8140 expect(statement.expression, isNotNull); |
| 8459 } | 8141 } |
| 8460 | 8142 |
| 8461 void test_parseNonLabeledStatement_const_object_named_typeParameters() { | 8143 void test_parseNonLabeledStatement_const_object_named_typeParameters() { |
| 8462 ExpressionStatement statement = | 8144 ExpressionStatement statement = |
| 8463 ParserTestCase.parse4("parseNonLabeledStatement", "const A<B>.c();"); | 8145 parse4("parseNonLabeledStatement", "const A<B>.c();"); |
| 8464 expect(statement.expression, isNotNull); | 8146 expect(statement.expression, isNotNull); |
| 8465 } | 8147 } |
| 8466 | 8148 |
| 8467 void test_parseNonLabeledStatement_constructorInvocation() { | 8149 void test_parseNonLabeledStatement_constructorInvocation() { |
| 8468 ExpressionStatement statement = | 8150 ExpressionStatement statement = |
| 8469 ParserTestCase.parse4("parseNonLabeledStatement", "new C().m();"); | 8151 parse4("parseNonLabeledStatement", "new C().m();"); |
| 8470 expect(statement.expression, isNotNull); | 8152 expect(statement.expression, isNotNull); |
| 8471 } | 8153 } |
| 8472 | 8154 |
| 8473 void test_parseNonLabeledStatement_false() { | 8155 void test_parseNonLabeledStatement_false() { |
| 8474 ExpressionStatement statement = | 8156 ExpressionStatement statement = |
| 8475 ParserTestCase.parse4("parseNonLabeledStatement", "false;"); | 8157 parse4("parseNonLabeledStatement", "false;"); |
| 8476 expect(statement.expression, isNotNull); | 8158 expect(statement.expression, isNotNull); |
| 8477 } | 8159 } |
| 8478 | 8160 |
| 8479 void test_parseNonLabeledStatement_functionDeclaration() { | 8161 void test_parseNonLabeledStatement_functionDeclaration() { |
| 8480 ParserTestCase.parse4("parseNonLabeledStatement", "f() {};"); | 8162 parse4("parseNonLabeledStatement", "f() {};"); |
| 8481 } | 8163 } |
| 8482 | 8164 |
| 8483 void test_parseNonLabeledStatement_functionDeclaration_arguments() { | 8165 void test_parseNonLabeledStatement_functionDeclaration_arguments() { |
| 8484 ParserTestCase.parse4("parseNonLabeledStatement", "f(void g()) {};"); | 8166 parse4("parseNonLabeledStatement", "f(void g()) {};"); |
| 8485 } | 8167 } |
| 8486 | 8168 |
| 8487 void test_parseNonLabeledStatement_functionExpressionIndex() { | 8169 void test_parseNonLabeledStatement_functionExpressionIndex() { |
| 8488 ParserTestCase.parse4("parseNonLabeledStatement", "() {}[0] = null;"); | 8170 parse4("parseNonLabeledStatement", "() {}[0] = null;"); |
| 8489 } | 8171 } |
| 8490 | 8172 |
| 8491 void test_parseNonLabeledStatement_functionInvocation() { | 8173 void test_parseNonLabeledStatement_functionInvocation() { |
| 8492 ExpressionStatement statement = | 8174 ExpressionStatement statement = parse4("parseNonLabeledStatement", "f();"); |
| 8493 ParserTestCase.parse4("parseNonLabeledStatement", "f();"); | |
| 8494 expect(statement.expression, isNotNull); | 8175 expect(statement.expression, isNotNull); |
| 8495 } | 8176 } |
| 8496 | 8177 |
| 8497 void test_parseNonLabeledStatement_invokeFunctionExpression() { | 8178 void test_parseNonLabeledStatement_invokeFunctionExpression() { |
| 8498 ExpressionStatement statement = ParserTestCase.parse4( | 8179 ExpressionStatement statement = |
| 8499 "parseNonLabeledStatement", "(a) {return a + a;} (3);"); | 8180 parse4("parseNonLabeledStatement", "(a) {return a + a;} (3);"); |
| 8500 EngineTestCase.assertInstanceOf( | 8181 EngineTestCase.assertInstanceOf( |
| 8501 (obj) => obj is FunctionExpressionInvocation, | 8182 (obj) => obj is FunctionExpressionInvocation, |
| 8502 FunctionExpressionInvocation, statement.expression); | 8183 FunctionExpressionInvocation, statement.expression); |
| 8503 FunctionExpressionInvocation invocation = | 8184 FunctionExpressionInvocation invocation = |
| 8504 statement.expression as FunctionExpressionInvocation; | 8185 statement.expression as FunctionExpressionInvocation; |
| 8505 EngineTestCase.assertInstanceOf((obj) => obj is FunctionExpression, | 8186 EngineTestCase.assertInstanceOf((obj) => obj is FunctionExpression, |
| 8506 FunctionExpression, invocation.function); | 8187 FunctionExpression, invocation.function); |
| 8507 FunctionExpression expression = invocation.function as FunctionExpression; | 8188 FunctionExpression expression = invocation.function as FunctionExpression; |
| 8508 expect(expression.parameters, isNotNull); | 8189 expect(expression.parameters, isNotNull); |
| 8509 expect(expression.body, isNotNull); | 8190 expect(expression.body, isNotNull); |
| 8510 ArgumentList list = invocation.argumentList; | 8191 ArgumentList list = invocation.argumentList; |
| 8511 expect(list, isNotNull); | 8192 expect(list, isNotNull); |
| 8512 expect(list.arguments, hasLength(1)); | 8193 expect(list.arguments, hasLength(1)); |
| 8513 } | 8194 } |
| 8514 | 8195 |
| 8515 void test_parseNonLabeledStatement_null() { | 8196 void test_parseNonLabeledStatement_null() { |
| 8516 ExpressionStatement statement = | 8197 ExpressionStatement statement = parse4("parseNonLabeledStatement", "null;"); |
| 8517 ParserTestCase.parse4("parseNonLabeledStatement", "null;"); | |
| 8518 expect(statement.expression, isNotNull); | 8198 expect(statement.expression, isNotNull); |
| 8519 } | 8199 } |
| 8520 | 8200 |
| 8521 void test_parseNonLabeledStatement_startingWithBuiltInIdentifier() { | 8201 void test_parseNonLabeledStatement_startingWithBuiltInIdentifier() { |
| 8522 ExpressionStatement statement = | 8202 ExpressionStatement statement = |
| 8523 ParserTestCase.parse4("parseNonLabeledStatement", "library.getName();"); | 8203 parse4("parseNonLabeledStatement", "library.getName();"); |
| 8524 expect(statement.expression, isNotNull); | 8204 expect(statement.expression, isNotNull); |
| 8525 } | 8205 } |
| 8526 | 8206 |
| 8527 void test_parseNonLabeledStatement_true() { | 8207 void test_parseNonLabeledStatement_true() { |
| 8528 ExpressionStatement statement = | 8208 ExpressionStatement statement = parse4("parseNonLabeledStatement", "true;"); |
| 8529 ParserTestCase.parse4("parseNonLabeledStatement", "true;"); | |
| 8530 expect(statement.expression, isNotNull); | 8209 expect(statement.expression, isNotNull); |
| 8531 } | 8210 } |
| 8532 | 8211 |
| 8533 void test_parseNonLabeledStatement_typeCast() { | 8212 void test_parseNonLabeledStatement_typeCast() { |
| 8534 ExpressionStatement statement = | 8213 ExpressionStatement statement = |
| 8535 ParserTestCase.parse4("parseNonLabeledStatement", "double.NAN as num;"); | 8214 parse4("parseNonLabeledStatement", "double.NAN as num;"); |
| 8536 expect(statement.expression, isNotNull); | 8215 expect(statement.expression, isNotNull); |
| 8537 } | 8216 } |
| 8538 | 8217 |
| 8539 void test_parseNormalFormalParameter_field_const_noType() { | 8218 void test_parseNormalFormalParameter_field_const_noType() { |
| 8540 FieldFormalParameter parameter = | 8219 FieldFormalParameter parameter = |
| 8541 ParserTestCase.parse4("parseNormalFormalParameter", "const this.a)"); | 8220 parse4("parseNormalFormalParameter", "const this.a)"); |
| 8542 expect(parameter.keyword, isNotNull); | 8221 expect(parameter.keyword, isNotNull); |
| 8543 expect(parameter.type, isNull); | 8222 expect(parameter.type, isNull); |
| 8544 expect(parameter.identifier, isNotNull); | 8223 expect(parameter.identifier, isNotNull); |
| 8545 expect(parameter.parameters, isNull); | 8224 expect(parameter.parameters, isNull); |
| 8546 } | 8225 } |
| 8547 | 8226 |
| 8548 void test_parseNormalFormalParameter_field_const_type() { | 8227 void test_parseNormalFormalParameter_field_const_type() { |
| 8549 FieldFormalParameter parameter = | 8228 FieldFormalParameter parameter = |
| 8550 ParserTestCase.parse4("parseNormalFormalParameter", "const A this.a)"); | 8229 parse4("parseNormalFormalParameter", "const A this.a)"); |
| 8551 expect(parameter.keyword, isNotNull); | 8230 expect(parameter.keyword, isNotNull); |
| 8552 expect(parameter.type, isNotNull); | 8231 expect(parameter.type, isNotNull); |
| 8553 expect(parameter.identifier, isNotNull); | 8232 expect(parameter.identifier, isNotNull); |
| 8554 expect(parameter.parameters, isNull); | 8233 expect(parameter.parameters, isNull); |
| 8555 } | 8234 } |
| 8556 | 8235 |
| 8557 void test_parseNormalFormalParameter_field_final_noType() { | 8236 void test_parseNormalFormalParameter_field_final_noType() { |
| 8558 FieldFormalParameter parameter = | 8237 FieldFormalParameter parameter = |
| 8559 ParserTestCase.parse4("parseNormalFormalParameter", "final this.a)"); | 8238 parse4("parseNormalFormalParameter", "final this.a)"); |
| 8560 expect(parameter.keyword, isNotNull); | 8239 expect(parameter.keyword, isNotNull); |
| 8561 expect(parameter.type, isNull); | 8240 expect(parameter.type, isNull); |
| 8562 expect(parameter.identifier, isNotNull); | 8241 expect(parameter.identifier, isNotNull); |
| 8563 expect(parameter.parameters, isNull); | 8242 expect(parameter.parameters, isNull); |
| 8564 } | 8243 } |
| 8565 | 8244 |
| 8566 void test_parseNormalFormalParameter_field_final_type() { | 8245 void test_parseNormalFormalParameter_field_final_type() { |
| 8567 FieldFormalParameter parameter = | 8246 FieldFormalParameter parameter = |
| 8568 ParserTestCase.parse4("parseNormalFormalParameter", "final A this.a)"); | 8247 parse4("parseNormalFormalParameter", "final A this.a)"); |
| 8569 expect(parameter.keyword, isNotNull); | 8248 expect(parameter.keyword, isNotNull); |
| 8570 expect(parameter.type, isNotNull); | 8249 expect(parameter.type, isNotNull); |
| 8571 expect(parameter.identifier, isNotNull); | 8250 expect(parameter.identifier, isNotNull); |
| 8572 expect(parameter.parameters, isNull); | 8251 expect(parameter.parameters, isNull); |
| 8573 } | 8252 } |
| 8574 | 8253 |
| 8575 void test_parseNormalFormalParameter_field_function_nested() { | 8254 void test_parseNormalFormalParameter_field_function_nested() { |
| 8576 FieldFormalParameter parameter = | 8255 FieldFormalParameter parameter = |
| 8577 ParserTestCase.parse4("parseNormalFormalParameter", "this.a(B b))"); | 8256 parse4("parseNormalFormalParameter", "this.a(B b))"); |
| 8578 expect(parameter.keyword, isNull); | 8257 expect(parameter.keyword, isNull); |
| 8579 expect(parameter.type, isNull); | 8258 expect(parameter.type, isNull); |
| 8580 expect(parameter.identifier, isNotNull); | 8259 expect(parameter.identifier, isNotNull); |
| 8581 FormalParameterList parameterList = parameter.parameters; | 8260 FormalParameterList parameterList = parameter.parameters; |
| 8582 expect(parameterList, isNotNull); | 8261 expect(parameterList, isNotNull); |
| 8583 expect(parameterList.parameters, hasLength(1)); | 8262 expect(parameterList.parameters, hasLength(1)); |
| 8584 } | 8263 } |
| 8585 | 8264 |
| 8586 void test_parseNormalFormalParameter_field_function_noNested() { | 8265 void test_parseNormalFormalParameter_field_function_noNested() { |
| 8587 FieldFormalParameter parameter = | 8266 FieldFormalParameter parameter = |
| 8588 ParserTestCase.parse4("parseNormalFormalParameter", "this.a())"); | 8267 parse4("parseNormalFormalParameter", "this.a())"); |
| 8589 expect(parameter.keyword, isNull); | 8268 expect(parameter.keyword, isNull); |
| 8590 expect(parameter.type, isNull); | 8269 expect(parameter.type, isNull); |
| 8591 expect(parameter.identifier, isNotNull); | 8270 expect(parameter.identifier, isNotNull); |
| 8592 FormalParameterList parameterList = parameter.parameters; | 8271 FormalParameterList parameterList = parameter.parameters; |
| 8593 expect(parameterList, isNotNull); | 8272 expect(parameterList, isNotNull); |
| 8594 expect(parameterList.parameters, hasLength(0)); | 8273 expect(parameterList.parameters, hasLength(0)); |
| 8595 } | 8274 } |
| 8596 | 8275 |
| 8597 void test_parseNormalFormalParameter_field_noType() { | 8276 void test_parseNormalFormalParameter_field_noType() { |
| 8598 FieldFormalParameter parameter = | 8277 FieldFormalParameter parameter = |
| 8599 ParserTestCase.parse4("parseNormalFormalParameter", "this.a)"); | 8278 parse4("parseNormalFormalParameter", "this.a)"); |
| 8600 expect(parameter.keyword, isNull); | 8279 expect(parameter.keyword, isNull); |
| 8601 expect(parameter.type, isNull); | 8280 expect(parameter.type, isNull); |
| 8602 expect(parameter.identifier, isNotNull); | 8281 expect(parameter.identifier, isNotNull); |
| 8603 expect(parameter.parameters, isNull); | 8282 expect(parameter.parameters, isNull); |
| 8604 } | 8283 } |
| 8605 | 8284 |
| 8606 void test_parseNormalFormalParameter_field_type() { | 8285 void test_parseNormalFormalParameter_field_type() { |
| 8607 FieldFormalParameter parameter = | 8286 FieldFormalParameter parameter = |
| 8608 ParserTestCase.parse4("parseNormalFormalParameter", "A this.a)"); | 8287 parse4("parseNormalFormalParameter", "A this.a)"); |
| 8609 expect(parameter.keyword, isNull); | 8288 expect(parameter.keyword, isNull); |
| 8610 expect(parameter.type, isNotNull); | 8289 expect(parameter.type, isNotNull); |
| 8611 expect(parameter.identifier, isNotNull); | 8290 expect(parameter.identifier, isNotNull); |
| 8612 expect(parameter.parameters, isNull); | 8291 expect(parameter.parameters, isNull); |
| 8613 } | 8292 } |
| 8614 | 8293 |
| 8615 void test_parseNormalFormalParameter_field_var() { | 8294 void test_parseNormalFormalParameter_field_var() { |
| 8616 FieldFormalParameter parameter = | 8295 FieldFormalParameter parameter = |
| 8617 ParserTestCase.parse4("parseNormalFormalParameter", "var this.a)"); | 8296 parse4("parseNormalFormalParameter", "var this.a)"); |
| 8618 expect(parameter.keyword, isNotNull); | 8297 expect(parameter.keyword, isNotNull); |
| 8619 expect(parameter.type, isNull); | 8298 expect(parameter.type, isNull); |
| 8620 expect(parameter.identifier, isNotNull); | 8299 expect(parameter.identifier, isNotNull); |
| 8621 expect(parameter.parameters, isNull); | 8300 expect(parameter.parameters, isNull); |
| 8622 } | 8301 } |
| 8623 | 8302 |
| 8624 void test_parseNormalFormalParameter_function_noType() { | 8303 void test_parseNormalFormalParameter_function_noType() { |
| 8625 FunctionTypedFormalParameter parameter = | 8304 FunctionTypedFormalParameter parameter = |
| 8626 ParserTestCase.parse4("parseNormalFormalParameter", "a())"); | 8305 parse4("parseNormalFormalParameter", "a())"); |
| 8627 expect(parameter.returnType, isNull); | 8306 expect(parameter.returnType, isNull); |
| 8628 expect(parameter.identifier, isNotNull); | 8307 expect(parameter.identifier, isNotNull); |
| 8629 expect(parameter.parameters, isNotNull); | 8308 expect(parameter.parameters, isNotNull); |
| 8630 } | 8309 } |
| 8631 | 8310 |
| 8632 void test_parseNormalFormalParameter_function_type() { | 8311 void test_parseNormalFormalParameter_function_type() { |
| 8633 FunctionTypedFormalParameter parameter = | 8312 FunctionTypedFormalParameter parameter = |
| 8634 ParserTestCase.parse4("parseNormalFormalParameter", "A a())"); | 8313 parse4("parseNormalFormalParameter", "A a())"); |
| 8635 expect(parameter.returnType, isNotNull); | 8314 expect(parameter.returnType, isNotNull); |
| 8636 expect(parameter.identifier, isNotNull); | 8315 expect(parameter.identifier, isNotNull); |
| 8637 expect(parameter.parameters, isNotNull); | 8316 expect(parameter.parameters, isNotNull); |
| 8638 } | 8317 } |
| 8639 | 8318 |
| 8640 void test_parseNormalFormalParameter_function_void() { | 8319 void test_parseNormalFormalParameter_function_void() { |
| 8641 FunctionTypedFormalParameter parameter = | 8320 FunctionTypedFormalParameter parameter = |
| 8642 ParserTestCase.parse4("parseNormalFormalParameter", "void a())"); | 8321 parse4("parseNormalFormalParameter", "void a())"); |
| 8643 expect(parameter.returnType, isNotNull); | 8322 expect(parameter.returnType, isNotNull); |
| 8644 expect(parameter.identifier, isNotNull); | 8323 expect(parameter.identifier, isNotNull); |
| 8645 expect(parameter.parameters, isNotNull); | 8324 expect(parameter.parameters, isNotNull); |
| 8646 } | 8325 } |
| 8647 | 8326 |
| 8648 void test_parseNormalFormalParameter_simple_const_noType() { | 8327 void test_parseNormalFormalParameter_simple_const_noType() { |
| 8649 SimpleFormalParameter parameter = | 8328 SimpleFormalParameter parameter = |
| 8650 ParserTestCase.parse4("parseNormalFormalParameter", "const a)"); | 8329 parse4("parseNormalFormalParameter", "const a)"); |
| 8651 expect(parameter.keyword, isNotNull); | 8330 expect(parameter.keyword, isNotNull); |
| 8652 expect(parameter.type, isNull); | 8331 expect(parameter.type, isNull); |
| 8653 expect(parameter.identifier, isNotNull); | 8332 expect(parameter.identifier, isNotNull); |
| 8654 } | 8333 } |
| 8655 | 8334 |
| 8656 void test_parseNormalFormalParameter_simple_const_type() { | 8335 void test_parseNormalFormalParameter_simple_const_type() { |
| 8657 SimpleFormalParameter parameter = | 8336 SimpleFormalParameter parameter = |
| 8658 ParserTestCase.parse4("parseNormalFormalParameter", "const A a)"); | 8337 parse4("parseNormalFormalParameter", "const A a)"); |
| 8659 expect(parameter.keyword, isNotNull); | 8338 expect(parameter.keyword, isNotNull); |
| 8660 expect(parameter.type, isNotNull); | 8339 expect(parameter.type, isNotNull); |
| 8661 expect(parameter.identifier, isNotNull); | 8340 expect(parameter.identifier, isNotNull); |
| 8662 } | 8341 } |
| 8663 | 8342 |
| 8664 void test_parseNormalFormalParameter_simple_final_noType() { | 8343 void test_parseNormalFormalParameter_simple_final_noType() { |
| 8665 SimpleFormalParameter parameter = | 8344 SimpleFormalParameter parameter = |
| 8666 ParserTestCase.parse4("parseNormalFormalParameter", "final a)"); | 8345 parse4("parseNormalFormalParameter", "final a)"); |
| 8667 expect(parameter.keyword, isNotNull); | 8346 expect(parameter.keyword, isNotNull); |
| 8668 expect(parameter.type, isNull); | 8347 expect(parameter.type, isNull); |
| 8669 expect(parameter.identifier, isNotNull); | 8348 expect(parameter.identifier, isNotNull); |
| 8670 } | 8349 } |
| 8671 | 8350 |
| 8672 void test_parseNormalFormalParameter_simple_final_type() { | 8351 void test_parseNormalFormalParameter_simple_final_type() { |
| 8673 SimpleFormalParameter parameter = | 8352 SimpleFormalParameter parameter = |
| 8674 ParserTestCase.parse4("parseNormalFormalParameter", "final A a)"); | 8353 parse4("parseNormalFormalParameter", "final A a)"); |
| 8675 expect(parameter.keyword, isNotNull); | 8354 expect(parameter.keyword, isNotNull); |
| 8676 expect(parameter.type, isNotNull); | 8355 expect(parameter.type, isNotNull); |
| 8677 expect(parameter.identifier, isNotNull); | 8356 expect(parameter.identifier, isNotNull); |
| 8678 } | 8357 } |
| 8679 | 8358 |
| 8680 void test_parseNormalFormalParameter_simple_noType() { | 8359 void test_parseNormalFormalParameter_simple_noType() { |
| 8681 SimpleFormalParameter parameter = | 8360 SimpleFormalParameter parameter = |
| 8682 ParserTestCase.parse4("parseNormalFormalParameter", "a)"); | 8361 parse4("parseNormalFormalParameter", "a)"); |
| 8683 expect(parameter.keyword, isNull); | 8362 expect(parameter.keyword, isNull); |
| 8684 expect(parameter.type, isNull); | 8363 expect(parameter.type, isNull); |
| 8685 expect(parameter.identifier, isNotNull); | 8364 expect(parameter.identifier, isNotNull); |
| 8686 } | 8365 } |
| 8687 | 8366 |
| 8688 void test_parseNormalFormalParameter_simple_type() { | 8367 void test_parseNormalFormalParameter_simple_type() { |
| 8689 SimpleFormalParameter parameter = | 8368 SimpleFormalParameter parameter = |
| 8690 ParserTestCase.parse4("parseNormalFormalParameter", "A a)"); | 8369 parse4("parseNormalFormalParameter", "A a)"); |
| 8691 expect(parameter.keyword, isNull); | 8370 expect(parameter.keyword, isNull); |
| 8692 expect(parameter.type, isNotNull); | 8371 expect(parameter.type, isNotNull); |
| 8693 expect(parameter.identifier, isNotNull); | 8372 expect(parameter.identifier, isNotNull); |
| 8694 } | 8373 } |
| 8695 | 8374 |
| 8696 void test_parseOperator() { | 8375 void test_parseOperator() { |
| 8697 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); | 8376 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); |
| 8698 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); | 8377 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); |
| 8699 MethodDeclaration method = ParserTestCase.parse("parseOperator", <Object>[ | 8378 MethodDeclaration method = parse("parseOperator", <Object>[ |
| 8700 commentAndMetadata(comment), | 8379 commentAndMetadata(comment), |
| 8701 null, | 8380 null, |
| 8702 returnType | 8381 returnType |
| 8703 ], "operator +(A a);"); | 8382 ], "operator +(A a);"); |
| 8704 expect(method.body, isNotNull); | 8383 expect(method.body, isNotNull); |
| 8705 expect(method.documentationComment, comment); | 8384 expect(method.documentationComment, comment); |
| 8706 expect(method.externalKeyword, isNull); | 8385 expect(method.externalKeyword, isNull); |
| 8707 expect(method.modifierKeyword, isNull); | 8386 expect(method.modifierKeyword, isNull); |
| 8708 expect(method.name, isNotNull); | 8387 expect(method.name, isNotNull); |
| 8709 expect(method.operatorKeyword, isNotNull); | 8388 expect(method.operatorKeyword, isNotNull); |
| 8710 expect(method.parameters, isNotNull); | 8389 expect(method.parameters, isNotNull); |
| 8711 expect(method.propertyKeyword, isNull); | 8390 expect(method.propertyKeyword, isNull); |
| 8712 expect(method.returnType, returnType); | 8391 expect(method.returnType, returnType); |
| 8713 } | 8392 } |
| 8714 | 8393 |
| 8715 void test_parseOptionalReturnType() { | 8394 void test_parseOptionalReturnType() { |
| 8716 // TODO(brianwilkerson) Implement tests for this method. | 8395 // TODO(brianwilkerson) Implement tests for this method. |
| 8717 } | 8396 } |
| 8718 | 8397 |
| 8719 void test_parsePartDirective_part() { | 8398 void test_parsePartDirective_part() { |
| 8720 PartDirective directive = ParserTestCase.parse("parsePartDirective", | 8399 PartDirective directive = parse("parsePartDirective", |
| 8721 <Object>[emptyCommentAndMetadata()], "part 'lib/lib.dart';"); | 8400 <Object>[emptyCommentAndMetadata()], "part 'lib/lib.dart';"); |
| 8722 expect(directive.partKeyword, isNotNull); | 8401 expect(directive.partKeyword, isNotNull); |
| 8723 expect(directive.uri, isNotNull); | 8402 expect(directive.uri, isNotNull); |
| 8724 expect(directive.semicolon, isNotNull); | 8403 expect(directive.semicolon, isNotNull); |
| 8725 } | 8404 } |
| 8726 | 8405 |
| 8727 void test_parsePartDirective_partOf() { | 8406 void test_parsePartDirective_partOf() { |
| 8728 PartOfDirective directive = ParserTestCase.parse("parsePartDirective", | 8407 PartOfDirective directive = parse("parsePartDirective", |
| 8729 <Object>[emptyCommentAndMetadata()], "part of l;"); | 8408 <Object>[emptyCommentAndMetadata()], "part of l;"); |
| 8730 expect(directive.partKeyword, isNotNull); | 8409 expect(directive.partKeyword, isNotNull); |
| 8731 expect(directive.ofKeyword, isNotNull); | 8410 expect(directive.ofKeyword, isNotNull); |
| 8732 expect(directive.libraryName, isNotNull); | 8411 expect(directive.libraryName, isNotNull); |
| 8733 expect(directive.semicolon, isNotNull); | 8412 expect(directive.semicolon, isNotNull); |
| 8734 } | 8413 } |
| 8735 | 8414 |
| 8736 void test_parsePostfixExpression_decrement() { | 8415 void test_parsePostfixExpression_decrement() { |
| 8737 PostfixExpression expression = | 8416 PostfixExpression expression = parse4("parsePostfixExpression", "i--"); |
| 8738 ParserTestCase.parse4("parsePostfixExpression", "i--"); | |
| 8739 expect(expression.operand, isNotNull); | 8417 expect(expression.operand, isNotNull); |
| 8740 expect(expression.operator, isNotNull); | 8418 expect(expression.operator, isNotNull); |
| 8741 expect(expression.operator.type, TokenType.MINUS_MINUS); | 8419 expect(expression.operator.type, TokenType.MINUS_MINUS); |
| 8742 } | 8420 } |
| 8743 | 8421 |
| 8744 void test_parsePostfixExpression_increment() { | 8422 void test_parsePostfixExpression_increment() { |
| 8745 PostfixExpression expression = | 8423 PostfixExpression expression = parse4("parsePostfixExpression", "i++"); |
| 8746 ParserTestCase.parse4("parsePostfixExpression", "i++"); | |
| 8747 expect(expression.operand, isNotNull); | 8424 expect(expression.operand, isNotNull); |
| 8748 expect(expression.operator, isNotNull); | 8425 expect(expression.operator, isNotNull); |
| 8749 expect(expression.operator.type, TokenType.PLUS_PLUS); | 8426 expect(expression.operator.type, TokenType.PLUS_PLUS); |
| 8750 } | 8427 } |
| 8751 | 8428 |
| 8752 void test_parsePostfixExpression_none_indexExpression() { | 8429 void test_parsePostfixExpression_none_indexExpression() { |
| 8753 IndexExpression expression = | 8430 IndexExpression expression = parse4("parsePostfixExpression", "a[0]"); |
| 8754 ParserTestCase.parse4("parsePostfixExpression", "a[0]"); | |
| 8755 expect(expression.target, isNotNull); | 8431 expect(expression.target, isNotNull); |
| 8756 expect(expression.index, isNotNull); | 8432 expect(expression.index, isNotNull); |
| 8757 } | 8433 } |
| 8758 | 8434 |
| 8759 void test_parsePostfixExpression_none_methodInvocation() { | 8435 void test_parsePostfixExpression_none_methodInvocation() { |
| 8760 MethodInvocation expression = | 8436 MethodInvocation expression = parse4("parsePostfixExpression", "a.m()"); |
| 8761 ParserTestCase.parse4("parsePostfixExpression", "a.m()"); | |
| 8762 expect(expression.target, isNotNull); | 8437 expect(expression.target, isNotNull); |
| 8763 expect(expression.methodName, isNotNull); | 8438 expect(expression.methodName, isNotNull); |
| 8764 expect(expression.argumentList, isNotNull); | 8439 expect(expression.argumentList, isNotNull); |
| 8765 } | 8440 } |
| 8766 | 8441 |
| 8767 void test_parsePostfixExpression_none_propertyAccess() { | 8442 void test_parsePostfixExpression_none_propertyAccess() { |
| 8768 PrefixedIdentifier expression = | 8443 PrefixedIdentifier expression = parse4("parsePostfixExpression", "a.b"); |
| 8769 ParserTestCase.parse4("parsePostfixExpression", "a.b"); | |
| 8770 expect(expression.prefix, isNotNull); | 8444 expect(expression.prefix, isNotNull); |
| 8771 expect(expression.identifier, isNotNull); | 8445 expect(expression.identifier, isNotNull); |
| 8772 } | 8446 } |
| 8773 | 8447 |
| 8774 void test_parsePrefixedIdentifier_noPrefix() { | 8448 void test_parsePrefixedIdentifier_noPrefix() { |
| 8775 String lexeme = "bar"; | 8449 String lexeme = "bar"; |
| 8776 SimpleIdentifier identifier = | 8450 SimpleIdentifier identifier = parse4("parsePrefixedIdentifier", lexeme); |
| 8777 ParserTestCase.parse4("parsePrefixedIdentifier", lexeme); | |
| 8778 expect(identifier.token, isNotNull); | 8451 expect(identifier.token, isNotNull); |
| 8779 expect(identifier.name, lexeme); | 8452 expect(identifier.name, lexeme); |
| 8780 } | 8453 } |
| 8781 | 8454 |
| 8782 void test_parsePrefixedIdentifier_prefix() { | 8455 void test_parsePrefixedIdentifier_prefix() { |
| 8783 String lexeme = "foo.bar"; | 8456 String lexeme = "foo.bar"; |
| 8784 PrefixedIdentifier identifier = | 8457 PrefixedIdentifier identifier = parse4("parsePrefixedIdentifier", lexeme); |
| 8785 ParserTestCase.parse4("parsePrefixedIdentifier", lexeme); | |
| 8786 expect(identifier.prefix.name, "foo"); | 8458 expect(identifier.prefix.name, "foo"); |
| 8787 expect(identifier.period, isNotNull); | 8459 expect(identifier.period, isNotNull); |
| 8788 expect(identifier.identifier.name, "bar"); | 8460 expect(identifier.identifier.name, "bar"); |
| 8789 } | 8461 } |
| 8790 | 8462 |
| 8791 void test_parsePrimaryExpression_const() { | 8463 void test_parsePrimaryExpression_const() { |
| 8792 InstanceCreationExpression expression = | 8464 InstanceCreationExpression expression = |
| 8793 ParserTestCase.parse4("parsePrimaryExpression", "const A()"); | 8465 parse4("parsePrimaryExpression", "const A()"); |
| 8794 expect(expression, isNotNull); | 8466 expect(expression, isNotNull); |
| 8795 } | 8467 } |
| 8796 | 8468 |
| 8797 void test_parsePrimaryExpression_double() { | 8469 void test_parsePrimaryExpression_double() { |
| 8798 String doubleLiteral = "3.2e4"; | 8470 String doubleLiteral = "3.2e4"; |
| 8799 DoubleLiteral literal = | 8471 DoubleLiteral literal = parse4("parsePrimaryExpression", doubleLiteral); |
| 8800 ParserTestCase.parse4("parsePrimaryExpression", doubleLiteral); | |
| 8801 expect(literal.literal, isNotNull); | 8472 expect(literal.literal, isNotNull); |
| 8802 expect(literal.value, double.parse(doubleLiteral)); | 8473 expect(literal.value, double.parse(doubleLiteral)); |
| 8803 } | 8474 } |
| 8804 | 8475 |
| 8805 void test_parsePrimaryExpression_false() { | 8476 void test_parsePrimaryExpression_false() { |
| 8806 BooleanLiteral literal = | 8477 BooleanLiteral literal = parse4("parsePrimaryExpression", "false"); |
| 8807 ParserTestCase.parse4("parsePrimaryExpression", "false"); | |
| 8808 expect(literal.literal, isNotNull); | 8478 expect(literal.literal, isNotNull); |
| 8809 expect(literal.value, isFalse); | 8479 expect(literal.value, isFalse); |
| 8810 } | 8480 } |
| 8811 | 8481 |
| 8812 void test_parsePrimaryExpression_function_arguments() { | 8482 void test_parsePrimaryExpression_function_arguments() { |
| 8813 FunctionExpression expression = | 8483 FunctionExpression expression = |
| 8814 ParserTestCase.parse4("parsePrimaryExpression", "(int i) => i + 1"); | 8484 parse4("parsePrimaryExpression", "(int i) => i + 1"); |
| 8815 expect(expression.parameters, isNotNull); | 8485 expect(expression.parameters, isNotNull); |
| 8816 expect(expression.body, isNotNull); | 8486 expect(expression.body, isNotNull); |
| 8817 } | 8487 } |
| 8818 | 8488 |
| 8819 void test_parsePrimaryExpression_function_noArguments() { | 8489 void test_parsePrimaryExpression_function_noArguments() { |
| 8820 FunctionExpression expression = | 8490 FunctionExpression expression = |
| 8821 ParserTestCase.parse4("parsePrimaryExpression", "() => 42"); | 8491 parse4("parsePrimaryExpression", "() => 42"); |
| 8822 expect(expression.parameters, isNotNull); | 8492 expect(expression.parameters, isNotNull); |
| 8823 expect(expression.body, isNotNull); | 8493 expect(expression.body, isNotNull); |
| 8824 } | 8494 } |
| 8825 | 8495 |
| 8826 void test_parsePrimaryExpression_hex() { | 8496 void test_parsePrimaryExpression_hex() { |
| 8827 String hexLiteral = "3F"; | 8497 String hexLiteral = "3F"; |
| 8828 IntegerLiteral literal = | 8498 IntegerLiteral literal = parse4("parsePrimaryExpression", "0x$hexLiteral"); |
| 8829 ParserTestCase.parse4("parsePrimaryExpression", "0x$hexLiteral"); | |
| 8830 expect(literal.literal, isNotNull); | 8499 expect(literal.literal, isNotNull); |
| 8831 expect(literal.value, int.parse(hexLiteral, radix: 16)); | 8500 expect(literal.value, int.parse(hexLiteral, radix: 16)); |
| 8832 } | 8501 } |
| 8833 | 8502 |
| 8834 void test_parsePrimaryExpression_identifier() { | 8503 void test_parsePrimaryExpression_identifier() { |
| 8835 SimpleIdentifier identifier = | 8504 SimpleIdentifier identifier = parse4("parsePrimaryExpression", "a"); |
| 8836 ParserTestCase.parse4("parsePrimaryExpression", "a"); | |
| 8837 expect(identifier, isNotNull); | 8505 expect(identifier, isNotNull); |
| 8838 } | 8506 } |
| 8839 | 8507 |
| 8840 void test_parsePrimaryExpression_int() { | 8508 void test_parsePrimaryExpression_int() { |
| 8841 String intLiteral = "472"; | 8509 String intLiteral = "472"; |
| 8842 IntegerLiteral literal = | 8510 IntegerLiteral literal = parse4("parsePrimaryExpression", intLiteral); |
| 8843 ParserTestCase.parse4("parsePrimaryExpression", intLiteral); | |
| 8844 expect(literal.literal, isNotNull); | 8511 expect(literal.literal, isNotNull); |
| 8845 expect(literal.value, int.parse(intLiteral)); | 8512 expect(literal.value, int.parse(intLiteral)); |
| 8846 } | 8513 } |
| 8847 | 8514 |
| 8848 void test_parsePrimaryExpression_listLiteral() { | 8515 void test_parsePrimaryExpression_listLiteral() { |
| 8849 ListLiteral literal = | 8516 ListLiteral literal = parse4("parsePrimaryExpression", "[ ]"); |
| 8850 ParserTestCase.parse4("parsePrimaryExpression", "[ ]"); | |
| 8851 expect(literal, isNotNull); | 8517 expect(literal, isNotNull); |
| 8852 } | 8518 } |
| 8853 | 8519 |
| 8854 void test_parsePrimaryExpression_listLiteral_index() { | 8520 void test_parsePrimaryExpression_listLiteral_index() { |
| 8855 ListLiteral literal = ParserTestCase.parse4("parsePrimaryExpression", "[]"); | 8521 ListLiteral literal = parse4("parsePrimaryExpression", "[]"); |
| 8856 expect(literal, isNotNull); | 8522 expect(literal, isNotNull); |
| 8857 } | 8523 } |
| 8858 | 8524 |
| 8859 void test_parsePrimaryExpression_listLiteral_typed() { | 8525 void test_parsePrimaryExpression_listLiteral_typed() { |
| 8860 ListLiteral literal = | 8526 ListLiteral literal = parse4("parsePrimaryExpression", "<A>[ ]"); |
| 8861 ParserTestCase.parse4("parsePrimaryExpression", "<A>[ ]"); | |
| 8862 expect(literal.typeArguments, isNotNull); | 8527 expect(literal.typeArguments, isNotNull); |
| 8863 expect(literal.typeArguments.arguments, hasLength(1)); | 8528 expect(literal.typeArguments.arguments, hasLength(1)); |
| 8864 } | 8529 } |
| 8865 | 8530 |
| 8866 void test_parsePrimaryExpression_mapLiteral() { | 8531 void test_parsePrimaryExpression_mapLiteral() { |
| 8867 MapLiteral literal = ParserTestCase.parse4("parsePrimaryExpression", "{}"); | 8532 MapLiteral literal = parse4("parsePrimaryExpression", "{}"); |
| 8868 expect(literal, isNotNull); | 8533 expect(literal, isNotNull); |
| 8869 } | 8534 } |
| 8870 | 8535 |
| 8871 void test_parsePrimaryExpression_mapLiteral_typed() { | 8536 void test_parsePrimaryExpression_mapLiteral_typed() { |
| 8872 MapLiteral literal = | 8537 MapLiteral literal = parse4("parsePrimaryExpression", "<A, B>{}"); |
| 8873 ParserTestCase.parse4("parsePrimaryExpression", "<A, B>{}"); | |
| 8874 expect(literal.typeArguments, isNotNull); | 8538 expect(literal.typeArguments, isNotNull); |
| 8875 expect(literal.typeArguments.arguments, hasLength(2)); | 8539 expect(literal.typeArguments.arguments, hasLength(2)); |
| 8876 } | 8540 } |
| 8877 | 8541 |
| 8878 void test_parsePrimaryExpression_new() { | 8542 void test_parsePrimaryExpression_new() { |
| 8879 InstanceCreationExpression expression = | 8543 InstanceCreationExpression expression = |
| 8880 ParserTestCase.parse4("parsePrimaryExpression", "new A()"); | 8544 parse4("parsePrimaryExpression", "new A()"); |
| 8881 expect(expression, isNotNull); | 8545 expect(expression, isNotNull); |
| 8882 } | 8546 } |
| 8883 | 8547 |
| 8884 void test_parsePrimaryExpression_null() { | 8548 void test_parsePrimaryExpression_null() { |
| 8885 NullLiteral literal = | 8549 NullLiteral literal = parse4("parsePrimaryExpression", "null"); |
| 8886 ParserTestCase.parse4("parsePrimaryExpression", "null"); | |
| 8887 expect(literal.literal, isNotNull); | 8550 expect(literal.literal, isNotNull); |
| 8888 } | 8551 } |
| 8889 | 8552 |
| 8890 void test_parsePrimaryExpression_parenthesized() { | 8553 void test_parsePrimaryExpression_parenthesized() { |
| 8891 ParenthesizedExpression expression = | 8554 ParenthesizedExpression expression = |
| 8892 ParserTestCase.parse4("parsePrimaryExpression", "(x)"); | 8555 parse4("parsePrimaryExpression", "(x)"); |
| 8893 expect(expression, isNotNull); | 8556 expect(expression, isNotNull); |
| 8894 } | 8557 } |
| 8895 | 8558 |
| 8896 void test_parsePrimaryExpression_string() { | 8559 void test_parsePrimaryExpression_string() { |
| 8897 SimpleStringLiteral literal = | 8560 SimpleStringLiteral literal = |
| 8898 ParserTestCase.parse4("parsePrimaryExpression", "\"string\""); | 8561 parse4("parsePrimaryExpression", "\"string\""); |
| 8899 expect(literal.isMultiline, isFalse); | 8562 expect(literal.isMultiline, isFalse); |
| 8900 expect(literal.isRaw, isFalse); | 8563 expect(literal.isRaw, isFalse); |
| 8901 expect(literal.value, "string"); | 8564 expect(literal.value, "string"); |
| 8902 } | 8565 } |
| 8903 | 8566 |
| 8904 void test_parsePrimaryExpression_string_multiline() { | 8567 void test_parsePrimaryExpression_string_multiline() { |
| 8905 SimpleStringLiteral literal = | 8568 SimpleStringLiteral literal = |
| 8906 ParserTestCase.parse4("parsePrimaryExpression", "'''string'''"); | 8569 parse4("parsePrimaryExpression", "'''string'''"); |
| 8907 expect(literal.isMultiline, isTrue); | 8570 expect(literal.isMultiline, isTrue); |
| 8908 expect(literal.isRaw, isFalse); | 8571 expect(literal.isRaw, isFalse); |
| 8909 expect(literal.value, "string"); | 8572 expect(literal.value, "string"); |
| 8910 } | 8573 } |
| 8911 | 8574 |
| 8912 void test_parsePrimaryExpression_string_raw() { | 8575 void test_parsePrimaryExpression_string_raw() { |
| 8913 SimpleStringLiteral literal = | 8576 SimpleStringLiteral literal = parse4("parsePrimaryExpression", "r'string'"); |
| 8914 ParserTestCase.parse4("parsePrimaryExpression", "r'string'"); | |
| 8915 expect(literal.isMultiline, isFalse); | 8577 expect(literal.isMultiline, isFalse); |
| 8916 expect(literal.isRaw, isTrue); | 8578 expect(literal.isRaw, isTrue); |
| 8917 expect(literal.value, "string"); | 8579 expect(literal.value, "string"); |
| 8918 } | 8580 } |
| 8919 | 8581 |
| 8920 void test_parsePrimaryExpression_super() { | 8582 void test_parsePrimaryExpression_super() { |
| 8921 PropertyAccess propertyAccess = | 8583 PropertyAccess propertyAccess = parse4("parsePrimaryExpression", "super.x"); |
| 8922 ParserTestCase.parse4("parsePrimaryExpression", "super.x"); | |
| 8923 expect(propertyAccess.target is SuperExpression, isTrue); | 8584 expect(propertyAccess.target is SuperExpression, isTrue); |
| 8924 expect(propertyAccess.operator, isNotNull); | 8585 expect(propertyAccess.operator, isNotNull); |
| 8925 expect(propertyAccess.operator.type, TokenType.PERIOD); | 8586 expect(propertyAccess.operator.type, TokenType.PERIOD); |
| 8926 expect(propertyAccess.propertyName, isNotNull); | 8587 expect(propertyAccess.propertyName, isNotNull); |
| 8927 } | 8588 } |
| 8928 | 8589 |
| 8929 void test_parsePrimaryExpression_this() { | 8590 void test_parsePrimaryExpression_this() { |
| 8930 ThisExpression expression = | 8591 ThisExpression expression = parse4("parsePrimaryExpression", "this"); |
| 8931 ParserTestCase.parse4("parsePrimaryExpression", "this"); | |
| 8932 expect(expression.thisKeyword, isNotNull); | 8592 expect(expression.thisKeyword, isNotNull); |
| 8933 } | 8593 } |
| 8934 | 8594 |
| 8935 void test_parsePrimaryExpression_true() { | 8595 void test_parsePrimaryExpression_true() { |
| 8936 BooleanLiteral literal = | 8596 BooleanLiteral literal = parse4("parsePrimaryExpression", "true"); |
| 8937 ParserTestCase.parse4("parsePrimaryExpression", "true"); | |
| 8938 expect(literal.literal, isNotNull); | 8597 expect(literal.literal, isNotNull); |
| 8939 expect(literal.value, isTrue); | 8598 expect(literal.value, isTrue); |
| 8940 } | 8599 } |
| 8941 | 8600 |
| 8942 void test_Parser() { | 8601 void test_Parser() { |
| 8943 expect(new Parser(null, null), isNotNull); | 8602 expect(new Parser(null, null), isNotNull); |
| 8944 } | 8603 } |
| 8945 | 8604 |
| 8946 void test_parseRedirectingConstructorInvocation_named() { | 8605 void test_parseRedirectingConstructorInvocation_named() { |
| 8947 RedirectingConstructorInvocation invocation = ParserTestCase.parse4( | 8606 RedirectingConstructorInvocation invocation = |
| 8948 "parseRedirectingConstructorInvocation", "this.a()"); | 8607 parse4("parseRedirectingConstructorInvocation", "this.a()"); |
| 8949 expect(invocation.argumentList, isNotNull); | 8608 expect(invocation.argumentList, isNotNull); |
| 8950 expect(invocation.constructorName, isNotNull); | 8609 expect(invocation.constructorName, isNotNull); |
| 8951 expect(invocation.thisKeyword, isNotNull); | 8610 expect(invocation.thisKeyword, isNotNull); |
| 8952 expect(invocation.period, isNotNull); | 8611 expect(invocation.period, isNotNull); |
| 8953 } | 8612 } |
| 8954 | 8613 |
| 8955 void test_parseRedirectingConstructorInvocation_unnamed() { | 8614 void test_parseRedirectingConstructorInvocation_unnamed() { |
| 8956 RedirectingConstructorInvocation invocation = ParserTestCase.parse4( | 8615 RedirectingConstructorInvocation invocation = |
| 8957 "parseRedirectingConstructorInvocation", "this()"); | 8616 parse4("parseRedirectingConstructorInvocation", "this()"); |
| 8958 expect(invocation.argumentList, isNotNull); | 8617 expect(invocation.argumentList, isNotNull); |
| 8959 expect(invocation.constructorName, isNull); | 8618 expect(invocation.constructorName, isNull); |
| 8960 expect(invocation.thisKeyword, isNotNull); | 8619 expect(invocation.thisKeyword, isNotNull); |
| 8961 expect(invocation.period, isNull); | 8620 expect(invocation.period, isNull); |
| 8962 } | 8621 } |
| 8963 | 8622 |
| 8964 void test_parseRelationalExpression_as() { | 8623 void test_parseRelationalExpression_as() { |
| 8965 AsExpression expression = | 8624 AsExpression expression = parse4("parseRelationalExpression", "x as Y"); |
| 8966 ParserTestCase.parse4("parseRelationalExpression", "x as Y"); | |
| 8967 expect(expression.expression, isNotNull); | 8625 expect(expression.expression, isNotNull); |
| 8968 expect(expression.asOperator, isNotNull); | 8626 expect(expression.asOperator, isNotNull); |
| 8969 expect(expression.type, isNotNull); | 8627 expect(expression.type, isNotNull); |
| 8970 } | 8628 } |
| 8971 | 8629 |
| 8972 void test_parseRelationalExpression_is() { | 8630 void test_parseRelationalExpression_is() { |
| 8973 IsExpression expression = | 8631 IsExpression expression = parse4("parseRelationalExpression", "x is y"); |
| 8974 ParserTestCase.parse4("parseRelationalExpression", "x is y"); | |
| 8975 expect(expression.expression, isNotNull); | 8632 expect(expression.expression, isNotNull); |
| 8976 expect(expression.isOperator, isNotNull); | 8633 expect(expression.isOperator, isNotNull); |
| 8977 expect(expression.notOperator, isNull); | 8634 expect(expression.notOperator, isNull); |
| 8978 expect(expression.type, isNotNull); | 8635 expect(expression.type, isNotNull); |
| 8979 } | 8636 } |
| 8980 | 8637 |
| 8981 void test_parseRelationalExpression_isNot() { | 8638 void test_parseRelationalExpression_isNot() { |
| 8982 IsExpression expression = | 8639 IsExpression expression = parse4("parseRelationalExpression", "x is! y"); |
| 8983 ParserTestCase.parse4("parseRelationalExpression", "x is! y"); | |
| 8984 expect(expression.expression, isNotNull); | 8640 expect(expression.expression, isNotNull); |
| 8985 expect(expression.isOperator, isNotNull); | 8641 expect(expression.isOperator, isNotNull); |
| 8986 expect(expression.notOperator, isNotNull); | 8642 expect(expression.notOperator, isNotNull); |
| 8987 expect(expression.type, isNotNull); | 8643 expect(expression.type, isNotNull); |
| 8988 } | 8644 } |
| 8989 | 8645 |
| 8990 void test_parseRelationalExpression_normal() { | 8646 void test_parseRelationalExpression_normal() { |
| 8991 BinaryExpression expression = | 8647 BinaryExpression expression = parse4("parseRelationalExpression", "x < y"); |
| 8992 ParserTestCase.parse4("parseRelationalExpression", "x < y"); | |
| 8993 expect(expression.leftOperand, isNotNull); | 8648 expect(expression.leftOperand, isNotNull); |
| 8994 expect(expression.operator, isNotNull); | 8649 expect(expression.operator, isNotNull); |
| 8995 expect(expression.operator.type, TokenType.LT); | 8650 expect(expression.operator.type, TokenType.LT); |
| 8996 expect(expression.rightOperand, isNotNull); | 8651 expect(expression.rightOperand, isNotNull); |
| 8997 } | 8652 } |
| 8998 | 8653 |
| 8999 void test_parseRelationalExpression_super() { | 8654 void test_parseRelationalExpression_super() { |
| 9000 BinaryExpression expression = | 8655 BinaryExpression expression = |
| 9001 ParserTestCase.parse4("parseRelationalExpression", "super < y"); | 8656 parse4("parseRelationalExpression", "super < y"); |
| 9002 expect(expression.leftOperand, isNotNull); | 8657 expect(expression.leftOperand, isNotNull); |
| 9003 expect(expression.operator, isNotNull); | 8658 expect(expression.operator, isNotNull); |
| 9004 expect(expression.operator.type, TokenType.LT); | 8659 expect(expression.operator.type, TokenType.LT); |
| 9005 expect(expression.rightOperand, isNotNull); | 8660 expect(expression.rightOperand, isNotNull); |
| 9006 } | 8661 } |
| 9007 | 8662 |
| 9008 void test_parseRethrowExpression() { | 8663 void test_parseRethrowExpression() { |
| 9009 RethrowExpression expression = | 8664 RethrowExpression expression = parse4("parseRethrowExpression", "rethrow;"); |
| 9010 ParserTestCase.parse4("parseRethrowExpression", "rethrow;"); | |
| 9011 expect(expression.rethrowKeyword, isNotNull); | 8665 expect(expression.rethrowKeyword, isNotNull); |
| 9012 } | 8666 } |
| 9013 | 8667 |
| 9014 void test_parseReturnStatement_noValue() { | 8668 void test_parseReturnStatement_noValue() { |
| 9015 ReturnStatement statement = | 8669 ReturnStatement statement = parse4("parseReturnStatement", "return;"); |
| 9016 ParserTestCase.parse4("parseReturnStatement", "return;"); | |
| 9017 expect(statement.returnKeyword, isNotNull); | 8670 expect(statement.returnKeyword, isNotNull); |
| 9018 expect(statement.expression, isNull); | 8671 expect(statement.expression, isNull); |
| 9019 expect(statement.semicolon, isNotNull); | 8672 expect(statement.semicolon, isNotNull); |
| 9020 } | 8673 } |
| 9021 | 8674 |
| 9022 void test_parseReturnStatement_value() { | 8675 void test_parseReturnStatement_value() { |
| 9023 ReturnStatement statement = | 8676 ReturnStatement statement = parse4("parseReturnStatement", "return x;"); |
| 9024 ParserTestCase.parse4("parseReturnStatement", "return x;"); | |
| 9025 expect(statement.returnKeyword, isNotNull); | 8677 expect(statement.returnKeyword, isNotNull); |
| 9026 expect(statement.expression, isNotNull); | 8678 expect(statement.expression, isNotNull); |
| 9027 expect(statement.semicolon, isNotNull); | 8679 expect(statement.semicolon, isNotNull); |
| 9028 } | 8680 } |
| 9029 | 8681 |
| 9030 void test_parseReturnType_nonVoid() { | 8682 void test_parseReturnType_nonVoid() { |
| 9031 TypeName typeName = ParserTestCase.parse4("parseReturnType", "A<B>"); | 8683 TypeName typeName = parse4("parseReturnType", "A<B>"); |
| 9032 expect(typeName.name, isNotNull); | 8684 expect(typeName.name, isNotNull); |
| 9033 expect(typeName.typeArguments, isNotNull); | 8685 expect(typeName.typeArguments, isNotNull); |
| 9034 } | 8686 } |
| 9035 | 8687 |
| 9036 void test_parseReturnType_void() { | 8688 void test_parseReturnType_void() { |
| 9037 TypeName typeName = ParserTestCase.parse4("parseReturnType", "void"); | 8689 TypeName typeName = parse4("parseReturnType", "void"); |
| 9038 expect(typeName.name, isNotNull); | 8690 expect(typeName.name, isNotNull); |
| 9039 expect(typeName.typeArguments, isNull); | 8691 expect(typeName.typeArguments, isNull); |
| 9040 } | 8692 } |
| 9041 | 8693 |
| 9042 void test_parseSetter_nonStatic() { | 8694 void test_parseSetter_nonStatic() { |
| 9043 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); | 8695 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); |
| 9044 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); | 8696 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); |
| 9045 MethodDeclaration method = ParserTestCase.parse("parseSetter", <Object>[ | 8697 MethodDeclaration method = parse("parseSetter", <Object>[ |
| 9046 commentAndMetadata(comment), | 8698 commentAndMetadata(comment), |
| 9047 null, | 8699 null, |
| 9048 null, | 8700 null, |
| 9049 returnType | 8701 returnType |
| 9050 ], "set a(var x);"); | 8702 ], "set a(var x);"); |
| 9051 expect(method.body, isNotNull); | 8703 expect(method.body, isNotNull); |
| 9052 expect(method.documentationComment, comment); | 8704 expect(method.documentationComment, comment); |
| 9053 expect(method.externalKeyword, isNull); | 8705 expect(method.externalKeyword, isNull); |
| 9054 expect(method.modifierKeyword, isNull); | 8706 expect(method.modifierKeyword, isNull); |
| 9055 expect(method.name, isNotNull); | 8707 expect(method.name, isNotNull); |
| 9056 expect(method.operatorKeyword, isNull); | 8708 expect(method.operatorKeyword, isNull); |
| 9057 expect(method.parameters, isNotNull); | 8709 expect(method.parameters, isNotNull); |
| 9058 expect(method.propertyKeyword, isNotNull); | 8710 expect(method.propertyKeyword, isNotNull); |
| 9059 expect(method.returnType, returnType); | 8711 expect(method.returnType, returnType); |
| 9060 } | 8712 } |
| 9061 | 8713 |
| 9062 void test_parseSetter_static() { | 8714 void test_parseSetter_static() { |
| 9063 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); | 8715 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); |
| 9064 Token staticKeyword = TokenFactory.tokenFromKeyword(Keyword.STATIC); | 8716 Token staticKeyword = TokenFactory.tokenFromKeyword(Keyword.STATIC); |
| 9065 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); | 8717 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); |
| 9066 MethodDeclaration method = ParserTestCase.parse("parseSetter", <Object>[ | 8718 MethodDeclaration method = parse("parseSetter", <Object>[ |
| 9067 commentAndMetadata(comment), | 8719 commentAndMetadata(comment), |
| 9068 null, | 8720 null, |
| 9069 staticKeyword, | 8721 staticKeyword, |
| 9070 returnType | 8722 returnType |
| 9071 ], "set a(var x) {}"); | 8723 ], "set a(var x) {}"); |
| 9072 expect(method.body, isNotNull); | 8724 expect(method.body, isNotNull); |
| 9073 expect(method.documentationComment, comment); | 8725 expect(method.documentationComment, comment); |
| 9074 expect(method.externalKeyword, isNull); | 8726 expect(method.externalKeyword, isNull); |
| 9075 expect(method.modifierKeyword, staticKeyword); | 8727 expect(method.modifierKeyword, staticKeyword); |
| 9076 expect(method.name, isNotNull); | 8728 expect(method.name, isNotNull); |
| 9077 expect(method.operatorKeyword, isNull); | 8729 expect(method.operatorKeyword, isNull); |
| 9078 expect(method.parameters, isNotNull); | 8730 expect(method.parameters, isNotNull); |
| 9079 expect(method.propertyKeyword, isNotNull); | 8731 expect(method.propertyKeyword, isNotNull); |
| 9080 expect(method.returnType, returnType); | 8732 expect(method.returnType, returnType); |
| 9081 } | 8733 } |
| 9082 | 8734 |
| 9083 void test_parseShiftExpression_normal() { | 8735 void test_parseShiftExpression_normal() { |
| 9084 BinaryExpression expression = | 8736 BinaryExpression expression = parse4("parseShiftExpression", "x << y"); |
| 9085 ParserTestCase.parse4("parseShiftExpression", "x << y"); | |
| 9086 expect(expression.leftOperand, isNotNull); | 8737 expect(expression.leftOperand, isNotNull); |
| 9087 expect(expression.operator, isNotNull); | 8738 expect(expression.operator, isNotNull); |
| 9088 expect(expression.operator.type, TokenType.LT_LT); | 8739 expect(expression.operator.type, TokenType.LT_LT); |
| 9089 expect(expression.rightOperand, isNotNull); | 8740 expect(expression.rightOperand, isNotNull); |
| 9090 } | 8741 } |
| 9091 | 8742 |
| 9092 void test_parseShiftExpression_super() { | 8743 void test_parseShiftExpression_super() { |
| 9093 BinaryExpression expression = | 8744 BinaryExpression expression = parse4("parseShiftExpression", "super << y"); |
| 9094 ParserTestCase.parse4("parseShiftExpression", "super << y"); | |
| 9095 expect(expression.leftOperand, isNotNull); | 8745 expect(expression.leftOperand, isNotNull); |
| 9096 expect(expression.operator, isNotNull); | 8746 expect(expression.operator, isNotNull); |
| 9097 expect(expression.operator.type, TokenType.LT_LT); | 8747 expect(expression.operator.type, TokenType.LT_LT); |
| 9098 expect(expression.rightOperand, isNotNull); | 8748 expect(expression.rightOperand, isNotNull); |
| 9099 } | 8749 } |
| 9100 | 8750 |
| 9101 void test_parseSimpleIdentifier1_normalIdentifier() { | 8751 void test_parseSimpleIdentifier1_normalIdentifier() { |
| 9102 // TODO(brianwilkerson) Implement tests for this method. | 8752 // TODO(brianwilkerson) Implement tests for this method. |
| 9103 } | 8753 } |
| 9104 | 8754 |
| 9105 void test_parseSimpleIdentifier_builtInIdentifier() { | 8755 void test_parseSimpleIdentifier_builtInIdentifier() { |
| 9106 String lexeme = "as"; | 8756 String lexeme = "as"; |
| 9107 SimpleIdentifier identifier = | 8757 SimpleIdentifier identifier = parse4("parseSimpleIdentifier", lexeme); |
| 9108 ParserTestCase.parse4("parseSimpleIdentifier", lexeme); | |
| 9109 expect(identifier.token, isNotNull); | 8758 expect(identifier.token, isNotNull); |
| 9110 expect(identifier.name, lexeme); | 8759 expect(identifier.name, lexeme); |
| 9111 } | 8760 } |
| 9112 | 8761 |
| 9113 void test_parseSimpleIdentifier_normalIdentifier() { | 8762 void test_parseSimpleIdentifier_normalIdentifier() { |
| 9114 String lexeme = "foo"; | 8763 String lexeme = "foo"; |
| 9115 SimpleIdentifier identifier = | 8764 SimpleIdentifier identifier = parse4("parseSimpleIdentifier", lexeme); |
| 9116 ParserTestCase.parse4("parseSimpleIdentifier", lexeme); | |
| 9117 expect(identifier.token, isNotNull); | 8765 expect(identifier.token, isNotNull); |
| 9118 expect(identifier.name, lexeme); | 8766 expect(identifier.name, lexeme); |
| 9119 } | 8767 } |
| 9120 | 8768 |
| 9121 void test_parseStatement_functionDeclaration() { | 8769 void test_parseStatement_functionDeclaration() { |
| 9122 // TODO(brianwilkerson) Implement more tests for this method. | 8770 // TODO(brianwilkerson) Implement more tests for this method. |
| 9123 FunctionDeclarationStatement statement = | 8771 FunctionDeclarationStatement statement = |
| 9124 ParserTestCase.parse4("parseStatement", "int f(a, b) {};"); | 8772 parse4("parseStatement", "int f(a, b) {};"); |
| 9125 expect(statement.functionDeclaration, isNotNull); | 8773 expect(statement.functionDeclaration, isNotNull); |
| 9126 } | 8774 } |
| 9127 | 8775 |
| 9128 void test_parseStatement_mulipleLabels() { | 8776 void test_parseStatement_mulipleLabels() { |
| 9129 LabeledStatement statement = | 8777 LabeledStatement statement = parse4("parseStatement", "l: m: return x;"); |
| 9130 ParserTestCase.parse4("parseStatement", "l: m: return x;"); | |
| 9131 expect(statement.labels, hasLength(2)); | 8778 expect(statement.labels, hasLength(2)); |
| 9132 expect(statement.statement, isNotNull); | 8779 expect(statement.statement, isNotNull); |
| 9133 } | 8780 } |
| 9134 | 8781 |
| 9135 void test_parseStatement_noLabels() { | 8782 void test_parseStatement_noLabels() { |
| 9136 ParserTestCase.parse4("parseStatement", "return x;"); | 8783 parse4("parseStatement", "return x;"); |
| 9137 } | 8784 } |
| 9138 | 8785 |
| 9139 void test_parseStatement_singleLabel() { | 8786 void test_parseStatement_singleLabel() { |
| 9140 LabeledStatement statement = | 8787 LabeledStatement statement = parse4("parseStatement", "l: return x;"); |
| 9141 ParserTestCase.parse4("parseStatement", "l: return x;"); | |
| 9142 expect(statement.labels, hasLength(1)); | 8788 expect(statement.labels, hasLength(1)); |
| 9143 expect(statement.statement, isNotNull); | 8789 expect(statement.statement, isNotNull); |
| 9144 } | 8790 } |
| 9145 | 8791 |
| 9146 void test_parseStatements_multiple() { | 8792 void test_parseStatements_multiple() { |
| 9147 List<Statement> statements = | 8793 List<Statement> statements = |
| 9148 ParserTestCase.parseStatements("return; return;", 2); | 8794 ParserTestCase.parseStatements("return; return;", 2); |
| 9149 expect(statements, hasLength(2)); | 8795 expect(statements, hasLength(2)); |
| 9150 } | 8796 } |
| 9151 | 8797 |
| 9152 void test_parseStatements_single() { | 8798 void test_parseStatements_single() { |
| 9153 List<Statement> statements = ParserTestCase.parseStatements("return;", 1); | 8799 List<Statement> statements = ParserTestCase.parseStatements("return;", 1); |
| 9154 expect(statements, hasLength(1)); | 8800 expect(statements, hasLength(1)); |
| 9155 } | 8801 } |
| 9156 | 8802 |
| 9157 void test_parseStringLiteral_adjacent() { | 8803 void test_parseStringLiteral_adjacent() { |
| 9158 AdjacentStrings literal = | 8804 AdjacentStrings literal = parse4("parseStringLiteral", "'a' 'b'"); |
| 9159 ParserTestCase.parse4("parseStringLiteral", "'a' 'b'"); | |
| 9160 NodeList<StringLiteral> strings = literal.strings; | 8805 NodeList<StringLiteral> strings = literal.strings; |
| 9161 expect(strings, hasLength(2)); | 8806 expect(strings, hasLength(2)); |
| 9162 StringLiteral firstString = strings[0]; | 8807 StringLiteral firstString = strings[0]; |
| 9163 StringLiteral secondString = strings[1]; | 8808 StringLiteral secondString = strings[1]; |
| 9164 expect((firstString as SimpleStringLiteral).value, "a"); | 8809 expect((firstString as SimpleStringLiteral).value, "a"); |
| 9165 expect((secondString as SimpleStringLiteral).value, "b"); | 8810 expect((secondString as SimpleStringLiteral).value, "b"); |
| 9166 } | 8811 } |
| 9167 | 8812 |
| 9168 void test_parseStringLiteral_interpolated() { | 8813 void test_parseStringLiteral_interpolated() { |
| 9169 StringInterpolation literal = | 8814 StringInterpolation literal = |
| 9170 ParserTestCase.parse4("parseStringLiteral", "'a \${b} c \$this d'"); | 8815 parse4("parseStringLiteral", "'a \${b} c \$this d'"); |
| 9171 NodeList<InterpolationElement> elements = literal.elements; | 8816 NodeList<InterpolationElement> elements = literal.elements; |
| 9172 expect(elements, hasLength(5)); | 8817 expect(elements, hasLength(5)); |
| 9173 expect(elements[0] is InterpolationString, isTrue); | 8818 expect(elements[0] is InterpolationString, isTrue); |
| 9174 expect(elements[1] is InterpolationExpression, isTrue); | 8819 expect(elements[1] is InterpolationExpression, isTrue); |
| 9175 expect(elements[2] is InterpolationString, isTrue); | 8820 expect(elements[2] is InterpolationString, isTrue); |
| 9176 expect(elements[3] is InterpolationExpression, isTrue); | 8821 expect(elements[3] is InterpolationExpression, isTrue); |
| 9177 expect(elements[4] is InterpolationString, isTrue); | 8822 expect(elements[4] is InterpolationString, isTrue); |
| 9178 } | 8823 } |
| 9179 | 8824 |
| 9180 void test_parseStringLiteral_single() { | 8825 void test_parseStringLiteral_single() { |
| 9181 SimpleStringLiteral literal = | 8826 SimpleStringLiteral literal = parse4("parseStringLiteral", "'a'"); |
| 9182 ParserTestCase.parse4("parseStringLiteral", "'a'"); | |
| 9183 expect(literal.literal, isNotNull); | 8827 expect(literal.literal, isNotNull); |
| 9184 expect(literal.value, "a"); | 8828 expect(literal.value, "a"); |
| 9185 } | 8829 } |
| 9186 | 8830 |
| 9187 void test_parseSuperConstructorInvocation_named() { | 8831 void test_parseSuperConstructorInvocation_named() { |
| 9188 SuperConstructorInvocation invocation = | 8832 SuperConstructorInvocation invocation = |
| 9189 ParserTestCase.parse4("parseSuperConstructorInvocation", "super.a()"); | 8833 parse4("parseSuperConstructorInvocation", "super.a()"); |
| 9190 expect(invocation.argumentList, isNotNull); | 8834 expect(invocation.argumentList, isNotNull); |
| 9191 expect(invocation.constructorName, isNotNull); | 8835 expect(invocation.constructorName, isNotNull); |
| 9192 expect(invocation.superKeyword, isNotNull); | 8836 expect(invocation.superKeyword, isNotNull); |
| 9193 expect(invocation.period, isNotNull); | 8837 expect(invocation.period, isNotNull); |
| 9194 } | 8838 } |
| 9195 | 8839 |
| 9196 void test_parseSuperConstructorInvocation_unnamed() { | 8840 void test_parseSuperConstructorInvocation_unnamed() { |
| 9197 SuperConstructorInvocation invocation = | 8841 SuperConstructorInvocation invocation = |
| 9198 ParserTestCase.parse4("parseSuperConstructorInvocation", "super()"); | 8842 parse4("parseSuperConstructorInvocation", "super()"); |
| 9199 expect(invocation.argumentList, isNotNull); | 8843 expect(invocation.argumentList, isNotNull); |
| 9200 expect(invocation.constructorName, isNull); | 8844 expect(invocation.constructorName, isNull); |
| 9201 expect(invocation.superKeyword, isNotNull); | 8845 expect(invocation.superKeyword, isNotNull); |
| 9202 expect(invocation.period, isNull); | 8846 expect(invocation.period, isNull); |
| 9203 } | 8847 } |
| 9204 | 8848 |
| 9205 void test_parseSwitchStatement_case() { | 8849 void test_parseSwitchStatement_case() { |
| 9206 SwitchStatement statement = ParserTestCase.parse4( | 8850 SwitchStatement statement = |
| 9207 "parseSwitchStatement", "switch (a) {case 1: return 'I';}"); | 8851 parse4("parseSwitchStatement", "switch (a) {case 1: return 'I';}"); |
| 9208 expect(statement.switchKeyword, isNotNull); | 8852 expect(statement.switchKeyword, isNotNull); |
| 9209 expect(statement.leftParenthesis, isNotNull); | 8853 expect(statement.leftParenthesis, isNotNull); |
| 9210 expect(statement.expression, isNotNull); | 8854 expect(statement.expression, isNotNull); |
| 9211 expect(statement.rightParenthesis, isNotNull); | 8855 expect(statement.rightParenthesis, isNotNull); |
| 9212 expect(statement.leftBracket, isNotNull); | 8856 expect(statement.leftBracket, isNotNull); |
| 9213 expect(statement.members, hasLength(1)); | 8857 expect(statement.members, hasLength(1)); |
| 9214 expect(statement.rightBracket, isNotNull); | 8858 expect(statement.rightBracket, isNotNull); |
| 9215 } | 8859 } |
| 9216 | 8860 |
| 9217 void test_parseSwitchStatement_empty() { | 8861 void test_parseSwitchStatement_empty() { |
| 9218 SwitchStatement statement = | 8862 SwitchStatement statement = parse4("parseSwitchStatement", "switch (a) {}"); |
| 9219 ParserTestCase.parse4("parseSwitchStatement", "switch (a) {}"); | |
| 9220 expect(statement.switchKeyword, isNotNull); | 8863 expect(statement.switchKeyword, isNotNull); |
| 9221 expect(statement.leftParenthesis, isNotNull); | 8864 expect(statement.leftParenthesis, isNotNull); |
| 9222 expect(statement.expression, isNotNull); | 8865 expect(statement.expression, isNotNull); |
| 9223 expect(statement.rightParenthesis, isNotNull); | 8866 expect(statement.rightParenthesis, isNotNull); |
| 9224 expect(statement.leftBracket, isNotNull); | 8867 expect(statement.leftBracket, isNotNull); |
| 9225 expect(statement.members, hasLength(0)); | 8868 expect(statement.members, hasLength(0)); |
| 9226 expect(statement.rightBracket, isNotNull); | 8869 expect(statement.rightBracket, isNotNull); |
| 9227 } | 8870 } |
| 9228 | 8871 |
| 9229 void test_parseSwitchStatement_labeledCase() { | 8872 void test_parseSwitchStatement_labeledCase() { |
| 9230 SwitchStatement statement = ParserTestCase.parse4( | 8873 SwitchStatement statement = |
| 9231 "parseSwitchStatement", "switch (a) {l1: l2: l3: case(1):}"); | 8874 parse4("parseSwitchStatement", "switch (a) {l1: l2: l3: case(1):}"); |
| 9232 expect(statement.switchKeyword, isNotNull); | 8875 expect(statement.switchKeyword, isNotNull); |
| 9233 expect(statement.leftParenthesis, isNotNull); | 8876 expect(statement.leftParenthesis, isNotNull); |
| 9234 expect(statement.expression, isNotNull); | 8877 expect(statement.expression, isNotNull); |
| 9235 expect(statement.rightParenthesis, isNotNull); | 8878 expect(statement.rightParenthesis, isNotNull); |
| 9236 expect(statement.leftBracket, isNotNull); | 8879 expect(statement.leftBracket, isNotNull); |
| 9237 expect(statement.members, hasLength(1)); | 8880 expect(statement.members, hasLength(1)); |
| 9238 expect(statement.members[0].labels, hasLength(3)); | 8881 expect(statement.members[0].labels, hasLength(3)); |
| 9239 expect(statement.rightBracket, isNotNull); | 8882 expect(statement.rightBracket, isNotNull); |
| 9240 } | 8883 } |
| 9241 | 8884 |
| 9242 void test_parseSwitchStatement_labeledStatementInCase() { | 8885 void test_parseSwitchStatement_labeledStatementInCase() { |
| 9243 SwitchStatement statement = ParserTestCase.parse4( | 8886 SwitchStatement statement = parse4( |
| 9244 "parseSwitchStatement", "switch (a) {case 0: f(); l1: g(); break;}"); | 8887 "parseSwitchStatement", "switch (a) {case 0: f(); l1: g(); break;}"); |
| 9245 expect(statement.switchKeyword, isNotNull); | 8888 expect(statement.switchKeyword, isNotNull); |
| 9246 expect(statement.leftParenthesis, isNotNull); | 8889 expect(statement.leftParenthesis, isNotNull); |
| 9247 expect(statement.expression, isNotNull); | 8890 expect(statement.expression, isNotNull); |
| 9248 expect(statement.rightParenthesis, isNotNull); | 8891 expect(statement.rightParenthesis, isNotNull); |
| 9249 expect(statement.leftBracket, isNotNull); | 8892 expect(statement.leftBracket, isNotNull); |
| 9250 expect(statement.members, hasLength(1)); | 8893 expect(statement.members, hasLength(1)); |
| 9251 expect(statement.members[0].statements, hasLength(3)); | 8894 expect(statement.members[0].statements, hasLength(3)); |
| 9252 expect(statement.rightBracket, isNotNull); | 8895 expect(statement.rightBracket, isNotNull); |
| 9253 } | 8896 } |
| 9254 | 8897 |
| 9255 void test_parseSymbolLiteral_builtInIdentifier() { | 8898 void test_parseSymbolLiteral_builtInIdentifier() { |
| 9256 SymbolLiteral literal = | 8899 SymbolLiteral literal = |
| 9257 ParserTestCase.parse4("parseSymbolLiteral", "#dynamic.static.abstract"); | 8900 parse4("parseSymbolLiteral", "#dynamic.static.abstract"); |
| 9258 expect(literal.poundSign, isNotNull); | 8901 expect(literal.poundSign, isNotNull); |
| 9259 List<Token> components = literal.components; | 8902 List<Token> components = literal.components; |
| 9260 expect(components, hasLength(3)); | 8903 expect(components, hasLength(3)); |
| 9261 expect(components[0].lexeme, "dynamic"); | 8904 expect(components[0].lexeme, "dynamic"); |
| 9262 expect(components[1].lexeme, "static"); | 8905 expect(components[1].lexeme, "static"); |
| 9263 expect(components[2].lexeme, "abstract"); | 8906 expect(components[2].lexeme, "abstract"); |
| 9264 } | 8907 } |
| 9265 | 8908 |
| 9266 void test_parseSymbolLiteral_multiple() { | 8909 void test_parseSymbolLiteral_multiple() { |
| 9267 SymbolLiteral literal = | 8910 SymbolLiteral literal = parse4("parseSymbolLiteral", "#a.b.c"); |
| 9268 ParserTestCase.parse4("parseSymbolLiteral", "#a.b.c"); | |
| 9269 expect(literal.poundSign, isNotNull); | 8911 expect(literal.poundSign, isNotNull); |
| 9270 List<Token> components = literal.components; | 8912 List<Token> components = literal.components; |
| 9271 expect(components, hasLength(3)); | 8913 expect(components, hasLength(3)); |
| 9272 expect(components[0].lexeme, "a"); | 8914 expect(components[0].lexeme, "a"); |
| 9273 expect(components[1].lexeme, "b"); | 8915 expect(components[1].lexeme, "b"); |
| 9274 expect(components[2].lexeme, "c"); | 8916 expect(components[2].lexeme, "c"); |
| 9275 } | 8917 } |
| 9276 | 8918 |
| 9277 void test_parseSymbolLiteral_operator() { | 8919 void test_parseSymbolLiteral_operator() { |
| 9278 SymbolLiteral literal = ParserTestCase.parse4("parseSymbolLiteral", "#=="); | 8920 SymbolLiteral literal = parse4("parseSymbolLiteral", "#=="); |
| 9279 expect(literal.poundSign, isNotNull); | 8921 expect(literal.poundSign, isNotNull); |
| 9280 List<Token> components = literal.components; | 8922 List<Token> components = literal.components; |
| 9281 expect(components, hasLength(1)); | 8923 expect(components, hasLength(1)); |
| 9282 expect(components[0].lexeme, "=="); | 8924 expect(components[0].lexeme, "=="); |
| 9283 } | 8925 } |
| 9284 | 8926 |
| 9285 void test_parseSymbolLiteral_single() { | 8927 void test_parseSymbolLiteral_single() { |
| 9286 SymbolLiteral literal = ParserTestCase.parse4("parseSymbolLiteral", "#a"); | 8928 SymbolLiteral literal = parse4("parseSymbolLiteral", "#a"); |
| 9287 expect(literal.poundSign, isNotNull); | 8929 expect(literal.poundSign, isNotNull); |
| 9288 List<Token> components = literal.components; | 8930 List<Token> components = literal.components; |
| 9289 expect(components, hasLength(1)); | 8931 expect(components, hasLength(1)); |
| 9290 expect(components[0].lexeme, "a"); | 8932 expect(components[0].lexeme, "a"); |
| 9291 } | 8933 } |
| 9292 | 8934 |
| 9293 void test_parseSymbolLiteral_void() { | 8935 void test_parseSymbolLiteral_void() { |
| 9294 SymbolLiteral literal = | 8936 SymbolLiteral literal = parse4("parseSymbolLiteral", "#void"); |
| 9295 ParserTestCase.parse4("parseSymbolLiteral", "#void"); | |
| 9296 expect(literal.poundSign, isNotNull); | 8937 expect(literal.poundSign, isNotNull); |
| 9297 List<Token> components = literal.components; | 8938 List<Token> components = literal.components; |
| 9298 expect(components, hasLength(1)); | 8939 expect(components, hasLength(1)); |
| 9299 expect(components[0].lexeme, "void"); | 8940 expect(components[0].lexeme, "void"); |
| 9300 } | 8941 } |
| 9301 | 8942 |
| 9302 void test_parseThrowExpression() { | 8943 void test_parseThrowExpression() { |
| 9303 ThrowExpression expression = | 8944 ThrowExpression expression = parse4("parseThrowExpression", "throw x;"); |
| 9304 ParserTestCase.parse4("parseThrowExpression", "throw x;"); | |
| 9305 expect(expression.throwKeyword, isNotNull); | 8945 expect(expression.throwKeyword, isNotNull); |
| 9306 expect(expression.expression, isNotNull); | 8946 expect(expression.expression, isNotNull); |
| 9307 } | 8947 } |
| 9308 | 8948 |
| 9309 void test_parseThrowExpressionWithoutCascade() { | 8949 void test_parseThrowExpressionWithoutCascade() { |
| 9310 ThrowExpression expression = | 8950 ThrowExpression expression = |
| 9311 ParserTestCase.parse4("parseThrowExpressionWithoutCascade", "throw x;"); | 8951 parse4("parseThrowExpressionWithoutCascade", "throw x;"); |
| 9312 expect(expression.throwKeyword, isNotNull); | 8952 expect(expression.throwKeyword, isNotNull); |
| 9313 expect(expression.expression, isNotNull); | 8953 expect(expression.expression, isNotNull); |
| 9314 } | 8954 } |
| 9315 | 8955 |
| 9316 void test_parseTryStatement_catch() { | 8956 void test_parseTryStatement_catch() { |
| 9317 TryStatement statement = | 8957 TryStatement statement = parse4("parseTryStatement", "try {} catch (e) {}"); |
| 9318 ParserTestCase.parse4("parseTryStatement", "try {} catch (e) {}"); | |
| 9319 expect(statement.tryKeyword, isNotNull); | 8958 expect(statement.tryKeyword, isNotNull); |
| 9320 expect(statement.body, isNotNull); | 8959 expect(statement.body, isNotNull); |
| 9321 NodeList<CatchClause> catchClauses = statement.catchClauses; | 8960 NodeList<CatchClause> catchClauses = statement.catchClauses; |
| 9322 expect(catchClauses, hasLength(1)); | 8961 expect(catchClauses, hasLength(1)); |
| 9323 CatchClause clause = catchClauses[0]; | 8962 CatchClause clause = catchClauses[0]; |
| 9324 expect(clause.onKeyword, isNull); | 8963 expect(clause.onKeyword, isNull); |
| 9325 expect(clause.exceptionType, isNull); | 8964 expect(clause.exceptionType, isNull); |
| 9326 expect(clause.catchKeyword, isNotNull); | 8965 expect(clause.catchKeyword, isNotNull); |
| 9327 expect(clause.exceptionParameter, isNotNull); | 8966 expect(clause.exceptionParameter, isNotNull); |
| 9328 expect(clause.comma, isNull); | 8967 expect(clause.comma, isNull); |
| 9329 expect(clause.stackTraceParameter, isNull); | 8968 expect(clause.stackTraceParameter, isNull); |
| 9330 expect(clause.body, isNotNull); | 8969 expect(clause.body, isNotNull); |
| 9331 expect(statement.finallyKeyword, isNull); | 8970 expect(statement.finallyKeyword, isNull); |
| 9332 expect(statement.finallyBlock, isNull); | 8971 expect(statement.finallyBlock, isNull); |
| 9333 } | 8972 } |
| 9334 | 8973 |
| 9335 void test_parseTryStatement_catch_finally() { | 8974 void test_parseTryStatement_catch_finally() { |
| 9336 TryStatement statement = ParserTestCase.parse4( | 8975 TryStatement statement = |
| 9337 "parseTryStatement", "try {} catch (e, s) {} finally {}"); | 8976 parse4("parseTryStatement", "try {} catch (e, s) {} finally {}"); |
| 9338 expect(statement.tryKeyword, isNotNull); | 8977 expect(statement.tryKeyword, isNotNull); |
| 9339 expect(statement.body, isNotNull); | 8978 expect(statement.body, isNotNull); |
| 9340 NodeList<CatchClause> catchClauses = statement.catchClauses; | 8979 NodeList<CatchClause> catchClauses = statement.catchClauses; |
| 9341 expect(catchClauses, hasLength(1)); | 8980 expect(catchClauses, hasLength(1)); |
| 9342 CatchClause clause = catchClauses[0]; | 8981 CatchClause clause = catchClauses[0]; |
| 9343 expect(clause.onKeyword, isNull); | 8982 expect(clause.onKeyword, isNull); |
| 9344 expect(clause.exceptionType, isNull); | 8983 expect(clause.exceptionType, isNull); |
| 9345 expect(clause.catchKeyword, isNotNull); | 8984 expect(clause.catchKeyword, isNotNull); |
| 9346 expect(clause.exceptionParameter, isNotNull); | 8985 expect(clause.exceptionParameter, isNotNull); |
| 9347 expect(clause.comma, isNotNull); | 8986 expect(clause.comma, isNotNull); |
| 9348 expect(clause.stackTraceParameter, isNotNull); | 8987 expect(clause.stackTraceParameter, isNotNull); |
| 9349 expect(clause.body, isNotNull); | 8988 expect(clause.body, isNotNull); |
| 9350 expect(statement.finallyKeyword, isNotNull); | 8989 expect(statement.finallyKeyword, isNotNull); |
| 9351 expect(statement.finallyBlock, isNotNull); | 8990 expect(statement.finallyBlock, isNotNull); |
| 9352 } | 8991 } |
| 9353 | 8992 |
| 9354 void test_parseTryStatement_finally() { | 8993 void test_parseTryStatement_finally() { |
| 9355 TryStatement statement = | 8994 TryStatement statement = parse4("parseTryStatement", "try {} finally {}"); |
| 9356 ParserTestCase.parse4("parseTryStatement", "try {} finally {}"); | |
| 9357 expect(statement.tryKeyword, isNotNull); | 8995 expect(statement.tryKeyword, isNotNull); |
| 9358 expect(statement.body, isNotNull); | 8996 expect(statement.body, isNotNull); |
| 9359 expect(statement.catchClauses, hasLength(0)); | 8997 expect(statement.catchClauses, hasLength(0)); |
| 9360 expect(statement.finallyKeyword, isNotNull); | 8998 expect(statement.finallyKeyword, isNotNull); |
| 9361 expect(statement.finallyBlock, isNotNull); | 8999 expect(statement.finallyBlock, isNotNull); |
| 9362 } | 9000 } |
| 9363 | 9001 |
| 9364 void test_parseTryStatement_multiple() { | 9002 void test_parseTryStatement_multiple() { |
| 9365 TryStatement statement = ParserTestCase.parse4("parseTryStatement", | 9003 TryStatement statement = parse4("parseTryStatement", |
| 9366 "try {} on NPE catch (e) {} on Error {} catch (e) {}"); | 9004 "try {} on NPE catch (e) {} on Error {} catch (e) {}"); |
| 9367 expect(statement.tryKeyword, isNotNull); | 9005 expect(statement.tryKeyword, isNotNull); |
| 9368 expect(statement.body, isNotNull); | 9006 expect(statement.body, isNotNull); |
| 9369 expect(statement.catchClauses, hasLength(3)); | 9007 expect(statement.catchClauses, hasLength(3)); |
| 9370 expect(statement.finallyKeyword, isNull); | 9008 expect(statement.finallyKeyword, isNull); |
| 9371 expect(statement.finallyBlock, isNull); | 9009 expect(statement.finallyBlock, isNull); |
| 9372 } | 9010 } |
| 9373 | 9011 |
| 9374 void test_parseTryStatement_on() { | 9012 void test_parseTryStatement_on() { |
| 9375 TryStatement statement = | 9013 TryStatement statement = parse4("parseTryStatement", "try {} on Error {}"); |
| 9376 ParserTestCase.parse4("parseTryStatement", "try {} on Error {}"); | |
| 9377 expect(statement.tryKeyword, isNotNull); | 9014 expect(statement.tryKeyword, isNotNull); |
| 9378 expect(statement.body, isNotNull); | 9015 expect(statement.body, isNotNull); |
| 9379 NodeList<CatchClause> catchClauses = statement.catchClauses; | 9016 NodeList<CatchClause> catchClauses = statement.catchClauses; |
| 9380 expect(catchClauses, hasLength(1)); | 9017 expect(catchClauses, hasLength(1)); |
| 9381 CatchClause clause = catchClauses[0]; | 9018 CatchClause clause = catchClauses[0]; |
| 9382 expect(clause.onKeyword, isNotNull); | 9019 expect(clause.onKeyword, isNotNull); |
| 9383 expect(clause.exceptionType, isNotNull); | 9020 expect(clause.exceptionType, isNotNull); |
| 9384 expect(clause.catchKeyword, isNull); | 9021 expect(clause.catchKeyword, isNull); |
| 9385 expect(clause.exceptionParameter, isNull); | 9022 expect(clause.exceptionParameter, isNull); |
| 9386 expect(clause.comma, isNull); | 9023 expect(clause.comma, isNull); |
| 9387 expect(clause.stackTraceParameter, isNull); | 9024 expect(clause.stackTraceParameter, isNull); |
| 9388 expect(clause.body, isNotNull); | 9025 expect(clause.body, isNotNull); |
| 9389 expect(statement.finallyKeyword, isNull); | 9026 expect(statement.finallyKeyword, isNull); |
| 9390 expect(statement.finallyBlock, isNull); | 9027 expect(statement.finallyBlock, isNull); |
| 9391 } | 9028 } |
| 9392 | 9029 |
| 9393 void test_parseTryStatement_on_catch() { | 9030 void test_parseTryStatement_on_catch() { |
| 9394 TryStatement statement = ParserTestCase.parse4( | 9031 TryStatement statement = |
| 9395 "parseTryStatement", "try {} on Error catch (e, s) {}"); | 9032 parse4("parseTryStatement", "try {} on Error catch (e, s) {}"); |
| 9396 expect(statement.tryKeyword, isNotNull); | 9033 expect(statement.tryKeyword, isNotNull); |
| 9397 expect(statement.body, isNotNull); | 9034 expect(statement.body, isNotNull); |
| 9398 NodeList<CatchClause> catchClauses = statement.catchClauses; | 9035 NodeList<CatchClause> catchClauses = statement.catchClauses; |
| 9399 expect(catchClauses, hasLength(1)); | 9036 expect(catchClauses, hasLength(1)); |
| 9400 CatchClause clause = catchClauses[0]; | 9037 CatchClause clause = catchClauses[0]; |
| 9401 expect(clause.onKeyword, isNotNull); | 9038 expect(clause.onKeyword, isNotNull); |
| 9402 expect(clause.exceptionType, isNotNull); | 9039 expect(clause.exceptionType, isNotNull); |
| 9403 expect(clause.catchKeyword, isNotNull); | 9040 expect(clause.catchKeyword, isNotNull); |
| 9404 expect(clause.exceptionParameter, isNotNull); | 9041 expect(clause.exceptionParameter, isNotNull); |
| 9405 expect(clause.comma, isNotNull); | 9042 expect(clause.comma, isNotNull); |
| 9406 expect(clause.stackTraceParameter, isNotNull); | 9043 expect(clause.stackTraceParameter, isNotNull); |
| 9407 expect(clause.body, isNotNull); | 9044 expect(clause.body, isNotNull); |
| 9408 expect(statement.finallyKeyword, isNull); | 9045 expect(statement.finallyKeyword, isNull); |
| 9409 expect(statement.finallyBlock, isNull); | 9046 expect(statement.finallyBlock, isNull); |
| 9410 } | 9047 } |
| 9411 | 9048 |
| 9412 void test_parseTryStatement_on_catch_finally() { | 9049 void test_parseTryStatement_on_catch_finally() { |
| 9413 TryStatement statement = ParserTestCase.parse4( | 9050 TryStatement statement = parse4( |
| 9414 "parseTryStatement", "try {} on Error catch (e, s) {} finally {}"); | 9051 "parseTryStatement", "try {} on Error catch (e, s) {} finally {}"); |
| 9415 expect(statement.tryKeyword, isNotNull); | 9052 expect(statement.tryKeyword, isNotNull); |
| 9416 expect(statement.body, isNotNull); | 9053 expect(statement.body, isNotNull); |
| 9417 NodeList<CatchClause> catchClauses = statement.catchClauses; | 9054 NodeList<CatchClause> catchClauses = statement.catchClauses; |
| 9418 expect(catchClauses, hasLength(1)); | 9055 expect(catchClauses, hasLength(1)); |
| 9419 CatchClause clause = catchClauses[0]; | 9056 CatchClause clause = catchClauses[0]; |
| 9420 expect(clause.onKeyword, isNotNull); | 9057 expect(clause.onKeyword, isNotNull); |
| 9421 expect(clause.exceptionType, isNotNull); | 9058 expect(clause.exceptionType, isNotNull); |
| 9422 expect(clause.catchKeyword, isNotNull); | 9059 expect(clause.catchKeyword, isNotNull); |
| 9423 expect(clause.exceptionParameter, isNotNull); | 9060 expect(clause.exceptionParameter, isNotNull); |
| 9424 expect(clause.comma, isNotNull); | 9061 expect(clause.comma, isNotNull); |
| 9425 expect(clause.stackTraceParameter, isNotNull); | 9062 expect(clause.stackTraceParameter, isNotNull); |
| 9426 expect(clause.body, isNotNull); | 9063 expect(clause.body, isNotNull); |
| 9427 expect(statement.finallyKeyword, isNotNull); | 9064 expect(statement.finallyKeyword, isNotNull); |
| 9428 expect(statement.finallyBlock, isNotNull); | 9065 expect(statement.finallyBlock, isNotNull); |
| 9429 } | 9066 } |
| 9430 | 9067 |
| 9431 void test_parseTypeAlias_function_noParameters() { | 9068 void test_parseTypeAlias_function_noParameters() { |
| 9432 FunctionTypeAlias typeAlias = ParserTestCase.parse("parseTypeAlias", | 9069 FunctionTypeAlias typeAlias = parse("parseTypeAlias", |
| 9433 <Object>[emptyCommentAndMetadata()], "typedef bool F();"); | 9070 <Object>[emptyCommentAndMetadata()], "typedef bool F();"); |
| 9434 expect(typeAlias.typedefKeyword, isNotNull); | 9071 expect(typeAlias.typedefKeyword, isNotNull); |
| 9435 expect(typeAlias.name, isNotNull); | 9072 expect(typeAlias.name, isNotNull); |
| 9436 expect(typeAlias.parameters, isNotNull); | 9073 expect(typeAlias.parameters, isNotNull); |
| 9437 expect(typeAlias.returnType, isNotNull); | 9074 expect(typeAlias.returnType, isNotNull); |
| 9438 expect(typeAlias.semicolon, isNotNull); | 9075 expect(typeAlias.semicolon, isNotNull); |
| 9439 expect(typeAlias.typeParameters, isNull); | 9076 expect(typeAlias.typeParameters, isNull); |
| 9440 } | 9077 } |
| 9441 | 9078 |
| 9442 void test_parseTypeAlias_function_noReturnType() { | 9079 void test_parseTypeAlias_function_noReturnType() { |
| 9443 FunctionTypeAlias typeAlias = ParserTestCase.parse( | 9080 FunctionTypeAlias typeAlias = parse( |
| 9444 "parseTypeAlias", <Object>[emptyCommentAndMetadata()], "typedef F();"); | 9081 "parseTypeAlias", <Object>[emptyCommentAndMetadata()], "typedef F();"); |
| 9445 expect(typeAlias.typedefKeyword, isNotNull); | 9082 expect(typeAlias.typedefKeyword, isNotNull); |
| 9446 expect(typeAlias.name, isNotNull); | 9083 expect(typeAlias.name, isNotNull); |
| 9447 expect(typeAlias.parameters, isNotNull); | 9084 expect(typeAlias.parameters, isNotNull); |
| 9448 expect(typeAlias.returnType, isNull); | 9085 expect(typeAlias.returnType, isNull); |
| 9449 expect(typeAlias.semicolon, isNotNull); | 9086 expect(typeAlias.semicolon, isNotNull); |
| 9450 expect(typeAlias.typeParameters, isNull); | 9087 expect(typeAlias.typeParameters, isNull); |
| 9451 } | 9088 } |
| 9452 | 9089 |
| 9453 void test_parseTypeAlias_function_parameterizedReturnType() { | 9090 void test_parseTypeAlias_function_parameterizedReturnType() { |
| 9454 FunctionTypeAlias typeAlias = ParserTestCase.parse("parseTypeAlias", | 9091 FunctionTypeAlias typeAlias = parse("parseTypeAlias", |
| 9455 <Object>[emptyCommentAndMetadata()], "typedef A<B> F();"); | 9092 <Object>[emptyCommentAndMetadata()], "typedef A<B> F();"); |
| 9456 expect(typeAlias.typedefKeyword, isNotNull); | 9093 expect(typeAlias.typedefKeyword, isNotNull); |
| 9457 expect(typeAlias.name, isNotNull); | 9094 expect(typeAlias.name, isNotNull); |
| 9458 expect(typeAlias.parameters, isNotNull); | 9095 expect(typeAlias.parameters, isNotNull); |
| 9459 expect(typeAlias.returnType, isNotNull); | 9096 expect(typeAlias.returnType, isNotNull); |
| 9460 expect(typeAlias.semicolon, isNotNull); | 9097 expect(typeAlias.semicolon, isNotNull); |
| 9461 expect(typeAlias.typeParameters, isNull); | 9098 expect(typeAlias.typeParameters, isNull); |
| 9462 } | 9099 } |
| 9463 | 9100 |
| 9464 void test_parseTypeAlias_function_parameters() { | 9101 void test_parseTypeAlias_function_parameters() { |
| 9465 FunctionTypeAlias typeAlias = ParserTestCase.parse("parseTypeAlias", | 9102 FunctionTypeAlias typeAlias = parse("parseTypeAlias", |
| 9466 <Object>[emptyCommentAndMetadata()], "typedef bool F(Object value);"); | 9103 <Object>[emptyCommentAndMetadata()], "typedef bool F(Object value);"); |
| 9467 expect(typeAlias.typedefKeyword, isNotNull); | 9104 expect(typeAlias.typedefKeyword, isNotNull); |
| 9468 expect(typeAlias.name, isNotNull); | 9105 expect(typeAlias.name, isNotNull); |
| 9469 expect(typeAlias.parameters, isNotNull); | 9106 expect(typeAlias.parameters, isNotNull); |
| 9470 expect(typeAlias.returnType, isNotNull); | 9107 expect(typeAlias.returnType, isNotNull); |
| 9471 expect(typeAlias.semicolon, isNotNull); | 9108 expect(typeAlias.semicolon, isNotNull); |
| 9472 expect(typeAlias.typeParameters, isNull); | 9109 expect(typeAlias.typeParameters, isNull); |
| 9473 } | 9110 } |
| 9474 | 9111 |
| 9475 void test_parseTypeAlias_function_typeParameters() { | 9112 void test_parseTypeAlias_function_typeParameters() { |
| 9476 FunctionTypeAlias typeAlias = ParserTestCase.parse("parseTypeAlias", | 9113 FunctionTypeAlias typeAlias = parse("parseTypeAlias", |
| 9477 <Object>[emptyCommentAndMetadata()], "typedef bool F<E>();"); | 9114 <Object>[emptyCommentAndMetadata()], "typedef bool F<E>();"); |
| 9478 expect(typeAlias.typedefKeyword, isNotNull); | 9115 expect(typeAlias.typedefKeyword, isNotNull); |
| 9479 expect(typeAlias.name, isNotNull); | 9116 expect(typeAlias.name, isNotNull); |
| 9480 expect(typeAlias.parameters, isNotNull); | 9117 expect(typeAlias.parameters, isNotNull); |
| 9481 expect(typeAlias.returnType, isNotNull); | 9118 expect(typeAlias.returnType, isNotNull); |
| 9482 expect(typeAlias.semicolon, isNotNull); | 9119 expect(typeAlias.semicolon, isNotNull); |
| 9483 expect(typeAlias.typeParameters, isNotNull); | 9120 expect(typeAlias.typeParameters, isNotNull); |
| 9484 } | 9121 } |
| 9485 | 9122 |
| 9486 void test_parseTypeAlias_function_voidReturnType() { | 9123 void test_parseTypeAlias_function_voidReturnType() { |
| 9487 FunctionTypeAlias typeAlias = ParserTestCase.parse("parseTypeAlias", | 9124 FunctionTypeAlias typeAlias = parse("parseTypeAlias", |
| 9488 <Object>[emptyCommentAndMetadata()], "typedef void F();"); | 9125 <Object>[emptyCommentAndMetadata()], "typedef void F();"); |
| 9489 expect(typeAlias.typedefKeyword, isNotNull); | 9126 expect(typeAlias.typedefKeyword, isNotNull); |
| 9490 expect(typeAlias.name, isNotNull); | 9127 expect(typeAlias.name, isNotNull); |
| 9491 expect(typeAlias.parameters, isNotNull); | 9128 expect(typeAlias.parameters, isNotNull); |
| 9492 expect(typeAlias.returnType, isNotNull); | 9129 expect(typeAlias.returnType, isNotNull); |
| 9493 expect(typeAlias.semicolon, isNotNull); | 9130 expect(typeAlias.semicolon, isNotNull); |
| 9494 expect(typeAlias.typeParameters, isNull); | 9131 expect(typeAlias.typeParameters, isNull); |
| 9495 } | 9132 } |
| 9496 | 9133 |
| 9497 void test_parseTypeArgumentList_multiple() { | 9134 void test_parseTypeArgumentList_multiple() { |
| 9498 TypeArgumentList argumentList = | 9135 TypeArgumentList argumentList = |
| 9499 ParserTestCase.parse4("parseTypeArgumentList", "<int, int, int>"); | 9136 parse4("parseTypeArgumentList", "<int, int, int>"); |
| 9500 expect(argumentList.leftBracket, isNotNull); | 9137 expect(argumentList.leftBracket, isNotNull); |
| 9501 expect(argumentList.arguments, hasLength(3)); | 9138 expect(argumentList.arguments, hasLength(3)); |
| 9502 expect(argumentList.rightBracket, isNotNull); | 9139 expect(argumentList.rightBracket, isNotNull); |
| 9503 } | 9140 } |
| 9504 | 9141 |
| 9505 void test_parseTypeArgumentList_nested() { | 9142 void test_parseTypeArgumentList_nested() { |
| 9506 TypeArgumentList argumentList = | 9143 TypeArgumentList argumentList = parse4("parseTypeArgumentList", "<A<B>>"); |
| 9507 ParserTestCase.parse4("parseTypeArgumentList", "<A<B>>"); | |
| 9508 expect(argumentList.leftBracket, isNotNull); | 9144 expect(argumentList.leftBracket, isNotNull); |
| 9509 expect(argumentList.arguments, hasLength(1)); | 9145 expect(argumentList.arguments, hasLength(1)); |
| 9510 TypeName argument = argumentList.arguments[0]; | 9146 TypeName argument = argumentList.arguments[0]; |
| 9511 expect(argument, isNotNull); | 9147 expect(argument, isNotNull); |
| 9512 TypeArgumentList innerList = argument.typeArguments; | 9148 TypeArgumentList innerList = argument.typeArguments; |
| 9513 expect(innerList, isNotNull); | 9149 expect(innerList, isNotNull); |
| 9514 expect(innerList.arguments, hasLength(1)); | 9150 expect(innerList.arguments, hasLength(1)); |
| 9515 expect(argumentList.rightBracket, isNotNull); | 9151 expect(argumentList.rightBracket, isNotNull); |
| 9516 } | 9152 } |
| 9517 | 9153 |
| 9518 void test_parseTypeArgumentList_nested_withComment_double() { | 9154 void test_parseTypeArgumentList_nested_withComment_double() { |
| 9519 TypeArgumentList argumentList = | 9155 TypeArgumentList argumentList = |
| 9520 ParserTestCase.parse4("parseTypeArgumentList", "<A<B /* 0 */ >>"); | 9156 parse4("parseTypeArgumentList", "<A<B /* 0 */ >>"); |
| 9521 expect(argumentList.leftBracket, isNotNull); | 9157 expect(argumentList.leftBracket, isNotNull); |
| 9522 expect(argumentList.rightBracket, isNotNull); | 9158 expect(argumentList.rightBracket, isNotNull); |
| 9523 expect(argumentList.arguments, hasLength(1)); | 9159 expect(argumentList.arguments, hasLength(1)); |
| 9524 | 9160 |
| 9525 TypeName argument = argumentList.arguments[0]; | 9161 TypeName argument = argumentList.arguments[0]; |
| 9526 expect(argument, isNotNull); | 9162 expect(argument, isNotNull); |
| 9527 | 9163 |
| 9528 TypeArgumentList innerList = argument.typeArguments; | 9164 TypeArgumentList innerList = argument.typeArguments; |
| 9529 expect(innerList, isNotNull); | 9165 expect(innerList, isNotNull); |
| 9530 expect(innerList.leftBracket, isNotNull); | 9166 expect(innerList.leftBracket, isNotNull); |
| 9531 expect(innerList.arguments, hasLength(1)); | 9167 expect(innerList.arguments, hasLength(1)); |
| 9532 expect(innerList.rightBracket, isNotNull); | 9168 expect(innerList.rightBracket, isNotNull); |
| 9533 expect(innerList.rightBracket.precedingComments, isNotNull); | 9169 expect(innerList.rightBracket.precedingComments, isNotNull); |
| 9534 } | 9170 } |
| 9535 | 9171 |
| 9536 void test_parseTypeArgumentList_nested_withComment_tripple() { | 9172 void test_parseTypeArgumentList_nested_withComment_tripple() { |
| 9537 TypeArgumentList argumentList = | 9173 TypeArgumentList argumentList = |
| 9538 ParserTestCase.parse4("parseTypeArgumentList", "<A<B<C /* 0 */ >>>"); | 9174 parse4("parseTypeArgumentList", "<A<B<C /* 0 */ >>>"); |
| 9539 expect(argumentList.leftBracket, isNotNull); | 9175 expect(argumentList.leftBracket, isNotNull); |
| 9540 expect(argumentList.rightBracket, isNotNull); | 9176 expect(argumentList.rightBracket, isNotNull); |
| 9541 expect(argumentList.arguments, hasLength(1)); | 9177 expect(argumentList.arguments, hasLength(1)); |
| 9542 | 9178 |
| 9543 TypeName argument = argumentList.arguments[0]; | 9179 TypeName argument = argumentList.arguments[0]; |
| 9544 expect(argument, isNotNull); | 9180 expect(argument, isNotNull); |
| 9545 | 9181 |
| 9546 TypeArgumentList innerList = argument.typeArguments; | 9182 TypeArgumentList innerList = argument.typeArguments; |
| 9547 expect(innerList, isNotNull); | 9183 expect(innerList, isNotNull); |
| 9548 expect(innerList.leftBracket, isNotNull); | 9184 expect(innerList.leftBracket, isNotNull); |
| 9549 expect(innerList.arguments, hasLength(1)); | 9185 expect(innerList.arguments, hasLength(1)); |
| 9550 expect(innerList.rightBracket, isNotNull); | 9186 expect(innerList.rightBracket, isNotNull); |
| 9551 | 9187 |
| 9552 TypeName innerArgument = innerList.arguments[0]; | 9188 TypeName innerArgument = innerList.arguments[0]; |
| 9553 expect(innerArgument, isNotNull); | 9189 expect(innerArgument, isNotNull); |
| 9554 | 9190 |
| 9555 TypeArgumentList innerInnerList = innerArgument.typeArguments; | 9191 TypeArgumentList innerInnerList = innerArgument.typeArguments; |
| 9556 expect(innerInnerList, isNotNull); | 9192 expect(innerInnerList, isNotNull); |
| 9557 expect(innerInnerList.leftBracket, isNotNull); | 9193 expect(innerInnerList.leftBracket, isNotNull); |
| 9558 expect(innerInnerList.arguments, hasLength(1)); | 9194 expect(innerInnerList.arguments, hasLength(1)); |
| 9559 expect(innerInnerList.rightBracket, isNotNull); | 9195 expect(innerInnerList.rightBracket, isNotNull); |
| 9560 expect(innerInnerList.rightBracket.precedingComments, isNotNull); | 9196 expect(innerInnerList.rightBracket.precedingComments, isNotNull); |
| 9561 } | 9197 } |
| 9562 | 9198 |
| 9563 void test_parseTypeArgumentList_single() { | 9199 void test_parseTypeArgumentList_single() { |
| 9564 TypeArgumentList argumentList = | 9200 TypeArgumentList argumentList = parse4("parseTypeArgumentList", "<int>"); |
| 9565 ParserTestCase.parse4("parseTypeArgumentList", "<int>"); | |
| 9566 expect(argumentList.leftBracket, isNotNull); | 9201 expect(argumentList.leftBracket, isNotNull); |
| 9567 expect(argumentList.arguments, hasLength(1)); | 9202 expect(argumentList.arguments, hasLength(1)); |
| 9568 expect(argumentList.rightBracket, isNotNull); | 9203 expect(argumentList.rightBracket, isNotNull); |
| 9569 } | 9204 } |
| 9570 | 9205 |
| 9571 void test_parseTypeName_parameterized() { | 9206 void test_parseTypeName_parameterized() { |
| 9572 TypeName typeName = ParserTestCase.parse4("parseTypeName", "List<int>"); | 9207 TypeName typeName = parse4("parseTypeName", "List<int>"); |
| 9573 expect(typeName.name, isNotNull); | 9208 expect(typeName.name, isNotNull); |
| 9574 expect(typeName.typeArguments, isNotNull); | 9209 expect(typeName.typeArguments, isNotNull); |
| 9575 } | 9210 } |
| 9576 | 9211 |
| 9577 void test_parseTypeName_simple() { | 9212 void test_parseTypeName_simple() { |
| 9578 TypeName typeName = ParserTestCase.parse4("parseTypeName", "int"); | 9213 TypeName typeName = parse4("parseTypeName", "int"); |
| 9579 expect(typeName.name, isNotNull); | 9214 expect(typeName.name, isNotNull); |
| 9580 expect(typeName.typeArguments, isNull); | 9215 expect(typeName.typeArguments, isNull); |
| 9581 } | 9216 } |
| 9582 | 9217 |
| 9583 void test_parseTypeParameter_bounded() { | 9218 void test_parseTypeParameter_bounded() { |
| 9584 TypeParameter parameter = | 9219 TypeParameter parameter = parse4("parseTypeParameter", "A extends B"); |
| 9585 ParserTestCase.parse4("parseTypeParameter", "A extends B"); | |
| 9586 expect(parameter.bound, isNotNull); | 9220 expect(parameter.bound, isNotNull); |
| 9587 expect(parameter.extendsKeyword, isNotNull); | 9221 expect(parameter.extendsKeyword, isNotNull); |
| 9588 expect(parameter.name, isNotNull); | 9222 expect(parameter.name, isNotNull); |
| 9589 } | 9223 } |
| 9590 | 9224 |
| 9591 void test_parseTypeParameter_simple() { | 9225 void test_parseTypeParameter_simple() { |
| 9592 TypeParameter parameter = ParserTestCase.parse4("parseTypeParameter", "A"); | 9226 TypeParameter parameter = parse4("parseTypeParameter", "A"); |
| 9593 expect(parameter.bound, isNull); | 9227 expect(parameter.bound, isNull); |
| 9594 expect(parameter.extendsKeyword, isNull); | 9228 expect(parameter.extendsKeyword, isNull); |
| 9595 expect(parameter.name, isNotNull); | 9229 expect(parameter.name, isNotNull); |
| 9596 } | 9230 } |
| 9597 | 9231 |
| 9598 void test_parseTypeParameterList_multiple() { | 9232 void test_parseTypeParameterList_multiple() { |
| 9599 TypeParameterList parameterList = | 9233 TypeParameterList parameterList = |
| 9600 ParserTestCase.parse4("parseTypeParameterList", "<A, B extends C, D>"); | 9234 parse4("parseTypeParameterList", "<A, B extends C, D>"); |
| 9601 expect(parameterList.leftBracket, isNotNull); | 9235 expect(parameterList.leftBracket, isNotNull); |
| 9602 expect(parameterList.rightBracket, isNotNull); | 9236 expect(parameterList.rightBracket, isNotNull); |
| 9603 expect(parameterList.typeParameters, hasLength(3)); | 9237 expect(parameterList.typeParameters, hasLength(3)); |
| 9604 } | 9238 } |
| 9605 | 9239 |
| 9606 void test_parseTypeParameterList_parameterizedWithTrailingEquals() { | 9240 void test_parseTypeParameterList_parameterizedWithTrailingEquals() { |
| 9607 TypeParameterList parameterList = | 9241 TypeParameterList parameterList = |
| 9608 ParserTestCase.parse4("parseTypeParameterList", "<A extends B<E>>="); | 9242 parse4("parseTypeParameterList", "<A extends B<E>>="); |
| 9609 expect(parameterList.leftBracket, isNotNull); | 9243 expect(parameterList.leftBracket, isNotNull); |
| 9610 expect(parameterList.rightBracket, isNotNull); | 9244 expect(parameterList.rightBracket, isNotNull); |
| 9611 expect(parameterList.typeParameters, hasLength(1)); | 9245 expect(parameterList.typeParameters, hasLength(1)); |
| 9612 } | 9246 } |
| 9613 | 9247 |
| 9614 void test_parseTypeParameterList_single() { | 9248 void test_parseTypeParameterList_single() { |
| 9615 TypeParameterList parameterList = | 9249 TypeParameterList parameterList = parse4("parseTypeParameterList", "<A>"); |
| 9616 ParserTestCase.parse4("parseTypeParameterList", "<A>"); | |
| 9617 expect(parameterList.leftBracket, isNotNull); | 9250 expect(parameterList.leftBracket, isNotNull); |
| 9618 expect(parameterList.rightBracket, isNotNull); | 9251 expect(parameterList.rightBracket, isNotNull); |
| 9619 expect(parameterList.typeParameters, hasLength(1)); | 9252 expect(parameterList.typeParameters, hasLength(1)); |
| 9620 } | 9253 } |
| 9621 | 9254 |
| 9622 void test_parseTypeParameterList_withTrailingEquals() { | 9255 void test_parseTypeParameterList_withTrailingEquals() { |
| 9623 TypeParameterList parameterList = | 9256 TypeParameterList parameterList = parse4("parseTypeParameterList", "<A>="); |
| 9624 ParserTestCase.parse4("parseTypeParameterList", "<A>="); | |
| 9625 expect(parameterList.leftBracket, isNotNull); | 9257 expect(parameterList.leftBracket, isNotNull); |
| 9626 expect(parameterList.rightBracket, isNotNull); | 9258 expect(parameterList.rightBracket, isNotNull); |
| 9627 expect(parameterList.typeParameters, hasLength(1)); | 9259 expect(parameterList.typeParameters, hasLength(1)); |
| 9628 } | 9260 } |
| 9629 | 9261 |
| 9630 void test_parseUnaryExpression_decrement_normal() { | 9262 void test_parseUnaryExpression_decrement_normal() { |
| 9631 PrefixExpression expression = | 9263 PrefixExpression expression = parse4("parseUnaryExpression", "--x"); |
| 9632 ParserTestCase.parse4("parseUnaryExpression", "--x"); | |
| 9633 expect(expression.operator, isNotNull); | 9264 expect(expression.operator, isNotNull); |
| 9634 expect(expression.operator.type, TokenType.MINUS_MINUS); | 9265 expect(expression.operator.type, TokenType.MINUS_MINUS); |
| 9635 expect(expression.operand, isNotNull); | 9266 expect(expression.operand, isNotNull); |
| 9636 } | 9267 } |
| 9637 | 9268 |
| 9638 void test_parseUnaryExpression_decrement_super() { | 9269 void test_parseUnaryExpression_decrement_super() { |
| 9639 PrefixExpression expression = | 9270 PrefixExpression expression = parse4("parseUnaryExpression", "--super"); |
| 9640 ParserTestCase.parse4("parseUnaryExpression", "--super"); | |
| 9641 expect(expression.operator, isNotNull); | 9271 expect(expression.operator, isNotNull); |
| 9642 expect(expression.operator.type, TokenType.MINUS); | 9272 expect(expression.operator.type, TokenType.MINUS); |
| 9643 Expression innerExpression = expression.operand; | 9273 Expression innerExpression = expression.operand; |
| 9644 expect(innerExpression, isNotNull); | 9274 expect(innerExpression, isNotNull); |
| 9645 expect(innerExpression is PrefixExpression, isTrue); | 9275 expect(innerExpression is PrefixExpression, isTrue); |
| 9646 PrefixExpression operand = innerExpression as PrefixExpression; | 9276 PrefixExpression operand = innerExpression as PrefixExpression; |
| 9647 expect(operand.operator, isNotNull); | 9277 expect(operand.operator, isNotNull); |
| 9648 expect(operand.operator.type, TokenType.MINUS); | 9278 expect(operand.operator.type, TokenType.MINUS); |
| 9649 expect(operand.operand, isNotNull); | 9279 expect(operand.operand, isNotNull); |
| 9650 } | 9280 } |
| 9651 | 9281 |
| 9652 void test_parseUnaryExpression_decrement_super_propertyAccess() { | 9282 void test_parseUnaryExpression_decrement_super_propertyAccess() { |
| 9653 PrefixExpression expression = | 9283 PrefixExpression expression = parse4("parseUnaryExpression", "--super.x"); |
| 9654 ParserTestCase.parse4("parseUnaryExpression", "--super.x"); | |
| 9655 expect(expression.operator, isNotNull); | 9284 expect(expression.operator, isNotNull); |
| 9656 expect(expression.operator.type, TokenType.MINUS_MINUS); | 9285 expect(expression.operator.type, TokenType.MINUS_MINUS); |
| 9657 expect(expression.operand, isNotNull); | 9286 expect(expression.operand, isNotNull); |
| 9658 PropertyAccess operand = expression.operand as PropertyAccess; | 9287 PropertyAccess operand = expression.operand as PropertyAccess; |
| 9659 expect(operand.target is SuperExpression, isTrue); | 9288 expect(operand.target is SuperExpression, isTrue); |
| 9660 expect(operand.propertyName.name, "x"); | 9289 expect(operand.propertyName.name, "x"); |
| 9661 } | 9290 } |
| 9662 | 9291 |
| 9663 void test_parseUnaryExpression_decrement_super_withComment() { | 9292 void test_parseUnaryExpression_decrement_super_withComment() { |
| 9664 PrefixExpression expression = | 9293 PrefixExpression expression = |
| 9665 ParserTestCase.parse4("parseUnaryExpression", "/* 0 */ --super"); | 9294 parse4("parseUnaryExpression", "/* 0 */ --super"); |
| 9666 expect(expression.operator, isNotNull); | 9295 expect(expression.operator, isNotNull); |
| 9667 expect(expression.operator.type, TokenType.MINUS); | 9296 expect(expression.operator.type, TokenType.MINUS); |
| 9668 expect(expression.operator.precedingComments, isNotNull); | 9297 expect(expression.operator.precedingComments, isNotNull); |
| 9669 Expression innerExpression = expression.operand; | 9298 Expression innerExpression = expression.operand; |
| 9670 expect(innerExpression, isNotNull); | 9299 expect(innerExpression, isNotNull); |
| 9671 expect(innerExpression is PrefixExpression, isTrue); | 9300 expect(innerExpression is PrefixExpression, isTrue); |
| 9672 PrefixExpression operand = innerExpression as PrefixExpression; | 9301 PrefixExpression operand = innerExpression as PrefixExpression; |
| 9673 expect(operand.operator, isNotNull); | 9302 expect(operand.operator, isNotNull); |
| 9674 expect(operand.operator.type, TokenType.MINUS); | 9303 expect(operand.operator.type, TokenType.MINUS); |
| 9675 expect(operand.operand, isNotNull); | 9304 expect(operand.operand, isNotNull); |
| 9676 } | 9305 } |
| 9677 | 9306 |
| 9678 void test_parseUnaryExpression_increment_normal() { | 9307 void test_parseUnaryExpression_increment_normal() { |
| 9679 PrefixExpression expression = | 9308 PrefixExpression expression = parse4("parseUnaryExpression", "++x"); |
| 9680 ParserTestCase.parse4("parseUnaryExpression", "++x"); | |
| 9681 expect(expression.operator, isNotNull); | 9309 expect(expression.operator, isNotNull); |
| 9682 expect(expression.operator.type, TokenType.PLUS_PLUS); | 9310 expect(expression.operator.type, TokenType.PLUS_PLUS); |
| 9683 expect(expression.operand, isNotNull); | 9311 expect(expression.operand, isNotNull); |
| 9684 } | 9312 } |
| 9685 | 9313 |
| 9686 void test_parseUnaryExpression_increment_super_index() { | 9314 void test_parseUnaryExpression_increment_super_index() { |
| 9687 PrefixExpression expression = | 9315 PrefixExpression expression = parse4("parseUnaryExpression", "++super[0]"); |
| 9688 ParserTestCase.parse4("parseUnaryExpression", "++super[0]"); | |
| 9689 expect(expression.operator, isNotNull); | 9316 expect(expression.operator, isNotNull); |
| 9690 expect(expression.operator.type, TokenType.PLUS_PLUS); | 9317 expect(expression.operator.type, TokenType.PLUS_PLUS); |
| 9691 expect(expression.operand, isNotNull); | 9318 expect(expression.operand, isNotNull); |
| 9692 IndexExpression operand = expression.operand as IndexExpression; | 9319 IndexExpression operand = expression.operand as IndexExpression; |
| 9693 expect(operand.realTarget is SuperExpression, isTrue); | 9320 expect(operand.realTarget is SuperExpression, isTrue); |
| 9694 expect(operand.index is IntegerLiteral, isTrue); | 9321 expect(operand.index is IntegerLiteral, isTrue); |
| 9695 } | 9322 } |
| 9696 | 9323 |
| 9697 void test_parseUnaryExpression_increment_super_propertyAccess() { | 9324 void test_parseUnaryExpression_increment_super_propertyAccess() { |
| 9698 PrefixExpression expression = | 9325 PrefixExpression expression = parse4("parseUnaryExpression", "++super.x"); |
| 9699 ParserTestCase.parse4("parseUnaryExpression", "++super.x"); | |
| 9700 expect(expression.operator, isNotNull); | 9326 expect(expression.operator, isNotNull); |
| 9701 expect(expression.operator.type, TokenType.PLUS_PLUS); | 9327 expect(expression.operator.type, TokenType.PLUS_PLUS); |
| 9702 expect(expression.operand, isNotNull); | 9328 expect(expression.operand, isNotNull); |
| 9703 PropertyAccess operand = expression.operand as PropertyAccess; | 9329 PropertyAccess operand = expression.operand as PropertyAccess; |
| 9704 expect(operand.target is SuperExpression, isTrue); | 9330 expect(operand.target is SuperExpression, isTrue); |
| 9705 expect(operand.propertyName.name, "x"); | 9331 expect(operand.propertyName.name, "x"); |
| 9706 } | 9332 } |
| 9707 | 9333 |
| 9708 void test_parseUnaryExpression_minus_normal() { | 9334 void test_parseUnaryExpression_minus_normal() { |
| 9709 PrefixExpression expression = | 9335 PrefixExpression expression = parse4("parseUnaryExpression", "-x"); |
| 9710 ParserTestCase.parse4("parseUnaryExpression", "-x"); | |
| 9711 expect(expression.operator, isNotNull); | 9336 expect(expression.operator, isNotNull); |
| 9712 expect(expression.operator.type, TokenType.MINUS); | 9337 expect(expression.operator.type, TokenType.MINUS); |
| 9713 expect(expression.operand, isNotNull); | 9338 expect(expression.operand, isNotNull); |
| 9714 } | 9339 } |
| 9715 | 9340 |
| 9716 void test_parseUnaryExpression_minus_super() { | 9341 void test_parseUnaryExpression_minus_super() { |
| 9717 PrefixExpression expression = | 9342 PrefixExpression expression = parse4("parseUnaryExpression", "-super"); |
| 9718 ParserTestCase.parse4("parseUnaryExpression", "-super"); | |
| 9719 expect(expression.operator, isNotNull); | 9343 expect(expression.operator, isNotNull); |
| 9720 expect(expression.operator.type, TokenType.MINUS); | 9344 expect(expression.operator.type, TokenType.MINUS); |
| 9721 expect(expression.operand, isNotNull); | 9345 expect(expression.operand, isNotNull); |
| 9722 } | 9346 } |
| 9723 | 9347 |
| 9724 void test_parseUnaryExpression_not_normal() { | 9348 void test_parseUnaryExpression_not_normal() { |
| 9725 PrefixExpression expression = | 9349 PrefixExpression expression = parse4("parseUnaryExpression", "!x"); |
| 9726 ParserTestCase.parse4("parseUnaryExpression", "!x"); | |
| 9727 expect(expression.operator, isNotNull); | 9350 expect(expression.operator, isNotNull); |
| 9728 expect(expression.operator.type, TokenType.BANG); | 9351 expect(expression.operator.type, TokenType.BANG); |
| 9729 expect(expression.operand, isNotNull); | 9352 expect(expression.operand, isNotNull); |
| 9730 } | 9353 } |
| 9731 | 9354 |
| 9732 void test_parseUnaryExpression_not_super() { | 9355 void test_parseUnaryExpression_not_super() { |
| 9733 PrefixExpression expression = | 9356 PrefixExpression expression = parse4("parseUnaryExpression", "!super"); |
| 9734 ParserTestCase.parse4("parseUnaryExpression", "!super"); | |
| 9735 expect(expression.operator, isNotNull); | 9357 expect(expression.operator, isNotNull); |
| 9736 expect(expression.operator.type, TokenType.BANG); | 9358 expect(expression.operator.type, TokenType.BANG); |
| 9737 expect(expression.operand, isNotNull); | 9359 expect(expression.operand, isNotNull); |
| 9738 } | 9360 } |
| 9739 | 9361 |
| 9740 void test_parseUnaryExpression_tilda_normal() { | 9362 void test_parseUnaryExpression_tilda_normal() { |
| 9741 PrefixExpression expression = | 9363 PrefixExpression expression = parse4("parseUnaryExpression", "~x"); |
| 9742 ParserTestCase.parse4("parseUnaryExpression", "~x"); | |
| 9743 expect(expression.operator, isNotNull); | 9364 expect(expression.operator, isNotNull); |
| 9744 expect(expression.operator.type, TokenType.TILDE); | 9365 expect(expression.operator.type, TokenType.TILDE); |
| 9745 expect(expression.operand, isNotNull); | 9366 expect(expression.operand, isNotNull); |
| 9746 } | 9367 } |
| 9747 | 9368 |
| 9748 void test_parseUnaryExpression_tilda_super() { | 9369 void test_parseUnaryExpression_tilda_super() { |
| 9749 PrefixExpression expression = | 9370 PrefixExpression expression = parse4("parseUnaryExpression", "~super"); |
| 9750 ParserTestCase.parse4("parseUnaryExpression", "~super"); | |
| 9751 expect(expression.operator, isNotNull); | 9371 expect(expression.operator, isNotNull); |
| 9752 expect(expression.operator.type, TokenType.TILDE); | 9372 expect(expression.operator.type, TokenType.TILDE); |
| 9753 expect(expression.operand, isNotNull); | 9373 expect(expression.operand, isNotNull); |
| 9754 } | 9374 } |
| 9755 | 9375 |
| 9756 void test_parseVariableDeclaration_equals() { | 9376 void test_parseVariableDeclaration_equals() { |
| 9757 VariableDeclaration declaration = | 9377 VariableDeclaration declaration = |
| 9758 ParserTestCase.parse4("parseVariableDeclaration", "a = b"); | 9378 parse4("parseVariableDeclaration", "a = b"); |
| 9759 expect(declaration.name, isNotNull); | 9379 expect(declaration.name, isNotNull); |
| 9760 expect(declaration.equals, isNotNull); | 9380 expect(declaration.equals, isNotNull); |
| 9761 expect(declaration.initializer, isNotNull); | 9381 expect(declaration.initializer, isNotNull); |
| 9762 } | 9382 } |
| 9763 | 9383 |
| 9764 void test_parseVariableDeclaration_noEquals() { | 9384 void test_parseVariableDeclaration_noEquals() { |
| 9765 VariableDeclaration declaration = | 9385 VariableDeclaration declaration = parse4("parseVariableDeclaration", "a"); |
| 9766 ParserTestCase.parse4("parseVariableDeclaration", "a"); | |
| 9767 expect(declaration.name, isNotNull); | 9386 expect(declaration.name, isNotNull); |
| 9768 expect(declaration.equals, isNull); | 9387 expect(declaration.equals, isNull); |
| 9769 expect(declaration.initializer, isNull); | 9388 expect(declaration.initializer, isNull); |
| 9770 } | 9389 } |
| 9771 | 9390 |
| 9772 void test_parseVariableDeclarationListAfterMetadata_const_noType() { | 9391 void test_parseVariableDeclarationListAfterMetadata_const_noType() { |
| 9773 VariableDeclarationList declarationList = ParserTestCase.parse( | 9392 VariableDeclarationList declarationList = parse( |
| 9774 "parseVariableDeclarationListAfterMetadata", <Object>[ | 9393 "parseVariableDeclarationListAfterMetadata", |
| 9775 emptyCommentAndMetadata() | 9394 <Object>[emptyCommentAndMetadata()], "const a"); |
| 9776 ], "const a"); | |
| 9777 expect(declarationList.keyword, isNotNull); | 9395 expect(declarationList.keyword, isNotNull); |
| 9778 expect(declarationList.type, isNull); | 9396 expect(declarationList.type, isNull); |
| 9779 expect(declarationList.variables, hasLength(1)); | 9397 expect(declarationList.variables, hasLength(1)); |
| 9780 } | 9398 } |
| 9781 | 9399 |
| 9782 void test_parseVariableDeclarationListAfterMetadata_const_type() { | 9400 void test_parseVariableDeclarationListAfterMetadata_const_type() { |
| 9783 VariableDeclarationList declarationList = ParserTestCase.parse( | 9401 VariableDeclarationList declarationList = parse( |
| 9784 "parseVariableDeclarationListAfterMetadata", <Object>[ | 9402 "parseVariableDeclarationListAfterMetadata", |
| 9785 emptyCommentAndMetadata() | 9403 <Object>[emptyCommentAndMetadata()], "const A a"); |
| 9786 ], "const A a"); | |
| 9787 expect(declarationList.keyword, isNotNull); | 9404 expect(declarationList.keyword, isNotNull); |
| 9788 expect(declarationList.type, isNotNull); | 9405 expect(declarationList.type, isNotNull); |
| 9789 expect(declarationList.variables, hasLength(1)); | 9406 expect(declarationList.variables, hasLength(1)); |
| 9790 } | 9407 } |
| 9791 | 9408 |
| 9792 void test_parseVariableDeclarationListAfterMetadata_final_noType() { | 9409 void test_parseVariableDeclarationListAfterMetadata_final_noType() { |
| 9793 VariableDeclarationList declarationList = ParserTestCase.parse( | 9410 VariableDeclarationList declarationList = parse( |
| 9794 "parseVariableDeclarationListAfterMetadata", <Object>[ | 9411 "parseVariableDeclarationListAfterMetadata", |
| 9795 emptyCommentAndMetadata() | 9412 <Object>[emptyCommentAndMetadata()], "final a"); |
| 9796 ], "final a"); | |
| 9797 expect(declarationList.keyword, isNotNull); | 9413 expect(declarationList.keyword, isNotNull); |
| 9798 expect(declarationList.type, isNull); | 9414 expect(declarationList.type, isNull); |
| 9799 expect(declarationList.variables, hasLength(1)); | 9415 expect(declarationList.variables, hasLength(1)); |
| 9800 } | 9416 } |
| 9801 | 9417 |
| 9802 void test_parseVariableDeclarationListAfterMetadata_final_type() { | 9418 void test_parseVariableDeclarationListAfterMetadata_final_type() { |
| 9803 VariableDeclarationList declarationList = ParserTestCase.parse( | 9419 VariableDeclarationList declarationList = parse( |
| 9804 "parseVariableDeclarationListAfterMetadata", <Object>[ | 9420 "parseVariableDeclarationListAfterMetadata", |
| 9805 emptyCommentAndMetadata() | 9421 <Object>[emptyCommentAndMetadata()], "final A a"); |
| 9806 ], "final A a"); | |
| 9807 expect(declarationList.keyword, isNotNull); | 9422 expect(declarationList.keyword, isNotNull); |
| 9808 expect(declarationList.type, isNotNull); | 9423 expect(declarationList.type, isNotNull); |
| 9809 expect(declarationList.variables, hasLength(1)); | 9424 expect(declarationList.variables, hasLength(1)); |
| 9810 } | 9425 } |
| 9811 | 9426 |
| 9812 void test_parseVariableDeclarationListAfterMetadata_type_multiple() { | 9427 void test_parseVariableDeclarationListAfterMetadata_type_multiple() { |
| 9813 VariableDeclarationList declarationList = ParserTestCase.parse( | 9428 VariableDeclarationList declarationList = parse( |
| 9814 "parseVariableDeclarationListAfterMetadata", <Object>[ | 9429 "parseVariableDeclarationListAfterMetadata", |
| 9815 emptyCommentAndMetadata() | 9430 <Object>[emptyCommentAndMetadata()], "A a, b, c"); |
| 9816 ], "A a, b, c"); | |
| 9817 expect(declarationList.keyword, isNull); | 9431 expect(declarationList.keyword, isNull); |
| 9818 expect(declarationList.type, isNotNull); | 9432 expect(declarationList.type, isNotNull); |
| 9819 expect(declarationList.variables, hasLength(3)); | 9433 expect(declarationList.variables, hasLength(3)); |
| 9820 } | 9434 } |
| 9821 | 9435 |
| 9822 void test_parseVariableDeclarationListAfterMetadata_type_single() { | 9436 void test_parseVariableDeclarationListAfterMetadata_type_single() { |
| 9823 VariableDeclarationList declarationList = ParserTestCase.parse( | 9437 VariableDeclarationList declarationList = parse( |
| 9824 "parseVariableDeclarationListAfterMetadata", <Object>[ | 9438 "parseVariableDeclarationListAfterMetadata", |
| 9825 emptyCommentAndMetadata() | 9439 <Object>[emptyCommentAndMetadata()], "A a"); |
| 9826 ], "A a"); | |
| 9827 expect(declarationList.keyword, isNull); | 9440 expect(declarationList.keyword, isNull); |
| 9828 expect(declarationList.type, isNotNull); | 9441 expect(declarationList.type, isNotNull); |
| 9829 expect(declarationList.variables, hasLength(1)); | 9442 expect(declarationList.variables, hasLength(1)); |
| 9830 } | 9443 } |
| 9831 | 9444 |
| 9832 void test_parseVariableDeclarationListAfterMetadata_var_multiple() { | 9445 void test_parseVariableDeclarationListAfterMetadata_var_multiple() { |
| 9833 VariableDeclarationList declarationList = ParserTestCase.parse( | 9446 VariableDeclarationList declarationList = parse( |
| 9834 "parseVariableDeclarationListAfterMetadata", <Object>[ | 9447 "parseVariableDeclarationListAfterMetadata", |
| 9835 emptyCommentAndMetadata() | 9448 <Object>[emptyCommentAndMetadata()], "var a, b, c"); |
| 9836 ], "var a, b, c"); | |
| 9837 expect(declarationList.keyword, isNotNull); | 9449 expect(declarationList.keyword, isNotNull); |
| 9838 expect(declarationList.type, isNull); | 9450 expect(declarationList.type, isNull); |
| 9839 expect(declarationList.variables, hasLength(3)); | 9451 expect(declarationList.variables, hasLength(3)); |
| 9840 } | 9452 } |
| 9841 | 9453 |
| 9842 void test_parseVariableDeclarationListAfterMetadata_var_single() { | 9454 void test_parseVariableDeclarationListAfterMetadata_var_single() { |
| 9843 VariableDeclarationList declarationList = ParserTestCase.parse( | 9455 VariableDeclarationList declarationList = parse( |
| 9844 "parseVariableDeclarationListAfterMetadata", <Object>[ | 9456 "parseVariableDeclarationListAfterMetadata", |
| 9845 emptyCommentAndMetadata() | 9457 <Object>[emptyCommentAndMetadata()], "var a"); |
| 9846 ], "var a"); | |
| 9847 expect(declarationList.keyword, isNotNull); | 9458 expect(declarationList.keyword, isNotNull); |
| 9848 expect(declarationList.type, isNull); | 9459 expect(declarationList.type, isNull); |
| 9849 expect(declarationList.variables, hasLength(1)); | 9460 expect(declarationList.variables, hasLength(1)); |
| 9850 } | 9461 } |
| 9851 | 9462 |
| 9852 void test_parseVariableDeclarationListAfterType_type() { | 9463 void test_parseVariableDeclarationListAfterType_type() { |
| 9853 TypeName type = new TypeName(new SimpleIdentifier(null), null); | 9464 TypeName type = new TypeName(new SimpleIdentifier(null), null); |
| 9854 VariableDeclarationList declarationList = ParserTestCase.parse( | 9465 VariableDeclarationList declarationList = parse( |
| 9855 "parseVariableDeclarationListAfterType", <Object>[ | 9466 "parseVariableDeclarationListAfterType", <Object>[ |
| 9856 emptyCommentAndMetadata(), | 9467 emptyCommentAndMetadata(), |
| 9857 null, | 9468 null, |
| 9858 type | 9469 type |
| 9859 ], "a"); | 9470 ], "a"); |
| 9860 expect(declarationList.keyword, isNull); | 9471 expect(declarationList.keyword, isNull); |
| 9861 expect(declarationList.type, type); | 9472 expect(declarationList.type, type); |
| 9862 expect(declarationList.variables, hasLength(1)); | 9473 expect(declarationList.variables, hasLength(1)); |
| 9863 } | 9474 } |
| 9864 | 9475 |
| 9865 void test_parseVariableDeclarationListAfterType_var() { | 9476 void test_parseVariableDeclarationListAfterType_var() { |
| 9866 Token keyword = TokenFactory.tokenFromKeyword(Keyword.VAR); | 9477 Token keyword = TokenFactory.tokenFromKeyword(Keyword.VAR); |
| 9867 VariableDeclarationList declarationList = ParserTestCase.parse( | 9478 VariableDeclarationList declarationList = parse( |
| 9868 "parseVariableDeclarationListAfterType", <Object>[ | 9479 "parseVariableDeclarationListAfterType", <Object>[ |
| 9869 emptyCommentAndMetadata(), | 9480 emptyCommentAndMetadata(), |
| 9870 keyword, | 9481 keyword, |
| 9871 null | 9482 null |
| 9872 ], "a, b, c"); | 9483 ], "a, b, c"); |
| 9873 expect(declarationList.keyword, keyword); | 9484 expect(declarationList.keyword, keyword); |
| 9874 expect(declarationList.type, isNull); | 9485 expect(declarationList.type, isNull); |
| 9875 expect(declarationList.variables, hasLength(3)); | 9486 expect(declarationList.variables, hasLength(3)); |
| 9876 } | 9487 } |
| 9877 | 9488 |
| 9878 void test_parseVariableDeclarationStatementAfterMetadata_multiple() { | 9489 void test_parseVariableDeclarationStatementAfterMetadata_multiple() { |
| 9879 VariableDeclarationStatement statement = ParserTestCase.parse( | 9490 VariableDeclarationStatement statement = parse( |
| 9880 "parseVariableDeclarationStatementAfterMetadata", <Object>[ | 9491 "parseVariableDeclarationStatementAfterMetadata", |
| 9881 emptyCommentAndMetadata() | 9492 <Object>[emptyCommentAndMetadata()], "var x, y, z;"); |
| 9882 ], "var x, y, z;"); | |
| 9883 expect(statement.semicolon, isNotNull); | 9493 expect(statement.semicolon, isNotNull); |
| 9884 VariableDeclarationList variableList = statement.variables; | 9494 VariableDeclarationList variableList = statement.variables; |
| 9885 expect(variableList, isNotNull); | 9495 expect(variableList, isNotNull); |
| 9886 expect(variableList.variables, hasLength(3)); | 9496 expect(variableList.variables, hasLength(3)); |
| 9887 } | 9497 } |
| 9888 | 9498 |
| 9889 void test_parseVariableDeclarationStatementAfterMetadata_single() { | 9499 void test_parseVariableDeclarationStatementAfterMetadata_single() { |
| 9890 VariableDeclarationStatement statement = ParserTestCase.parse( | 9500 VariableDeclarationStatement statement = parse( |
| 9891 "parseVariableDeclarationStatementAfterMetadata", <Object>[ | 9501 "parseVariableDeclarationStatementAfterMetadata", |
| 9892 emptyCommentAndMetadata() | 9502 <Object>[emptyCommentAndMetadata()], "var x;"); |
| 9893 ], "var x;"); | |
| 9894 expect(statement.semicolon, isNotNull); | 9503 expect(statement.semicolon, isNotNull); |
| 9895 VariableDeclarationList variableList = statement.variables; | 9504 VariableDeclarationList variableList = statement.variables; |
| 9896 expect(variableList, isNotNull); | 9505 expect(variableList, isNotNull); |
| 9897 expect(variableList.variables, hasLength(1)); | 9506 expect(variableList.variables, hasLength(1)); |
| 9898 } | 9507 } |
| 9899 | 9508 |
| 9900 void test_parseWhileStatement() { | 9509 void test_parseWhileStatement() { |
| 9901 WhileStatement statement = | 9510 WhileStatement statement = parse4("parseWhileStatement", "while (x) {}"); |
| 9902 ParserTestCase.parse4("parseWhileStatement", "while (x) {}"); | |
| 9903 expect(statement.whileKeyword, isNotNull); | 9511 expect(statement.whileKeyword, isNotNull); |
| 9904 expect(statement.leftParenthesis, isNotNull); | 9512 expect(statement.leftParenthesis, isNotNull); |
| 9905 expect(statement.condition, isNotNull); | 9513 expect(statement.condition, isNotNull); |
| 9906 expect(statement.rightParenthesis, isNotNull); | 9514 expect(statement.rightParenthesis, isNotNull); |
| 9907 expect(statement.body, isNotNull); | 9515 expect(statement.body, isNotNull); |
| 9908 } | 9516 } |
| 9909 | 9517 |
| 9910 void test_parseWithClause_multiple() { | 9518 void test_parseWithClause_multiple() { |
| 9911 WithClause clause = | 9519 WithClause clause = parse4("parseWithClause", "with A, B, C"); |
| 9912 ParserTestCase.parse4("parseWithClause", "with A, B, C"); | |
| 9913 expect(clause.withKeyword, isNotNull); | 9520 expect(clause.withKeyword, isNotNull); |
| 9914 expect(clause.mixinTypes, hasLength(3)); | 9521 expect(clause.mixinTypes, hasLength(3)); |
| 9915 } | 9522 } |
| 9916 | 9523 |
| 9917 void test_parseWithClause_single() { | 9524 void test_parseWithClause_single() { |
| 9918 WithClause clause = ParserTestCase.parse4("parseWithClause", "with M"); | 9525 WithClause clause = parse4("parseWithClause", "with M"); |
| 9919 expect(clause.withKeyword, isNotNull); | 9526 expect(clause.withKeyword, isNotNull); |
| 9920 expect(clause.mixinTypes, hasLength(1)); | 9527 expect(clause.mixinTypes, hasLength(1)); |
| 9921 } | 9528 } |
| 9922 | 9529 |
| 9923 void test_parseYieldStatement_each() { | 9530 void test_parseYieldStatement_each() { |
| 9924 YieldStatement statement = | 9531 YieldStatement statement = parse4("parseYieldStatement", "yield* x;"); |
| 9925 ParserTestCase.parse4("parseYieldStatement", "yield* x;"); | |
| 9926 expect(statement.yieldKeyword, isNotNull); | 9532 expect(statement.yieldKeyword, isNotNull); |
| 9927 expect(statement.star, isNotNull); | 9533 expect(statement.star, isNotNull); |
| 9928 expect(statement.expression, isNotNull); | 9534 expect(statement.expression, isNotNull); |
| 9929 expect(statement.semicolon, isNotNull); | 9535 expect(statement.semicolon, isNotNull); |
| 9930 } | 9536 } |
| 9931 | 9537 |
| 9932 void test_parseYieldStatement_normal() { | 9538 void test_parseYieldStatement_normal() { |
| 9933 YieldStatement statement = | 9539 YieldStatement statement = parse4("parseYieldStatement", "yield x;"); |
| 9934 ParserTestCase.parse4("parseYieldStatement", "yield x;"); | |
| 9935 expect(statement.yieldKeyword, isNotNull); | 9540 expect(statement.yieldKeyword, isNotNull); |
| 9936 expect(statement.star, isNull); | 9541 expect(statement.star, isNull); |
| 9937 expect(statement.expression, isNotNull); | 9542 expect(statement.expression, isNotNull); |
| 9938 expect(statement.semicolon, isNotNull); | 9543 expect(statement.semicolon, isNotNull); |
| 9939 } | 9544 } |
| 9940 | 9545 |
| 9941 void test_skipPrefixedIdentifier_invalid() { | 9546 void test_skipPrefixedIdentifier_invalid() { |
| 9942 Token following = _skip("skipPrefixedIdentifier", "+"); | 9547 Token following = _skip("skipPrefixedIdentifier", "+"); |
| 9943 expect(following, isNull); | 9548 expect(following, isNull); |
| 9944 } | 9549 } |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10069 /** | 9674 /** |
| 10070 * Invoke the method [Parser.createSyntheticIdentifier] with the parser set to
the token | 9675 * Invoke the method [Parser.createSyntheticIdentifier] with the parser set to
the token |
| 10071 * stream produced by scanning the given source. | 9676 * stream produced by scanning the given source. |
| 10072 * | 9677 * |
| 10073 * @param source the source to be scanned to produce the token stream being te
sted | 9678 * @param source the source to be scanned to produce the token stream being te
sted |
| 10074 * @return the result of invoking the method | 9679 * @return the result of invoking the method |
| 10075 * @throws Exception if the method could not be invoked or throws an exception | 9680 * @throws Exception if the method could not be invoked or throws an exception |
| 10076 */ | 9681 */ |
| 10077 SimpleIdentifier _createSyntheticIdentifier() { | 9682 SimpleIdentifier _createSyntheticIdentifier() { |
| 10078 GatheringErrorListener listener = new GatheringErrorListener(); | 9683 GatheringErrorListener listener = new GatheringErrorListener(); |
| 10079 return ParserTestCase.invokeParserMethod2( | 9684 return invokeParserMethod2("createSyntheticIdentifier", "", listener); |
| 10080 "createSyntheticIdentifier", "", listener); | |
| 10081 } | 9685 } |
| 10082 | 9686 |
| 10083 /** | 9687 /** |
| 10084 * Invoke the method [Parser.createSyntheticIdentifier] with the parser set to
the token | 9688 * Invoke the method [Parser.createSyntheticIdentifier] with the parser set to
the token |
| 10085 * stream produced by scanning the given source. | 9689 * stream produced by scanning the given source. |
| 10086 * | 9690 * |
| 10087 * @param source the source to be scanned to produce the token stream being te
sted | 9691 * @param source the source to be scanned to produce the token stream being te
sted |
| 10088 * @return the result of invoking the method | 9692 * @return the result of invoking the method |
| 10089 * @throws Exception if the method could not be invoked or throws an exception | 9693 * @throws Exception if the method could not be invoked or throws an exception |
| 10090 */ | 9694 */ |
| 10091 SimpleStringLiteral _createSyntheticStringLiteral() { | 9695 SimpleStringLiteral _createSyntheticStringLiteral() { |
| 10092 GatheringErrorListener listener = new GatheringErrorListener(); | 9696 GatheringErrorListener listener = new GatheringErrorListener(); |
| 10093 return ParserTestCase.invokeParserMethod2( | 9697 return invokeParserMethod2("createSyntheticStringLiteral", "", listener); |
| 10094 "createSyntheticStringLiteral", "", listener); | |
| 10095 } | 9698 } |
| 10096 | 9699 |
| 10097 /** | 9700 /** |
| 10098 * Invoke the method [Parser.isFunctionDeclaration] with the parser set to the
token | 9701 * Invoke the method [Parser.isFunctionDeclaration] with the parser set to the
token |
| 10099 * stream produced by scanning the given source. | 9702 * stream produced by scanning the given source. |
| 10100 * | 9703 * |
| 10101 * @param source the source to be scanned to produce the token stream being te
sted | 9704 * @param source the source to be scanned to produce the token stream being te
sted |
| 10102 * @return the result of invoking the method | 9705 * @return the result of invoking the method |
| 10103 * @throws Exception if the method could not be invoked or throws an exception | 9706 * @throws Exception if the method could not be invoked or throws an exception |
| 10104 */ | 9707 */ |
| 10105 bool _isFunctionDeclaration(String source) { | 9708 bool _isFunctionDeclaration(String source) { |
| 10106 GatheringErrorListener listener = new GatheringErrorListener(); | 9709 GatheringErrorListener listener = new GatheringErrorListener(); |
| 10107 return ParserTestCase.invokeParserMethod2( | 9710 return invokeParserMethod2( |
| 10108 "isFunctionDeclaration", source, listener) as bool; | 9711 "isFunctionDeclaration", source, listener) as bool; |
| 10109 } | 9712 } |
| 10110 | 9713 |
| 10111 /** | 9714 /** |
| 10112 * Invoke the method [Parser.isFunctionExpression] with the parser set to the
token stream | 9715 * Invoke the method [Parser.isFunctionExpression] with the parser set to the
token stream |
| 10113 * produced by scanning the given source. | 9716 * produced by scanning the given source. |
| 10114 * | 9717 * |
| 10115 * @param source the source to be scanned to produce the token stream being te
sted | 9718 * @param source the source to be scanned to produce the token stream being te
sted |
| 10116 * @return the result of invoking the method | 9719 * @return the result of invoking the method |
| 10117 * @throws Exception if the method could not be invoked or throws an exception | 9720 * @throws Exception if the method could not be invoked or throws an exception |
| 10118 */ | 9721 */ |
| 10119 bool _isFunctionExpression(String source) { | 9722 bool _isFunctionExpression(String source) { |
| 10120 GatheringErrorListener listener = new GatheringErrorListener(); | 9723 GatheringErrorListener listener = new GatheringErrorListener(); |
| 10121 // | 9724 // |
| 10122 // Scan the source. | 9725 // Scan the source. |
| 10123 // | 9726 // |
| 10124 Scanner scanner = | 9727 Scanner scanner = |
| 10125 new Scanner(null, new CharSequenceReader(source), listener); | 9728 new Scanner(null, new CharSequenceReader(source), listener); |
| 10126 Token tokenStream = scanner.tokenize(); | 9729 Token tokenStream = scanner.tokenize(); |
| 10127 // | 9730 // |
| 10128 // Parse the source. | 9731 // Parse the source. |
| 10129 // | 9732 // |
| 10130 Parser parser = new Parser(null, listener); | 9733 Parser parser = new Parser(null, listener); |
| 10131 return invokeParserMethodImpl(parser, "isFunctionExpression", <Object>[ | 9734 return invokeParserMethodImpl(parser, "isFunctionExpression", |
| 10132 tokenStream | 9735 <Object>[tokenStream], tokenStream) as bool; |
| 10133 ], tokenStream) as bool; | |
| 10134 } | 9736 } |
| 10135 | 9737 |
| 10136 /** | 9738 /** |
| 10137 * Invoke the method [Parser.isInitializedVariableDeclaration] with the parser
set to the | 9739 * Invoke the method [Parser.isInitializedVariableDeclaration] with the parser
set to the |
| 10138 * token stream produced by scanning the given source. | 9740 * token stream produced by scanning the given source. |
| 10139 * | 9741 * |
| 10140 * @param source the source to be scanned to produce the token stream being te
sted | 9742 * @param source the source to be scanned to produce the token stream being te
sted |
| 10141 * @return the result of invoking the method | 9743 * @return the result of invoking the method |
| 10142 * @throws Exception if the method could not be invoked or throws an exception | 9744 * @throws Exception if the method could not be invoked or throws an exception |
| 10143 */ | 9745 */ |
| 10144 bool _isInitializedVariableDeclaration(String source) { | 9746 bool _isInitializedVariableDeclaration(String source) { |
| 10145 GatheringErrorListener listener = new GatheringErrorListener(); | 9747 GatheringErrorListener listener = new GatheringErrorListener(); |
| 10146 return ParserTestCase.invokeParserMethod2( | 9748 return invokeParserMethod2( |
| 10147 "isInitializedVariableDeclaration", source, listener) as bool; | 9749 "isInitializedVariableDeclaration", source, listener) as bool; |
| 10148 } | 9750 } |
| 10149 | 9751 |
| 10150 /** | 9752 /** |
| 10151 * Invoke the method [Parser.isSwitchMember] with the parser set to the token
stream | 9753 * Invoke the method [Parser.isSwitchMember] with the parser set to the token
stream |
| 10152 * produced by scanning the given source. | 9754 * produced by scanning the given source. |
| 10153 * | 9755 * |
| 10154 * @param source the source to be scanned to produce the token stream being te
sted | 9756 * @param source the source to be scanned to produce the token stream being te
sted |
| 10155 * @return the result of invoking the method | 9757 * @return the result of invoking the method |
| 10156 * @throws Exception if the method could not be invoked or throws an exception | 9758 * @throws Exception if the method could not be invoked or throws an exception |
| 10157 */ | 9759 */ |
| 10158 bool _isSwitchMember(String source) { | 9760 bool _isSwitchMember(String source) { |
| 10159 GatheringErrorListener listener = new GatheringErrorListener(); | 9761 GatheringErrorListener listener = new GatheringErrorListener(); |
| 10160 return ParserTestCase.invokeParserMethod2( | 9762 return invokeParserMethod2("isSwitchMember", source, listener) as bool; |
| 10161 "isSwitchMember", source, listener) as bool; | |
| 10162 } | 9763 } |
| 10163 | 9764 |
| 10164 /** | 9765 /** |
| 10165 * Parse the given source as a compilation unit. | 9766 * Parse the given source as a compilation unit. |
| 10166 * | 9767 * |
| 10167 * @param source the source to be parsed | 9768 * @param source the source to be parsed |
| 10168 * @param errorCodes the error codes of the errors that are expected to be fou
nd | 9769 * @param errorCodes the error codes of the errors that are expected to be fou
nd |
| 10169 * @return the compilation unit that was parsed | 9770 * @return the compilation unit that was parsed |
| 10170 * @throws Exception if the source could not be parsed, if the compilation err
ors in the source do | 9771 * @throws Exception if the source could not be parsed, if the compilation err
ors in the source do |
| 10171 * not match those that are expected, or if the result would have be
en `null` | 9772 * not match those that are expected, or if the result would have be
en `null` |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10204 new Scanner(null, new CharSequenceReader(source), listener); | 9805 new Scanner(null, new CharSequenceReader(source), listener); |
| 10205 Token tokenStream = scanner.tokenize(); | 9806 Token tokenStream = scanner.tokenize(); |
| 10206 // | 9807 // |
| 10207 // Parse the source. | 9808 // Parse the source. |
| 10208 // | 9809 // |
| 10209 Parser parser = new Parser(null, listener); | 9810 Parser parser = new Parser(null, listener); |
| 10210 return invokeParserMethodImpl( | 9811 return invokeParserMethodImpl( |
| 10211 parser, methodName, <Object>[tokenStream], tokenStream) as Token; | 9812 parser, methodName, <Object>[tokenStream], tokenStream) as Token; |
| 10212 } | 9813 } |
| 10213 } | 9814 } |
| OLD | NEW |