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

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

Issue 975453004: Reformat (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library engine.parser_test; 5 library engine.parser_test;
6 6
7 import 'package:analyzer/src/generated/ast.dart'; 7 import 'package:analyzer/src/generated/ast.dart';
8 import 'package:analyzer/src/generated/element.dart'; 8 import 'package:analyzer/src/generated/element.dart';
9 import 'package:analyzer/src/generated/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';
11 import 'package:analyzer/src/generated/parser.dart'; 11 import 'package:analyzer/src/generated/parser.dart';
12 import 'package:analyzer/src/generated/scanner.dart'; 12 import 'package:analyzer/src/generated/scanner.dart';
13 import 'package:analyzer/src/generated/source.dart' show Source; 13 import 'package:analyzer/src/generated/source.dart' show Source;
14 import 'package:analyzer/src/generated/testing/ast_factory.dart'; 14 import 'package:analyzer/src/generated/testing/ast_factory.dart';
15 import 'package:analyzer/src/generated/testing/element_factory.dart'; 15 import 'package:analyzer/src/generated/testing/element_factory.dart';
16 import 'package:analyzer/src/generated/testing/token_factory.dart'; 16 import 'package:analyzer/src/generated/testing/token_factory.dart';
17 import 'package:analyzer/src/generated/utilities_dart.dart'; 17 import 'package:analyzer/src/generated/utilities_dart.dart';
18 import 'package:unittest/unittest.dart'; 18 import 'package:unittest/unittest.dart';
19 19
20 import '../reflective_tests.dart'; 20 import '../reflective_tests.dart';
21 import 'test_support.dart'; 21 import 'test_support.dart';
22 22
23
24 main() { 23 main() {
25 groupSep = ' | '; 24 groupSep = ' | ';
26 runReflectiveTests(ComplexParserTest); 25 runReflectiveTests(ComplexParserTest);
27 runReflectiveTests(ErrorParserTest); 26 runReflectiveTests(ErrorParserTest);
28 runReflectiveTests(IncrementalParserTest); 27 runReflectiveTests(IncrementalParserTest);
29 runReflectiveTests(NonErrorParserTest); 28 runReflectiveTests(NonErrorParserTest);
30 runReflectiveTests(RecoveryParserTest); 29 runReflectiveTests(RecoveryParserTest);
31 runReflectiveTests(ResolutionCopierTest); 30 runReflectiveTests(ResolutionCopierTest);
32 runReflectiveTests(SimpleParserTest); 31 runReflectiveTests(SimpleParserTest);
33 } 32 }
34 33
35 class AnalysisErrorListener_SimpleParserTest_computeStringValue implements 34 class AnalysisErrorListener_SimpleParserTest_computeStringValue
36 AnalysisErrorListener { 35 implements AnalysisErrorListener {
37 @override 36 @override
38 void onError(AnalysisError event) { 37 void onError(AnalysisError event) {
39 fail( 38 fail(
40 "Unexpected compilation error: ${event.message} (${event.offset}, ${even t.length})"); 39 "Unexpected compilation error: ${event.message} (${event.offset}, ${even t.length})");
41 } 40 }
42 } 41 }
43 42
44 /** 43 /**
45 * Instances of the class `AstValidator` are used to validate the correct constr uction of an 44 * Instances of the class `AstValidator` are used to validate the correct constr uction of an
46 * AST structure. 45 * AST structure.
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 * 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
121 * 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
122 * 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.
123 * 122 *
124 * Simpler tests should be defined in the class [SimpleParserTest]. 123 * Simpler tests should be defined in the class [SimpleParserTest].
125 */ 124 */
126 @reflectiveTest 125 @reflectiveTest
127 class ComplexParserTest extends ParserTestCase { 126 class ComplexParserTest extends ParserTestCase {
128 void test_additiveExpression_normal() { 127 void test_additiveExpression_normal() {
129 BinaryExpression expression = ParserTestCase.parseExpression("x + y - z"); 128 BinaryExpression expression = ParserTestCase.parseExpression("x + y - z");
130 EngineTestCase.assertInstanceOf( 129 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression,
131 (obj) => obj is BinaryExpression, 130 BinaryExpression, expression.leftOperand);
132 BinaryExpression,
133 expression.leftOperand);
134 } 131 }
135 132
136 void test_additiveExpression_noSpaces() { 133 void test_additiveExpression_noSpaces() {
137 BinaryExpression expression = ParserTestCase.parseExpression("i+1"); 134 BinaryExpression expression = ParserTestCase.parseExpression("i+1");
138 EngineTestCase.assertInstanceOf( 135 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier,
139 (obj) => obj is SimpleIdentifier, 136 SimpleIdentifier, expression.leftOperand);
140 SimpleIdentifier, 137 EngineTestCase.assertInstanceOf((obj) => obj is IntegerLiteral,
141 expression.leftOperand); 138 IntegerLiteral, expression.rightOperand);
142 EngineTestCase.assertInstanceOf(
143 (obj) => obj is IntegerLiteral,
144 IntegerLiteral,
145 expression.rightOperand);
146 } 139 }
147 140
148 void test_additiveExpression_precedence_multiplicative_left() { 141 void test_additiveExpression_precedence_multiplicative_left() {
149 BinaryExpression expression = ParserTestCase.parseExpression("x * y + z"); 142 BinaryExpression expression = ParserTestCase.parseExpression("x * y + z");
150 EngineTestCase.assertInstanceOf( 143 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression,
151 (obj) => obj is BinaryExpression, 144 BinaryExpression, expression.leftOperand);
152 BinaryExpression,
153 expression.leftOperand);
154 } 145 }
155 146
156 void test_additiveExpression_precedence_multiplicative_left_withSuper() { 147 void test_additiveExpression_precedence_multiplicative_left_withSuper() {
157 BinaryExpression expression = 148 BinaryExpression expression =
158 ParserTestCase.parseExpression("super * y - z"); 149 ParserTestCase.parseExpression("super * y - z");
159 EngineTestCase.assertInstanceOf( 150 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression,
160 (obj) => obj is BinaryExpression, 151 BinaryExpression, expression.leftOperand);
161 BinaryExpression,
162 expression.leftOperand);
163 } 152 }
164 153
165 void test_additiveExpression_precedence_multiplicative_right() { 154 void test_additiveExpression_precedence_multiplicative_right() {
166 BinaryExpression expression = ParserTestCase.parseExpression("x + y * z"); 155 BinaryExpression expression = ParserTestCase.parseExpression("x + y * z");
167 EngineTestCase.assertInstanceOf( 156 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression,
168 (obj) => obj is BinaryExpression, 157 BinaryExpression, expression.rightOperand);
169 BinaryExpression,
170 expression.rightOperand);
171 } 158 }
172 159
173 void test_additiveExpression_super() { 160 void test_additiveExpression_super() {
174 BinaryExpression expression = 161 BinaryExpression expression =
175 ParserTestCase.parseExpression("super + y - z"); 162 ParserTestCase.parseExpression("super + y - z");
176 EngineTestCase.assertInstanceOf( 163 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression,
177 (obj) => obj is BinaryExpression, 164 BinaryExpression, expression.leftOperand);
178 BinaryExpression,
179 expression.leftOperand);
180 } 165 }
181 166
182 void test_assignableExpression_arguments_normal_chain() { 167 void test_assignableExpression_arguments_normal_chain() {
183 PropertyAccess propertyAccess1 = 168 PropertyAccess propertyAccess1 =
184 ParserTestCase.parseExpression("a(b)(c).d(e).f"); 169 ParserTestCase.parseExpression("a(b)(c).d(e).f");
185 expect(propertyAccess1.propertyName.name, "f"); 170 expect(propertyAccess1.propertyName.name, "f");
186 // 171 //
187 // a(b)(c).d(e) 172 // a(b)(c).d(e)
188 // 173 //
189 MethodInvocation invocation2 = EngineTestCase.assertInstanceOf( 174 MethodInvocation invocation2 = EngineTestCase.assertInstanceOf(
190 (obj) => obj is MethodInvocation, 175 (obj) => obj is MethodInvocation, MethodInvocation,
191 MethodInvocation,
192 propertyAccess1.target); 176 propertyAccess1.target);
193 expect(invocation2.methodName.name, "d"); 177 expect(invocation2.methodName.name, "d");
194 ArgumentList argumentList2 = invocation2.argumentList; 178 ArgumentList argumentList2 = invocation2.argumentList;
195 expect(argumentList2, isNotNull); 179 expect(argumentList2, isNotNull);
196 expect(argumentList2.arguments, hasLength(1)); 180 expect(argumentList2.arguments, hasLength(1));
197 // 181 //
198 // a(b)(c) 182 // a(b)(c)
199 // 183 //
200 FunctionExpressionInvocation invocation3 = EngineTestCase.assertInstanceOf( 184 FunctionExpressionInvocation invocation3 = EngineTestCase.assertInstanceOf(
201 (obj) => obj is FunctionExpressionInvocation, 185 (obj) => obj is FunctionExpressionInvocation,
202 FunctionExpressionInvocation, 186 FunctionExpressionInvocation, invocation2.target);
203 invocation2.target);
204 ArgumentList argumentList3 = invocation3.argumentList; 187 ArgumentList argumentList3 = invocation3.argumentList;
205 expect(argumentList3, isNotNull); 188 expect(argumentList3, isNotNull);
206 expect(argumentList3.arguments, hasLength(1)); 189 expect(argumentList3.arguments, hasLength(1));
207 // 190 //
208 // a(b) 191 // a(b)
209 // 192 //
210 MethodInvocation invocation4 = EngineTestCase.assertInstanceOf( 193 MethodInvocation invocation4 = EngineTestCase.assertInstanceOf(
211 (obj) => obj is MethodInvocation, 194 (obj) => obj is MethodInvocation, MethodInvocation,
212 MethodInvocation,
213 invocation3.function); 195 invocation3.function);
214 expect(invocation4.methodName.name, "a"); 196 expect(invocation4.methodName.name, "a");
215 ArgumentList argumentList4 = invocation4.argumentList; 197 ArgumentList argumentList4 = invocation4.argumentList;
216 expect(argumentList4, isNotNull); 198 expect(argumentList4, isNotNull);
217 expect(argumentList4.arguments, hasLength(1)); 199 expect(argumentList4.arguments, hasLength(1));
218 } 200 }
219 201
220 void test_assignmentExpression_compound() { 202 void test_assignmentExpression_compound() {
221 AssignmentExpression expression = 203 AssignmentExpression expression =
222 ParserTestCase.parseExpression("x = y = 0"); 204 ParserTestCase.parseExpression("x = y = 0");
223 EngineTestCase.assertInstanceOf( 205 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier,
224 (obj) => obj is SimpleIdentifier, 206 SimpleIdentifier, expression.leftHandSide);
225 SimpleIdentifier, 207 EngineTestCase.assertInstanceOf((obj) => obj is AssignmentExpression,
226 expression.leftHandSide); 208 AssignmentExpression, expression.rightHandSide);
227 EngineTestCase.assertInstanceOf(
228 (obj) => obj is AssignmentExpression,
229 AssignmentExpression,
230 expression.rightHandSide);
231 } 209 }
232 210
233 void test_assignmentExpression_indexExpression() { 211 void test_assignmentExpression_indexExpression() {
234 AssignmentExpression expression = 212 AssignmentExpression expression =
235 ParserTestCase.parseExpression("x[1] = 0"); 213 ParserTestCase.parseExpression("x[1] = 0");
236 EngineTestCase.assertInstanceOf( 214 EngineTestCase.assertInstanceOf((obj) => obj is IndexExpression,
237 (obj) => obj is IndexExpression, 215 IndexExpression, expression.leftHandSide);
238 IndexExpression, 216 EngineTestCase.assertInstanceOf((obj) => obj is IntegerLiteral,
239 expression.leftHandSide); 217 IntegerLiteral, expression.rightHandSide);
240 EngineTestCase.assertInstanceOf(
241 (obj) => obj is IntegerLiteral,
242 IntegerLiteral,
243 expression.rightHandSide);
244 } 218 }
245 219
246 void test_assignmentExpression_prefixedIdentifier() { 220 void test_assignmentExpression_prefixedIdentifier() {
247 AssignmentExpression expression = ParserTestCase.parseExpression("x.y = 0"); 221 AssignmentExpression expression = ParserTestCase.parseExpression("x.y = 0");
248 EngineTestCase.assertInstanceOf( 222 EngineTestCase.assertInstanceOf((obj) => obj is PrefixedIdentifier,
249 (obj) => obj is PrefixedIdentifier, 223 PrefixedIdentifier, expression.leftHandSide);
250 PrefixedIdentifier, 224 EngineTestCase.assertInstanceOf((obj) => obj is IntegerLiteral,
251 expression.leftHandSide); 225 IntegerLiteral, expression.rightHandSide);
252 EngineTestCase.assertInstanceOf(
253 (obj) => obj is IntegerLiteral,
254 IntegerLiteral,
255 expression.rightHandSide);
256 } 226 }
257 227
258 void test_assignmentExpression_propertyAccess() { 228 void test_assignmentExpression_propertyAccess() {
259 AssignmentExpression expression = 229 AssignmentExpression expression =
260 ParserTestCase.parseExpression("super.y = 0"); 230 ParserTestCase.parseExpression("super.y = 0");
261 EngineTestCase.assertInstanceOf( 231 EngineTestCase.assertInstanceOf((obj) => obj is PropertyAccess,
262 (obj) => obj is PropertyAccess, 232 PropertyAccess, expression.leftHandSide);
263 PropertyAccess, 233 EngineTestCase.assertInstanceOf((obj) => obj is IntegerLiteral,
264 expression.leftHandSide); 234 IntegerLiteral, expression.rightHandSide);
265 EngineTestCase.assertInstanceOf(
266 (obj) => obj is IntegerLiteral,
267 IntegerLiteral,
268 expression.rightHandSide);
269 } 235 }
270 236
271 void test_bitwiseAndExpression_normal() { 237 void test_bitwiseAndExpression_normal() {
272 BinaryExpression expression = ParserTestCase.parseExpression("x & y & z"); 238 BinaryExpression expression = ParserTestCase.parseExpression("x & y & z");
273 EngineTestCase.assertInstanceOf( 239 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression,
274 (obj) => obj is BinaryExpression, 240 BinaryExpression, expression.leftOperand);
275 BinaryExpression,
276 expression.leftOperand);
277 } 241 }
278 242
279 void test_bitwiseAndExpression_precedence_equality_left() { 243 void test_bitwiseAndExpression_precedence_equality_left() {
280 BinaryExpression expression = ParserTestCase.parseExpression("x == y && z"); 244 BinaryExpression expression = ParserTestCase.parseExpression("x == y && z");
281 EngineTestCase.assertInstanceOf( 245 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression,
282 (obj) => obj is BinaryExpression, 246 BinaryExpression, expression.leftOperand);
283 BinaryExpression,
284 expression.leftOperand);
285 } 247 }
286 248
287 void test_bitwiseAndExpression_precedence_equality_right() { 249 void test_bitwiseAndExpression_precedence_equality_right() {
288 BinaryExpression expression = ParserTestCase.parseExpression("x && y == z"); 250 BinaryExpression expression = ParserTestCase.parseExpression("x && y == z");
289 EngineTestCase.assertInstanceOf( 251 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression,
290 (obj) => obj is BinaryExpression, 252 BinaryExpression, expression.rightOperand);
291 BinaryExpression,
292 expression.rightOperand);
293 } 253 }
294 254
295 void test_bitwiseAndExpression_super() { 255 void test_bitwiseAndExpression_super() {
296 BinaryExpression expression = 256 BinaryExpression expression =
297 ParserTestCase.parseExpression("super & y & z"); 257 ParserTestCase.parseExpression("super & y & z");
298 EngineTestCase.assertInstanceOf( 258 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression,
299 (obj) => obj is BinaryExpression, 259 BinaryExpression, expression.leftOperand);
300 BinaryExpression,
301 expression.leftOperand);
302 } 260 }
303 261
304 void test_bitwiseOrExpression_normal() { 262 void test_bitwiseOrExpression_normal() {
305 BinaryExpression expression = ParserTestCase.parseExpression("x | y | z"); 263 BinaryExpression expression = ParserTestCase.parseExpression("x | y | z");
306 EngineTestCase.assertInstanceOf( 264 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression,
307 (obj) => obj is BinaryExpression, 265 BinaryExpression, expression.leftOperand);
308 BinaryExpression,
309 expression.leftOperand);
310 } 266 }
311 267
312 void test_bitwiseOrExpression_precedence_xor_left() { 268 void test_bitwiseOrExpression_precedence_xor_left() {
313 BinaryExpression expression = ParserTestCase.parseExpression("x ^ y | z"); 269 BinaryExpression expression = ParserTestCase.parseExpression("x ^ y | z");
314 EngineTestCase.assertInstanceOf( 270 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression,
315 (obj) => obj is BinaryExpression, 271 BinaryExpression, expression.leftOperand);
316 BinaryExpression,
317 expression.leftOperand);
318 } 272 }
319 273
320 void test_bitwiseOrExpression_precedence_xor_right() { 274 void test_bitwiseOrExpression_precedence_xor_right() {
321 BinaryExpression expression = ParserTestCase.parseExpression("x | y ^ z"); 275 BinaryExpression expression = ParserTestCase.parseExpression("x | y ^ z");
322 EngineTestCase.assertInstanceOf( 276 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression,
323 (obj) => obj is BinaryExpression, 277 BinaryExpression, expression.rightOperand);
324 BinaryExpression,
325 expression.rightOperand);
326 } 278 }
327 279
328 void test_bitwiseOrExpression_super() { 280 void test_bitwiseOrExpression_super() {
329 BinaryExpression expression = 281 BinaryExpression expression =
330 ParserTestCase.parseExpression("super | y | z"); 282 ParserTestCase.parseExpression("super | y | z");
331 EngineTestCase.assertInstanceOf( 283 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression,
332 (obj) => obj is BinaryExpression, 284 BinaryExpression, expression.leftOperand);
333 BinaryExpression,
334 expression.leftOperand);
335 } 285 }
336 286
337 void test_bitwiseXorExpression_normal() { 287 void test_bitwiseXorExpression_normal() {
338 BinaryExpression expression = ParserTestCase.parseExpression("x ^ y ^ z"); 288 BinaryExpression expression = ParserTestCase.parseExpression("x ^ y ^ z");
339 EngineTestCase.assertInstanceOf( 289 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression,
340 (obj) => obj is BinaryExpression, 290 BinaryExpression, expression.leftOperand);
341 BinaryExpression,
342 expression.leftOperand);
343 } 291 }
344 292
345 void test_bitwiseXorExpression_precedence_and_left() { 293 void test_bitwiseXorExpression_precedence_and_left() {
346 BinaryExpression expression = ParserTestCase.parseExpression("x & y ^ z"); 294 BinaryExpression expression = ParserTestCase.parseExpression("x & y ^ z");
347 EngineTestCase.assertInstanceOf( 295 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression,
348 (obj) => obj is BinaryExpression, 296 BinaryExpression, expression.leftOperand);
349 BinaryExpression,
350 expression.leftOperand);
351 } 297 }
352 298
353 void test_bitwiseXorExpression_precedence_and_right() { 299 void test_bitwiseXorExpression_precedence_and_right() {
354 BinaryExpression expression = ParserTestCase.parseExpression("x ^ y & z"); 300 BinaryExpression expression = ParserTestCase.parseExpression("x ^ y & z");
355 EngineTestCase.assertInstanceOf( 301 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression,
356 (obj) => obj is BinaryExpression, 302 BinaryExpression, expression.rightOperand);
357 BinaryExpression,
358 expression.rightOperand);
359 } 303 }
360 304
361 void test_bitwiseXorExpression_super() { 305 void test_bitwiseXorExpression_super() {
362 BinaryExpression expression = 306 BinaryExpression expression =
363 ParserTestCase.parseExpression("super ^ y ^ z"); 307 ParserTestCase.parseExpression("super ^ y ^ z");
364 EngineTestCase.assertInstanceOf( 308 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression,
365 (obj) => obj is BinaryExpression, 309 BinaryExpression, expression.leftOperand);
366 BinaryExpression,
367 expression.leftOperand);
368 } 310 }
369 311
370 void test_cascade_withAssignment() { 312 void test_cascade_withAssignment() {
371 CascadeExpression cascade = 313 CascadeExpression cascade =
372 ParserTestCase.parseExpression("new Map()..[3] = 4 ..[0] = 11;"); 314 ParserTestCase.parseExpression("new Map()..[3] = 4 ..[0] = 11;");
373 Expression target = cascade.target; 315 Expression target = cascade.target;
374 for (Expression section in cascade.cascadeSections) { 316 for (Expression section in cascade.cascadeSections) {
375 EngineTestCase.assertInstanceOf( 317 EngineTestCase.assertInstanceOf(
376 (obj) => obj is AssignmentExpression, 318 (obj) => obj is AssignmentExpression, AssignmentExpression, section);
377 AssignmentExpression,
378 section);
379 Expression lhs = (section as AssignmentExpression).leftHandSide; 319 Expression lhs = (section as AssignmentExpression).leftHandSide;
380 EngineTestCase.assertInstanceOf( 320 EngineTestCase.assertInstanceOf(
381 (obj) => obj is IndexExpression, 321 (obj) => obj is IndexExpression, IndexExpression, lhs);
382 IndexExpression,
383 lhs);
384 IndexExpression index = lhs as IndexExpression; 322 IndexExpression index = lhs as IndexExpression;
385 expect(index.isCascaded, isTrue); 323 expect(index.isCascaded, isTrue);
386 expect(index.realTarget, same(target)); 324 expect(index.realTarget, same(target));
387 } 325 }
388 } 326 }
389 327
390 void test_conditionalExpression_precedence_logicalOrExpression() { 328 void test_conditionalExpression_precedence_logicalOrExpression() {
391 ConditionalExpression expression = 329 ConditionalExpression expression =
392 ParserTestCase.parseExpression("a | b ? y : z"); 330 ParserTestCase.parseExpression("a | b ? y : z");
393 EngineTestCase.assertInstanceOf( 331 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression,
394 (obj) => obj is BinaryExpression, 332 BinaryExpression, expression.condition);
395 BinaryExpression,
396 expression.condition);
397 } 333 }
398 334
399 void test_constructor_initializer_withParenthesizedExpression() { 335 void test_constructor_initializer_withParenthesizedExpression() {
400 CompilationUnit unit = ParserTestCase.parseCompilationUnit(r''' 336 CompilationUnit unit = ParserTestCase.parseCompilationUnit(r'''
401 class C { 337 class C {
402 C() : 338 C() :
403 this.a = (b == null ? c : d) { 339 this.a = (b == null ? c : d) {
404 } 340 }
405 }'''); 341 }''');
406 NodeList<CompilationUnitMember> declarations = unit.declarations; 342 NodeList<CompilationUnitMember> declarations = unit.declarations;
407 expect(declarations, hasLength(1)); 343 expect(declarations, hasLength(1));
408 } 344 }
409 345
410 void test_equalityExpression_normal() { 346 void test_equalityExpression_normal() {
411 BinaryExpression expression = ParserTestCase.parseExpression( 347 BinaryExpression expression = ParserTestCase.parseExpression(
412 "x == y != z", 348 "x == y != z", [ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND]);
413 [ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND]); 349 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression,
414 EngineTestCase.assertInstanceOf( 350 BinaryExpression, expression.leftOperand);
415 (obj) => obj is BinaryExpression,
416 BinaryExpression,
417 expression.leftOperand);
418 } 351 }
419 352
420 void test_equalityExpression_precedence_relational_left() { 353 void test_equalityExpression_precedence_relational_left() {
421 BinaryExpression expression = ParserTestCase.parseExpression("x is y == z"); 354 BinaryExpression expression = ParserTestCase.parseExpression("x is y == z");
422 EngineTestCase.assertInstanceOf( 355 EngineTestCase.assertInstanceOf(
423 (obj) => obj is IsExpression, 356 (obj) => obj is IsExpression, IsExpression, expression.leftOperand);
424 IsExpression,
425 expression.leftOperand);
426 } 357 }
427 358
428 void test_equalityExpression_precedence_relational_right() { 359 void test_equalityExpression_precedence_relational_right() {
429 BinaryExpression expression = ParserTestCase.parseExpression("x == y is z"); 360 BinaryExpression expression = ParserTestCase.parseExpression("x == y is z");
430 EngineTestCase.assertInstanceOf( 361 EngineTestCase.assertInstanceOf(
431 (obj) => obj is IsExpression, 362 (obj) => obj is IsExpression, IsExpression, expression.rightOperand);
432 IsExpression,
433 expression.rightOperand);
434 } 363 }
435 364
436 void test_equalityExpression_super() { 365 void test_equalityExpression_super() {
437 BinaryExpression expression = ParserTestCase.parseExpression( 366 BinaryExpression expression = ParserTestCase.parseExpression(
438 "super == y != z", 367 "super == y != z", [
439 [ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND]); 368 ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND
440 EngineTestCase.assertInstanceOf( 369 ]);
441 (obj) => obj is BinaryExpression, 370 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression,
442 BinaryExpression, 371 BinaryExpression, expression.leftOperand);
443 expression.leftOperand);
444 } 372 }
445 373
446 void test_logicalAndExpression() { 374 void test_logicalAndExpression() {
447 BinaryExpression expression = ParserTestCase.parseExpression("x && y && z"); 375 BinaryExpression expression = ParserTestCase.parseExpression("x && y && z");
448 EngineTestCase.assertInstanceOf( 376 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression,
449 (obj) => obj is BinaryExpression, 377 BinaryExpression, expression.leftOperand);
450 BinaryExpression,
451 expression.leftOperand);
452 } 378 }
453 379
454 void test_logicalAndExpression_precedence_bitwiseOr_left() { 380 void test_logicalAndExpression_precedence_bitwiseOr_left() {
455 BinaryExpression expression = ParserTestCase.parseExpression("x | y < z"); 381 BinaryExpression expression = ParserTestCase.parseExpression("x | y < z");
456 EngineTestCase.assertInstanceOf( 382 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression,
457 (obj) => obj is BinaryExpression, 383 BinaryExpression, expression.leftOperand);
458 BinaryExpression,
459 expression.leftOperand);
460 } 384 }
461 385
462 void test_logicalAndExpression_precedence_bitwiseOr_right() { 386 void test_logicalAndExpression_precedence_bitwiseOr_right() {
463 BinaryExpression expression = ParserTestCase.parseExpression("x < y | z"); 387 BinaryExpression expression = ParserTestCase.parseExpression("x < y | z");
464 EngineTestCase.assertInstanceOf( 388 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression,
465 (obj) => obj is BinaryExpression, 389 BinaryExpression, expression.rightOperand);
466 BinaryExpression,
467 expression.rightOperand);
468 } 390 }
469 391
470 void test_logicalOrExpression() { 392 void test_logicalOrExpression() {
471 BinaryExpression expression = ParserTestCase.parseExpression("x || y || z"); 393 BinaryExpression expression = ParserTestCase.parseExpression("x || y || z");
472 EngineTestCase.assertInstanceOf( 394 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression,
473 (obj) => obj is BinaryExpression, 395 BinaryExpression, expression.leftOperand);
474 BinaryExpression,
475 expression.leftOperand);
476 } 396 }
477 397
478 void test_logicalOrExpression_precedence_logicalAnd_left() { 398 void test_logicalOrExpression_precedence_logicalAnd_left() {
479 BinaryExpression expression = ParserTestCase.parseExpression("x && y || z"); 399 BinaryExpression expression = ParserTestCase.parseExpression("x && y || z");
480 EngineTestCase.assertInstanceOf( 400 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression,
481 (obj) => obj is BinaryExpression, 401 BinaryExpression, expression.leftOperand);
482 BinaryExpression,
483 expression.leftOperand);
484 } 402 }
485 403
486 void test_logicalOrExpression_precedence_logicalAnd_right() { 404 void test_logicalOrExpression_precedence_logicalAnd_right() {
487 BinaryExpression expression = ParserTestCase.parseExpression("x || y && z"); 405 BinaryExpression expression = ParserTestCase.parseExpression("x || y && z");
488 EngineTestCase.assertInstanceOf( 406 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression,
489 (obj) => obj is BinaryExpression, 407 BinaryExpression, expression.rightOperand);
490 BinaryExpression,
491 expression.rightOperand);
492 } 408 }
493 409
494 void test_multipleLabels_statement() { 410 void test_multipleLabels_statement() {
495 LabeledStatement statement = 411 LabeledStatement statement =
496 ParserTestCase.parseStatement("a: b: c: return x;"); 412 ParserTestCase.parseStatement("a: b: c: return x;");
497 expect(statement.labels, hasLength(3)); 413 expect(statement.labels, hasLength(3));
498 EngineTestCase.assertInstanceOf( 414 EngineTestCase.assertInstanceOf(
499 (obj) => obj is ReturnStatement, 415 (obj) => obj is ReturnStatement, ReturnStatement, statement.statement);
500 ReturnStatement,
501 statement.statement);
502 } 416 }
503 417
504 void test_multiplicativeExpression_normal() { 418 void test_multiplicativeExpression_normal() {
505 BinaryExpression expression = ParserTestCase.parseExpression("x * y / z"); 419 BinaryExpression expression = ParserTestCase.parseExpression("x * y / z");
506 EngineTestCase.assertInstanceOf( 420 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression,
507 (obj) => obj is BinaryExpression, 421 BinaryExpression, expression.leftOperand);
508 BinaryExpression,
509 expression.leftOperand);
510 } 422 }
511 423
512 void test_multiplicativeExpression_precedence_unary_left() { 424 void test_multiplicativeExpression_precedence_unary_left() {
513 BinaryExpression expression = ParserTestCase.parseExpression("-x * y"); 425 BinaryExpression expression = ParserTestCase.parseExpression("-x * y");
514 EngineTestCase.assertInstanceOf( 426 EngineTestCase.assertInstanceOf((obj) => obj is PrefixExpression,
515 (obj) => obj is PrefixExpression, 427 PrefixExpression, expression.leftOperand);
516 PrefixExpression,
517 expression.leftOperand);
518 } 428 }
519 429
520 void test_multiplicativeExpression_precedence_unary_right() { 430 void test_multiplicativeExpression_precedence_unary_right() {
521 BinaryExpression expression = ParserTestCase.parseExpression("x * -y"); 431 BinaryExpression expression = ParserTestCase.parseExpression("x * -y");
522 EngineTestCase.assertInstanceOf( 432 EngineTestCase.assertInstanceOf((obj) => obj is PrefixExpression,
523 (obj) => obj is PrefixExpression, 433 PrefixExpression, expression.rightOperand);
524 PrefixExpression,
525 expression.rightOperand);
526 } 434 }
527 435
528 void test_multiplicativeExpression_super() { 436 void test_multiplicativeExpression_super() {
529 BinaryExpression expression = 437 BinaryExpression expression =
530 ParserTestCase.parseExpression("super * y / z"); 438 ParserTestCase.parseExpression("super * y / z");
531 EngineTestCase.assertInstanceOf( 439 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression,
532 (obj) => obj is BinaryExpression, 440 BinaryExpression, expression.leftOperand);
533 BinaryExpression,
534 expression.leftOperand);
535 } 441 }
536 442
537 void test_relationalExpression_precedence_shift_right() { 443 void test_relationalExpression_precedence_shift_right() {
538 IsExpression expression = ParserTestCase.parseExpression("x << y is z"); 444 IsExpression expression = ParserTestCase.parseExpression("x << y is z");
539 EngineTestCase.assertInstanceOf( 445 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression,
540 (obj) => obj is BinaryExpression, 446 BinaryExpression, expression.expression);
541 BinaryExpression,
542 expression.expression);
543 } 447 }
544 448
545 void test_shiftExpression_normal() { 449 void test_shiftExpression_normal() {
546 BinaryExpression expression = ParserTestCase.parseExpression("x >> 4 << 3"); 450 BinaryExpression expression = ParserTestCase.parseExpression("x >> 4 << 3");
547 EngineTestCase.assertInstanceOf( 451 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression,
548 (obj) => obj is BinaryExpression, 452 BinaryExpression, expression.leftOperand);
549 BinaryExpression,
550 expression.leftOperand);
551 } 453 }
552 454
553 void test_shiftExpression_precedence_additive_left() { 455 void test_shiftExpression_precedence_additive_left() {
554 BinaryExpression expression = ParserTestCase.parseExpression("x + y << z"); 456 BinaryExpression expression = ParserTestCase.parseExpression("x + y << z");
555 EngineTestCase.assertInstanceOf( 457 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression,
556 (obj) => obj is BinaryExpression, 458 BinaryExpression, expression.leftOperand);
557 BinaryExpression,
558 expression.leftOperand);
559 } 459 }
560 460
561 void test_shiftExpression_precedence_additive_right() { 461 void test_shiftExpression_precedence_additive_right() {
562 BinaryExpression expression = ParserTestCase.parseExpression("x << y + z"); 462 BinaryExpression expression = ParserTestCase.parseExpression("x << y + z");
563 EngineTestCase.assertInstanceOf( 463 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression,
564 (obj) => obj is BinaryExpression, 464 BinaryExpression, expression.rightOperand);
565 BinaryExpression,
566 expression.rightOperand);
567 } 465 }
568 466
569 void test_shiftExpression_super() { 467 void test_shiftExpression_super() {
570 BinaryExpression expression = 468 BinaryExpression expression =
571 ParserTestCase.parseExpression("super >> 4 << 3"); 469 ParserTestCase.parseExpression("super >> 4 << 3");
572 EngineTestCase.assertInstanceOf( 470 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression,
573 (obj) => obj is BinaryExpression, 471 BinaryExpression, expression.leftOperand);
574 BinaryExpression,
575 expression.leftOperand);
576 } 472 }
577 473
578 void test_topLevelVariable_withMetadata() { 474 void test_topLevelVariable_withMetadata() {
579 ParserTestCase.parseCompilationUnit("String @A string;"); 475 ParserTestCase.parseCompilationUnit("String @A string;");
580 } 476 }
581 } 477 }
582 478
583 /** 479 /**
584 * The class `ErrorParserTest` defines parser tests that test the parsing of cod e to ensure 480 * The class `ErrorParserTest` defines parser tests that test the parsing of cod e to ensure
585 * that errors are correctly reported, and in some cases, not reported. 481 * that errors are correctly reported, and in some cases, not reported.
586 */ 482 */
587 @reflectiveTest 483 @reflectiveTest
588 class ErrorParserTest extends ParserTestCase { 484 class ErrorParserTest extends ParserTestCase {
589 void fail_expectedListOrMapLiteral() { 485 void fail_expectedListOrMapLiteral() {
590 // It isn't clear that this test can ever pass. The parser is currently 486 // It isn't clear that this test can ever pass. The parser is currently
591 // create a synthetic list literal in this case, but isSynthetic() isn't 487 // create a synthetic list literal in this case, but isSynthetic() isn't
592 // overridden for ListLiteral. The problem is that the synthetic list 488 // overridden for ListLiteral. The problem is that the synthetic list
593 // literals that are being created are not always zero length (because they 489 // literals that are being created are not always zero length (because they
594 // could have type parameters), which violates the contract of 490 // could have type parameters), which violates the contract of
595 // isSynthetic(). 491 // isSynthetic().
596 TypedLiteral literal = ParserTestCase.parse3( 492 TypedLiteral literal = ParserTestCase.parse3("parseListOrMapLiteral",
597 "parseListOrMapLiteral", 493 <Object>[null], "1", [ParserErrorCode.EXPECTED_LIST_OR_MAP_LITERAL]);
598 <Object>[null],
599 "1",
600 [ParserErrorCode.EXPECTED_LIST_OR_MAP_LITERAL]);
601 expect(literal.isSynthetic, isTrue); 494 expect(literal.isSynthetic, isTrue);
602 } 495 }
603 496
604 void fail_illegalAssignmentToNonAssignable_superAssigned() { 497 void fail_illegalAssignmentToNonAssignable_superAssigned() {
605 // TODO(brianwilkerson) When this test starts to pass, remove the test 498 // TODO(brianwilkerson) When this test starts to pass, remove the test
606 // test_illegalAssignmentToNonAssignable_superAssigned. 499 // test_illegalAssignmentToNonAssignable_superAssigned.
607 ParserTestCase.parseExpression( 500 ParserTestCase.parseExpression(
608 "super = x;", 501 "super = x;", [ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE]);
609 [ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE]);
610 } 502 }
611 503
612 void fail_invalidCommentReference__new_nonIdentifier() { 504 void fail_invalidCommentReference__new_nonIdentifier() {
613 // This test fails because the method parseCommentReference returns null. 505 // This test fails because the method parseCommentReference returns null.
614 ParserTestCase.parse3( 506 ParserTestCase.parse3("parseCommentReference", <Object>["new 42", 0], "", [
615 "parseCommentReference", 507 ParserErrorCode.INVALID_COMMENT_REFERENCE
616 <Object>["new 42", 0], 508 ]);
617 "",
618 [ParserErrorCode.INVALID_COMMENT_REFERENCE]);
619 } 509 }
620 510
621 void fail_invalidCommentReference__new_tooMuch() { 511 void fail_invalidCommentReference__new_tooMuch() {
622 ParserTestCase.parse3( 512 ParserTestCase.parse3("parseCommentReference", <Object>[
623 "parseCommentReference", 513 "new a.b.c.d",
624 <Object>["new a.b.c.d", 0], 514 0
625 "", 515 ], "", [ParserErrorCode.INVALID_COMMENT_REFERENCE]);
626 [ParserErrorCode.INVALID_COMMENT_REFERENCE]);
627 } 516 }
628 517
629 void fail_invalidCommentReference__nonNew_nonIdentifier() { 518 void fail_invalidCommentReference__nonNew_nonIdentifier() {
630 // This test fails because the method parseCommentReference returns null. 519 // This test fails because the method parseCommentReference returns null.
631 ParserTestCase.parse3( 520 ParserTestCase.parse3("parseCommentReference", <Object>["42", 0], "", [
632 "parseCommentReference", 521 ParserErrorCode.INVALID_COMMENT_REFERENCE
633 <Object>["42", 0], 522 ]);
634 "",
635 [ParserErrorCode.INVALID_COMMENT_REFERENCE]);
636 } 523 }
637 524
638 void fail_invalidCommentReference__nonNew_tooMuch() { 525 void fail_invalidCommentReference__nonNew_tooMuch() {
639 ParserTestCase.parse3( 526 ParserTestCase.parse3("parseCommentReference", <Object>["a.b.c.d", 0], "", [
640 "parseCommentReference", 527 ParserErrorCode.INVALID_COMMENT_REFERENCE
641 <Object>["a.b.c.d", 0], 528 ]);
642 "",
643 [ParserErrorCode.INVALID_COMMENT_REFERENCE]);
644 } 529 }
645 530
646 void fail_missingClosingParenthesis() { 531 void fail_missingClosingParenthesis() {
647 // It is possible that it is not possible to generate this error (that it's 532 // It is possible that it is not possible to generate this error (that it's
648 // being reported in code that cannot actually be reached), but that hasn't 533 // being reported in code that cannot actually be reached), but that hasn't
649 // been proven yet. 534 // been proven yet.
650 ParserTestCase.parse4( 535 ParserTestCase.parse4("parseFormalParameterList", "(int a, int b ;", [
651 "parseFormalParameterList", 536 ParserErrorCode.MISSING_CLOSING_PARENTHESIS
652 "(int a, int b ;", 537 ]);
653 [ParserErrorCode.MISSING_CLOSING_PARENTHESIS]);
654 } 538 }
655 539
656 void fail_missingFunctionParameters_local_nonVoid_block() { 540 void fail_missingFunctionParameters_local_nonVoid_block() {
657 // The parser does not recognize this as a function declaration, so it tries 541 // The parser does not recognize this as a function declaration, so it tries
658 // to parse it as an expression statement. It isn't clear what the best 542 // to parse it as an expression statement. It isn't clear what the best
659 // error message is in this case. 543 // error message is in this case.
660 ParserTestCase.parseStatement( 544 ParserTestCase.parseStatement(
661 "int f { return x;}", 545 "int f { return x;}", [ParserErrorCode.MISSING_FUNCTION_PARAMETERS]);
662 [ParserErrorCode.MISSING_FUNCTION_PARAMETERS]);
663 } 546 }
664 547
665 void fail_missingFunctionParameters_local_nonVoid_expression() { 548 void fail_missingFunctionParameters_local_nonVoid_expression() {
666 // The parser does not recognize this as a function declaration, so it tries 549 // The parser does not recognize this as a function declaration, so it tries
667 // to parse it as an expression statement. It isn't clear what the best 550 // to parse it as an expression statement. It isn't clear what the best
668 // error message is in this case. 551 // error message is in this case.
669 ParserTestCase.parseStatement( 552 ParserTestCase.parseStatement(
670 "int f => x;", 553 "int f => x;", [ParserErrorCode.MISSING_FUNCTION_PARAMETERS]);
671 [ParserErrorCode.MISSING_FUNCTION_PARAMETERS]);
672 } 554 }
673 555
674 void fail_namedFunctionExpression() { 556 void fail_namedFunctionExpression() {
675 Expression expression = ParserTestCase.parse4( 557 Expression expression = ParserTestCase.parse4("parsePrimaryExpression",
676 "parsePrimaryExpression", 558 "f() {}", [ParserErrorCode.NAMED_FUNCTION_EXPRESSION]);
677 "f() {}",
678 [ParserErrorCode.NAMED_FUNCTION_EXPRESSION]);
679 EngineTestCase.assertInstanceOf( 559 EngineTestCase.assertInstanceOf(
680 (obj) => obj is FunctionExpression, 560 (obj) => obj is FunctionExpression, FunctionExpression, expression);
681 FunctionExpression,
682 expression);
683 } 561 }
684 562
685 void fail_unexpectedToken_invalidPostfixExpression() { 563 void fail_unexpectedToken_invalidPostfixExpression() {
686 // Note: this might not be the right error to produce, but some error should 564 // Note: this might not be the right error to produce, but some error should
687 // be produced 565 // be produced
688 ParserTestCase.parseExpression("f()++", [ParserErrorCode.UNEXPECTED_TOKEN]); 566 ParserTestCase.parseExpression("f()++", [ParserErrorCode.UNEXPECTED_TOKEN]);
689 } 567 }
690 568
691 void fail_varAndType_local() { 569 void fail_varAndType_local() {
692 // This is currently reporting EXPECTED_TOKEN for a missing semicolon, but 570 // This is currently reporting EXPECTED_TOKEN for a missing semicolon, but
693 // this would be a better error message. 571 // this would be a better error message.
694 ParserTestCase.parseStatement("var int x;", [ParserErrorCode.VAR_AND_TYPE]); 572 ParserTestCase.parseStatement("var int x;", [ParserErrorCode.VAR_AND_TYPE]);
695 } 573 }
696 574
697 void fail_varAndType_parameter() { 575 void fail_varAndType_parameter() {
698 // This is currently reporting EXPECTED_TOKEN for a missing semicolon, but 576 // This is currently reporting EXPECTED_TOKEN for a missing semicolon, but
699 // this would be a better error message. 577 // this would be a better error message.
700 ParserTestCase.parse4( 578 ParserTestCase.parse4("parseFormalParameterList", "(var int x)", [
701 "parseFormalParameterList", 579 ParserErrorCode.VAR_AND_TYPE
702 "(var int x)", 580 ]);
703 [ParserErrorCode.VAR_AND_TYPE]);
704 } 581 }
705 582
706 void test_abstractClassMember_constructor() { 583 void test_abstractClassMember_constructor() {
707 ParserTestCase.parse3( 584 ParserTestCase.parse3("parseClassMember", <Object>[
708 "parseClassMember", 585 "C"
709 <Object>["C"], 586 ], "abstract C.c();", [ParserErrorCode.ABSTRACT_CLASS_MEMBER]);
710 "abstract C.c();",
711 [ParserErrorCode.ABSTRACT_CLASS_MEMBER]);
712 } 587 }
713 588
714 void test_abstractClassMember_field() { 589 void test_abstractClassMember_field() {
715 ParserTestCase.parse3( 590 ParserTestCase.parse3("parseClassMember", <Object>["C"], "abstract C f;", [
716 "parseClassMember", 591 ParserErrorCode.ABSTRACT_CLASS_MEMBER
717 <Object>["C"], 592 ]);
718 "abstract C f;",
719 [ParserErrorCode.ABSTRACT_CLASS_MEMBER]);
720 } 593 }
721 594
722 void test_abstractClassMember_getter() { 595 void test_abstractClassMember_getter() {
723 ParserTestCase.parse3( 596 ParserTestCase.parse3("parseClassMember", <Object>[
724 "parseClassMember", 597 "C"
725 <Object>["C"], 598 ], "abstract get m;", [ParserErrorCode.ABSTRACT_CLASS_MEMBER]);
726 "abstract get m;",
727 [ParserErrorCode.ABSTRACT_CLASS_MEMBER]);
728 } 599 }
729 600
730 void test_abstractClassMember_method() { 601 void test_abstractClassMember_method() {
731 ParserTestCase.parse3( 602 ParserTestCase.parse3("parseClassMember", <Object>["C"], "abstract m();", [
732 "parseClassMember", 603 ParserErrorCode.ABSTRACT_CLASS_MEMBER
733 <Object>["C"], 604 ]);
734 "abstract m();",
735 [ParserErrorCode.ABSTRACT_CLASS_MEMBER]);
736 } 605 }
737 606
738 void test_abstractClassMember_setter() { 607 void test_abstractClassMember_setter() {
739 ParserTestCase.parse3( 608 ParserTestCase.parse3("parseClassMember", <Object>[
740 "parseClassMember", 609 "C"
741 <Object>["C"], 610 ], "abstract set m(v);", [ParserErrorCode.ABSTRACT_CLASS_MEMBER]);
742 "abstract set m(v);",
743 [ParserErrorCode.ABSTRACT_CLASS_MEMBER]);
744 } 611 }
745 612
746 void test_abstractEnum() { 613 void test_abstractEnum() {
747 ParserTestCase.parseCompilationUnit( 614 ParserTestCase.parseCompilationUnit(
748 "abstract enum E {ONE}", 615 "abstract enum E {ONE}", [ParserErrorCode.ABSTRACT_ENUM]);
749 [ParserErrorCode.ABSTRACT_ENUM]);
750 } 616 }
751 617
752 void test_abstractTopLevelFunction_function() { 618 void test_abstractTopLevelFunction_function() {
753 ParserTestCase.parseCompilationUnit( 619 ParserTestCase.parseCompilationUnit(
754 "abstract f(v) {}", 620 "abstract f(v) {}", [ParserErrorCode.ABSTRACT_TOP_LEVEL_FUNCTION]);
755 [ParserErrorCode.ABSTRACT_TOP_LEVEL_FUNCTION]);
756 } 621 }
757 622
758 void test_abstractTopLevelFunction_getter() { 623 void test_abstractTopLevelFunction_getter() {
759 ParserTestCase.parseCompilationUnit( 624 ParserTestCase.parseCompilationUnit(
760 "abstract get m {}", 625 "abstract get m {}", [ParserErrorCode.ABSTRACT_TOP_LEVEL_FUNCTION]);
761 [ParserErrorCode.ABSTRACT_TOP_LEVEL_FUNCTION]);
762 } 626 }
763 627
764 void test_abstractTopLevelFunction_setter() { 628 void test_abstractTopLevelFunction_setter() {
765 ParserTestCase.parseCompilationUnit( 629 ParserTestCase.parseCompilationUnit(
766 "abstract set m(v) {}", 630 "abstract set m(v) {}", [ParserErrorCode.ABSTRACT_TOP_LEVEL_FUNCTION]);
767 [ParserErrorCode.ABSTRACT_TOP_LEVEL_FUNCTION]);
768 } 631 }
769 632
770 void test_abstractTopLevelVariable() { 633 void test_abstractTopLevelVariable() {
771 ParserTestCase.parseCompilationUnit( 634 ParserTestCase.parseCompilationUnit(
772 "abstract C f;", 635 "abstract C f;", [ParserErrorCode.ABSTRACT_TOP_LEVEL_VARIABLE]);
773 [ParserErrorCode.ABSTRACT_TOP_LEVEL_VARIABLE]);
774 } 636 }
775 637
776 void test_abstractTypeDef() { 638 void test_abstractTypeDef() {
777 ParserTestCase.parseCompilationUnit( 639 ParserTestCase.parseCompilationUnit(
778 "abstract typedef F();", 640 "abstract typedef F();", [ParserErrorCode.ABSTRACT_TYPEDEF]);
779 [ParserErrorCode.ABSTRACT_TYPEDEF]);
780 } 641 }
781 642
782 void test_annotationOnEnumConstant_first() { 643 void test_annotationOnEnumConstant_first() {
783 ParserTestCase.parseCompilationUnit( 644 ParserTestCase.parseCompilationUnit("enum E { @override C }", [
784 "enum E { @override C }", 645 ParserErrorCode.ANNOTATION_ON_ENUM_CONSTANT
785 [ParserErrorCode.ANNOTATION_ON_ENUM_CONSTANT]); 646 ]);
786 } 647 }
787 648
788 void test_annotationOnEnumConstant_middle() { 649 void test_annotationOnEnumConstant_middle() {
789 ParserTestCase.parseCompilationUnit( 650 ParserTestCase.parseCompilationUnit("enum E { C, @override D, E }", [
790 "enum E { C, @override D, E }", 651 ParserErrorCode.ANNOTATION_ON_ENUM_CONSTANT
791 [ParserErrorCode.ANNOTATION_ON_ENUM_CONSTANT]); 652 ]);
792 } 653 }
793 654
794 void test_assertDoesNotTakeAssignment() { 655 void test_assertDoesNotTakeAssignment() {
795 ParserTestCase.parse4( 656 ParserTestCase.parse4("parseAssertStatement", "assert(b = true);", [
796 "parseAssertStatement", 657 ParserErrorCode.ASSERT_DOES_NOT_TAKE_ASSIGNMENT
797 "assert(b = true);", 658 ]);
798 [ParserErrorCode.ASSERT_DOES_NOT_TAKE_ASSIGNMENT]);
799 } 659 }
800 660
801 void test_assertDoesNotTakeCascades() { 661 void test_assertDoesNotTakeCascades() {
802 ParserTestCase.parse4( 662 ParserTestCase.parse4("parseAssertStatement", "assert(new A()..m());", [
803 "parseAssertStatement", 663 ParserErrorCode.ASSERT_DOES_NOT_TAKE_CASCADE
804 "assert(new A()..m());", 664 ]);
805 [ParserErrorCode.ASSERT_DOES_NOT_TAKE_CASCADE]);
806 } 665 }
807 666
808 void test_assertDoesNotTakeRethrow() { 667 void test_assertDoesNotTakeRethrow() {
809 ParserTestCase.parse4( 668 ParserTestCase.parse4("parseAssertStatement", "assert(rethrow);", [
810 "parseAssertStatement", 669 ParserErrorCode.ASSERT_DOES_NOT_TAKE_RETHROW
811 "assert(rethrow);", 670 ]);
812 [ParserErrorCode.ASSERT_DOES_NOT_TAKE_RETHROW]);
813 } 671 }
814 672
815 void test_assertDoesNotTakeThrow() { 673 void test_assertDoesNotTakeThrow() {
816 ParserTestCase.parse4( 674 ParserTestCase.parse4("parseAssertStatement", "assert(throw x);", [
817 "parseAssertStatement", 675 ParserErrorCode.ASSERT_DOES_NOT_TAKE_THROW
818 "assert(throw x);", 676 ]);
819 [ParserErrorCode.ASSERT_DOES_NOT_TAKE_THROW]);
820 } 677 }
821 678
822 void test_breakOutsideOfLoop_breakInDoStatement() { 679 void test_breakOutsideOfLoop_breakInDoStatement() {
823 ParserTestCase.parse4("parseDoStatement", "do {break;} while (x);"); 680 ParserTestCase.parse4("parseDoStatement", "do {break;} while (x);");
824 } 681 }
825 682
826 void test_breakOutsideOfLoop_breakInForStatement() { 683 void test_breakOutsideOfLoop_breakInForStatement() {
827 ParserTestCase.parse4("parseForStatement", "for (; x;) {break;}"); 684 ParserTestCase.parse4("parseForStatement", "for (; x;) {break;}");
828 } 685 }
829 686
830 void test_breakOutsideOfLoop_breakInIfStatement() { 687 void test_breakOutsideOfLoop_breakInIfStatement() {
831 ParserTestCase.parse4( 688 ParserTestCase.parse4("parseIfStatement", "if (x) {break;}", [
832 "parseIfStatement", 689 ParserErrorCode.BREAK_OUTSIDE_OF_LOOP
833 "if (x) {break;}", 690 ]);
834 [ParserErrorCode.BREAK_OUTSIDE_OF_LOOP]);
835 } 691 }
836 692
837 void test_breakOutsideOfLoop_breakInSwitchStatement() { 693 void test_breakOutsideOfLoop_breakInSwitchStatement() {
838 ParserTestCase.parse4( 694 ParserTestCase.parse4(
839 "parseSwitchStatement", 695 "parseSwitchStatement", "switch (x) {case 1: break;}");
840 "switch (x) {case 1: break;}");
841 } 696 }
842 697
843 void test_breakOutsideOfLoop_breakInWhileStatement() { 698 void test_breakOutsideOfLoop_breakInWhileStatement() {
844 ParserTestCase.parse4("parseWhileStatement", "while (x) {break;}"); 699 ParserTestCase.parse4("parseWhileStatement", "while (x) {break;}");
845 } 700 }
846 701
847 void test_breakOutsideOfLoop_functionExpression_inALoop() { 702 void test_breakOutsideOfLoop_functionExpression_inALoop() {
848 ParserTestCase.parseStatement( 703 ParserTestCase.parseStatement(
849 "for(; x;) {() {break;};}", 704 "for(; x;) {() {break;};}", [ParserErrorCode.BREAK_OUTSIDE_OF_LOOP]);
850 [ParserErrorCode.BREAK_OUTSIDE_OF_LOOP]);
851 } 705 }
852 706
853 void test_breakOutsideOfLoop_functionExpression_withALoop() { 707 void test_breakOutsideOfLoop_functionExpression_withALoop() {
854 ParserTestCase.parseStatement("() {for (; x;) {break;}};"); 708 ParserTestCase.parseStatement("() {for (; x;) {break;}};");
855 } 709 }
856 710
857 void test_classInClass_abstract() { 711 void test_classInClass_abstract() {
858 ParserTestCase.parseCompilationUnit( 712 ParserTestCase.parseCompilationUnit(
859 "class C { abstract class B {} }", 713 "class C { abstract class B {} }", [ParserErrorCode.CLASS_IN_CLASS]);
860 [ParserErrorCode.CLASS_IN_CLASS]);
861 } 714 }
862 715
863 void test_classInClass_nonAbstract() { 716 void test_classInClass_nonAbstract() {
864 ParserTestCase.parseCompilationUnit( 717 ParserTestCase.parseCompilationUnit(
865 "class C { class B {} }", 718 "class C { class B {} }", [ParserErrorCode.CLASS_IN_CLASS]);
866 [ParserErrorCode.CLASS_IN_CLASS]);
867 } 719 }
868 720
869 void test_classTypeAlias_abstractAfterEq() { 721 void test_classTypeAlias_abstractAfterEq() {
870 // This syntax has been removed from the language in favor of 722 // This syntax has been removed from the language in favor of
871 // "abstract class A = B with C;" (issue 18098). 723 // "abstract class A = B with C;" (issue 18098).
872 ParserTestCase.parse3( 724 ParserTestCase.parse3("parseCompilationUnitMember", <Object>[
873 "parseCompilationUnitMember", 725 emptyCommentAndMetadata()
874 <Object>[emptyCommentAndMetadata()], 726 ], "class A = abstract B with C;", [
875 "class A = abstract B with C;", 727 ParserErrorCode.EXPECTED_TOKEN,
876 [ParserErrorCode.EXPECTED_TOKEN, ParserErrorCode.EXPECTED_TOKEN]); 728 ParserErrorCode.EXPECTED_TOKEN
729 ]);
877 } 730 }
878 731
879 void test_colonInPlaceOfIn() { 732 void test_colonInPlaceOfIn() {
880 ParserTestCase.parseStatement( 733 ParserTestCase.parseStatement(
881 "for (var x : list) {}", 734 "for (var x : list) {}", [ParserErrorCode.COLON_IN_PLACE_OF_IN]);
882 [ParserErrorCode.COLON_IN_PLACE_OF_IN]);
883 } 735 }
884 736
885 void test_constAndFinal() { 737 void test_constAndFinal() {
886 ParserTestCase.parse3( 738 ParserTestCase.parse3("parseClassMember", <Object>[
887 "parseClassMember", 739 "C"
888 <Object>["C"], 740 ], "const final int x;", [ParserErrorCode.CONST_AND_FINAL]);
889 "const final int x;",
890 [ParserErrorCode.CONST_AND_FINAL]);
891 } 741 }
892 742
893 void test_constAndVar() { 743 void test_constAndVar() {
894 ParserTestCase.parse3( 744 ParserTestCase.parse3("parseClassMember", <Object>["C"], "const var x;", [
895 "parseClassMember", 745 ParserErrorCode.CONST_AND_VAR
896 <Object>["C"], 746 ]);
897 "const var x;",
898 [ParserErrorCode.CONST_AND_VAR]);
899 } 747 }
900 748
901 void test_constClass() { 749 void test_constClass() {
902 ParserTestCase.parseCompilationUnit( 750 ParserTestCase.parseCompilationUnit(
903 "const class C {}", 751 "const class C {}", [ParserErrorCode.CONST_CLASS]);
904 [ParserErrorCode.CONST_CLASS]);
905 } 752 }
906 753
907 void test_constConstructorWithBody() { 754 void test_constConstructorWithBody() {
908 ParserTestCase.parse3( 755 ParserTestCase.parse3("parseClassMember", <Object>["C"], "const C() {}", [
909 "parseClassMember", 756 ParserErrorCode.CONST_CONSTRUCTOR_WITH_BODY
910 <Object>["C"], 757 ]);
911 "const C() {}",
912 [ParserErrorCode.CONST_CONSTRUCTOR_WITH_BODY]);
913 } 758 }
914 759
915 void test_constEnum() { 760 void test_constEnum() {
916 ParserTestCase.parseCompilationUnit( 761 ParserTestCase.parseCompilationUnit(
917 "const enum E {ONE}", 762 "const enum E {ONE}", [ParserErrorCode.CONST_ENUM]);
918 [ParserErrorCode.CONST_ENUM]);
919 } 763 }
920 764
921 void test_constFactory() { 765 void test_constFactory() {
922 ParserTestCase.parse3( 766 ParserTestCase.parse3("parseClassMember", <Object>[
923 "parseClassMember", 767 "C"
924 <Object>["C"], 768 ], "const factory C() {}", [ParserErrorCode.CONST_FACTORY]);
925 "const factory C() {}",
926 [ParserErrorCode.CONST_FACTORY]);
927 } 769 }
928 770
929 void test_constMethod() { 771 void test_constMethod() {
930 ParserTestCase.parse3( 772 ParserTestCase.parse3("parseClassMember", <Object>[
931 "parseClassMember", 773 "C"
932 <Object>["C"], 774 ], "const int m() {}", [ParserErrorCode.CONST_METHOD]);
933 "const int m() {}",
934 [ParserErrorCode.CONST_METHOD]);
935 } 775 }
936 776
937 void test_constructorWithReturnType() { 777 void test_constructorWithReturnType() {
938 ParserTestCase.parse3( 778 ParserTestCase.parse3("parseClassMember", <Object>["C"], "C C() {}", [
939 "parseClassMember", 779 ParserErrorCode.CONSTRUCTOR_WITH_RETURN_TYPE
940 <Object>["C"], 780 ]);
941 "C C() {}",
942 [ParserErrorCode.CONSTRUCTOR_WITH_RETURN_TYPE]);
943 } 781 }
944 782
945 void test_constructorWithReturnType_var() { 783 void test_constructorWithReturnType_var() {
946 ParserTestCase.parse3( 784 ParserTestCase.parse3("parseClassMember", <Object>["C"], "var C() {}", [
947 "parseClassMember", 785 ParserErrorCode.CONSTRUCTOR_WITH_RETURN_TYPE
948 <Object>["C"], 786 ]);
949 "var C() {}",
950 [ParserErrorCode.CONSTRUCTOR_WITH_RETURN_TYPE]);
951 } 787 }
952 788
953 void test_constTypedef() { 789 void test_constTypedef() {
954 ParserTestCase.parseCompilationUnit( 790 ParserTestCase.parseCompilationUnit(
955 "const typedef F();", 791 "const typedef F();", [ParserErrorCode.CONST_TYPEDEF]);
956 [ParserErrorCode.CONST_TYPEDEF]);
957 } 792 }
958 793
959 void test_continueOutsideOfLoop_continueInDoStatement() { 794 void test_continueOutsideOfLoop_continueInDoStatement() {
960 ParserTestCase.parse4("parseDoStatement", "do {continue;} while (x);"); 795 ParserTestCase.parse4("parseDoStatement", "do {continue;} while (x);");
961 } 796 }
962 797
963 void test_continueOutsideOfLoop_continueInForStatement() { 798 void test_continueOutsideOfLoop_continueInForStatement() {
964 ParserTestCase.parse4("parseForStatement", "for (; x;) {continue;}"); 799 ParserTestCase.parse4("parseForStatement", "for (; x;) {continue;}");
965 } 800 }
966 801
967 void test_continueOutsideOfLoop_continueInIfStatement() { 802 void test_continueOutsideOfLoop_continueInIfStatement() {
968 ParserTestCase.parse4( 803 ParserTestCase.parse4("parseIfStatement", "if (x) {continue;}", [
969 "parseIfStatement", 804 ParserErrorCode.CONTINUE_OUTSIDE_OF_LOOP
970 "if (x) {continue;}", 805 ]);
971 [ParserErrorCode.CONTINUE_OUTSIDE_OF_LOOP]);
972 } 806 }
973 807
974 void test_continueOutsideOfLoop_continueInSwitchStatement() { 808 void test_continueOutsideOfLoop_continueInSwitchStatement() {
975 ParserTestCase.parse4( 809 ParserTestCase.parse4(
976 "parseSwitchStatement", 810 "parseSwitchStatement", "switch (x) {case 1: continue a;}");
977 "switch (x) {case 1: continue a;}");
978 } 811 }
979 812
980 void test_continueOutsideOfLoop_continueInWhileStatement() { 813 void test_continueOutsideOfLoop_continueInWhileStatement() {
981 ParserTestCase.parse4("parseWhileStatement", "while (x) {continue;}"); 814 ParserTestCase.parse4("parseWhileStatement", "while (x) {continue;}");
982 } 815 }
983 816
984 void test_continueOutsideOfLoop_functionExpression_inALoop() { 817 void test_continueOutsideOfLoop_functionExpression_inALoop() {
985 ParserTestCase.parseStatement( 818 ParserTestCase.parseStatement("for(; x;) {() {continue;};}", [
986 "for(; x;) {() {continue;};}", 819 ParserErrorCode.CONTINUE_OUTSIDE_OF_LOOP
987 [ParserErrorCode.CONTINUE_OUTSIDE_OF_LOOP]); 820 ]);
988 } 821 }
989 822
990 void test_continueOutsideOfLoop_functionExpression_withALoop() { 823 void test_continueOutsideOfLoop_functionExpression_withALoop() {
991 ParserTestCase.parseStatement("() {for (; x;) {continue;}};"); 824 ParserTestCase.parseStatement("() {for (; x;) {continue;}};");
992 } 825 }
993 826
994 void test_continueWithoutLabelInCase_error() { 827 void test_continueWithoutLabelInCase_error() {
995 ParserTestCase.parse4( 828 ParserTestCase.parse4("parseSwitchStatement",
996 "parseSwitchStatement", 829 "switch (x) {case 1: continue;}", [
997 "switch (x) {case 1: continue;}", 830 ParserErrorCode.CONTINUE_WITHOUT_LABEL_IN_CASE
998 [ParserErrorCode.CONTINUE_WITHOUT_LABEL_IN_CASE]); 831 ]);
999 } 832 }
1000 833
1001 void test_continueWithoutLabelInCase_noError() { 834 void test_continueWithoutLabelInCase_noError() {
1002 ParserTestCase.parse4( 835 ParserTestCase.parse4(
1003 "parseSwitchStatement", 836 "parseSwitchStatement", "switch (x) {case 1: continue a;}");
1004 "switch (x) {case 1: continue a;}");
1005 } 837 }
1006 838
1007 void test_continueWithoutLabelInCase_noError_switchInLoop() { 839 void test_continueWithoutLabelInCase_noError_switchInLoop() {
1008 ParserTestCase.parse4( 840 ParserTestCase.parse4(
1009 "parseWhileStatement", 841 "parseWhileStatement", "while (a) { switch (b) {default: continue;}}");
1010 "while (a) { switch (b) {default: continue;}}");
1011 } 842 }
1012 843
1013 void test_deprecatedClassTypeAlias() { 844 void test_deprecatedClassTypeAlias() {
1014 ParserTestCase.parseCompilationUnit( 845 ParserTestCase.parseCompilationUnit(
1015 "typedef C = S with M;", 846 "typedef C = S with M;", [ParserErrorCode.DEPRECATED_CLASS_TYPE_ALIAS]);
1016 [ParserErrorCode.DEPRECATED_CLASS_TYPE_ALIAS]);
1017 } 847 }
1018 848
1019 void test_deprecatedClassTypeAlias_withGeneric() { 849 void test_deprecatedClassTypeAlias_withGeneric() {
1020 ParserTestCase.parseCompilationUnit( 850 ParserTestCase.parseCompilationUnit("typedef C<T> = S<T> with M;", [
1021 "typedef C<T> = S<T> with M;", 851 ParserErrorCode.DEPRECATED_CLASS_TYPE_ALIAS
1022 [ParserErrorCode.DEPRECATED_CLASS_TYPE_ALIAS]); 852 ]);
1023 } 853 }
1024 854
1025 void test_directiveAfterDeclaration_classBeforeDirective() { 855 void test_directiveAfterDeclaration_classBeforeDirective() {
1026 CompilationUnit unit = ParserTestCase.parseCompilationUnit( 856 CompilationUnit unit = ParserTestCase.parseCompilationUnit(
1027 "class Foo{} library l;", 857 "class Foo{} library l;", [
1028 [ParserErrorCode.DIRECTIVE_AFTER_DECLARATION]); 858 ParserErrorCode.DIRECTIVE_AFTER_DECLARATION
859 ]);
1029 expect(unit, isNotNull); 860 expect(unit, isNotNull);
1030 } 861 }
1031 862
1032 void test_directiveAfterDeclaration_classBetweenDirectives() { 863 void test_directiveAfterDeclaration_classBetweenDirectives() {
1033 CompilationUnit unit = ParserTestCase.parseCompilationUnit( 864 CompilationUnit unit = ParserTestCase.parseCompilationUnit(
1034 "library l;\nclass Foo{}\npart 'a.dart';", 865 "library l;\nclass Foo{}\npart 'a.dart';", [
1035 [ParserErrorCode.DIRECTIVE_AFTER_DECLARATION]); 866 ParserErrorCode.DIRECTIVE_AFTER_DECLARATION
867 ]);
1036 expect(unit, isNotNull); 868 expect(unit, isNotNull);
1037 } 869 }
1038 870
1039 void test_duplicatedModifier_const() { 871 void test_duplicatedModifier_const() {
1040 ParserTestCase.parse3( 872 ParserTestCase.parse3("parseClassMember", <Object>["C"], "const const m;", [
1041 "parseClassMember", 873 ParserErrorCode.DUPLICATED_MODIFIER
1042 <Object>["C"], 874 ]);
1043 "const const m;",
1044 [ParserErrorCode.DUPLICATED_MODIFIER]);
1045 } 875 }
1046 876
1047 void test_duplicatedModifier_external() { 877 void test_duplicatedModifier_external() {
1048 ParserTestCase.parse3( 878 ParserTestCase.parse3("parseClassMember", <Object>[
1049 "parseClassMember", 879 "C"
1050 <Object>["C"], 880 ], "external external f();", [ParserErrorCode.DUPLICATED_MODIFIER]);
1051 "external external f();",
1052 [ParserErrorCode.DUPLICATED_MODIFIER]);
1053 } 881 }
1054 882
1055 void test_duplicatedModifier_factory() { 883 void test_duplicatedModifier_factory() {
1056 ParserTestCase.parse3( 884 ParserTestCase.parse3("parseClassMember", <Object>[
1057 "parseClassMember", 885 "C"
1058 <Object>["C"], 886 ], "factory factory C() {}", [ParserErrorCode.DUPLICATED_MODIFIER]);
1059 "factory factory C() {}",
1060 [ParserErrorCode.DUPLICATED_MODIFIER]);
1061 } 887 }
1062 888
1063 void test_duplicatedModifier_final() { 889 void test_duplicatedModifier_final() {
1064 ParserTestCase.parse3( 890 ParserTestCase.parse3("parseClassMember", <Object>["C"], "final final m;", [
1065 "parseClassMember", 891 ParserErrorCode.DUPLICATED_MODIFIER
1066 <Object>["C"], 892 ]);
1067 "final final m;",
1068 [ParserErrorCode.DUPLICATED_MODIFIER]);
1069 } 893 }
1070 894
1071 void test_duplicatedModifier_static() { 895 void test_duplicatedModifier_static() {
1072 ParserTestCase.parse3( 896 ParserTestCase.parse3("parseClassMember", <Object>[
1073 "parseClassMember", 897 "C"
1074 <Object>["C"], 898 ], "static static var m;", [ParserErrorCode.DUPLICATED_MODIFIER]);
1075 "static static var m;",
1076 [ParserErrorCode.DUPLICATED_MODIFIER]);
1077 } 899 }
1078 900
1079 void test_duplicatedModifier_var() { 901 void test_duplicatedModifier_var() {
1080 ParserTestCase.parse3( 902 ParserTestCase.parse3("parseClassMember", <Object>["C"], "var var m;", [
1081 "parseClassMember", 903 ParserErrorCode.DUPLICATED_MODIFIER
1082 <Object>["C"], 904 ]);
1083 "var var m;",
1084 [ParserErrorCode.DUPLICATED_MODIFIER]);
1085 } 905 }
1086 906
1087 void test_duplicateLabelInSwitchStatement() { 907 void test_duplicateLabelInSwitchStatement() {
1088 ParserTestCase.parse4( 908 ParserTestCase.parse4("parseSwitchStatement",
1089 "parseSwitchStatement", 909 "switch (e) {l1: case 0: break; l1: case 1: break;}", [
1090 "switch (e) {l1: case 0: break; l1: case 1: break;}", 910 ParserErrorCode.DUPLICATE_LABEL_IN_SWITCH_STATEMENT
1091 [ParserErrorCode.DUPLICATE_LABEL_IN_SWITCH_STATEMENT]); 911 ]);
1092 } 912 }
1093 913
1094 void test_emptyEnumBody() { 914 void test_emptyEnumBody() {
1095 ParserTestCase.parse3( 915 ParserTestCase.parse3("parseEnumDeclaration", <Object>[
1096 "parseEnumDeclaration", 916 emptyCommentAndMetadata()
1097 <Object>[emptyCommentAndMetadata()], 917 ], "enum E {}", [ParserErrorCode.EMPTY_ENUM_BODY]);
1098 "enum E {}",
1099 [ParserErrorCode.EMPTY_ENUM_BODY]);
1100 } 918 }
1101 919
1102 void test_equalityCannotBeEqualityOperand_eq_eq() { 920 void test_equalityCannotBeEqualityOperand_eq_eq() {
1103 ParserTestCase.parseExpression( 921 ParserTestCase.parseExpression(
1104 "1 == 2 == 3", 922 "1 == 2 == 3", [ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND]);
1105 [ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND]);
1106 } 923 }
1107 924
1108 void test_equalityCannotBeEqualityOperand_eq_neq() { 925 void test_equalityCannotBeEqualityOperand_eq_neq() {
1109 ParserTestCase.parseExpression( 926 ParserTestCase.parseExpression(
1110 "1 == 2 != 3", 927 "1 == 2 != 3", [ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND]);
1111 [ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND]);
1112 } 928 }
1113 929
1114 void test_equalityCannotBeEqualityOperand_neq_eq() { 930 void test_equalityCannotBeEqualityOperand_neq_eq() {
1115 ParserTestCase.parseExpression( 931 ParserTestCase.parseExpression(
1116 "1 != 2 == 3", 932 "1 != 2 == 3", [ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND]);
1117 [ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND]);
1118 } 933 }
1119 934
1120 void test_expectedCaseOrDefault() { 935 void test_expectedCaseOrDefault() {
1121 ParserTestCase.parse4( 936 ParserTestCase.parse4("parseSwitchStatement", "switch (e) {break;}", [
1122 "parseSwitchStatement", 937 ParserErrorCode.EXPECTED_CASE_OR_DEFAULT
1123 "switch (e) {break;}", 938 ]);
1124 [ParserErrorCode.EXPECTED_CASE_OR_DEFAULT]);
1125 } 939 }
1126 940
1127 void test_expectedClassMember_inClass_afterType() { 941 void test_expectedClassMember_inClass_afterType() {
1128 ParserTestCase.parse3( 942 ParserTestCase.parse3("parseClassMember", <Object>["C"], "heart 2 heart", [
1129 "parseClassMember", 943 ParserErrorCode.EXPECTED_CLASS_MEMBER
1130 <Object>["C"], 944 ]);
1131 "heart 2 heart",
1132 [ParserErrorCode.EXPECTED_CLASS_MEMBER]);
1133 } 945 }
1134 946
1135 void test_expectedClassMember_inClass_beforeType() { 947 void test_expectedClassMember_inClass_beforeType() {
1136 ParserTestCase.parse3( 948 ParserTestCase.parse3("parseClassMember", <Object>["C"], "4 score", [
1137 "parseClassMember", 949 ParserErrorCode.EXPECTED_CLASS_MEMBER
1138 <Object>["C"], 950 ]);
1139 "4 score",
1140 [ParserErrorCode.EXPECTED_CLASS_MEMBER]);
1141 } 951 }
1142 952
1143 void test_expectedExecutable_inClass_afterVoid() { 953 void test_expectedExecutable_inClass_afterVoid() {
1144 ParserTestCase.parse3( 954 ParserTestCase.parse3("parseClassMember", <Object>["C"], "void 2 void", [
1145 "parseClassMember", 955 ParserErrorCode.EXPECTED_EXECUTABLE
1146 <Object>["C"], 956 ]);
1147 "void 2 void",
1148 [ParserErrorCode.EXPECTED_EXECUTABLE]);
1149 } 957 }
1150 958
1151 void test_expectedExecutable_topLevel_afterType() { 959 void test_expectedExecutable_topLevel_afterType() {
1152 ParserTestCase.parse3( 960 ParserTestCase.parse3("parseCompilationUnitMember", <Object>[
1153 "parseCompilationUnitMember", 961 emptyCommentAndMetadata()
1154 <Object>[emptyCommentAndMetadata()], 962 ], "heart 2 heart", [ParserErrorCode.EXPECTED_EXECUTABLE]);
1155 "heart 2 heart",
1156 [ParserErrorCode.EXPECTED_EXECUTABLE]);
1157 } 963 }
1158 964
1159 void test_expectedExecutable_topLevel_afterVoid() { 965 void test_expectedExecutable_topLevel_afterVoid() {
1160 ParserTestCase.parse3( 966 ParserTestCase.parse3("parseCompilationUnitMember", <Object>[
1161 "parseCompilationUnitMember", 967 emptyCommentAndMetadata()
1162 <Object>[emptyCommentAndMetadata()], 968 ], "void 2 void", [ParserErrorCode.EXPECTED_EXECUTABLE]);
1163 "void 2 void",
1164 [ParserErrorCode.EXPECTED_EXECUTABLE]);
1165 } 969 }
1166 970
1167 void test_expectedExecutable_topLevel_beforeType() { 971 void test_expectedExecutable_topLevel_beforeType() {
1168 ParserTestCase.parse3( 972 ParserTestCase.parse3("parseCompilationUnitMember", <Object>[
1169 "parseCompilationUnitMember", 973 emptyCommentAndMetadata()
1170 <Object>[emptyCommentAndMetadata()], 974 ], "4 score", [ParserErrorCode.EXPECTED_EXECUTABLE]);
1171 "4 score",
1172 [ParserErrorCode.EXPECTED_EXECUTABLE]);
1173 } 975 }
1174 976
1175 void test_expectedExecutable_topLevel_eof() { 977 void test_expectedExecutable_topLevel_eof() {
1176 ParserTestCase.parse2( 978 ParserTestCase.parse2("parseCompilationUnitMember", <Object>[
1177 "parseCompilationUnitMember", 979 emptyCommentAndMetadata()
1178 <Object>[emptyCommentAndMetadata()], 980 ], "x", [
1179 "x", 981 new AnalysisError.con2(null, 0, 1, ParserErrorCode.EXPECTED_EXECUTABLE)
1180 [new AnalysisError.con2(null, 0, 1, ParserErrorCode.EXPECTED_EXECUTABLE) ]); 982 ]);
1181 } 983 }
1182 984
1183 void test_expectedInterpolationIdentifier() { 985 void test_expectedInterpolationIdentifier() {
1184 ParserTestCase.parse4( 986 ParserTestCase.parse4(
1185 "parseStringLiteral", 987 "parseStringLiteral", "'\$x\$'", [ParserErrorCode.MISSING_IDENTIFIER]);
1186 "'\$x\$'",
1187 [ParserErrorCode.MISSING_IDENTIFIER]);
1188 } 988 }
1189 989
1190 void test_expectedInterpolationIdentifier_emptyString() { 990 void test_expectedInterpolationIdentifier_emptyString() {
1191 // The scanner inserts an empty string token between the two $'s; we need to 991 // The scanner inserts an empty string token between the two $'s; we need to
1192 // make sure that the MISSING_IDENTIFIER error that is generated has a 992 // make sure that the MISSING_IDENTIFIER error that is generated has a
1193 // nonzero width so that it will show up in the editor UI. 993 // nonzero width so that it will show up in the editor UI.
1194 ParserTestCase.parse2( 994 ParserTestCase.parse2("parseStringLiteral", <Object>[], "'\$\$foo'", [
1195 "parseStringLiteral", 995 new AnalysisError.con2(null, 2, 1, ParserErrorCode.MISSING_IDENTIFIER)
1196 <Object>[], 996 ]);
1197 "'\$\$foo'",
1198 [new AnalysisError.con2(null, 2, 1, ParserErrorCode.MISSING_IDENTIFIER)] );
1199 } 997 }
1200 998
1201 void test_expectedStringLiteral() { 999 void test_expectedStringLiteral() {
1202 StringLiteral expression = ParserTestCase.parse4( 1000 StringLiteral expression = ParserTestCase.parse4(
1203 "parseStringLiteral", 1001 "parseStringLiteral", "1", [ParserErrorCode.EXPECTED_STRING_LITERAL]);
1204 "1",
1205 [ParserErrorCode.EXPECTED_STRING_LITERAL]);
1206 expect(expression.isSynthetic, isTrue); 1002 expect(expression.isSynthetic, isTrue);
1207 } 1003 }
1208 1004
1209 void test_expectedToken_commaMissingInArgumentList() { 1005 void test_expectedToken_commaMissingInArgumentList() {
1210 ParserTestCase.parse4( 1006 ParserTestCase.parse4(
1211 "parseArgumentList", 1007 "parseArgumentList", "(x, y z)", [ParserErrorCode.EXPECTED_TOKEN]);
1212 "(x, y z)",
1213 [ParserErrorCode.EXPECTED_TOKEN]);
1214 } 1008 }
1215 1009
1216 void test_expectedToken_parseStatement_afterVoid() { 1010 void test_expectedToken_parseStatement_afterVoid() {
1217 ParserTestCase.parseStatement( 1011 ParserTestCase.parseStatement("void}", [
1218 "void}", 1012 ParserErrorCode.EXPECTED_TOKEN,
1219 [ParserErrorCode.EXPECTED_TOKEN, ParserErrorCode.MISSING_IDENTIFIER]); 1013 ParserErrorCode.MISSING_IDENTIFIER
1014 ]);
1220 } 1015 }
1221 1016
1222 void test_expectedToken_semicolonAfterClass() { 1017 void test_expectedToken_semicolonAfterClass() {
1223 Token token = TokenFactory.tokenFromKeyword(Keyword.CLASS); 1018 Token token = TokenFactory.tokenFromKeyword(Keyword.CLASS);
1224 ParserTestCase.parse3( 1019 ParserTestCase.parse3("parseClassTypeAlias", <Object>[
1225 "parseClassTypeAlias", 1020 emptyCommentAndMetadata(),
1226 <Object>[emptyCommentAndMetadata(), null, token], 1021 null,
1227 "A = B with C", 1022 token
1228 [ParserErrorCode.EXPECTED_TOKEN]); 1023 ], "A = B with C", [ParserErrorCode.EXPECTED_TOKEN]);
1229 } 1024 }
1230 1025
1231 void test_expectedToken_semicolonMissingAfterExport() { 1026 void test_expectedToken_semicolonMissingAfterExport() {
1232 CompilationUnit unit = ParserTestCase.parseCompilationUnit( 1027 CompilationUnit unit = ParserTestCase.parseCompilationUnit(
1233 "export '' class A {}", 1028 "export '' class A {}", [ParserErrorCode.EXPECTED_TOKEN]);
1234 [ParserErrorCode.EXPECTED_TOKEN]);
1235 ExportDirective directive = unit.directives[0] as ExportDirective; 1029 ExportDirective directive = unit.directives[0] as ExportDirective;
1236 Token semicolon = directive.semicolon; 1030 Token semicolon = directive.semicolon;
1237 expect(semicolon, isNotNull); 1031 expect(semicolon, isNotNull);
1238 expect(semicolon.isSynthetic, isTrue); 1032 expect(semicolon.isSynthetic, isTrue);
1239 } 1033 }
1240 1034
1241 void test_expectedToken_semicolonMissingAfterExpression() { 1035 void test_expectedToken_semicolonMissingAfterExpression() {
1242 ParserTestCase.parseStatement("x", [ParserErrorCode.EXPECTED_TOKEN]); 1036 ParserTestCase.parseStatement("x", [ParserErrorCode.EXPECTED_TOKEN]);
1243 } 1037 }
1244 1038
1245 void test_expectedToken_semicolonMissingAfterImport() { 1039 void test_expectedToken_semicolonMissingAfterImport() {
1246 CompilationUnit unit = ParserTestCase.parseCompilationUnit( 1040 CompilationUnit unit = ParserTestCase.parseCompilationUnit(
1247 "import '' class A {}", 1041 "import '' class A {}", [ParserErrorCode.EXPECTED_TOKEN]);
1248 [ParserErrorCode.EXPECTED_TOKEN]);
1249 ImportDirective directive = unit.directives[0] as ImportDirective; 1042 ImportDirective directive = unit.directives[0] as ImportDirective;
1250 Token semicolon = directive.semicolon; 1043 Token semicolon = directive.semicolon;
1251 expect(semicolon, isNotNull); 1044 expect(semicolon, isNotNull);
1252 expect(semicolon.isSynthetic, isTrue); 1045 expect(semicolon.isSynthetic, isTrue);
1253 } 1046 }
1254 1047
1255 void test_expectedToken_whileMissingInDoStatement() { 1048 void test_expectedToken_whileMissingInDoStatement() {
1256 ParserTestCase.parseStatement( 1049 ParserTestCase.parseStatement(
1257 "do {} (x);", 1050 "do {} (x);", [ParserErrorCode.EXPECTED_TOKEN]);
1258 [ParserErrorCode.EXPECTED_TOKEN]);
1259 } 1051 }
1260 1052
1261 void test_expectedTypeName_is() { 1053 void test_expectedTypeName_is() {
1262 ParserTestCase.parseExpression( 1054 ParserTestCase.parseExpression(
1263 "x is", 1055 "x is", [ParserErrorCode.EXPECTED_TYPE_NAME]);
1264 [ParserErrorCode.EXPECTED_TYPE_NAME]);
1265 } 1056 }
1266 1057
1267 void test_exportDirectiveAfterPartDirective() { 1058 void test_exportDirectiveAfterPartDirective() {
1268 ParserTestCase.parseCompilationUnit( 1059 ParserTestCase.parseCompilationUnit("part 'a.dart'; export 'b.dart';", [
1269 "part 'a.dart'; export 'b.dart';", 1060 ParserErrorCode.EXPORT_DIRECTIVE_AFTER_PART_DIRECTIVE
1270 [ParserErrorCode.EXPORT_DIRECTIVE_AFTER_PART_DIRECTIVE]); 1061 ]);
1271 } 1062 }
1272 1063
1273 void test_externalAfterConst() { 1064 void test_externalAfterConst() {
1274 ParserTestCase.parse3( 1065 ParserTestCase.parse3("parseClassMember", <Object>[
1275 "parseClassMember", 1066 "C"
1276 <Object>["C"], 1067 ], "const external C();", [ParserErrorCode.EXTERNAL_AFTER_CONST]);
1277 "const external C();",
1278 [ParserErrorCode.EXTERNAL_AFTER_CONST]);
1279 } 1068 }
1280 1069
1281 void test_externalAfterFactory() { 1070 void test_externalAfterFactory() {
1282 ParserTestCase.parse3( 1071 ParserTestCase.parse3("parseClassMember", <Object>[
1283 "parseClassMember", 1072 "C"
1284 <Object>["C"], 1073 ], "factory external C();", [ParserErrorCode.EXTERNAL_AFTER_FACTORY]);
1285 "factory external C();",
1286 [ParserErrorCode.EXTERNAL_AFTER_FACTORY]);
1287 } 1074 }
1288 1075
1289 void test_externalAfterStatic() { 1076 void test_externalAfterStatic() {
1290 ParserTestCase.parse3( 1077 ParserTestCase.parse3("parseClassMember", <Object>[
1291 "parseClassMember", 1078 "C"
1292 <Object>["C"], 1079 ], "static external int m();", [ParserErrorCode.EXTERNAL_AFTER_STATIC]);
1293 "static external int m();",
1294 [ParserErrorCode.EXTERNAL_AFTER_STATIC]);
1295 } 1080 }
1296 1081
1297 void test_externalClass() { 1082 void test_externalClass() {
1298 ParserTestCase.parseCompilationUnit( 1083 ParserTestCase.parseCompilationUnit(
1299 "external class C {}", 1084 "external class C {}", [ParserErrorCode.EXTERNAL_CLASS]);
1300 [ParserErrorCode.EXTERNAL_CLASS]);
1301 } 1085 }
1302 1086
1303 void test_externalConstructorWithBody_factory() { 1087 void test_externalConstructorWithBody_factory() {
1304 ParserTestCase.parse3( 1088 ParserTestCase.parse3("parseClassMember", <Object>[
1305 "parseClassMember", 1089 "C"
1306 <Object>["C"], 1090 ], "external factory C() {}", [
1307 "external factory C() {}", 1091 ParserErrorCode.EXTERNAL_CONSTRUCTOR_WITH_BODY
1308 [ParserErrorCode.EXTERNAL_CONSTRUCTOR_WITH_BODY]); 1092 ]);
1309 } 1093 }
1310 1094
1311 void test_externalConstructorWithBody_named() { 1095 void test_externalConstructorWithBody_named() {
1312 ParserTestCase.parse3( 1096 ParserTestCase.parse3("parseClassMember", <Object>[
1313 "parseClassMember", 1097 "C"
1314 <Object>["C"], 1098 ], "external C.c() {}", [ParserErrorCode.EXTERNAL_CONSTRUCTOR_WITH_BODY]);
1315 "external C.c() {}",
1316 [ParserErrorCode.EXTERNAL_CONSTRUCTOR_WITH_BODY]);
1317 } 1099 }
1318 1100
1319 void test_externalEnum() { 1101 void test_externalEnum() {
1320 ParserTestCase.parseCompilationUnit( 1102 ParserTestCase.parseCompilationUnit(
1321 "external enum E {ONE}", 1103 "external enum E {ONE}", [ParserErrorCode.EXTERNAL_ENUM]);
1322 [ParserErrorCode.EXTERNAL_ENUM]);
1323 } 1104 }
1324 1105
1325 void test_externalField_const() { 1106 void test_externalField_const() {
1326 ParserTestCase.parse3( 1107 ParserTestCase.parse3("parseClassMember", <Object>[
1327 "parseClassMember", 1108 "C"
1328 <Object>["C"], 1109 ], "external const A f;", [ParserErrorCode.EXTERNAL_FIELD]);
1329 "external const A f;",
1330 [ParserErrorCode.EXTERNAL_FIELD]);
1331 } 1110 }
1332 1111
1333 void test_externalField_final() { 1112 void test_externalField_final() {
1334 ParserTestCase.parse3( 1113 ParserTestCase.parse3("parseClassMember", <Object>[
1335 "parseClassMember", 1114 "C"
1336 <Object>["C"], 1115 ], "external final A f;", [ParserErrorCode.EXTERNAL_FIELD]);
1337 "external final A f;",
1338 [ParserErrorCode.EXTERNAL_FIELD]);
1339 } 1116 }
1340 1117
1341 void test_externalField_static() { 1118 void test_externalField_static() {
1342 ParserTestCase.parse3( 1119 ParserTestCase.parse3("parseClassMember", <Object>[
1343 "parseClassMember", 1120 "C"
1344 <Object>["C"], 1121 ], "external static A f;", [ParserErrorCode.EXTERNAL_FIELD]);
1345 "external static A f;",
1346 [ParserErrorCode.EXTERNAL_FIELD]);
1347 } 1122 }
1348 1123
1349 void test_externalField_typed() { 1124 void test_externalField_typed() {
1350 ParserTestCase.parse3( 1125 ParserTestCase.parse3("parseClassMember", <Object>["C"], "external A f;", [
1351 "parseClassMember", 1126 ParserErrorCode.EXTERNAL_FIELD
1352 <Object>["C"], 1127 ]);
1353 "external A f;",
1354 [ParserErrorCode.EXTERNAL_FIELD]);
1355 } 1128 }
1356 1129
1357 void test_externalField_untyped() { 1130 void test_externalField_untyped() {
1358 ParserTestCase.parse3( 1131 ParserTestCase.parse3("parseClassMember", <Object>[
1359 "parseClassMember", 1132 "C"
1360 <Object>["C"], 1133 ], "external var f;", [ParserErrorCode.EXTERNAL_FIELD]);
1361 "external var f;",
1362 [ParserErrorCode.EXTERNAL_FIELD]);
1363 } 1134 }
1364 1135
1365 void test_externalGetterWithBody() { 1136 void test_externalGetterWithBody() {
1366 ParserTestCase.parse3( 1137 ParserTestCase.parse3("parseClassMember", <Object>[
1367 "parseClassMember", 1138 "C"
1368 <Object>["C"], 1139 ], "external int get x {}", [ParserErrorCode.EXTERNAL_GETTER_WITH_BODY]);
1369 "external int get x {}",
1370 [ParserErrorCode.EXTERNAL_GETTER_WITH_BODY]);
1371 } 1140 }
1372 1141
1373 void test_externalMethodWithBody() { 1142 void test_externalMethodWithBody() {
1374 ParserTestCase.parse3( 1143 ParserTestCase.parse3("parseClassMember", <Object>[
1375 "parseClassMember", 1144 "C"
1376 <Object>["C"], 1145 ], "external m() {}", [ParserErrorCode.EXTERNAL_METHOD_WITH_BODY]);
1377 "external m() {}",
1378 [ParserErrorCode.EXTERNAL_METHOD_WITH_BODY]);
1379 } 1146 }
1380 1147
1381 void test_externalOperatorWithBody() { 1148 void test_externalOperatorWithBody() {
1382 ParserTestCase.parse3( 1149 ParserTestCase.parse3("parseClassMember", <Object>[
1383 "parseClassMember", 1150 "C"
1384 <Object>["C"], 1151 ], "external operator +(int value) {}", [
1385 "external operator +(int value) {}", 1152 ParserErrorCode.EXTERNAL_OPERATOR_WITH_BODY
1386 [ParserErrorCode.EXTERNAL_OPERATOR_WITH_BODY]); 1153 ]);
1387 } 1154 }
1388 1155
1389 void test_externalSetterWithBody() { 1156 void test_externalSetterWithBody() {
1390 ParserTestCase.parse3( 1157 ParserTestCase.parse3("parseClassMember", <Object>[
1391 "parseClassMember", 1158 "C"
1392 <Object>["C"], 1159 ], "external set x(int value) {}", [
1393 "external set x(int value) {}", 1160 ParserErrorCode.EXTERNAL_SETTER_WITH_BODY
1394 [ParserErrorCode.EXTERNAL_SETTER_WITH_BODY]); 1161 ]);
1395 } 1162 }
1396 1163
1397 void test_externalTypedef() { 1164 void test_externalTypedef() {
1398 ParserTestCase.parseCompilationUnit( 1165 ParserTestCase.parseCompilationUnit(
1399 "external typedef F();", 1166 "external typedef F();", [ParserErrorCode.EXTERNAL_TYPEDEF]);
1400 [ParserErrorCode.EXTERNAL_TYPEDEF]);
1401 } 1167 }
1402 1168
1403 void test_factoryTopLevelDeclaration_class() { 1169 void test_factoryTopLevelDeclaration_class() {
1404 ParserTestCase.parseCompilationUnit( 1170 ParserTestCase.parseCompilationUnit(
1405 "factory class C {}", 1171 "factory class C {}", [ParserErrorCode.FACTORY_TOP_LEVEL_DECLARATION]);
1406 [ParserErrorCode.FACTORY_TOP_LEVEL_DECLARATION]);
1407 } 1172 }
1408 1173
1409 void test_factoryTopLevelDeclaration_typedef() { 1174 void test_factoryTopLevelDeclaration_typedef() {
1410 ParserTestCase.parseCompilationUnit( 1175 ParserTestCase.parseCompilationUnit("factory typedef F();", [
1411 "factory typedef F();", 1176 ParserErrorCode.FACTORY_TOP_LEVEL_DECLARATION
1412 [ParserErrorCode.FACTORY_TOP_LEVEL_DECLARATION]); 1177 ]);
1413 } 1178 }
1414 1179
1415 void test_factoryWithInitializers() { 1180 void test_factoryWithInitializers() {
1416 ParserTestCase.parse3( 1181 ParserTestCase.parse3("parseClassMember", <Object>[
1417 "parseClassMember", 1182 "C"
1418 <Object>["C"], 1183 ], "factory C() : x = 3 {}", [ParserErrorCode.FACTORY_WITH_INITIALIZERS]);
1419 "factory C() : x = 3 {}",
1420 [ParserErrorCode.FACTORY_WITH_INITIALIZERS]);
1421 } 1184 }
1422 1185
1423 void test_factoryWithoutBody() { 1186 void test_factoryWithoutBody() {
1424 ParserTestCase.parse3( 1187 ParserTestCase.parse3("parseClassMember", <Object>["C"], "factory C();", [
1425 "parseClassMember", 1188 ParserErrorCode.FACTORY_WITHOUT_BODY
1426 <Object>["C"], 1189 ]);
1427 "factory C();",
1428 [ParserErrorCode.FACTORY_WITHOUT_BODY]);
1429 } 1190 }
1430 1191
1431 void test_fieldInitializerOutsideConstructor() { 1192 void test_fieldInitializerOutsideConstructor() {
1432 ParserTestCase.parse3( 1193 ParserTestCase.parse3("parseClassMember", <Object>["C"], "void m(this.x);",
1433 "parseClassMember",
1434 <Object>["C"],
1435 "void m(this.x);",
1436 [ParserErrorCode.FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR]); 1194 [ParserErrorCode.FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR]);
1437 } 1195 }
1438 1196
1439 void test_finalAndVar() { 1197 void test_finalAndVar() {
1440 ParserTestCase.parse3( 1198 ParserTestCase.parse3("parseClassMember", <Object>["C"], "final var x;", [
1441 "parseClassMember", 1199 ParserErrorCode.FINAL_AND_VAR
1442 <Object>["C"], 1200 ]);
1443 "final var x;",
1444 [ParserErrorCode.FINAL_AND_VAR]);
1445 } 1201 }
1446 1202
1447 void test_finalClass() { 1203 void test_finalClass() {
1448 ParserTestCase.parseCompilationUnit( 1204 ParserTestCase.parseCompilationUnit(
1449 "final class C {}", 1205 "final class C {}", [ParserErrorCode.FINAL_CLASS]);
1450 [ParserErrorCode.FINAL_CLASS]);
1451 } 1206 }
1452 1207
1453 void test_finalConstructor() { 1208 void test_finalConstructor() {
1454 ParserTestCase.parse3( 1209 ParserTestCase.parse3("parseClassMember", <Object>["C"], "final C() {}", [
1455 "parseClassMember", 1210 ParserErrorCode.FINAL_CONSTRUCTOR
1456 <Object>["C"], 1211 ]);
1457 "final C() {}",
1458 [ParserErrorCode.FINAL_CONSTRUCTOR]);
1459 } 1212 }
1460 1213
1461 void test_finalEnum() { 1214 void test_finalEnum() {
1462 ParserTestCase.parseCompilationUnit( 1215 ParserTestCase.parseCompilationUnit(
1463 "final enum E {ONE}", 1216 "final enum E {ONE}", [ParserErrorCode.FINAL_ENUM]);
1464 [ParserErrorCode.FINAL_ENUM]);
1465 } 1217 }
1466 1218
1467 void test_finalMethod() { 1219 void test_finalMethod() {
1468 ParserTestCase.parse3( 1220 ParserTestCase.parse3("parseClassMember", <Object>[
1469 "parseClassMember", 1221 "C"
1470 <Object>["C"], 1222 ], "final int m() {}", [ParserErrorCode.FINAL_METHOD]);
1471 "final int m() {}",
1472 [ParserErrorCode.FINAL_METHOD]);
1473 } 1223 }
1474 1224
1475 void test_finalTypedef() { 1225 void test_finalTypedef() {
1476 ParserTestCase.parseCompilationUnit( 1226 ParserTestCase.parseCompilationUnit(
1477 "final typedef F();", 1227 "final typedef F();", [ParserErrorCode.FINAL_TYPEDEF]);
1478 [ParserErrorCode.FINAL_TYPEDEF]);
1479 } 1228 }
1480 1229
1481 void test_functionTypedParameter_const() { 1230 void test_functionTypedParameter_const() {
1482 ParserTestCase.parseCompilationUnit( 1231 ParserTestCase.parseCompilationUnit(
1483 "void f(const x()) {}", 1232 "void f(const x()) {}", [ParserErrorCode.FUNCTION_TYPED_PARAMETER_VAR]);
1484 [ParserErrorCode.FUNCTION_TYPED_PARAMETER_VAR]);
1485 } 1233 }
1486 1234
1487 void test_functionTypedParameter_final() { 1235 void test_functionTypedParameter_final() {
1488 ParserTestCase.parseCompilationUnit( 1236 ParserTestCase.parseCompilationUnit(
1489 "void f(final x()) {}", 1237 "void f(final x()) {}", [ParserErrorCode.FUNCTION_TYPED_PARAMETER_VAR]);
1490 [ParserErrorCode.FUNCTION_TYPED_PARAMETER_VAR]);
1491 } 1238 }
1492 1239
1493 void test_functionTypedParameter_var() { 1240 void test_functionTypedParameter_var() {
1494 ParserTestCase.parseCompilationUnit( 1241 ParserTestCase.parseCompilationUnit(
1495 "void f(var x()) {}", 1242 "void f(var x()) {}", [ParserErrorCode.FUNCTION_TYPED_PARAMETER_VAR]);
1496 [ParserErrorCode.FUNCTION_TYPED_PARAMETER_VAR]);
1497 } 1243 }
1498 1244
1499 void test_getterInFunction_block_noReturnType() { 1245 void test_getterInFunction_block_noReturnType() {
1500 ParserTestCase.parseStatement( 1246 ParserTestCase.parseStatement(
1501 "get x { return _x; }", 1247 "get x { return _x; }", [ParserErrorCode.GETTER_IN_FUNCTION]);
1502 [ParserErrorCode.GETTER_IN_FUNCTION]);
1503 } 1248 }
1504 1249
1505 void test_getterInFunction_block_returnType() { 1250 void test_getterInFunction_block_returnType() {
1506 ParserTestCase.parseStatement( 1251 ParserTestCase.parseStatement(
1507 "int get x { return _x; }", 1252 "int get x { return _x; }", [ParserErrorCode.GETTER_IN_FUNCTION]);
1508 [ParserErrorCode.GETTER_IN_FUNCTION]);
1509 } 1253 }
1510 1254
1511 void test_getterInFunction_expression_noReturnType() { 1255 void test_getterInFunction_expression_noReturnType() {
1512 ParserTestCase.parseStatement( 1256 ParserTestCase.parseStatement(
1513 "get x => _x;", 1257 "get x => _x;", [ParserErrorCode.GETTER_IN_FUNCTION]);
1514 [ParserErrorCode.GETTER_IN_FUNCTION]);
1515 } 1258 }
1516 1259
1517 void test_getterInFunction_expression_returnType() { 1260 void test_getterInFunction_expression_returnType() {
1518 ParserTestCase.parseStatement( 1261 ParserTestCase.parseStatement(
1519 "int get x => _x;", 1262 "int get x => _x;", [ParserErrorCode.GETTER_IN_FUNCTION]);
1520 [ParserErrorCode.GETTER_IN_FUNCTION]);
1521 } 1263 }
1522 1264
1523 void test_getterWithParameters() { 1265 void test_getterWithParameters() {
1524 ParserTestCase.parse3( 1266 ParserTestCase.parse3("parseClassMember", <Object>["C"], "int get x() {}", [
1525 "parseClassMember", 1267 ParserErrorCode.GETTER_WITH_PARAMETERS
1526 <Object>["C"], 1268 ]);
1527 "int get x() {}",
1528 [ParserErrorCode.GETTER_WITH_PARAMETERS]);
1529 } 1269 }
1530 1270
1531 void test_illegalAssignmentToNonAssignable_postfix_minusMinus_literal() { 1271 void test_illegalAssignmentToNonAssignable_postfix_minusMinus_literal() {
1532 ParserTestCase.parseExpression( 1272 ParserTestCase.parseExpression(
1533 "0--", 1273 "0--", [ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE]);
1534 [ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE]);
1535 } 1274 }
1536 1275
1537 void test_illegalAssignmentToNonAssignable_postfix_plusPlus_literal() { 1276 void test_illegalAssignmentToNonAssignable_postfix_plusPlus_literal() {
1538 ParserTestCase.parseExpression( 1277 ParserTestCase.parseExpression(
1539 "0++", 1278 "0++", [ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE]);
1540 [ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE]);
1541 } 1279 }
1542 1280
1543 void test_illegalAssignmentToNonAssignable_postfix_plusPlus_parethesized() { 1281 void test_illegalAssignmentToNonAssignable_postfix_plusPlus_parethesized() {
1544 ParserTestCase.parseExpression( 1282 ParserTestCase.parseExpression(
1545 "(x)++", 1283 "(x)++", [ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE]);
1546 [ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE]);
1547 } 1284 }
1548 1285
1549 void test_illegalAssignmentToNonAssignable_primarySelectorPostfix() { 1286 void test_illegalAssignmentToNonAssignable_primarySelectorPostfix() {
1550 ParserTestCase.parseExpression( 1287 ParserTestCase.parseExpression(
1551 "x(y)(z)++", 1288 "x(y)(z)++", [ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE]);
1552 [ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE]);
1553 } 1289 }
1554 1290
1555 void test_illegalAssignmentToNonAssignable_superAssigned() { 1291 void test_illegalAssignmentToNonAssignable_superAssigned() {
1556 // TODO(brianwilkerson) When the test 1292 // TODO(brianwilkerson) When the test
1557 // fail_illegalAssignmentToNonAssignable_superAssigned starts to pass, 1293 // fail_illegalAssignmentToNonAssignable_superAssigned starts to pass,
1558 // remove this test (there should only be one error generated, but we're 1294 // remove this test (there should only be one error generated, but we're
1559 // keeping this test until that time so that we can catch other forms of 1295 // keeping this test until that time so that we can catch other forms of
1560 // regressions). 1296 // regressions).
1561 ParserTestCase.parseExpression( 1297 ParserTestCase.parseExpression("super = x;", [
1562 "super = x;", 1298 ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR,
1563 [ 1299 ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE
1564 ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR, 1300 ]);
1565 ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE]);
1566 } 1301 }
1567 1302
1568 void test_implementsBeforeExtends() { 1303 void test_implementsBeforeExtends() {
1569 ParserTestCase.parseCompilationUnit( 1304 ParserTestCase.parseCompilationUnit("class A implements B extends C {}", [
1570 "class A implements B extends C {}", 1305 ParserErrorCode.IMPLEMENTS_BEFORE_EXTENDS
1571 [ParserErrorCode.IMPLEMENTS_BEFORE_EXTENDS]); 1306 ]);
1572 } 1307 }
1573 1308
1574 void test_implementsBeforeWith() { 1309 void test_implementsBeforeWith() {
1575 ParserTestCase.parseCompilationUnit( 1310 ParserTestCase.parseCompilationUnit(
1576 "class A extends B implements C with D {}", 1311 "class A extends B implements C with D {}", [
1577 [ParserErrorCode.IMPLEMENTS_BEFORE_WITH]); 1312 ParserErrorCode.IMPLEMENTS_BEFORE_WITH
1313 ]);
1578 } 1314 }
1579 1315
1580 void test_importDirectiveAfterPartDirective() { 1316 void test_importDirectiveAfterPartDirective() {
1581 ParserTestCase.parseCompilationUnit( 1317 ParserTestCase.parseCompilationUnit("part 'a.dart'; import 'b.dart';", [
1582 "part 'a.dart'; import 'b.dart';", 1318 ParserErrorCode.IMPORT_DIRECTIVE_AFTER_PART_DIRECTIVE
1583 [ParserErrorCode.IMPORT_DIRECTIVE_AFTER_PART_DIRECTIVE]); 1319 ]);
1584 } 1320 }
1585 1321
1586 void test_initializedVariableInForEach() { 1322 void test_initializedVariableInForEach() {
1587 ParserTestCase.parse4( 1323 ParserTestCase.parse4("parseForStatement", "for (int a = 0 in foo) {}", [
1588 "parseForStatement", 1324 ParserErrorCode.INITIALIZED_VARIABLE_IN_FOR_EACH
1589 "for (int a = 0 in foo) {}", 1325 ]);
1590 [ParserErrorCode.INITIALIZED_VARIABLE_IN_FOR_EACH]);
1591 } 1326 }
1592 1327
1593 void test_invalidAwaitInFor() { 1328 void test_invalidAwaitInFor() {
1594 ParserTestCase.parse4( 1329 ParserTestCase.parse4("parseForStatement", "await for (; ;) {}", [
1595 "parseForStatement", 1330 ParserErrorCode.INVALID_AWAIT_IN_FOR
1596 "await for (; ;) {}", 1331 ]);
1597 [ParserErrorCode.INVALID_AWAIT_IN_FOR]);
1598 } 1332 }
1599 1333
1600 void test_invalidCodePoint() { 1334 void test_invalidCodePoint() {
1601 ParserTestCase.parse4( 1335 ParserTestCase.parse4("parseStringLiteral", "'\\uD900'", [
1602 "parseStringLiteral", 1336 ParserErrorCode.INVALID_CODE_POINT
1603 "'\\uD900'", 1337 ]);
1604 [ParserErrorCode.INVALID_CODE_POINT]);
1605 } 1338 }
1606 1339
1607 void test_invalidHexEscape_invalidDigit() { 1340 void test_invalidHexEscape_invalidDigit() {
1608 ParserTestCase.parse4( 1341 ParserTestCase.parse4(
1609 "parseStringLiteral", 1342 "parseStringLiteral", "'\\x0 a'", [ParserErrorCode.INVALID_HEX_ESCAPE]);
1610 "'\\x0 a'",
1611 [ParserErrorCode.INVALID_HEX_ESCAPE]);
1612 } 1343 }
1613 1344
1614 void test_invalidHexEscape_tooFewDigits() { 1345 void test_invalidHexEscape_tooFewDigits() {
1615 ParserTestCase.parse4( 1346 ParserTestCase.parse4(
1616 "parseStringLiteral", 1347 "parseStringLiteral", "'\\x0'", [ParserErrorCode.INVALID_HEX_ESCAPE]);
1617 "'\\x0'",
1618 [ParserErrorCode.INVALID_HEX_ESCAPE]);
1619 } 1348 }
1620 1349
1621 void test_invalidInterpolationIdentifier_startWithDigit() { 1350 void test_invalidInterpolationIdentifier_startWithDigit() {
1622 ParserTestCase.parse4( 1351 ParserTestCase.parse4(
1623 "parseStringLiteral", 1352 "parseStringLiteral", "'\$1'", [ParserErrorCode.MISSING_IDENTIFIER]);
1624 "'\$1'",
1625 [ParserErrorCode.MISSING_IDENTIFIER]);
1626 } 1353 }
1627 1354
1628 void test_invalidOperator() { 1355 void test_invalidOperator() {
1629 ParserTestCase.parse3( 1356 ParserTestCase.parse3("parseClassMember", <Object>[
1630 "parseClassMember", 1357 "C"
1631 <Object>["C"], 1358 ], "void operator ===(x) {}", [ParserErrorCode.INVALID_OPERATOR]);
1632 "void operator ===(x) {}",
1633 [ParserErrorCode.INVALID_OPERATOR]);
1634 } 1359 }
1635 1360
1636 void test_invalidOperatorForSuper() { 1361 void test_invalidOperatorForSuper() {
1637 ParserTestCase.parse4( 1362 ParserTestCase.parse4("parseUnaryExpression", "++super", [
1638 "parseUnaryExpression", 1363 ParserErrorCode.INVALID_OPERATOR_FOR_SUPER
1639 "++super", 1364 ]);
1640 [ParserErrorCode.INVALID_OPERATOR_FOR_SUPER]);
1641 } 1365 }
1642 1366
1643 void test_invalidStarAfterAsync() { 1367 void test_invalidStarAfterAsync() {
1644 ParserTestCase.parse3( 1368 ParserTestCase.parse3("parseFunctionBody", <Object>[
1645 "parseFunctionBody", 1369 false,
1646 <Object>[false, null, false], 1370 null,
1647 "async* => 0;", 1371 false
1648 [ParserErrorCode.INVALID_STAR_AFTER_ASYNC]); 1372 ], "async* => 0;", [ParserErrorCode.INVALID_STAR_AFTER_ASYNC]);
1649 } 1373 }
1650 1374
1651 void test_invalidSync() { 1375 void test_invalidSync() {
1652 ParserTestCase.parse3( 1376 ParserTestCase.parse3("parseFunctionBody", <Object>[
1653 "parseFunctionBody", 1377 false,
1654 <Object>[false, null, false], 1378 null,
1655 "sync* => 0;", 1379 false
1656 [ParserErrorCode.INVALID_SYNC]); 1380 ], "sync* => 0;", [ParserErrorCode.INVALID_SYNC]);
1657 } 1381 }
1658 1382
1659 void test_invalidUnicodeEscape_incomplete_noDigits() { 1383 void test_invalidUnicodeEscape_incomplete_noDigits() {
1660 ParserTestCase.parse4( 1384 ParserTestCase.parse4("parseStringLiteral", "'\\u{'", [
1661 "parseStringLiteral", 1385 ParserErrorCode.INVALID_UNICODE_ESCAPE
1662 "'\\u{'", 1386 ]);
1663 [ParserErrorCode.INVALID_UNICODE_ESCAPE]);
1664 } 1387 }
1665 1388
1666 void test_invalidUnicodeEscape_incomplete_someDigits() { 1389 void test_invalidUnicodeEscape_incomplete_someDigits() {
1667 ParserTestCase.parse4( 1390 ParserTestCase.parse4("parseStringLiteral", "'\\u{0A'", [
1668 "parseStringLiteral", 1391 ParserErrorCode.INVALID_UNICODE_ESCAPE
1669 "'\\u{0A'", 1392 ]);
1670 [ParserErrorCode.INVALID_UNICODE_ESCAPE]);
1671 } 1393 }
1672 1394
1673 void test_invalidUnicodeEscape_invalidDigit() { 1395 void test_invalidUnicodeEscape_invalidDigit() {
1674 ParserTestCase.parse4( 1396 ParserTestCase.parse4("parseStringLiteral", "'\\u0 a'", [
1675 "parseStringLiteral", 1397 ParserErrorCode.INVALID_UNICODE_ESCAPE
1676 "'\\u0 a'", 1398 ]);
1677 [ParserErrorCode.INVALID_UNICODE_ESCAPE]);
1678 } 1399 }
1679 1400
1680 void test_invalidUnicodeEscape_tooFewDigits_fixed() { 1401 void test_invalidUnicodeEscape_tooFewDigits_fixed() {
1681 ParserTestCase.parse4( 1402 ParserTestCase.parse4("parseStringLiteral", "'\\u04'", [
1682 "parseStringLiteral", 1403 ParserErrorCode.INVALID_UNICODE_ESCAPE
1683 "'\\u04'", 1404 ]);
1684 [ParserErrorCode.INVALID_UNICODE_ESCAPE]);
1685 } 1405 }
1686 1406
1687 void test_invalidUnicodeEscape_tooFewDigits_variable() { 1407 void test_invalidUnicodeEscape_tooFewDigits_variable() {
1688 ParserTestCase.parse4( 1408 ParserTestCase.parse4("parseStringLiteral", "'\\u{}'", [
1689 "parseStringLiteral", 1409 ParserErrorCode.INVALID_UNICODE_ESCAPE
1690 "'\\u{}'", 1410 ]);
1691 [ParserErrorCode.INVALID_UNICODE_ESCAPE]);
1692 } 1411 }
1693 1412
1694 void test_invalidUnicodeEscape_tooManyDigits_variable() { 1413 void test_invalidUnicodeEscape_tooManyDigits_variable() {
1695 ParserTestCase.parse4( 1414 ParserTestCase.parse4("parseStringLiteral", "'\\u{12345678}'", [
1696 "parseStringLiteral", 1415 ParserErrorCode.INVALID_UNICODE_ESCAPE,
1697 "'\\u{12345678}'", 1416 ParserErrorCode.INVALID_CODE_POINT
1698 [ParserErrorCode.INVALID_UNICODE_ESCAPE, ParserErrorCode.INVALID_CODE_PO INT]); 1417 ]);
1699 } 1418 }
1700 1419
1701 void test_libraryDirectiveNotFirst() { 1420 void test_libraryDirectiveNotFirst() {
1702 ParserTestCase.parseCompilationUnit( 1421 ParserTestCase.parseCompilationUnit("import 'x.dart'; library l;", [
1703 "import 'x.dart'; library l;", 1422 ParserErrorCode.LIBRARY_DIRECTIVE_NOT_FIRST
1704 [ParserErrorCode.LIBRARY_DIRECTIVE_NOT_FIRST]); 1423 ]);
1705 } 1424 }
1706 1425
1707 void test_libraryDirectiveNotFirst_afterPart() { 1426 void test_libraryDirectiveNotFirst_afterPart() {
1708 CompilationUnit unit = ParserTestCase.parseCompilationUnit( 1427 CompilationUnit unit = ParserTestCase.parseCompilationUnit(
1709 "part 'a.dart';\nlibrary l;", 1428 "part 'a.dart';\nlibrary l;", [
1710 [ParserErrorCode.LIBRARY_DIRECTIVE_NOT_FIRST]); 1429 ParserErrorCode.LIBRARY_DIRECTIVE_NOT_FIRST
1430 ]);
1711 expect(unit, isNotNull); 1431 expect(unit, isNotNull);
1712 } 1432 }
1713 1433
1714 void test_localFunctionDeclarationModifier_abstract() { 1434 void test_localFunctionDeclarationModifier_abstract() {
1715 ParserTestCase.parseStatement( 1435 ParserTestCase.parseStatement("abstract f() {}", [
1716 "abstract f() {}", 1436 ParserErrorCode.LOCAL_FUNCTION_DECLARATION_MODIFIER
1717 [ParserErrorCode.LOCAL_FUNCTION_DECLARATION_MODIFIER]); 1437 ]);
1718 } 1438 }
1719 1439
1720 void test_localFunctionDeclarationModifier_external() { 1440 void test_localFunctionDeclarationModifier_external() {
1721 ParserTestCase.parseStatement( 1441 ParserTestCase.parseStatement("external f() {}", [
1722 "external f() {}", 1442 ParserErrorCode.LOCAL_FUNCTION_DECLARATION_MODIFIER
1723 [ParserErrorCode.LOCAL_FUNCTION_DECLARATION_MODIFIER]); 1443 ]);
1724 } 1444 }
1725 1445
1726 void test_localFunctionDeclarationModifier_factory() { 1446 void test_localFunctionDeclarationModifier_factory() {
1727 ParserTestCase.parseStatement( 1447 ParserTestCase.parseStatement("factory f() {}", [
1728 "factory f() {}", 1448 ParserErrorCode.LOCAL_FUNCTION_DECLARATION_MODIFIER
1729 [ParserErrorCode.LOCAL_FUNCTION_DECLARATION_MODIFIER]); 1449 ]);
1730 } 1450 }
1731 1451
1732 void test_localFunctionDeclarationModifier_static() { 1452 void test_localFunctionDeclarationModifier_static() {
1733 ParserTestCase.parseStatement( 1453 ParserTestCase.parseStatement(
1734 "static f() {}", 1454 "static f() {}", [ParserErrorCode.LOCAL_FUNCTION_DECLARATION_MODIFIER]);
1735 [ParserErrorCode.LOCAL_FUNCTION_DECLARATION_MODIFIER]);
1736 } 1455 }
1737 1456
1738 void test_missingAssignableSelector_identifiersAssigned() { 1457 void test_missingAssignableSelector_identifiersAssigned() {
1739 ParserTestCase.parseExpression("x.y = y;"); 1458 ParserTestCase.parseExpression("x.y = y;");
1740 } 1459 }
1741 1460
1742 void test_missingAssignableSelector_prefix_minusMinus_literal() { 1461 void test_missingAssignableSelector_prefix_minusMinus_literal() {
1743 ParserTestCase.parseExpression( 1462 ParserTestCase.parseExpression(
1744 "--0", 1463 "--0", [ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR]);
1745 [ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR]);
1746 } 1464 }
1747 1465
1748 void test_missingAssignableSelector_prefix_plusPlus_literal() { 1466 void test_missingAssignableSelector_prefix_plusPlus_literal() {
1749 ParserTestCase.parseExpression( 1467 ParserTestCase.parseExpression(
1750 "++0", 1468 "++0", [ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR]);
1751 [ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR]);
1752 } 1469 }
1753 1470
1754 void test_missingAssignableSelector_selector() { 1471 void test_missingAssignableSelector_selector() {
1755 ParserTestCase.parseExpression("x(y)(z).a++"); 1472 ParserTestCase.parseExpression("x(y)(z).a++");
1756 } 1473 }
1757 1474
1758 void test_missingAssignableSelector_superPrimaryExpression() { 1475 void test_missingAssignableSelector_superPrimaryExpression() {
1759 SuperExpression expression = ParserTestCase.parse4( 1476 SuperExpression expression = ParserTestCase.parse4("parsePrimaryExpression",
1760 "parsePrimaryExpression", 1477 "super", [ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR]);
1761 "super",
1762 [ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR]);
1763 expect(expression.superKeyword, isNotNull); 1478 expect(expression.superKeyword, isNotNull);
1764 } 1479 }
1765 1480
1766 void test_missingAssignableSelector_superPropertyAccessAssigned() { 1481 void test_missingAssignableSelector_superPropertyAccessAssigned() {
1767 ParserTestCase.parseExpression("super.x = x;"); 1482 ParserTestCase.parseExpression("super.x = x;");
1768 } 1483 }
1769 1484
1770 void test_missingCatchOrFinally() { 1485 void test_missingCatchOrFinally() {
1771 TryStatement statement = ParserTestCase.parse4( 1486 TryStatement statement = ParserTestCase.parse4("parseTryStatement",
1772 "parseTryStatement", 1487 "try {}", [ParserErrorCode.MISSING_CATCH_OR_FINALLY]);
1773 "try {}",
1774 [ParserErrorCode.MISSING_CATCH_OR_FINALLY]);
1775 expect(statement, isNotNull); 1488 expect(statement, isNotNull);
1776 } 1489 }
1777 1490
1778 void test_missingClassBody() { 1491 void test_missingClassBody() {
1779 ParserTestCase.parseCompilationUnit( 1492 ParserTestCase.parseCompilationUnit(
1780 "class A class B {}", 1493 "class A class B {}", [ParserErrorCode.MISSING_CLASS_BODY]);
1781 [ParserErrorCode.MISSING_CLASS_BODY]);
1782 } 1494 }
1783 1495
1784 void test_missingConstFinalVarOrType_static() { 1496 void test_missingConstFinalVarOrType_static() {
1785 ParserTestCase.parseCompilationUnit( 1497 ParserTestCase.parseCompilationUnit("class A { static f; }", [
1786 "class A { static f; }", 1498 ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE
1787 [ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE]); 1499 ]);
1788 } 1500 }
1789 1501
1790 void test_missingConstFinalVarOrType_topLevel() { 1502 void test_missingConstFinalVarOrType_topLevel() {
1791 ParserTestCase.parse3( 1503 ParserTestCase.parse3("parseFinalConstVarOrType", <Object>[false], "a;", [
1792 "parseFinalConstVarOrType", 1504 ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE
1793 <Object>[false], 1505 ]);
1794 "a;",
1795 [ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE]);
1796 } 1506 }
1797 1507
1798 void test_missingEnumBody() { 1508 void test_missingEnumBody() {
1799 ParserTestCase.parse3( 1509 ParserTestCase.parse3("parseEnumDeclaration", <Object>[
1800 "parseEnumDeclaration", 1510 emptyCommentAndMetadata()
1801 <Object>[emptyCommentAndMetadata()], 1511 ], "enum E;", [ParserErrorCode.MISSING_ENUM_BODY]);
1802 "enum E;",
1803 [ParserErrorCode.MISSING_ENUM_BODY]);
1804 } 1512 }
1805 1513
1806 void test_missingExpressionInThrow_withCascade() { 1514 void test_missingExpressionInThrow_withCascade() {
1807 ParserTestCase.parse4( 1515 ParserTestCase.parse4("parseThrowExpression", "throw;", [
1808 "parseThrowExpression", 1516 ParserErrorCode.MISSING_EXPRESSION_IN_THROW
1809 "throw;", 1517 ]);
1810 [ParserErrorCode.MISSING_EXPRESSION_IN_THROW]);
1811 } 1518 }
1812 1519
1813 void test_missingExpressionInThrow_withoutCascade() { 1520 void test_missingExpressionInThrow_withoutCascade() {
1814 ParserTestCase.parse4( 1521 ParserTestCase.parse4("parseThrowExpressionWithoutCascade", "throw;", [
1815 "parseThrowExpressionWithoutCascade", 1522 ParserErrorCode.MISSING_EXPRESSION_IN_THROW
1816 "throw;", 1523 ]);
1817 [ParserErrorCode.MISSING_EXPRESSION_IN_THROW]);
1818 } 1524 }
1819 1525
1820 void test_missingFunctionBody_emptyNotAllowed() { 1526 void test_missingFunctionBody_emptyNotAllowed() {
1821 ParserTestCase.parse3( 1527 ParserTestCase.parse3("parseFunctionBody", <Object>[
1822 "parseFunctionBody", 1528 false,
1823 <Object>[false, ParserErrorCode.MISSING_FUNCTION_BODY, false], 1529 ParserErrorCode.MISSING_FUNCTION_BODY,
1824 ";", 1530 false
1825 [ParserErrorCode.MISSING_FUNCTION_BODY]); 1531 ], ";", [ParserErrorCode.MISSING_FUNCTION_BODY]);
1826 } 1532 }
1827 1533
1828 void test_missingFunctionBody_invalid() { 1534 void test_missingFunctionBody_invalid() {
1829 ParserTestCase.parse3( 1535 ParserTestCase.parse3("parseFunctionBody", <Object>[
1830 "parseFunctionBody", 1536 false,
1831 <Object>[false, ParserErrorCode.MISSING_FUNCTION_BODY, false], 1537 ParserErrorCode.MISSING_FUNCTION_BODY,
1832 "return 0;", 1538 false
1833 [ParserErrorCode.MISSING_FUNCTION_BODY]); 1539 ], "return 0;", [ParserErrorCode.MISSING_FUNCTION_BODY]);
1834 } 1540 }
1835 1541
1836 void test_missingFunctionParameters_local_void_block() { 1542 void test_missingFunctionParameters_local_void_block() {
1837 ParserTestCase.parseStatement( 1543 ParserTestCase.parseStatement(
1838 "void f { return x;}", 1544 "void f { return x;}", [ParserErrorCode.MISSING_FUNCTION_PARAMETERS]);
1839 [ParserErrorCode.MISSING_FUNCTION_PARAMETERS]);
1840 } 1545 }
1841 1546
1842 void test_missingFunctionParameters_local_void_expression() { 1547 void test_missingFunctionParameters_local_void_expression() {
1843 ParserTestCase.parseStatement( 1548 ParserTestCase.parseStatement(
1844 "void f => x;", 1549 "void f => x;", [ParserErrorCode.MISSING_FUNCTION_PARAMETERS]);
1845 [ParserErrorCode.MISSING_FUNCTION_PARAMETERS]);
1846 } 1550 }
1847 1551
1848 void test_missingFunctionParameters_topLevel_nonVoid_block() { 1552 void test_missingFunctionParameters_topLevel_nonVoid_block() {
1849 ParserTestCase.parseCompilationUnit( 1553 ParserTestCase.parseCompilationUnit(
1850 "int f { return x;}", 1554 "int f { return x;}", [ParserErrorCode.MISSING_FUNCTION_PARAMETERS]);
1851 [ParserErrorCode.MISSING_FUNCTION_PARAMETERS]);
1852 } 1555 }
1853 1556
1854 void test_missingFunctionParameters_topLevel_nonVoid_expression() { 1557 void test_missingFunctionParameters_topLevel_nonVoid_expression() {
1855 ParserTestCase.parseCompilationUnit( 1558 ParserTestCase.parseCompilationUnit(
1856 "int f => x;", 1559 "int f => x;", [ParserErrorCode.MISSING_FUNCTION_PARAMETERS]);
1857 [ParserErrorCode.MISSING_FUNCTION_PARAMETERS]);
1858 } 1560 }
1859 1561
1860 void test_missingFunctionParameters_topLevel_void_block() { 1562 void test_missingFunctionParameters_topLevel_void_block() {
1861 ParserTestCase.parseCompilationUnit( 1563 ParserTestCase.parseCompilationUnit(
1862 "void f { return x;}", 1564 "void f { return x;}", [ParserErrorCode.MISSING_FUNCTION_PARAMETERS]);
1863 [ParserErrorCode.MISSING_FUNCTION_PARAMETERS]);
1864 } 1565 }
1865 1566
1866 void test_missingFunctionParameters_topLevel_void_expression() { 1567 void test_missingFunctionParameters_topLevel_void_expression() {
1867 ParserTestCase.parseCompilationUnit( 1568 ParserTestCase.parseCompilationUnit(
1868 "void f => x;", 1569 "void f => x;", [ParserErrorCode.MISSING_FUNCTION_PARAMETERS]);
1869 [ParserErrorCode.MISSING_FUNCTION_PARAMETERS]);
1870 } 1570 }
1871 1571
1872 void test_missingIdentifier_afterOperator() { 1572 void test_missingIdentifier_afterOperator() {
1873 ParserTestCase.parse4( 1573 ParserTestCase.parse4("parseMultiplicativeExpression", "1 *", [
1874 "parseMultiplicativeExpression", 1574 ParserErrorCode.MISSING_IDENTIFIER
1875 "1 *", 1575 ]);
1876 [ParserErrorCode.MISSING_IDENTIFIER]);
1877 } 1576 }
1878 1577
1879 void test_missingIdentifier_beforeClosingCurly() { 1578 void test_missingIdentifier_beforeClosingCurly() {
1880 ParserTestCase.parse3( 1579 ParserTestCase.parse3("parseClassMember", <Object>["C"], "int}", [
1881 "parseClassMember", 1580 ParserErrorCode.MISSING_IDENTIFIER,
1882 <Object>["C"], 1581 ParserErrorCode.EXPECTED_TOKEN
1883 "int}", 1582 ]);
1884 [ParserErrorCode.MISSING_IDENTIFIER, ParserErrorCode.EXPECTED_TOKEN]);
1885 } 1583 }
1886 1584
1887 void test_missingIdentifier_functionDeclaration_returnTypeWithoutName() { 1585 void test_missingIdentifier_functionDeclaration_returnTypeWithoutName() {
1888 ParserTestCase.parse4( 1586 ParserTestCase.parse4("parseFunctionDeclarationStatement", "A<T> () {}", [
1889 "parseFunctionDeclarationStatement", 1587 ParserErrorCode.MISSING_IDENTIFIER
1890 "A<T> () {}", 1588 ]);
1891 [ParserErrorCode.MISSING_IDENTIFIER]);
1892 } 1589 }
1893 1590
1894 void test_missingIdentifier_inEnum() { 1591 void test_missingIdentifier_inEnum() {
1895 ParserTestCase.parse3( 1592 ParserTestCase.parse3("parseEnumDeclaration", <Object>[
1896 "parseEnumDeclaration", 1593 emptyCommentAndMetadata()
1897 <Object>[emptyCommentAndMetadata()], 1594 ], "enum E {, TWO}", [ParserErrorCode.MISSING_IDENTIFIER]);
1898 "enum E {, TWO}",
1899 [ParserErrorCode.MISSING_IDENTIFIER]);
1900 } 1595 }
1901 1596
1902 void test_missingIdentifier_inSymbol_afterPeriod() { 1597 void test_missingIdentifier_inSymbol_afterPeriod() {
1903 ParserTestCase.parse4( 1598 ParserTestCase.parse4(
1904 "parseSymbolLiteral", 1599 "parseSymbolLiteral", "#a.", [ParserErrorCode.MISSING_IDENTIFIER]);
1905 "#a.",
1906 [ParserErrorCode.MISSING_IDENTIFIER]);
1907 } 1600 }
1908 1601
1909 void test_missingIdentifier_inSymbol_first() { 1602 void test_missingIdentifier_inSymbol_first() {
1910 ParserTestCase.parse4( 1603 ParserTestCase.parse4(
1911 "parseSymbolLiteral", 1604 "parseSymbolLiteral", "#", [ParserErrorCode.MISSING_IDENTIFIER]);
1912 "#",
1913 [ParserErrorCode.MISSING_IDENTIFIER]);
1914 } 1605 }
1915 1606
1916 void test_missingIdentifier_number() { 1607 void test_missingIdentifier_number() {
1917 SimpleIdentifier expression = ParserTestCase.parse4( 1608 SimpleIdentifier expression = ParserTestCase.parse4(
1918 "parseSimpleIdentifier", 1609 "parseSimpleIdentifier", "1", [ParserErrorCode.MISSING_IDENTIFIER]);
1919 "1",
1920 [ParserErrorCode.MISSING_IDENTIFIER]);
1921 expect(expression.isSynthetic, isTrue); 1610 expect(expression.isSynthetic, isTrue);
1922 } 1611 }
1923 1612
1924 void test_missingKeywordOperator() { 1613 void test_missingKeywordOperator() {
1925 ParserTestCase.parse3( 1614 ParserTestCase.parse3("parseOperator", <Object>[
1926 "parseOperator", 1615 emptyCommentAndMetadata(),
1927 <Object>[emptyCommentAndMetadata(), null, null], 1616 null,
1928 "+(x) {}", 1617 null
1929 [ParserErrorCode.MISSING_KEYWORD_OPERATOR]); 1618 ], "+(x) {}", [ParserErrorCode.MISSING_KEYWORD_OPERATOR]);
1930 } 1619 }
1931 1620
1932 void test_missingKeywordOperator_parseClassMember() { 1621 void test_missingKeywordOperator_parseClassMember() {
1933 ParserTestCase.parse3( 1622 ParserTestCase.parse3("parseClassMember", <Object>["C"], "+() {}", [
1934 "parseClassMember", 1623 ParserErrorCode.MISSING_KEYWORD_OPERATOR
1935 <Object>["C"], 1624 ]);
1936 "+() {}",
1937 [ParserErrorCode.MISSING_KEYWORD_OPERATOR]);
1938 } 1625 }
1939 1626
1940 void test_missingKeywordOperator_parseClassMember_afterTypeName() { 1627 void test_missingKeywordOperator_parseClassMember_afterTypeName() {
1941 ParserTestCase.parse3( 1628 ParserTestCase.parse3("parseClassMember", <Object>["C"], "int +() {}", [
1942 "parseClassMember", 1629 ParserErrorCode.MISSING_KEYWORD_OPERATOR
1943 <Object>["C"], 1630 ]);
1944 "int +() {}",
1945 [ParserErrorCode.MISSING_KEYWORD_OPERATOR]);
1946 } 1631 }
1947 1632
1948 void test_missingKeywordOperator_parseClassMember_afterVoid() { 1633 void test_missingKeywordOperator_parseClassMember_afterVoid() {
1949 ParserTestCase.parse3( 1634 ParserTestCase.parse3("parseClassMember", <Object>["C"], "void +() {}", [
1950 "parseClassMember", 1635 ParserErrorCode.MISSING_KEYWORD_OPERATOR
1951 <Object>["C"], 1636 ]);
1952 "void +() {}",
1953 [ParserErrorCode.MISSING_KEYWORD_OPERATOR]);
1954 } 1637 }
1955 1638
1956 void test_missingMethodParameters_void_block() { 1639 void test_missingMethodParameters_void_block() {
1957 ParserTestCase.parse3( 1640 ParserTestCase.parse3("parseClassMember", <Object>["C"], "void m {} }", [
1958 "parseClassMember", 1641 ParserErrorCode.MISSING_METHOD_PARAMETERS
1959 <Object>["C"], 1642 ]);
1960 "void m {} }",
1961 [ParserErrorCode.MISSING_METHOD_PARAMETERS]);
1962 } 1643 }
1963 1644
1964 void test_missingMethodParameters_void_expression() { 1645 void test_missingMethodParameters_void_expression() {
1965 ParserTestCase.parse3( 1646 ParserTestCase.parse3("parseClassMember", <Object>[
1966 "parseClassMember", 1647 "C"
1967 <Object>["C"], 1648 ], "void m => null; }", [ParserErrorCode.MISSING_METHOD_PARAMETERS]);
1968 "void m => null; }",
1969 [ParserErrorCode.MISSING_METHOD_PARAMETERS]);
1970 } 1649 }
1971 1650
1972 void test_missingNameInLibraryDirective() { 1651 void test_missingNameInLibraryDirective() {
1973 CompilationUnit unit = ParserTestCase.parseCompilationUnit( 1652 CompilationUnit unit = ParserTestCase.parseCompilationUnit(
1974 "library;", 1653 "library;", [ParserErrorCode.MISSING_NAME_IN_LIBRARY_DIRECTIVE]);
1975 [ParserErrorCode.MISSING_NAME_IN_LIBRARY_DIRECTIVE]);
1976 expect(unit, isNotNull); 1654 expect(unit, isNotNull);
1977 } 1655 }
1978 1656
1979 void test_missingNameInPartOfDirective() { 1657 void test_missingNameInPartOfDirective() {
1980 CompilationUnit unit = ParserTestCase.parseCompilationUnit( 1658 CompilationUnit unit = ParserTestCase.parseCompilationUnit(
1981 "part of;", 1659 "part of;", [ParserErrorCode.MISSING_NAME_IN_PART_OF_DIRECTIVE]);
1982 [ParserErrorCode.MISSING_NAME_IN_PART_OF_DIRECTIVE]);
1983 expect(unit, isNotNull); 1660 expect(unit, isNotNull);
1984 } 1661 }
1985 1662
1986 void test_missingPrefixInDeferredImport() { 1663 void test_missingPrefixInDeferredImport() {
1987 ParserTestCase.parseCompilationUnit( 1664 ParserTestCase.parseCompilationUnit("import 'foo.dart' deferred;", [
1988 "import 'foo.dart' deferred;", 1665 ParserErrorCode.MISSING_PREFIX_IN_DEFERRED_IMPORT
1989 [ParserErrorCode.MISSING_PREFIX_IN_DEFERRED_IMPORT]); 1666 ]);
1990 } 1667 }
1991 1668
1992 void test_missingStartAfterSync() { 1669 void test_missingStartAfterSync() {
1993 ParserTestCase.parse3( 1670 ParserTestCase.parse3("parseFunctionBody", <Object>[
1994 "parseFunctionBody", 1671 false,
1995 <Object>[false, null, false], 1672 null,
1996 "sync {}", 1673 false
1997 [ParserErrorCode.MISSING_STAR_AFTER_SYNC]); 1674 ], "sync {}", [ParserErrorCode.MISSING_STAR_AFTER_SYNC]);
1998 } 1675 }
1999 1676
2000 void test_missingStatement() { 1677 void test_missingStatement() {
2001 ParserTestCase.parseStatement("is", [ParserErrorCode.MISSING_STATEMENT]); 1678 ParserTestCase.parseStatement("is", [ParserErrorCode.MISSING_STATEMENT]);
2002 } 1679 }
2003 1680
2004 void test_missingStatement_afterVoid() { 1681 void test_missingStatement_afterVoid() {
2005 ParserTestCase.parseStatement("void;", [ParserErrorCode.MISSING_STATEMENT]); 1682 ParserTestCase.parseStatement("void;", [ParserErrorCode.MISSING_STATEMENT]);
2006 } 1683 }
2007 1684
2008 void test_missingTerminatorForParameterGroup_named() { 1685 void test_missingTerminatorForParameterGroup_named() {
2009 ParserTestCase.parse4( 1686 ParserTestCase.parse4("parseFormalParameterList", "(a, {b: 0)", [
2010 "parseFormalParameterList", 1687 ParserErrorCode.MISSING_TERMINATOR_FOR_PARAMETER_GROUP
2011 "(a, {b: 0)", 1688 ]);
2012 [ParserErrorCode.MISSING_TERMINATOR_FOR_PARAMETER_GROUP]);
2013 } 1689 }
2014 1690
2015 void test_missingTerminatorForParameterGroup_optional() { 1691 void test_missingTerminatorForParameterGroup_optional() {
2016 ParserTestCase.parse4( 1692 ParserTestCase.parse4("parseFormalParameterList", "(a, [b = 0)", [
2017 "parseFormalParameterList", 1693 ParserErrorCode.MISSING_TERMINATOR_FOR_PARAMETER_GROUP
2018 "(a, [b = 0)", 1694 ]);
2019 [ParserErrorCode.MISSING_TERMINATOR_FOR_PARAMETER_GROUP]);
2020 } 1695 }
2021 1696
2022 void test_missingTypedefParameters_nonVoid() { 1697 void test_missingTypedefParameters_nonVoid() {
2023 ParserTestCase.parseCompilationUnit( 1698 ParserTestCase.parseCompilationUnit(
2024 "typedef int F;", 1699 "typedef int F;", [ParserErrorCode.MISSING_TYPEDEF_PARAMETERS]);
2025 [ParserErrorCode.MISSING_TYPEDEF_PARAMETERS]);
2026 } 1700 }
2027 1701
2028 void test_missingTypedefParameters_typeParameters() { 1702 void test_missingTypedefParameters_typeParameters() {
2029 ParserTestCase.parseCompilationUnit( 1703 ParserTestCase.parseCompilationUnit(
2030 "typedef F<E>;", 1704 "typedef F<E>;", [ParserErrorCode.MISSING_TYPEDEF_PARAMETERS]);
2031 [ParserErrorCode.MISSING_TYPEDEF_PARAMETERS]);
2032 } 1705 }
2033 1706
2034 void test_missingTypedefParameters_void() { 1707 void test_missingTypedefParameters_void() {
2035 ParserTestCase.parseCompilationUnit( 1708 ParserTestCase.parseCompilationUnit(
2036 "typedef void F;", 1709 "typedef void F;", [ParserErrorCode.MISSING_TYPEDEF_PARAMETERS]);
2037 [ParserErrorCode.MISSING_TYPEDEF_PARAMETERS]);
2038 } 1710 }
2039 1711
2040 void test_missingVariableInForEach() { 1712 void test_missingVariableInForEach() {
2041 ParserTestCase.parse4( 1713 ParserTestCase.parse4("parseForStatement", "for (a < b in foo) {}", [
2042 "parseForStatement", 1714 ParserErrorCode.MISSING_VARIABLE_IN_FOR_EACH
2043 "for (a < b in foo) {}", 1715 ]);
2044 [ParserErrorCode.MISSING_VARIABLE_IN_FOR_EACH]);
2045 } 1716 }
2046 1717
2047 void test_mixedParameterGroups_namedPositional() { 1718 void test_mixedParameterGroups_namedPositional() {
2048 ParserTestCase.parse4( 1719 ParserTestCase.parse4("parseFormalParameterList", "(a, {b}, [c])", [
2049 "parseFormalParameterList", 1720 ParserErrorCode.MIXED_PARAMETER_GROUPS
2050 "(a, {b}, [c])", 1721 ]);
2051 [ParserErrorCode.MIXED_PARAMETER_GROUPS]);
2052 } 1722 }
2053 1723
2054 void test_mixedParameterGroups_positionalNamed() { 1724 void test_mixedParameterGroups_positionalNamed() {
2055 ParserTestCase.parse4( 1725 ParserTestCase.parse4("parseFormalParameterList", "(a, [b], {c})", [
2056 "parseFormalParameterList", 1726 ParserErrorCode.MIXED_PARAMETER_GROUPS
2057 "(a, [b], {c})", 1727 ]);
2058 [ParserErrorCode.MIXED_PARAMETER_GROUPS]);
2059 } 1728 }
2060 1729
2061 void test_mixin_application_lacks_with_clause() { 1730 void test_mixin_application_lacks_with_clause() {
2062 ParserTestCase.parseCompilationUnit( 1731 ParserTestCase.parseCompilationUnit(
2063 "class Foo = Bar;", 1732 "class Foo = Bar;", [ParserErrorCode.EXPECTED_TOKEN]);
2064 [ParserErrorCode.EXPECTED_TOKEN]);
2065 } 1733 }
2066 1734
2067 void test_multipleExtendsClauses() { 1735 void test_multipleExtendsClauses() {
2068 ParserTestCase.parseCompilationUnit( 1736 ParserTestCase.parseCompilationUnit("class A extends B extends C {}", [
2069 "class A extends B extends C {}", 1737 ParserErrorCode.MULTIPLE_EXTENDS_CLAUSES
2070 [ParserErrorCode.MULTIPLE_EXTENDS_CLAUSES]); 1738 ]);
2071 } 1739 }
2072 1740
2073 void test_multipleImplementsClauses() { 1741 void test_multipleImplementsClauses() {
2074 ParserTestCase.parseCompilationUnit( 1742 ParserTestCase.parseCompilationUnit("class A implements B implements C {}",
2075 "class A implements B implements C {}",
2076 [ParserErrorCode.MULTIPLE_IMPLEMENTS_CLAUSES]); 1743 [ParserErrorCode.MULTIPLE_IMPLEMENTS_CLAUSES]);
2077 } 1744 }
2078 1745
2079 void test_multipleLibraryDirectives() { 1746 void test_multipleLibraryDirectives() {
2080 ParserTestCase.parseCompilationUnit( 1747 ParserTestCase.parseCompilationUnit(
2081 "library l; library m;", 1748 "library l; library m;", [ParserErrorCode.MULTIPLE_LIBRARY_DIRECTIVES]);
2082 [ParserErrorCode.MULTIPLE_LIBRARY_DIRECTIVES]);
2083 } 1749 }
2084 1750
2085 void test_multipleNamedParameterGroups() { 1751 void test_multipleNamedParameterGroups() {
2086 ParserTestCase.parse4( 1752 ParserTestCase.parse4("parseFormalParameterList", "(a, {b}, {c})", [
2087 "parseFormalParameterList", 1753 ParserErrorCode.MULTIPLE_NAMED_PARAMETER_GROUPS
2088 "(a, {b}, {c})", 1754 ]);
2089 [ParserErrorCode.MULTIPLE_NAMED_PARAMETER_GROUPS]);
2090 } 1755 }
2091 1756
2092 void test_multiplePartOfDirectives() { 1757 void test_multiplePartOfDirectives() {
2093 ParserTestCase.parseCompilationUnit( 1758 ParserTestCase.parseCompilationUnit(
2094 "part of l; part of m;", 1759 "part of l; part of m;", [ParserErrorCode.MULTIPLE_PART_OF_DIRECTIVES]);
2095 [ParserErrorCode.MULTIPLE_PART_OF_DIRECTIVES]);
2096 } 1760 }
2097 1761
2098 void test_multiplePositionalParameterGroups() { 1762 void test_multiplePositionalParameterGroups() {
2099 ParserTestCase.parse4( 1763 ParserTestCase.parse4("parseFormalParameterList", "(a, [b], [c])", [
2100 "parseFormalParameterList", 1764 ParserErrorCode.MULTIPLE_POSITIONAL_PARAMETER_GROUPS
2101 "(a, [b], [c])", 1765 ]);
2102 [ParserErrorCode.MULTIPLE_POSITIONAL_PARAMETER_GROUPS]);
2103 } 1766 }
2104 1767
2105 void test_multipleVariablesInForEach() { 1768 void test_multipleVariablesInForEach() {
2106 ParserTestCase.parse4( 1769 ParserTestCase.parse4("parseForStatement", "for (int a, b in foo) {}", [
2107 "parseForStatement", 1770 ParserErrorCode.MULTIPLE_VARIABLES_IN_FOR_EACH
2108 "for (int a, b in foo) {}", 1771 ]);
2109 [ParserErrorCode.MULTIPLE_VARIABLES_IN_FOR_EACH]);
2110 } 1772 }
2111 1773
2112 void test_multipleWithClauses() { 1774 void test_multipleWithClauses() {
2113 ParserTestCase.parseCompilationUnit( 1775 ParserTestCase.parseCompilationUnit("class A extends B with C with D {}", [
2114 "class A extends B with C with D {}", 1776 ParserErrorCode.MULTIPLE_WITH_CLAUSES
2115 [ParserErrorCode.MULTIPLE_WITH_CLAUSES]); 1777 ]);
2116 } 1778 }
2117 1779
2118 void test_namedParameterOutsideGroup() { 1780 void test_namedParameterOutsideGroup() {
2119 ParserTestCase.parse4( 1781 ParserTestCase.parse4("parseFormalParameterList", "(a, b : 0)", [
2120 "parseFormalParameterList", 1782 ParserErrorCode.NAMED_PARAMETER_OUTSIDE_GROUP
2121 "(a, b : 0)", 1783 ]);
2122 [ParserErrorCode.NAMED_PARAMETER_OUTSIDE_GROUP]);
2123 } 1784 }
2124 1785
2125 void test_nonConstructorFactory_field() { 1786 void test_nonConstructorFactory_field() {
2126 ParserTestCase.parse3( 1787 ParserTestCase.parse3("parseClassMember", <Object>["C"], "factory int x;", [
2127 "parseClassMember", 1788 ParserErrorCode.NON_CONSTRUCTOR_FACTORY
2128 <Object>["C"], 1789 ]);
2129 "factory int x;",
2130 [ParserErrorCode.NON_CONSTRUCTOR_FACTORY]);
2131 } 1790 }
2132 1791
2133 void test_nonConstructorFactory_method() { 1792 void test_nonConstructorFactory_method() {
2134 ParserTestCase.parse3( 1793 ParserTestCase.parse3("parseClassMember", <Object>[
2135 "parseClassMember", 1794 "C"
2136 <Object>["C"], 1795 ], "factory int m() {}", [ParserErrorCode.NON_CONSTRUCTOR_FACTORY]);
2137 "factory int m() {}",
2138 [ParserErrorCode.NON_CONSTRUCTOR_FACTORY]);
2139 } 1796 }
2140 1797
2141 void test_nonIdentifierLibraryName_library() { 1798 void test_nonIdentifierLibraryName_library() {
2142 CompilationUnit unit = ParserTestCase.parseCompilationUnit( 1799 CompilationUnit unit = ParserTestCase.parseCompilationUnit(
2143 "library 'lib';", 1800 "library 'lib';", [ParserErrorCode.NON_IDENTIFIER_LIBRARY_NAME]);
2144 [ParserErrorCode.NON_IDENTIFIER_LIBRARY_NAME]);
2145 expect(unit, isNotNull); 1801 expect(unit, isNotNull);
2146 } 1802 }
2147 1803
2148 void test_nonIdentifierLibraryName_partOf() { 1804 void test_nonIdentifierLibraryName_partOf() {
2149 CompilationUnit unit = ParserTestCase.parseCompilationUnit( 1805 CompilationUnit unit = ParserTestCase.parseCompilationUnit(
2150 "part of 'lib';", 1806 "part of 'lib';", [ParserErrorCode.NON_IDENTIFIER_LIBRARY_NAME]);
2151 [ParserErrorCode.NON_IDENTIFIER_LIBRARY_NAME]);
2152 expect(unit, isNotNull); 1807 expect(unit, isNotNull);
2153 } 1808 }
2154 1809
2155 void test_nonPartOfDirectiveInPart_after() { 1810 void test_nonPartOfDirectiveInPart_after() {
2156 ParserTestCase.parseCompilationUnit( 1811 ParserTestCase.parseCompilationUnit("part of l; part 'f.dart';", [
2157 "part of l; part 'f.dart';", 1812 ParserErrorCode.NON_PART_OF_DIRECTIVE_IN_PART
2158 [ParserErrorCode.NON_PART_OF_DIRECTIVE_IN_PART]); 1813 ]);
2159 } 1814 }
2160 1815
2161 void test_nonPartOfDirectiveInPart_before() { 1816 void test_nonPartOfDirectiveInPart_before() {
2162 ParserTestCase.parseCompilationUnit( 1817 ParserTestCase.parseCompilationUnit("part 'f.dart'; part of m;", [
2163 "part 'f.dart'; part of m;", 1818 ParserErrorCode.NON_PART_OF_DIRECTIVE_IN_PART
2164 [ParserErrorCode.NON_PART_OF_DIRECTIVE_IN_PART]); 1819 ]);
2165 } 1820 }
2166 1821
2167 void test_nonUserDefinableOperator() { 1822 void test_nonUserDefinableOperator() {
2168 ParserTestCase.parse3( 1823 ParserTestCase.parse3("parseClassMember", <Object>[
2169 "parseClassMember", 1824 "C"
2170 <Object>["C"], 1825 ], "operator +=(int x) => x + 1;", [
2171 "operator +=(int x) => x + 1;", 1826 ParserErrorCode.NON_USER_DEFINABLE_OPERATOR
2172 [ParserErrorCode.NON_USER_DEFINABLE_OPERATOR]); 1827 ]);
2173 } 1828 }
2174 1829
2175 void test_optionalAfterNormalParameters_named() { 1830 void test_optionalAfterNormalParameters_named() {
2176 ParserTestCase.parseCompilationUnit( 1831 ParserTestCase.parseCompilationUnit(
2177 "f({a}, b) {}", 1832 "f({a}, b) {}", [ParserErrorCode.NORMAL_BEFORE_OPTIONAL_PARAMETERS]);
2178 [ParserErrorCode.NORMAL_BEFORE_OPTIONAL_PARAMETERS]);
2179 } 1833 }
2180 1834
2181 void test_optionalAfterNormalParameters_positional() { 1835 void test_optionalAfterNormalParameters_positional() {
2182 ParserTestCase.parseCompilationUnit( 1836 ParserTestCase.parseCompilationUnit(
2183 "f([a], b) {}", 1837 "f([a], b) {}", [ParserErrorCode.NORMAL_BEFORE_OPTIONAL_PARAMETERS]);
2184 [ParserErrorCode.NORMAL_BEFORE_OPTIONAL_PARAMETERS]);
2185 } 1838 }
2186 1839
2187 void test_parseCascadeSection_missingIdentifier() { 1840 void test_parseCascadeSection_missingIdentifier() {
2188 MethodInvocation methodInvocation = ParserTestCase.parse4( 1841 MethodInvocation methodInvocation = ParserTestCase.parse4(
2189 "parseCascadeSection", 1842 "parseCascadeSection", "..()", [ParserErrorCode.MISSING_IDENTIFIER]);
2190 "..()",
2191 [ParserErrorCode.MISSING_IDENTIFIER]);
2192 expect(methodInvocation.target, isNull); 1843 expect(methodInvocation.target, isNull);
2193 expect(methodInvocation.methodName.name, ""); 1844 expect(methodInvocation.methodName.name, "");
2194 expect(methodInvocation.argumentList.arguments, hasLength(0)); 1845 expect(methodInvocation.argumentList.arguments, hasLength(0));
2195 } 1846 }
2196 1847
2197 void test_positionalAfterNamedArgument() { 1848 void test_positionalAfterNamedArgument() {
2198 ParserTestCase.parse4( 1849 ParserTestCase.parse4("parseArgumentList", "(x: 1, 2)", [
2199 "parseArgumentList", 1850 ParserErrorCode.POSITIONAL_AFTER_NAMED_ARGUMENT
2200 "(x: 1, 2)", 1851 ]);
2201 [ParserErrorCode.POSITIONAL_AFTER_NAMED_ARGUMENT]);
2202 } 1852 }
2203 1853
2204 void test_positionalParameterOutsideGroup() { 1854 void test_positionalParameterOutsideGroup() {
2205 ParserTestCase.parse4( 1855 ParserTestCase.parse4("parseFormalParameterList", "(a, b = 0)", [
2206 "parseFormalParameterList", 1856 ParserErrorCode.POSITIONAL_PARAMETER_OUTSIDE_GROUP
2207 "(a, b = 0)", 1857 ]);
2208 [ParserErrorCode.POSITIONAL_PARAMETER_OUTSIDE_GROUP]);
2209 } 1858 }
2210 1859
2211 void test_redirectionInNonFactoryConstructor() { 1860 void test_redirectionInNonFactoryConstructor() {
2212 ParserTestCase.parse3( 1861 ParserTestCase.parse3("parseClassMember", <Object>["C"], "C() = D;", [
2213 "parseClassMember", 1862 ParserErrorCode.REDIRECTION_IN_NON_FACTORY_CONSTRUCTOR
2214 <Object>["C"], 1863 ]);
2215 "C() = D;",
2216 [ParserErrorCode.REDIRECTION_IN_NON_FACTORY_CONSTRUCTOR]);
2217 } 1864 }
2218 1865
2219 void test_setterInFunction_block() { 1866 void test_setterInFunction_block() {
2220 ParserTestCase.parseStatement( 1867 ParserTestCase.parseStatement(
2221 "set x(v) {_x = v;}", 1868 "set x(v) {_x = v;}", [ParserErrorCode.SETTER_IN_FUNCTION]);
2222 [ParserErrorCode.SETTER_IN_FUNCTION]);
2223 } 1869 }
2224 1870
2225 void test_setterInFunction_expression() { 1871 void test_setterInFunction_expression() {
2226 ParserTestCase.parseStatement( 1872 ParserTestCase.parseStatement(
2227 "set x(v) => _x = v;", 1873 "set x(v) => _x = v;", [ParserErrorCode.SETTER_IN_FUNCTION]);
2228 [ParserErrorCode.SETTER_IN_FUNCTION]);
2229 } 1874 }
2230 1875
2231 void test_staticAfterConst() { 1876 void test_staticAfterConst() {
2232 ParserTestCase.parse3( 1877 ParserTestCase.parse3("parseClassMember", <Object>[
2233 "parseClassMember", 1878 "C"
2234 <Object>["C"], 1879 ], "final static int f;", [ParserErrorCode.STATIC_AFTER_FINAL]);
2235 "final static int f;",
2236 [ParserErrorCode.STATIC_AFTER_FINAL]);
2237 } 1880 }
2238 1881
2239 void test_staticAfterFinal() { 1882 void test_staticAfterFinal() {
2240 ParserTestCase.parse3( 1883 ParserTestCase.parse3("parseClassMember", <Object>[
2241 "parseClassMember", 1884 "C"
2242 <Object>["C"], 1885 ], "const static int f;", [ParserErrorCode.STATIC_AFTER_CONST]);
2243 "const static int f;",
2244 [ParserErrorCode.STATIC_AFTER_CONST]);
2245 } 1886 }
2246 1887
2247 void test_staticAfterVar() { 1888 void test_staticAfterVar() {
2248 ParserTestCase.parse3( 1889 ParserTestCase.parse3("parseClassMember", <Object>["C"], "var static f;", [
2249 "parseClassMember", 1890 ParserErrorCode.STATIC_AFTER_VAR
2250 <Object>["C"], 1891 ]);
2251 "var static f;",
2252 [ParserErrorCode.STATIC_AFTER_VAR]);
2253 } 1892 }
2254 1893
2255 void test_staticConstructor() { 1894 void test_staticConstructor() {
2256 ParserTestCase.parse3( 1895 ParserTestCase.parse3("parseClassMember", <Object>[
2257 "parseClassMember", 1896 "C"
2258 <Object>["C"], 1897 ], "static C.m() {}", [ParserErrorCode.STATIC_CONSTRUCTOR]);
2259 "static C.m() {}",
2260 [ParserErrorCode.STATIC_CONSTRUCTOR]);
2261 } 1898 }
2262 1899
2263 void test_staticGetterWithoutBody() { 1900 void test_staticGetterWithoutBody() {
2264 ParserTestCase.parse3( 1901 ParserTestCase.parse3("parseClassMember", <Object>["C"], "static get m;", [
2265 "parseClassMember", 1902 ParserErrorCode.STATIC_GETTER_WITHOUT_BODY
2266 <Object>["C"], 1903 ]);
2267 "static get m;",
2268 [ParserErrorCode.STATIC_GETTER_WITHOUT_BODY]);
2269 } 1904 }
2270 1905
2271 void test_staticOperator_noReturnType() { 1906 void test_staticOperator_noReturnType() {
2272 ParserTestCase.parse3( 1907 ParserTestCase.parse3("parseClassMember", <Object>[
2273 "parseClassMember", 1908 "C"
2274 <Object>["C"], 1909 ], "static operator +(int x) => x + 1;", [ParserErrorCode.STATIC_OPERATOR]);
2275 "static operator +(int x) => x + 1;",
2276 [ParserErrorCode.STATIC_OPERATOR]);
2277 } 1910 }
2278 1911
2279 void test_staticOperator_returnType() { 1912 void test_staticOperator_returnType() {
2280 ParserTestCase.parse3( 1913 ParserTestCase.parse3("parseClassMember", <Object>[
2281 "parseClassMember", 1914 "C"
2282 <Object>["C"], 1915 ], "static int operator +(int x) => x + 1;", [
2283 "static int operator +(int x) => x + 1;", 1916 ParserErrorCode.STATIC_OPERATOR
2284 [ParserErrorCode.STATIC_OPERATOR]); 1917 ]);
2285 } 1918 }
2286 1919
2287 void test_staticSetterWithoutBody() { 1920 void test_staticSetterWithoutBody() {
2288 ParserTestCase.parse3( 1921 ParserTestCase.parse3("parseClassMember", <Object>[
2289 "parseClassMember", 1922 "C"
2290 <Object>["C"], 1923 ], "static set m(x);", [ParserErrorCode.STATIC_SETTER_WITHOUT_BODY]);
2291 "static set m(x);",
2292 [ParserErrorCode.STATIC_SETTER_WITHOUT_BODY]);
2293 } 1924 }
2294 1925
2295 void test_staticTopLevelDeclaration_class() { 1926 void test_staticTopLevelDeclaration_class() {
2296 ParserTestCase.parseCompilationUnit( 1927 ParserTestCase.parseCompilationUnit(
2297 "static class C {}", 1928 "static class C {}", [ParserErrorCode.STATIC_TOP_LEVEL_DECLARATION]);
2298 [ParserErrorCode.STATIC_TOP_LEVEL_DECLARATION]);
2299 } 1929 }
2300 1930
2301 void test_staticTopLevelDeclaration_function() { 1931 void test_staticTopLevelDeclaration_function() {
2302 ParserTestCase.parseCompilationUnit( 1932 ParserTestCase.parseCompilationUnit(
2303 "static f() {}", 1933 "static f() {}", [ParserErrorCode.STATIC_TOP_LEVEL_DECLARATION]);
2304 [ParserErrorCode.STATIC_TOP_LEVEL_DECLARATION]);
2305 } 1934 }
2306 1935
2307 void test_staticTopLevelDeclaration_typedef() { 1936 void test_staticTopLevelDeclaration_typedef() {
2308 ParserTestCase.parseCompilationUnit( 1937 ParserTestCase.parseCompilationUnit(
2309 "static typedef F();", 1938 "static typedef F();", [ParserErrorCode.STATIC_TOP_LEVEL_DECLARATION]);
2310 [ParserErrorCode.STATIC_TOP_LEVEL_DECLARATION]);
2311 } 1939 }
2312 1940
2313 void test_staticTopLevelDeclaration_variable() { 1941 void test_staticTopLevelDeclaration_variable() {
2314 ParserTestCase.parseCompilationUnit( 1942 ParserTestCase.parseCompilationUnit(
2315 "static var x;", 1943 "static var x;", [ParserErrorCode.STATIC_TOP_LEVEL_DECLARATION]);
2316 [ParserErrorCode.STATIC_TOP_LEVEL_DECLARATION]);
2317 } 1944 }
2318 1945
2319 void test_switchHasCaseAfterDefaultCase() { 1946 void test_switchHasCaseAfterDefaultCase() {
2320 ParserTestCase.parse4( 1947 ParserTestCase.parse4("parseSwitchStatement",
2321 "parseSwitchStatement", 1948 "switch (a) {default: return 0; case 1: return 1;}", [
2322 "switch (a) {default: return 0; case 1: return 1;}", 1949 ParserErrorCode.SWITCH_HAS_CASE_AFTER_DEFAULT_CASE
2323 [ParserErrorCode.SWITCH_HAS_CASE_AFTER_DEFAULT_CASE]); 1950 ]);
2324 } 1951 }
2325 1952
2326 void test_switchHasCaseAfterDefaultCase_repeated() { 1953 void test_switchHasCaseAfterDefaultCase_repeated() {
2327 ParserTestCase.parse4( 1954 ParserTestCase.parse4("parseSwitchStatement",
2328 "parseSwitchStatement", 1955 "switch (a) {default: return 0; case 1: return 1; case 2: return 2;}", [
2329 "switch (a) {default: return 0; case 1: return 1; case 2: return 2;}", 1956 ParserErrorCode.SWITCH_HAS_CASE_AFTER_DEFAULT_CASE,
2330 [ 1957 ParserErrorCode.SWITCH_HAS_CASE_AFTER_DEFAULT_CASE
2331 ParserErrorCode.SWITCH_HAS_CASE_AFTER_DEFAULT_CASE, 1958 ]);
2332 ParserErrorCode.SWITCH_HAS_CASE_AFTER_DEFAULT_CASE]);
2333 } 1959 }
2334 1960
2335 void test_switchHasMultipleDefaultCases() { 1961 void test_switchHasMultipleDefaultCases() {
2336 ParserTestCase.parse4( 1962 ParserTestCase.parse4("parseSwitchStatement",
2337 "parseSwitchStatement", 1963 "switch (a) {default: return 0; default: return 1;}", [
2338 "switch (a) {default: return 0; default: return 1;}", 1964 ParserErrorCode.SWITCH_HAS_MULTIPLE_DEFAULT_CASES
2339 [ParserErrorCode.SWITCH_HAS_MULTIPLE_DEFAULT_CASES]); 1965 ]);
2340 } 1966 }
2341 1967
2342 void test_switchHasMultipleDefaultCases_repeated() { 1968 void test_switchHasMultipleDefaultCases_repeated() {
2343 ParserTestCase.parse4( 1969 ParserTestCase.parse4("parseSwitchStatement",
2344 "parseSwitchStatement",
2345 "switch (a) {default: return 0; default: return 1; default: return 2;}", 1970 "switch (a) {default: return 0; default: return 1; default: return 2;}",
2346 [ 1971 [
2347 ParserErrorCode.SWITCH_HAS_MULTIPLE_DEFAULT_CASES, 1972 ParserErrorCode.SWITCH_HAS_MULTIPLE_DEFAULT_CASES,
2348 ParserErrorCode.SWITCH_HAS_MULTIPLE_DEFAULT_CASES]); 1973 ParserErrorCode.SWITCH_HAS_MULTIPLE_DEFAULT_CASES
1974 ]);
2349 } 1975 }
2350 1976
2351 void test_topLevelOperator_withoutType() { 1977 void test_topLevelOperator_withoutType() {
2352 ParserTestCase.parse3( 1978 ParserTestCase.parse3("parseCompilationUnitMember", <Object>[
2353 "parseCompilationUnitMember", 1979 emptyCommentAndMetadata()
2354 <Object>[emptyCommentAndMetadata()], 1980 ], "operator +(bool x, bool y) => x | y;", [
2355 "operator +(bool x, bool y) => x | y;", 1981 ParserErrorCode.TOP_LEVEL_OPERATOR
2356 [ParserErrorCode.TOP_LEVEL_OPERATOR]); 1982 ]);
2357 } 1983 }
2358 1984
2359 void test_topLevelOperator_withType() { 1985 void test_topLevelOperator_withType() {
2360 ParserTestCase.parse3( 1986 ParserTestCase.parse3("parseCompilationUnitMember", <Object>[
2361 "parseCompilationUnitMember", 1987 emptyCommentAndMetadata()
2362 <Object>[emptyCommentAndMetadata()], 1988 ], "bool operator +(bool x, bool y) => x | y;", [
2363 "bool operator +(bool x, bool y) => x | y;", 1989 ParserErrorCode.TOP_LEVEL_OPERATOR
2364 [ParserErrorCode.TOP_LEVEL_OPERATOR]); 1990 ]);
2365 } 1991 }
2366 1992
2367 void test_topLevelOperator_withVoid() { 1993 void test_topLevelOperator_withVoid() {
2368 ParserTestCase.parse3( 1994 ParserTestCase.parse3("parseCompilationUnitMember", <Object>[
2369 "parseCompilationUnitMember", 1995 emptyCommentAndMetadata()
2370 <Object>[emptyCommentAndMetadata()], 1996 ], "void operator +(bool x, bool y) => x | y;", [
2371 "void operator +(bool x, bool y) => x | y;", 1997 ParserErrorCode.TOP_LEVEL_OPERATOR
2372 [ParserErrorCode.TOP_LEVEL_OPERATOR]); 1998 ]);
2373 } 1999 }
2374 2000
2375 void test_typedefInClass_withoutReturnType() { 2001 void test_typedefInClass_withoutReturnType() {
2376 ParserTestCase.parseCompilationUnit( 2002 ParserTestCase.parseCompilationUnit(
2377 "class C { typedef F(x); }", 2003 "class C { typedef F(x); }", [ParserErrorCode.TYPEDEF_IN_CLASS]);
2378 [ParserErrorCode.TYPEDEF_IN_CLASS]);
2379 } 2004 }
2380 2005
2381 void test_typedefInClass_withReturnType() { 2006 void test_typedefInClass_withReturnType() {
2382 ParserTestCase.parseCompilationUnit( 2007 ParserTestCase.parseCompilationUnit("class C { typedef int F(int x); }", [
2383 "class C { typedef int F(int x); }", 2008 ParserErrorCode.TYPEDEF_IN_CLASS
2384 [ParserErrorCode.TYPEDEF_IN_CLASS]); 2009 ]);
2385 } 2010 }
2386 2011
2387 void test_unexpectedTerminatorForParameterGroup_named() { 2012 void test_unexpectedTerminatorForParameterGroup_named() {
2388 ParserTestCase.parse4( 2013 ParserTestCase.parse4("parseFormalParameterList", "(a, b})", [
2389 "parseFormalParameterList", 2014 ParserErrorCode.UNEXPECTED_TERMINATOR_FOR_PARAMETER_GROUP
2390 "(a, b})", 2015 ]);
2391 [ParserErrorCode.UNEXPECTED_TERMINATOR_FOR_PARAMETER_GROUP]);
2392 } 2016 }
2393 2017
2394 void test_unexpectedTerminatorForParameterGroup_optional() { 2018 void test_unexpectedTerminatorForParameterGroup_optional() {
2395 ParserTestCase.parse4( 2019 ParserTestCase.parse4("parseFormalParameterList", "(a, b])", [
2396 "parseFormalParameterList", 2020 ParserErrorCode.UNEXPECTED_TERMINATOR_FOR_PARAMETER_GROUP
2397 "(a, b])", 2021 ]);
2398 [ParserErrorCode.UNEXPECTED_TERMINATOR_FOR_PARAMETER_GROUP]);
2399 } 2022 }
2400 2023
2401 void test_unexpectedToken_endOfFieldDeclarationStatement() { 2024 void test_unexpectedToken_endOfFieldDeclarationStatement() {
2402 ParserTestCase.parseStatement( 2025 ParserTestCase.parseStatement(
2403 "String s = (null));", 2026 "String s = (null));", [ParserErrorCode.UNEXPECTED_TOKEN]);
2404 [ParserErrorCode.UNEXPECTED_TOKEN]);
2405 } 2027 }
2406 2028
2407 void test_unexpectedToken_returnInExpressionFuntionBody() { 2029 void test_unexpectedToken_returnInExpressionFuntionBody() {
2408 ParserTestCase.parseCompilationUnit( 2030 ParserTestCase.parseCompilationUnit(
2409 "f() => return null;", 2031 "f() => return null;", [ParserErrorCode.UNEXPECTED_TOKEN]);
2410 [ParserErrorCode.UNEXPECTED_TOKEN]);
2411 } 2032 }
2412 2033
2413 void test_unexpectedToken_semicolonBetweenClassMembers() { 2034 void test_unexpectedToken_semicolonBetweenClassMembers() {
2414 ParserTestCase.parse3( 2035 ParserTestCase.parse3("parseClassDeclaration", <Object>[
2415 "parseClassDeclaration", 2036 emptyCommentAndMetadata(),
2416 <Object>[emptyCommentAndMetadata(), null], 2037 null
2417 "class C { int x; ; int y;}", 2038 ], "class C { int x; ; int y;}", [ParserErrorCode.UNEXPECTED_TOKEN]);
2418 [ParserErrorCode.UNEXPECTED_TOKEN]);
2419 } 2039 }
2420 2040
2421 void test_unexpectedToken_semicolonBetweenCompilationUnitMembers() { 2041 void test_unexpectedToken_semicolonBetweenCompilationUnitMembers() {
2422 ParserTestCase.parseCompilationUnit( 2042 ParserTestCase.parseCompilationUnit(
2423 "int x; ; int y;", 2043 "int x; ; int y;", [ParserErrorCode.UNEXPECTED_TOKEN]);
2424 [ParserErrorCode.UNEXPECTED_TOKEN]);
2425 } 2044 }
2426 2045
2427 void test_useOfUnaryPlusOperator() { 2046 void test_useOfUnaryPlusOperator() {
2428 SimpleIdentifier expression = ParserTestCase.parse4( 2047 SimpleIdentifier expression = ParserTestCase.parse4(
2429 "parseUnaryExpression", 2048 "parseUnaryExpression", "+x", [ParserErrorCode.MISSING_IDENTIFIER]);
2430 "+x",
2431 [ParserErrorCode.MISSING_IDENTIFIER]);
2432 EngineTestCase.assertInstanceOf( 2049 EngineTestCase.assertInstanceOf(
2433 (obj) => obj is SimpleIdentifier, 2050 (obj) => obj is SimpleIdentifier, SimpleIdentifier, expression);
2434 SimpleIdentifier,
2435 expression);
2436 expect(expression.isSynthetic, isTrue); 2051 expect(expression.isSynthetic, isTrue);
2437 } 2052 }
2438 2053
2439 void test_varAndType_field() { 2054 void test_varAndType_field() {
2440 ParserTestCase.parseCompilationUnit( 2055 ParserTestCase.parseCompilationUnit(
2441 "class C { var int x; }", 2056 "class C { var int x; }", [ParserErrorCode.VAR_AND_TYPE]);
2442 [ParserErrorCode.VAR_AND_TYPE]);
2443 } 2057 }
2444 2058
2445 void test_varAndType_topLevelVariable() { 2059 void test_varAndType_topLevelVariable() {
2446 ParserTestCase.parseCompilationUnit( 2060 ParserTestCase.parseCompilationUnit(
2447 "var int x;", 2061 "var int x;", [ParserErrorCode.VAR_AND_TYPE]);
2448 [ParserErrorCode.VAR_AND_TYPE]);
2449 } 2062 }
2450 2063
2451 void test_varAsTypeName_as() { 2064 void test_varAsTypeName_as() {
2452 ParserTestCase.parseExpression( 2065 ParserTestCase.parseExpression(
2453 "x as var", 2066 "x as var", [ParserErrorCode.VAR_AS_TYPE_NAME]);
2454 [ParserErrorCode.VAR_AS_TYPE_NAME]);
2455 } 2067 }
2456 2068
2457 void test_varClass() { 2069 void test_varClass() {
2458 ParserTestCase.parseCompilationUnit( 2070 ParserTestCase.parseCompilationUnit(
2459 "var class C {}", 2071 "var class C {}", [ParserErrorCode.VAR_CLASS]);
2460 [ParserErrorCode.VAR_CLASS]);
2461 } 2072 }
2462 2073
2463 void test_varEnum() { 2074 void test_varEnum() {
2464 ParserTestCase.parseCompilationUnit( 2075 ParserTestCase.parseCompilationUnit(
2465 "var enum E {ONE}", 2076 "var enum E {ONE}", [ParserErrorCode.VAR_ENUM]);
2466 [ParserErrorCode.VAR_ENUM]);
2467 } 2077 }
2468 2078
2469 void test_varReturnType() { 2079 void test_varReturnType() {
2470 ParserTestCase.parse3( 2080 ParserTestCase.parse3("parseClassMember", <Object>["C"], "var m() {}", [
2471 "parseClassMember", 2081 ParserErrorCode.VAR_RETURN_TYPE
2472 <Object>["C"], 2082 ]);
2473 "var m() {}",
2474 [ParserErrorCode.VAR_RETURN_TYPE]);
2475 } 2083 }
2476 2084
2477 void test_varTypedef() { 2085 void test_varTypedef() {
2478 ParserTestCase.parseCompilationUnit( 2086 ParserTestCase.parseCompilationUnit(
2479 "var typedef F();", 2087 "var typedef F();", [ParserErrorCode.VAR_TYPEDEF]);
2480 [ParserErrorCode.VAR_TYPEDEF]);
2481 } 2088 }
2482 2089
2483 void test_voidParameter() { 2090 void test_voidParameter() {
2484 ParserTestCase.parse4( 2091 ParserTestCase.parse4("parseNormalFormalParameter", "void a)", [
2485 "parseNormalFormalParameter", 2092 ParserErrorCode.VOID_PARAMETER
2486 "void a)", 2093 ]);
2487 [ParserErrorCode.VOID_PARAMETER]);
2488 } 2094 }
2489 2095
2490 void test_voidVariable_parseClassMember_initializer() { 2096 void test_voidVariable_parseClassMember_initializer() {
2491 ParserTestCase.parse3( 2097 ParserTestCase.parse3("parseClassMember", <Object>["C"], "void x = 0;", [
2492 "parseClassMember", 2098 ParserErrorCode.VOID_VARIABLE
2493 <Object>["C"], 2099 ]);
2494 "void x = 0;",
2495 [ParserErrorCode.VOID_VARIABLE]);
2496 } 2100 }
2497 2101
2498 void test_voidVariable_parseClassMember_noInitializer() { 2102 void test_voidVariable_parseClassMember_noInitializer() {
2499 ParserTestCase.parse3( 2103 ParserTestCase.parse3("parseClassMember", <Object>["C"], "void x;", [
2500 "parseClassMember", 2104 ParserErrorCode.VOID_VARIABLE
2501 <Object>["C"], 2105 ]);
2502 "void x;",
2503 [ParserErrorCode.VOID_VARIABLE]);
2504 } 2106 }
2505 2107
2506 void test_voidVariable_parseCompilationUnit_initializer() { 2108 void test_voidVariable_parseCompilationUnit_initializer() {
2507 ParserTestCase.parseCompilationUnit( 2109 ParserTestCase.parseCompilationUnit(
2508 "void x = 0;", 2110 "void x = 0;", [ParserErrorCode.VOID_VARIABLE]);
2509 [ParserErrorCode.VOID_VARIABLE]);
2510 } 2111 }
2511 2112
2512 void test_voidVariable_parseCompilationUnit_noInitializer() { 2113 void test_voidVariable_parseCompilationUnit_noInitializer() {
2513 ParserTestCase.parseCompilationUnit( 2114 ParserTestCase.parseCompilationUnit(
2514 "void x;", 2115 "void x;", [ParserErrorCode.VOID_VARIABLE]);
2515 [ParserErrorCode.VOID_VARIABLE]);
2516 } 2116 }
2517 2117
2518 void test_voidVariable_parseCompilationUnitMember_initializer() { 2118 void test_voidVariable_parseCompilationUnitMember_initializer() {
2519 ParserTestCase.parse3( 2119 ParserTestCase.parse3("parseCompilationUnitMember", <Object>[
2520 "parseCompilationUnitMember", 2120 emptyCommentAndMetadata()
2521 <Object>[emptyCommentAndMetadata()], 2121 ], "void a = 0;", [ParserErrorCode.VOID_VARIABLE]);
2522 "void a = 0;",
2523 [ParserErrorCode.VOID_VARIABLE]);
2524 } 2122 }
2525 2123
2526 void test_voidVariable_parseCompilationUnitMember_noInitializer() { 2124 void test_voidVariable_parseCompilationUnitMember_noInitializer() {
2527 ParserTestCase.parse3( 2125 ParserTestCase.parse3("parseCompilationUnitMember", <Object>[
2528 "parseCompilationUnitMember", 2126 emptyCommentAndMetadata()
2529 <Object>[emptyCommentAndMetadata()], 2127 ], "void a;", [ParserErrorCode.VOID_VARIABLE]);
2530 "void a;",
2531 [ParserErrorCode.VOID_VARIABLE]);
2532 } 2128 }
2533 2129
2534 void test_voidVariable_statement_initializer() { 2130 void test_voidVariable_statement_initializer() {
2535 ParserTestCase.parseStatement( 2131 ParserTestCase.parseStatement("void x = 0;", [
2536 "void x = 0;", 2132 ParserErrorCode.VOID_VARIABLE,
2537 [ 2133 ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE
2538 ParserErrorCode.VOID_VARIABLE, 2134 ]);
2539 ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE]);
2540 } 2135 }
2541 2136
2542 void test_voidVariable_statement_noInitializer() { 2137 void test_voidVariable_statement_noInitializer() {
2543 ParserTestCase.parseStatement( 2138 ParserTestCase.parseStatement("void x;", [
2544 "void x;", 2139 ParserErrorCode.VOID_VARIABLE,
2545 [ 2140 ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE
2546 ParserErrorCode.VOID_VARIABLE, 2141 ]);
2547 ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE]);
2548 } 2142 }
2549 2143
2550 void test_withBeforeExtends() { 2144 void test_withBeforeExtends() {
2551 ParserTestCase.parseCompilationUnit( 2145 ParserTestCase.parseCompilationUnit(
2552 "class A with B extends C {}", 2146 "class A with B extends C {}", [ParserErrorCode.WITH_BEFORE_EXTENDS]);
2553 [ParserErrorCode.WITH_BEFORE_EXTENDS]);
2554 } 2147 }
2555 2148
2556 void test_withWithoutExtends() { 2149 void test_withWithoutExtends() {
2557 ParserTestCase.parse3( 2150 ParserTestCase.parse3("parseClassDeclaration", <Object>[
2558 "parseClassDeclaration", 2151 emptyCommentAndMetadata(),
2559 <Object>[emptyCommentAndMetadata(), null], 2152 null
2560 "class A with B, C {}", 2153 ], "class A with B, C {}", [ParserErrorCode.WITH_WITHOUT_EXTENDS]);
2561 [ParserErrorCode.WITH_WITHOUT_EXTENDS]);
2562 } 2154 }
2563 2155
2564 void test_wrongSeparatorForNamedParameter() { 2156 void test_wrongSeparatorForNamedParameter() {
2565 ParserTestCase.parse4( 2157 ParserTestCase.parse4("parseFormalParameterList", "(a, {b = 0})", [
2566 "parseFormalParameterList", 2158 ParserErrorCode.WRONG_SEPARATOR_FOR_NAMED_PARAMETER
2567 "(a, {b = 0})", 2159 ]);
2568 [ParserErrorCode.WRONG_SEPARATOR_FOR_NAMED_PARAMETER]);
2569 } 2160 }
2570 2161
2571 void test_wrongSeparatorForPositionalParameter() { 2162 void test_wrongSeparatorForPositionalParameter() {
2572 ParserTestCase.parse4( 2163 ParserTestCase.parse4("parseFormalParameterList", "(a, [b : 0])", [
2573 "parseFormalParameterList", 2164 ParserErrorCode.WRONG_SEPARATOR_FOR_POSITIONAL_PARAMETER
2574 "(a, [b : 0])", 2165 ]);
2575 [ParserErrorCode.WRONG_SEPARATOR_FOR_POSITIONAL_PARAMETER]);
2576 } 2166 }
2577 2167
2578 void test_wrongTerminatorForParameterGroup_named() { 2168 void test_wrongTerminatorForParameterGroup_named() {
2579 ParserTestCase.parse4( 2169 ParserTestCase.parse4("parseFormalParameterList", "(a, {b, c])", [
2580 "parseFormalParameterList", 2170 ParserErrorCode.WRONG_TERMINATOR_FOR_PARAMETER_GROUP
2581 "(a, {b, c])", 2171 ]);
2582 [ParserErrorCode.WRONG_TERMINATOR_FOR_PARAMETER_GROUP]);
2583 } 2172 }
2584 2173
2585 void test_wrongTerminatorForParameterGroup_optional() { 2174 void test_wrongTerminatorForParameterGroup_optional() {
2586 ParserTestCase.parse4( 2175 ParserTestCase.parse4("parseFormalParameterList", "(a, [b, c})", [
2587 "parseFormalParameterList", 2176 ParserErrorCode.WRONG_TERMINATOR_FOR_PARAMETER_GROUP
2588 "(a, [b, c})", 2177 ]);
2589 [ParserErrorCode.WRONG_TERMINATOR_FOR_PARAMETER_GROUP]);
2590 } 2178 }
2591 } 2179 }
2592 2180
2593 @reflectiveTest 2181 @reflectiveTest
2594 class IncrementalParserTest extends EngineTestCase { 2182 class IncrementalParserTest extends EngineTestCase {
2595 void fail_replace_identifier_with_functionLiteral_in_initializer_interp() { 2183 void fail_replace_identifier_with_functionLiteral_in_initializer_interp() {
2596 // TODO(paulberry, brianwilkerson): broken due to incremental scanning bugs 2184 // TODO(paulberry, brianwilkerson): broken due to incremental scanning bugs
2597 2185
2598 // Function literals are allowed inside interpolation expressions in 2186 // Function literals are allowed inside interpolation expressions in
2599 // initializers. 2187 // initializers.
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
2707 2295
2708 void test_insert_newIdentifier3() { 2296 void test_insert_newIdentifier3() {
2709 // "/** A simple function. */ f() => a; c;" 2297 // "/** A simple function. */ f() => a; c;"
2710 // "/** A simple function. */ f() => a; b c;" 2298 // "/** A simple function. */ f() => a; b c;"
2711 _assertParse("/** A simple function. */ f() => a;", "", " b", " c;"); 2299 _assertParse("/** A simple function. */ f() => a;", "", " b", " c;");
2712 } 2300 }
2713 2301
2714 void test_insert_newIdentifier4() { 2302 void test_insert_newIdentifier4() {
2715 // "/** An [A]. */ class A {} class B { m() { return 1; } }" 2303 // "/** An [A]. */ class A {} class B { m() { return 1; } }"
2716 // "/** An [A]. */ class A {} class B { m() { return 1 + 2; } }" 2304 // "/** An [A]. */ class A {} class B { m() { return 1 + 2; } }"
2717 _assertParse( 2305 _assertParse("/** An [A]. */ class A {} class B { m() { return 1", "",
2718 "/** An [A]. */ class A {} class B { m() { return 1", 2306 " + 2", "; } }");
2719 "",
2720 " + 2",
2721 "; } }");
2722 } 2307 }
2723 2308
2724 void test_insert_period() { 2309 void test_insert_period() {
2725 // "f() => a + b;" 2310 // "f() => a + b;"
2726 // "f() => a + b.;" 2311 // "f() => a + b.;"
2727 _assertParse("f() => a + b", "", ".", ";"); 2312 _assertParse("f() => a + b", "", ".", ";");
2728 } 2313 }
2729 2314
2730 void test_insert_period_betweenIdentifiers1() { 2315 void test_insert_period_betweenIdentifiers1() {
2731 // "f() => a b;" 2316 // "f() => a b;"
(...skipping 22 matching lines...) Expand all
2754 void test_insert_periodAndIdentifier() { 2339 void test_insert_periodAndIdentifier() {
2755 // "f() => a + b;" 2340 // "f() => a + b;"
2756 // "f() => a + b.x;" 2341 // "f() => a + b.x;"
2757 _assertParse("f() => a + b", "", ".x", ";"); 2342 _assertParse("f() => a + b", "", ".x", ";");
2758 } 2343 }
2759 2344
2760 void test_insert_simpleToComplexExression() { 2345 void test_insert_simpleToComplexExression() {
2761 // "/** An [A]. */ class A {} class B { m() => 1; }" 2346 // "/** An [A]. */ class A {} class B { m() => 1; }"
2762 // "/** An [A]. */ class A {} class B { m() => 1 + 2; }" 2347 // "/** An [A]. */ class A {} class B { m() => 1 + 2; }"
2763 _assertParse( 2348 _assertParse(
2764 "/** An [A]. */ class A {} class B { m() => 1", 2349 "/** An [A]. */ class A {} class B { m() => 1", "", " + 2", "; }");
2765 "",
2766 " + 2",
2767 "; }");
2768 } 2350 }
2769 2351
2770 void test_insert_statement_in_method_with_mismatched_braces() { 2352 void test_insert_statement_in_method_with_mismatched_braces() {
2771 _assertParse(''' 2353 _assertParse('''
2772 class C { 2354 class C {
2773 void f() { 2355 void f() {
2774 ''', '', 'g();', ''' 2356 ''', '', 'g();', '''
2775 if (b) { 2357 if (b) {
2776 2358
2777 2359
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
2832 _assertParse("f() => f", "ir", "ro", "st + b;"); 2414 _assertParse("f() => f", "ir", "ro", "st + b;");
2833 } 2415 }
2834 2416
2835 void test_replace_identifier_with_functionLiteral_in_initializer() { 2417 void test_replace_identifier_with_functionLiteral_in_initializer() {
2836 // Function literals aren't allowed inside initializers; incremental parsing 2418 // Function literals aren't allowed inside initializers; incremental parsing
2837 // needs to gather the appropriate context. 2419 // needs to gather the appropriate context.
2838 // 2420 //
2839 // "class A { var a; A(b) : a = b ? b : 0 { } }" 2421 // "class A { var a; A(b) : a = b ? b : 0 { } }"
2840 // "class A { var a; A(b) : a = b ? () {} : 0 { } }" 2422 // "class A { var a; A(b) : a = b ? () {} : 0 { } }"
2841 _assertParse( 2423 _assertParse(
2842 "class A { var a; A(b) : a = b ? ", 2424 "class A { var a; A(b) : a = b ? ", "b", "() {}", " : 0 { } }");
2843 "b",
2844 "() {}",
2845 " : 0 { } }");
2846 } 2425 }
2847 2426
2848 void test_replace_identifier_with_functionLiteral_in_initializer_index() { 2427 void test_replace_identifier_with_functionLiteral_in_initializer_index() {
2849 // Function literals are allowed inside index expressions in initializers. 2428 // Function literals are allowed inside index expressions in initializers.
2850 // 2429 //
2851 // "class A { var a; A(b) : a = b[b];" 2430 // "class A { var a; A(b) : a = b[b];"
2852 // "class A { var a; A(b) : a = b[() {}];" 2431 // "class A { var a; A(b) : a = b[() {}];"
2853 _assertParse('class A { var a; A(b) : a = b[', 'b', '() {}', '];'); 2432 _assertParse('class A { var a; A(b) : a = b[', 'b', '() {}', '];');
2854 } 2433 }
2855 2434
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
2903 2482
2904 /** 2483 /**
2905 * Given a description of the original and modified contents, perform an incre mental scan of the 2484 * Given a description of the original and modified contents, perform an incre mental scan of the
2906 * two pieces of text. 2485 * two pieces of text.
2907 * 2486 *
2908 * @param prefix the unchanged text before the edit region 2487 * @param prefix the unchanged text before the edit region
2909 * @param removed the text that was removed from the original contents 2488 * @param removed the text that was removed from the original contents
2910 * @param added the text that was added to the modified contents 2489 * @param added the text that was added to the modified contents
2911 * @param suffix the unchanged text after the edit region 2490 * @param suffix the unchanged text after the edit region
2912 */ 2491 */
2913 void _assertParse(String prefix, String removed, String added, 2492 void _assertParse(
2914 String suffix) { 2493 String prefix, String removed, String added, String suffix) {
2915 // 2494 //
2916 // Compute the information needed to perform the test. 2495 // Compute the information needed to perform the test.
2917 // 2496 //
2918 String originalContents = "$prefix$removed$suffix"; 2497 String originalContents = "$prefix$removed$suffix";
2919 String modifiedContents = "$prefix$added$suffix"; 2498 String modifiedContents = "$prefix$added$suffix";
2920 int replaceStart = prefix.length; 2499 int replaceStart = prefix.length;
2921 Source source = new TestSource(); 2500 Source source = new TestSource();
2922 // 2501 //
2923 // Parse the original contents. 2502 // Parse the original contents.
2924 // 2503 //
2925 GatheringErrorListener originalListener = new GatheringErrorListener(); 2504 GatheringErrorListener originalListener = new GatheringErrorListener();
2926 Scanner originalScanner = new Scanner( 2505 Scanner originalScanner = new Scanner(
2927 source, 2506 source, new CharSequenceReader(originalContents), originalListener);
2928 new CharSequenceReader(originalContents),
2929 originalListener);
2930 Token originalTokens = originalScanner.tokenize(); 2507 Token originalTokens = originalScanner.tokenize();
2931 expect(originalTokens, isNotNull); 2508 expect(originalTokens, isNotNull);
2932 Parser originalParser = new Parser(source, originalListener); 2509 Parser originalParser = new Parser(source, originalListener);
2933 CompilationUnit originalUnit = 2510 CompilationUnit originalUnit =
2934 originalParser.parseCompilationUnit(originalTokens); 2511 originalParser.parseCompilationUnit(originalTokens);
2935 expect(originalUnit, isNotNull); 2512 expect(originalUnit, isNotNull);
2936 // 2513 //
2937 // Parse the modified contents. 2514 // Parse the modified contents.
2938 // 2515 //
2939 GatheringErrorListener modifiedListener = new GatheringErrorListener(); 2516 GatheringErrorListener modifiedListener = new GatheringErrorListener();
2940 Scanner modifiedScanner = new Scanner( 2517 Scanner modifiedScanner = new Scanner(
2941 source, 2518 source, new CharSequenceReader(modifiedContents), modifiedListener);
2942 new CharSequenceReader(modifiedContents),
2943 modifiedListener);
2944 Token modifiedTokens = modifiedScanner.tokenize(); 2519 Token modifiedTokens = modifiedScanner.tokenize();
2945 expect(modifiedTokens, isNotNull); 2520 expect(modifiedTokens, isNotNull);
2946 Parser modifiedParser = new Parser(source, modifiedListener); 2521 Parser modifiedParser = new Parser(source, modifiedListener);
2947 CompilationUnit modifiedUnit = 2522 CompilationUnit modifiedUnit =
2948 modifiedParser.parseCompilationUnit(modifiedTokens); 2523 modifiedParser.parseCompilationUnit(modifiedTokens);
2949 expect(modifiedUnit, isNotNull); 2524 expect(modifiedUnit, isNotNull);
2950 // 2525 //
2951 // Incrementally parse the modified contents. 2526 // Incrementally parse the modified contents.
2952 // 2527 //
2953 GatheringErrorListener incrementalListener = new GatheringErrorListener(); 2528 GatheringErrorListener incrementalListener = new GatheringErrorListener();
2954 IncrementalScanner incrementalScanner = new IncrementalScanner( 2529 IncrementalScanner incrementalScanner = new IncrementalScanner(
2955 source, 2530 source, new CharSequenceReader(modifiedContents), incrementalListener);
2956 new CharSequenceReader(modifiedContents),
2957 incrementalListener);
2958 Token incrementalTokens = incrementalScanner.rescan( 2531 Token incrementalTokens = incrementalScanner.rescan(
2959 originalTokens, 2532 originalTokens, replaceStart, removed.length, added.length);
2960 replaceStart,
2961 removed.length,
2962 added.length);
2963 expect(incrementalTokens, isNotNull); 2533 expect(incrementalTokens, isNotNull);
2964 IncrementalParser incrementalParser = new IncrementalParser( 2534 IncrementalParser incrementalParser = new IncrementalParser(
2965 source, 2535 source, incrementalScanner.tokenMap, incrementalListener);
2966 incrementalScanner.tokenMap, 2536 CompilationUnit incrementalUnit = incrementalParser.reparse(originalUnit,
2967 incrementalListener); 2537 incrementalScanner.leftToken, incrementalScanner.rightToken,
2968 CompilationUnit incrementalUnit = incrementalParser.reparse( 2538 replaceStart, prefix.length + removed.length);
2969 originalUnit,
2970 incrementalScanner.leftToken,
2971 incrementalScanner.rightToken,
2972 replaceStart,
2973 prefix.length + removed.length);
2974 expect(incrementalUnit, isNotNull); 2539 expect(incrementalUnit, isNotNull);
2975 // 2540 //
2976 // Validate that the results of the incremental parse are the same as the 2541 // Validate that the results of the incremental parse are the same as the
2977 // full parse of the modified source. 2542 // full parse of the modified source.
2978 // 2543 //
2979 expect(AstComparator.equalNodes(modifiedUnit, incrementalUnit), isTrue); 2544 expect(AstComparator.equalNodes(modifiedUnit, incrementalUnit), isTrue);
2980 // TODO(brianwilkerson) Verify that the errors are correct? 2545 // TODO(brianwilkerson) Verify that the errors are correct?
2981 } 2546 }
2982 } 2547 }
2983 2548
2984 @reflectiveTest 2549 @reflectiveTest
2985 class NonErrorParserTest extends ParserTestCase { 2550 class NonErrorParserTest extends ParserTestCase {
2986 void test_constFactory_external() { 2551 void test_constFactory_external() {
2987 ParserTestCase.parse( 2552 ParserTestCase.parse(
2988 "parseClassMember", 2553 "parseClassMember", <Object>["C"], "external const factory C();");
2989 <Object>["C"],
2990 "external const factory C();");
2991 } 2554 }
2992 } 2555 }
2993 2556
2994 class ParserTestCase extends EngineTestCase { 2557 class ParserTestCase extends EngineTestCase {
2995 /** 2558 /**
2996 * An empty list of objects used as arguments to zero-argument methods. 2559 * An empty list of objects used as arguments to zero-argument methods.
2997 */ 2560 */
2998 static const List<Object> _EMPTY_ARGUMENTS = const <Object>[]; 2561 static const List<Object> _EMPTY_ARGUMENTS = const <Object>[];
2999 2562
3000 /** 2563 /**
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
3086 * source before the method is invoked. 2649 * source before the method is invoked.
3087 * 2650 *
3088 * @param methodName the name of the method that should be invoked 2651 * @param methodName the name of the method that should be invoked
3089 * @param source the source to be processed by the parse method 2652 * @param source the source to be processed by the parse method
3090 * @param listener the error listener that will be used for both scanning and parsing 2653 * @param listener the error listener that will be used for both scanning and parsing
3091 * @return the result of invoking the method 2654 * @return the result of invoking the method
3092 * @throws Exception if the method could not be invoked or throws an exception 2655 * @throws Exception if the method could not be invoked or throws an exception
3093 * @throws AssertionFailedError if the result is `null` or the errors produced while 2656 * @throws AssertionFailedError if the result is `null` or the errors produced while
3094 * scanning and parsing the source do not match the expected errors 2657 * scanning and parsing the source do not match the expected errors
3095 */ 2658 */
3096 static Object invokeParserMethod2(String methodName, String source, 2659 static Object invokeParserMethod2(
3097 GatheringErrorListener listener) => 2660 String methodName, String source, GatheringErrorListener listener) =>
3098 invokeParserMethod(methodName, _EMPTY_ARGUMENTS, source, listener); 2661 invokeParserMethod(methodName, _EMPTY_ARGUMENTS, source, listener);
3099 2662
3100 /** 2663 /**
3101 * Invoke a parse method in [Parser]. The method is assumed to have the given number and 2664 * Invoke a parse method in [Parser]. The method is assumed to have the given number and
3102 * type of parameters and will be invoked with the given arguments. 2665 * type of parameters and will be invoked with the given arguments.
3103 * 2666 *
3104 * The given source is scanned and the parser is initialized to start with the first token in the 2667 * The given source is scanned and the parser is initialized to start with the first token in the
3105 * source before the parse method is invoked. 2668 * source before the parse method is invoked.
3106 * 2669 *
3107 * @param methodName the name of the parse method that should be invoked to pa rse the source 2670 * @param methodName the name of the parse method that should be invoked to pa rse the source
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
3170 * 2733 *
3171 * @param methodName the name of the parse method that should be invoked to pa rse the source 2734 * @param methodName the name of the parse method that should be invoked to pa rse the source
3172 * @param source the source to be parsed by the parse method 2735 * @param source the source to be parsed by the parse method
3173 * @param errorCodes the error codes of the errors that should be generated 2736 * @param errorCodes the error codes of the errors that should be generated
3174 * @return the result of invoking the method 2737 * @return the result of invoking the method
3175 * @throws Exception if the method could not be invoked or throws an exception 2738 * @throws Exception if the method could not be invoked or throws an exception
3176 * @throws AssertionFailedError if the result is `null` or the errors produced while 2739 * @throws AssertionFailedError if the result is `null` or the errors produced while
3177 * scanning and parsing the source do not match the expected errors 2740 * scanning and parsing the source do not match the expected errors
3178 */ 2741 */
3179 static Object parse4(String methodName, String source, 2742 static Object parse4(String methodName, String source,
3180 [List<ErrorCode> errorCodes = ErrorCode.EMPTY_LIST]) => 2743 [List<ErrorCode> errorCodes = ErrorCode.EMPTY_LIST]) =>
3181 parse3(methodName, _EMPTY_ARGUMENTS, source, errorCodes); 2744 parse3(methodName, _EMPTY_ARGUMENTS, source, errorCodes);
3182 2745
3183 /** 2746 /**
3184 * Parse the given source as a compilation unit. 2747 * Parse the given source as a compilation unit.
3185 * 2748 *
3186 * @param source the source to be parsed 2749 * @param source the source to be parsed
3187 * @param errorCodes the error codes of the errors that are expected to be fou nd 2750 * @param errorCodes the error codes of the errors that are expected to be fou nd
3188 * @return the compilation unit that was parsed 2751 * @return the compilation unit that was parsed
3189 * @throws Exception if the source could not be parsed, if the compilation err ors in the source do 2752 * @throws Exception if the source could not be parsed, if the compilation err ors in the source do
3190 * not match those that are expected, or if the result would have be en `null` 2753 * not match those that are expected, or if the result would have be en `null`
(...skipping 14 matching lines...) Expand all
3205 2768
3206 /** 2769 /**
3207 * Parse the given source as an expression. 2770 * Parse the given source as an expression.
3208 * 2771 *
3209 * @param source the source to be parsed 2772 * @param source the source to be parsed
3210 * @param errorCodes the error codes of the errors that are expected to be fou nd 2773 * @param errorCodes the error codes of the errors that are expected to be fou nd
3211 * @return the expression that was parsed 2774 * @return the expression that was parsed
3212 * @throws Exception if the source could not be parsed, if the compilation err ors in the source do 2775 * @throws Exception if the source could not be parsed, if the compilation err ors in the source do
3213 * not match those that are expected, or if the result would have be en `null` 2776 * not match those that are expected, or if the result would have be en `null`
3214 */ 2777 */
3215 static Expression parseExpression(String source, [List<ErrorCode> errorCodes = 2778 static Expression parseExpression(String source,
3216 ErrorCode.EMPTY_LIST]) { 2779 [List<ErrorCode> errorCodes = ErrorCode.EMPTY_LIST]) {
3217 GatheringErrorListener listener = new GatheringErrorListener(); 2780 GatheringErrorListener listener = new GatheringErrorListener();
3218 Scanner scanner = 2781 Scanner scanner =
3219 new Scanner(null, new CharSequenceReader(source), listener); 2782 new Scanner(null, new CharSequenceReader(source), listener);
3220 listener.setLineInfo(new TestSource(), scanner.lineStarts); 2783 listener.setLineInfo(new TestSource(), scanner.lineStarts);
3221 Token token = scanner.tokenize(); 2784 Token token = scanner.tokenize();
3222 Parser parser = createParser(listener); 2785 Parser parser = createParser(listener);
3223 Expression expression = parser.parseExpression(token); 2786 Expression expression = parser.parseExpression(token);
3224 expect(expression, isNotNull); 2787 expect(expression, isNotNull);
3225 listener.assertErrorsWithCodes(errorCodes); 2788 listener.assertErrorsWithCodes(errorCodes);
3226 return expression; 2789 return expression;
3227 } 2790 }
3228 2791
3229 /** 2792 /**
3230 * Parse the given source as a statement. 2793 * Parse the given source as a statement.
3231 * 2794 *
3232 * @param source the source to be parsed 2795 * @param source the source to be parsed
3233 * @param errorCodes the error codes of the errors that are expected to be fou nd 2796 * @param errorCodes the error codes of the errors that are expected to be fou nd
3234 * @return the statement that was parsed 2797 * @return the statement that was parsed
3235 * @throws Exception if the source could not be parsed, if the compilation err ors in the source do 2798 * @throws Exception if the source could not be parsed, if the compilation err ors in the source do
3236 * not match those that are expected, or if the result would have be en `null` 2799 * not match those that are expected, or if the result would have be en `null`
3237 */ 2800 */
3238 static Statement parseStatement(String source, [List<ErrorCode> errorCodes = 2801 static Statement parseStatement(String source,
3239 ErrorCode.EMPTY_LIST]) { 2802 [List<ErrorCode> errorCodes = ErrorCode.EMPTY_LIST]) {
3240 GatheringErrorListener listener = new GatheringErrorListener(); 2803 GatheringErrorListener listener = new GatheringErrorListener();
3241 Scanner scanner = 2804 Scanner scanner =
3242 new Scanner(null, new CharSequenceReader(source), listener); 2805 new Scanner(null, new CharSequenceReader(source), listener);
3243 listener.setLineInfo(new TestSource(), scanner.lineStarts); 2806 listener.setLineInfo(new TestSource(), scanner.lineStarts);
3244 Token token = scanner.tokenize(); 2807 Token token = scanner.tokenize();
3245 Parser parser = createParser(listener); 2808 Parser parser = createParser(listener);
3246 Statement statement = parser.parseStatement(token); 2809 Statement statement = parser.parseStatement(token);
3247 expect(statement, isNotNull); 2810 expect(statement, isNotNull);
3248 listener.assertErrorsWithCodes(errorCodes); 2811 listener.assertErrorsWithCodes(errorCodes);
3249 return statement; 2812 return statement;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
3287 if (map == null) return null; 2850 if (map == null) return null;
3288 Map<Symbol, dynamic> result = new Map<Symbol, dynamic>(); 2851 Map<Symbol, dynamic> result = new Map<Symbol, dynamic>();
3289 map.forEach((name, value) { 2852 map.forEach((name, value) {
3290 result[new Symbol(name)] = value; 2853 result[new Symbol(name)] = value;
3291 }); 2854 });
3292 return result; 2855 return result;
3293 }'''); 2856 }''');
3294 } 2857 }
3295 2858
3296 void test_additiveExpression_missing_LHS() { 2859 void test_additiveExpression_missing_LHS() {
3297 BinaryExpression expression = 2860 BinaryExpression expression = ParserTestCase.parseExpression(
3298 ParserTestCase.parseExpression("+ y", [ParserErrorCode.MISSING_IDENTIFIE R]); 2861 "+ y", [ParserErrorCode.MISSING_IDENTIFIER]);
3299 EngineTestCase.assertInstanceOf( 2862 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier,
3300 (obj) => obj is SimpleIdentifier, 2863 SimpleIdentifier, expression.leftOperand);
3301 SimpleIdentifier,
3302 expression.leftOperand);
3303 expect(expression.leftOperand.isSynthetic, isTrue); 2864 expect(expression.leftOperand.isSynthetic, isTrue);
3304 } 2865 }
3305 2866
3306 void test_additiveExpression_missing_LHS_RHS() { 2867 void test_additiveExpression_missing_LHS_RHS() {
3307 BinaryExpression expression = ParserTestCase.parseExpression( 2868 BinaryExpression expression = ParserTestCase.parseExpression("+", [
3308 "+", 2869 ParserErrorCode.MISSING_IDENTIFIER,
3309 [ParserErrorCode.MISSING_IDENTIFIER, ParserErrorCode.MISSING_IDENTIFIER] ); 2870 ParserErrorCode.MISSING_IDENTIFIER
3310 EngineTestCase.assertInstanceOf( 2871 ]);
3311 (obj) => obj is SimpleIdentifier, 2872 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier,
3312 SimpleIdentifier, 2873 SimpleIdentifier, expression.leftOperand);
3313 expression.leftOperand); 2874 expect(expression.leftOperand.isSynthetic, isTrue);
3314 expect(expression.leftOperand.isSynthetic, isTrue); 2875 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier,
3315 EngineTestCase.assertInstanceOf( 2876 SimpleIdentifier, expression.rightOperand);
3316 (obj) => obj is SimpleIdentifier,
3317 SimpleIdentifier,
3318 expression.rightOperand);
3319 expect(expression.rightOperand.isSynthetic, isTrue); 2877 expect(expression.rightOperand.isSynthetic, isTrue);
3320 } 2878 }
3321 2879
3322 void test_additiveExpression_missing_RHS() { 2880 void test_additiveExpression_missing_RHS() {
3323 BinaryExpression expression = 2881 BinaryExpression expression = ParserTestCase.parseExpression(
3324 ParserTestCase.parseExpression("x +", [ParserErrorCode.MISSING_IDENTIFIE R]); 2882 "x +", [ParserErrorCode.MISSING_IDENTIFIER]);
3325 EngineTestCase.assertInstanceOf( 2883 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier,
3326 (obj) => obj is SimpleIdentifier, 2884 SimpleIdentifier, expression.rightOperand);
3327 SimpleIdentifier,
3328 expression.rightOperand);
3329 expect(expression.rightOperand.isSynthetic, isTrue); 2885 expect(expression.rightOperand.isSynthetic, isTrue);
3330 } 2886 }
3331 2887
3332 void test_additiveExpression_missing_RHS_super() { 2888 void test_additiveExpression_missing_RHS_super() {
3333 BinaryExpression expression = ParserTestCase.parseExpression( 2889 BinaryExpression expression = ParserTestCase.parseExpression(
3334 "super +", 2890 "super +", [ParserErrorCode.MISSING_IDENTIFIER]);
3335 [ParserErrorCode.MISSING_IDENTIFIER]); 2891 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier,
3336 EngineTestCase.assertInstanceOf( 2892 SimpleIdentifier, expression.rightOperand);
3337 (obj) => obj is SimpleIdentifier,
3338 SimpleIdentifier,
3339 expression.rightOperand);
3340 expect(expression.rightOperand.isSynthetic, isTrue); 2893 expect(expression.rightOperand.isSynthetic, isTrue);
3341 } 2894 }
3342 2895
3343 void test_additiveExpression_precedence_multiplicative_left() { 2896 void test_additiveExpression_precedence_multiplicative_left() {
3344 BinaryExpression expression = ParserTestCase.parseExpression( 2897 BinaryExpression expression = ParserTestCase.parseExpression("* +", [
3345 "* +", 2898 ParserErrorCode.MISSING_IDENTIFIER,
3346 [ 2899 ParserErrorCode.MISSING_IDENTIFIER,
3347 ParserErrorCode.MISSING_IDENTIFIER, 2900 ParserErrorCode.MISSING_IDENTIFIER
3348 ParserErrorCode.MISSING_IDENTIFIER, 2901 ]);
3349 ParserErrorCode.MISSING_IDENTIFIER]); 2902 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression,
3350 EngineTestCase.assertInstanceOf( 2903 BinaryExpression, expression.leftOperand);
3351 (obj) => obj is BinaryExpression,
3352 BinaryExpression,
3353 expression.leftOperand);
3354 } 2904 }
3355 2905
3356 void test_additiveExpression_precedence_multiplicative_right() { 2906 void test_additiveExpression_precedence_multiplicative_right() {
3357 BinaryExpression expression = ParserTestCase.parseExpression( 2907 BinaryExpression expression = ParserTestCase.parseExpression("+ *", [
3358 "+ *", 2908 ParserErrorCode.MISSING_IDENTIFIER,
3359 [ 2909 ParserErrorCode.MISSING_IDENTIFIER,
3360 ParserErrorCode.MISSING_IDENTIFIER, 2910 ParserErrorCode.MISSING_IDENTIFIER
3361 ParserErrorCode.MISSING_IDENTIFIER, 2911 ]);
3362 ParserErrorCode.MISSING_IDENTIFIER]); 2912 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression,
3363 EngineTestCase.assertInstanceOf( 2913 BinaryExpression, expression.rightOperand);
3364 (obj) => obj is BinaryExpression,
3365 BinaryExpression,
3366 expression.rightOperand);
3367 } 2914 }
3368 2915
3369 void test_additiveExpression_super() { 2916 void test_additiveExpression_super() {
3370 BinaryExpression expression = ParserTestCase.parseExpression( 2917 BinaryExpression expression = ParserTestCase.parseExpression("super + +", [
3371 "super + +", 2918 ParserErrorCode.MISSING_IDENTIFIER,
3372 [ParserErrorCode.MISSING_IDENTIFIER, ParserErrorCode.MISSING_IDENTIFIER] ); 2919 ParserErrorCode.MISSING_IDENTIFIER
3373 EngineTestCase.assertInstanceOf( 2920 ]);
3374 (obj) => obj is BinaryExpression, 2921 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression,
3375 BinaryExpression, 2922 BinaryExpression, expression.leftOperand);
3376 expression.leftOperand);
3377 } 2923 }
3378 2924
3379 void test_assignmentExpression_missing_compound1() { 2925 void test_assignmentExpression_missing_compound1() {
3380 AssignmentExpression expression = ParserTestCase.parseExpression( 2926 AssignmentExpression expression = ParserTestCase.parseExpression(
3381 "= y = 0", 2927 "= y = 0", [ParserErrorCode.MISSING_IDENTIFIER]);
3382 [ParserErrorCode.MISSING_IDENTIFIER]);
3383 Expression syntheticExpression = expression.leftHandSide; 2928 Expression syntheticExpression = expression.leftHandSide;
3384 EngineTestCase.assertInstanceOf( 2929 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier,
3385 (obj) => obj is SimpleIdentifier, 2930 SimpleIdentifier, syntheticExpression);
3386 SimpleIdentifier,
3387 syntheticExpression);
3388 expect(syntheticExpression.isSynthetic, isTrue); 2931 expect(syntheticExpression.isSynthetic, isTrue);
3389 } 2932 }
3390 2933
3391 void test_assignmentExpression_missing_compound2() { 2934 void test_assignmentExpression_missing_compound2() {
3392 AssignmentExpression expression = ParserTestCase.parseExpression( 2935 AssignmentExpression expression = ParserTestCase.parseExpression(
3393 "x = = 0", 2936 "x = = 0", [ParserErrorCode.MISSING_IDENTIFIER]);
3394 [ParserErrorCode.MISSING_IDENTIFIER]);
3395 Expression syntheticExpression = 2937 Expression syntheticExpression =
3396 (expression.rightHandSide as AssignmentExpression).leftHandSide; 2938 (expression.rightHandSide as AssignmentExpression).leftHandSide;
3397 EngineTestCase.assertInstanceOf( 2939 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier,
3398 (obj) => obj is SimpleIdentifier, 2940 SimpleIdentifier, syntheticExpression);
3399 SimpleIdentifier,
3400 syntheticExpression);
3401 expect(syntheticExpression.isSynthetic, isTrue); 2941 expect(syntheticExpression.isSynthetic, isTrue);
3402 } 2942 }
3403 2943
3404 void test_assignmentExpression_missing_compound3() { 2944 void test_assignmentExpression_missing_compound3() {
3405 AssignmentExpression expression = ParserTestCase.parseExpression( 2945 AssignmentExpression expression = ParserTestCase.parseExpression(
3406 "x = y =", 2946 "x = y =", [ParserErrorCode.MISSING_IDENTIFIER]);
3407 [ParserErrorCode.MISSING_IDENTIFIER]);
3408 Expression syntheticExpression = 2947 Expression syntheticExpression =
3409 (expression.rightHandSide as AssignmentExpression).rightHandSide; 2948 (expression.rightHandSide as AssignmentExpression).rightHandSide;
3410 EngineTestCase.assertInstanceOf( 2949 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier,
3411 (obj) => obj is SimpleIdentifier, 2950 SimpleIdentifier, syntheticExpression);
3412 SimpleIdentifier,
3413 syntheticExpression);
3414 expect(syntheticExpression.isSynthetic, isTrue); 2951 expect(syntheticExpression.isSynthetic, isTrue);
3415 } 2952 }
3416 2953
3417 void test_assignmentExpression_missing_LHS() { 2954 void test_assignmentExpression_missing_LHS() {
3418 AssignmentExpression expression = 2955 AssignmentExpression expression = ParserTestCase.parseExpression(
3419 ParserTestCase.parseExpression("= 0", [ParserErrorCode.MISSING_IDENTIFIE R]); 2956 "= 0", [ParserErrorCode.MISSING_IDENTIFIER]);
3420 EngineTestCase.assertInstanceOf( 2957 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier,
3421 (obj) => obj is SimpleIdentifier, 2958 SimpleIdentifier, expression.leftHandSide);
3422 SimpleIdentifier,
3423 expression.leftHandSide);
3424 expect(expression.leftHandSide.isSynthetic, isTrue); 2959 expect(expression.leftHandSide.isSynthetic, isTrue);
3425 } 2960 }
3426 2961
3427 void test_assignmentExpression_missing_RHS() { 2962 void test_assignmentExpression_missing_RHS() {
3428 AssignmentExpression expression = 2963 AssignmentExpression expression = ParserTestCase.parseExpression(
3429 ParserTestCase.parseExpression("x =", [ParserErrorCode.MISSING_IDENTIFIE R]); 2964 "x =", [ParserErrorCode.MISSING_IDENTIFIER]);
3430 EngineTestCase.assertInstanceOf( 2965 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier,
3431 (obj) => obj is SimpleIdentifier, 2966 SimpleIdentifier, expression.leftHandSide);
3432 SimpleIdentifier,
3433 expression.leftHandSide);
3434 expect(expression.rightHandSide.isSynthetic, isTrue); 2967 expect(expression.rightHandSide.isSynthetic, isTrue);
3435 } 2968 }
3436 2969
3437 void test_bitwiseAndExpression_missing_LHS() { 2970 void test_bitwiseAndExpression_missing_LHS() {
3438 BinaryExpression expression = 2971 BinaryExpression expression = ParserTestCase.parseExpression(
3439 ParserTestCase.parseExpression("& y", [ParserErrorCode.MISSING_IDENTIFIE R]); 2972 "& y", [ParserErrorCode.MISSING_IDENTIFIER]);
3440 EngineTestCase.assertInstanceOf( 2973 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier,
3441 (obj) => obj is SimpleIdentifier, 2974 SimpleIdentifier, expression.leftOperand);
3442 SimpleIdentifier,
3443 expression.leftOperand);
3444 expect(expression.leftOperand.isSynthetic, isTrue); 2975 expect(expression.leftOperand.isSynthetic, isTrue);
3445 } 2976 }
3446 2977
3447 void test_bitwiseAndExpression_missing_LHS_RHS() { 2978 void test_bitwiseAndExpression_missing_LHS_RHS() {
3448 BinaryExpression expression = ParserTestCase.parseExpression( 2979 BinaryExpression expression = ParserTestCase.parseExpression("&", [
3449 "&", 2980 ParserErrorCode.MISSING_IDENTIFIER,
3450 [ParserErrorCode.MISSING_IDENTIFIER, ParserErrorCode.MISSING_IDENTIFIER] ); 2981 ParserErrorCode.MISSING_IDENTIFIER
3451 EngineTestCase.assertInstanceOf( 2982 ]);
3452 (obj) => obj is SimpleIdentifier, 2983 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier,
3453 SimpleIdentifier, 2984 SimpleIdentifier, expression.leftOperand);
3454 expression.leftOperand); 2985 expect(expression.leftOperand.isSynthetic, isTrue);
3455 expect(expression.leftOperand.isSynthetic, isTrue); 2986 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier,
3456 EngineTestCase.assertInstanceOf( 2987 SimpleIdentifier, expression.rightOperand);
3457 (obj) => obj is SimpleIdentifier,
3458 SimpleIdentifier,
3459 expression.rightOperand);
3460 expect(expression.rightOperand.isSynthetic, isTrue); 2988 expect(expression.rightOperand.isSynthetic, isTrue);
3461 } 2989 }
3462 2990
3463 void test_bitwiseAndExpression_missing_RHS() { 2991 void test_bitwiseAndExpression_missing_RHS() {
3464 BinaryExpression expression = 2992 BinaryExpression expression = ParserTestCase.parseExpression(
3465 ParserTestCase.parseExpression("x &", [ParserErrorCode.MISSING_IDENTIFIE R]); 2993 "x &", [ParserErrorCode.MISSING_IDENTIFIER]);
3466 EngineTestCase.assertInstanceOf( 2994 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier,
3467 (obj) => obj is SimpleIdentifier, 2995 SimpleIdentifier, expression.rightOperand);
3468 SimpleIdentifier,
3469 expression.rightOperand);
3470 expect(expression.rightOperand.isSynthetic, isTrue); 2996 expect(expression.rightOperand.isSynthetic, isTrue);
3471 } 2997 }
3472 2998
3473 void test_bitwiseAndExpression_missing_RHS_super() { 2999 void test_bitwiseAndExpression_missing_RHS_super() {
3474 BinaryExpression expression = ParserTestCase.parseExpression( 3000 BinaryExpression expression = ParserTestCase.parseExpression(
3475 "super &", 3001 "super &", [ParserErrorCode.MISSING_IDENTIFIER]);
3476 [ParserErrorCode.MISSING_IDENTIFIER]); 3002 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier,
3477 EngineTestCase.assertInstanceOf( 3003 SimpleIdentifier, expression.rightOperand);
3478 (obj) => obj is SimpleIdentifier,
3479 SimpleIdentifier,
3480 expression.rightOperand);
3481 expect(expression.rightOperand.isSynthetic, isTrue); 3004 expect(expression.rightOperand.isSynthetic, isTrue);
3482 } 3005 }
3483 3006
3484 void test_bitwiseAndExpression_precedence_equality_left() { 3007 void test_bitwiseAndExpression_precedence_equality_left() {
3485 BinaryExpression expression = ParserTestCase.parseExpression( 3008 BinaryExpression expression = ParserTestCase.parseExpression("== &&", [
3486 "== &&", 3009 ParserErrorCode.MISSING_IDENTIFIER,
3487 [ 3010 ParserErrorCode.MISSING_IDENTIFIER,
3488 ParserErrorCode.MISSING_IDENTIFIER, 3011 ParserErrorCode.MISSING_IDENTIFIER
3489 ParserErrorCode.MISSING_IDENTIFIER, 3012 ]);
3490 ParserErrorCode.MISSING_IDENTIFIER]); 3013 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression,
3491 EngineTestCase.assertInstanceOf( 3014 BinaryExpression, expression.leftOperand);
3492 (obj) => obj is BinaryExpression,
3493 BinaryExpression,
3494 expression.leftOperand);
3495 } 3015 }
3496 3016
3497 void test_bitwiseAndExpression_precedence_equality_right() { 3017 void test_bitwiseAndExpression_precedence_equality_right() {
3498 BinaryExpression expression = ParserTestCase.parseExpression( 3018 BinaryExpression expression = ParserTestCase.parseExpression("&& ==", [
3499 "&& ==", 3019 ParserErrorCode.MISSING_IDENTIFIER,
3500 [ 3020 ParserErrorCode.MISSING_IDENTIFIER,
3501 ParserErrorCode.MISSING_IDENTIFIER, 3021 ParserErrorCode.MISSING_IDENTIFIER
3502 ParserErrorCode.MISSING_IDENTIFIER, 3022 ]);
3503 ParserErrorCode.MISSING_IDENTIFIER]); 3023 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression,
3504 EngineTestCase.assertInstanceOf( 3024 BinaryExpression, expression.rightOperand);
3505 (obj) => obj is BinaryExpression,
3506 BinaryExpression,
3507 expression.rightOperand);
3508 } 3025 }
3509 3026
3510 void test_bitwiseAndExpression_super() { 3027 void test_bitwiseAndExpression_super() {
3511 BinaryExpression expression = ParserTestCase.parseExpression( 3028 BinaryExpression expression = ParserTestCase.parseExpression("super & &", [
3512 "super & &", 3029 ParserErrorCode.MISSING_IDENTIFIER,
3513 [ParserErrorCode.MISSING_IDENTIFIER, ParserErrorCode.MISSING_IDENTIFIER] ); 3030 ParserErrorCode.MISSING_IDENTIFIER
3514 EngineTestCase.assertInstanceOf( 3031 ]);
3515 (obj) => obj is BinaryExpression, 3032 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression,
3516 BinaryExpression, 3033 BinaryExpression, expression.leftOperand);
3517 expression.leftOperand);
3518 } 3034 }
3519 3035
3520 void test_bitwiseOrExpression_missing_LHS() { 3036 void test_bitwiseOrExpression_missing_LHS() {
3521 BinaryExpression expression = 3037 BinaryExpression expression = ParserTestCase.parseExpression(
3522 ParserTestCase.parseExpression("| y", [ParserErrorCode.MISSING_IDENTIFIE R]); 3038 "| y", [ParserErrorCode.MISSING_IDENTIFIER]);
3523 EngineTestCase.assertInstanceOf( 3039 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier,
3524 (obj) => obj is SimpleIdentifier, 3040 SimpleIdentifier, expression.leftOperand);
3525 SimpleIdentifier,
3526 expression.leftOperand);
3527 expect(expression.leftOperand.isSynthetic, isTrue); 3041 expect(expression.leftOperand.isSynthetic, isTrue);
3528 } 3042 }
3529 3043
3530 void test_bitwiseOrExpression_missing_LHS_RHS() { 3044 void test_bitwiseOrExpression_missing_LHS_RHS() {
3531 BinaryExpression expression = ParserTestCase.parseExpression( 3045 BinaryExpression expression = ParserTestCase.parseExpression("|", [
3532 "|", 3046 ParserErrorCode.MISSING_IDENTIFIER,
3533 [ParserErrorCode.MISSING_IDENTIFIER, ParserErrorCode.MISSING_IDENTIFIER] ); 3047 ParserErrorCode.MISSING_IDENTIFIER
3534 EngineTestCase.assertInstanceOf( 3048 ]);
3535 (obj) => obj is SimpleIdentifier, 3049 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier,
3536 SimpleIdentifier, 3050 SimpleIdentifier, expression.leftOperand);
3537 expression.leftOperand); 3051 expect(expression.leftOperand.isSynthetic, isTrue);
3538 expect(expression.leftOperand.isSynthetic, isTrue); 3052 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier,
3539 EngineTestCase.assertInstanceOf( 3053 SimpleIdentifier, expression.rightOperand);
3540 (obj) => obj is SimpleIdentifier,
3541 SimpleIdentifier,
3542 expression.rightOperand);
3543 expect(expression.rightOperand.isSynthetic, isTrue); 3054 expect(expression.rightOperand.isSynthetic, isTrue);
3544 } 3055 }
3545 3056
3546 void test_bitwiseOrExpression_missing_RHS() { 3057 void test_bitwiseOrExpression_missing_RHS() {
3547 BinaryExpression expression = 3058 BinaryExpression expression = ParserTestCase.parseExpression(
3548 ParserTestCase.parseExpression("x |", [ParserErrorCode.MISSING_IDENTIFIE R]); 3059 "x |", [ParserErrorCode.MISSING_IDENTIFIER]);
3549 EngineTestCase.assertInstanceOf( 3060 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier,
3550 (obj) => obj is SimpleIdentifier, 3061 SimpleIdentifier, expression.rightOperand);
3551 SimpleIdentifier,
3552 expression.rightOperand);
3553 expect(expression.rightOperand.isSynthetic, isTrue); 3062 expect(expression.rightOperand.isSynthetic, isTrue);
3554 } 3063 }
3555 3064
3556 void test_bitwiseOrExpression_missing_RHS_super() { 3065 void test_bitwiseOrExpression_missing_RHS_super() {
3557 BinaryExpression expression = ParserTestCase.parseExpression( 3066 BinaryExpression expression = ParserTestCase.parseExpression(
3558 "super |", 3067 "super |", [ParserErrorCode.MISSING_IDENTIFIER]);
3559 [ParserErrorCode.MISSING_IDENTIFIER]); 3068 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier,
3560 EngineTestCase.assertInstanceOf( 3069 SimpleIdentifier, expression.rightOperand);
3561 (obj) => obj is SimpleIdentifier,
3562 SimpleIdentifier,
3563 expression.rightOperand);
3564 expect(expression.rightOperand.isSynthetic, isTrue); 3070 expect(expression.rightOperand.isSynthetic, isTrue);
3565 } 3071 }
3566 3072
3567 void test_bitwiseOrExpression_precedence_xor_left() { 3073 void test_bitwiseOrExpression_precedence_xor_left() {
3568 BinaryExpression expression = ParserTestCase.parseExpression( 3074 BinaryExpression expression = ParserTestCase.parseExpression("^ |", [
3569 "^ |", 3075 ParserErrorCode.MISSING_IDENTIFIER,
3570 [ 3076 ParserErrorCode.MISSING_IDENTIFIER,
3571 ParserErrorCode.MISSING_IDENTIFIER, 3077 ParserErrorCode.MISSING_IDENTIFIER
3572 ParserErrorCode.MISSING_IDENTIFIER, 3078 ]);
3573 ParserErrorCode.MISSING_IDENTIFIER]); 3079 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression,
3574 EngineTestCase.assertInstanceOf( 3080 BinaryExpression, expression.leftOperand);
3575 (obj) => obj is BinaryExpression,
3576 BinaryExpression,
3577 expression.leftOperand);
3578 } 3081 }
3579 3082
3580 void test_bitwiseOrExpression_precedence_xor_right() { 3083 void test_bitwiseOrExpression_precedence_xor_right() {
3581 BinaryExpression expression = ParserTestCase.parseExpression( 3084 BinaryExpression expression = ParserTestCase.parseExpression("| ^", [
3582 "| ^", 3085 ParserErrorCode.MISSING_IDENTIFIER,
3583 [ 3086 ParserErrorCode.MISSING_IDENTIFIER,
3584 ParserErrorCode.MISSING_IDENTIFIER, 3087 ParserErrorCode.MISSING_IDENTIFIER
3585 ParserErrorCode.MISSING_IDENTIFIER, 3088 ]);
3586 ParserErrorCode.MISSING_IDENTIFIER]); 3089 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression,
3587 EngineTestCase.assertInstanceOf( 3090 BinaryExpression, expression.rightOperand);
3588 (obj) => obj is BinaryExpression,
3589 BinaryExpression,
3590 expression.rightOperand);
3591 } 3091 }
3592 3092
3593 void test_bitwiseOrExpression_super() { 3093 void test_bitwiseOrExpression_super() {
3594 BinaryExpression expression = ParserTestCase.parseExpression( 3094 BinaryExpression expression = ParserTestCase.parseExpression("super | |", [
3595 "super | |", 3095 ParserErrorCode.MISSING_IDENTIFIER,
3596 [ParserErrorCode.MISSING_IDENTIFIER, ParserErrorCode.MISSING_IDENTIFIER] ); 3096 ParserErrorCode.MISSING_IDENTIFIER
3597 EngineTestCase.assertInstanceOf( 3097 ]);
3598 (obj) => obj is BinaryExpression, 3098 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression,
3599 BinaryExpression, 3099 BinaryExpression, expression.leftOperand);
3600 expression.leftOperand);
3601 } 3100 }
3602 3101
3603 void test_bitwiseXorExpression_missing_LHS() { 3102 void test_bitwiseXorExpression_missing_LHS() {
3604 BinaryExpression expression = 3103 BinaryExpression expression = ParserTestCase.parseExpression(
3605 ParserTestCase.parseExpression("^ y", [ParserErrorCode.MISSING_IDENTIFIE R]); 3104 "^ y", [ParserErrorCode.MISSING_IDENTIFIER]);
3606 EngineTestCase.assertInstanceOf( 3105 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier,
3607 (obj) => obj is SimpleIdentifier, 3106 SimpleIdentifier, expression.leftOperand);
3608 SimpleIdentifier,
3609 expression.leftOperand);
3610 expect(expression.leftOperand.isSynthetic, isTrue); 3107 expect(expression.leftOperand.isSynthetic, isTrue);
3611 } 3108 }
3612 3109
3613 void test_bitwiseXorExpression_missing_LHS_RHS() { 3110 void test_bitwiseXorExpression_missing_LHS_RHS() {
3614 BinaryExpression expression = ParserTestCase.parseExpression( 3111 BinaryExpression expression = ParserTestCase.parseExpression("^", [
3615 "^", 3112 ParserErrorCode.MISSING_IDENTIFIER,
3616 [ParserErrorCode.MISSING_IDENTIFIER, ParserErrorCode.MISSING_IDENTIFIER] ); 3113 ParserErrorCode.MISSING_IDENTIFIER
3617 EngineTestCase.assertInstanceOf( 3114 ]);
3618 (obj) => obj is SimpleIdentifier, 3115 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier,
3619 SimpleIdentifier, 3116 SimpleIdentifier, expression.leftOperand);
3620 expression.leftOperand); 3117 expect(expression.leftOperand.isSynthetic, isTrue);
3621 expect(expression.leftOperand.isSynthetic, isTrue); 3118 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier,
3622 EngineTestCase.assertInstanceOf( 3119 SimpleIdentifier, expression.rightOperand);
3623 (obj) => obj is SimpleIdentifier,
3624 SimpleIdentifier,
3625 expression.rightOperand);
3626 expect(expression.rightOperand.isSynthetic, isTrue); 3120 expect(expression.rightOperand.isSynthetic, isTrue);
3627 } 3121 }
3628 3122
3629 void test_bitwiseXorExpression_missing_RHS() { 3123 void test_bitwiseXorExpression_missing_RHS() {
3630 BinaryExpression expression = 3124 BinaryExpression expression = ParserTestCase.parseExpression(
3631 ParserTestCase.parseExpression("x ^", [ParserErrorCode.MISSING_IDENTIFIE R]); 3125 "x ^", [ParserErrorCode.MISSING_IDENTIFIER]);
3632 EngineTestCase.assertInstanceOf( 3126 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier,
3633 (obj) => obj is SimpleIdentifier, 3127 SimpleIdentifier, expression.rightOperand);
3634 SimpleIdentifier,
3635 expression.rightOperand);
3636 expect(expression.rightOperand.isSynthetic, isTrue); 3128 expect(expression.rightOperand.isSynthetic, isTrue);
3637 } 3129 }
3638 3130
3639 void test_bitwiseXorExpression_missing_RHS_super() { 3131 void test_bitwiseXorExpression_missing_RHS_super() {
3640 BinaryExpression expression = ParserTestCase.parseExpression( 3132 BinaryExpression expression = ParserTestCase.parseExpression(
3641 "super ^", 3133 "super ^", [ParserErrorCode.MISSING_IDENTIFIER]);
3642 [ParserErrorCode.MISSING_IDENTIFIER]); 3134 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier,
3643 EngineTestCase.assertInstanceOf( 3135 SimpleIdentifier, expression.rightOperand);
3644 (obj) => obj is SimpleIdentifier,
3645 SimpleIdentifier,
3646 expression.rightOperand);
3647 expect(expression.rightOperand.isSynthetic, isTrue); 3136 expect(expression.rightOperand.isSynthetic, isTrue);
3648 } 3137 }
3649 3138
3650 void test_bitwiseXorExpression_precedence_and_left() { 3139 void test_bitwiseXorExpression_precedence_and_left() {
3651 BinaryExpression expression = ParserTestCase.parseExpression( 3140 BinaryExpression expression = ParserTestCase.parseExpression("& ^", [
3652 "& ^", 3141 ParserErrorCode.MISSING_IDENTIFIER,
3653 [ 3142 ParserErrorCode.MISSING_IDENTIFIER,
3654 ParserErrorCode.MISSING_IDENTIFIER, 3143 ParserErrorCode.MISSING_IDENTIFIER
3655 ParserErrorCode.MISSING_IDENTIFIER, 3144 ]);
3656 ParserErrorCode.MISSING_IDENTIFIER]); 3145 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression,
3657 EngineTestCase.assertInstanceOf( 3146 BinaryExpression, expression.leftOperand);
3658 (obj) => obj is BinaryExpression,
3659 BinaryExpression,
3660 expression.leftOperand);
3661 } 3147 }
3662 3148
3663 void test_bitwiseXorExpression_precedence_and_right() { 3149 void test_bitwiseXorExpression_precedence_and_right() {
3664 BinaryExpression expression = ParserTestCase.parseExpression( 3150 BinaryExpression expression = ParserTestCase.parseExpression("^ &", [
3665 "^ &", 3151 ParserErrorCode.MISSING_IDENTIFIER,
3666 [ 3152 ParserErrorCode.MISSING_IDENTIFIER,
3667 ParserErrorCode.MISSING_IDENTIFIER, 3153 ParserErrorCode.MISSING_IDENTIFIER
3668 ParserErrorCode.MISSING_IDENTIFIER, 3154 ]);
3669 ParserErrorCode.MISSING_IDENTIFIER]); 3155 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression,
3670 EngineTestCase.assertInstanceOf( 3156 BinaryExpression, expression.rightOperand);
3671 (obj) => obj is BinaryExpression,
3672 BinaryExpression,
3673 expression.rightOperand);
3674 } 3157 }
3675 3158
3676 void test_bitwiseXorExpression_super() { 3159 void test_bitwiseXorExpression_super() {
3677 BinaryExpression expression = ParserTestCase.parseExpression( 3160 BinaryExpression expression = ParserTestCase.parseExpression("super ^ ^", [
3678 "super ^ ^", 3161 ParserErrorCode.MISSING_IDENTIFIER,
3679 [ParserErrorCode.MISSING_IDENTIFIER, ParserErrorCode.MISSING_IDENTIFIER] ); 3162 ParserErrorCode.MISSING_IDENTIFIER
3680 EngineTestCase.assertInstanceOf( 3163 ]);
3681 (obj) => obj is BinaryExpression, 3164 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression,
3682 BinaryExpression, 3165 BinaryExpression, expression.leftOperand);
3683 expression.leftOperand);
3684 } 3166 }
3685 3167
3686 void test_classTypeAlias_withBody() { 3168 void test_classTypeAlias_withBody() {
3687 ParserTestCase.parseCompilationUnit(r''' 3169 ParserTestCase.parseCompilationUnit(r'''
3688 class A {} 3170 class A {}
3689 class B = Object with A {}''', [ParserErrorCode.EXPECTED_TOKEN]); 3171 class B = Object with A {}''', [ParserErrorCode.EXPECTED_TOKEN]);
3690 } 3172 }
3691 3173
3692 void test_conditionalExpression_missingElse() { 3174 void test_conditionalExpression_missingElse() {
3693 ConditionalExpression expression = ParserTestCase.parse4( 3175 ConditionalExpression expression = ParserTestCase.parse4(
3694 "parseConditionalExpression", 3176 "parseConditionalExpression", "x ? y :", [
3695 "x ? y :", 3177 ParserErrorCode.MISSING_IDENTIFIER
3696 [ParserErrorCode.MISSING_IDENTIFIER]); 3178 ]);
3697 EngineTestCase.assertInstanceOf( 3179 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier,
3698 (obj) => obj is SimpleIdentifier, 3180 SimpleIdentifier, expression.elseExpression);
3699 SimpleIdentifier,
3700 expression.elseExpression);
3701 expect(expression.elseExpression.isSynthetic, isTrue); 3181 expect(expression.elseExpression.isSynthetic, isTrue);
3702 } 3182 }
3703 3183
3704 void test_conditionalExpression_missingThen() { 3184 void test_conditionalExpression_missingThen() {
3705 ConditionalExpression expression = ParserTestCase.parse4( 3185 ConditionalExpression expression = ParserTestCase.parse4(
3706 "parseConditionalExpression", 3186 "parseConditionalExpression", "x ? : z", [
3707 "x ? : z", 3187 ParserErrorCode.MISSING_IDENTIFIER
3708 [ParserErrorCode.MISSING_IDENTIFIER]); 3188 ]);
3709 EngineTestCase.assertInstanceOf( 3189 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier,
3710 (obj) => obj is SimpleIdentifier, 3190 SimpleIdentifier, expression.thenExpression);
3711 SimpleIdentifier,
3712 expression.thenExpression);
3713 expect(expression.thenExpression.isSynthetic, isTrue); 3191 expect(expression.thenExpression.isSynthetic, isTrue);
3714 } 3192 }
3715 3193
3716 void test_equalityExpression_missing_LHS() { 3194 void test_equalityExpression_missing_LHS() {
3717 BinaryExpression expression = 3195 BinaryExpression expression = ParserTestCase.parseExpression(
3718 ParserTestCase.parseExpression("== y", [ParserErrorCode.MISSING_IDENTIFI ER]); 3196 "== y", [ParserErrorCode.MISSING_IDENTIFIER]);
3719 EngineTestCase.assertInstanceOf( 3197 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier,
3720 (obj) => obj is SimpleIdentifier, 3198 SimpleIdentifier, expression.leftOperand);
3721 SimpleIdentifier,
3722 expression.leftOperand);
3723 expect(expression.leftOperand.isSynthetic, isTrue); 3199 expect(expression.leftOperand.isSynthetic, isTrue);
3724 } 3200 }
3725 3201
3726 void test_equalityExpression_missing_LHS_RHS() { 3202 void test_equalityExpression_missing_LHS_RHS() {
3727 BinaryExpression expression = ParserTestCase.parseExpression( 3203 BinaryExpression expression = ParserTestCase.parseExpression("==", [
3728 "==", 3204 ParserErrorCode.MISSING_IDENTIFIER,
3729 [ParserErrorCode.MISSING_IDENTIFIER, ParserErrorCode.MISSING_IDENTIFIER] ); 3205 ParserErrorCode.MISSING_IDENTIFIER
3730 EngineTestCase.assertInstanceOf( 3206 ]);
3731 (obj) => obj is SimpleIdentifier, 3207 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier,
3732 SimpleIdentifier, 3208 SimpleIdentifier, expression.leftOperand);
3733 expression.leftOperand);
3734 expect(expression.leftOperand.isSynthetic, isTrue); 3209 expect(expression.leftOperand.isSynthetic, isTrue);
3735 EngineTestCase.assertInstanceOf( 3210 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier,
3736 (obj) => obj is SimpleIdentifier, 3211 SimpleIdentifier, expression.rightOperand);
3737 SimpleIdentifier,
3738 expression.rightOperand);
3739 expect(expression.rightOperand.isSynthetic, isTrue); 3212 expect(expression.rightOperand.isSynthetic, isTrue);
3740 } 3213 }
3741 3214
3742 void test_equalityExpression_missing_RHS() { 3215 void test_equalityExpression_missing_RHS() {
3743 BinaryExpression expression = 3216 BinaryExpression expression = ParserTestCase.parseExpression(
3744 ParserTestCase.parseExpression("x ==", [ParserErrorCode.MISSING_IDENTIFI ER]); 3217 "x ==", [ParserErrorCode.MISSING_IDENTIFIER]);
3745 EngineTestCase.assertInstanceOf( 3218 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier,
3746 (obj) => obj is SimpleIdentifier, 3219 SimpleIdentifier, expression.rightOperand);
3747 SimpleIdentifier,
3748 expression.rightOperand);
3749 expect(expression.rightOperand.isSynthetic, isTrue); 3220 expect(expression.rightOperand.isSynthetic, isTrue);
3750 } 3221 }
3751 3222
3752 void test_equalityExpression_missing_RHS_super() { 3223 void test_equalityExpression_missing_RHS_super() {
3753 BinaryExpression expression = ParserTestCase.parseExpression( 3224 BinaryExpression expression = ParserTestCase.parseExpression(
3754 "super ==", 3225 "super ==", [ParserErrorCode.MISSING_IDENTIFIER]);
3755 [ParserErrorCode.MISSING_IDENTIFIER]); 3226 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier,
3756 EngineTestCase.assertInstanceOf( 3227 SimpleIdentifier, expression.rightOperand);
3757 (obj) => obj is SimpleIdentifier,
3758 SimpleIdentifier,
3759 expression.rightOperand);
3760 expect(expression.rightOperand.isSynthetic, isTrue); 3228 expect(expression.rightOperand.isSynthetic, isTrue);
3761 } 3229 }
3762 3230
3763 void test_equalityExpression_precedence_relational_left() { 3231 void test_equalityExpression_precedence_relational_left() {
3764 BinaryExpression expression = ParserTestCase.parseExpression( 3232 BinaryExpression expression = ParserTestCase.parseExpression("is ==", [
3765 "is ==", 3233 ParserErrorCode.EXPECTED_TYPE_NAME,
3766 [ 3234 ParserErrorCode.MISSING_IDENTIFIER,
3767 ParserErrorCode.EXPECTED_TYPE_NAME, 3235 ParserErrorCode.MISSING_IDENTIFIER
3768 ParserErrorCode.MISSING_IDENTIFIER, 3236 ]);
3769 ParserErrorCode.MISSING_IDENTIFIER]);
3770 EngineTestCase.assertInstanceOf( 3237 EngineTestCase.assertInstanceOf(
3771 (obj) => obj is IsExpression, 3238 (obj) => obj is IsExpression, IsExpression, expression.leftOperand);
3772 IsExpression,
3773 expression.leftOperand);
3774 } 3239 }
3775 3240
3776 void test_equalityExpression_precedence_relational_right() { 3241 void test_equalityExpression_precedence_relational_right() {
3777 BinaryExpression expression = ParserTestCase.parseExpression( 3242 BinaryExpression expression = ParserTestCase.parseExpression("== is", [
3778 "== is", 3243 ParserErrorCode.EXPECTED_TYPE_NAME,
3779 [ 3244 ParserErrorCode.MISSING_IDENTIFIER,
3780 ParserErrorCode.EXPECTED_TYPE_NAME, 3245 ParserErrorCode.MISSING_IDENTIFIER
3781 ParserErrorCode.MISSING_IDENTIFIER, 3246 ]);
3782 ParserErrorCode.MISSING_IDENTIFIER]);
3783 EngineTestCase.assertInstanceOf( 3247 EngineTestCase.assertInstanceOf(
3784 (obj) => obj is IsExpression, 3248 (obj) => obj is IsExpression, IsExpression, expression.rightOperand);
3785 IsExpression,
3786 expression.rightOperand);
3787 } 3249 }
3788 3250
3789 void test_equalityExpression_super() { 3251 void test_equalityExpression_super() {
3790 BinaryExpression expression = ParserTestCase.parseExpression( 3252 BinaryExpression expression = ParserTestCase.parseExpression("super == ==",
3791 "super == ==",
3792 [ 3253 [
3793 ParserErrorCode.MISSING_IDENTIFIER, 3254 ParserErrorCode.MISSING_IDENTIFIER,
3794 ParserErrorCode.MISSING_IDENTIFIER, 3255 ParserErrorCode.MISSING_IDENTIFIER,
3795 ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND]); 3256 ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND
3796 EngineTestCase.assertInstanceOf( 3257 ]);
3797 (obj) => obj is BinaryExpression, 3258 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression,
3798 BinaryExpression, 3259 BinaryExpression, expression.leftOperand);
3799 expression.leftOperand);
3800 } 3260 }
3801 3261
3802 void test_expressionList_multiple_end() { 3262 void test_expressionList_multiple_end() {
3803 List<Expression> result = ParserTestCase.parse4( 3263 List<Expression> result = ParserTestCase.parse4("parseExpressionList",
3804 "parseExpressionList", 3264 ", 2, 3, 4", [ParserErrorCode.MISSING_IDENTIFIER]);
3805 ", 2, 3, 4",
3806 [ParserErrorCode.MISSING_IDENTIFIER]);
3807 expect(result, hasLength(4)); 3265 expect(result, hasLength(4));
3808 Expression syntheticExpression = result[0]; 3266 Expression syntheticExpression = result[0];
3809 EngineTestCase.assertInstanceOf( 3267 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier,
3810 (obj) => obj is SimpleIdentifier, 3268 SimpleIdentifier, syntheticExpression);
3811 SimpleIdentifier,
3812 syntheticExpression);
3813 expect(syntheticExpression.isSynthetic, isTrue); 3269 expect(syntheticExpression.isSynthetic, isTrue);
3814 } 3270 }
3815 3271
3816 void test_expressionList_multiple_middle() { 3272 void test_expressionList_multiple_middle() {
3817 List<Expression> result = ParserTestCase.parse4( 3273 List<Expression> result = ParserTestCase.parse4("parseExpressionList",
3818 "parseExpressionList", 3274 "1, 2, , 4", [ParserErrorCode.MISSING_IDENTIFIER]);
3819 "1, 2, , 4",
3820 [ParserErrorCode.MISSING_IDENTIFIER]);
3821 expect(result, hasLength(4)); 3275 expect(result, hasLength(4));
3822 Expression syntheticExpression = result[2]; 3276 Expression syntheticExpression = result[2];
3823 EngineTestCase.assertInstanceOf( 3277 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier,
3824 (obj) => obj is SimpleIdentifier, 3278 SimpleIdentifier, syntheticExpression);
3825 SimpleIdentifier,
3826 syntheticExpression);
3827 expect(syntheticExpression.isSynthetic, isTrue); 3279 expect(syntheticExpression.isSynthetic, isTrue);
3828 } 3280 }
3829 3281
3830 void test_expressionList_multiple_start() { 3282 void test_expressionList_multiple_start() {
3831 List<Expression> result = ParserTestCase.parse4( 3283 List<Expression> result = ParserTestCase.parse4("parseExpressionList",
3832 "parseExpressionList", 3284 "1, 2, 3,", [ParserErrorCode.MISSING_IDENTIFIER]);
3833 "1, 2, 3,",
3834 [ParserErrorCode.MISSING_IDENTIFIER]);
3835 expect(result, hasLength(4)); 3285 expect(result, hasLength(4));
3836 Expression syntheticExpression = result[3]; 3286 Expression syntheticExpression = result[3];
3837 EngineTestCase.assertInstanceOf( 3287 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier,
3838 (obj) => obj is SimpleIdentifier, 3288 SimpleIdentifier, syntheticExpression);
3839 SimpleIdentifier,
3840 syntheticExpression);
3841 expect(syntheticExpression.isSynthetic, isTrue); 3289 expect(syntheticExpression.isSynthetic, isTrue);
3842 } 3290 }
3843 3291
3844 void test_functionExpression_in_ConstructorFieldInitializer() { 3292 void test_functionExpression_in_ConstructorFieldInitializer() {
3845 CompilationUnit unit = ParserTestCase.parseCompilationUnit( 3293 CompilationUnit unit = ParserTestCase.parseCompilationUnit(
3846 "class A { A() : a = (){}; var v; }", 3294 "class A { A() : a = (){}; var v; }", [
3847 [ParserErrorCode.MISSING_IDENTIFIER, ParserErrorCode.UNEXPECTED_TOKEN]); 3295 ParserErrorCode.MISSING_IDENTIFIER,
3296 ParserErrorCode.UNEXPECTED_TOKEN
3297 ]);
3848 // Make sure we recovered and parsed "var v" correctly 3298 // Make sure we recovered and parsed "var v" correctly
3849 ClassDeclaration declaration = unit.declarations[0] as ClassDeclaration; 3299 ClassDeclaration declaration = unit.declarations[0] as ClassDeclaration;
3850 NodeList<ClassMember> members = declaration.members; 3300 NodeList<ClassMember> members = declaration.members;
3851 ClassMember fieldDecl = members[1]; 3301 ClassMember fieldDecl = members[1];
3852 EngineTestCase.assertInstanceOf( 3302 EngineTestCase.assertInstanceOf(
3853 (obj) => obj is FieldDeclaration, 3303 (obj) => obj is FieldDeclaration, FieldDeclaration, fieldDecl);
3854 FieldDeclaration,
3855 fieldDecl);
3856 NodeList<VariableDeclaration> vars = 3304 NodeList<VariableDeclaration> vars =
3857 (fieldDecl as FieldDeclaration).fields.variables; 3305 (fieldDecl as FieldDeclaration).fields.variables;
3858 expect(vars, hasLength(1)); 3306 expect(vars, hasLength(1));
3859 expect(vars[0].name.name, "v"); 3307 expect(vars[0].name.name, "v");
3860 } 3308 }
3861 3309
3862 void test_functionExpression_named() { 3310 void test_functionExpression_named() {
3863 ParserTestCase.parseExpression( 3311 ParserTestCase.parseExpression(
3864 "m(f() => 0);", 3312 "m(f() => 0);", [ParserErrorCode.EXPECTED_TOKEN]);
3865 [ParserErrorCode.EXPECTED_TOKEN]);
3866 } 3313 }
3867 3314
3868 void test_incomplete_conditionalExpression() { 3315 void test_incomplete_conditionalExpression() {
3869 ParserTestCase.parseExpression( 3316 ParserTestCase.parseExpression("x ? 0", [
3870 "x ? 0", 3317 ParserErrorCode.EXPECTED_TOKEN,
3871 [ParserErrorCode.EXPECTED_TOKEN, ParserErrorCode.MISSING_IDENTIFIER]); 3318 ParserErrorCode.MISSING_IDENTIFIER
3319 ]);
3872 } 3320 }
3873 3321
3874 void test_incomplete_constructorInitializers_empty() { 3322 void test_incomplete_constructorInitializers_empty() {
3875 ParserTestCase.parse3( 3323 ParserTestCase.parse3("parseClassMember", ["C"], "C() : {}", [
3876 "parseClassMember", 3324 ParserErrorCode.MISSING_INITIALIZER
3877 ["C"], 3325 ]);
3878 "C() : {}",
3879 [ParserErrorCode.MISSING_INITIALIZER]);
3880 } 3326 }
3881 3327
3882 void test_incomplete_constructorInitializers_missingEquals() { 3328 void test_incomplete_constructorInitializers_missingEquals() {
3883 ClassMember member = ParserTestCase.parse3( 3329 ClassMember member = ParserTestCase.parse3("parseClassMember", [
3884 "parseClassMember", 3330 "C"
3885 ["C"], 3331 ], "C() : x(3) {}", [ParserErrorCode.MISSING_ASSIGNMENT_IN_INITIALIZER]);
3886 "C() : x(3) {}",
3887 [ParserErrorCode.MISSING_ASSIGNMENT_IN_INITIALIZER]);
3888 expect(member, new isInstanceOf<ConstructorDeclaration>()); 3332 expect(member, new isInstanceOf<ConstructorDeclaration>());
3889 NodeList<ConstructorInitializer> initializers = 3333 NodeList<ConstructorInitializer> initializers =
3890 (member as ConstructorDeclaration).initializers; 3334 (member as ConstructorDeclaration).initializers;
3891 expect(initializers, hasLength(1)); 3335 expect(initializers, hasLength(1));
3892 ConstructorInitializer initializer = initializers[0]; 3336 ConstructorInitializer initializer = initializers[0];
3893 expect(initializer, new isInstanceOf<ConstructorFieldInitializer>()); 3337 expect(initializer, new isInstanceOf<ConstructorFieldInitializer>());
3894 Expression expression = 3338 Expression expression =
3895 (initializer as ConstructorFieldInitializer).expression; 3339 (initializer as ConstructorFieldInitializer).expression;
3896 expect(expression, isNotNull); 3340 expect(expression, isNotNull);
3897 expect(expression, new isInstanceOf<ParenthesizedExpression>()); 3341 expect(expression, new isInstanceOf<ParenthesizedExpression>());
3898 } 3342 }
3899 3343
3900 void test_incomplete_constructorInitializers_variable() { 3344 void test_incomplete_constructorInitializers_variable() {
3901 ParserTestCase.parse3( 3345 ParserTestCase.parse3("parseClassMember", ["C"], "C() : x {}", [
3902 "parseClassMember", 3346 ParserErrorCode.MISSING_ASSIGNMENT_IN_INITIALIZER
3903 ["C"], 3347 ]);
3904 "C() : x {}",
3905 [ParserErrorCode.MISSING_ASSIGNMENT_IN_INITIALIZER]);
3906 } 3348 }
3907 3349
3908 void test_incomplete_topLevelFunction() { 3350 void test_incomplete_topLevelFunction() {
3909 ParserTestCase.parseCompilationUnit( 3351 ParserTestCase.parseCompilationUnit(
3910 "foo();", 3352 "foo();", [ParserErrorCode.MISSING_FUNCTION_BODY]);
3911 [ParserErrorCode.MISSING_FUNCTION_BODY]);
3912 } 3353 }
3913 3354
3914 void test_incomplete_topLevelVariable() { 3355 void test_incomplete_topLevelVariable() {
3915 CompilationUnit unit = ParserTestCase.parseCompilationUnit( 3356 CompilationUnit unit = ParserTestCase.parseCompilationUnit(
3916 "String", 3357 "String", [ParserErrorCode.EXPECTED_EXECUTABLE]);
3917 [ParserErrorCode.EXPECTED_EXECUTABLE]);
3918 NodeList<CompilationUnitMember> declarations = unit.declarations; 3358 NodeList<CompilationUnitMember> declarations = unit.declarations;
3919 expect(declarations, hasLength(1)); 3359 expect(declarations, hasLength(1));
3920 CompilationUnitMember member = declarations[0]; 3360 CompilationUnitMember member = declarations[0];
3921 EngineTestCase.assertInstanceOf( 3361 EngineTestCase.assertInstanceOf((obj) => obj is TopLevelVariableDeclaration,
3922 (obj) => obj is TopLevelVariableDeclaration, 3362 TopLevelVariableDeclaration, member);
3923 TopLevelVariableDeclaration,
3924 member);
3925 NodeList<VariableDeclaration> variables = 3363 NodeList<VariableDeclaration> variables =
3926 (member as TopLevelVariableDeclaration).variables.variables; 3364 (member as TopLevelVariableDeclaration).variables.variables;
3927 expect(variables, hasLength(1)); 3365 expect(variables, hasLength(1));
3928 SimpleIdentifier name = variables[0].name; 3366 SimpleIdentifier name = variables[0].name;
3929 expect(name.isSynthetic, isTrue); 3367 expect(name.isSynthetic, isTrue);
3930 } 3368 }
3931 3369
3932 void test_incomplete_topLevelVariable_const() { 3370 void test_incomplete_topLevelVariable_const() {
3933 CompilationUnit unit = ParserTestCase.parseCompilationUnit( 3371 CompilationUnit unit = ParserTestCase.parseCompilationUnit("const ", [
3934 "const ", 3372 ParserErrorCode.MISSING_IDENTIFIER,
3935 [ParserErrorCode.MISSING_IDENTIFIER, ParserErrorCode.EXPECTED_TOKEN]); 3373 ParserErrorCode.EXPECTED_TOKEN
3374 ]);
3936 NodeList<CompilationUnitMember> declarations = unit.declarations; 3375 NodeList<CompilationUnitMember> declarations = unit.declarations;
3937 expect(declarations, hasLength(1)); 3376 expect(declarations, hasLength(1));
3938 CompilationUnitMember member = declarations[0]; 3377 CompilationUnitMember member = declarations[0];
3939 EngineTestCase.assertInstanceOf( 3378 EngineTestCase.assertInstanceOf((obj) => obj is TopLevelVariableDeclaration,
3940 (obj) => obj is TopLevelVariableDeclaration, 3379 TopLevelVariableDeclaration, member);
3941 TopLevelVariableDeclaration,
3942 member);
3943 NodeList<VariableDeclaration> variables = 3380 NodeList<VariableDeclaration> variables =
3944 (member as TopLevelVariableDeclaration).variables.variables; 3381 (member as TopLevelVariableDeclaration).variables.variables;
3945 expect(variables, hasLength(1)); 3382 expect(variables, hasLength(1));
3946 SimpleIdentifier name = variables[0].name; 3383 SimpleIdentifier name = variables[0].name;
3947 expect(name.isSynthetic, isTrue); 3384 expect(name.isSynthetic, isTrue);
3948 } 3385 }
3949 3386
3950 void test_incomplete_topLevelVariable_final() { 3387 void test_incomplete_topLevelVariable_final() {
3951 CompilationUnit unit = ParserTestCase.parseCompilationUnit( 3388 CompilationUnit unit = ParserTestCase.parseCompilationUnit("final ", [
3952 "final ", 3389 ParserErrorCode.MISSING_IDENTIFIER,
3953 [ParserErrorCode.MISSING_IDENTIFIER, ParserErrorCode.EXPECTED_TOKEN]); 3390 ParserErrorCode.EXPECTED_TOKEN
3391 ]);
3954 NodeList<CompilationUnitMember> declarations = unit.declarations; 3392 NodeList<CompilationUnitMember> declarations = unit.declarations;
3955 expect(declarations, hasLength(1)); 3393 expect(declarations, hasLength(1));
3956 CompilationUnitMember member = declarations[0]; 3394 CompilationUnitMember member = declarations[0];
3957 EngineTestCase.assertInstanceOf( 3395 EngineTestCase.assertInstanceOf((obj) => obj is TopLevelVariableDeclaration,
3958 (obj) => obj is TopLevelVariableDeclaration, 3396 TopLevelVariableDeclaration, member);
3959 TopLevelVariableDeclaration,
3960 member);
3961 NodeList<VariableDeclaration> variables = 3397 NodeList<VariableDeclaration> variables =
3962 (member as TopLevelVariableDeclaration).variables.variables; 3398 (member as TopLevelVariableDeclaration).variables.variables;
3963 expect(variables, hasLength(1)); 3399 expect(variables, hasLength(1));
3964 SimpleIdentifier name = variables[0].name; 3400 SimpleIdentifier name = variables[0].name;
3965 expect(name.isSynthetic, isTrue); 3401 expect(name.isSynthetic, isTrue);
3966 } 3402 }
3967 3403
3968 void test_incomplete_topLevelVariable_var() { 3404 void test_incomplete_topLevelVariable_var() {
3969 CompilationUnit unit = ParserTestCase.parseCompilationUnit( 3405 CompilationUnit unit = ParserTestCase.parseCompilationUnit("var ", [
3970 "var ", 3406 ParserErrorCode.MISSING_IDENTIFIER,
3971 [ParserErrorCode.MISSING_IDENTIFIER, ParserErrorCode.EXPECTED_TOKEN]); 3407 ParserErrorCode.EXPECTED_TOKEN
3408 ]);
3972 NodeList<CompilationUnitMember> declarations = unit.declarations; 3409 NodeList<CompilationUnitMember> declarations = unit.declarations;
3973 expect(declarations, hasLength(1)); 3410 expect(declarations, hasLength(1));
3974 CompilationUnitMember member = declarations[0]; 3411 CompilationUnitMember member = declarations[0];
3975 EngineTestCase.assertInstanceOf( 3412 EngineTestCase.assertInstanceOf((obj) => obj is TopLevelVariableDeclaration,
3976 (obj) => obj is TopLevelVariableDeclaration, 3413 TopLevelVariableDeclaration, member);
3977 TopLevelVariableDeclaration,
3978 member);
3979 NodeList<VariableDeclaration> variables = 3414 NodeList<VariableDeclaration> variables =
3980 (member as TopLevelVariableDeclaration).variables.variables; 3415 (member as TopLevelVariableDeclaration).variables.variables;
3981 expect(variables, hasLength(1)); 3416 expect(variables, hasLength(1));
3982 SimpleIdentifier name = variables[0].name; 3417 SimpleIdentifier name = variables[0].name;
3983 expect(name.isSynthetic, isTrue); 3418 expect(name.isSynthetic, isTrue);
3984 } 3419 }
3985 3420
3986 void test_incompleteField_const() { 3421 void test_incompleteField_const() {
3987 CompilationUnit unit = ParserTestCase.parseCompilationUnit(r''' 3422 CompilationUnit unit = ParserTestCase.parseCompilationUnit(r'''
3988 class C { 3423 class C {
3989 const 3424 const
3990 }''', [ParserErrorCode.MISSING_IDENTIFIER, ParserErrorCode.EXPECTED_TOKEN]); 3425 }''', [ParserErrorCode.MISSING_IDENTIFIER, ParserErrorCode.EXPECTED_TOKEN]);
3991 NodeList<CompilationUnitMember> declarations = unit.declarations; 3426 NodeList<CompilationUnitMember> declarations = unit.declarations;
3992 expect(declarations, hasLength(1)); 3427 expect(declarations, hasLength(1));
3993 CompilationUnitMember unitMember = declarations[0]; 3428 CompilationUnitMember unitMember = declarations[0];
3994 EngineTestCase.assertInstanceOf( 3429 EngineTestCase.assertInstanceOf(
3995 (obj) => obj is ClassDeclaration, 3430 (obj) => obj is ClassDeclaration, ClassDeclaration, unitMember);
3996 ClassDeclaration,
3997 unitMember);
3998 NodeList<ClassMember> members = (unitMember as ClassDeclaration).members; 3431 NodeList<ClassMember> members = (unitMember as ClassDeclaration).members;
3999 expect(members, hasLength(1)); 3432 expect(members, hasLength(1));
4000 ClassMember classMember = members[0]; 3433 ClassMember classMember = members[0];
4001 EngineTestCase.assertInstanceOf( 3434 EngineTestCase.assertInstanceOf(
4002 (obj) => obj is FieldDeclaration, 3435 (obj) => obj is FieldDeclaration, FieldDeclaration, classMember);
4003 FieldDeclaration,
4004 classMember);
4005 VariableDeclarationList fieldList = 3436 VariableDeclarationList fieldList =
4006 (classMember as FieldDeclaration).fields; 3437 (classMember as FieldDeclaration).fields;
4007 expect((fieldList.keyword as KeywordToken).keyword, Keyword.CONST); 3438 expect((fieldList.keyword as KeywordToken).keyword, Keyword.CONST);
4008 NodeList<VariableDeclaration> fields = fieldList.variables; 3439 NodeList<VariableDeclaration> fields = fieldList.variables;
4009 expect(fields, hasLength(1)); 3440 expect(fields, hasLength(1));
4010 VariableDeclaration field = fields[0]; 3441 VariableDeclaration field = fields[0];
4011 expect(field.name.isSynthetic, isTrue); 3442 expect(field.name.isSynthetic, isTrue);
4012 } 3443 }
4013 3444
4014 void test_incompleteField_final() { 3445 void test_incompleteField_final() {
4015 CompilationUnit unit = ParserTestCase.parseCompilationUnit(r''' 3446 CompilationUnit unit = ParserTestCase.parseCompilationUnit(r'''
4016 class C { 3447 class C {
4017 final 3448 final
4018 }''', [ParserErrorCode.MISSING_IDENTIFIER, ParserErrorCode.EXPECTED_TOKEN]); 3449 }''', [ParserErrorCode.MISSING_IDENTIFIER, ParserErrorCode.EXPECTED_TOKEN]);
4019 NodeList<CompilationUnitMember> declarations = unit.declarations; 3450 NodeList<CompilationUnitMember> declarations = unit.declarations;
4020 expect(declarations, hasLength(1)); 3451 expect(declarations, hasLength(1));
4021 CompilationUnitMember unitMember = declarations[0]; 3452 CompilationUnitMember unitMember = declarations[0];
4022 EngineTestCase.assertInstanceOf( 3453 EngineTestCase.assertInstanceOf(
4023 (obj) => obj is ClassDeclaration, 3454 (obj) => obj is ClassDeclaration, ClassDeclaration, unitMember);
4024 ClassDeclaration,
4025 unitMember);
4026 NodeList<ClassMember> members = (unitMember as ClassDeclaration).members; 3455 NodeList<ClassMember> members = (unitMember as ClassDeclaration).members;
4027 expect(members, hasLength(1)); 3456 expect(members, hasLength(1));
4028 ClassMember classMember = members[0]; 3457 ClassMember classMember = members[0];
4029 EngineTestCase.assertInstanceOf( 3458 EngineTestCase.assertInstanceOf(
4030 (obj) => obj is FieldDeclaration, 3459 (obj) => obj is FieldDeclaration, FieldDeclaration, classMember);
4031 FieldDeclaration,
4032 classMember);
4033 VariableDeclarationList fieldList = 3460 VariableDeclarationList fieldList =
4034 (classMember as FieldDeclaration).fields; 3461 (classMember as FieldDeclaration).fields;
4035 expect((fieldList.keyword as KeywordToken).keyword, Keyword.FINAL); 3462 expect((fieldList.keyword as KeywordToken).keyword, Keyword.FINAL);
4036 NodeList<VariableDeclaration> fields = fieldList.variables; 3463 NodeList<VariableDeclaration> fields = fieldList.variables;
4037 expect(fields, hasLength(1)); 3464 expect(fields, hasLength(1));
4038 VariableDeclaration field = fields[0]; 3465 VariableDeclaration field = fields[0];
4039 expect(field.name.isSynthetic, isTrue); 3466 expect(field.name.isSynthetic, isTrue);
4040 } 3467 }
4041 3468
4042 void test_incompleteField_var() { 3469 void test_incompleteField_var() {
4043 CompilationUnit unit = ParserTestCase.parseCompilationUnit(r''' 3470 CompilationUnit unit = ParserTestCase.parseCompilationUnit(r'''
4044 class C { 3471 class C {
4045 var 3472 var
4046 }''', [ParserErrorCode.MISSING_IDENTIFIER, ParserErrorCode.EXPECTED_TOKEN]); 3473 }''', [ParserErrorCode.MISSING_IDENTIFIER, ParserErrorCode.EXPECTED_TOKEN]);
4047 NodeList<CompilationUnitMember> declarations = unit.declarations; 3474 NodeList<CompilationUnitMember> declarations = unit.declarations;
4048 expect(declarations, hasLength(1)); 3475 expect(declarations, hasLength(1));
4049 CompilationUnitMember unitMember = declarations[0]; 3476 CompilationUnitMember unitMember = declarations[0];
4050 EngineTestCase.assertInstanceOf( 3477 EngineTestCase.assertInstanceOf(
4051 (obj) => obj is ClassDeclaration, 3478 (obj) => obj is ClassDeclaration, ClassDeclaration, unitMember);
4052 ClassDeclaration,
4053 unitMember);
4054 NodeList<ClassMember> members = (unitMember as ClassDeclaration).members; 3479 NodeList<ClassMember> members = (unitMember as ClassDeclaration).members;
4055 expect(members, hasLength(1)); 3480 expect(members, hasLength(1));
4056 ClassMember classMember = members[0]; 3481 ClassMember classMember = members[0];
4057 EngineTestCase.assertInstanceOf( 3482 EngineTestCase.assertInstanceOf(
4058 (obj) => obj is FieldDeclaration, 3483 (obj) => obj is FieldDeclaration, FieldDeclaration, classMember);
4059 FieldDeclaration,
4060 classMember);
4061 VariableDeclarationList fieldList = 3484 VariableDeclarationList fieldList =
4062 (classMember as FieldDeclaration).fields; 3485 (classMember as FieldDeclaration).fields;
4063 expect((fieldList.keyword as KeywordToken).keyword, Keyword.VAR); 3486 expect((fieldList.keyword as KeywordToken).keyword, Keyword.VAR);
4064 NodeList<VariableDeclaration> fields = fieldList.variables; 3487 NodeList<VariableDeclaration> fields = fieldList.variables;
4065 expect(fields, hasLength(1)); 3488 expect(fields, hasLength(1));
4066 VariableDeclaration field = fields[0]; 3489 VariableDeclaration field = fields[0];
4067 expect(field.name.isSynthetic, isTrue); 3490 expect(field.name.isSynthetic, isTrue);
4068 } 3491 }
4069 3492
4070 void test_invalidFunctionBodyModifier() { 3493 void test_invalidFunctionBodyModifier() {
4071 ParserTestCase.parseCompilationUnit( 3494 ParserTestCase.parseCompilationUnit(
4072 "f() sync {}", 3495 "f() sync {}", [ParserErrorCode.MISSING_STAR_AFTER_SYNC]);
4073 [ParserErrorCode.MISSING_STAR_AFTER_SYNC]);
4074 } 3496 }
4075 3497
4076 void test_isExpression_noType() { 3498 void test_isExpression_noType() {
4077 CompilationUnit unit = ParserTestCase.parseCompilationUnit( 3499 CompilationUnit unit = ParserTestCase.parseCompilationUnit(
4078 "class Bar<T extends Foo> {m(x){if (x is ) return;if (x is !)}}", 3500 "class Bar<T extends Foo> {m(x){if (x is ) return;if (x is !)}}", [
4079 [ 3501 ParserErrorCode.EXPECTED_TYPE_NAME,
4080 ParserErrorCode.EXPECTED_TYPE_NAME, 3502 ParserErrorCode.EXPECTED_TYPE_NAME,
4081 ParserErrorCode.EXPECTED_TYPE_NAME, 3503 ParserErrorCode.MISSING_STATEMENT
4082 ParserErrorCode.MISSING_STATEMENT]); 3504 ]);
4083 ClassDeclaration declaration = unit.declarations[0] as ClassDeclaration; 3505 ClassDeclaration declaration = unit.declarations[0] as ClassDeclaration;
4084 MethodDeclaration method = declaration.members[0] as MethodDeclaration; 3506 MethodDeclaration method = declaration.members[0] as MethodDeclaration;
4085 BlockFunctionBody body = method.body as BlockFunctionBody; 3507 BlockFunctionBody body = method.body as BlockFunctionBody;
4086 IfStatement ifStatement = body.block.statements[1] as IfStatement; 3508 IfStatement ifStatement = body.block.statements[1] as IfStatement;
4087 IsExpression expression = ifStatement.condition as IsExpression; 3509 IsExpression expression = ifStatement.condition as IsExpression;
4088 expect(expression.expression, isNotNull); 3510 expect(expression.expression, isNotNull);
4089 expect(expression.isOperator, isNotNull); 3511 expect(expression.isOperator, isNotNull);
4090 expect(expression.notOperator, isNotNull); 3512 expect(expression.notOperator, isNotNull);
4091 TypeName type = expression.type; 3513 TypeName type = expression.type;
4092 expect(type, isNotNull); 3514 expect(type, isNotNull);
4093 expect(type.name.isSynthetic, isTrue); 3515 expect(type.name.isSynthetic, isTrue);
4094 EngineTestCase.assertInstanceOf( 3516 EngineTestCase.assertInstanceOf((obj) => obj is EmptyStatement,
4095 (obj) => obj is EmptyStatement, 3517 EmptyStatement, ifStatement.thenStatement);
4096 EmptyStatement,
4097 ifStatement.thenStatement);
4098 } 3518 }
4099 3519
4100 void test_keywordInPlaceOfIdentifier() { 3520 void test_keywordInPlaceOfIdentifier() {
4101 // TODO(brianwilkerson) We could do better with this. 3521 // TODO(brianwilkerson) We could do better with this.
4102 ParserTestCase.parseCompilationUnit( 3522 ParserTestCase.parseCompilationUnit("do() {}", [
4103 "do() {}", 3523 ParserErrorCode.EXPECTED_EXECUTABLE,
4104 [ParserErrorCode.EXPECTED_EXECUTABLE, ParserErrorCode.UNEXPECTED_TOKEN]) ; 3524 ParserErrorCode.UNEXPECTED_TOKEN
3525 ]);
4105 } 3526 }
4106 3527
4107 void test_logicalAndExpression_missing_LHS() { 3528 void test_logicalAndExpression_missing_LHS() {
4108 BinaryExpression expression = 3529 BinaryExpression expression = ParserTestCase.parseExpression(
4109 ParserTestCase.parseExpression("&& y", [ParserErrorCode.MISSING_IDENTIFI ER]); 3530 "&& y", [ParserErrorCode.MISSING_IDENTIFIER]);
4110 EngineTestCase.assertInstanceOf( 3531 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier,
4111 (obj) => obj is SimpleIdentifier, 3532 SimpleIdentifier, expression.leftOperand);
4112 SimpleIdentifier,
4113 expression.leftOperand);
4114 expect(expression.leftOperand.isSynthetic, isTrue); 3533 expect(expression.leftOperand.isSynthetic, isTrue);
4115 } 3534 }
4116 3535
4117 void test_logicalAndExpression_missing_LHS_RHS() { 3536 void test_logicalAndExpression_missing_LHS_RHS() {
4118 BinaryExpression expression = ParserTestCase.parseExpression( 3537 BinaryExpression expression = ParserTestCase.parseExpression("&&", [
4119 "&&", 3538 ParserErrorCode.MISSING_IDENTIFIER,
4120 [ParserErrorCode.MISSING_IDENTIFIER, ParserErrorCode.MISSING_IDENTIFIER] ); 3539 ParserErrorCode.MISSING_IDENTIFIER
4121 EngineTestCase.assertInstanceOf( 3540 ]);
4122 (obj) => obj is SimpleIdentifier, 3541 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier,
4123 SimpleIdentifier, 3542 SimpleIdentifier, expression.leftOperand);
4124 expression.leftOperand);
4125 expect(expression.leftOperand.isSynthetic, isTrue); 3543 expect(expression.leftOperand.isSynthetic, isTrue);
4126 EngineTestCase.assertInstanceOf( 3544 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier,
4127 (obj) => obj is SimpleIdentifier, 3545 SimpleIdentifier, expression.rightOperand);
4128 SimpleIdentifier,
4129 expression.rightOperand);
4130 expect(expression.rightOperand.isSynthetic, isTrue); 3546 expect(expression.rightOperand.isSynthetic, isTrue);
4131 } 3547 }
4132 3548
4133 void test_logicalAndExpression_missing_RHS() { 3549 void test_logicalAndExpression_missing_RHS() {
4134 BinaryExpression expression = 3550 BinaryExpression expression = ParserTestCase.parseExpression(
4135 ParserTestCase.parseExpression("x &&", [ParserErrorCode.MISSING_IDENTIFI ER]); 3551 "x &&", [ParserErrorCode.MISSING_IDENTIFIER]);
4136 EngineTestCase.assertInstanceOf( 3552 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier,
4137 (obj) => obj is SimpleIdentifier, 3553 SimpleIdentifier, expression.rightOperand);
4138 SimpleIdentifier,
4139 expression.rightOperand);
4140 expect(expression.rightOperand.isSynthetic, isTrue); 3554 expect(expression.rightOperand.isSynthetic, isTrue);
4141 } 3555 }
4142 3556
4143 void test_logicalAndExpression_precedence_bitwiseOr_left() { 3557 void test_logicalAndExpression_precedence_bitwiseOr_left() {
4144 BinaryExpression expression = ParserTestCase.parseExpression( 3558 BinaryExpression expression = ParserTestCase.parseExpression("| &&", [
4145 "| &&", 3559 ParserErrorCode.MISSING_IDENTIFIER,
4146 [ 3560 ParserErrorCode.MISSING_IDENTIFIER,
4147 ParserErrorCode.MISSING_IDENTIFIER, 3561 ParserErrorCode.MISSING_IDENTIFIER
4148 ParserErrorCode.MISSING_IDENTIFIER, 3562 ]);
4149 ParserErrorCode.MISSING_IDENTIFIER]); 3563 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression,
4150 EngineTestCase.assertInstanceOf( 3564 BinaryExpression, expression.leftOperand);
4151 (obj) => obj is BinaryExpression,
4152 BinaryExpression,
4153 expression.leftOperand);
4154 } 3565 }
4155 3566
4156 void test_logicalAndExpression_precedence_bitwiseOr_right() { 3567 void test_logicalAndExpression_precedence_bitwiseOr_right() {
4157 BinaryExpression expression = ParserTestCase.parseExpression( 3568 BinaryExpression expression = ParserTestCase.parseExpression("&& |", [
4158 "&& |", 3569 ParserErrorCode.MISSING_IDENTIFIER,
4159 [ 3570 ParserErrorCode.MISSING_IDENTIFIER,
4160 ParserErrorCode.MISSING_IDENTIFIER, 3571 ParserErrorCode.MISSING_IDENTIFIER
4161 ParserErrorCode.MISSING_IDENTIFIER, 3572 ]);
4162 ParserErrorCode.MISSING_IDENTIFIER]); 3573 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression,
4163 EngineTestCase.assertInstanceOf( 3574 BinaryExpression, expression.rightOperand);
4164 (obj) => obj is BinaryExpression,
4165 BinaryExpression,
4166 expression.rightOperand);
4167 } 3575 }
4168 3576
4169 void test_logicalOrExpression_missing_LHS() { 3577 void test_logicalOrExpression_missing_LHS() {
4170 BinaryExpression expression = 3578 BinaryExpression expression = ParserTestCase.parseExpression(
4171 ParserTestCase.parseExpression("|| y", [ParserErrorCode.MISSING_IDENTIFI ER]); 3579 "|| y", [ParserErrorCode.MISSING_IDENTIFIER]);
4172 EngineTestCase.assertInstanceOf( 3580 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier,
4173 (obj) => obj is SimpleIdentifier, 3581 SimpleIdentifier, expression.leftOperand);
4174 SimpleIdentifier,
4175 expression.leftOperand);
4176 expect(expression.leftOperand.isSynthetic, isTrue); 3582 expect(expression.leftOperand.isSynthetic, isTrue);
4177 } 3583 }
4178 3584
4179 void test_logicalOrExpression_missing_LHS_RHS() { 3585 void test_logicalOrExpression_missing_LHS_RHS() {
4180 BinaryExpression expression = ParserTestCase.parseExpression( 3586 BinaryExpression expression = ParserTestCase.parseExpression("||", [
4181 "||", 3587 ParserErrorCode.MISSING_IDENTIFIER,
4182 [ParserErrorCode.MISSING_IDENTIFIER, ParserErrorCode.MISSING_IDENTIFIER] ); 3588 ParserErrorCode.MISSING_IDENTIFIER
4183 EngineTestCase.assertInstanceOf( 3589 ]);
4184 (obj) => obj is SimpleIdentifier, 3590 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier,
4185 SimpleIdentifier, 3591 SimpleIdentifier, expression.leftOperand);
4186 expression.leftOperand);
4187 expect(expression.leftOperand.isSynthetic, isTrue); 3592 expect(expression.leftOperand.isSynthetic, isTrue);
4188 EngineTestCase.assertInstanceOf( 3593 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier,
4189 (obj) => obj is SimpleIdentifier, 3594 SimpleIdentifier, expression.rightOperand);
4190 SimpleIdentifier,
4191 expression.rightOperand);
4192 expect(expression.rightOperand.isSynthetic, isTrue); 3595 expect(expression.rightOperand.isSynthetic, isTrue);
4193 } 3596 }
4194 3597
4195 void test_logicalOrExpression_missing_RHS() { 3598 void test_logicalOrExpression_missing_RHS() {
4196 BinaryExpression expression = 3599 BinaryExpression expression = ParserTestCase.parseExpression(
4197 ParserTestCase.parseExpression("x ||", [ParserErrorCode.MISSING_IDENTIFI ER]); 3600 "x ||", [ParserErrorCode.MISSING_IDENTIFIER]);
4198 EngineTestCase.assertInstanceOf( 3601 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier,
4199 (obj) => obj is SimpleIdentifier, 3602 SimpleIdentifier, expression.rightOperand);
4200 SimpleIdentifier,
4201 expression.rightOperand);
4202 expect(expression.rightOperand.isSynthetic, isTrue); 3603 expect(expression.rightOperand.isSynthetic, isTrue);
4203 } 3604 }
4204 3605
4205 void test_logicalOrExpression_precedence_logicalAnd_left() { 3606 void test_logicalOrExpression_precedence_logicalAnd_left() {
4206 BinaryExpression expression = ParserTestCase.parseExpression( 3607 BinaryExpression expression = ParserTestCase.parseExpression("&& ||", [
4207 "&& ||", 3608 ParserErrorCode.MISSING_IDENTIFIER,
4208 [ 3609 ParserErrorCode.MISSING_IDENTIFIER,
4209 ParserErrorCode.MISSING_IDENTIFIER, 3610 ParserErrorCode.MISSING_IDENTIFIER
4210 ParserErrorCode.MISSING_IDENTIFIER, 3611 ]);
4211 ParserErrorCode.MISSING_IDENTIFIER]); 3612 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression,
4212 EngineTestCase.assertInstanceOf( 3613 BinaryExpression, expression.leftOperand);
4213 (obj) => obj is BinaryExpression,
4214 BinaryExpression,
4215 expression.leftOperand);
4216 } 3614 }
4217 3615
4218 void test_logicalOrExpression_precedence_logicalAnd_right() { 3616 void test_logicalOrExpression_precedence_logicalAnd_right() {
4219 BinaryExpression expression = ParserTestCase.parseExpression( 3617 BinaryExpression expression = ParserTestCase.parseExpression("|| &&", [
4220 "|| &&", 3618 ParserErrorCode.MISSING_IDENTIFIER,
4221 [ 3619 ParserErrorCode.MISSING_IDENTIFIER,
4222 ParserErrorCode.MISSING_IDENTIFIER, 3620 ParserErrorCode.MISSING_IDENTIFIER
4223 ParserErrorCode.MISSING_IDENTIFIER, 3621 ]);
4224 ParserErrorCode.MISSING_IDENTIFIER]); 3622 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression,
4225 EngineTestCase.assertInstanceOf( 3623 BinaryExpression, expression.rightOperand);
4226 (obj) => obj is BinaryExpression,
4227 BinaryExpression,
4228 expression.rightOperand);
4229 } 3624 }
4230 3625
4231 void test_missing_commaInArgumentList() { 3626 void test_missing_commaInArgumentList() {
4232 ParserTestCase.parseExpression( 3627 ParserTestCase.parseExpression(
4233 "f(x: 1 y: 2)", 3628 "f(x: 1 y: 2)", [ParserErrorCode.EXPECTED_TOKEN]);
4234 [ParserErrorCode.EXPECTED_TOKEN]);
4235 } 3629 }
4236 3630
4237 void test_missingGet() { 3631 void test_missingGet() {
4238 CompilationUnit unit = ParserTestCase.parseCompilationUnit(r''' 3632 CompilationUnit unit = ParserTestCase.parseCompilationUnit(r'''
4239 class C { 3633 class C {
4240 int length {} 3634 int length {}
4241 void foo() {} 3635 void foo() {}
4242 }''', [ParserErrorCode.MISSING_GET]); 3636 }''', [ParserErrorCode.MISSING_GET]);
4243 expect(unit, isNotNull); 3637 expect(unit, isNotNull);
4244 ClassDeclaration classDeclaration = 3638 ClassDeclaration classDeclaration =
4245 unit.declarations[0] as ClassDeclaration; 3639 unit.declarations[0] as ClassDeclaration;
4246 NodeList<ClassMember> members = classDeclaration.members; 3640 NodeList<ClassMember> members = classDeclaration.members;
4247 expect(members, hasLength(2)); 3641 expect(members, hasLength(2));
4248 EngineTestCase.assertInstanceOf( 3642 EngineTestCase.assertInstanceOf(
4249 (obj) => obj is MethodDeclaration, 3643 (obj) => obj is MethodDeclaration, MethodDeclaration, members[0]);
4250 MethodDeclaration,
4251 members[0]);
4252 ClassMember member = members[1]; 3644 ClassMember member = members[1];
4253 EngineTestCase.assertInstanceOf( 3645 EngineTestCase.assertInstanceOf(
4254 (obj) => obj is MethodDeclaration, 3646 (obj) => obj is MethodDeclaration, MethodDeclaration, member);
4255 MethodDeclaration,
4256 member);
4257 expect((member as MethodDeclaration).name.name, "foo"); 3647 expect((member as MethodDeclaration).name.name, "foo");
4258 } 3648 }
4259 3649
4260 void test_missingIdentifier_afterAnnotation() { 3650 void test_missingIdentifier_afterAnnotation() {
4261 MethodDeclaration method = ParserTestCase.parse3( 3651 MethodDeclaration method = ParserTestCase.parse3("parseClassMember",
4262 "parseClassMember", 3652 <Object>["C"], "@override }", [ParserErrorCode.EXPECTED_CLASS_MEMBER]);
4263 <Object>["C"],
4264 "@override }",
4265 [ParserErrorCode.EXPECTED_CLASS_MEMBER]);
4266 expect(method.documentationComment, isNull); 3653 expect(method.documentationComment, isNull);
4267 NodeList<Annotation> metadata = method.metadata; 3654 NodeList<Annotation> metadata = method.metadata;
4268 expect(metadata, hasLength(1)); 3655 expect(metadata, hasLength(1));
4269 expect(metadata[0].name.name, "override"); 3656 expect(metadata[0].name.name, "override");
4270 } 3657 }
4271 3658
4272 void test_multiplicativeExpression_missing_LHS() { 3659 void test_multiplicativeExpression_missing_LHS() {
4273 BinaryExpression expression = 3660 BinaryExpression expression = ParserTestCase.parseExpression(
4274 ParserTestCase.parseExpression("* y", [ParserErrorCode.MISSING_IDENTIFIE R]); 3661 "* y", [ParserErrorCode.MISSING_IDENTIFIER]);
4275 EngineTestCase.assertInstanceOf( 3662 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier,
4276 (obj) => obj is SimpleIdentifier, 3663 SimpleIdentifier, expression.leftOperand);
4277 SimpleIdentifier,
4278 expression.leftOperand);
4279 expect(expression.leftOperand.isSynthetic, isTrue); 3664 expect(expression.leftOperand.isSynthetic, isTrue);
4280 } 3665 }
4281 3666
4282 void test_multiplicativeExpression_missing_LHS_RHS() { 3667 void test_multiplicativeExpression_missing_LHS_RHS() {
4283 BinaryExpression expression = ParserTestCase.parseExpression( 3668 BinaryExpression expression = ParserTestCase.parseExpression("*", [
4284 "*", 3669 ParserErrorCode.MISSING_IDENTIFIER,
4285 [ParserErrorCode.MISSING_IDENTIFIER, ParserErrorCode.MISSING_IDENTIFIER] ); 3670 ParserErrorCode.MISSING_IDENTIFIER
4286 EngineTestCase.assertInstanceOf( 3671 ]);
4287 (obj) => obj is SimpleIdentifier, 3672 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier,
4288 SimpleIdentifier, 3673 SimpleIdentifier, expression.leftOperand);
4289 expression.leftOperand); 3674 expect(expression.leftOperand.isSynthetic, isTrue);
4290 expect(expression.leftOperand.isSynthetic, isTrue); 3675 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier,
4291 EngineTestCase.assertInstanceOf( 3676 SimpleIdentifier, expression.rightOperand);
4292 (obj) => obj is SimpleIdentifier,
4293 SimpleIdentifier,
4294 expression.rightOperand);
4295 expect(expression.rightOperand.isSynthetic, isTrue); 3677 expect(expression.rightOperand.isSynthetic, isTrue);
4296 } 3678 }
4297 3679
4298 void test_multiplicativeExpression_missing_RHS() { 3680 void test_multiplicativeExpression_missing_RHS() {
4299 BinaryExpression expression = 3681 BinaryExpression expression = ParserTestCase.parseExpression(
4300 ParserTestCase.parseExpression("x *", [ParserErrorCode.MISSING_IDENTIFIE R]); 3682 "x *", [ParserErrorCode.MISSING_IDENTIFIER]);
4301 EngineTestCase.assertInstanceOf( 3683 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier,
4302 (obj) => obj is SimpleIdentifier, 3684 SimpleIdentifier, expression.rightOperand);
4303 SimpleIdentifier,
4304 expression.rightOperand);
4305 expect(expression.rightOperand.isSynthetic, isTrue); 3685 expect(expression.rightOperand.isSynthetic, isTrue);
4306 } 3686 }
4307 3687
4308 void test_multiplicativeExpression_missing_RHS_super() { 3688 void test_multiplicativeExpression_missing_RHS_super() {
4309 BinaryExpression expression = ParserTestCase.parseExpression( 3689 BinaryExpression expression = ParserTestCase.parseExpression(
4310 "super *", 3690 "super *", [ParserErrorCode.MISSING_IDENTIFIER]);
4311 [ParserErrorCode.MISSING_IDENTIFIER]); 3691 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier,
4312 EngineTestCase.assertInstanceOf( 3692 SimpleIdentifier, expression.rightOperand);
4313 (obj) => obj is SimpleIdentifier,
4314 SimpleIdentifier,
4315 expression.rightOperand);
4316 expect(expression.rightOperand.isSynthetic, isTrue); 3693 expect(expression.rightOperand.isSynthetic, isTrue);
4317 } 3694 }
4318 3695
4319 void test_multiplicativeExpression_precedence_unary_left() { 3696 void test_multiplicativeExpression_precedence_unary_left() {
4320 BinaryExpression expression = 3697 BinaryExpression expression = ParserTestCase.parseExpression(
4321 ParserTestCase.parseExpression("-x *", [ParserErrorCode.MISSING_IDENTIFI ER]); 3698 "-x *", [ParserErrorCode.MISSING_IDENTIFIER]);
4322 EngineTestCase.assertInstanceOf( 3699 EngineTestCase.assertInstanceOf((obj) => obj is PrefixExpression,
4323 (obj) => obj is PrefixExpression, 3700 PrefixExpression, expression.leftOperand);
4324 PrefixExpression,
4325 expression.leftOperand);
4326 } 3701 }
4327 3702
4328 void test_multiplicativeExpression_precedence_unary_right() { 3703 void test_multiplicativeExpression_precedence_unary_right() {
4329 BinaryExpression expression = 3704 BinaryExpression expression = ParserTestCase.parseExpression(
4330 ParserTestCase.parseExpression("* -y", [ParserErrorCode.MISSING_IDENTIFI ER]); 3705 "* -y", [ParserErrorCode.MISSING_IDENTIFIER]);
4331 EngineTestCase.assertInstanceOf( 3706 EngineTestCase.assertInstanceOf((obj) => obj is PrefixExpression,
4332 (obj) => obj is PrefixExpression, 3707 PrefixExpression, expression.rightOperand);
4333 PrefixExpression,
4334 expression.rightOperand);
4335 } 3708 }
4336 3709
4337 void test_multiplicativeExpression_super() { 3710 void test_multiplicativeExpression_super() {
4338 BinaryExpression expression = ParserTestCase.parseExpression( 3711 BinaryExpression expression = ParserTestCase.parseExpression("super == ==",
4339 "super == ==",
4340 [ 3712 [
4341 ParserErrorCode.MISSING_IDENTIFIER, 3713 ParserErrorCode.MISSING_IDENTIFIER,
4342 ParserErrorCode.MISSING_IDENTIFIER, 3714 ParserErrorCode.MISSING_IDENTIFIER,
4343 ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND]); 3715 ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND
4344 EngineTestCase.assertInstanceOf( 3716 ]);
4345 (obj) => obj is BinaryExpression, 3717 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression,
4346 BinaryExpression, 3718 BinaryExpression, expression.leftOperand);
4347 expression.leftOperand);
4348 } 3719 }
4349 3720
4350 void test_nonStringLiteralUri_import() { 3721 void test_nonStringLiteralUri_import() {
4351 ParserTestCase.parseCompilationUnit( 3722 ParserTestCase.parseCompilationUnit("import dart:io; class C {}", [
4352 "import dart:io; class C {}", 3723 ParserErrorCode.NON_STRING_LITERAL_AS_URI
4353 [ParserErrorCode.NON_STRING_LITERAL_AS_URI]); 3724 ]);
4354 } 3725 }
4355 3726
4356 void test_prefixExpression_missing_operand_minus() { 3727 void test_prefixExpression_missing_operand_minus() {
4357 PrefixExpression expression = 3728 PrefixExpression expression = ParserTestCase.parseExpression(
4358 ParserTestCase.parseExpression("-", [ParserErrorCode.MISSING_IDENTIFIER] ); 3729 "-", [ParserErrorCode.MISSING_IDENTIFIER]);
4359 EngineTestCase.assertInstanceOf( 3730 EngineTestCase.assertInstanceOf(
4360 (obj) => obj is SimpleIdentifier, 3731 (obj) => obj is SimpleIdentifier, SimpleIdentifier, expression.operand);
4361 SimpleIdentifier,
4362 expression.operand);
4363 expect(expression.operand.isSynthetic, isTrue); 3732 expect(expression.operand.isSynthetic, isTrue);
4364 expect(expression.operator.type, TokenType.MINUS); 3733 expect(expression.operator.type, TokenType.MINUS);
4365 } 3734 }
4366 3735
4367 void test_primaryExpression_argumentDefinitionTest() { 3736 void test_primaryExpression_argumentDefinitionTest() {
4368 Expression expression = ParserTestCase.parse4( 3737 Expression expression = ParserTestCase.parse4(
4369 "parsePrimaryExpression", 3738 "parsePrimaryExpression", "?a", [ParserErrorCode.UNEXPECTED_TOKEN]);
4370 "?a", 3739 EngineTestCase.assertInstanceOf(
4371 [ParserErrorCode.UNEXPECTED_TOKEN]); 3740 (obj) => obj is SimpleIdentifier, SimpleIdentifier, expression);
4372 EngineTestCase.assertInstanceOf(
4373 (obj) => obj is SimpleIdentifier,
4374 SimpleIdentifier,
4375 expression);
4376 } 3741 }
4377 3742
4378 void test_relationalExpression_missing_LHS() { 3743 void test_relationalExpression_missing_LHS() {
4379 IsExpression expression = 3744 IsExpression expression = ParserTestCase.parseExpression(
4380 ParserTestCase.parseExpression("is y", [ParserErrorCode.MISSING_IDENTIFI ER]); 3745 "is y", [ParserErrorCode.MISSING_IDENTIFIER]);
4381 EngineTestCase.assertInstanceOf( 3746 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier,
4382 (obj) => obj is SimpleIdentifier, 3747 SimpleIdentifier, expression.expression);
4383 SimpleIdentifier,
4384 expression.expression);
4385 expect(expression.expression.isSynthetic, isTrue); 3748 expect(expression.expression.isSynthetic, isTrue);
4386 } 3749 }
4387 3750
4388 void test_relationalExpression_missing_LHS_RHS() { 3751 void test_relationalExpression_missing_LHS_RHS() {
3752 IsExpression expression = ParserTestCase.parseExpression("is", [
3753 ParserErrorCode.EXPECTED_TYPE_NAME,
3754 ParserErrorCode.MISSING_IDENTIFIER
3755 ]);
3756 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier,
3757 SimpleIdentifier, expression.expression);
3758 expect(expression.expression.isSynthetic, isTrue);
3759 EngineTestCase.assertInstanceOf(
3760 (obj) => obj is TypeName, TypeName, expression.type);
3761 expect(expression.type.isSynthetic, isTrue);
3762 }
3763
3764 void test_relationalExpression_missing_RHS() {
4389 IsExpression expression = ParserTestCase.parseExpression( 3765 IsExpression expression = ParserTestCase.parseExpression(
4390 "is", 3766 "x is", [ParserErrorCode.EXPECTED_TYPE_NAME]);
4391 [ParserErrorCode.EXPECTED_TYPE_NAME, ParserErrorCode.MISSING_IDENTIFIER] ); 3767 EngineTestCase.assertInstanceOf(
4392 EngineTestCase.assertInstanceOf( 3768 (obj) => obj is TypeName, TypeName, expression.type);
4393 (obj) => obj is SimpleIdentifier,
4394 SimpleIdentifier,
4395 expression.expression);
4396 expect(expression.expression.isSynthetic, isTrue);
4397 EngineTestCase.assertInstanceOf(
4398 (obj) => obj is TypeName,
4399 TypeName,
4400 expression.type);
4401 expect(expression.type.isSynthetic, isTrue); 3769 expect(expression.type.isSynthetic, isTrue);
4402 } 3770 }
4403 3771
4404 void test_relationalExpression_missing_RHS() {
4405 IsExpression expression =
4406 ParserTestCase.parseExpression("x is", [ParserErrorCode.EXPECTED_TYPE_NA ME]);
4407 EngineTestCase.assertInstanceOf(
4408 (obj) => obj is TypeName,
4409 TypeName,
4410 expression.type);
4411 expect(expression.type.isSynthetic, isTrue);
4412 }
4413
4414 void test_relationalExpression_precedence_shift_right() { 3772 void test_relationalExpression_precedence_shift_right() {
4415 IsExpression expression = ParserTestCase.parseExpression( 3773 IsExpression expression = ParserTestCase.parseExpression("<< is", [
4416 "<< is", 3774 ParserErrorCode.EXPECTED_TYPE_NAME,
3775 ParserErrorCode.MISSING_IDENTIFIER,
3776 ParserErrorCode.MISSING_IDENTIFIER
3777 ]);
3778 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression,
3779 BinaryExpression, expression.expression);
3780 }
3781
3782 void test_shiftExpression_missing_LHS() {
3783 BinaryExpression expression = ParserTestCase.parseExpression(
3784 "<< y", [ParserErrorCode.MISSING_IDENTIFIER]);
3785 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier,
3786 SimpleIdentifier, expression.leftOperand);
3787 expect(expression.leftOperand.isSynthetic, isTrue);
3788 }
3789
3790 void test_shiftExpression_missing_LHS_RHS() {
3791 BinaryExpression expression = ParserTestCase.parseExpression("<<", [
3792 ParserErrorCode.MISSING_IDENTIFIER,
3793 ParserErrorCode.MISSING_IDENTIFIER
3794 ]);
3795 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier,
3796 SimpleIdentifier, expression.leftOperand);
3797 expect(expression.leftOperand.isSynthetic, isTrue);
3798 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier,
3799 SimpleIdentifier, expression.rightOperand);
3800 expect(expression.rightOperand.isSynthetic, isTrue);
3801 }
3802
3803 void test_shiftExpression_missing_RHS() {
3804 BinaryExpression expression = ParserTestCase.parseExpression(
3805 "x <<", [ParserErrorCode.MISSING_IDENTIFIER]);
3806 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier,
3807 SimpleIdentifier, expression.rightOperand);
3808 expect(expression.rightOperand.isSynthetic, isTrue);
3809 }
3810
3811 void test_shiftExpression_missing_RHS_super() {
3812 BinaryExpression expression = ParserTestCase.parseExpression(
3813 "super <<", [ParserErrorCode.MISSING_IDENTIFIER]);
3814 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier,
3815 SimpleIdentifier, expression.rightOperand);
3816 expect(expression.rightOperand.isSynthetic, isTrue);
3817 }
3818
3819 void test_shiftExpression_precedence_unary_left() {
3820 BinaryExpression expression = ParserTestCase.parseExpression("+ <<", [
3821 ParserErrorCode.MISSING_IDENTIFIER,
3822 ParserErrorCode.MISSING_IDENTIFIER,
3823 ParserErrorCode.MISSING_IDENTIFIER
3824 ]);
3825 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression,
3826 BinaryExpression, expression.leftOperand);
3827 }
3828
3829 void test_shiftExpression_precedence_unary_right() {
3830 BinaryExpression expression = ParserTestCase.parseExpression("<< +", [
3831 ParserErrorCode.MISSING_IDENTIFIER,
3832 ParserErrorCode.MISSING_IDENTIFIER,
3833 ParserErrorCode.MISSING_IDENTIFIER
3834 ]);
3835 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression,
3836 BinaryExpression, expression.rightOperand);
3837 }
3838
3839 void test_shiftExpression_super() {
3840 BinaryExpression expression = ParserTestCase.parseExpression("super << <<",
4417 [ 3841 [
4418 ParserErrorCode.EXPECTED_TYPE_NAME, 3842 ParserErrorCode.MISSING_IDENTIFIER,
4419 ParserErrorCode.MISSING_IDENTIFIER, 3843 ParserErrorCode.MISSING_IDENTIFIER
4420 ParserErrorCode.MISSING_IDENTIFIER]); 3844 ]);
4421 EngineTestCase.assertInstanceOf( 3845 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression,
4422 (obj) => obj is BinaryExpression, 3846 BinaryExpression, expression.leftOperand);
4423 BinaryExpression,
4424 expression.expression);
4425 }
4426
4427 void test_shiftExpression_missing_LHS() {
4428 BinaryExpression expression =
4429 ParserTestCase.parseExpression("<< y", [ParserErrorCode.MISSING_IDENTIFI ER]);
4430 EngineTestCase.assertInstanceOf(
4431 (obj) => obj is SimpleIdentifier,
4432 SimpleIdentifier,
4433 expression.leftOperand);
4434 expect(expression.leftOperand.isSynthetic, isTrue);
4435 }
4436
4437 void test_shiftExpression_missing_LHS_RHS() {
4438 BinaryExpression expression = ParserTestCase.parseExpression(
4439 "<<",
4440 [ParserErrorCode.MISSING_IDENTIFIER, ParserErrorCode.MISSING_IDENTIFIER] );
4441 EngineTestCase.assertInstanceOf(
4442 (obj) => obj is SimpleIdentifier,
4443 SimpleIdentifier,
4444 expression.leftOperand);
4445 expect(expression.leftOperand.isSynthetic, isTrue);
4446 EngineTestCase.assertInstanceOf(
4447 (obj) => obj is SimpleIdentifier,
4448 SimpleIdentifier,
4449 expression.rightOperand);
4450 expect(expression.rightOperand.isSynthetic, isTrue);
4451 }
4452
4453 void test_shiftExpression_missing_RHS() {
4454 BinaryExpression expression =
4455 ParserTestCase.parseExpression("x <<", [ParserErrorCode.MISSING_IDENTIFI ER]);
4456 EngineTestCase.assertInstanceOf(
4457 (obj) => obj is SimpleIdentifier,
4458 SimpleIdentifier,
4459 expression.rightOperand);
4460 expect(expression.rightOperand.isSynthetic, isTrue);
4461 }
4462
4463 void test_shiftExpression_missing_RHS_super() {
4464 BinaryExpression expression = ParserTestCase.parseExpression(
4465 "super <<",
4466 [ParserErrorCode.MISSING_IDENTIFIER]);
4467 EngineTestCase.assertInstanceOf(
4468 (obj) => obj is SimpleIdentifier,
4469 SimpleIdentifier,
4470 expression.rightOperand);
4471 expect(expression.rightOperand.isSynthetic, isTrue);
4472 }
4473
4474 void test_shiftExpression_precedence_unary_left() {
4475 BinaryExpression expression = ParserTestCase.parseExpression(
4476 "+ <<",
4477 [
4478 ParserErrorCode.MISSING_IDENTIFIER,
4479 ParserErrorCode.MISSING_IDENTIFIER,
4480 ParserErrorCode.MISSING_IDENTIFIER]);
4481 EngineTestCase.assertInstanceOf(
4482 (obj) => obj is BinaryExpression,
4483 BinaryExpression,
4484 expression.leftOperand);
4485 }
4486
4487 void test_shiftExpression_precedence_unary_right() {
4488 BinaryExpression expression = ParserTestCase.parseExpression(
4489 "<< +",
4490 [
4491 ParserErrorCode.MISSING_IDENTIFIER,
4492 ParserErrorCode.MISSING_IDENTIFIER,
4493 ParserErrorCode.MISSING_IDENTIFIER]);
4494 EngineTestCase.assertInstanceOf(
4495 (obj) => obj is BinaryExpression,
4496 BinaryExpression,
4497 expression.rightOperand);
4498 }
4499
4500 void test_shiftExpression_super() {
4501 BinaryExpression expression = ParserTestCase.parseExpression(
4502 "super << <<",
4503 [ParserErrorCode.MISSING_IDENTIFIER, ParserErrorCode.MISSING_IDENTIFIER] );
4504 EngineTestCase.assertInstanceOf(
4505 (obj) => obj is BinaryExpression,
4506 BinaryExpression,
4507 expression.leftOperand);
4508 } 3847 }
4509 3848
4510 void test_typedef_eof() { 3849 void test_typedef_eof() {
4511 CompilationUnit unit = ParserTestCase.parseCompilationUnit( 3850 CompilationUnit unit = ParserTestCase.parseCompilationUnit("typedef n", [
4512 "typedef n", 3851 ParserErrorCode.EXPECTED_TOKEN,
4513 [ParserErrorCode.EXPECTED_TOKEN, ParserErrorCode.MISSING_TYPEDEF_PARAMET ERS]); 3852 ParserErrorCode.MISSING_TYPEDEF_PARAMETERS
3853 ]);
4514 NodeList<CompilationUnitMember> declarations = unit.declarations; 3854 NodeList<CompilationUnitMember> declarations = unit.declarations;
4515 expect(declarations, hasLength(1)); 3855 expect(declarations, hasLength(1));
4516 CompilationUnitMember member = declarations[0]; 3856 CompilationUnitMember member = declarations[0];
4517 EngineTestCase.assertInstanceOf( 3857 EngineTestCase.assertInstanceOf(
4518 (obj) => obj is FunctionTypeAlias, 3858 (obj) => obj is FunctionTypeAlias, FunctionTypeAlias, member);
4519 FunctionTypeAlias,
4520 member);
4521 } 3859 }
4522 3860
4523 void test_unaryPlus() { 3861 void test_unaryPlus() {
4524 ParserTestCase.parseExpression("+2", [ParserErrorCode.MISSING_IDENTIFIER]); 3862 ParserTestCase.parseExpression("+2", [ParserErrorCode.MISSING_IDENTIFIER]);
4525 } 3863 }
4526 } 3864 }
4527 3865
4528 @reflectiveTest 3866 @reflectiveTest
4529 class ResolutionCopierTest extends EngineTestCase { 3867 class ResolutionCopierTest extends EngineTestCase {
4530 void test_visitAnnotation() { 3868 void test_visitAnnotation() {
4531 String annotationName = "proxy"; 3869 String annotationName = "proxy";
4532 Annotation fromNode = 3870 Annotation fromNode =
4533 AstFactory.annotation(AstFactory.identifier3(annotationName)); 3871 AstFactory.annotation(AstFactory.identifier3(annotationName));
4534 Element element = ElementFactory.topLevelVariableElement2(annotationName); 3872 Element element = ElementFactory.topLevelVariableElement2(annotationName);
4535 fromNode.element = element; 3873 fromNode.element = element;
4536 Annotation toNode = 3874 Annotation toNode =
4537 AstFactory.annotation(AstFactory.identifier3(annotationName)); 3875 AstFactory.annotation(AstFactory.identifier3(annotationName));
4538 ResolutionCopier.copyResolutionData(fromNode, toNode); 3876 ResolutionCopier.copyResolutionData(fromNode, toNode);
4539 expect(toNode.element, same(element)); 3877 expect(toNode.element, same(element));
4540 } 3878 }
4541 3879
4542 void test_visitAsExpression() { 3880 void test_visitAsExpression() {
4543 AsExpression fromNode = AstFactory.asExpression( 3881 AsExpression fromNode = AstFactory.asExpression(
4544 AstFactory.identifier3("x"), 3882 AstFactory.identifier3("x"), AstFactory.typeName4("A"));
4545 AstFactory.typeName4("A"));
4546 DartType propagatedType = ElementFactory.classElement2("A").type; 3883 DartType propagatedType = ElementFactory.classElement2("A").type;
4547 fromNode.propagatedType = propagatedType; 3884 fromNode.propagatedType = propagatedType;
4548 DartType staticType = ElementFactory.classElement2("B").type; 3885 DartType staticType = ElementFactory.classElement2("B").type;
4549 fromNode.staticType = staticType; 3886 fromNode.staticType = staticType;
4550 AsExpression toNode = AstFactory.asExpression( 3887 AsExpression toNode = AstFactory.asExpression(
4551 AstFactory.identifier3("x"), 3888 AstFactory.identifier3("x"), AstFactory.typeName4("A"));
4552 AstFactory.typeName4("A"));
4553 ResolutionCopier.copyResolutionData(fromNode, toNode); 3889 ResolutionCopier.copyResolutionData(fromNode, toNode);
4554 expect(toNode.propagatedType, same(propagatedType)); 3890 expect(toNode.propagatedType, same(propagatedType));
4555 expect(toNode.staticType, same(staticType)); 3891 expect(toNode.staticType, same(staticType));
4556 } 3892 }
4557 3893
4558 void test_visitAssignmentExpression() { 3894 void test_visitAssignmentExpression() {
4559 AssignmentExpression fromNode = AstFactory.assignmentExpression( 3895 AssignmentExpression fromNode = AstFactory.assignmentExpression(
4560 AstFactory.identifier3("a"), 3896 AstFactory.identifier3("a"), TokenType.PLUS_EQ,
4561 TokenType.PLUS_EQ,
4562 AstFactory.identifier3("b")); 3897 AstFactory.identifier3("b"));
4563 DartType propagatedType = ElementFactory.classElement2("C").type; 3898 DartType propagatedType = ElementFactory.classElement2("C").type;
4564 MethodElement propagatedElement = 3899 MethodElement propagatedElement =
4565 ElementFactory.methodElement("+", propagatedType); 3900 ElementFactory.methodElement("+", propagatedType);
4566 fromNode.propagatedElement = propagatedElement; 3901 fromNode.propagatedElement = propagatedElement;
4567 fromNode.propagatedType = propagatedType; 3902 fromNode.propagatedType = propagatedType;
4568 DartType staticType = ElementFactory.classElement2("C").type; 3903 DartType staticType = ElementFactory.classElement2("C").type;
4569 MethodElement staticElement = ElementFactory.methodElement("+", staticType); 3904 MethodElement staticElement = ElementFactory.methodElement("+", staticType);
4570 fromNode.staticElement = staticElement; 3905 fromNode.staticElement = staticElement;
4571 fromNode.staticType = staticType; 3906 fromNode.staticType = staticType;
4572 AssignmentExpression toNode = AstFactory.assignmentExpression( 3907 AssignmentExpression toNode = AstFactory.assignmentExpression(
4573 AstFactory.identifier3("a"), 3908 AstFactory.identifier3("a"), TokenType.PLUS_EQ,
4574 TokenType.PLUS_EQ,
4575 AstFactory.identifier3("b")); 3909 AstFactory.identifier3("b"));
4576 ResolutionCopier.copyResolutionData(fromNode, toNode); 3910 ResolutionCopier.copyResolutionData(fromNode, toNode);
4577 expect(toNode.propagatedElement, same(propagatedElement)); 3911 expect(toNode.propagatedElement, same(propagatedElement));
4578 expect(toNode.propagatedType, same(propagatedType)); 3912 expect(toNode.propagatedType, same(propagatedType));
4579 expect(toNode.staticElement, same(staticElement)); 3913 expect(toNode.staticElement, same(staticElement));
4580 expect(toNode.staticType, same(staticType)); 3914 expect(toNode.staticType, same(staticType));
4581 } 3915 }
4582 3916
4583 void test_visitBinaryExpression() { 3917 void test_visitBinaryExpression() {
4584 BinaryExpression fromNode = AstFactory.binaryExpression( 3918 BinaryExpression fromNode = AstFactory.binaryExpression(
4585 AstFactory.identifier3("a"), 3919 AstFactory.identifier3("a"), TokenType.PLUS,
4586 TokenType.PLUS,
4587 AstFactory.identifier3("b")); 3920 AstFactory.identifier3("b"));
4588 DartType propagatedType = ElementFactory.classElement2("C").type; 3921 DartType propagatedType = ElementFactory.classElement2("C").type;
4589 MethodElement propagatedElement = 3922 MethodElement propagatedElement =
4590 ElementFactory.methodElement("+", propagatedType); 3923 ElementFactory.methodElement("+", propagatedType);
4591 fromNode.propagatedElement = propagatedElement; 3924 fromNode.propagatedElement = propagatedElement;
4592 fromNode.propagatedType = propagatedType; 3925 fromNode.propagatedType = propagatedType;
4593 DartType staticType = ElementFactory.classElement2("C").type; 3926 DartType staticType = ElementFactory.classElement2("C").type;
4594 MethodElement staticElement = ElementFactory.methodElement("+", staticType); 3927 MethodElement staticElement = ElementFactory.methodElement("+", staticType);
4595 fromNode.staticElement = staticElement; 3928 fromNode.staticElement = staticElement;
4596 fromNode.staticType = staticType; 3929 fromNode.staticType = staticType;
4597 BinaryExpression toNode = AstFactory.binaryExpression( 3930 BinaryExpression toNode = AstFactory.binaryExpression(
4598 AstFactory.identifier3("a"), 3931 AstFactory.identifier3("a"), TokenType.PLUS,
4599 TokenType.PLUS,
4600 AstFactory.identifier3("b")); 3932 AstFactory.identifier3("b"));
4601 ResolutionCopier.copyResolutionData(fromNode, toNode); 3933 ResolutionCopier.copyResolutionData(fromNode, toNode);
4602 expect(toNode.propagatedElement, same(propagatedElement)); 3934 expect(toNode.propagatedElement, same(propagatedElement));
4603 expect(toNode.propagatedType, same(propagatedType)); 3935 expect(toNode.propagatedType, same(propagatedType));
4604 expect(toNode.staticElement, same(staticElement)); 3936 expect(toNode.staticElement, same(staticElement));
4605 expect(toNode.staticType, same(staticType)); 3937 expect(toNode.staticType, same(staticType));
4606 } 3938 }
4607 3939
4608 void test_visitBooleanLiteral() { 3940 void test_visitBooleanLiteral() {
4609 BooleanLiteral fromNode = AstFactory.booleanLiteral(true); 3941 BooleanLiteral fromNode = AstFactory.booleanLiteral(true);
4610 DartType propagatedType = ElementFactory.classElement2("C").type; 3942 DartType propagatedType = ElementFactory.classElement2("C").type;
4611 fromNode.propagatedType = propagatedType; 3943 fromNode.propagatedType = propagatedType;
4612 DartType staticType = ElementFactory.classElement2("C").type; 3944 DartType staticType = ElementFactory.classElement2("C").type;
4613 fromNode.staticType = staticType; 3945 fromNode.staticType = staticType;
4614 BooleanLiteral toNode = AstFactory.booleanLiteral(true); 3946 BooleanLiteral toNode = AstFactory.booleanLiteral(true);
4615 ResolutionCopier.copyResolutionData(fromNode, toNode); 3947 ResolutionCopier.copyResolutionData(fromNode, toNode);
4616 expect(toNode.propagatedType, same(propagatedType)); 3948 expect(toNode.propagatedType, same(propagatedType));
4617 expect(toNode.staticType, same(staticType)); 3949 expect(toNode.staticType, same(staticType));
4618 } 3950 }
4619 3951
4620 void test_visitCascadeExpression() { 3952 void test_visitCascadeExpression() {
4621 CascadeExpression fromNode = AstFactory.cascadeExpression( 3953 CascadeExpression fromNode = AstFactory.cascadeExpression(
4622 AstFactory.identifier3("a"), 3954 AstFactory.identifier3("a"), [AstFactory.identifier3("b")]);
4623 [AstFactory.identifier3("b")]);
4624 DartType propagatedType = ElementFactory.classElement2("C").type; 3955 DartType propagatedType = ElementFactory.classElement2("C").type;
4625 fromNode.propagatedType = propagatedType; 3956 fromNode.propagatedType = propagatedType;
4626 DartType staticType = ElementFactory.classElement2("C").type; 3957 DartType staticType = ElementFactory.classElement2("C").type;
4627 fromNode.staticType = staticType; 3958 fromNode.staticType = staticType;
4628 CascadeExpression toNode = AstFactory.cascadeExpression( 3959 CascadeExpression toNode = AstFactory.cascadeExpression(
4629 AstFactory.identifier3("a"), 3960 AstFactory.identifier3("a"), [AstFactory.identifier3("b")]);
4630 [AstFactory.identifier3("b")]);
4631 ResolutionCopier.copyResolutionData(fromNode, toNode); 3961 ResolutionCopier.copyResolutionData(fromNode, toNode);
4632 expect(toNode.propagatedType, same(propagatedType)); 3962 expect(toNode.propagatedType, same(propagatedType));
4633 expect(toNode.staticType, same(staticType)); 3963 expect(toNode.staticType, same(staticType));
4634 } 3964 }
4635 3965
4636 void test_visitCompilationUnit() { 3966 void test_visitCompilationUnit() {
4637 CompilationUnit fromNode = AstFactory.compilationUnit(); 3967 CompilationUnit fromNode = AstFactory.compilationUnit();
4638 CompilationUnitElement element = 3968 CompilationUnitElement element =
4639 new CompilationUnitElementImpl("test.dart"); 3969 new CompilationUnitElementImpl("test.dart");
4640 fromNode.element = element; 3970 fromNode.element = element;
4641 CompilationUnit toNode = AstFactory.compilationUnit(); 3971 CompilationUnit toNode = AstFactory.compilationUnit();
4642 ResolutionCopier.copyResolutionData(fromNode, toNode); 3972 ResolutionCopier.copyResolutionData(fromNode, toNode);
4643 expect(toNode.element, same(element)); 3973 expect(toNode.element, same(element));
4644 } 3974 }
4645 3975
4646 void test_visitConditionalExpression() { 3976 void test_visitConditionalExpression() {
4647 ConditionalExpression fromNode = AstFactory.conditionalExpression( 3977 ConditionalExpression fromNode = AstFactory.conditionalExpression(
4648 AstFactory.identifier3("c"), 3978 AstFactory.identifier3("c"), AstFactory.identifier3("a"),
4649 AstFactory.identifier3("a"),
4650 AstFactory.identifier3("b")); 3979 AstFactory.identifier3("b"));
4651 DartType propagatedType = ElementFactory.classElement2("C").type; 3980 DartType propagatedType = ElementFactory.classElement2("C").type;
4652 fromNode.propagatedType = propagatedType; 3981 fromNode.propagatedType = propagatedType;
4653 DartType staticType = ElementFactory.classElement2("C").type; 3982 DartType staticType = ElementFactory.classElement2("C").type;
4654 fromNode.staticType = staticType; 3983 fromNode.staticType = staticType;
4655 ConditionalExpression toNode = AstFactory.conditionalExpression( 3984 ConditionalExpression toNode = AstFactory.conditionalExpression(
4656 AstFactory.identifier3("c"), 3985 AstFactory.identifier3("c"), AstFactory.identifier3("a"),
4657 AstFactory.identifier3("a"),
4658 AstFactory.identifier3("b")); 3986 AstFactory.identifier3("b"));
4659 ResolutionCopier.copyResolutionData(fromNode, toNode); 3987 ResolutionCopier.copyResolutionData(fromNode, toNode);
4660 expect(toNode.propagatedType, same(propagatedType)); 3988 expect(toNode.propagatedType, same(propagatedType));
4661 expect(toNode.staticType, same(staticType)); 3989 expect(toNode.staticType, same(staticType));
4662 } 3990 }
4663 3991
4664 void test_visitConstructorDeclaration() { 3992 void test_visitConstructorDeclaration() {
4665 String className = "A"; 3993 String className = "A";
4666 String constructorName = "c"; 3994 String constructorName = "c";
4667 ConstructorDeclaration fromNode = AstFactory.constructorDeclaration( 3995 ConstructorDeclaration fromNode = AstFactory.constructorDeclaration(
4668 AstFactory.identifier3(className), 3996 AstFactory.identifier3(className), constructorName,
4669 constructorName, 3997 AstFactory.formalParameterList(), null);
4670 AstFactory.formalParameterList(),
4671 null);
4672 ConstructorElement element = ElementFactory.constructorElement2( 3998 ConstructorElement element = ElementFactory.constructorElement2(
4673 ElementFactory.classElement2(className), 3999 ElementFactory.classElement2(className), constructorName);
4674 constructorName);
4675 fromNode.element = element; 4000 fromNode.element = element;
4676 ConstructorDeclaration toNode = AstFactory.constructorDeclaration( 4001 ConstructorDeclaration toNode = AstFactory.constructorDeclaration(
4677 AstFactory.identifier3(className), 4002 AstFactory.identifier3(className), constructorName,
4678 constructorName, 4003 AstFactory.formalParameterList(), null);
4679 AstFactory.formalParameterList(),
4680 null);
4681 ResolutionCopier.copyResolutionData(fromNode, toNode); 4004 ResolutionCopier.copyResolutionData(fromNode, toNode);
4682 expect(toNode.element, same(element)); 4005 expect(toNode.element, same(element));
4683 } 4006 }
4684 4007
4685 void test_visitConstructorName() { 4008 void test_visitConstructorName() {
4686 ConstructorName fromNode = 4009 ConstructorName fromNode =
4687 AstFactory.constructorName(AstFactory.typeName4("A"), "c"); 4010 AstFactory.constructorName(AstFactory.typeName4("A"), "c");
4688 ConstructorElement staticElement = 4011 ConstructorElement staticElement = ElementFactory.constructorElement2(
4689 ElementFactory.constructorElement2(ElementFactory.classElement2("A"), "c "); 4012 ElementFactory.classElement2("A"), "c");
4690 fromNode.staticElement = staticElement; 4013 fromNode.staticElement = staticElement;
4691 ConstructorName toNode = 4014 ConstructorName toNode =
4692 AstFactory.constructorName(AstFactory.typeName4("A"), "c"); 4015 AstFactory.constructorName(AstFactory.typeName4("A"), "c");
4693 ResolutionCopier.copyResolutionData(fromNode, toNode); 4016 ResolutionCopier.copyResolutionData(fromNode, toNode);
4694 expect(toNode.staticElement, same(staticElement)); 4017 expect(toNode.staticElement, same(staticElement));
4695 } 4018 }
4696 4019
4697 void test_visitDoubleLiteral() { 4020 void test_visitDoubleLiteral() {
4698 DoubleLiteral fromNode = AstFactory.doubleLiteral(1.0); 4021 DoubleLiteral fromNode = AstFactory.doubleLiteral(1.0);
4699 DartType propagatedType = ElementFactory.classElement2("C").type; 4022 DartType propagatedType = ElementFactory.classElement2("C").type;
(...skipping 10 matching lines...) Expand all
4710 ExportDirective fromNode = AstFactory.exportDirective2("dart:uri"); 4033 ExportDirective fromNode = AstFactory.exportDirective2("dart:uri");
4711 ExportElement element = new ExportElementImpl(); 4034 ExportElement element = new ExportElementImpl();
4712 fromNode.element = element; 4035 fromNode.element = element;
4713 ExportDirective toNode = AstFactory.exportDirective2("dart:uri"); 4036 ExportDirective toNode = AstFactory.exportDirective2("dart:uri");
4714 ResolutionCopier.copyResolutionData(fromNode, toNode); 4037 ResolutionCopier.copyResolutionData(fromNode, toNode);
4715 expect(toNode.element, same(element)); 4038 expect(toNode.element, same(element));
4716 } 4039 }
4717 4040
4718 void test_visitFunctionExpression() { 4041 void test_visitFunctionExpression() {
4719 FunctionExpression fromNode = AstFactory.functionExpression2( 4042 FunctionExpression fromNode = AstFactory.functionExpression2(
4720 AstFactory.formalParameterList(), 4043 AstFactory.formalParameterList(), AstFactory.emptyFunctionBody());
4721 AstFactory.emptyFunctionBody()); 4044 MethodElement element = ElementFactory.methodElement(
4722 MethodElement element = 4045 "m", ElementFactory.classElement2("C").type);
4723 ElementFactory.methodElement("m", ElementFactory.classElement2("C").type );
4724 fromNode.element = element; 4046 fromNode.element = element;
4725 DartType propagatedType = ElementFactory.classElement2("C").type; 4047 DartType propagatedType = ElementFactory.classElement2("C").type;
4726 fromNode.propagatedType = propagatedType; 4048 fromNode.propagatedType = propagatedType;
4727 DartType staticType = ElementFactory.classElement2("C").type; 4049 DartType staticType = ElementFactory.classElement2("C").type;
4728 fromNode.staticType = staticType; 4050 fromNode.staticType = staticType;
4729 FunctionExpression toNode = AstFactory.functionExpression2( 4051 FunctionExpression toNode = AstFactory.functionExpression2(
4730 AstFactory.formalParameterList(), 4052 AstFactory.formalParameterList(), AstFactory.emptyFunctionBody());
4731 AstFactory.emptyFunctionBody());
4732 ResolutionCopier.copyResolutionData(fromNode, toNode); 4053 ResolutionCopier.copyResolutionData(fromNode, toNode);
4733 expect(toNode.element, same(element)); 4054 expect(toNode.element, same(element));
4734 expect(toNode.propagatedType, same(propagatedType)); 4055 expect(toNode.propagatedType, same(propagatedType));
4735 expect(toNode.staticType, same(staticType)); 4056 expect(toNode.staticType, same(staticType));
4736 } 4057 }
4737 4058
4738 void test_visitFunctionExpressionInvocation() { 4059 void test_visitFunctionExpressionInvocation() {
4739 FunctionExpressionInvocation fromNode = 4060 FunctionExpressionInvocation fromNode =
4740 AstFactory.functionExpressionInvocation(AstFactory.identifier3("f")); 4061 AstFactory.functionExpressionInvocation(AstFactory.identifier3("f"));
4741 MethodElement propagatedElement = 4062 MethodElement propagatedElement = ElementFactory.methodElement(
4742 ElementFactory.methodElement("m", ElementFactory.classElement2("C").type ); 4063 "m", ElementFactory.classElement2("C").type);
4743 fromNode.propagatedElement = propagatedElement; 4064 fromNode.propagatedElement = propagatedElement;
4744 DartType propagatedType = ElementFactory.classElement2("C").type; 4065 DartType propagatedType = ElementFactory.classElement2("C").type;
4745 fromNode.propagatedType = propagatedType; 4066 fromNode.propagatedType = propagatedType;
4746 MethodElement staticElement = 4067 MethodElement staticElement = ElementFactory.methodElement(
4747 ElementFactory.methodElement("m", ElementFactory.classElement2("C").type ); 4068 "m", ElementFactory.classElement2("C").type);
4748 fromNode.staticElement = staticElement; 4069 fromNode.staticElement = staticElement;
4749 DartType staticType = ElementFactory.classElement2("C").type; 4070 DartType staticType = ElementFactory.classElement2("C").type;
4750 fromNode.staticType = staticType; 4071 fromNode.staticType = staticType;
4751 FunctionExpressionInvocation toNode = 4072 FunctionExpressionInvocation toNode =
4752 AstFactory.functionExpressionInvocation(AstFactory.identifier3("f")); 4073 AstFactory.functionExpressionInvocation(AstFactory.identifier3("f"));
4753 ResolutionCopier.copyResolutionData(fromNode, toNode); 4074 ResolutionCopier.copyResolutionData(fromNode, toNode);
4754 expect(toNode.propagatedElement, same(propagatedElement)); 4075 expect(toNode.propagatedElement, same(propagatedElement));
4755 expect(toNode.propagatedType, same(propagatedType)); 4076 expect(toNode.propagatedType, same(propagatedType));
4756 expect(toNode.staticElement, same(staticElement)); 4077 expect(toNode.staticElement, same(staticElement));
4757 expect(toNode.staticType, same(staticType)); 4078 expect(toNode.staticType, same(staticType));
4758 } 4079 }
4759 4080
4760 void test_visitImportDirective() { 4081 void test_visitImportDirective() {
4761 ImportDirective fromNode = AstFactory.importDirective3("dart:uri", null); 4082 ImportDirective fromNode = AstFactory.importDirective3("dart:uri", null);
4762 ImportElement element = new ImportElementImpl(0); 4083 ImportElement element = new ImportElementImpl(0);
4763 fromNode.element = element; 4084 fromNode.element = element;
4764 ImportDirective toNode = AstFactory.importDirective3("dart:uri", null); 4085 ImportDirective toNode = AstFactory.importDirective3("dart:uri", null);
4765 ResolutionCopier.copyResolutionData(fromNode, toNode); 4086 ResolutionCopier.copyResolutionData(fromNode, toNode);
4766 expect(toNode.element, same(element)); 4087 expect(toNode.element, same(element));
4767 } 4088 }
4768 4089
4769 void test_visitIndexExpression() { 4090 void test_visitIndexExpression() {
4770 IndexExpression fromNode = 4091 IndexExpression fromNode = AstFactory.indexExpression(
4771 AstFactory.indexExpression(AstFactory.identifier3("a"), AstFactory.integ er(0)); 4092 AstFactory.identifier3("a"), AstFactory.integer(0));
4772 MethodElement propagatedElement = 4093 MethodElement propagatedElement = ElementFactory.methodElement(
4773 ElementFactory.methodElement("m", ElementFactory.classElement2("C").type ); 4094 "m", ElementFactory.classElement2("C").type);
4774 MethodElement staticElement = 4095 MethodElement staticElement = ElementFactory.methodElement(
4775 ElementFactory.methodElement("m", ElementFactory.classElement2("C").type ); 4096 "m", ElementFactory.classElement2("C").type);
4776 AuxiliaryElements auxiliaryElements = 4097 AuxiliaryElements auxiliaryElements =
4777 new AuxiliaryElements(staticElement, propagatedElement); 4098 new AuxiliaryElements(staticElement, propagatedElement);
4778 fromNode.auxiliaryElements = auxiliaryElements; 4099 fromNode.auxiliaryElements = auxiliaryElements;
4779 fromNode.propagatedElement = propagatedElement; 4100 fromNode.propagatedElement = propagatedElement;
4780 DartType propagatedType = ElementFactory.classElement2("C").type; 4101 DartType propagatedType = ElementFactory.classElement2("C").type;
4781 fromNode.propagatedType = propagatedType; 4102 fromNode.propagatedType = propagatedType;
4782 fromNode.staticElement = staticElement; 4103 fromNode.staticElement = staticElement;
4783 DartType staticType = ElementFactory.classElement2("C").type; 4104 DartType staticType = ElementFactory.classElement2("C").type;
4784 fromNode.staticType = staticType; 4105 fromNode.staticType = staticType;
4785 IndexExpression toNode = 4106 IndexExpression toNode = AstFactory.indexExpression(
4786 AstFactory.indexExpression(AstFactory.identifier3("a"), AstFactory.integ er(0)); 4107 AstFactory.identifier3("a"), AstFactory.integer(0));
4787 ResolutionCopier.copyResolutionData(fromNode, toNode); 4108 ResolutionCopier.copyResolutionData(fromNode, toNode);
4788 expect(toNode.auxiliaryElements, same(auxiliaryElements)); 4109 expect(toNode.auxiliaryElements, same(auxiliaryElements));
4789 expect(toNode.propagatedElement, same(propagatedElement)); 4110 expect(toNode.propagatedElement, same(propagatedElement));
4790 expect(toNode.propagatedType, same(propagatedType)); 4111 expect(toNode.propagatedType, same(propagatedType));
4791 expect(toNode.staticElement, same(staticElement)); 4112 expect(toNode.staticElement, same(staticElement));
4792 expect(toNode.staticType, same(staticType)); 4113 expect(toNode.staticType, same(staticType));
4793 } 4114 }
4794 4115
4795 void test_visitInstanceCreationExpression() { 4116 void test_visitInstanceCreationExpression() {
4796 InstanceCreationExpression fromNode = 4117 InstanceCreationExpression fromNode = AstFactory
4797 AstFactory.instanceCreationExpression2(Keyword.NEW, AstFactory.typeName4 ("C")); 4118 .instanceCreationExpression2(Keyword.NEW, AstFactory.typeName4("C"));
4798 DartType propagatedType = ElementFactory.classElement2("C").type; 4119 DartType propagatedType = ElementFactory.classElement2("C").type;
4799 fromNode.propagatedType = propagatedType; 4120 fromNode.propagatedType = propagatedType;
4800 ConstructorElement staticElement = 4121 ConstructorElement staticElement = ElementFactory.constructorElement2(
4801 ElementFactory.constructorElement2(ElementFactory.classElement2("C"), nu ll); 4122 ElementFactory.classElement2("C"), null);
4802 fromNode.staticElement = staticElement; 4123 fromNode.staticElement = staticElement;
4803 DartType staticType = ElementFactory.classElement2("C").type; 4124 DartType staticType = ElementFactory.classElement2("C").type;
4804 fromNode.staticType = staticType; 4125 fromNode.staticType = staticType;
4805 InstanceCreationExpression toNode = 4126 InstanceCreationExpression toNode = AstFactory.instanceCreationExpression2(
4806 AstFactory.instanceCreationExpression2(Keyword.NEW, AstFactory.typeName4 ("C")); 4127 Keyword.NEW, AstFactory.typeName4("C"));
4807 ResolutionCopier.copyResolutionData(fromNode, toNode); 4128 ResolutionCopier.copyResolutionData(fromNode, toNode);
4808 expect(toNode.propagatedType, same(propagatedType)); 4129 expect(toNode.propagatedType, same(propagatedType));
4809 expect(toNode.staticElement, same(staticElement)); 4130 expect(toNode.staticElement, same(staticElement));
4810 expect(toNode.staticType, same(staticType)); 4131 expect(toNode.staticType, same(staticType));
4811 } 4132 }
4812 4133
4813 void test_visitIntegerLiteral() { 4134 void test_visitIntegerLiteral() {
4814 IntegerLiteral fromNode = AstFactory.integer(2); 4135 IntegerLiteral fromNode = AstFactory.integer(2);
4815 DartType propagatedType = ElementFactory.classElement2("C").type; 4136 DartType propagatedType = ElementFactory.classElement2("C").type;
4816 fromNode.propagatedType = propagatedType; 4137 fromNode.propagatedType = propagatedType;
4817 DartType staticType = ElementFactory.classElement2("C").type; 4138 DartType staticType = ElementFactory.classElement2("C").type;
4818 fromNode.staticType = staticType; 4139 fromNode.staticType = staticType;
4819 IntegerLiteral toNode = AstFactory.integer(2); 4140 IntegerLiteral toNode = AstFactory.integer(2);
4820 ResolutionCopier.copyResolutionData(fromNode, toNode); 4141 ResolutionCopier.copyResolutionData(fromNode, toNode);
4821 expect(toNode.propagatedType, same(propagatedType)); 4142 expect(toNode.propagatedType, same(propagatedType));
4822 expect(toNode.staticType, same(staticType)); 4143 expect(toNode.staticType, same(staticType));
4823 } 4144 }
4824 4145
4825 void test_visitIsExpression() { 4146 void test_visitIsExpression() {
4826 IsExpression fromNode = AstFactory.isExpression( 4147 IsExpression fromNode = AstFactory.isExpression(
4827 AstFactory.identifier3("x"), 4148 AstFactory.identifier3("x"), false, AstFactory.typeName4("A"));
4828 false,
4829 AstFactory.typeName4("A"));
4830 DartType propagatedType = ElementFactory.classElement2("C").type; 4149 DartType propagatedType = ElementFactory.classElement2("C").type;
4831 fromNode.propagatedType = propagatedType; 4150 fromNode.propagatedType = propagatedType;
4832 DartType staticType = ElementFactory.classElement2("C").type; 4151 DartType staticType = ElementFactory.classElement2("C").type;
4833 fromNode.staticType = staticType; 4152 fromNode.staticType = staticType;
4834 IsExpression toNode = AstFactory.isExpression( 4153 IsExpression toNode = AstFactory.isExpression(
4835 AstFactory.identifier3("x"), 4154 AstFactory.identifier3("x"), false, AstFactory.typeName4("A"));
4836 false,
4837 AstFactory.typeName4("A"));
4838 ResolutionCopier.copyResolutionData(fromNode, toNode); 4155 ResolutionCopier.copyResolutionData(fromNode, toNode);
4839 expect(toNode.propagatedType, same(propagatedType)); 4156 expect(toNode.propagatedType, same(propagatedType));
4840 expect(toNode.staticType, same(staticType)); 4157 expect(toNode.staticType, same(staticType));
4841 } 4158 }
4842 4159
4843 void test_visitLibraryIdentifier() { 4160 void test_visitLibraryIdentifier() {
4844 LibraryIdentifier fromNode = 4161 LibraryIdentifier fromNode =
4845 AstFactory.libraryIdentifier([AstFactory.identifier3("lib")]); 4162 AstFactory.libraryIdentifier([AstFactory.identifier3("lib")]);
4846 DartType propagatedType = ElementFactory.classElement2("C").type; 4163 DartType propagatedType = ElementFactory.classElement2("C").type;
4847 fromNode.propagatedType = propagatedType; 4164 fromNode.propagatedType = propagatedType;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
4925 fromNode.staticType = staticType; 4242 fromNode.staticType = staticType;
4926 ParenthesizedExpression toNode = 4243 ParenthesizedExpression toNode =
4927 AstFactory.parenthesizedExpression(AstFactory.integer(0)); 4244 AstFactory.parenthesizedExpression(AstFactory.integer(0));
4928 ResolutionCopier.copyResolutionData(fromNode, toNode); 4245 ResolutionCopier.copyResolutionData(fromNode, toNode);
4929 expect(toNode.propagatedType, same(propagatedType)); 4246 expect(toNode.propagatedType, same(propagatedType));
4930 expect(toNode.staticType, same(staticType)); 4247 expect(toNode.staticType, same(staticType));
4931 } 4248 }
4932 4249
4933 void test_visitPartDirective() { 4250 void test_visitPartDirective() {
4934 PartDirective fromNode = AstFactory.partDirective2("part.dart"); 4251 PartDirective fromNode = AstFactory.partDirective2("part.dart");
4935 LibraryElement element = 4252 LibraryElement element = new LibraryElementImpl.forNode(
4936 new LibraryElementImpl.forNode(null, AstFactory.libraryIdentifier2(["lib "])); 4253 null, AstFactory.libraryIdentifier2(["lib"]));
4937 fromNode.element = element; 4254 fromNode.element = element;
4938 PartDirective toNode = AstFactory.partDirective2("part.dart"); 4255 PartDirective toNode = AstFactory.partDirective2("part.dart");
4939 ResolutionCopier.copyResolutionData(fromNode, toNode); 4256 ResolutionCopier.copyResolutionData(fromNode, toNode);
4940 expect(toNode.element, same(element)); 4257 expect(toNode.element, same(element));
4941 } 4258 }
4942 4259
4943 void test_visitPartOfDirective() { 4260 void test_visitPartOfDirective() {
4944 PartOfDirective fromNode = 4261 PartOfDirective fromNode =
4945 AstFactory.partOfDirective(AstFactory.libraryIdentifier2(["lib"])); 4262 AstFactory.partOfDirective(AstFactory.libraryIdentifier2(["lib"]));
4946 LibraryElement element = 4263 LibraryElement element = new LibraryElementImpl.forNode(
4947 new LibraryElementImpl.forNode(null, AstFactory.libraryIdentifier2(["lib "])); 4264 null, AstFactory.libraryIdentifier2(["lib"]));
4948 fromNode.element = element; 4265 fromNode.element = element;
4949 PartOfDirective toNode = 4266 PartOfDirective toNode =
4950 AstFactory.partOfDirective(AstFactory.libraryIdentifier2(["lib"])); 4267 AstFactory.partOfDirective(AstFactory.libraryIdentifier2(["lib"]));
4951 ResolutionCopier.copyResolutionData(fromNode, toNode); 4268 ResolutionCopier.copyResolutionData(fromNode, toNode);
4952 expect(toNode.element, same(element)); 4269 expect(toNode.element, same(element));
4953 } 4270 }
4954 4271
4955 void test_visitPostfixExpression() { 4272 void test_visitPostfixExpression() {
4956 String variableName = "x"; 4273 String variableName = "x";
4957 PostfixExpression fromNode = AstFactory.postfixExpression( 4274 PostfixExpression fromNode = AstFactory.postfixExpression(
4958 AstFactory.identifier3(variableName), 4275 AstFactory.identifier3(variableName), TokenType.PLUS_PLUS);
4959 TokenType.PLUS_PLUS); 4276 MethodElement propagatedElement = ElementFactory.methodElement(
4960 MethodElement propagatedElement = 4277 "+", ElementFactory.classElement2("C").type);
4961 ElementFactory.methodElement("+", ElementFactory.classElement2("C").type );
4962 fromNode.propagatedElement = propagatedElement; 4278 fromNode.propagatedElement = propagatedElement;
4963 DartType propagatedType = ElementFactory.classElement2("C").type; 4279 DartType propagatedType = ElementFactory.classElement2("C").type;
4964 fromNode.propagatedType = propagatedType; 4280 fromNode.propagatedType = propagatedType;
4965 MethodElement staticElement = 4281 MethodElement staticElement = ElementFactory.methodElement(
4966 ElementFactory.methodElement("+", ElementFactory.classElement2("C").type ); 4282 "+", ElementFactory.classElement2("C").type);
4967 fromNode.staticElement = staticElement; 4283 fromNode.staticElement = staticElement;
4968 DartType staticType = ElementFactory.classElement2("C").type; 4284 DartType staticType = ElementFactory.classElement2("C").type;
4969 fromNode.staticType = staticType; 4285 fromNode.staticType = staticType;
4970 PostfixExpression toNode = AstFactory.postfixExpression( 4286 PostfixExpression toNode = AstFactory.postfixExpression(
4971 AstFactory.identifier3(variableName), 4287 AstFactory.identifier3(variableName), TokenType.PLUS_PLUS);
4972 TokenType.PLUS_PLUS);
4973 ResolutionCopier.copyResolutionData(fromNode, toNode); 4288 ResolutionCopier.copyResolutionData(fromNode, toNode);
4974 expect(toNode.propagatedElement, same(propagatedElement)); 4289 expect(toNode.propagatedElement, same(propagatedElement));
4975 expect(toNode.propagatedType, same(propagatedType)); 4290 expect(toNode.propagatedType, same(propagatedType));
4976 expect(toNode.staticElement, same(staticElement)); 4291 expect(toNode.staticElement, same(staticElement));
4977 expect(toNode.staticType, same(staticType)); 4292 expect(toNode.staticType, same(staticType));
4978 } 4293 }
4979 4294
4980 void test_visitPrefixedIdentifier() { 4295 void test_visitPrefixedIdentifier() {
4981 PrefixedIdentifier fromNode = AstFactory.identifier5("p", "f"); 4296 PrefixedIdentifier fromNode = AstFactory.identifier5("p", "f");
4982 DartType propagatedType = ElementFactory.classElement2("C").type; 4297 DartType propagatedType = ElementFactory.classElement2("C").type;
4983 fromNode.propagatedType = propagatedType; 4298 fromNode.propagatedType = propagatedType;
4984 DartType staticType = ElementFactory.classElement2("C").type; 4299 DartType staticType = ElementFactory.classElement2("C").type;
4985 fromNode.staticType = staticType; 4300 fromNode.staticType = staticType;
4986 PrefixedIdentifier toNode = AstFactory.identifier5("p", "f"); 4301 PrefixedIdentifier toNode = AstFactory.identifier5("p", "f");
4987 ResolutionCopier.copyResolutionData(fromNode, toNode); 4302 ResolutionCopier.copyResolutionData(fromNode, toNode);
4988 expect(toNode.propagatedType, same(propagatedType)); 4303 expect(toNode.propagatedType, same(propagatedType));
4989 expect(toNode.staticType, same(staticType)); 4304 expect(toNode.staticType, same(staticType));
4990 } 4305 }
4991 4306
4992 void test_visitPrefixExpression() { 4307 void test_visitPrefixExpression() {
4993 PrefixExpression fromNode = 4308 PrefixExpression fromNode = AstFactory.prefixExpression(
4994 AstFactory.prefixExpression(TokenType.PLUS_PLUS, AstFactory.identifier3( "x")); 4309 TokenType.PLUS_PLUS, AstFactory.identifier3("x"));
4995 MethodElement propagatedElement = 4310 MethodElement propagatedElement = ElementFactory.methodElement(
4996 ElementFactory.methodElement("+", ElementFactory.classElement2("C").type ); 4311 "+", ElementFactory.classElement2("C").type);
4997 DartType propagatedType = ElementFactory.classElement2("C").type; 4312 DartType propagatedType = ElementFactory.classElement2("C").type;
4998 fromNode.propagatedElement = propagatedElement; 4313 fromNode.propagatedElement = propagatedElement;
4999 fromNode.propagatedType = propagatedType; 4314 fromNode.propagatedType = propagatedType;
5000 DartType staticType = ElementFactory.classElement2("C").type; 4315 DartType staticType = ElementFactory.classElement2("C").type;
5001 MethodElement staticElement = 4316 MethodElement staticElement = ElementFactory.methodElement(
5002 ElementFactory.methodElement("+", ElementFactory.classElement2("C").type ); 4317 "+", ElementFactory.classElement2("C").type);
5003 fromNode.staticElement = staticElement; 4318 fromNode.staticElement = staticElement;
5004 fromNode.staticType = staticType; 4319 fromNode.staticType = staticType;
5005 PrefixExpression toNode = 4320 PrefixExpression toNode = AstFactory.prefixExpression(
5006 AstFactory.prefixExpression(TokenType.PLUS_PLUS, AstFactory.identifier3( "x")); 4321 TokenType.PLUS_PLUS, AstFactory.identifier3("x"));
5007 ResolutionCopier.copyResolutionData(fromNode, toNode); 4322 ResolutionCopier.copyResolutionData(fromNode, toNode);
5008 expect(toNode.propagatedElement, same(propagatedElement)); 4323 expect(toNode.propagatedElement, same(propagatedElement));
5009 expect(toNode.propagatedType, same(propagatedType)); 4324 expect(toNode.propagatedType, same(propagatedType));
5010 expect(toNode.staticElement, same(staticElement)); 4325 expect(toNode.staticElement, same(staticElement));
5011 expect(toNode.staticType, same(staticType)); 4326 expect(toNode.staticType, same(staticType));
5012 } 4327 }
5013 4328
5014 void test_visitPropertyAccess() { 4329 void test_visitPropertyAccess() {
5015 PropertyAccess fromNode = 4330 PropertyAccess fromNode =
5016 AstFactory.propertyAccess2(AstFactory.identifier3("x"), "y"); 4331 AstFactory.propertyAccess2(AstFactory.identifier3("x"), "y");
5017 DartType propagatedType = ElementFactory.classElement2("C").type; 4332 DartType propagatedType = ElementFactory.classElement2("C").type;
5018 fromNode.propagatedType = propagatedType; 4333 fromNode.propagatedType = propagatedType;
5019 DartType staticType = ElementFactory.classElement2("C").type; 4334 DartType staticType = ElementFactory.classElement2("C").type;
5020 fromNode.staticType = staticType; 4335 fromNode.staticType = staticType;
5021 PropertyAccess toNode = 4336 PropertyAccess toNode =
5022 AstFactory.propertyAccess2(AstFactory.identifier3("x"), "y"); 4337 AstFactory.propertyAccess2(AstFactory.identifier3("x"), "y");
5023 ResolutionCopier.copyResolutionData(fromNode, toNode); 4338 ResolutionCopier.copyResolutionData(fromNode, toNode);
5024 expect(toNode.propagatedType, same(propagatedType)); 4339 expect(toNode.propagatedType, same(propagatedType));
5025 expect(toNode.staticType, same(staticType)); 4340 expect(toNode.staticType, same(staticType));
5026 } 4341 }
5027 4342
5028 void test_visitRedirectingConstructorInvocation() { 4343 void test_visitRedirectingConstructorInvocation() {
5029 RedirectingConstructorInvocation fromNode = 4344 RedirectingConstructorInvocation fromNode =
5030 AstFactory.redirectingConstructorInvocation(); 4345 AstFactory.redirectingConstructorInvocation();
5031 ConstructorElement staticElement = 4346 ConstructorElement staticElement = ElementFactory.constructorElement2(
5032 ElementFactory.constructorElement2(ElementFactory.classElement2("C"), nu ll); 4347 ElementFactory.classElement2("C"), null);
5033 fromNode.staticElement = staticElement; 4348 fromNode.staticElement = staticElement;
5034 RedirectingConstructorInvocation toNode = 4349 RedirectingConstructorInvocation toNode =
5035 AstFactory.redirectingConstructorInvocation(); 4350 AstFactory.redirectingConstructorInvocation();
5036 ResolutionCopier.copyResolutionData(fromNode, toNode); 4351 ResolutionCopier.copyResolutionData(fromNode, toNode);
5037 expect(toNode.staticElement, same(staticElement)); 4352 expect(toNode.staticElement, same(staticElement));
5038 } 4353 }
5039 4354
5040 void test_visitRethrowExpression() { 4355 void test_visitRethrowExpression() {
5041 RethrowExpression fromNode = AstFactory.rethrowExpression(); 4356 RethrowExpression fromNode = AstFactory.rethrowExpression();
5042 DartType propagatedType = ElementFactory.classElement2("C").type; 4357 DartType propagatedType = ElementFactory.classElement2("C").type;
5043 fromNode.propagatedType = propagatedType; 4358 fromNode.propagatedType = propagatedType;
5044 DartType staticType = ElementFactory.classElement2("C").type; 4359 DartType staticType = ElementFactory.classElement2("C").type;
5045 fromNode.staticType = staticType; 4360 fromNode.staticType = staticType;
5046 RethrowExpression toNode = AstFactory.rethrowExpression(); 4361 RethrowExpression toNode = AstFactory.rethrowExpression();
5047 ResolutionCopier.copyResolutionData(fromNode, toNode); 4362 ResolutionCopier.copyResolutionData(fromNode, toNode);
5048 expect(toNode.propagatedType, same(propagatedType)); 4363 expect(toNode.propagatedType, same(propagatedType));
5049 expect(toNode.staticType, same(staticType)); 4364 expect(toNode.staticType, same(staticType));
5050 } 4365 }
5051 4366
5052 void test_visitSimpleIdentifier() { 4367 void test_visitSimpleIdentifier() {
5053 SimpleIdentifier fromNode = AstFactory.identifier3("x"); 4368 SimpleIdentifier fromNode = AstFactory.identifier3("x");
5054 MethodElement propagatedElement = 4369 MethodElement propagatedElement = ElementFactory.methodElement(
5055 ElementFactory.methodElement("m", ElementFactory.classElement2("C").type ); 4370 "m", ElementFactory.classElement2("C").type);
5056 MethodElement staticElement = 4371 MethodElement staticElement = ElementFactory.methodElement(
5057 ElementFactory.methodElement("m", ElementFactory.classElement2("C").type ); 4372 "m", ElementFactory.classElement2("C").type);
5058 AuxiliaryElements auxiliaryElements = 4373 AuxiliaryElements auxiliaryElements =
5059 new AuxiliaryElements(staticElement, propagatedElement); 4374 new AuxiliaryElements(staticElement, propagatedElement);
5060 fromNode.auxiliaryElements = auxiliaryElements; 4375 fromNode.auxiliaryElements = auxiliaryElements;
5061 fromNode.propagatedElement = propagatedElement; 4376 fromNode.propagatedElement = propagatedElement;
5062 DartType propagatedType = ElementFactory.classElement2("C").type; 4377 DartType propagatedType = ElementFactory.classElement2("C").type;
5063 fromNode.propagatedType = propagatedType; 4378 fromNode.propagatedType = propagatedType;
5064 fromNode.staticElement = staticElement; 4379 fromNode.staticElement = staticElement;
5065 DartType staticType = ElementFactory.classElement2("C").type; 4380 DartType staticType = ElementFactory.classElement2("C").type;
5066 fromNode.staticType = staticType; 4381 fromNode.staticType = staticType;
5067 SimpleIdentifier toNode = AstFactory.identifier3("x"); 4382 SimpleIdentifier toNode = AstFactory.identifier3("x");
(...skipping 27 matching lines...) Expand all
5095 StringInterpolation toNode = 4410 StringInterpolation toNode =
5096 AstFactory.string([AstFactory.interpolationString("a", "'a'")]); 4411 AstFactory.string([AstFactory.interpolationString("a", "'a'")]);
5097 ResolutionCopier.copyResolutionData(fromNode, toNode); 4412 ResolutionCopier.copyResolutionData(fromNode, toNode);
5098 expect(toNode.propagatedType, same(propagatedType)); 4413 expect(toNode.propagatedType, same(propagatedType));
5099 expect(toNode.staticType, same(staticType)); 4414 expect(toNode.staticType, same(staticType));
5100 } 4415 }
5101 4416
5102 void test_visitSuperConstructorInvocation() { 4417 void test_visitSuperConstructorInvocation() {
5103 SuperConstructorInvocation fromNode = 4418 SuperConstructorInvocation fromNode =
5104 AstFactory.superConstructorInvocation(); 4419 AstFactory.superConstructorInvocation();
5105 ConstructorElement staticElement = 4420 ConstructorElement staticElement = ElementFactory.constructorElement2(
5106 ElementFactory.constructorElement2(ElementFactory.classElement2("C"), nu ll); 4421 ElementFactory.classElement2("C"), null);
5107 fromNode.staticElement = staticElement; 4422 fromNode.staticElement = staticElement;
5108 SuperConstructorInvocation toNode = AstFactory.superConstructorInvocation(); 4423 SuperConstructorInvocation toNode = AstFactory.superConstructorInvocation();
5109 ResolutionCopier.copyResolutionData(fromNode, toNode); 4424 ResolutionCopier.copyResolutionData(fromNode, toNode);
5110 expect(toNode.staticElement, same(staticElement)); 4425 expect(toNode.staticElement, same(staticElement));
5111 } 4426 }
5112 4427
5113 void test_visitSuperExpression() { 4428 void test_visitSuperExpression() {
5114 SuperExpression fromNode = AstFactory.superExpression(); 4429 SuperExpression fromNode = AstFactory.superExpression();
5115 DartType propagatedType = ElementFactory.classElement2("C").type; 4430 DartType propagatedType = ElementFactory.classElement2("C").type;
5116 fromNode.propagatedType = propagatedType; 4431 fromNode.propagatedType = propagatedType;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
5175 * 4490 *
5176 * More complex tests should be defined in the class [ComplexParserTest]. 4491 * More complex tests should be defined in the class [ComplexParserTest].
5177 */ 4492 */
5178 @reflectiveTest 4493 @reflectiveTest
5179 class SimpleParserTest extends ParserTestCase { 4494 class SimpleParserTest extends ParserTestCase {
5180 void fail_parseAwaitExpression_inSync() { 4495 void fail_parseAwaitExpression_inSync() {
5181 // This test requires better error recovery than we currently have. In 4496 // This test requires better error recovery than we currently have. In
5182 // particular, we need to be able to distinguish between an await expression 4497 // particular, we need to be able to distinguish between an await expression
5183 // in the wrong context, and the use of 'await' as an identifier. 4498 // in the wrong context, and the use of 'await' as an identifier.
5184 MethodDeclaration method = ParserTestCase.parse( 4499 MethodDeclaration method = ParserTestCase.parse(
5185 "parseClassMember", 4500 "parseClassMember", <Object>["C"], "m() { return await x + await y; }");
5186 <Object>["C"],
5187 "m() { return await x + await y; }");
5188 FunctionBody body = method.body; 4501 FunctionBody body = method.body;
5189 EngineTestCase.assertInstanceOf( 4502 EngineTestCase.assertInstanceOf(
5190 (obj) => obj is BlockFunctionBody, 4503 (obj) => obj is BlockFunctionBody, BlockFunctionBody, body);
5191 BlockFunctionBody,
5192 body);
5193 Statement statement = (body as BlockFunctionBody).block.statements[0]; 4504 Statement statement = (body as BlockFunctionBody).block.statements[0];
5194 EngineTestCase.assertInstanceOf( 4505 EngineTestCase.assertInstanceOf(
5195 (obj) => obj is ReturnStatement, 4506 (obj) => obj is ReturnStatement, ReturnStatement, statement);
5196 ReturnStatement,
5197 statement);
5198 Expression expression = (statement as ReturnStatement).expression; 4507 Expression expression = (statement as ReturnStatement).expression;
5199 EngineTestCase.assertInstanceOf( 4508 EngineTestCase.assertInstanceOf(
5200 (obj) => obj is BinaryExpression, 4509 (obj) => obj is BinaryExpression, BinaryExpression, expression);
5201 BinaryExpression, 4510 EngineTestCase.assertInstanceOf((obj) => obj is AwaitExpression,
5202 expression); 4511 AwaitExpression, (expression as BinaryExpression).leftOperand);
5203 EngineTestCase.assertInstanceOf( 4512 EngineTestCase.assertInstanceOf((obj) => obj is AwaitExpression,
5204 (obj) => obj is AwaitExpression, 4513 AwaitExpression, (expression as BinaryExpression).rightOperand);
5205 AwaitExpression,
5206 (expression as BinaryExpression).leftOperand);
5207 EngineTestCase.assertInstanceOf(
5208 (obj) => obj is AwaitExpression,
5209 AwaitExpression,
5210 (expression as BinaryExpression).rightOperand);
5211 } 4514 }
5212 4515
5213 void fail_parseCommentReference_this() { 4516 void fail_parseCommentReference_this() {
5214 // This fails because we are returning null from the method and asserting 4517 // This fails because we are returning null from the method and asserting
5215 // that the return value is not null. 4518 // that the return value is not null.
5216 CommentReference reference = 4519 CommentReference reference =
5217 ParserTestCase.parse("parseCommentReference", <Object>["this", 5], ""); 4520 ParserTestCase.parse("parseCommentReference", <Object>["this", 5], "");
5218 SimpleIdentifier identifier = EngineTestCase.assertInstanceOf( 4521 SimpleIdentifier identifier = EngineTestCase.assertInstanceOf(
5219 (obj) => obj is SimpleIdentifier, 4522 (obj) => obj is SimpleIdentifier, SimpleIdentifier,
5220 SimpleIdentifier,
5221 reference.identifier); 4523 reference.identifier);
5222 expect(identifier.token, isNotNull); 4524 expect(identifier.token, isNotNull);
5223 expect(identifier.name, "a"); 4525 expect(identifier.name, "a");
5224 expect(identifier.offset, 5); 4526 expect(identifier.offset, 5);
5225 } 4527 }
5226 4528
5227 void test_computeStringValue_emptyInterpolationPrefix() { 4529 void test_computeStringValue_emptyInterpolationPrefix() {
5228 expect(_computeStringValue("'''", true, false), ""); 4530 expect(_computeStringValue("'''", true, false), "");
5229 } 4531 }
5230 4532
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
5299 void test_computeStringValue_triple_internalQuote_last_empty() { 4601 void test_computeStringValue_triple_internalQuote_last_empty() {
5300 expect(_computeStringValue("'''", false, true), ""); 4602 expect(_computeStringValue("'''", false, true), "");
5301 } 4603 }
5302 4604
5303 void test_computeStringValue_triple_internalQuote_last_nonEmpty() { 4605 void test_computeStringValue_triple_internalQuote_last_nonEmpty() {
5304 expect(_computeStringValue("text'''", false, true), "text"); 4606 expect(_computeStringValue("text'''", false, true), "text");
5305 } 4607 }
5306 4608
5307 void test_constFactory() { 4609 void test_constFactory() {
5308 ParserTestCase.parse( 4610 ParserTestCase.parse(
5309 "parseClassMember", 4611 "parseClassMember", <Object>["C"], "const factory C() = A;");
5310 <Object>["C"],
5311 "const factory C() = A;");
5312 } 4612 }
5313 4613
5314 void test_createSyntheticIdentifier() { 4614 void test_createSyntheticIdentifier() {
5315 SimpleIdentifier identifier = _createSyntheticIdentifier(); 4615 SimpleIdentifier identifier = _createSyntheticIdentifier();
5316 expect(identifier.isSynthetic, isTrue); 4616 expect(identifier.isSynthetic, isTrue);
5317 } 4617 }
5318 4618
5319 void test_createSyntheticStringLiteral() { 4619 void test_createSyntheticStringLiteral() {
5320 SimpleStringLiteral literal = _createSyntheticStringLiteral(); 4620 SimpleStringLiteral literal = _createSyntheticStringLiteral();
5321 expect(literal.isSynthetic, isTrue); 4621 expect(literal.isSynthetic, isTrue);
5322 } 4622 }
5323 4623
5324 void test_function_literal_allowed_at_toplevel() { 4624 void test_function_literal_allowed_at_toplevel() {
5325 ParserTestCase.parseCompilationUnit("var x = () {};"); 4625 ParserTestCase.parseCompilationUnit("var x = () {};");
5326 } 4626 }
5327 4627
5328 void 4628 void test_function_literal_allowed_in_ArgumentList_in_ConstructorFieldInitiali zer() {
5329 test_function_literal_allowed_in_ArgumentList_in_ConstructorFieldInitializ er() {
5330 ParserTestCase.parseCompilationUnit("class C { C() : a = f(() {}); }"); 4629 ParserTestCase.parseCompilationUnit("class C { C() : a = f(() {}); }");
5331 } 4630 }
5332 4631
5333 void 4632 void test_function_literal_allowed_in_IndexExpression_in_ConstructorFieldIniti alizer() {
5334 test_function_literal_allowed_in_IndexExpression_in_ConstructorFieldInitia lizer() {
5335 ParserTestCase.parseCompilationUnit("class C { C() : a = x[() {}]; }"); 4633 ParserTestCase.parseCompilationUnit("class C { C() : a = x[() {}]; }");
5336 } 4634 }
5337 4635
5338 void 4636 void test_function_literal_allowed_in_ListLiteral_in_ConstructorFieldInitializ er() {
5339 test_function_literal_allowed_in_ListLiteral_in_ConstructorFieldInitialize r() {
5340 ParserTestCase.parseCompilationUnit("class C { C() : a = [() {}]; }"); 4637 ParserTestCase.parseCompilationUnit("class C { C() : a = [() {}]; }");
5341 } 4638 }
5342 4639
5343 void 4640 void test_function_literal_allowed_in_MapLiteral_in_ConstructorFieldInitialize r() {
5344 test_function_literal_allowed_in_MapLiteral_in_ConstructorFieldInitializer () { 4641 ParserTestCase
5345 ParserTestCase.parseCompilationUnit( 4642 .parseCompilationUnit("class C { C() : a = {'key': () {}}; }");
5346 "class C { C() : a = {'key': () {}}; }");
5347 } 4643 }
5348 4644
5349 void 4645 void test_function_literal_allowed_in_ParenthesizedExpression_in_ConstructorFi eldInitializer() {
5350 test_function_literal_allowed_in_ParenthesizedExpression_in_ConstructorFie ldInitializer() {
5351 ParserTestCase.parseCompilationUnit("class C { C() : a = (() {}); }"); 4646 ParserTestCase.parseCompilationUnit("class C { C() : a = (() {}); }");
5352 } 4647 }
5353 4648
5354 void 4649 void test_function_literal_allowed_in_StringInterpolation_in_ConstructorFieldI nitializer() {
5355 test_function_literal_allowed_in_StringInterpolation_in_ConstructorFieldIn itializer() {
5356 ParserTestCase.parseCompilationUnit("class C { C() : a = \"\${(){}}\"; }"); 4650 ParserTestCase.parseCompilationUnit("class C { C() : a = \"\${(){}}\"; }");
5357 } 4651 }
5358 4652
5359 void test_isFunctionDeclaration_nameButNoReturn_block() { 4653 void test_isFunctionDeclaration_nameButNoReturn_block() {
5360 expect(_isFunctionDeclaration("f() {}"), isTrue); 4654 expect(_isFunctionDeclaration("f() {}"), isTrue);
5361 } 4655 }
5362 4656
5363 void test_isFunctionDeclaration_nameButNoReturn_expression() { 4657 void test_isFunctionDeclaration_nameButNoReturn_expression() {
5364 expect(_isFunctionDeclaration("f() => e"), isTrue); 4658 expect(_isFunctionDeclaration("f() => e"), isTrue);
5365 } 4659 }
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
5431 4725
5432 void test_isInitializedVariableDeclaration_assignment() { 4726 void test_isInitializedVariableDeclaration_assignment() {
5433 expect(_isInitializedVariableDeclaration("a = null;"), isFalse); 4727 expect(_isInitializedVariableDeclaration("a = null;"), isFalse);
5434 } 4728 }
5435 4729
5436 void test_isInitializedVariableDeclaration_comparison() { 4730 void test_isInitializedVariableDeclaration_comparison() {
5437 expect(_isInitializedVariableDeclaration("a < 0;"), isFalse); 4731 expect(_isInitializedVariableDeclaration("a < 0;"), isFalse);
5438 } 4732 }
5439 4733
5440 void test_isInitializedVariableDeclaration_conditional() { 4734 void test_isInitializedVariableDeclaration_conditional() {
5441 expect( 4735 expect(_isInitializedVariableDeclaration("a == null ? init() : update();"),
5442 _isInitializedVariableDeclaration("a == null ? init() : update();"),
5443 isFalse); 4736 isFalse);
5444 } 4737 }
5445 4738
5446 void test_isInitializedVariableDeclaration_const_noType_initialized() { 4739 void test_isInitializedVariableDeclaration_const_noType_initialized() {
5447 expect(_isInitializedVariableDeclaration("const a = 0;"), isTrue); 4740 expect(_isInitializedVariableDeclaration("const a = 0;"), isTrue);
5448 } 4741 }
5449 4742
5450 void test_isInitializedVariableDeclaration_const_noType_uninitialized() { 4743 void test_isInitializedVariableDeclaration_const_noType_uninitialized() {
5451 expect(_isInitializedVariableDeclaration("const a;"), isTrue); 4744 expect(_isInitializedVariableDeclaration("const a;"), isTrue);
5452 } 4745 }
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
5524 ParserTestCase.parse4("parseAdditiveExpression", "x + y"); 4817 ParserTestCase.parse4("parseAdditiveExpression", "x + y");
5525 expect(expression.leftOperand, isNotNull); 4818 expect(expression.leftOperand, isNotNull);
5526 expect(expression.operator, isNotNull); 4819 expect(expression.operator, isNotNull);
5527 expect(expression.operator.type, TokenType.PLUS); 4820 expect(expression.operator.type, TokenType.PLUS);
5528 expect(expression.rightOperand, isNotNull); 4821 expect(expression.rightOperand, isNotNull);
5529 } 4822 }
5530 4823
5531 void test_parseAdditiveExpression_super() { 4824 void test_parseAdditiveExpression_super() {
5532 BinaryExpression expression = 4825 BinaryExpression expression =
5533 ParserTestCase.parse4("parseAdditiveExpression", "super + y"); 4826 ParserTestCase.parse4("parseAdditiveExpression", "super + y");
5534 EngineTestCase.assertInstanceOf( 4827 EngineTestCase.assertInstanceOf((obj) => obj is SuperExpression,
5535 (obj) => obj is SuperExpression, 4828 SuperExpression, expression.leftOperand);
5536 SuperExpression,
5537 expression.leftOperand);
5538 expect(expression.operator, isNotNull); 4829 expect(expression.operator, isNotNull);
5539 expect(expression.operator.type, TokenType.PLUS); 4830 expect(expression.operator.type, TokenType.PLUS);
5540 expect(expression.rightOperand, isNotNull); 4831 expect(expression.rightOperand, isNotNull);
5541 } 4832 }
5542 4833
5543 void test_parseAnnotation_n1() { 4834 void test_parseAnnotation_n1() {
5544 Annotation annotation = ParserTestCase.parse4("parseAnnotation", "@A"); 4835 Annotation annotation = ParserTestCase.parse4("parseAnnotation", "@A");
5545 expect(annotation.atSign, isNotNull); 4836 expect(annotation.atSign, isNotNull);
5546 expect(annotation.name, isNotNull); 4837 expect(annotation.name, isNotNull);
5547 expect(annotation.period, isNull); 4838 expect(annotation.period, isNull);
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
5644 AssertStatement statement = 4935 AssertStatement statement =
5645 ParserTestCase.parse4("parseAssertStatement", "assert (x);"); 4936 ParserTestCase.parse4("parseAssertStatement", "assert (x);");
5646 expect(statement.assertKeyword, isNotNull); 4937 expect(statement.assertKeyword, isNotNull);
5647 expect(statement.leftParenthesis, isNotNull); 4938 expect(statement.leftParenthesis, isNotNull);
5648 expect(statement.condition, isNotNull); 4939 expect(statement.condition, isNotNull);
5649 expect(statement.rightParenthesis, isNotNull); 4940 expect(statement.rightParenthesis, isNotNull);
5650 expect(statement.semicolon, isNotNull); 4941 expect(statement.semicolon, isNotNull);
5651 } 4942 }
5652 4943
5653 void test_parseAssignableExpression_expression_args_dot() { 4944 void test_parseAssignableExpression_expression_args_dot() {
5654 PropertyAccess propertyAccess = 4945 PropertyAccess propertyAccess = ParserTestCase.parse(
5655 ParserTestCase.parse("parseAssignableExpression", <Object>[false], "(x)( y).z"); 4946 "parseAssignableExpression", <Object>[false], "(x)(y).z");
5656 FunctionExpressionInvocation invocation = 4947 FunctionExpressionInvocation invocation =
5657 propertyAccess.target as FunctionExpressionInvocation; 4948 propertyAccess.target as FunctionExpressionInvocation;
5658 expect(invocation.function, isNotNull); 4949 expect(invocation.function, isNotNull);
5659 ArgumentList argumentList = invocation.argumentList; 4950 ArgumentList argumentList = invocation.argumentList;
5660 expect(argumentList, isNotNull); 4951 expect(argumentList, isNotNull);
5661 expect(argumentList.arguments, hasLength(1)); 4952 expect(argumentList.arguments, hasLength(1));
5662 expect(propertyAccess.operator, isNotNull); 4953 expect(propertyAccess.operator, isNotNull);
5663 expect(propertyAccess.propertyName, isNotNull); 4954 expect(propertyAccess.propertyName, isNotNull);
5664 } 4955 }
5665 4956
5666 void test_parseAssignableExpression_expression_dot() { 4957 void test_parseAssignableExpression_expression_dot() {
5667 PropertyAccess propertyAccess = 4958 PropertyAccess propertyAccess = ParserTestCase.parse(
5668 ParserTestCase.parse("parseAssignableExpression", <Object>[false], "(x). y"); 4959 "parseAssignableExpression", <Object>[false], "(x).y");
5669 expect(propertyAccess.target, isNotNull); 4960 expect(propertyAccess.target, isNotNull);
5670 expect(propertyAccess.operator, isNotNull); 4961 expect(propertyAccess.operator, isNotNull);
5671 expect(propertyAccess.propertyName, isNotNull); 4962 expect(propertyAccess.propertyName, isNotNull);
5672 } 4963 }
5673 4964
5674 void test_parseAssignableExpression_expression_index() { 4965 void test_parseAssignableExpression_expression_index() {
5675 IndexExpression expression = 4966 IndexExpression expression = ParserTestCase.parse(
5676 ParserTestCase.parse("parseAssignableExpression", <Object>[false], "(x)[ y]"); 4967 "parseAssignableExpression", <Object>[false], "(x)[y]");
5677 expect(expression.target, isNotNull); 4968 expect(expression.target, isNotNull);
5678 expect(expression.leftBracket, isNotNull); 4969 expect(expression.leftBracket, isNotNull);
5679 expect(expression.index, isNotNull); 4970 expect(expression.index, isNotNull);
5680 expect(expression.rightBracket, isNotNull); 4971 expect(expression.rightBracket, isNotNull);
5681 } 4972 }
5682 4973
5683 void test_parseAssignableExpression_identifier() { 4974 void test_parseAssignableExpression_identifier() {
5684 SimpleIdentifier identifier = 4975 SimpleIdentifier identifier =
5685 ParserTestCase.parse("parseAssignableExpression", <Object>[false], "x"); 4976 ParserTestCase.parse("parseAssignableExpression", <Object>[false], "x");
5686 expect(identifier, isNotNull); 4977 expect(identifier, isNotNull);
5687 } 4978 }
5688 4979
5689 void test_parseAssignableExpression_identifier_args_dot() { 4980 void test_parseAssignableExpression_identifier_args_dot() {
5690 PropertyAccess propertyAccess = 4981 PropertyAccess propertyAccess = ParserTestCase.parse(
5691 ParserTestCase.parse("parseAssignableExpression", <Object>[false], "x(y) .z"); 4982 "parseAssignableExpression", <Object>[false], "x(y).z");
5692 MethodInvocation invocation = propertyAccess.target as MethodInvocation; 4983 MethodInvocation invocation = propertyAccess.target as MethodInvocation;
5693 expect(invocation.methodName.name, "x"); 4984 expect(invocation.methodName.name, "x");
5694 ArgumentList argumentList = invocation.argumentList; 4985 ArgumentList argumentList = invocation.argumentList;
5695 expect(argumentList, isNotNull); 4986 expect(argumentList, isNotNull);
5696 expect(argumentList.arguments, hasLength(1)); 4987 expect(argumentList.arguments, hasLength(1));
5697 expect(propertyAccess.operator, isNotNull); 4988 expect(propertyAccess.operator, isNotNull);
5698 expect(propertyAccess.propertyName, isNotNull); 4989 expect(propertyAccess.propertyName, isNotNull);
5699 } 4990 }
5700 4991
5701 void test_parseAssignableExpression_identifier_dot() { 4992 void test_parseAssignableExpression_identifier_dot() {
5702 PropertyAccess propertyAccess = 4993 PropertyAccess propertyAccess = ParserTestCase.parse(
5703 ParserTestCase.parse("parseAssignableExpression", <Object>[false], "x.y" ); 4994 "parseAssignableExpression", <Object>[false], "x.y");
5704 expect(propertyAccess.target, isNotNull); 4995 expect(propertyAccess.target, isNotNull);
5705 expect(propertyAccess.operator, isNotNull); 4996 expect(propertyAccess.operator, isNotNull);
5706 expect(propertyAccess.propertyName, isNotNull); 4997 expect(propertyAccess.propertyName, isNotNull);
5707 } 4998 }
5708 4999
5709 void test_parseAssignableExpression_identifier_index() { 5000 void test_parseAssignableExpression_identifier_index() {
5710 IndexExpression expression = 5001 IndexExpression expression = ParserTestCase.parse(
5711 ParserTestCase.parse("parseAssignableExpression", <Object>[false], "x[y] "); 5002 "parseAssignableExpression", <Object>[false], "x[y]");
5712 expect(expression.target, isNotNull); 5003 expect(expression.target, isNotNull);
5713 expect(expression.leftBracket, isNotNull); 5004 expect(expression.leftBracket, isNotNull);
5714 expect(expression.index, isNotNull); 5005 expect(expression.index, isNotNull);
5715 expect(expression.rightBracket, isNotNull); 5006 expect(expression.rightBracket, isNotNull);
5716 } 5007 }
5717 5008
5718 void test_parseAssignableExpression_super_dot() { 5009 void test_parseAssignableExpression_super_dot() {
5719 PropertyAccess propertyAccess = 5010 PropertyAccess propertyAccess = ParserTestCase.parse(
5720 ParserTestCase.parse("parseAssignableExpression", <Object>[false], "supe r.y"); 5011 "parseAssignableExpression", <Object>[false], "super.y");
5721 EngineTestCase.assertInstanceOf( 5012 EngineTestCase.assertInstanceOf((obj) => obj is SuperExpression,
5722 (obj) => obj is SuperExpression, 5013 SuperExpression, propertyAccess.target);
5723 SuperExpression,
5724 propertyAccess.target);
5725 expect(propertyAccess.operator, isNotNull); 5014 expect(propertyAccess.operator, isNotNull);
5726 expect(propertyAccess.propertyName, isNotNull); 5015 expect(propertyAccess.propertyName, isNotNull);
5727 } 5016 }
5728 5017
5729 void test_parseAssignableExpression_super_index() { 5018 void test_parseAssignableExpression_super_index() {
5730 IndexExpression expression = 5019 IndexExpression expression = ParserTestCase.parse(
5731 ParserTestCase.parse("parseAssignableExpression", <Object>[false], "supe r[y]"); 5020 "parseAssignableExpression", <Object>[false], "super[y]");
5732 EngineTestCase.assertInstanceOf( 5021 EngineTestCase.assertInstanceOf(
5733 (obj) => obj is SuperExpression, 5022 (obj) => obj is SuperExpression, SuperExpression, expression.target);
5734 SuperExpression,
5735 expression.target);
5736 expect(expression.leftBracket, isNotNull); 5023 expect(expression.leftBracket, isNotNull);
5737 expect(expression.index, isNotNull); 5024 expect(expression.index, isNotNull);
5738 expect(expression.rightBracket, isNotNull); 5025 expect(expression.rightBracket, isNotNull);
5739 } 5026 }
5740 5027
5741 void test_parseAssignableSelector_dot() { 5028 void test_parseAssignableSelector_dot() {
5742 PropertyAccess selector = 5029 PropertyAccess selector = ParserTestCase.parse(
5743 ParserTestCase.parse("parseAssignableSelector", <Object>[null, true], ". x"); 5030 "parseAssignableSelector", <Object>[null, true], ".x");
5744 expect(selector.operator, isNotNull); 5031 expect(selector.operator, isNotNull);
5745 expect(selector.propertyName, isNotNull); 5032 expect(selector.propertyName, isNotNull);
5746 } 5033 }
5747 5034
5748 void test_parseAssignableSelector_index() { 5035 void test_parseAssignableSelector_index() {
5749 IndexExpression selector = 5036 IndexExpression selector = ParserTestCase.parse(
5750 ParserTestCase.parse("parseAssignableSelector", <Object>[null, true], "[ x]"); 5037 "parseAssignableSelector", <Object>[null, true], "[x]");
5751 expect(selector.leftBracket, isNotNull); 5038 expect(selector.leftBracket, isNotNull);
5752 expect(selector.index, isNotNull); 5039 expect(selector.index, isNotNull);
5753 expect(selector.rightBracket, isNotNull); 5040 expect(selector.rightBracket, isNotNull);
5754 } 5041 }
5755 5042
5756 void test_parseAssignableSelector_none() { 5043 void test_parseAssignableSelector_none() {
5757 SimpleIdentifier selector = ParserTestCase.parse( 5044 SimpleIdentifier selector = ParserTestCase.parse("parseAssignableSelector",
5758 "parseAssignableSelector", 5045 <Object>[new SimpleIdentifier(null), true], ";");
5759 <Object>[new SimpleIdentifier(null), true],
5760 ";");
5761 expect(selector, isNotNull); 5046 expect(selector, isNotNull);
5762 } 5047 }
5763 5048
5764 void test_parseAwaitExpression() { 5049 void test_parseAwaitExpression() {
5765 AwaitExpression expression = 5050 AwaitExpression expression =
5766 ParserTestCase.parse4("parseAwaitExpression", "await x;"); 5051 ParserTestCase.parse4("parseAwaitExpression", "await x;");
5767 expect(expression.awaitKeyword, isNotNull); 5052 expect(expression.awaitKeyword, isNotNull);
5768 expect(expression.expression, isNotNull); 5053 expect(expression.expression, isNotNull);
5769 } 5054 }
5770 5055
5771 void test_parseAwaitExpression_asStatement_inAsync() { 5056 void test_parseAwaitExpression_asStatement_inAsync() {
5772 MethodDeclaration method = ParserTestCase.parse( 5057 MethodDeclaration method = ParserTestCase.parse(
5773 "parseClassMember", 5058 "parseClassMember", <Object>["C"], "m() async { await x; }");
5774 <Object>["C"],
5775 "m() async { await x; }");
5776 FunctionBody body = method.body; 5059 FunctionBody body = method.body;
5777 EngineTestCase.assertInstanceOf( 5060 EngineTestCase.assertInstanceOf(
5778 (obj) => obj is BlockFunctionBody, 5061 (obj) => obj is BlockFunctionBody, BlockFunctionBody, body);
5779 BlockFunctionBody,
5780 body);
5781 Statement statement = (body as BlockFunctionBody).block.statements[0]; 5062 Statement statement = (body as BlockFunctionBody).block.statements[0];
5782 EngineTestCase.assertInstanceOf( 5063 EngineTestCase.assertInstanceOf(
5783 (obj) => obj is ExpressionStatement, 5064 (obj) => obj is ExpressionStatement, ExpressionStatement, statement);
5784 ExpressionStatement,
5785 statement);
5786 Expression expression = (statement as ExpressionStatement).expression; 5065 Expression expression = (statement as ExpressionStatement).expression;
5787 EngineTestCase.assertInstanceOf( 5066 EngineTestCase.assertInstanceOf(
5788 (obj) => obj is AwaitExpression, 5067 (obj) => obj is AwaitExpression, AwaitExpression, expression);
5789 AwaitExpression,
5790 expression);
5791 expect((expression as AwaitExpression).awaitKeyword, isNotNull); 5068 expect((expression as AwaitExpression).awaitKeyword, isNotNull);
5792 expect((expression as AwaitExpression).expression, isNotNull); 5069 expect((expression as AwaitExpression).expression, isNotNull);
5793 } 5070 }
5794 5071
5795 void test_parseAwaitExpression_asStatement_inSync() { 5072 void test_parseAwaitExpression_asStatement_inSync() {
5796 MethodDeclaration method = 5073 MethodDeclaration method = ParserTestCase.parse(
5797 ParserTestCase.parse("parseClassMember", <Object>["C"], "m() { await x; }"); 5074 "parseClassMember", <Object>["C"], "m() { await x; }");
5798 FunctionBody body = method.body; 5075 FunctionBody body = method.body;
5799 EngineTestCase.assertInstanceOf( 5076 EngineTestCase.assertInstanceOf(
5800 (obj) => obj is BlockFunctionBody, 5077 (obj) => obj is BlockFunctionBody, BlockFunctionBody, body);
5801 BlockFunctionBody,
5802 body);
5803 Statement statement = (body as BlockFunctionBody).block.statements[0]; 5078 Statement statement = (body as BlockFunctionBody).block.statements[0];
5804 EngineTestCase.assertInstanceOf( 5079 EngineTestCase.assertInstanceOf(
5805 (obj) => obj is VariableDeclarationStatement, 5080 (obj) => obj is VariableDeclarationStatement,
5806 VariableDeclarationStatement, 5081 VariableDeclarationStatement, statement);
5807 statement);
5808 } 5082 }
5809 5083
5810 void test_parseBitwiseAndExpression_normal() { 5084 void test_parseBitwiseAndExpression_normal() {
5811 BinaryExpression expression = 5085 BinaryExpression expression =
5812 ParserTestCase.parse4("parseBitwiseAndExpression", "x & y"); 5086 ParserTestCase.parse4("parseBitwiseAndExpression", "x & y");
5813 expect(expression.leftOperand, isNotNull); 5087 expect(expression.leftOperand, isNotNull);
5814 expect(expression.operator, isNotNull); 5088 expect(expression.operator, isNotNull);
5815 expect(expression.operator.type, TokenType.AMPERSAND); 5089 expect(expression.operator.type, TokenType.AMPERSAND);
5816 expect(expression.rightOperand, isNotNull); 5090 expect(expression.rightOperand, isNotNull);
5817 } 5091 }
5818 5092
5819 void test_parseBitwiseAndExpression_super() { 5093 void test_parseBitwiseAndExpression_super() {
5820 BinaryExpression expression = 5094 BinaryExpression expression =
5821 ParserTestCase.parse4("parseBitwiseAndExpression", "super & y"); 5095 ParserTestCase.parse4("parseBitwiseAndExpression", "super & y");
5822 EngineTestCase.assertInstanceOf( 5096 EngineTestCase.assertInstanceOf((obj) => obj is SuperExpression,
5823 (obj) => obj is SuperExpression, 5097 SuperExpression, expression.leftOperand);
5824 SuperExpression,
5825 expression.leftOperand);
5826 expect(expression.operator, isNotNull); 5098 expect(expression.operator, isNotNull);
5827 expect(expression.operator.type, TokenType.AMPERSAND); 5099 expect(expression.operator.type, TokenType.AMPERSAND);
5828 expect(expression.rightOperand, isNotNull); 5100 expect(expression.rightOperand, isNotNull);
5829 } 5101 }
5830 5102
5831 void test_parseBitwiseOrExpression_normal() { 5103 void test_parseBitwiseOrExpression_normal() {
5832 BinaryExpression expression = 5104 BinaryExpression expression =
5833 ParserTestCase.parse4("parseBitwiseOrExpression", "x | y"); 5105 ParserTestCase.parse4("parseBitwiseOrExpression", "x | y");
5834 expect(expression.leftOperand, isNotNull); 5106 expect(expression.leftOperand, isNotNull);
5835 expect(expression.operator, isNotNull); 5107 expect(expression.operator, isNotNull);
5836 expect(expression.operator.type, TokenType.BAR); 5108 expect(expression.operator.type, TokenType.BAR);
5837 expect(expression.rightOperand, isNotNull); 5109 expect(expression.rightOperand, isNotNull);
5838 } 5110 }
5839 5111
5840 void test_parseBitwiseOrExpression_super() { 5112 void test_parseBitwiseOrExpression_super() {
5841 BinaryExpression expression = 5113 BinaryExpression expression =
5842 ParserTestCase.parse4("parseBitwiseOrExpression", "super | y"); 5114 ParserTestCase.parse4("parseBitwiseOrExpression", "super | y");
5843 EngineTestCase.assertInstanceOf( 5115 EngineTestCase.assertInstanceOf((obj) => obj is SuperExpression,
5844 (obj) => obj is SuperExpression, 5116 SuperExpression, expression.leftOperand);
5845 SuperExpression,
5846 expression.leftOperand);
5847 expect(expression.operator, isNotNull); 5117 expect(expression.operator, isNotNull);
5848 expect(expression.operator.type, TokenType.BAR); 5118 expect(expression.operator.type, TokenType.BAR);
5849 expect(expression.rightOperand, isNotNull); 5119 expect(expression.rightOperand, isNotNull);
5850 } 5120 }
5851 5121
5852 void test_parseBitwiseXorExpression_normal() { 5122 void test_parseBitwiseXorExpression_normal() {
5853 BinaryExpression expression = 5123 BinaryExpression expression =
5854 ParserTestCase.parse4("parseBitwiseXorExpression", "x ^ y"); 5124 ParserTestCase.parse4("parseBitwiseXorExpression", "x ^ y");
5855 expect(expression.leftOperand, isNotNull); 5125 expect(expression.leftOperand, isNotNull);
5856 expect(expression.operator, isNotNull); 5126 expect(expression.operator, isNotNull);
5857 expect(expression.operator.type, TokenType.CARET); 5127 expect(expression.operator.type, TokenType.CARET);
5858 expect(expression.rightOperand, isNotNull); 5128 expect(expression.rightOperand, isNotNull);
5859 } 5129 }
5860 5130
5861 void test_parseBitwiseXorExpression_super() { 5131 void test_parseBitwiseXorExpression_super() {
5862 BinaryExpression expression = 5132 BinaryExpression expression =
5863 ParserTestCase.parse4("parseBitwiseXorExpression", "super ^ y"); 5133 ParserTestCase.parse4("parseBitwiseXorExpression", "super ^ y");
5864 EngineTestCase.assertInstanceOf( 5134 EngineTestCase.assertInstanceOf((obj) => obj is SuperExpression,
5865 (obj) => obj is SuperExpression, 5135 SuperExpression, expression.leftOperand);
5866 SuperExpression,
5867 expression.leftOperand);
5868 expect(expression.operator, isNotNull); 5136 expect(expression.operator, isNotNull);
5869 expect(expression.operator.type, TokenType.CARET); 5137 expect(expression.operator.type, TokenType.CARET);
5870 expect(expression.rightOperand, isNotNull); 5138 expect(expression.rightOperand, isNotNull);
5871 } 5139 }
5872 5140
5873 void test_parseBlock_empty() { 5141 void test_parseBlock_empty() {
5874 Block block = ParserTestCase.parse4("parseBlock", "{}"); 5142 Block block = ParserTestCase.parse4("parseBlock", "{}");
5875 expect(block.leftBracket, isNotNull); 5143 expect(block.leftBracket, isNotNull);
5876 expect(block.statements, hasLength(0)); 5144 expect(block.statements, hasLength(0));
5877 expect(block.rightBracket, isNotNull); 5145 expect(block.rightBracket, isNotNull);
5878 } 5146 }
5879 5147
5880 void test_parseBlock_nonEmpty() { 5148 void test_parseBlock_nonEmpty() {
5881 Block block = ParserTestCase.parse4("parseBlock", "{;}"); 5149 Block block = ParserTestCase.parse4("parseBlock", "{;}");
5882 expect(block.leftBracket, isNotNull); 5150 expect(block.leftBracket, isNotNull);
5883 expect(block.statements, hasLength(1)); 5151 expect(block.statements, hasLength(1));
5884 expect(block.rightBracket, isNotNull); 5152 expect(block.rightBracket, isNotNull);
5885 } 5153 }
5886 5154
5887 void test_parseBreakStatement_label() { 5155 void test_parseBreakStatement_label() {
5888 BreakStatement statement = 5156 BreakStatement statement =
5889 ParserTestCase.parse4("parseBreakStatement", "break foo;"); 5157 ParserTestCase.parse4("parseBreakStatement", "break foo;");
5890 expect(statement.breakKeyword, isNotNull); 5158 expect(statement.breakKeyword, isNotNull);
5891 expect(statement.label, isNotNull); 5159 expect(statement.label, isNotNull);
5892 expect(statement.semicolon, isNotNull); 5160 expect(statement.semicolon, isNotNull);
5893 } 5161 }
5894 5162
5895 void test_parseBreakStatement_noLabel() { 5163 void test_parseBreakStatement_noLabel() {
5896 BreakStatement statement = ParserTestCase.parse4( 5164 BreakStatement statement = ParserTestCase.parse4("parseBreakStatement",
5897 "parseBreakStatement", 5165 "break;", [ParserErrorCode.BREAK_OUTSIDE_OF_LOOP]);
5898 "break;",
5899 [ParserErrorCode.BREAK_OUTSIDE_OF_LOOP]);
5900 expect(statement.breakKeyword, isNotNull); 5166 expect(statement.breakKeyword, isNotNull);
5901 expect(statement.label, isNull); 5167 expect(statement.label, isNull);
5902 expect(statement.semicolon, isNotNull); 5168 expect(statement.semicolon, isNotNull);
5903 } 5169 }
5904 5170
5905 void test_parseCascadeSection_i() { 5171 void test_parseCascadeSection_i() {
5906 IndexExpression section = 5172 IndexExpression section =
5907 ParserTestCase.parse4("parseCascadeSection", "..[i]"); 5173 ParserTestCase.parse4("parseCascadeSection", "..[i]");
5908 expect(section.target, isNull); 5174 expect(section.target, isNull);
5909 expect(section.leftBracket, isNotNull); 5175 expect(section.leftBracket, isNotNull);
5910 expect(section.index, isNotNull); 5176 expect(section.index, isNotNull);
5911 expect(section.rightBracket, isNotNull); 5177 expect(section.rightBracket, isNotNull);
5912 } 5178 }
5913 5179
5914 void test_parseCascadeSection_ia() { 5180 void test_parseCascadeSection_ia() {
5915 FunctionExpressionInvocation section = 5181 FunctionExpressionInvocation section =
5916 ParserTestCase.parse4("parseCascadeSection", "..[i](b)"); 5182 ParserTestCase.parse4("parseCascadeSection", "..[i](b)");
5917 EngineTestCase.assertInstanceOf( 5183 EngineTestCase.assertInstanceOf(
5918 (obj) => obj is IndexExpression, 5184 (obj) => obj is IndexExpression, IndexExpression, section.function);
5919 IndexExpression,
5920 section.function);
5921 expect(section.argumentList, isNotNull); 5185 expect(section.argumentList, isNotNull);
5922 } 5186 }
5923 5187
5924 void test_parseCascadeSection_ii() { 5188 void test_parseCascadeSection_ii() {
5925 MethodInvocation section = 5189 MethodInvocation section =
5926 ParserTestCase.parse4("parseCascadeSection", "..a(b).c(d)"); 5190 ParserTestCase.parse4("parseCascadeSection", "..a(b).c(d)");
5927 EngineTestCase.assertInstanceOf( 5191 EngineTestCase.assertInstanceOf(
5928 (obj) => obj is MethodInvocation, 5192 (obj) => obj is MethodInvocation, MethodInvocation, section.target);
5929 MethodInvocation,
5930 section.target);
5931 expect(section.period, isNotNull); 5193 expect(section.period, isNotNull);
5932 expect(section.methodName, isNotNull); 5194 expect(section.methodName, isNotNull);
5933 expect(section.argumentList, isNotNull); 5195 expect(section.argumentList, isNotNull);
5934 expect(section.argumentList.arguments, hasLength(1)); 5196 expect(section.argumentList.arguments, hasLength(1));
5935 } 5197 }
5936 5198
5937 void test_parseCascadeSection_p() { 5199 void test_parseCascadeSection_p() {
5938 PropertyAccess section = 5200 PropertyAccess section =
5939 ParserTestCase.parse4("parseCascadeSection", "..a"); 5201 ParserTestCase.parse4("parseCascadeSection", "..a");
5940 expect(section.target, isNull); 5202 expect(section.target, isNull);
5941 expect(section.operator, isNotNull); 5203 expect(section.operator, isNotNull);
5942 expect(section.propertyName, isNotNull); 5204 expect(section.propertyName, isNotNull);
5943 } 5205 }
5944 5206
5945 void test_parseCascadeSection_p_assign() { 5207 void test_parseCascadeSection_p_assign() {
5946 AssignmentExpression section = 5208 AssignmentExpression section =
5947 ParserTestCase.parse4("parseCascadeSection", "..a = 3"); 5209 ParserTestCase.parse4("parseCascadeSection", "..a = 3");
5948 expect(section.leftHandSide, isNotNull); 5210 expect(section.leftHandSide, isNotNull);
5949 expect(section.operator, isNotNull); 5211 expect(section.operator, isNotNull);
5950 Expression rhs = section.rightHandSide; 5212 Expression rhs = section.rightHandSide;
5951 expect(rhs, isNotNull); 5213 expect(rhs, isNotNull);
5952 } 5214 }
5953 5215
5954 void test_parseCascadeSection_p_assign_withCascade() { 5216 void test_parseCascadeSection_p_assign_withCascade() {
5955 AssignmentExpression section = 5217 AssignmentExpression section =
5956 ParserTestCase.parse4("parseCascadeSection", "..a = 3..m()"); 5218 ParserTestCase.parse4("parseCascadeSection", "..a = 3..m()");
5957 expect(section.leftHandSide, isNotNull); 5219 expect(section.leftHandSide, isNotNull);
5958 expect(section.operator, isNotNull); 5220 expect(section.operator, isNotNull);
5959 Expression rhs = section.rightHandSide; 5221 Expression rhs = section.rightHandSide;
5960 EngineTestCase.assertInstanceOf( 5222 EngineTestCase
5961 (obj) => obj is IntegerLiteral, 5223 .assertInstanceOf((obj) => obj is IntegerLiteral, IntegerLiteral, rhs);
5962 IntegerLiteral,
5963 rhs);
5964 } 5224 }
5965 5225
5966 void test_parseCascadeSection_p_builtIn() { 5226 void test_parseCascadeSection_p_builtIn() {
5967 PropertyAccess section = 5227 PropertyAccess section =
5968 ParserTestCase.parse4("parseCascadeSection", "..as"); 5228 ParserTestCase.parse4("parseCascadeSection", "..as");
5969 expect(section.target, isNull); 5229 expect(section.target, isNull);
5970 expect(section.operator, isNotNull); 5230 expect(section.operator, isNotNull);
5971 expect(section.propertyName, isNotNull); 5231 expect(section.propertyName, isNotNull);
5972 } 5232 }
5973 5233
5974 void test_parseCascadeSection_pa() { 5234 void test_parseCascadeSection_pa() {
5975 MethodInvocation section = 5235 MethodInvocation section =
5976 ParserTestCase.parse4("parseCascadeSection", "..a(b)"); 5236 ParserTestCase.parse4("parseCascadeSection", "..a(b)");
5977 expect(section.target, isNull); 5237 expect(section.target, isNull);
5978 expect(section.period, isNotNull); 5238 expect(section.period, isNotNull);
5979 expect(section.methodName, isNotNull); 5239 expect(section.methodName, isNotNull);
5980 expect(section.argumentList, isNotNull); 5240 expect(section.argumentList, isNotNull);
5981 expect(section.argumentList.arguments, hasLength(1)); 5241 expect(section.argumentList.arguments, hasLength(1));
5982 } 5242 }
5983 5243
5984 void test_parseCascadeSection_paa() { 5244 void test_parseCascadeSection_paa() {
5985 FunctionExpressionInvocation section = 5245 FunctionExpressionInvocation section =
5986 ParserTestCase.parse4("parseCascadeSection", "..a(b)(c)"); 5246 ParserTestCase.parse4("parseCascadeSection", "..a(b)(c)");
5987 EngineTestCase.assertInstanceOf( 5247 EngineTestCase.assertInstanceOf(
5988 (obj) => obj is MethodInvocation, 5248 (obj) => obj is MethodInvocation, MethodInvocation, section.function);
5989 MethodInvocation,
5990 section.function);
5991 expect(section.argumentList, isNotNull); 5249 expect(section.argumentList, isNotNull);
5992 expect(section.argumentList.arguments, hasLength(1)); 5250 expect(section.argumentList.arguments, hasLength(1));
5993 } 5251 }
5994 5252
5995 void test_parseCascadeSection_paapaa() { 5253 void test_parseCascadeSection_paapaa() {
5996 FunctionExpressionInvocation section = 5254 FunctionExpressionInvocation section =
5997 ParserTestCase.parse4("parseCascadeSection", "..a(b)(c).d(e)(f)"); 5255 ParserTestCase.parse4("parseCascadeSection", "..a(b)(c).d(e)(f)");
5998 EngineTestCase.assertInstanceOf( 5256 EngineTestCase.assertInstanceOf(
5999 (obj) => obj is MethodInvocation, 5257 (obj) => obj is MethodInvocation, MethodInvocation, section.function);
6000 MethodInvocation,
6001 section.function);
6002 expect(section.argumentList, isNotNull); 5258 expect(section.argumentList, isNotNull);
6003 expect(section.argumentList.arguments, hasLength(1)); 5259 expect(section.argumentList.arguments, hasLength(1));
6004 } 5260 }
6005 5261
6006 void test_parseCascadeSection_pap() { 5262 void test_parseCascadeSection_pap() {
6007 PropertyAccess section = 5263 PropertyAccess section =
6008 ParserTestCase.parse4("parseCascadeSection", "..a(b).c"); 5264 ParserTestCase.parse4("parseCascadeSection", "..a(b).c");
6009 expect(section.target, isNotNull); 5265 expect(section.target, isNotNull);
6010 expect(section.operator, isNotNull); 5266 expect(section.operator, isNotNull);
6011 expect(section.propertyName, isNotNull); 5267 expect(section.propertyName, isNotNull);
6012 } 5268 }
6013 5269
6014 void test_parseClassDeclaration_abstract() { 5270 void test_parseClassDeclaration_abstract() {
6015 ClassDeclaration declaration = ParserTestCase.parse( 5271 ClassDeclaration declaration = ParserTestCase.parse("parseClassDeclaration",
6016 "parseClassDeclaration",
6017 <Object>[ 5272 <Object>[
6018 emptyCommentAndMetadata(), 5273 emptyCommentAndMetadata(),
6019 TokenFactory.tokenFromKeyword(Keyword.ABSTRACT)], 5274 TokenFactory.tokenFromKeyword(Keyword.ABSTRACT)
6020 "class A {}"); 5275 ], "class A {}");
6021 expect(declaration.documentationComment, isNull); 5276 expect(declaration.documentationComment, isNull);
6022 expect(declaration.abstractKeyword, isNotNull); 5277 expect(declaration.abstractKeyword, isNotNull);
6023 expect(declaration.extendsClause, isNull); 5278 expect(declaration.extendsClause, isNull);
6024 expect(declaration.implementsClause, isNull); 5279 expect(declaration.implementsClause, isNull);
6025 expect(declaration.classKeyword, isNotNull); 5280 expect(declaration.classKeyword, isNotNull);
6026 expect(declaration.leftBracket, isNotNull); 5281 expect(declaration.leftBracket, isNotNull);
6027 expect(declaration.name, isNotNull); 5282 expect(declaration.name, isNotNull);
6028 expect(declaration.members, hasLength(0)); 5283 expect(declaration.members, hasLength(0));
6029 expect(declaration.rightBracket, isNotNull); 5284 expect(declaration.rightBracket, isNotNull);
6030 expect(declaration.typeParameters, isNull); 5285 expect(declaration.typeParameters, isNull);
6031 } 5286 }
6032 5287
6033 void test_parseClassDeclaration_empty() { 5288 void test_parseClassDeclaration_empty() {
6034 ClassDeclaration declaration = ParserTestCase.parse( 5289 ClassDeclaration declaration = ParserTestCase.parse("parseClassDeclaration",
6035 "parseClassDeclaration", 5290 <Object>[emptyCommentAndMetadata(), null], "class A {}");
6036 <Object>[emptyCommentAndMetadata(), null],
6037 "class A {}");
6038 expect(declaration.documentationComment, isNull); 5291 expect(declaration.documentationComment, isNull);
6039 expect(declaration.abstractKeyword, isNull); 5292 expect(declaration.abstractKeyword, isNull);
6040 expect(declaration.extendsClause, isNull); 5293 expect(declaration.extendsClause, isNull);
6041 expect(declaration.implementsClause, isNull); 5294 expect(declaration.implementsClause, isNull);
6042 expect(declaration.classKeyword, isNotNull); 5295 expect(declaration.classKeyword, isNotNull);
6043 expect(declaration.leftBracket, isNotNull); 5296 expect(declaration.leftBracket, isNotNull);
6044 expect(declaration.name, isNotNull); 5297 expect(declaration.name, isNotNull);
6045 expect(declaration.members, hasLength(0)); 5298 expect(declaration.members, hasLength(0));
6046 expect(declaration.rightBracket, isNotNull); 5299 expect(declaration.rightBracket, isNotNull);
6047 expect(declaration.typeParameters, isNull); 5300 expect(declaration.typeParameters, isNull);
6048 } 5301 }
6049 5302
6050 void test_parseClassDeclaration_extends() { 5303 void test_parseClassDeclaration_extends() {
6051 ClassDeclaration declaration = ParserTestCase.parse( 5304 ClassDeclaration declaration = ParserTestCase.parse("parseClassDeclaration",
6052 "parseClassDeclaration", 5305 <Object>[emptyCommentAndMetadata(), null], "class A extends B {}");
6053 <Object>[emptyCommentAndMetadata(), null],
6054 "class A extends B {}");
6055 expect(declaration.documentationComment, isNull); 5306 expect(declaration.documentationComment, isNull);
6056 expect(declaration.abstractKeyword, isNull); 5307 expect(declaration.abstractKeyword, isNull);
6057 expect(declaration.extendsClause, isNotNull); 5308 expect(declaration.extendsClause, isNotNull);
6058 expect(declaration.implementsClause, isNull); 5309 expect(declaration.implementsClause, isNull);
6059 expect(declaration.classKeyword, isNotNull); 5310 expect(declaration.classKeyword, isNotNull);
6060 expect(declaration.leftBracket, isNotNull); 5311 expect(declaration.leftBracket, isNotNull);
6061 expect(declaration.name, isNotNull); 5312 expect(declaration.name, isNotNull);
6062 expect(declaration.members, hasLength(0)); 5313 expect(declaration.members, hasLength(0));
6063 expect(declaration.rightBracket, isNotNull); 5314 expect(declaration.rightBracket, isNotNull);
6064 expect(declaration.typeParameters, isNull); 5315 expect(declaration.typeParameters, isNull);
6065 } 5316 }
6066 5317
6067 void test_parseClassDeclaration_extendsAndImplements() { 5318 void test_parseClassDeclaration_extendsAndImplements() {
6068 ClassDeclaration declaration = ParserTestCase.parse( 5319 ClassDeclaration declaration = ParserTestCase.parse("parseClassDeclaration",
6069 "parseClassDeclaration", 5320 <Object>[
6070 <Object>[emptyCommentAndMetadata(), null], 5321 emptyCommentAndMetadata(),
6071 "class A extends B implements C {}"); 5322 null
5323 ], "class A extends B implements C {}");
6072 expect(declaration.documentationComment, isNull); 5324 expect(declaration.documentationComment, isNull);
6073 expect(declaration.abstractKeyword, isNull); 5325 expect(declaration.abstractKeyword, isNull);
6074 expect(declaration.extendsClause, isNotNull); 5326 expect(declaration.extendsClause, isNotNull);
6075 expect(declaration.implementsClause, isNotNull); 5327 expect(declaration.implementsClause, isNotNull);
6076 expect(declaration.classKeyword, isNotNull); 5328 expect(declaration.classKeyword, isNotNull);
6077 expect(declaration.leftBracket, isNotNull); 5329 expect(declaration.leftBracket, isNotNull);
6078 expect(declaration.name, isNotNull); 5330 expect(declaration.name, isNotNull);
6079 expect(declaration.members, hasLength(0)); 5331 expect(declaration.members, hasLength(0));
6080 expect(declaration.rightBracket, isNotNull); 5332 expect(declaration.rightBracket, isNotNull);
6081 expect(declaration.typeParameters, isNull); 5333 expect(declaration.typeParameters, isNull);
6082 } 5334 }
6083 5335
6084 void test_parseClassDeclaration_extendsAndWith() { 5336 void test_parseClassDeclaration_extendsAndWith() {
6085 ClassDeclaration declaration = ParserTestCase.parse( 5337 ClassDeclaration declaration = ParserTestCase.parse("parseClassDeclaration",
6086 "parseClassDeclaration", 5338 <Object>[
6087 <Object>[emptyCommentAndMetadata(), null], 5339 emptyCommentAndMetadata(),
6088 "class A extends B with C {}"); 5340 null
5341 ], "class A extends B with C {}");
6089 expect(declaration.documentationComment, isNull); 5342 expect(declaration.documentationComment, isNull);
6090 expect(declaration.abstractKeyword, isNull); 5343 expect(declaration.abstractKeyword, isNull);
6091 expect(declaration.classKeyword, isNotNull); 5344 expect(declaration.classKeyword, isNotNull);
6092 expect(declaration.name, isNotNull); 5345 expect(declaration.name, isNotNull);
6093 expect(declaration.typeParameters, isNull); 5346 expect(declaration.typeParameters, isNull);
6094 expect(declaration.extendsClause, isNotNull); 5347 expect(declaration.extendsClause, isNotNull);
6095 expect(declaration.withClause, isNotNull); 5348 expect(declaration.withClause, isNotNull);
6096 expect(declaration.implementsClause, isNull); 5349 expect(declaration.implementsClause, isNull);
6097 expect(declaration.leftBracket, isNotNull); 5350 expect(declaration.leftBracket, isNotNull);
6098 expect(declaration.members, hasLength(0)); 5351 expect(declaration.members, hasLength(0));
6099 expect(declaration.rightBracket, isNotNull); 5352 expect(declaration.rightBracket, isNotNull);
6100 } 5353 }
6101 5354
6102 void test_parseClassDeclaration_extendsAndWithAndImplements() { 5355 void test_parseClassDeclaration_extendsAndWithAndImplements() {
6103 ClassDeclaration declaration = ParserTestCase.parse( 5356 ClassDeclaration declaration = ParserTestCase.parse("parseClassDeclaration",
6104 "parseClassDeclaration", 5357 <Object>[
6105 <Object>[emptyCommentAndMetadata(), null], 5358 emptyCommentAndMetadata(),
6106 "class A extends B with C implements D {}"); 5359 null
5360 ], "class A extends B with C implements D {}");
6107 expect(declaration.documentationComment, isNull); 5361 expect(declaration.documentationComment, isNull);
6108 expect(declaration.abstractKeyword, isNull); 5362 expect(declaration.abstractKeyword, isNull);
6109 expect(declaration.classKeyword, isNotNull); 5363 expect(declaration.classKeyword, isNotNull);
6110 expect(declaration.name, isNotNull); 5364 expect(declaration.name, isNotNull);
6111 expect(declaration.typeParameters, isNull); 5365 expect(declaration.typeParameters, isNull);
6112 expect(declaration.extendsClause, isNotNull); 5366 expect(declaration.extendsClause, isNotNull);
6113 expect(declaration.withClause, isNotNull); 5367 expect(declaration.withClause, isNotNull);
6114 expect(declaration.implementsClause, isNotNull); 5368 expect(declaration.implementsClause, isNotNull);
6115 expect(declaration.leftBracket, isNotNull); 5369 expect(declaration.leftBracket, isNotNull);
6116 expect(declaration.members, hasLength(0)); 5370 expect(declaration.members, hasLength(0));
6117 expect(declaration.rightBracket, isNotNull); 5371 expect(declaration.rightBracket, isNotNull);
6118 } 5372 }
6119 5373
6120 void test_parseClassDeclaration_implements() { 5374 void test_parseClassDeclaration_implements() {
6121 ClassDeclaration declaration = ParserTestCase.parse( 5375 ClassDeclaration declaration = ParserTestCase.parse("parseClassDeclaration",
6122 "parseClassDeclaration", 5376 <Object>[emptyCommentAndMetadata(), null], "class A implements C {}");
6123 <Object>[emptyCommentAndMetadata(), null],
6124 "class A implements C {}");
6125 expect(declaration.documentationComment, isNull); 5377 expect(declaration.documentationComment, isNull);
6126 expect(declaration.abstractKeyword, isNull); 5378 expect(declaration.abstractKeyword, isNull);
6127 expect(declaration.extendsClause, isNull); 5379 expect(declaration.extendsClause, isNull);
6128 expect(declaration.implementsClause, isNotNull); 5380 expect(declaration.implementsClause, isNotNull);
6129 expect(declaration.classKeyword, isNotNull); 5381 expect(declaration.classKeyword, isNotNull);
6130 expect(declaration.leftBracket, isNotNull); 5382 expect(declaration.leftBracket, isNotNull);
6131 expect(declaration.name, isNotNull); 5383 expect(declaration.name, isNotNull);
6132 expect(declaration.members, hasLength(0)); 5384 expect(declaration.members, hasLength(0));
6133 expect(declaration.rightBracket, isNotNull); 5385 expect(declaration.rightBracket, isNotNull);
6134 expect(declaration.typeParameters, isNull); 5386 expect(declaration.typeParameters, isNull);
6135 } 5387 }
6136 5388
6137 void test_parseClassDeclaration_native() { 5389 void test_parseClassDeclaration_native() {
6138 ClassDeclaration declaration = ParserTestCase.parse( 5390 ClassDeclaration declaration = ParserTestCase.parse("parseClassDeclaration",
6139 "parseClassDeclaration", 5391 <Object>[
6140 <Object>[emptyCommentAndMetadata(), null], 5392 emptyCommentAndMetadata(),
6141 "class A native 'nativeValue' {}"); 5393 null
5394 ], "class A native 'nativeValue' {}");
6142 NativeClause nativeClause = declaration.nativeClause; 5395 NativeClause nativeClause = declaration.nativeClause;
6143 expect(nativeClause, isNotNull); 5396 expect(nativeClause, isNotNull);
6144 expect(nativeClause.nativeKeyword, isNotNull); 5397 expect(nativeClause.nativeKeyword, isNotNull);
6145 expect(nativeClause.name.stringValue, "nativeValue"); 5398 expect(nativeClause.name.stringValue, "nativeValue");
6146 expect(nativeClause.beginToken, same(nativeClause.nativeKeyword)); 5399 expect(nativeClause.beginToken, same(nativeClause.nativeKeyword));
6147 expect(nativeClause.endToken, same(nativeClause.name.endToken)); 5400 expect(nativeClause.endToken, same(nativeClause.name.endToken));
6148 } 5401 }
6149 5402
6150 void test_parseClassDeclaration_nonEmpty() { 5403 void test_parseClassDeclaration_nonEmpty() {
6151 ClassDeclaration declaration = ParserTestCase.parse( 5404 ClassDeclaration declaration = ParserTestCase.parse("parseClassDeclaration",
6152 "parseClassDeclaration", 5405 <Object>[emptyCommentAndMetadata(), null], "class A {var f;}");
6153 <Object>[emptyCommentAndMetadata(), null],
6154 "class A {var f;}");
6155 expect(declaration.documentationComment, isNull); 5406 expect(declaration.documentationComment, isNull);
6156 expect(declaration.abstractKeyword, isNull); 5407 expect(declaration.abstractKeyword, isNull);
6157 expect(declaration.extendsClause, isNull); 5408 expect(declaration.extendsClause, isNull);
6158 expect(declaration.implementsClause, isNull); 5409 expect(declaration.implementsClause, isNull);
6159 expect(declaration.classKeyword, isNotNull); 5410 expect(declaration.classKeyword, isNotNull);
6160 expect(declaration.leftBracket, isNotNull); 5411 expect(declaration.leftBracket, isNotNull);
6161 expect(declaration.name, isNotNull); 5412 expect(declaration.name, isNotNull);
6162 expect(declaration.members, hasLength(1)); 5413 expect(declaration.members, hasLength(1));
6163 expect(declaration.rightBracket, isNotNull); 5414 expect(declaration.rightBracket, isNotNull);
6164 expect(declaration.typeParameters, isNull); 5415 expect(declaration.typeParameters, isNull);
6165 } 5416 }
6166 5417
6167 void test_parseClassDeclaration_typeAlias_implementsC() { 5418 void test_parseClassDeclaration_typeAlias_implementsC() {
6168 ClassTypeAlias typeAlias = ParserTestCase.parse( 5419 ClassTypeAlias typeAlias = ParserTestCase.parse("parseClassDeclaration",
6169 "parseClassDeclaration", 5420 <Object>[
6170 <Object>[emptyCommentAndMetadata(), null], 5421 emptyCommentAndMetadata(),
6171 "class A = Object with B implements C;"); 5422 null
5423 ], "class A = Object with B implements C;");
6172 expect(typeAlias.typedefKeyword, isNotNull); 5424 expect(typeAlias.typedefKeyword, isNotNull);
6173 expect(typeAlias.name, isNotNull); 5425 expect(typeAlias.name, isNotNull);
6174 expect(typeAlias.typeParameters, isNull); 5426 expect(typeAlias.typeParameters, isNull);
6175 expect(typeAlias.withClause, isNotNull); 5427 expect(typeAlias.withClause, isNotNull);
6176 expect(typeAlias.implementsClause, isNotNull); 5428 expect(typeAlias.implementsClause, isNotNull);
6177 expect(typeAlias.implementsClause.implementsKeyword, isNotNull); 5429 expect(typeAlias.implementsClause.implementsKeyword, isNotNull);
6178 expect(typeAlias.implementsClause.interfaces.length, 1); 5430 expect(typeAlias.implementsClause.interfaces.length, 1);
6179 expect(typeAlias.semicolon, isNotNull); 5431 expect(typeAlias.semicolon, isNotNull);
6180 } 5432 }
6181 5433
6182 void test_parseClassDeclaration_typeAlias_withB() { 5434 void test_parseClassDeclaration_typeAlias_withB() {
6183 ClassTypeAlias typeAlias = ParserTestCase.parse( 5435 ClassTypeAlias typeAlias = ParserTestCase.parse("parseClassDeclaration",
6184 "parseClassDeclaration", 5436 <Object>[emptyCommentAndMetadata(), null], "class A = Object with B;");
6185 <Object>[emptyCommentAndMetadata(), null],
6186 "class A = Object with B;");
6187 expect(typeAlias.typedefKeyword, isNotNull); 5437 expect(typeAlias.typedefKeyword, isNotNull);
6188 expect(typeAlias.name, isNotNull); 5438 expect(typeAlias.name, isNotNull);
6189 expect(typeAlias.typeParameters, isNull); 5439 expect(typeAlias.typeParameters, isNull);
6190 expect(typeAlias.withClause, isNotNull); 5440 expect(typeAlias.withClause, isNotNull);
6191 expect(typeAlias.withClause.withKeyword, isNotNull); 5441 expect(typeAlias.withClause.withKeyword, isNotNull);
6192 expect(typeAlias.withClause.mixinTypes.length, 1); 5442 expect(typeAlias.withClause.mixinTypes.length, 1);
6193 expect(typeAlias.implementsClause, isNull); 5443 expect(typeAlias.implementsClause, isNull);
6194 expect(typeAlias.semicolon, isNotNull); 5444 expect(typeAlias.semicolon, isNotNull);
6195 } 5445 }
6196 5446
6197 void test_parseClassDeclaration_typeParameters() { 5447 void test_parseClassDeclaration_typeParameters() {
6198 ClassDeclaration declaration = ParserTestCase.parse( 5448 ClassDeclaration declaration = ParserTestCase.parse("parseClassDeclaration",
6199 "parseClassDeclaration", 5449 <Object>[emptyCommentAndMetadata(), null], "class A<B> {}");
6200 <Object>[emptyCommentAndMetadata(), null],
6201 "class A<B> {}");
6202 expect(declaration.documentationComment, isNull); 5450 expect(declaration.documentationComment, isNull);
6203 expect(declaration.abstractKeyword, isNull); 5451 expect(declaration.abstractKeyword, isNull);
6204 expect(declaration.extendsClause, isNull); 5452 expect(declaration.extendsClause, isNull);
6205 expect(declaration.implementsClause, isNull); 5453 expect(declaration.implementsClause, isNull);
6206 expect(declaration.classKeyword, isNotNull); 5454 expect(declaration.classKeyword, isNotNull);
6207 expect(declaration.leftBracket, isNotNull); 5455 expect(declaration.leftBracket, isNotNull);
6208 expect(declaration.name, isNotNull); 5456 expect(declaration.name, isNotNull);
6209 expect(declaration.members, hasLength(0)); 5457 expect(declaration.members, hasLength(0));
6210 expect(declaration.rightBracket, isNotNull); 5458 expect(declaration.rightBracket, isNotNull);
6211 expect(declaration.typeParameters, isNotNull); 5459 expect(declaration.typeParameters, isNotNull);
6212 expect(declaration.typeParameters.typeParameters, hasLength(1)); 5460 expect(declaration.typeParameters.typeParameters, hasLength(1));
6213 } 5461 }
6214 5462
6215 void test_parseClassMember_constructor_withInitializers() { 5463 void test_parseClassMember_constructor_withInitializers() {
6216 // TODO(brianwilkerson) Test other kinds of class members: fields, getters 5464 // TODO(brianwilkerson) Test other kinds of class members: fields, getters
6217 // and setters. 5465 // and setters.
6218 ConstructorDeclaration constructor = ParserTestCase.parse( 5466 ConstructorDeclaration constructor = ParserTestCase.parse(
6219 "parseClassMember", 5467 "parseClassMember", <Object>[
6220 <Object>["C"], 5468 "C"
6221 "C(_, _\$, this.__) : _a = _ + _\$ {}"); 5469 ], "C(_, _\$, this.__) : _a = _ + _\$ {}");
6222 expect(constructor.body, isNotNull); 5470 expect(constructor.body, isNotNull);
6223 expect(constructor.separator, isNotNull); 5471 expect(constructor.separator, isNotNull);
6224 expect(constructor.externalKeyword, isNull); 5472 expect(constructor.externalKeyword, isNull);
6225 expect(constructor.constKeyword, isNull); 5473 expect(constructor.constKeyword, isNull);
6226 expect(constructor.factoryKeyword, isNull); 5474 expect(constructor.factoryKeyword, isNull);
6227 expect(constructor.name, isNull); 5475 expect(constructor.name, isNull);
6228 expect(constructor.parameters, isNotNull); 5476 expect(constructor.parameters, isNotNull);
6229 expect(constructor.period, isNull); 5477 expect(constructor.period, isNull);
6230 expect(constructor.returnType, isNotNull); 5478 expect(constructor.returnType, isNotNull);
6231 expect(constructor.initializers, hasLength(1)); 5479 expect(constructor.initializers, hasLength(1));
(...skipping 21 matching lines...) Expand all
6253 expect(field.staticKeyword, isNull); 5501 expect(field.staticKeyword, isNull);
6254 VariableDeclarationList list = field.fields; 5502 VariableDeclarationList list = field.fields;
6255 expect(list, isNotNull); 5503 expect(list, isNotNull);
6256 NodeList<VariableDeclaration> variables = list.variables; 5504 NodeList<VariableDeclaration> variables = list.variables;
6257 expect(variables, hasLength(1)); 5505 expect(variables, hasLength(1));
6258 VariableDeclaration variable = variables[0]; 5506 VariableDeclaration variable = variables[0];
6259 expect(variable.name, isNotNull); 5507 expect(variable.name, isNotNull);
6260 } 5508 }
6261 5509
6262 void test_parseClassMember_field_namedOperator() { 5510 void test_parseClassMember_field_namedOperator() {
6263 FieldDeclaration field = 5511 FieldDeclaration field = ParserTestCase.parse(
6264 ParserTestCase.parse("parseClassMember", <Object>["C"], "var operator;") ; 5512 "parseClassMember", <Object>["C"], "var operator;");
6265 expect(field.documentationComment, isNull); 5513 expect(field.documentationComment, isNull);
6266 expect(field.metadata, hasLength(0)); 5514 expect(field.metadata, hasLength(0));
6267 expect(field.staticKeyword, isNull); 5515 expect(field.staticKeyword, isNull);
6268 VariableDeclarationList list = field.fields; 5516 VariableDeclarationList list = field.fields;
6269 expect(list, isNotNull); 5517 expect(list, isNotNull);
6270 NodeList<VariableDeclaration> variables = list.variables; 5518 NodeList<VariableDeclaration> variables = list.variables;
6271 expect(variables, hasLength(1)); 5519 expect(variables, hasLength(1));
6272 VariableDeclaration variable = variables[0]; 5520 VariableDeclaration variable = variables[0];
6273 expect(variable.name, isNotNull); 5521 expect(variable.name, isNotNull);
6274 } 5522 }
6275 5523
6276 void test_parseClassMember_field_namedOperator_withAssignment() { 5524 void test_parseClassMember_field_namedOperator_withAssignment() {
6277 FieldDeclaration field = 5525 FieldDeclaration field = ParserTestCase.parse(
6278 ParserTestCase.parse("parseClassMember", <Object>["C"], "var operator = (5);"); 5526 "parseClassMember", <Object>["C"], "var operator = (5);");
6279 expect(field.documentationComment, isNull); 5527 expect(field.documentationComment, isNull);
6280 expect(field.metadata, hasLength(0)); 5528 expect(field.metadata, hasLength(0));
6281 expect(field.staticKeyword, isNull); 5529 expect(field.staticKeyword, isNull);
6282 VariableDeclarationList list = field.fields; 5530 VariableDeclarationList list = field.fields;
6283 expect(list, isNotNull); 5531 expect(list, isNotNull);
6284 NodeList<VariableDeclaration> variables = list.variables; 5532 NodeList<VariableDeclaration> variables = list.variables;
6285 expect(variables, hasLength(1)); 5533 expect(variables, hasLength(1));
6286 VariableDeclaration variable = variables[0]; 5534 VariableDeclaration variable = variables[0];
6287 expect(variable.name, isNotNull); 5535 expect(variable.name, isNotNull);
6288 expect(variable.initializer, isNotNull); 5536 expect(variable.initializer, isNotNull);
6289 } 5537 }
6290 5538
6291 void test_parseClassMember_field_namedSet() { 5539 void test_parseClassMember_field_namedSet() {
6292 FieldDeclaration field = 5540 FieldDeclaration field =
6293 ParserTestCase.parse("parseClassMember", <Object>["C"], "var set;"); 5541 ParserTestCase.parse("parseClassMember", <Object>["C"], "var set;");
6294 expect(field.documentationComment, isNull); 5542 expect(field.documentationComment, isNull);
6295 expect(field.metadata, hasLength(0)); 5543 expect(field.metadata, hasLength(0));
6296 expect(field.staticKeyword, isNull); 5544 expect(field.staticKeyword, isNull);
6297 VariableDeclarationList list = field.fields; 5545 VariableDeclarationList list = field.fields;
6298 expect(list, isNotNull); 5546 expect(list, isNotNull);
6299 NodeList<VariableDeclaration> variables = list.variables; 5547 NodeList<VariableDeclaration> variables = list.variables;
6300 expect(variables, hasLength(1)); 5548 expect(variables, hasLength(1));
6301 VariableDeclaration variable = variables[0]; 5549 VariableDeclaration variable = variables[0];
6302 expect(variable.name, isNotNull); 5550 expect(variable.name, isNotNull);
6303 } 5551 }
6304 5552
6305 void test_parseClassMember_getter_void() { 5553 void test_parseClassMember_getter_void() {
6306 MethodDeclaration method = 5554 MethodDeclaration method = ParserTestCase.parse(
6307 ParserTestCase.parse("parseClassMember", <Object>["C"], "void get g {}") ; 5555 "parseClassMember", <Object>["C"], "void get g {}");
6308 expect(method.documentationComment, isNull); 5556 expect(method.documentationComment, isNull);
6309 expect(method.externalKeyword, isNull); 5557 expect(method.externalKeyword, isNull);
6310 expect(method.modifierKeyword, isNull); 5558 expect(method.modifierKeyword, isNull);
6311 expect(method.propertyKeyword, isNotNull); 5559 expect(method.propertyKeyword, isNotNull);
6312 expect(method.returnType, isNotNull); 5560 expect(method.returnType, isNotNull);
6313 expect(method.name, isNotNull); 5561 expect(method.name, isNotNull);
6314 expect(method.operatorKeyword, isNull); 5562 expect(method.operatorKeyword, isNull);
6315 expect(method.body, isNotNull); 5563 expect(method.body, isNotNull);
6316 } 5564 }
6317 5565
6318 void test_parseClassMember_method_external() { 5566 void test_parseClassMember_method_external() {
6319 MethodDeclaration method = 5567 MethodDeclaration method = ParserTestCase.parse(
6320 ParserTestCase.parse("parseClassMember", <Object>["C"], "external m();") ; 5568 "parseClassMember", <Object>["C"], "external m();");
6321 expect(method.body, isNotNull); 5569 expect(method.body, isNotNull);
6322 expect(method.documentationComment, isNull); 5570 expect(method.documentationComment, isNull);
6323 expect(method.externalKeyword, isNotNull); 5571 expect(method.externalKeyword, isNotNull);
6324 expect(method.modifierKeyword, isNull); 5572 expect(method.modifierKeyword, isNull);
6325 expect(method.name, isNotNull); 5573 expect(method.name, isNotNull);
6326 expect(method.operatorKeyword, isNull); 5574 expect(method.operatorKeyword, isNull);
6327 expect(method.parameters, isNotNull); 5575 expect(method.parameters, isNotNull);
6328 expect(method.propertyKeyword, isNull); 5576 expect(method.propertyKeyword, isNull);
6329 expect(method.returnType, isNull); 5577 expect(method.returnType, isNull);
6330 } 5578 }
6331 5579
6332 void test_parseClassMember_method_external_withTypeAndArgs() { 5580 void test_parseClassMember_method_external_withTypeAndArgs() {
6333 MethodDeclaration method = ParserTestCase.parse( 5581 MethodDeclaration method = ParserTestCase.parse(
6334 "parseClassMember", 5582 "parseClassMember", <Object>["C"], "external int m(int a);");
6335 <Object>["C"],
6336 "external int m(int a);");
6337 expect(method.body, isNotNull); 5583 expect(method.body, isNotNull);
6338 expect(method.documentationComment, isNull); 5584 expect(method.documentationComment, isNull);
6339 expect(method.externalKeyword, isNotNull); 5585 expect(method.externalKeyword, isNotNull);
6340 expect(method.modifierKeyword, isNull); 5586 expect(method.modifierKeyword, isNull);
6341 expect(method.name, isNotNull); 5587 expect(method.name, isNotNull);
6342 expect(method.operatorKeyword, isNull); 5588 expect(method.operatorKeyword, isNull);
6343 expect(method.parameters, isNotNull); 5589 expect(method.parameters, isNotNull);
6344 expect(method.propertyKeyword, isNull); 5590 expect(method.propertyKeyword, isNull);
6345 expect(method.returnType, isNotNull); 5591 expect(method.returnType, isNotNull);
6346 } 5592 }
(...skipping 20 matching lines...) Expand all
6367 expect(method.modifierKeyword, isNull); 5613 expect(method.modifierKeyword, isNull);
6368 expect(method.propertyKeyword, isNull); 5614 expect(method.propertyKeyword, isNull);
6369 expect(method.returnType, isNotNull); 5615 expect(method.returnType, isNotNull);
6370 expect(method.name, isNotNull); 5616 expect(method.name, isNotNull);
6371 expect(method.operatorKeyword, isNull); 5617 expect(method.operatorKeyword, isNull);
6372 expect(method.parameters, isNotNull); 5618 expect(method.parameters, isNotNull);
6373 expect(method.body, isNotNull); 5619 expect(method.body, isNotNull);
6374 } 5620 }
6375 5621
6376 void test_parseClassMember_method_get_void() { 5622 void test_parseClassMember_method_get_void() {
6377 MethodDeclaration method = 5623 MethodDeclaration method = ParserTestCase.parse(
6378 ParserTestCase.parse("parseClassMember", <Object>["C"], "void get() {}") ; 5624 "parseClassMember", <Object>["C"], "void get() {}");
6379 expect(method.documentationComment, isNull); 5625 expect(method.documentationComment, isNull);
6380 expect(method.externalKeyword, isNull); 5626 expect(method.externalKeyword, isNull);
6381 expect(method.modifierKeyword, isNull); 5627 expect(method.modifierKeyword, isNull);
6382 expect(method.propertyKeyword, isNull); 5628 expect(method.propertyKeyword, isNull);
6383 expect(method.returnType, isNotNull); 5629 expect(method.returnType, isNotNull);
6384 expect(method.name, isNotNull); 5630 expect(method.name, isNotNull);
6385 expect(method.operatorKeyword, isNull); 5631 expect(method.operatorKeyword, isNull);
6386 expect(method.parameters, isNotNull); 5632 expect(method.parameters, isNotNull);
6387 expect(method.body, isNotNull); 5633 expect(method.body, isNotNull);
6388 } 5634 }
6389 5635
6390 void test_parseClassMember_method_operator_noType() { 5636 void test_parseClassMember_method_operator_noType() {
6391 MethodDeclaration method = 5637 MethodDeclaration method = ParserTestCase.parse(
6392 ParserTestCase.parse("parseClassMember", <Object>["C"], "operator() {}") ; 5638 "parseClassMember", <Object>["C"], "operator() {}");
6393 expect(method.documentationComment, isNull); 5639 expect(method.documentationComment, isNull);
6394 expect(method.externalKeyword, isNull); 5640 expect(method.externalKeyword, isNull);
6395 expect(method.modifierKeyword, isNull); 5641 expect(method.modifierKeyword, isNull);
6396 expect(method.propertyKeyword, isNull); 5642 expect(method.propertyKeyword, isNull);
6397 expect(method.returnType, isNull); 5643 expect(method.returnType, isNull);
6398 expect(method.name, isNotNull); 5644 expect(method.name, isNotNull);
6399 expect(method.operatorKeyword, isNull); 5645 expect(method.operatorKeyword, isNull);
6400 expect(method.parameters, isNotNull); 5646 expect(method.parameters, isNotNull);
6401 expect(method.body, isNotNull); 5647 expect(method.body, isNotNull);
6402 } 5648 }
6403 5649
6404 void test_parseClassMember_method_operator_type() { 5650 void test_parseClassMember_method_operator_type() {
6405 MethodDeclaration method = 5651 MethodDeclaration method = ParserTestCase.parse(
6406 ParserTestCase.parse("parseClassMember", <Object>["C"], "int operator() {}"); 5652 "parseClassMember", <Object>["C"], "int operator() {}");
6407 expect(method.documentationComment, isNull); 5653 expect(method.documentationComment, isNull);
6408 expect(method.externalKeyword, isNull); 5654 expect(method.externalKeyword, isNull);
6409 expect(method.modifierKeyword, isNull); 5655 expect(method.modifierKeyword, isNull);
6410 expect(method.propertyKeyword, isNull); 5656 expect(method.propertyKeyword, isNull);
6411 expect(method.returnType, isNotNull); 5657 expect(method.returnType, isNotNull);
6412 expect(method.name, isNotNull); 5658 expect(method.name, isNotNull);
6413 expect(method.operatorKeyword, isNull); 5659 expect(method.operatorKeyword, isNull);
6414 expect(method.parameters, isNotNull); 5660 expect(method.parameters, isNotNull);
6415 expect(method.body, isNotNull); 5661 expect(method.body, isNotNull);
6416 } 5662 }
6417 5663
6418 void test_parseClassMember_method_operator_void() { 5664 void test_parseClassMember_method_operator_void() {
6419 MethodDeclaration method = 5665 MethodDeclaration method = ParserTestCase.parse(
6420 ParserTestCase.parse("parseClassMember", <Object>["C"], "void operator() {}"); 5666 "parseClassMember", <Object>["C"], "void operator() {}");
6421 expect(method.documentationComment, isNull); 5667 expect(method.documentationComment, isNull);
6422 expect(method.externalKeyword, isNull); 5668 expect(method.externalKeyword, isNull);
6423 expect(method.modifierKeyword, isNull); 5669 expect(method.modifierKeyword, isNull);
6424 expect(method.propertyKeyword, isNull); 5670 expect(method.propertyKeyword, isNull);
6425 expect(method.returnType, isNotNull); 5671 expect(method.returnType, isNotNull);
6426 expect(method.name, isNotNull); 5672 expect(method.name, isNotNull);
6427 expect(method.operatorKeyword, isNull); 5673 expect(method.operatorKeyword, isNull);
6428 expect(method.parameters, isNotNull); 5674 expect(method.parameters, isNotNull);
6429 expect(method.body, isNotNull); 5675 expect(method.body, isNotNull);
6430 } 5676 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
6465 expect(method.modifierKeyword, isNull); 5711 expect(method.modifierKeyword, isNull);
6466 expect(method.propertyKeyword, isNull); 5712 expect(method.propertyKeyword, isNull);
6467 expect(method.returnType, isNotNull); 5713 expect(method.returnType, isNotNull);
6468 expect(method.name, isNotNull); 5714 expect(method.name, isNotNull);
6469 expect(method.operatorKeyword, isNull); 5715 expect(method.operatorKeyword, isNull);
6470 expect(method.parameters, isNotNull); 5716 expect(method.parameters, isNotNull);
6471 expect(method.body, isNotNull); 5717 expect(method.body, isNotNull);
6472 } 5718 }
6473 5719
6474 void test_parseClassMember_method_set_void() { 5720 void test_parseClassMember_method_set_void() {
6475 MethodDeclaration method = 5721 MethodDeclaration method = ParserTestCase.parse(
6476 ParserTestCase.parse("parseClassMember", <Object>["C"], "void set() {}") ; 5722 "parseClassMember", <Object>["C"], "void set() {}");
6477 expect(method.documentationComment, isNull); 5723 expect(method.documentationComment, isNull);
6478 expect(method.externalKeyword, isNull); 5724 expect(method.externalKeyword, isNull);
6479 expect(method.modifierKeyword, isNull); 5725 expect(method.modifierKeyword, isNull);
6480 expect(method.propertyKeyword, isNull); 5726 expect(method.propertyKeyword, isNull);
6481 expect(method.returnType, isNotNull); 5727 expect(method.returnType, isNotNull);
6482 expect(method.name, isNotNull); 5728 expect(method.name, isNotNull);
6483 expect(method.operatorKeyword, isNull); 5729 expect(method.operatorKeyword, isNull);
6484 expect(method.parameters, isNotNull); 5730 expect(method.parameters, isNotNull);
6485 expect(method.body, isNotNull); 5731 expect(method.body, isNotNull);
6486 } 5732 }
6487 5733
6488 void test_parseClassMember_operator_index() { 5734 void test_parseClassMember_operator_index() {
6489 MethodDeclaration method = ParserTestCase.parse( 5735 MethodDeclaration method = ParserTestCase.parse(
6490 "parseClassMember", 5736 "parseClassMember", <Object>["C"], "int operator [](int i) {}");
6491 <Object>["C"],
6492 "int operator [](int i) {}");
6493 expect(method.documentationComment, isNull); 5737 expect(method.documentationComment, isNull);
6494 expect(method.externalKeyword, isNull); 5738 expect(method.externalKeyword, isNull);
6495 expect(method.modifierKeyword, isNull); 5739 expect(method.modifierKeyword, isNull);
6496 expect(method.propertyKeyword, isNull); 5740 expect(method.propertyKeyword, isNull);
6497 expect(method.returnType, isNotNull); 5741 expect(method.returnType, isNotNull);
6498 expect(method.name, isNotNull); 5742 expect(method.name, isNotNull);
6499 expect(method.operatorKeyword, isNotNull); 5743 expect(method.operatorKeyword, isNotNull);
6500 expect(method.parameters, isNotNull); 5744 expect(method.parameters, isNotNull);
6501 expect(method.body, isNotNull); 5745 expect(method.body, isNotNull);
6502 } 5746 }
6503 5747
6504 void test_parseClassMember_operator_indexAssign() { 5748 void test_parseClassMember_operator_indexAssign() {
6505 MethodDeclaration method = ParserTestCase.parse( 5749 MethodDeclaration method = ParserTestCase.parse(
6506 "parseClassMember", 5750 "parseClassMember", <Object>["C"], "int operator []=(int i) {}");
6507 <Object>["C"],
6508 "int operator []=(int i) {}");
6509 expect(method.documentationComment, isNull); 5751 expect(method.documentationComment, isNull);
6510 expect(method.externalKeyword, isNull); 5752 expect(method.externalKeyword, isNull);
6511 expect(method.modifierKeyword, isNull); 5753 expect(method.modifierKeyword, isNull);
6512 expect(method.propertyKeyword, isNull); 5754 expect(method.propertyKeyword, isNull);
6513 expect(method.returnType, isNotNull); 5755 expect(method.returnType, isNotNull);
6514 expect(method.name, isNotNull); 5756 expect(method.name, isNotNull);
6515 expect(method.operatorKeyword, isNotNull); 5757 expect(method.operatorKeyword, isNotNull);
6516 expect(method.parameters, isNotNull); 5758 expect(method.parameters, isNotNull);
6517 expect(method.body, isNotNull); 5759 expect(method.body, isNotNull);
6518 } 5760 }
6519 5761
6520 void test_parseClassMember_redirectingFactory_const() { 5762 void test_parseClassMember_redirectingFactory_const() {
6521 ConstructorDeclaration constructor = ParserTestCase.parse( 5763 ConstructorDeclaration constructor = ParserTestCase.parse(
6522 "parseClassMember", 5764 "parseClassMember", <Object>["C"], "const factory C() = B;");
6523 <Object>["C"],
6524 "const factory C() = B;");
6525 expect(constructor.externalKeyword, isNull); 5765 expect(constructor.externalKeyword, isNull);
6526 expect(constructor.constKeyword, isNotNull); 5766 expect(constructor.constKeyword, isNotNull);
6527 expect(constructor.factoryKeyword, isNotNull); 5767 expect(constructor.factoryKeyword, isNotNull);
6528 expect(constructor.returnType, isNotNull); 5768 expect(constructor.returnType, isNotNull);
6529 expect(constructor.period, isNull); 5769 expect(constructor.period, isNull);
6530 expect(constructor.name, isNull); 5770 expect(constructor.name, isNull);
6531 expect(constructor.parameters, isNotNull); 5771 expect(constructor.parameters, isNotNull);
6532 expect(constructor.separator, isNotNull); 5772 expect(constructor.separator, isNotNull);
6533 expect(constructor.initializers, hasLength(0)); 5773 expect(constructor.initializers, hasLength(0));
6534 expect(constructor.redirectedConstructor, isNotNull); 5774 expect(constructor.redirectedConstructor, isNotNull);
6535 expect(constructor.body, isNotNull); 5775 expect(constructor.body, isNotNull);
6536 } 5776 }
6537 5777
6538 void test_parseClassMember_redirectingFactory_nonConst() { 5778 void test_parseClassMember_redirectingFactory_nonConst() {
6539 ConstructorDeclaration constructor = 5779 ConstructorDeclaration constructor = ParserTestCase.parse(
6540 ParserTestCase.parse("parseClassMember", <Object>["C"], "factory C() = B ;"); 5780 "parseClassMember", <Object>["C"], "factory C() = B;");
6541 expect(constructor.externalKeyword, isNull); 5781 expect(constructor.externalKeyword, isNull);
6542 expect(constructor.constKeyword, isNull); 5782 expect(constructor.constKeyword, isNull);
6543 expect(constructor.factoryKeyword, isNotNull); 5783 expect(constructor.factoryKeyword, isNotNull);
6544 expect(constructor.returnType, isNotNull); 5784 expect(constructor.returnType, isNotNull);
6545 expect(constructor.period, isNull); 5785 expect(constructor.period, isNull);
6546 expect(constructor.name, isNull); 5786 expect(constructor.name, isNull);
6547 expect(constructor.parameters, isNotNull); 5787 expect(constructor.parameters, isNotNull);
6548 expect(constructor.separator, isNotNull); 5788 expect(constructor.separator, isNotNull);
6549 expect(constructor.initializers, hasLength(0)); 5789 expect(constructor.initializers, hasLength(0));
6550 expect(constructor.redirectedConstructor, isNotNull); 5790 expect(constructor.redirectedConstructor, isNotNull);
6551 expect(constructor.body, isNotNull); 5791 expect(constructor.body, isNotNull);
6552 } 5792 }
6553 5793
6554 void test_parseClassTypeAlias_abstract() { 5794 void test_parseClassTypeAlias_abstract() {
6555 Token classToken = TokenFactory.tokenFromKeyword(Keyword.CLASS); 5795 Token classToken = TokenFactory.tokenFromKeyword(Keyword.CLASS);
6556 Token abstractToken = TokenFactory.tokenFromKeyword(Keyword.ABSTRACT); 5796 Token abstractToken = TokenFactory.tokenFromKeyword(Keyword.ABSTRACT);
6557 ClassTypeAlias classTypeAlias = ParserTestCase.parse( 5797 ClassTypeAlias classTypeAlias = ParserTestCase.parse("parseClassTypeAlias",
6558 "parseClassTypeAlias", 5798 <Object>[
6559 <Object>[emptyCommentAndMetadata(), abstractToken, classToken], 5799 emptyCommentAndMetadata(),
6560 "A = B with C;"); 5800 abstractToken,
5801 classToken
5802 ], "A = B with C;");
6561 expect(classTypeAlias.typedefKeyword, isNotNull); 5803 expect(classTypeAlias.typedefKeyword, isNotNull);
6562 expect(classTypeAlias.name.name, "A"); 5804 expect(classTypeAlias.name.name, "A");
6563 expect(classTypeAlias.equals, isNotNull); 5805 expect(classTypeAlias.equals, isNotNull);
6564 expect(classTypeAlias.abstractKeyword, isNotNull); 5806 expect(classTypeAlias.abstractKeyword, isNotNull);
6565 expect(classTypeAlias.superclass.name.name, isNotNull, reason: "B"); 5807 expect(classTypeAlias.superclass.name.name, isNotNull, reason: "B");
6566 expect(classTypeAlias.withClause, isNotNull); 5808 expect(classTypeAlias.withClause, isNotNull);
6567 expect(classTypeAlias.implementsClause, isNull); 5809 expect(classTypeAlias.implementsClause, isNull);
6568 expect(classTypeAlias.semicolon, isNotNull); 5810 expect(classTypeAlias.semicolon, isNotNull);
6569 } 5811 }
6570 5812
6571 void test_parseClassTypeAlias_implements() { 5813 void test_parseClassTypeAlias_implements() {
6572 Token token = TokenFactory.tokenFromKeyword(Keyword.CLASS); 5814 Token token = TokenFactory.tokenFromKeyword(Keyword.CLASS);
6573 ClassTypeAlias classTypeAlias = ParserTestCase.parse( 5815 ClassTypeAlias classTypeAlias = ParserTestCase.parse("parseClassTypeAlias",
6574 "parseClassTypeAlias", 5816 <Object>[
6575 <Object>[emptyCommentAndMetadata(), null, token], 5817 emptyCommentAndMetadata(),
6576 "A = B with C implements D;"); 5818 null,
5819 token
5820 ], "A = B with C implements D;");
6577 expect(classTypeAlias.typedefKeyword, isNotNull); 5821 expect(classTypeAlias.typedefKeyword, isNotNull);
6578 expect(classTypeAlias.name.name, "A"); 5822 expect(classTypeAlias.name.name, "A");
6579 expect(classTypeAlias.equals, isNotNull); 5823 expect(classTypeAlias.equals, isNotNull);
6580 expect(classTypeAlias.abstractKeyword, isNull); 5824 expect(classTypeAlias.abstractKeyword, isNull);
6581 expect(classTypeAlias.superclass.name.name, isNotNull, reason: "B"); 5825 expect(classTypeAlias.superclass.name.name, isNotNull, reason: "B");
6582 expect(classTypeAlias.withClause, isNotNull); 5826 expect(classTypeAlias.withClause, isNotNull);
6583 expect(classTypeAlias.implementsClause, isNotNull); 5827 expect(classTypeAlias.implementsClause, isNotNull);
6584 expect(classTypeAlias.semicolon, isNotNull); 5828 expect(classTypeAlias.semicolon, isNotNull);
6585 } 5829 }
6586 5830
6587 void test_parseClassTypeAlias_with() { 5831 void test_parseClassTypeAlias_with() {
6588 Token token = TokenFactory.tokenFromKeyword(Keyword.CLASS); 5832 Token token = TokenFactory.tokenFromKeyword(Keyword.CLASS);
6589 ClassTypeAlias classTypeAlias = ParserTestCase.parse( 5833 ClassTypeAlias classTypeAlias = ParserTestCase.parse("parseClassTypeAlias",
6590 "parseClassTypeAlias", 5834 <Object>[emptyCommentAndMetadata(), null, token], "A = B with C;");
6591 <Object>[emptyCommentAndMetadata(), null, token],
6592 "A = B with C;");
6593 expect(classTypeAlias.typedefKeyword, isNotNull); 5835 expect(classTypeAlias.typedefKeyword, isNotNull);
6594 expect(classTypeAlias.name.name, "A"); 5836 expect(classTypeAlias.name.name, "A");
6595 expect(classTypeAlias.equals, isNotNull); 5837 expect(classTypeAlias.equals, isNotNull);
6596 expect(classTypeAlias.abstractKeyword, isNull); 5838 expect(classTypeAlias.abstractKeyword, isNull);
6597 expect(classTypeAlias.superclass.name.name, isNotNull, reason: "B"); 5839 expect(classTypeAlias.superclass.name.name, isNotNull, reason: "B");
6598 expect(classTypeAlias.withClause, isNotNull); 5840 expect(classTypeAlias.withClause, isNotNull);
6599 expect(classTypeAlias.implementsClause, isNull); 5841 expect(classTypeAlias.implementsClause, isNull);
6600 expect(classTypeAlias.semicolon, isNotNull); 5842 expect(classTypeAlias.semicolon, isNotNull);
6601 } 5843 }
6602 5844
6603 void test_parseClassTypeAlias_with_implements() { 5845 void test_parseClassTypeAlias_with_implements() {
6604 Token token = TokenFactory.tokenFromKeyword(Keyword.CLASS); 5846 Token token = TokenFactory.tokenFromKeyword(Keyword.CLASS);
6605 ClassTypeAlias classTypeAlias = ParserTestCase.parse( 5847 ClassTypeAlias classTypeAlias = ParserTestCase.parse("parseClassTypeAlias",
6606 "parseClassTypeAlias", 5848 <Object>[
6607 <Object>[emptyCommentAndMetadata(), null, token], 5849 emptyCommentAndMetadata(),
6608 "A = B with C implements D;"); 5850 null,
5851 token
5852 ], "A = B with C implements D;");
6609 expect(classTypeAlias.typedefKeyword, isNotNull); 5853 expect(classTypeAlias.typedefKeyword, isNotNull);
6610 expect(classTypeAlias.name.name, "A"); 5854 expect(classTypeAlias.name.name, "A");
6611 expect(classTypeAlias.equals, isNotNull); 5855 expect(classTypeAlias.equals, isNotNull);
6612 expect(classTypeAlias.abstractKeyword, isNull); 5856 expect(classTypeAlias.abstractKeyword, isNull);
6613 expect(classTypeAlias.superclass.name.name, isNotNull, reason: "B"); 5857 expect(classTypeAlias.superclass.name.name, isNotNull, reason: "B");
6614 expect(classTypeAlias.withClause, isNotNull); 5858 expect(classTypeAlias.withClause, isNotNull);
6615 expect(classTypeAlias.implementsClause, isNotNull); 5859 expect(classTypeAlias.implementsClause, isNotNull);
6616 expect(classTypeAlias.semicolon, isNotNull); 5860 expect(classTypeAlias.semicolon, isNotNull);
6617 } 5861 }
6618 5862
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
6650 expect(hideCombinator, isNotNull); 5894 expect(hideCombinator, isNotNull);
6651 expect(hideCombinator.keyword, isNotNull); 5895 expect(hideCombinator.keyword, isNotNull);
6652 expect(hideCombinator.hiddenNames, hasLength(1)); 5896 expect(hideCombinator.hiddenNames, hasLength(1));
6653 ShowCombinator showCombinator = combinators[1] as ShowCombinator; 5897 ShowCombinator showCombinator = combinators[1] as ShowCombinator;
6654 expect(showCombinator, isNotNull); 5898 expect(showCombinator, isNotNull);
6655 expect(showCombinator.keyword, isNotNull); 5899 expect(showCombinator.keyword, isNotNull);
6656 expect(showCombinator.shownNames, hasLength(1)); 5900 expect(showCombinator.shownNames, hasLength(1));
6657 } 5901 }
6658 5902
6659 void test_parseCombinators_hshs() { 5903 void test_parseCombinators_hshs() {
6660 List<Combinator> combinators = 5904 List<Combinator> combinators = ParserTestCase.parse4(
6661 ParserTestCase.parse4("parseCombinators", "hide a show b hide c show d;" ); 5905 "parseCombinators", "hide a show b hide c show d;");
6662 expect(combinators, hasLength(4)); 5906 expect(combinators, hasLength(4));
6663 } 5907 }
6664 5908
6665 void test_parseCombinators_s() { 5909 void test_parseCombinators_s() {
6666 List<Combinator> combinators = 5910 List<Combinator> combinators =
6667 ParserTestCase.parse4("parseCombinators", "show a;"); 5911 ParserTestCase.parse4("parseCombinators", "show a;");
6668 expect(combinators, hasLength(1)); 5912 expect(combinators, hasLength(1));
6669 ShowCombinator combinator = combinators[0] as ShowCombinator; 5913 ShowCombinator combinator = combinators[0] as ShowCombinator;
6670 expect(combinator, isNotNull); 5914 expect(combinator, isNotNull);
6671 expect(combinator.keyword, isNotNull); 5915 expect(combinator.keyword, isNotNull);
6672 expect(combinator.shownNames, hasLength(1)); 5916 expect(combinator.shownNames, hasLength(1));
6673 } 5917 }
6674 5918
6675 void test_parseCommentAndMetadata_c() { 5919 void test_parseCommentAndMetadata_c() {
6676 CommentAndMetadata commentAndMetadata = 5920 CommentAndMetadata commentAndMetadata =
6677 ParserTestCase.parse4("parseCommentAndMetadata", "/** 1 */ void"); 5921 ParserTestCase.parse4("parseCommentAndMetadata", "/** 1 */ void");
6678 expect(commentAndMetadata.comment, isNotNull); 5922 expect(commentAndMetadata.comment, isNotNull);
6679 expect(commentAndMetadata.metadata, hasLength(0)); 5923 expect(commentAndMetadata.metadata, hasLength(0));
6680 } 5924 }
6681 5925
6682 void test_parseCommentAndMetadata_cmc() { 5926 void test_parseCommentAndMetadata_cmc() {
6683 CommentAndMetadata commentAndMetadata = 5927 CommentAndMetadata commentAndMetadata = ParserTestCase.parse4(
6684 ParserTestCase.parse4("parseCommentAndMetadata", "/** 1 */ @A /** 2 */ v oid"); 5928 "parseCommentAndMetadata", "/** 1 */ @A /** 2 */ void");
6685 expect(commentAndMetadata.comment, isNotNull); 5929 expect(commentAndMetadata.comment, isNotNull);
6686 expect(commentAndMetadata.metadata, hasLength(1)); 5930 expect(commentAndMetadata.metadata, hasLength(1));
6687 } 5931 }
6688 5932
6689 void test_parseCommentAndMetadata_cmcm() { 5933 void test_parseCommentAndMetadata_cmcm() {
6690 CommentAndMetadata commentAndMetadata = ParserTestCase.parse4( 5934 CommentAndMetadata commentAndMetadata = ParserTestCase.parse4(
6691 "parseCommentAndMetadata", 5935 "parseCommentAndMetadata", "/** 1 */ @A /** 2 */ @B void");
6692 "/** 1 */ @A /** 2 */ @B void");
6693 expect(commentAndMetadata.comment, isNotNull); 5936 expect(commentAndMetadata.comment, isNotNull);
6694 expect(commentAndMetadata.metadata, hasLength(2)); 5937 expect(commentAndMetadata.metadata, hasLength(2));
6695 } 5938 }
6696 5939
6697 void test_parseCommentAndMetadata_cmm() { 5940 void test_parseCommentAndMetadata_cmm() {
6698 CommentAndMetadata commentAndMetadata = 5941 CommentAndMetadata commentAndMetadata =
6699 ParserTestCase.parse4("parseCommentAndMetadata", "/** 1 */ @A @B void"); 5942 ParserTestCase.parse4("parseCommentAndMetadata", "/** 1 */ @A @B void");
6700 expect(commentAndMetadata.comment, isNotNull); 5943 expect(commentAndMetadata.comment, isNotNull);
6701 expect(commentAndMetadata.metadata, hasLength(2)); 5944 expect(commentAndMetadata.metadata, hasLength(2));
6702 } 5945 }
6703 5946
6704 void test_parseCommentAndMetadata_m() { 5947 void test_parseCommentAndMetadata_m() {
6705 CommentAndMetadata commentAndMetadata = 5948 CommentAndMetadata commentAndMetadata =
6706 ParserTestCase.parse4("parseCommentAndMetadata", "@A void"); 5949 ParserTestCase.parse4("parseCommentAndMetadata", "@A void");
6707 expect(commentAndMetadata.comment, isNull); 5950 expect(commentAndMetadata.comment, isNull);
6708 expect(commentAndMetadata.metadata, hasLength(1)); 5951 expect(commentAndMetadata.metadata, hasLength(1));
6709 } 5952 }
6710 5953
6711 void test_parseCommentAndMetadata_mcm() { 5954 void test_parseCommentAndMetadata_mcm() {
6712 CommentAndMetadata commentAndMetadata = 5955 CommentAndMetadata commentAndMetadata =
6713 ParserTestCase.parse4("parseCommentAndMetadata", "@A /** 1 */ @B void"); 5956 ParserTestCase.parse4("parseCommentAndMetadata", "@A /** 1 */ @B void");
6714 expect(commentAndMetadata.comment, isNotNull); 5957 expect(commentAndMetadata.comment, isNotNull);
6715 expect(commentAndMetadata.metadata, hasLength(2)); 5958 expect(commentAndMetadata.metadata, hasLength(2));
6716 } 5959 }
6717 5960
6718 void test_parseCommentAndMetadata_mcmc() { 5961 void test_parseCommentAndMetadata_mcmc() {
6719 CommentAndMetadata commentAndMetadata = ParserTestCase.parse4( 5962 CommentAndMetadata commentAndMetadata = ParserTestCase.parse4(
6720 "parseCommentAndMetadata", 5963 "parseCommentAndMetadata", "@A /** 1 */ @B /** 2 */ void");
6721 "@A /** 1 */ @B /** 2 */ void");
6722 expect(commentAndMetadata.comment, isNotNull); 5964 expect(commentAndMetadata.comment, isNotNull);
6723 expect(commentAndMetadata.metadata, hasLength(2)); 5965 expect(commentAndMetadata.metadata, hasLength(2));
6724 } 5966 }
6725 5967
6726 void test_parseCommentAndMetadata_mm() { 5968 void test_parseCommentAndMetadata_mm() {
6727 CommentAndMetadata commentAndMetadata = 5969 CommentAndMetadata commentAndMetadata =
6728 ParserTestCase.parse4("parseCommentAndMetadata", "@A @B(x) void"); 5970 ParserTestCase.parse4("parseCommentAndMetadata", "@A @B(x) void");
6729 expect(commentAndMetadata.comment, isNull); 5971 expect(commentAndMetadata.comment, isNull);
6730 expect(commentAndMetadata.metadata, hasLength(2)); 5972 expect(commentAndMetadata.metadata, hasLength(2));
6731 } 5973 }
6732 5974
6733 void test_parseCommentAndMetadata_none() { 5975 void test_parseCommentAndMetadata_none() {
6734 CommentAndMetadata commentAndMetadata = 5976 CommentAndMetadata commentAndMetadata =
6735 ParserTestCase.parse4("parseCommentAndMetadata", "void"); 5977 ParserTestCase.parse4("parseCommentAndMetadata", "void");
6736 expect(commentAndMetadata.comment, isNull); 5978 expect(commentAndMetadata.comment, isNull);
6737 expect(commentAndMetadata.metadata, hasLength(0)); 5979 expect(commentAndMetadata.metadata, hasLength(0));
6738 } 5980 }
6739 5981
6740 void test_parseCommentAndMetadata_singleLine() { 5982 void test_parseCommentAndMetadata_singleLine() {
6741 CommentAndMetadata commentAndMetadata = 5983 CommentAndMetadata commentAndMetadata = ParserTestCase.parse4(
6742 ParserTestCase.parse4("parseCommentAndMetadata", r''' 5984 "parseCommentAndMetadata", r'''
6743 /// 1 5985 /// 1
6744 /// 2 5986 /// 2
6745 void'''); 5987 void''');
6746 expect(commentAndMetadata.comment, isNotNull); 5988 expect(commentAndMetadata.comment, isNotNull);
6747 expect(commentAndMetadata.metadata, hasLength(0)); 5989 expect(commentAndMetadata.metadata, hasLength(0));
6748 } 5990 }
6749 5991
6750 void test_parseCommentReference_new_prefixed() { 5992 void test_parseCommentReference_new_prefixed() {
6751 CommentReference reference = 5993 CommentReference reference = ParserTestCase.parse(
6752 ParserTestCase.parse("parseCommentReference", <Object>["new a.b", 7], "" ); 5994 "parseCommentReference", <Object>["new a.b", 7], "");
6753 PrefixedIdentifier prefixedIdentifier = EngineTestCase.assertInstanceOf( 5995 PrefixedIdentifier prefixedIdentifier = EngineTestCase.assertInstanceOf(
6754 (obj) => obj is PrefixedIdentifier, 5996 (obj) => obj is PrefixedIdentifier, PrefixedIdentifier,
6755 PrefixedIdentifier,
6756 reference.identifier); 5997 reference.identifier);
6757 SimpleIdentifier prefix = prefixedIdentifier.prefix; 5998 SimpleIdentifier prefix = prefixedIdentifier.prefix;
6758 expect(prefix.token, isNotNull); 5999 expect(prefix.token, isNotNull);
6759 expect(prefix.name, "a"); 6000 expect(prefix.name, "a");
6760 expect(prefix.offset, 11); 6001 expect(prefix.offset, 11);
6761 expect(prefixedIdentifier.period, isNotNull); 6002 expect(prefixedIdentifier.period, isNotNull);
6762 SimpleIdentifier identifier = prefixedIdentifier.identifier; 6003 SimpleIdentifier identifier = prefixedIdentifier.identifier;
6763 expect(identifier.token, isNotNull); 6004 expect(identifier.token, isNotNull);
6764 expect(identifier.name, "b"); 6005 expect(identifier.name, "b");
6765 expect(identifier.offset, 13); 6006 expect(identifier.offset, 13);
6766 } 6007 }
6767 6008
6768 void test_parseCommentReference_new_simple() { 6009 void test_parseCommentReference_new_simple() {
6769 CommentReference reference = 6010 CommentReference reference =
6770 ParserTestCase.parse("parseCommentReference", <Object>["new a", 5], ""); 6011 ParserTestCase.parse("parseCommentReference", <Object>["new a", 5], "");
6771 SimpleIdentifier identifier = EngineTestCase.assertInstanceOf( 6012 SimpleIdentifier identifier = EngineTestCase.assertInstanceOf(
6772 (obj) => obj is SimpleIdentifier, 6013 (obj) => obj is SimpleIdentifier, SimpleIdentifier,
6773 SimpleIdentifier,
6774 reference.identifier); 6014 reference.identifier);
6775 expect(identifier.token, isNotNull); 6015 expect(identifier.token, isNotNull);
6776 expect(identifier.name, "a"); 6016 expect(identifier.name, "a");
6777 expect(identifier.offset, 9); 6017 expect(identifier.offset, 9);
6778 } 6018 }
6779 6019
6780 void test_parseCommentReference_prefixed() { 6020 void test_parseCommentReference_prefixed() {
6781 CommentReference reference = 6021 CommentReference reference =
6782 ParserTestCase.parse("parseCommentReference", <Object>["a.b", 7], ""); 6022 ParserTestCase.parse("parseCommentReference", <Object>["a.b", 7], "");
6783 PrefixedIdentifier prefixedIdentifier = EngineTestCase.assertInstanceOf( 6023 PrefixedIdentifier prefixedIdentifier = EngineTestCase.assertInstanceOf(
6784 (obj) => obj is PrefixedIdentifier, 6024 (obj) => obj is PrefixedIdentifier, PrefixedIdentifier,
6785 PrefixedIdentifier,
6786 reference.identifier); 6025 reference.identifier);
6787 SimpleIdentifier prefix = prefixedIdentifier.prefix; 6026 SimpleIdentifier prefix = prefixedIdentifier.prefix;
6788 expect(prefix.token, isNotNull); 6027 expect(prefix.token, isNotNull);
6789 expect(prefix.name, "a"); 6028 expect(prefix.name, "a");
6790 expect(prefix.offset, 7); 6029 expect(prefix.offset, 7);
6791 expect(prefixedIdentifier.period, isNotNull); 6030 expect(prefixedIdentifier.period, isNotNull);
6792 SimpleIdentifier identifier = prefixedIdentifier.identifier; 6031 SimpleIdentifier identifier = prefixedIdentifier.identifier;
6793 expect(identifier.token, isNotNull); 6032 expect(identifier.token, isNotNull);
6794 expect(identifier.name, "b"); 6033 expect(identifier.name, "b");
6795 expect(identifier.offset, 9); 6034 expect(identifier.offset, 9);
6796 } 6035 }
6797 6036
6798 void test_parseCommentReference_simple() { 6037 void test_parseCommentReference_simple() {
6799 CommentReference reference = 6038 CommentReference reference =
6800 ParserTestCase.parse("parseCommentReference", <Object>["a", 5], ""); 6039 ParserTestCase.parse("parseCommentReference", <Object>["a", 5], "");
6801 SimpleIdentifier identifier = EngineTestCase.assertInstanceOf( 6040 SimpleIdentifier identifier = EngineTestCase.assertInstanceOf(
6802 (obj) => obj is SimpleIdentifier, 6041 (obj) => obj is SimpleIdentifier, SimpleIdentifier,
6803 SimpleIdentifier,
6804 reference.identifier); 6042 reference.identifier);
6805 expect(identifier.token, isNotNull); 6043 expect(identifier.token, isNotNull);
6806 expect(identifier.name, "a"); 6044 expect(identifier.name, "a");
6807 expect(identifier.offset, 5); 6045 expect(identifier.offset, 5);
6808 } 6046 }
6809 6047
6810 void test_parseCommentReference_synthetic() { 6048 void test_parseCommentReference_synthetic() {
6811 CommentReference reference = 6049 CommentReference reference =
6812 ParserTestCase.parse("parseCommentReference", <Object>["", 5], ""); 6050 ParserTestCase.parse("parseCommentReference", <Object>["", 5], "");
6813 SimpleIdentifier identifier = EngineTestCase.assertInstanceOf( 6051 SimpleIdentifier identifier = EngineTestCase.assertInstanceOf(
6814 (obj) => obj is SimpleIdentifier, 6052 (obj) => obj is SimpleIdentifier, SimpleIdentifier,
6815 SimpleIdentifier,
6816 reference.identifier); 6053 reference.identifier);
6817 expect(identifier, isNotNull); 6054 expect(identifier, isNotNull);
6818 expect(identifier.isSynthetic, isTrue); 6055 expect(identifier.isSynthetic, isTrue);
6819 expect(identifier.token, isNotNull); 6056 expect(identifier.token, isNotNull);
6820 expect(identifier.name, ""); 6057 expect(identifier.name, "");
6821 expect(identifier.offset, 5); 6058 expect(identifier.offset, 5);
6822 } 6059 }
6823 6060
6824 void test_parseCommentReferences_multiLine() { 6061 void test_parseCommentReferences_multiLine() {
6825 DocumentationCommentToken token = new DocumentationCommentToken( 6062 DocumentationCommentToken token = new DocumentationCommentToken(
6826 TokenType.MULTI_LINE_COMMENT, 6063 TokenType.MULTI_LINE_COMMENT, "/** xxx [a] yyy [bb] zzz */", 3);
6827 "/** xxx [a] yyy [bb] zzz */",
6828 3);
6829 List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[token]; 6064 List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[token];
6830 List<CommentReference> references = 6065 List<CommentReference> references =
6831 ParserTestCase.parse("parseCommentReferences", <Object>[tokens], ""); 6066 ParserTestCase.parse("parseCommentReferences", <Object>[tokens], "");
6832 List<Token> tokenReferences = token.references; 6067 List<Token> tokenReferences = token.references;
6833 expect(references, hasLength(2)); 6068 expect(references, hasLength(2));
6834 expect(tokenReferences, hasLength(2)); 6069 expect(tokenReferences, hasLength(2));
6835 { 6070 {
6836 CommentReference reference = references[0]; 6071 CommentReference reference = references[0];
6837 expect(reference, isNotNull); 6072 expect(reference, isNotNull);
6838 expect(reference.identifier, isNotNull); 6073 expect(reference.identifier, isNotNull);
(...skipping 10 matching lines...) Expand all
6849 expect(reference.offset, 20); 6084 expect(reference.offset, 20);
6850 // the reference is recorded in the comment token 6085 // the reference is recorded in the comment token
6851 Token referenceToken = tokenReferences[1]; 6086 Token referenceToken = tokenReferences[1];
6852 expect(referenceToken.offset, 20); 6087 expect(referenceToken.offset, 20);
6853 expect(referenceToken.lexeme, 'bb'); 6088 expect(referenceToken.lexeme, 'bb');
6854 } 6089 }
6855 } 6090 }
6856 6091
6857 void test_parseCommentReferences_notClosed_noIdentifier() { 6092 void test_parseCommentReferences_notClosed_noIdentifier() {
6858 List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[ 6093 List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[
6859 new DocumentationCommentToken( 6094 new DocumentationCommentToken(
6860 TokenType.MULTI_LINE_COMMENT, 6095 TokenType.MULTI_LINE_COMMENT, "/** [ some text", 5)
6861 "/** [ some text", 6096 ];
6862 5)];
6863 List<CommentReference> references = 6097 List<CommentReference> references =
6864 ParserTestCase.parse("parseCommentReferences", <Object>[tokens], ""); 6098 ParserTestCase.parse("parseCommentReferences", <Object>[tokens], "");
6865 expect(references, hasLength(1)); 6099 expect(references, hasLength(1));
6866 CommentReference reference = references[0]; 6100 CommentReference reference = references[0];
6867 expect(reference, isNotNull); 6101 expect(reference, isNotNull);
6868 expect(reference.identifier, isNotNull); 6102 expect(reference.identifier, isNotNull);
6869 expect(reference.identifier.isSynthetic, isTrue); 6103 expect(reference.identifier.isSynthetic, isTrue);
6870 expect(reference.identifier.name, ""); 6104 expect(reference.identifier.name, "");
6871 } 6105 }
6872 6106
6873 void test_parseCommentReferences_notClosed_withIdentifier() { 6107 void test_parseCommentReferences_notClosed_withIdentifier() {
6874 List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[ 6108 List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[
6875 new DocumentationCommentToken( 6109 new DocumentationCommentToken(
6876 TokenType.MULTI_LINE_COMMENT, 6110 TokenType.MULTI_LINE_COMMENT, "/** [namePrefix some text", 5)
6877 "/** [namePrefix some text", 6111 ];
6878 5)];
6879 List<CommentReference> references = 6112 List<CommentReference> references =
6880 ParserTestCase.parse("parseCommentReferences", <Object>[tokens], ""); 6113 ParserTestCase.parse("parseCommentReferences", <Object>[tokens], "");
6881 expect(references, hasLength(1)); 6114 expect(references, hasLength(1));
6882 CommentReference reference = references[0]; 6115 CommentReference reference = references[0];
6883 expect(reference, isNotNull); 6116 expect(reference, isNotNull);
6884 expect(reference.identifier, isNotNull); 6117 expect(reference.identifier, isNotNull);
6885 expect(reference.identifier.isSynthetic, isFalse); 6118 expect(reference.identifier.isSynthetic, isFalse);
6886 expect(reference.identifier.name, "namePrefix"); 6119 expect(reference.identifier.name, "namePrefix");
6887 } 6120 }
6888 6121
6889 void test_parseCommentReferences_singleLine() { 6122 void test_parseCommentReferences_singleLine() {
6890 List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[ 6123 List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[
6891 new DocumentationCommentToken( 6124 new DocumentationCommentToken(
6892 TokenType.SINGLE_LINE_COMMENT, 6125 TokenType.SINGLE_LINE_COMMENT, "/// xxx [a] yyy [b] zzz", 3),
6893 "/// xxx [a] yyy [b] zzz", 6126 new DocumentationCommentToken(
6894 3), 6127 TokenType.SINGLE_LINE_COMMENT, "/// x [c]", 28)
6895 new DocumentationCommentToken(TokenType.SINGLE_LINE_COMMENT, "/// x [c]" , 28)]; 6128 ];
6896 List<CommentReference> references = 6129 List<CommentReference> references =
6897 ParserTestCase.parse("parseCommentReferences", <Object>[tokens], ""); 6130 ParserTestCase.parse("parseCommentReferences", <Object>[tokens], "");
6898 expect(references, hasLength(3)); 6131 expect(references, hasLength(3));
6899 CommentReference reference = references[0]; 6132 CommentReference reference = references[0];
6900 expect(reference, isNotNull); 6133 expect(reference, isNotNull);
6901 expect(reference.identifier, isNotNull); 6134 expect(reference.identifier, isNotNull);
6902 expect(reference.offset, 12); 6135 expect(reference.offset, 12);
6903 reference = references[1]; 6136 reference = references[1];
6904 expect(reference, isNotNull); 6137 expect(reference, isNotNull);
6905 expect(reference.identifier, isNotNull); 6138 expect(reference.identifier, isNotNull);
6906 expect(reference.offset, 20); 6139 expect(reference.offset, 20);
6907 reference = references[2]; 6140 reference = references[2];
6908 expect(reference, isNotNull); 6141 expect(reference, isNotNull);
6909 expect(reference.identifier, isNotNull); 6142 expect(reference.identifier, isNotNull);
6910 expect(reference.offset, 35); 6143 expect(reference.offset, 35);
6911 } 6144 }
6912 6145
6913 void test_parseCommentReferences_skipCodeBlock_bracketed() { 6146 void test_parseCommentReferences_skipCodeBlock_bracketed() {
6914 List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[ 6147 List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[
6915 new DocumentationCommentToken( 6148 new DocumentationCommentToken(
6916 TokenType.MULTI_LINE_COMMENT, 6149 TokenType.MULTI_LINE_COMMENT, "/** [:xxx [a] yyy:] [b] zzz */", 3)
6917 "/** [:xxx [a] yyy:] [b] zzz */", 6150 ];
6918 3)];
6919 List<CommentReference> references = 6151 List<CommentReference> references =
6920 ParserTestCase.parse("parseCommentReferences", <Object>[tokens], ""); 6152 ParserTestCase.parse("parseCommentReferences", <Object>[tokens], "");
6921 expect(references, hasLength(1)); 6153 expect(references, hasLength(1));
6922 CommentReference reference = references[0]; 6154 CommentReference reference = references[0];
6923 expect(reference, isNotNull); 6155 expect(reference, isNotNull);
6924 expect(reference.identifier, isNotNull); 6156 expect(reference.identifier, isNotNull);
6925 expect(reference.offset, 24); 6157 expect(reference.offset, 24);
6926 } 6158 }
6927 6159
6928 void test_parseCommentReferences_skipCodeBlock_spaces() { 6160 void test_parseCommentReferences_skipCodeBlock_spaces() {
6929 List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[ 6161 List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[
6930 new DocumentationCommentToken( 6162 new DocumentationCommentToken(TokenType.MULTI_LINE_COMMENT,
6931 TokenType.MULTI_LINE_COMMENT, 6163 "/**\n * a[i]\n * xxx [i] zzz\n */", 3)
6932 "/**\n * a[i]\n * xxx [i] zzz\n */", 6164 ];
6933 3)];
6934 List<CommentReference> references = 6165 List<CommentReference> references =
6935 ParserTestCase.parse("parseCommentReferences", <Object>[tokens], ""); 6166 ParserTestCase.parse("parseCommentReferences", <Object>[tokens], "");
6936 expect(references, hasLength(1)); 6167 expect(references, hasLength(1));
6937 CommentReference reference = references[0]; 6168 CommentReference reference = references[0];
6938 expect(reference, isNotNull); 6169 expect(reference, isNotNull);
6939 expect(reference.identifier, isNotNull); 6170 expect(reference.identifier, isNotNull);
6940 expect(reference.offset, 27); 6171 expect(reference.offset, 27);
6941 } 6172 }
6942 6173
6943 void test_parseCommentReferences_skipLinkDefinition() { 6174 void test_parseCommentReferences_skipLinkDefinition() {
6944 List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[ 6175 List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[
6945 new DocumentationCommentToken( 6176 new DocumentationCommentToken(TokenType.MULTI_LINE_COMMENT,
6946 TokenType.MULTI_LINE_COMMENT, 6177 "/** [a]: http://www.google.com (Google) [b] zzz */", 3)
6947 "/** [a]: http://www.google.com (Google) [b] zzz */", 6178 ];
6948 3)];
6949 List<CommentReference> references = 6179 List<CommentReference> references =
6950 ParserTestCase.parse("parseCommentReferences", <Object>[tokens], ""); 6180 ParserTestCase.parse("parseCommentReferences", <Object>[tokens], "");
6951 expect(references, hasLength(1)); 6181 expect(references, hasLength(1));
6952 CommentReference reference = references[0]; 6182 CommentReference reference = references[0];
6953 expect(reference, isNotNull); 6183 expect(reference, isNotNull);
6954 expect(reference.identifier, isNotNull); 6184 expect(reference.identifier, isNotNull);
6955 expect(reference.offset, 44); 6185 expect(reference.offset, 44);
6956 } 6186 }
6957 6187
6958 void test_parseCommentReferences_skipLinked() { 6188 void test_parseCommentReferences_skipLinked() {
6959 List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[ 6189 List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[
6960 new DocumentationCommentToken( 6190 new DocumentationCommentToken(TokenType.MULTI_LINE_COMMENT,
6961 TokenType.MULTI_LINE_COMMENT, 6191 "/** [a](http://www.google.com) [b] zzz */", 3)
6962 "/** [a](http://www.google.com) [b] zzz */", 6192 ];
6963 3)];
6964 List<CommentReference> references = 6193 List<CommentReference> references =
6965 ParserTestCase.parse("parseCommentReferences", <Object>[tokens], ""); 6194 ParserTestCase.parse("parseCommentReferences", <Object>[tokens], "");
6966 expect(references, hasLength(1)); 6195 expect(references, hasLength(1));
6967 CommentReference reference = references[0]; 6196 CommentReference reference = references[0];
6968 expect(reference, isNotNull); 6197 expect(reference, isNotNull);
6969 expect(reference.identifier, isNotNull); 6198 expect(reference.identifier, isNotNull);
6970 expect(reference.offset, 35); 6199 expect(reference.offset, 35);
6971 } 6200 }
6972 6201
6973 void test_parseCommentReferences_skipReferenceLink() { 6202 void test_parseCommentReferences_skipReferenceLink() {
6974 List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[ 6203 List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[
6975 new DocumentationCommentToken( 6204 new DocumentationCommentToken(
6976 TokenType.MULTI_LINE_COMMENT, 6205 TokenType.MULTI_LINE_COMMENT, "/** [a][c] [b] zzz */", 3)
6977 "/** [a][c] [b] zzz */", 6206 ];
6978 3)];
6979 List<CommentReference> references = 6207 List<CommentReference> references =
6980 ParserTestCase.parse("parseCommentReferences", <Object>[tokens], ""); 6208 ParserTestCase.parse("parseCommentReferences", <Object>[tokens], "");
6981 expect(references, hasLength(1)); 6209 expect(references, hasLength(1));
6982 CommentReference reference = references[0]; 6210 CommentReference reference = references[0];
6983 expect(reference, isNotNull); 6211 expect(reference, isNotNull);
6984 expect(reference.identifier, isNotNull); 6212 expect(reference.identifier, isNotNull);
6985 expect(reference.offset, 15); 6213 expect(reference.offset, 15);
6986 } 6214 }
6987 6215
6988 void test_parseCompilationUnit_abstractAsPrefix_parameterized() { 6216 void test_parseCompilationUnit_abstractAsPrefix_parameterized() {
6989 CompilationUnit unit = ParserTestCase.parse4( 6217 CompilationUnit unit = ParserTestCase.parse4("parseCompilationUnit",
6990 "parseCompilationUnit",
6991 "abstract<dynamic> _abstract = new abstract.A();"); 6218 "abstract<dynamic> _abstract = new abstract.A();");
6992 expect(unit.scriptTag, isNull); 6219 expect(unit.scriptTag, isNull);
6993 expect(unit.directives, hasLength(0)); 6220 expect(unit.directives, hasLength(0));
6994 expect(unit.declarations, hasLength(1)); 6221 expect(unit.declarations, hasLength(1));
6995 } 6222 }
6996 6223
6997 void test_parseCompilationUnit_builtIn_asFunctionName() { 6224 void test_parseCompilationUnit_builtIn_asFunctionName() {
6998 ParserTestCase.parse4("parseCompilationUnit", "abstract(x) => 0;"); 6225 ParserTestCase.parse4("parseCompilationUnit", "abstract(x) => 0;");
6999 ParserTestCase.parse4("parseCompilationUnit", "as(x) => 0;"); 6226 ParserTestCase.parse4("parseCompilationUnit", "as(x) => 0;");
7000 ParserTestCase.parse4("parseCompilationUnit", "dynamic(x) => 0;"); 6227 ParserTestCase.parse4("parseCompilationUnit", "dynamic(x) => 0;");
7001 ParserTestCase.parse4("parseCompilationUnit", "export(x) => 0;"); 6228 ParserTestCase.parse4("parseCompilationUnit", "export(x) => 0;");
7002 ParserTestCase.parse4("parseCompilationUnit", "external(x) => 0;"); 6229 ParserTestCase.parse4("parseCompilationUnit", "external(x) => 0;");
7003 ParserTestCase.parse4("parseCompilationUnit", "factory(x) => 0;"); 6230 ParserTestCase.parse4("parseCompilationUnit", "factory(x) => 0;");
7004 ParserTestCase.parse4("parseCompilationUnit", "get(x) => 0;"); 6231 ParserTestCase.parse4("parseCompilationUnit", "get(x) => 0;");
7005 ParserTestCase.parse4("parseCompilationUnit", "implements(x) => 0;"); 6232 ParserTestCase.parse4("parseCompilationUnit", "implements(x) => 0;");
7006 ParserTestCase.parse4("parseCompilationUnit", "import(x) => 0;"); 6233 ParserTestCase.parse4("parseCompilationUnit", "import(x) => 0;");
7007 ParserTestCase.parse4("parseCompilationUnit", "library(x) => 0;"); 6234 ParserTestCase.parse4("parseCompilationUnit", "library(x) => 0;");
7008 ParserTestCase.parse4("parseCompilationUnit", "operator(x) => 0;"); 6235 ParserTestCase.parse4("parseCompilationUnit", "operator(x) => 0;");
7009 ParserTestCase.parse4("parseCompilationUnit", "part(x) => 0;"); 6236 ParserTestCase.parse4("parseCompilationUnit", "part(x) => 0;");
7010 ParserTestCase.parse4("parseCompilationUnit", "set(x) => 0;"); 6237 ParserTestCase.parse4("parseCompilationUnit", "set(x) => 0;");
7011 ParserTestCase.parse4("parseCompilationUnit", "static(x) => 0;"); 6238 ParserTestCase.parse4("parseCompilationUnit", "static(x) => 0;");
7012 ParserTestCase.parse4("parseCompilationUnit", "typedef(x) => 0;"); 6239 ParserTestCase.parse4("parseCompilationUnit", "typedef(x) => 0;");
7013 } 6240 }
7014 6241
7015 void test_parseCompilationUnit_directives_multiple() { 6242 void test_parseCompilationUnit_directives_multiple() {
7016 CompilationUnit unit = 6243 CompilationUnit unit = ParserTestCase.parse4(
7017 ParserTestCase.parse4("parseCompilationUnit", "library l;\npart 'a.dart' ;"); 6244 "parseCompilationUnit", "library l;\npart 'a.dart';");
7018 expect(unit.scriptTag, isNull); 6245 expect(unit.scriptTag, isNull);
7019 expect(unit.directives, hasLength(2)); 6246 expect(unit.directives, hasLength(2));
7020 expect(unit.declarations, hasLength(0)); 6247 expect(unit.declarations, hasLength(0));
7021 } 6248 }
7022 6249
7023 void test_parseCompilationUnit_directives_single() { 6250 void test_parseCompilationUnit_directives_single() {
7024 CompilationUnit unit = 6251 CompilationUnit unit =
7025 ParserTestCase.parse4("parseCompilationUnit", "library l;"); 6252 ParserTestCase.parse4("parseCompilationUnit", "library l;");
7026 expect(unit.scriptTag, isNull); 6253 expect(unit.scriptTag, isNull);
7027 expect(unit.directives, hasLength(1)); 6254 expect(unit.directives, hasLength(1));
7028 expect(unit.declarations, hasLength(0)); 6255 expect(unit.declarations, hasLength(0));
7029 } 6256 }
7030 6257
7031 void test_parseCompilationUnit_empty() { 6258 void test_parseCompilationUnit_empty() {
7032 CompilationUnit unit = ParserTestCase.parse4("parseCompilationUnit", ""); 6259 CompilationUnit unit = ParserTestCase.parse4("parseCompilationUnit", "");
7033 expect(unit.scriptTag, isNull); 6260 expect(unit.scriptTag, isNull);
7034 expect(unit.directives, hasLength(0)); 6261 expect(unit.directives, hasLength(0));
7035 expect(unit.declarations, hasLength(0)); 6262 expect(unit.declarations, hasLength(0));
7036 } 6263 }
7037 6264
7038 void test_parseCompilationUnit_exportAsPrefix() { 6265 void test_parseCompilationUnit_exportAsPrefix() {
7039 CompilationUnit unit = ParserTestCase.parse4( 6266 CompilationUnit unit = ParserTestCase.parse4(
7040 "parseCompilationUnit", 6267 "parseCompilationUnit", "export.A _export = new export.A();");
7041 "export.A _export = new export.A();");
7042 expect(unit.scriptTag, isNull); 6268 expect(unit.scriptTag, isNull);
7043 expect(unit.directives, hasLength(0)); 6269 expect(unit.directives, hasLength(0));
7044 expect(unit.declarations, hasLength(1)); 6270 expect(unit.declarations, hasLength(1));
7045 } 6271 }
7046 6272
7047 void test_parseCompilationUnit_exportAsPrefix_parameterized() { 6273 void test_parseCompilationUnit_exportAsPrefix_parameterized() {
7048 CompilationUnit unit = ParserTestCase.parse4( 6274 CompilationUnit unit = ParserTestCase.parse4(
7049 "parseCompilationUnit", 6275 "parseCompilationUnit", "export<dynamic> _export = new export.A();");
7050 "export<dynamic> _export = new export.A();");
7051 expect(unit.scriptTag, isNull); 6276 expect(unit.scriptTag, isNull);
7052 expect(unit.directives, hasLength(0)); 6277 expect(unit.directives, hasLength(0));
7053 expect(unit.declarations, hasLength(1)); 6278 expect(unit.declarations, hasLength(1));
7054 } 6279 }
7055 6280
7056 void test_parseCompilationUnit_operatorAsPrefix_parameterized() { 6281 void test_parseCompilationUnit_operatorAsPrefix_parameterized() {
7057 CompilationUnit unit = ParserTestCase.parse4( 6282 CompilationUnit unit = ParserTestCase.parse4("parseCompilationUnit",
7058 "parseCompilationUnit",
7059 "operator<dynamic> _operator = new operator.A();"); 6283 "operator<dynamic> _operator = new operator.A();");
7060 expect(unit.scriptTag, isNull); 6284 expect(unit.scriptTag, isNull);
7061 expect(unit.directives, hasLength(0)); 6285 expect(unit.directives, hasLength(0));
7062 expect(unit.declarations, hasLength(1)); 6286 expect(unit.declarations, hasLength(1));
7063 } 6287 }
7064 6288
7065 void test_parseCompilationUnit_script() { 6289 void test_parseCompilationUnit_script() {
7066 CompilationUnit unit = 6290 CompilationUnit unit =
7067 ParserTestCase.parse4("parseCompilationUnit", "#! /bin/dart"); 6291 ParserTestCase.parse4("parseCompilationUnit", "#! /bin/dart");
7068 expect(unit.scriptTag, isNotNull); 6292 expect(unit.scriptTag, isNotNull);
(...skipping 12 matching lines...) Expand all
7081 void test_parseCompilationUnit_topLevelDeclaration() { 6305 void test_parseCompilationUnit_topLevelDeclaration() {
7082 CompilationUnit unit = 6306 CompilationUnit unit =
7083 ParserTestCase.parse4("parseCompilationUnit", "class A {}"); 6307 ParserTestCase.parse4("parseCompilationUnit", "class A {}");
7084 expect(unit.scriptTag, isNull); 6308 expect(unit.scriptTag, isNull);
7085 expect(unit.directives, hasLength(0)); 6309 expect(unit.directives, hasLength(0));
7086 expect(unit.declarations, hasLength(1)); 6310 expect(unit.declarations, hasLength(1));
7087 } 6311 }
7088 6312
7089 void test_parseCompilationUnit_typedefAsPrefix() { 6313 void test_parseCompilationUnit_typedefAsPrefix() {
7090 CompilationUnit unit = ParserTestCase.parse4( 6314 CompilationUnit unit = ParserTestCase.parse4(
7091 "parseCompilationUnit", 6315 "parseCompilationUnit", "typedef.A _typedef = new typedef.A();");
7092 "typedef.A _typedef = new typedef.A();");
7093 expect(unit.scriptTag, isNull); 6316 expect(unit.scriptTag, isNull);
7094 expect(unit.directives, hasLength(0)); 6317 expect(unit.directives, hasLength(0));
7095 expect(unit.declarations, hasLength(1)); 6318 expect(unit.declarations, hasLength(1));
7096 } 6319 }
7097 6320
7098 void test_parseCompilationUnitMember_abstractAsPrefix() { 6321 void test_parseCompilationUnitMember_abstractAsPrefix() {
7099 TopLevelVariableDeclaration declaration = ParserTestCase.parse( 6322 TopLevelVariableDeclaration declaration = ParserTestCase.parse(
7100 "parseCompilationUnitMember", 6323 "parseCompilationUnitMember", <Object>[
7101 <Object>[emptyCommentAndMetadata()], 6324 emptyCommentAndMetadata()
7102 "abstract.A _abstract = new abstract.A();"); 6325 ], "abstract.A _abstract = new abstract.A();");
7103 expect(declaration.semicolon, isNotNull); 6326 expect(declaration.semicolon, isNotNull);
7104 expect(declaration.variables, isNotNull); 6327 expect(declaration.variables, isNotNull);
7105 } 6328 }
7106 6329
7107 void test_parseCompilationUnitMember_class() { 6330 void test_parseCompilationUnitMember_class() {
7108 ClassDeclaration declaration = ParserTestCase.parse( 6331 ClassDeclaration declaration = ParserTestCase.parse(
7109 "parseCompilationUnitMember", 6332 "parseCompilationUnitMember", <Object>[
7110 <Object>[emptyCommentAndMetadata()], 6333 emptyCommentAndMetadata()
7111 "class A {}"); 6334 ], "class A {}");
7112 expect(declaration.name.name, "A"); 6335 expect(declaration.name.name, "A");
7113 expect(declaration.members, hasLength(0)); 6336 expect(declaration.members, hasLength(0));
7114 } 6337 }
7115 6338
7116 void test_parseCompilationUnitMember_classTypeAlias() { 6339 void test_parseCompilationUnitMember_classTypeAlias() {
7117 ClassTypeAlias alias = ParserTestCase.parse( 6340 ClassTypeAlias alias = ParserTestCase.parse("parseCompilationUnitMember",
7118 "parseCompilationUnitMember", 6341 <Object>[emptyCommentAndMetadata()], "abstract class A = B with C;");
7119 <Object>[emptyCommentAndMetadata()],
7120 "abstract class A = B with C;");
7121 expect(alias.name.name, "A"); 6342 expect(alias.name.name, "A");
7122 expect(alias.abstractKeyword, isNotNull); 6343 expect(alias.abstractKeyword, isNotNull);
7123 } 6344 }
7124 6345
7125 void test_parseCompilationUnitMember_constVariable() { 6346 void test_parseCompilationUnitMember_constVariable() {
7126 TopLevelVariableDeclaration declaration = ParserTestCase.parse( 6347 TopLevelVariableDeclaration declaration = ParserTestCase.parse(
7127 "parseCompilationUnitMember", 6348 "parseCompilationUnitMember", <Object>[
7128 <Object>[emptyCommentAndMetadata()], 6349 emptyCommentAndMetadata()
7129 "const int x = 0;"); 6350 ], "const int x = 0;");
7130 expect(declaration.semicolon, isNotNull); 6351 expect(declaration.semicolon, isNotNull);
7131 expect(declaration.variables, isNotNull); 6352 expect(declaration.variables, isNotNull);
7132 } 6353 }
7133 6354
7134 void test_parseCompilationUnitMember_finalVariable() { 6355 void test_parseCompilationUnitMember_finalVariable() {
7135 TopLevelVariableDeclaration declaration = ParserTestCase.parse( 6356 TopLevelVariableDeclaration declaration = ParserTestCase.parse(
7136 "parseCompilationUnitMember", 6357 "parseCompilationUnitMember", <Object>[
7137 <Object>[emptyCommentAndMetadata()], 6358 emptyCommentAndMetadata()
7138 "final x = 0;"); 6359 ], "final x = 0;");
7139 expect(declaration.semicolon, isNotNull); 6360 expect(declaration.semicolon, isNotNull);
7140 expect(declaration.variables, isNotNull); 6361 expect(declaration.variables, isNotNull);
7141 } 6362 }
7142 6363
7143 void test_parseCompilationUnitMember_function_external_noType() { 6364 void test_parseCompilationUnitMember_function_external_noType() {
7144 FunctionDeclaration declaration = ParserTestCase.parse( 6365 FunctionDeclaration declaration = ParserTestCase.parse(
7145 "parseCompilationUnitMember", 6366 "parseCompilationUnitMember", <Object>[
7146 <Object>[emptyCommentAndMetadata()], 6367 emptyCommentAndMetadata()
7147 "external f();"); 6368 ], "external f();");
7148 expect(declaration.externalKeyword, isNotNull); 6369 expect(declaration.externalKeyword, isNotNull);
7149 expect(declaration.functionExpression, isNotNull); 6370 expect(declaration.functionExpression, isNotNull);
7150 expect(declaration.propertyKeyword, isNull); 6371 expect(declaration.propertyKeyword, isNull);
7151 } 6372 }
7152 6373
7153 void test_parseCompilationUnitMember_function_external_type() { 6374 void test_parseCompilationUnitMember_function_external_type() {
7154 FunctionDeclaration declaration = ParserTestCase.parse( 6375 FunctionDeclaration declaration = ParserTestCase.parse(
7155 "parseCompilationUnitMember", 6376 "parseCompilationUnitMember", <Object>[
7156 <Object>[emptyCommentAndMetadata()], 6377 emptyCommentAndMetadata()
7157 "external int f();"); 6378 ], "external int f();");
7158 expect(declaration.externalKeyword, isNotNull); 6379 expect(declaration.externalKeyword, isNotNull);
7159 expect(declaration.functionExpression, isNotNull); 6380 expect(declaration.functionExpression, isNotNull);
7160 expect(declaration.propertyKeyword, isNull); 6381 expect(declaration.propertyKeyword, isNull);
7161 } 6382 }
7162 6383
7163 void test_parseCompilationUnitMember_function_noType() { 6384 void test_parseCompilationUnitMember_function_noType() {
7164 FunctionDeclaration declaration = ParserTestCase.parse( 6385 FunctionDeclaration declaration = ParserTestCase.parse(
7165 "parseCompilationUnitMember", 6386 "parseCompilationUnitMember", <Object>[
7166 <Object>[emptyCommentAndMetadata()], 6387 emptyCommentAndMetadata()
7167 "f() {}"); 6388 ], "f() {}");
7168 expect(declaration.functionExpression, isNotNull); 6389 expect(declaration.functionExpression, isNotNull);
7169 expect(declaration.propertyKeyword, isNull); 6390 expect(declaration.propertyKeyword, isNull);
7170 } 6391 }
7171 6392
7172 void test_parseCompilationUnitMember_function_type() { 6393 void test_parseCompilationUnitMember_function_type() {
7173 FunctionDeclaration declaration = ParserTestCase.parse( 6394 FunctionDeclaration declaration = ParserTestCase.parse(
7174 "parseCompilationUnitMember", 6395 "parseCompilationUnitMember", <Object>[
7175 <Object>[emptyCommentAndMetadata()], 6396 emptyCommentAndMetadata()
7176 "int f() {}"); 6397 ], "int f() {}");
7177 expect(declaration.functionExpression, isNotNull); 6398 expect(declaration.functionExpression, isNotNull);
7178 expect(declaration.propertyKeyword, isNull); 6399 expect(declaration.propertyKeyword, isNull);
7179 } 6400 }
7180 6401
7181 void test_parseCompilationUnitMember_function_void() { 6402 void test_parseCompilationUnitMember_function_void() {
7182 FunctionDeclaration declaration = ParserTestCase.parse( 6403 FunctionDeclaration declaration = ParserTestCase.parse(
7183 "parseCompilationUnitMember", 6404 "parseCompilationUnitMember", <Object>[
7184 <Object>[emptyCommentAndMetadata()], 6405 emptyCommentAndMetadata()
7185 "void f() {}"); 6406 ], "void f() {}");
7186 expect(declaration.returnType, isNotNull); 6407 expect(declaration.returnType, isNotNull);
7187 } 6408 }
7188 6409
7189 void test_parseCompilationUnitMember_getter_external_noType() { 6410 void test_parseCompilationUnitMember_getter_external_noType() {
7190 FunctionDeclaration declaration = ParserTestCase.parse( 6411 FunctionDeclaration declaration = ParserTestCase.parse(
7191 "parseCompilationUnitMember", 6412 "parseCompilationUnitMember", <Object>[
7192 <Object>[emptyCommentAndMetadata()], 6413 emptyCommentAndMetadata()
7193 "external get p;"); 6414 ], "external get p;");
7194 expect(declaration.externalKeyword, isNotNull); 6415 expect(declaration.externalKeyword, isNotNull);
7195 expect(declaration.functionExpression, isNotNull); 6416 expect(declaration.functionExpression, isNotNull);
7196 expect(declaration.propertyKeyword, isNotNull); 6417 expect(declaration.propertyKeyword, isNotNull);
7197 } 6418 }
7198 6419
7199 void test_parseCompilationUnitMember_getter_external_type() { 6420 void test_parseCompilationUnitMember_getter_external_type() {
7200 FunctionDeclaration declaration = ParserTestCase.parse( 6421 FunctionDeclaration declaration = ParserTestCase.parse(
7201 "parseCompilationUnitMember", 6422 "parseCompilationUnitMember", <Object>[
7202 <Object>[emptyCommentAndMetadata()], 6423 emptyCommentAndMetadata()
7203 "external int get p;"); 6424 ], "external int get p;");
7204 expect(declaration.externalKeyword, isNotNull); 6425 expect(declaration.externalKeyword, isNotNull);
7205 expect(declaration.functionExpression, isNotNull); 6426 expect(declaration.functionExpression, isNotNull);
7206 expect(declaration.propertyKeyword, isNotNull); 6427 expect(declaration.propertyKeyword, isNotNull);
7207 } 6428 }
7208 6429
7209 void test_parseCompilationUnitMember_getter_noType() { 6430 void test_parseCompilationUnitMember_getter_noType() {
7210 FunctionDeclaration declaration = ParserTestCase.parse( 6431 FunctionDeclaration declaration = ParserTestCase.parse(
7211 "parseCompilationUnitMember", 6432 "parseCompilationUnitMember", <Object>[
7212 <Object>[emptyCommentAndMetadata()], 6433 emptyCommentAndMetadata()
7213 "get p => 0;"); 6434 ], "get p => 0;");
7214 expect(declaration.functionExpression, isNotNull); 6435 expect(declaration.functionExpression, isNotNull);
7215 expect(declaration.propertyKeyword, isNotNull); 6436 expect(declaration.propertyKeyword, isNotNull);
7216 } 6437 }
7217 6438
7218 void test_parseCompilationUnitMember_getter_type() { 6439 void test_parseCompilationUnitMember_getter_type() {
7219 FunctionDeclaration declaration = ParserTestCase.parse( 6440 FunctionDeclaration declaration = ParserTestCase.parse(
7220 "parseCompilationUnitMember", 6441 "parseCompilationUnitMember", <Object>[
7221 <Object>[emptyCommentAndMetadata()], 6442 emptyCommentAndMetadata()
7222 "int get p => 0;"); 6443 ], "int get p => 0;");
7223 expect(declaration.functionExpression, isNotNull); 6444 expect(declaration.functionExpression, isNotNull);
7224 expect(declaration.propertyKeyword, isNotNull); 6445 expect(declaration.propertyKeyword, isNotNull);
7225 } 6446 }
7226 6447
7227 void test_parseCompilationUnitMember_setter_external_noType() { 6448 void test_parseCompilationUnitMember_setter_external_noType() {
7228 FunctionDeclaration declaration = ParserTestCase.parse( 6449 FunctionDeclaration declaration = ParserTestCase.parse(
7229 "parseCompilationUnitMember", 6450 "parseCompilationUnitMember", <Object>[
7230 <Object>[emptyCommentAndMetadata()], 6451 emptyCommentAndMetadata()
7231 "external set p(v);"); 6452 ], "external set p(v);");
7232 expect(declaration.externalKeyword, isNotNull); 6453 expect(declaration.externalKeyword, isNotNull);
7233 expect(declaration.functionExpression, isNotNull); 6454 expect(declaration.functionExpression, isNotNull);
7234 expect(declaration.propertyKeyword, isNotNull); 6455 expect(declaration.propertyKeyword, isNotNull);
7235 } 6456 }
7236 6457
7237 void test_parseCompilationUnitMember_setter_external_type() { 6458 void test_parseCompilationUnitMember_setter_external_type() {
7238 FunctionDeclaration declaration = ParserTestCase.parse( 6459 FunctionDeclaration declaration = ParserTestCase.parse(
7239 "parseCompilationUnitMember", 6460 "parseCompilationUnitMember", <Object>[
7240 <Object>[emptyCommentAndMetadata()], 6461 emptyCommentAndMetadata()
7241 "external void set p(int v);"); 6462 ], "external void set p(int v);");
7242 expect(declaration.externalKeyword, isNotNull); 6463 expect(declaration.externalKeyword, isNotNull);
7243 expect(declaration.functionExpression, isNotNull); 6464 expect(declaration.functionExpression, isNotNull);
7244 expect(declaration.propertyKeyword, isNotNull); 6465 expect(declaration.propertyKeyword, isNotNull);
7245 } 6466 }
7246 6467
7247 void test_parseCompilationUnitMember_setter_noType() { 6468 void test_parseCompilationUnitMember_setter_noType() {
7248 FunctionDeclaration declaration = ParserTestCase.parse( 6469 FunctionDeclaration declaration = ParserTestCase.parse(
7249 "parseCompilationUnitMember", 6470 "parseCompilationUnitMember", <Object>[
7250 <Object>[emptyCommentAndMetadata()], 6471 emptyCommentAndMetadata()
7251 "set p(v) {}"); 6472 ], "set p(v) {}");
7252 expect(declaration.functionExpression, isNotNull); 6473 expect(declaration.functionExpression, isNotNull);
7253 expect(declaration.propertyKeyword, isNotNull); 6474 expect(declaration.propertyKeyword, isNotNull);
7254 } 6475 }
7255 6476
7256 void test_parseCompilationUnitMember_setter_type() { 6477 void test_parseCompilationUnitMember_setter_type() {
7257 FunctionDeclaration declaration = ParserTestCase.parse( 6478 FunctionDeclaration declaration = ParserTestCase.parse(
7258 "parseCompilationUnitMember", 6479 "parseCompilationUnitMember", <Object>[
7259 <Object>[emptyCommentAndMetadata()], 6480 emptyCommentAndMetadata()
7260 "void set p(int v) {}"); 6481 ], "void set p(int v) {}");
7261 expect(declaration.functionExpression, isNotNull); 6482 expect(declaration.functionExpression, isNotNull);
7262 expect(declaration.propertyKeyword, isNotNull); 6483 expect(declaration.propertyKeyword, isNotNull);
7263 expect(declaration.returnType, isNotNull); 6484 expect(declaration.returnType, isNotNull);
7264 } 6485 }
7265 6486
7266 void test_parseCompilationUnitMember_typeAlias_abstract() { 6487 void test_parseCompilationUnitMember_typeAlias_abstract() {
7267 ClassTypeAlias typeAlias = ParserTestCase.parse( 6488 ClassTypeAlias typeAlias = ParserTestCase.parse(
7268 "parseCompilationUnitMember", 6489 "parseCompilationUnitMember", <Object>[
7269 <Object>[emptyCommentAndMetadata()], 6490 emptyCommentAndMetadata()
7270 "abstract class C = S with M;"); 6491 ], "abstract class C = S with M;");
7271 expect(typeAlias.typedefKeyword, isNotNull); 6492 expect(typeAlias.typedefKeyword, isNotNull);
7272 expect(typeAlias.name.name, "C"); 6493 expect(typeAlias.name.name, "C");
7273 expect(typeAlias.typeParameters, isNull); 6494 expect(typeAlias.typeParameters, isNull);
7274 expect(typeAlias.equals, isNotNull); 6495 expect(typeAlias.equals, isNotNull);
7275 expect(typeAlias.abstractKeyword, isNotNull); 6496 expect(typeAlias.abstractKeyword, isNotNull);
7276 expect(typeAlias.superclass.name.name, "S"); 6497 expect(typeAlias.superclass.name.name, "S");
7277 expect(typeAlias.withClause, isNotNull); 6498 expect(typeAlias.withClause, isNotNull);
7278 expect(typeAlias.implementsClause, isNull); 6499 expect(typeAlias.implementsClause, isNull);
7279 expect(typeAlias.semicolon, isNotNull); 6500 expect(typeAlias.semicolon, isNotNull);
7280 } 6501 }
7281 6502
7282 void test_parseCompilationUnitMember_typeAlias_generic() { 6503 void test_parseCompilationUnitMember_typeAlias_generic() {
7283 ClassTypeAlias typeAlias = ParserTestCase.parse( 6504 ClassTypeAlias typeAlias = ParserTestCase.parse(
7284 "parseCompilationUnitMember", 6505 "parseCompilationUnitMember", <Object>[
7285 <Object>[emptyCommentAndMetadata()], 6506 emptyCommentAndMetadata()
7286 "class C<E> = S<E> with M<E> implements I<E>;"); 6507 ], "class C<E> = S<E> with M<E> implements I<E>;");
7287 expect(typeAlias.typedefKeyword, isNotNull); 6508 expect(typeAlias.typedefKeyword, isNotNull);
7288 expect(typeAlias.name.name, "C"); 6509 expect(typeAlias.name.name, "C");
7289 expect(typeAlias.typeParameters.typeParameters, hasLength(1)); 6510 expect(typeAlias.typeParameters.typeParameters, hasLength(1));
7290 expect(typeAlias.equals, isNotNull); 6511 expect(typeAlias.equals, isNotNull);
7291 expect(typeAlias.abstractKeyword, isNull); 6512 expect(typeAlias.abstractKeyword, isNull);
7292 expect(typeAlias.superclass.name.name, "S"); 6513 expect(typeAlias.superclass.name.name, "S");
7293 expect(typeAlias.withClause, isNotNull); 6514 expect(typeAlias.withClause, isNotNull);
7294 expect(typeAlias.implementsClause, isNotNull); 6515 expect(typeAlias.implementsClause, isNotNull);
7295 expect(typeAlias.semicolon, isNotNull); 6516 expect(typeAlias.semicolon, isNotNull);
7296 } 6517 }
7297 6518
7298 void test_parseCompilationUnitMember_typeAlias_implements() { 6519 void test_parseCompilationUnitMember_typeAlias_implements() {
7299 ClassTypeAlias typeAlias = ParserTestCase.parse( 6520 ClassTypeAlias typeAlias = ParserTestCase.parse(
7300 "parseCompilationUnitMember", 6521 "parseCompilationUnitMember", <Object>[
7301 <Object>[emptyCommentAndMetadata()], 6522 emptyCommentAndMetadata()
7302 "class C = S with M implements I;"); 6523 ], "class C = S with M implements I;");
7303 expect(typeAlias.typedefKeyword, isNotNull); 6524 expect(typeAlias.typedefKeyword, isNotNull);
7304 expect(typeAlias.name.name, "C"); 6525 expect(typeAlias.name.name, "C");
7305 expect(typeAlias.typeParameters, isNull); 6526 expect(typeAlias.typeParameters, isNull);
7306 expect(typeAlias.equals, isNotNull); 6527 expect(typeAlias.equals, isNotNull);
7307 expect(typeAlias.abstractKeyword, isNull); 6528 expect(typeAlias.abstractKeyword, isNull);
7308 expect(typeAlias.superclass.name.name, "S"); 6529 expect(typeAlias.superclass.name.name, "S");
7309 expect(typeAlias.withClause, isNotNull); 6530 expect(typeAlias.withClause, isNotNull);
7310 expect(typeAlias.implementsClause, isNotNull); 6531 expect(typeAlias.implementsClause, isNotNull);
7311 expect(typeAlias.semicolon, isNotNull); 6532 expect(typeAlias.semicolon, isNotNull);
7312 } 6533 }
7313 6534
7314 void test_parseCompilationUnitMember_typeAlias_noImplements() { 6535 void test_parseCompilationUnitMember_typeAlias_noImplements() {
7315 ClassTypeAlias typeAlias = ParserTestCase.parse( 6536 ClassTypeAlias typeAlias = ParserTestCase.parse(
7316 "parseCompilationUnitMember", 6537 "parseCompilationUnitMember", <Object>[
7317 <Object>[emptyCommentAndMetadata()], 6538 emptyCommentAndMetadata()
7318 "class C = S with M;"); 6539 ], "class C = S with M;");
7319 expect(typeAlias.typedefKeyword, isNotNull); 6540 expect(typeAlias.typedefKeyword, isNotNull);
7320 expect(typeAlias.name.name, "C"); 6541 expect(typeAlias.name.name, "C");
7321 expect(typeAlias.typeParameters, isNull); 6542 expect(typeAlias.typeParameters, isNull);
7322 expect(typeAlias.equals, isNotNull); 6543 expect(typeAlias.equals, isNotNull);
7323 expect(typeAlias.abstractKeyword, isNull); 6544 expect(typeAlias.abstractKeyword, isNull);
7324 expect(typeAlias.superclass.name.name, "S"); 6545 expect(typeAlias.superclass.name.name, "S");
7325 expect(typeAlias.withClause, isNotNull); 6546 expect(typeAlias.withClause, isNotNull);
7326 expect(typeAlias.implementsClause, isNull); 6547 expect(typeAlias.implementsClause, isNull);
7327 expect(typeAlias.semicolon, isNotNull); 6548 expect(typeAlias.semicolon, isNotNull);
7328 } 6549 }
7329 6550
7330 void test_parseCompilationUnitMember_typedef() { 6551 void test_parseCompilationUnitMember_typedef() {
7331 FunctionTypeAlias typeAlias = ParserTestCase.parse( 6552 FunctionTypeAlias typeAlias = ParserTestCase.parse(
7332 "parseCompilationUnitMember", 6553 "parseCompilationUnitMember", <Object>[
7333 <Object>[emptyCommentAndMetadata()], 6554 emptyCommentAndMetadata()
7334 "typedef F();"); 6555 ], "typedef F();");
7335 expect(typeAlias.name.name, "F"); 6556 expect(typeAlias.name.name, "F");
7336 expect(typeAlias.parameters.parameters, hasLength(0)); 6557 expect(typeAlias.parameters.parameters, hasLength(0));
7337 } 6558 }
7338 6559
7339 void test_parseCompilationUnitMember_variable() { 6560 void test_parseCompilationUnitMember_variable() {
7340 TopLevelVariableDeclaration declaration = ParserTestCase.parse( 6561 TopLevelVariableDeclaration declaration = ParserTestCase.parse(
7341 "parseCompilationUnitMember", 6562 "parseCompilationUnitMember", <Object>[
7342 <Object>[emptyCommentAndMetadata()], 6563 emptyCommentAndMetadata()
7343 "var x = 0;"); 6564 ], "var x = 0;");
7344 expect(declaration.semicolon, isNotNull); 6565 expect(declaration.semicolon, isNotNull);
7345 expect(declaration.variables, isNotNull); 6566 expect(declaration.variables, isNotNull);
7346 } 6567 }
7347 6568
7348 void test_parseCompilationUnitMember_variableGet() { 6569 void test_parseCompilationUnitMember_variableGet() {
7349 TopLevelVariableDeclaration declaration = ParserTestCase.parse( 6570 TopLevelVariableDeclaration declaration = ParserTestCase.parse(
7350 "parseCompilationUnitMember", 6571 "parseCompilationUnitMember", <Object>[
7351 <Object>[emptyCommentAndMetadata()], 6572 emptyCommentAndMetadata()
7352 "String get = null;"); 6573 ], "String get = null;");
7353 expect(declaration.semicolon, isNotNull); 6574 expect(declaration.semicolon, isNotNull);
7354 expect(declaration.variables, isNotNull); 6575 expect(declaration.variables, isNotNull);
7355 } 6576 }
7356 6577
7357 void test_parseCompilationUnitMember_variableSet() { 6578 void test_parseCompilationUnitMember_variableSet() {
7358 TopLevelVariableDeclaration declaration = ParserTestCase.parse( 6579 TopLevelVariableDeclaration declaration = ParserTestCase.parse(
7359 "parseCompilationUnitMember", 6580 "parseCompilationUnitMember", <Object>[
7360 <Object>[emptyCommentAndMetadata()], 6581 emptyCommentAndMetadata()
7361 "String set = null;"); 6582 ], "String set = null;");
7362 expect(declaration.semicolon, isNotNull); 6583 expect(declaration.semicolon, isNotNull);
7363 expect(declaration.variables, isNotNull); 6584 expect(declaration.variables, isNotNull);
7364 } 6585 }
7365 6586
7366 void test_parseConditionalExpression() { 6587 void test_parseConditionalExpression() {
7367 ConditionalExpression expression = 6588 ConditionalExpression expression =
7368 ParserTestCase.parse4("parseConditionalExpression", "x ? y : z"); 6589 ParserTestCase.parse4("parseConditionalExpression", "x ? y : z");
7369 expect(expression.condition, isNotNull); 6590 expect(expression.condition, isNotNull);
7370 expect(expression.question, isNotNull); 6591 expect(expression.question, isNotNull);
7371 expect(expression.thenExpression, isNotNull); 6592 expect(expression.thenExpression, isNotNull);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
7427 // TODO(brianwilkerson) Implement tests for this method. 6648 // TODO(brianwilkerson) Implement tests for this method.
7428 // parse("parseConstructor", new Class[] {Parser.CommentAndMetadata.class, 6649 // parse("parseConstructor", new Class[] {Parser.CommentAndMetadata.class,
7429 // Token.class, Token.class, SimpleIdentifier.class, Token.class, 6650 // Token.class, Token.class, SimpleIdentifier.class, Token.class,
7430 // SimpleIdentifier.class, FormalParameterList.class}, new Object[] {empt yCommentAndMetadata(), 6651 // SimpleIdentifier.class, FormalParameterList.class}, new Object[] {empt yCommentAndMetadata(),
7431 // null, null, null, null, null, null}, ""); 6652 // null, null, null, null, null, null}, "");
7432 } 6653 }
7433 6654
7434 void test_parseConstructor_with_pseudo_function_literal() { 6655 void test_parseConstructor_with_pseudo_function_literal() {
7435 // "(b) {}" should not be misinterpreted as a function literal even though 6656 // "(b) {}" should not be misinterpreted as a function literal even though
7436 // it looks like one. 6657 // it looks like one.
7437 ClassMember classMember = 6658 ClassMember classMember = ParserTestCase.parse(
7438 ParserTestCase.parse("parseClassMember", <Object>["C"], "C() : a = (b) { }"); 6659 "parseClassMember", <Object>["C"], "C() : a = (b) {}");
7439 EngineTestCase.assertInstanceOf( 6660 EngineTestCase.assertInstanceOf((obj) => obj is ConstructorDeclaration,
7440 (obj) => obj is ConstructorDeclaration, 6661 ConstructorDeclaration, classMember);
7441 ConstructorDeclaration,
7442 classMember);
7443 ConstructorDeclaration constructor = classMember as ConstructorDeclaration; 6662 ConstructorDeclaration constructor = classMember as ConstructorDeclaration;
7444 NodeList<ConstructorInitializer> initializers = constructor.initializers; 6663 NodeList<ConstructorInitializer> initializers = constructor.initializers;
7445 expect(initializers, hasLength(1)); 6664 expect(initializers, hasLength(1));
7446 ConstructorInitializer initializer = initializers[0]; 6665 ConstructorInitializer initializer = initializers[0];
7447 EngineTestCase.assertInstanceOf( 6666 EngineTestCase.assertInstanceOf((obj) => obj is ConstructorFieldInitializer,
7448 (obj) => obj is ConstructorFieldInitializer, 6667 ConstructorFieldInitializer, initializer);
7449 ConstructorFieldInitializer, 6668 EngineTestCase.assertInstanceOf((obj) => obj is ParenthesizedExpression,
7450 initializer);
7451 EngineTestCase.assertInstanceOf(
7452 (obj) => obj is ParenthesizedExpression,
7453 ParenthesizedExpression, 6669 ParenthesizedExpression,
7454 (initializer as ConstructorFieldInitializer).expression); 6670 (initializer as ConstructorFieldInitializer).expression);
7455 EngineTestCase.assertInstanceOf( 6671 EngineTestCase.assertInstanceOf(
7456 (obj) => obj is BlockFunctionBody, 6672 (obj) => obj is BlockFunctionBody, BlockFunctionBody, constructor.body);
7457 BlockFunctionBody,
7458 constructor.body);
7459 } 6673 }
7460 6674
7461 void test_parseConstructorFieldInitializer_qualified() { 6675 void test_parseConstructorFieldInitializer_qualified() {
7462 ConstructorFieldInitializer invocation = 6676 ConstructorFieldInitializer invocation =
7463 ParserTestCase.parse4("parseConstructorFieldInitializer", "this.a = b"); 6677 ParserTestCase.parse4("parseConstructorFieldInitializer", "this.a = b");
7464 expect(invocation.equals, isNotNull); 6678 expect(invocation.equals, isNotNull);
7465 expect(invocation.expression, isNotNull); 6679 expect(invocation.expression, isNotNull);
7466 expect(invocation.fieldName, isNotNull); 6680 expect(invocation.fieldName, isNotNull);
7467 expect(invocation.thisKeyword, isNotNull); 6681 expect(invocation.thisKeyword, isNotNull);
7468 expect(invocation.period, isNotNull); 6682 expect(invocation.period, isNotNull);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
7504 void test_parseConstructorName_unnamed_prefixed() { 6718 void test_parseConstructorName_unnamed_prefixed() {
7505 ConstructorName name = 6719 ConstructorName name =
7506 ParserTestCase.parse4("parseConstructorName", "p.A;"); 6720 ParserTestCase.parse4("parseConstructorName", "p.A;");
7507 expect(name.type, isNotNull); 6721 expect(name.type, isNotNull);
7508 expect(name.period, isNull); 6722 expect(name.period, isNull);
7509 expect(name.name, isNull); 6723 expect(name.name, isNull);
7510 } 6724 }
7511 6725
7512 void test_parseContinueStatement_label() { 6726 void test_parseContinueStatement_label() {
7513 ContinueStatement statement = ParserTestCase.parse4( 6727 ContinueStatement statement = ParserTestCase.parse4(
7514 "parseContinueStatement", 6728 "parseContinueStatement", "continue foo;", [
7515 "continue foo;", 6729 ParserErrorCode.CONTINUE_OUTSIDE_OF_LOOP
7516 [ParserErrorCode.CONTINUE_OUTSIDE_OF_LOOP]); 6730 ]);
7517 expect(statement.continueKeyword, isNotNull); 6731 expect(statement.continueKeyword, isNotNull);
7518 expect(statement.label, isNotNull); 6732 expect(statement.label, isNotNull);
7519 expect(statement.semicolon, isNotNull); 6733 expect(statement.semicolon, isNotNull);
7520 } 6734 }
7521 6735
7522 void test_parseContinueStatement_noLabel() { 6736 void test_parseContinueStatement_noLabel() {
7523 ContinueStatement statement = ParserTestCase.parse4( 6737 ContinueStatement statement = ParserTestCase.parse4(
7524 "parseContinueStatement", 6738 "parseContinueStatement", "continue;", [
7525 "continue;", 6739 ParserErrorCode.CONTINUE_OUTSIDE_OF_LOOP
7526 [ParserErrorCode.CONTINUE_OUTSIDE_OF_LOOP]); 6740 ]);
7527 expect(statement.continueKeyword, isNotNull); 6741 expect(statement.continueKeyword, isNotNull);
7528 expect(statement.label, isNull); 6742 expect(statement.label, isNull);
7529 expect(statement.semicolon, isNotNull); 6743 expect(statement.semicolon, isNotNull);
7530 } 6744 }
7531 6745
7532 void test_parseDirective_export() { 6746 void test_parseDirective_export() {
7533 ExportDirective directive = ParserTestCase.parse( 6747 ExportDirective directive = ParserTestCase.parse("parseDirective", <Object>[
7534 "parseDirective", 6748 emptyCommentAndMetadata()
7535 <Object>[emptyCommentAndMetadata()], 6749 ], "export 'lib/lib.dart';");
7536 "export 'lib/lib.dart';");
7537 expect(directive.keyword, isNotNull); 6750 expect(directive.keyword, isNotNull);
7538 expect(directive.uri, isNotNull); 6751 expect(directive.uri, isNotNull);
7539 expect(directive.combinators, hasLength(0)); 6752 expect(directive.combinators, hasLength(0));
7540 expect(directive.semicolon, isNotNull); 6753 expect(directive.semicolon, isNotNull);
7541 } 6754 }
7542 6755
7543 void test_parseDirective_import() { 6756 void test_parseDirective_import() {
7544 ImportDirective directive = ParserTestCase.parse( 6757 ImportDirective directive = ParserTestCase.parse("parseDirective", <Object>[
7545 "parseDirective", 6758 emptyCommentAndMetadata()
7546 <Object>[emptyCommentAndMetadata()], 6759 ], "import 'lib/lib.dart';");
7547 "import 'lib/lib.dart';");
7548 expect(directive.keyword, isNotNull); 6760 expect(directive.keyword, isNotNull);
7549 expect(directive.uri, isNotNull); 6761 expect(directive.uri, isNotNull);
7550 expect(directive.asKeyword, isNull); 6762 expect(directive.asKeyword, isNull);
7551 expect(directive.prefix, isNull); 6763 expect(directive.prefix, isNull);
7552 expect(directive.combinators, hasLength(0)); 6764 expect(directive.combinators, hasLength(0));
7553 expect(directive.semicolon, isNotNull); 6765 expect(directive.semicolon, isNotNull);
7554 } 6766 }
7555 6767
7556 void test_parseDirective_library() { 6768 void test_parseDirective_library() {
7557 LibraryDirective directive = ParserTestCase.parse( 6769 LibraryDirective directive = ParserTestCase.parse(
7558 "parseDirective", 6770 "parseDirective", <Object>[emptyCommentAndMetadata()], "library l;");
7559 <Object>[emptyCommentAndMetadata()],
7560 "library l;");
7561 expect(directive.libraryKeyword, isNotNull); 6771 expect(directive.libraryKeyword, isNotNull);
7562 expect(directive.name, isNotNull); 6772 expect(directive.name, isNotNull);
7563 expect(directive.semicolon, isNotNull); 6773 expect(directive.semicolon, isNotNull);
7564 } 6774 }
7565 6775
7566 void test_parseDirective_part() { 6776 void test_parseDirective_part() {
7567 PartDirective directive = ParserTestCase.parse( 6777 PartDirective directive = ParserTestCase.parse("parseDirective", <Object>[
7568 "parseDirective", 6778 emptyCommentAndMetadata()
7569 <Object>[emptyCommentAndMetadata()], 6779 ], "part 'lib/lib.dart';");
7570 "part 'lib/lib.dart';");
7571 expect(directive.partKeyword, isNotNull); 6780 expect(directive.partKeyword, isNotNull);
7572 expect(directive.uri, isNotNull); 6781 expect(directive.uri, isNotNull);
7573 expect(directive.semicolon, isNotNull); 6782 expect(directive.semicolon, isNotNull);
7574 } 6783 }
7575 6784
7576 void test_parseDirective_partOf() { 6785 void test_parseDirective_partOf() {
7577 PartOfDirective directive = ParserTestCase.parse( 6786 PartOfDirective directive = ParserTestCase.parse(
7578 "parseDirective", 6787 "parseDirective", <Object>[emptyCommentAndMetadata()], "part of l;");
7579 <Object>[emptyCommentAndMetadata()],
7580 "part of l;");
7581 expect(directive.partKeyword, isNotNull); 6788 expect(directive.partKeyword, isNotNull);
7582 expect(directive.ofKeyword, isNotNull); 6789 expect(directive.ofKeyword, isNotNull);
7583 expect(directive.libraryName, isNotNull); 6790 expect(directive.libraryName, isNotNull);
7584 expect(directive.semicolon, isNotNull); 6791 expect(directive.semicolon, isNotNull);
7585 } 6792 }
7586 6793
7587 void test_parseDirectives_complete() { 6794 void test_parseDirectives_complete() {
7588 CompilationUnit unit = 6795 CompilationUnit unit =
7589 _parseDirectives("#! /bin/dart\nlibrary l;\nclass A {}"); 6796 _parseDirectives("#! /bin/dart\nlibrary l;\nclass A {}");
7590 expect(unit.scriptTag, isNotNull); 6797 expect(unit.scriptTag, isNotNull);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
7643 expect(comment.isDocumentation, isTrue); 6850 expect(comment.isDocumentation, isTrue);
7644 expect(comment.isEndOfLine, isFalse); 6851 expect(comment.isEndOfLine, isFalse);
7645 NodeList<CommentReference> references = comment.references; 6852 NodeList<CommentReference> references = comment.references;
7646 expect(references, hasLength(1)); 6853 expect(references, hasLength(1));
7647 CommentReference reference = references[0]; 6854 CommentReference reference = references[0];
7648 expect(reference, isNotNull); 6855 expect(reference, isNotNull);
7649 expect(reference.offset, 5); 6856 expect(reference.offset, 5);
7650 } 6857 }
7651 6858
7652 void test_parseDocumentationComment_endOfLine() { 6859 void test_parseDocumentationComment_endOfLine() {
7653 Comment comment = 6860 Comment comment = ParserTestCase.parse4(
7654 ParserTestCase.parse4("parseDocumentationComment", "/// \n/// \n class") ; 6861 "parseDocumentationComment", "/// \n/// \n class");
7655 expect(comment.isBlock, isFalse); 6862 expect(comment.isBlock, isFalse);
7656 expect(comment.isDocumentation, isTrue); 6863 expect(comment.isDocumentation, isTrue);
7657 expect(comment.isEndOfLine, isFalse); 6864 expect(comment.isEndOfLine, isFalse);
7658 } 6865 }
7659 6866
7660 void test_parseDoStatement() { 6867 void test_parseDoStatement() {
7661 DoStatement statement = 6868 DoStatement statement =
7662 ParserTestCase.parse4("parseDoStatement", "do {} while (x);"); 6869 ParserTestCase.parse4("parseDoStatement", "do {} while (x);");
7663 expect(statement.doKeyword, isNotNull); 6870 expect(statement.doKeyword, isNotNull);
7664 expect(statement.body, isNotNull); 6871 expect(statement.body, isNotNull);
7665 expect(statement.whileKeyword, isNotNull); 6872 expect(statement.whileKeyword, isNotNull);
7666 expect(statement.leftParenthesis, isNotNull); 6873 expect(statement.leftParenthesis, isNotNull);
7667 expect(statement.condition, isNotNull); 6874 expect(statement.condition, isNotNull);
7668 expect(statement.rightParenthesis, isNotNull); 6875 expect(statement.rightParenthesis, isNotNull);
7669 expect(statement.semicolon, isNotNull); 6876 expect(statement.semicolon, isNotNull);
7670 } 6877 }
7671 6878
7672 void test_parseEmptyStatement() { 6879 void test_parseEmptyStatement() {
7673 EmptyStatement statement = 6880 EmptyStatement statement =
7674 ParserTestCase.parse4("parseEmptyStatement", ";"); 6881 ParserTestCase.parse4("parseEmptyStatement", ";");
7675 expect(statement.semicolon, isNotNull); 6882 expect(statement.semicolon, isNotNull);
7676 } 6883 }
7677 6884
7678 void test_parseEnumDeclaration_one() { 6885 void test_parseEnumDeclaration_one() {
7679 EnumDeclaration declaration = ParserTestCase.parse( 6886 EnumDeclaration declaration = ParserTestCase.parse("parseEnumDeclaration",
7680 "parseEnumDeclaration", 6887 <Object>[emptyCommentAndMetadata()], "enum E {ONE}");
7681 <Object>[emptyCommentAndMetadata()],
7682 "enum E {ONE}");
7683 expect(declaration.documentationComment, isNull); 6888 expect(declaration.documentationComment, isNull);
7684 expect(declaration.enumKeyword, isNotNull); 6889 expect(declaration.enumKeyword, isNotNull);
7685 expect(declaration.leftBracket, isNotNull); 6890 expect(declaration.leftBracket, isNotNull);
7686 expect(declaration.name, isNotNull); 6891 expect(declaration.name, isNotNull);
7687 expect(declaration.constants, hasLength(1)); 6892 expect(declaration.constants, hasLength(1));
7688 expect(declaration.rightBracket, isNotNull); 6893 expect(declaration.rightBracket, isNotNull);
7689 } 6894 }
7690 6895
7691 void test_parseEnumDeclaration_trailingComma() { 6896 void test_parseEnumDeclaration_trailingComma() {
7692 EnumDeclaration declaration = ParserTestCase.parse( 6897 EnumDeclaration declaration = ParserTestCase.parse("parseEnumDeclaration",
7693 "parseEnumDeclaration", 6898 <Object>[emptyCommentAndMetadata()], "enum E {ONE,}");
7694 <Object>[emptyCommentAndMetadata()],
7695 "enum E {ONE,}");
7696 expect(declaration.documentationComment, isNull); 6899 expect(declaration.documentationComment, isNull);
7697 expect(declaration.enumKeyword, isNotNull); 6900 expect(declaration.enumKeyword, isNotNull);
7698 expect(declaration.leftBracket, isNotNull); 6901 expect(declaration.leftBracket, isNotNull);
7699 expect(declaration.name, isNotNull); 6902 expect(declaration.name, isNotNull);
7700 expect(declaration.constants, hasLength(1)); 6903 expect(declaration.constants, hasLength(1));
7701 expect(declaration.rightBracket, isNotNull); 6904 expect(declaration.rightBracket, isNotNull);
7702 } 6905 }
7703 6906
7704 void test_parseEnumDeclaration_two() { 6907 void test_parseEnumDeclaration_two() {
7705 EnumDeclaration declaration = ParserTestCase.parse( 6908 EnumDeclaration declaration = ParserTestCase.parse("parseEnumDeclaration",
7706 "parseEnumDeclaration", 6909 <Object>[emptyCommentAndMetadata()], "enum E {ONE, TWO}");
7707 <Object>[emptyCommentAndMetadata()],
7708 "enum E {ONE, TWO}");
7709 expect(declaration.documentationComment, isNull); 6910 expect(declaration.documentationComment, isNull);
7710 expect(declaration.enumKeyword, isNotNull); 6911 expect(declaration.enumKeyword, isNotNull);
7711 expect(declaration.leftBracket, isNotNull); 6912 expect(declaration.leftBracket, isNotNull);
7712 expect(declaration.name, isNotNull); 6913 expect(declaration.name, isNotNull);
7713 expect(declaration.constants, hasLength(2)); 6914 expect(declaration.constants, hasLength(2));
7714 expect(declaration.rightBracket, isNotNull); 6915 expect(declaration.rightBracket, isNotNull);
7715 } 6916 }
7716 6917
7717 void test_parseEqualityExpression_normal() { 6918 void test_parseEqualityExpression_normal() {
7718 BinaryExpression expression = 6919 BinaryExpression expression =
7719 ParserTestCase.parse4("parseEqualityExpression", "x == y"); 6920 ParserTestCase.parse4("parseEqualityExpression", "x == y");
7720 expect(expression.leftOperand, isNotNull); 6921 expect(expression.leftOperand, isNotNull);
7721 expect(expression.operator, isNotNull); 6922 expect(expression.operator, isNotNull);
7722 expect(expression.operator.type, TokenType.EQ_EQ); 6923 expect(expression.operator.type, TokenType.EQ_EQ);
7723 expect(expression.rightOperand, isNotNull); 6924 expect(expression.rightOperand, isNotNull);
7724 } 6925 }
7725 6926
7726 void test_parseEqualityExpression_super() { 6927 void test_parseEqualityExpression_super() {
7727 BinaryExpression expression = 6928 BinaryExpression expression =
7728 ParserTestCase.parse4("parseEqualityExpression", "super == y"); 6929 ParserTestCase.parse4("parseEqualityExpression", "super == y");
7729 EngineTestCase.assertInstanceOf( 6930 EngineTestCase.assertInstanceOf((obj) => obj is SuperExpression,
7730 (obj) => obj is SuperExpression, 6931 SuperExpression, expression.leftOperand);
7731 SuperExpression,
7732 expression.leftOperand);
7733 expect(expression.operator, isNotNull); 6932 expect(expression.operator, isNotNull);
7734 expect(expression.operator.type, TokenType.EQ_EQ); 6933 expect(expression.operator.type, TokenType.EQ_EQ);
7735 expect(expression.rightOperand, isNotNull); 6934 expect(expression.rightOperand, isNotNull);
7736 } 6935 }
7737 6936
7738 void test_parseExportDirective_hide() { 6937 void test_parseExportDirective_hide() {
7739 ExportDirective directive = ParserTestCase.parse( 6938 ExportDirective directive = ParserTestCase.parse("parseExportDirective",
7740 "parseExportDirective", 6939 <Object>[
7741 <Object>[emptyCommentAndMetadata()], 6940 emptyCommentAndMetadata()
7742 "export 'lib/lib.dart' hide A, B;"); 6941 ], "export 'lib/lib.dart' hide A, B;");
7743 expect(directive.keyword, isNotNull); 6942 expect(directive.keyword, isNotNull);
7744 expect(directive.uri, isNotNull); 6943 expect(directive.uri, isNotNull);
7745 expect(directive.combinators, hasLength(1)); 6944 expect(directive.combinators, hasLength(1));
7746 expect(directive.semicolon, isNotNull); 6945 expect(directive.semicolon, isNotNull);
7747 } 6946 }
7748 6947
7749 void test_parseExportDirective_hide_show() { 6948 void test_parseExportDirective_hide_show() {
7750 ExportDirective directive = ParserTestCase.parse( 6949 ExportDirective directive = ParserTestCase.parse("parseExportDirective",
7751 "parseExportDirective", 6950 <Object>[
7752 <Object>[emptyCommentAndMetadata()], 6951 emptyCommentAndMetadata()
7753 "export 'lib/lib.dart' hide A show B;"); 6952 ], "export 'lib/lib.dart' hide A show B;");
7754 expect(directive.keyword, isNotNull); 6953 expect(directive.keyword, isNotNull);
7755 expect(directive.uri, isNotNull); 6954 expect(directive.uri, isNotNull);
7756 expect(directive.combinators, hasLength(2)); 6955 expect(directive.combinators, hasLength(2));
7757 expect(directive.semicolon, isNotNull); 6956 expect(directive.semicolon, isNotNull);
7758 } 6957 }
7759 6958
7760 void test_parseExportDirective_noCombinator() { 6959 void test_parseExportDirective_noCombinator() {
7761 ExportDirective directive = ParserTestCase.parse( 6960 ExportDirective directive = ParserTestCase.parse("parseExportDirective",
7762 "parseExportDirective", 6961 <Object>[emptyCommentAndMetadata()], "export 'lib/lib.dart';");
7763 <Object>[emptyCommentAndMetadata()],
7764 "export 'lib/lib.dart';");
7765 expect(directive.keyword, isNotNull); 6962 expect(directive.keyword, isNotNull);
7766 expect(directive.uri, isNotNull); 6963 expect(directive.uri, isNotNull);
7767 expect(directive.combinators, hasLength(0)); 6964 expect(directive.combinators, hasLength(0));
7768 expect(directive.semicolon, isNotNull); 6965 expect(directive.semicolon, isNotNull);
7769 } 6966 }
7770 6967
7771 void test_parseExportDirective_show() { 6968 void test_parseExportDirective_show() {
7772 ExportDirective directive = ParserTestCase.parse( 6969 ExportDirective directive = ParserTestCase.parse("parseExportDirective",
7773 "parseExportDirective", 6970 <Object>[
7774 <Object>[emptyCommentAndMetadata()], 6971 emptyCommentAndMetadata()
7775 "export 'lib/lib.dart' show A, B;"); 6972 ], "export 'lib/lib.dart' show A, B;");
7776 expect(directive.keyword, isNotNull); 6973 expect(directive.keyword, isNotNull);
7777 expect(directive.uri, isNotNull); 6974 expect(directive.uri, isNotNull);
7778 expect(directive.combinators, hasLength(1)); 6975 expect(directive.combinators, hasLength(1));
7779 expect(directive.semicolon, isNotNull); 6976 expect(directive.semicolon, isNotNull);
7780 } 6977 }
7781 6978
7782 void test_parseExportDirective_show_hide() { 6979 void test_parseExportDirective_show_hide() {
7783 ExportDirective directive = ParserTestCase.parse( 6980 ExportDirective directive = ParserTestCase.parse("parseExportDirective",
7784 "parseExportDirective", 6981 <Object>[
7785 <Object>[emptyCommentAndMetadata()], 6982 emptyCommentAndMetadata()
7786 "export 'lib/lib.dart' show B hide A;"); 6983 ], "export 'lib/lib.dart' show B hide A;");
7787 expect(directive.keyword, isNotNull); 6984 expect(directive.keyword, isNotNull);
7788 expect(directive.uri, isNotNull); 6985 expect(directive.uri, isNotNull);
7789 expect(directive.combinators, hasLength(2)); 6986 expect(directive.combinators, hasLength(2));
7790 expect(directive.semicolon, isNotNull); 6987 expect(directive.semicolon, isNotNull);
7791 } 6988 }
7792 6989
7793 void test_parseExpression_assign() { 6990 void test_parseExpression_assign() {
7794 // TODO(brianwilkerson) Implement more tests for this method. 6991 // TODO(brianwilkerson) Implement more tests for this method.
7795 AssignmentExpression expression = 6992 AssignmentExpression expression =
7796 ParserTestCase.parse4("parseExpression", "x = y"); 6993 ParserTestCase.parse4("parseExpression", "x = y");
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
7840 ParserTestCase.parseExpression("() sync* {}"); 7037 ParserTestCase.parseExpression("() sync* {}");
7841 expect(expression.body, isNotNull); 7038 expect(expression.body, isNotNull);
7842 expect(expression.body.isAsynchronous, isFalse); 7039 expect(expression.body.isAsynchronous, isFalse);
7843 expect(expression.body.isGenerator, isTrue); 7040 expect(expression.body.isGenerator, isTrue);
7844 expect(expression.parameters, isNotNull); 7041 expect(expression.parameters, isNotNull);
7845 } 7042 }
7846 7043
7847 void test_parseExpression_invokeFunctionExpression() { 7044 void test_parseExpression_invokeFunctionExpression() {
7848 FunctionExpressionInvocation invocation = 7045 FunctionExpressionInvocation invocation =
7849 ParserTestCase.parse4("parseExpression", "(a) {return a + a;} (3)"); 7046 ParserTestCase.parse4("parseExpression", "(a) {return a + a;} (3)");
7850 EngineTestCase.assertInstanceOf( 7047 EngineTestCase.assertInstanceOf((obj) => obj is FunctionExpression,
7851 (obj) => obj is FunctionExpression, 7048 FunctionExpression, invocation.function);
7852 FunctionExpression,
7853 invocation.function);
7854 FunctionExpression expression = invocation.function as FunctionExpression; 7049 FunctionExpression expression = invocation.function as FunctionExpression;
7855 expect(expression.parameters, isNotNull); 7050 expect(expression.parameters, isNotNull);
7856 expect(expression.body, isNotNull); 7051 expect(expression.body, isNotNull);
7857 ArgumentList list = invocation.argumentList; 7052 ArgumentList list = invocation.argumentList;
7858 expect(list, isNotNull); 7053 expect(list, isNotNull);
7859 expect(list.arguments, hasLength(1)); 7054 expect(list.arguments, hasLength(1));
7860 } 7055 }
7861 7056
7862 void test_parseExpression_nonAwait() { 7057 void test_parseExpression_nonAwait() {
7863 MethodInvocation expression = ParserTestCase.parseExpression("await()"); 7058 MethodInvocation expression = ParserTestCase.parseExpression("await()");
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
7909 expect(invocation.methodName, isNotNull); 7104 expect(invocation.methodName, isNotNull);
7910 expect(invocation.argumentList, isNotNull); 7105 expect(invocation.argumentList, isNotNull);
7911 } 7106 }
7912 7107
7913 void test_parseExtendsClause() { 7108 void test_parseExtendsClause() {
7914 ExtendsClause clause = 7109 ExtendsClause clause =
7915 ParserTestCase.parse4("parseExtendsClause", "extends B"); 7110 ParserTestCase.parse4("parseExtendsClause", "extends B");
7916 expect(clause.extendsKeyword, isNotNull); 7111 expect(clause.extendsKeyword, isNotNull);
7917 expect(clause.superclass, isNotNull); 7112 expect(clause.superclass, isNotNull);
7918 EngineTestCase.assertInstanceOf( 7113 EngineTestCase.assertInstanceOf(
7919 (obj) => obj is TypeName, 7114 (obj) => obj is TypeName, TypeName, clause.superclass);
7920 TypeName,
7921 clause.superclass);
7922 } 7115 }
7923 7116
7924 void test_parseFinalConstVarOrType_const_noType() { 7117 void test_parseFinalConstVarOrType_const_noType() {
7925 FinalConstVarOrType result = 7118 FinalConstVarOrType result = ParserTestCase.parse(
7926 ParserTestCase.parse("parseFinalConstVarOrType", <Object>[false], "const "); 7119 "parseFinalConstVarOrType", <Object>[false], "const");
7927 Token keyword = result.keyword; 7120 Token keyword = result.keyword;
7928 expect(keyword, isNotNull); 7121 expect(keyword, isNotNull);
7929 expect(keyword.type, TokenType.KEYWORD); 7122 expect(keyword.type, TokenType.KEYWORD);
7930 expect((keyword as KeywordToken).keyword, Keyword.CONST); 7123 expect((keyword as KeywordToken).keyword, Keyword.CONST);
7931 expect(result.type, isNull); 7124 expect(result.type, isNull);
7932 } 7125 }
7933 7126
7934 void test_parseFinalConstVarOrType_const_type() { 7127 void test_parseFinalConstVarOrType_const_type() {
7935 FinalConstVarOrType result = 7128 FinalConstVarOrType result = ParserTestCase.parse(
7936 ParserTestCase.parse("parseFinalConstVarOrType", <Object>[false], "const A a"); 7129 "parseFinalConstVarOrType", <Object>[false], "const A a");
7937 Token keyword = result.keyword; 7130 Token keyword = result.keyword;
7938 expect(keyword, isNotNull); 7131 expect(keyword, isNotNull);
7939 expect(keyword.type, TokenType.KEYWORD); 7132 expect(keyword.type, TokenType.KEYWORD);
7940 expect((keyword as KeywordToken).keyword, Keyword.CONST); 7133 expect((keyword as KeywordToken).keyword, Keyword.CONST);
7941 expect(result.type, isNotNull); 7134 expect(result.type, isNotNull);
7942 } 7135 }
7943 7136
7944 void test_parseFinalConstVarOrType_final_noType() { 7137 void test_parseFinalConstVarOrType_final_noType() {
7945 FinalConstVarOrType result = 7138 FinalConstVarOrType result = ParserTestCase.parse(
7946 ParserTestCase.parse("parseFinalConstVarOrType", <Object>[false], "final "); 7139 "parseFinalConstVarOrType", <Object>[false], "final");
7947 Token keyword = result.keyword; 7140 Token keyword = result.keyword;
7948 expect(keyword, isNotNull); 7141 expect(keyword, isNotNull);
7949 expect(keyword.type, TokenType.KEYWORD); 7142 expect(keyword.type, TokenType.KEYWORD);
7950 expect((keyword as KeywordToken).keyword, Keyword.FINAL); 7143 expect((keyword as KeywordToken).keyword, Keyword.FINAL);
7951 expect(result.type, isNull); 7144 expect(result.type, isNull);
7952 } 7145 }
7953 7146
7954 void test_parseFinalConstVarOrType_final_prefixedType() { 7147 void test_parseFinalConstVarOrType_final_prefixedType() {
7955 FinalConstVarOrType result = ParserTestCase.parse( 7148 FinalConstVarOrType result = ParserTestCase.parse(
7956 "parseFinalConstVarOrType", 7149 "parseFinalConstVarOrType", <Object>[false], "final p.A a");
7957 <Object>[false],
7958 "final p.A a");
7959 Token keyword = result.keyword; 7150 Token keyword = result.keyword;
7960 expect(keyword, isNotNull); 7151 expect(keyword, isNotNull);
7961 expect(keyword.type, TokenType.KEYWORD); 7152 expect(keyword.type, TokenType.KEYWORD);
7962 expect((keyword as KeywordToken).keyword, Keyword.FINAL); 7153 expect((keyword as KeywordToken).keyword, Keyword.FINAL);
7963 expect(result.type, isNotNull); 7154 expect(result.type, isNotNull);
7964 } 7155 }
7965 7156
7966 void test_parseFinalConstVarOrType_final_type() { 7157 void test_parseFinalConstVarOrType_final_type() {
7967 FinalConstVarOrType result = 7158 FinalConstVarOrType result = ParserTestCase.parse(
7968 ParserTestCase.parse("parseFinalConstVarOrType", <Object>[false], "final A a"); 7159 "parseFinalConstVarOrType", <Object>[false], "final A a");
7969 Token keyword = result.keyword; 7160 Token keyword = result.keyword;
7970 expect(keyword, isNotNull); 7161 expect(keyword, isNotNull);
7971 expect(keyword.type, TokenType.KEYWORD); 7162 expect(keyword.type, TokenType.KEYWORD);
7972 expect((keyword as KeywordToken).keyword, Keyword.FINAL); 7163 expect((keyword as KeywordToken).keyword, Keyword.FINAL);
7973 expect(result.type, isNotNull); 7164 expect(result.type, isNotNull);
7974 } 7165 }
7975 7166
7976 void test_parseFinalConstVarOrType_type_parameterized() { 7167 void test_parseFinalConstVarOrType_type_parameterized() {
7977 FinalConstVarOrType result = 7168 FinalConstVarOrType result = ParserTestCase.parse(
7978 ParserTestCase.parse("parseFinalConstVarOrType", <Object>[false], "A<B> a"); 7169 "parseFinalConstVarOrType", <Object>[false], "A<B> a");
7979 expect(result.keyword, isNull); 7170 expect(result.keyword, isNull);
7980 expect(result.type, isNotNull); 7171 expect(result.type, isNotNull);
7981 } 7172 }
7982 7173
7983 void test_parseFinalConstVarOrType_type_prefixed() { 7174 void test_parseFinalConstVarOrType_type_prefixed() {
7984 FinalConstVarOrType result = 7175 FinalConstVarOrType result = ParserTestCase.parse(
7985 ParserTestCase.parse("parseFinalConstVarOrType", <Object>[false], "p.A a "); 7176 "parseFinalConstVarOrType", <Object>[false], "p.A a");
7986 expect(result.keyword, isNull); 7177 expect(result.keyword, isNull);
7987 expect(result.type, isNotNull); 7178 expect(result.type, isNotNull);
7988 } 7179 }
7989 7180
7990 void test_parseFinalConstVarOrType_type_prefixed_noIdentifier() { 7181 void test_parseFinalConstVarOrType_type_prefixed_noIdentifier() {
7991 FinalConstVarOrType result = 7182 FinalConstVarOrType result = ParserTestCase.parse(
7992 ParserTestCase.parse("parseFinalConstVarOrType", <Object>[false], "p.A," ); 7183 "parseFinalConstVarOrType", <Object>[false], "p.A,");
7993 expect(result.keyword, isNull); 7184 expect(result.keyword, isNull);
7994 expect(result.type, isNotNull); 7185 expect(result.type, isNotNull);
7995 } 7186 }
7996 7187
7997 void test_parseFinalConstVarOrType_type_prefixedAndParameterized() { 7188 void test_parseFinalConstVarOrType_type_prefixedAndParameterized() {
7998 FinalConstVarOrType result = 7189 FinalConstVarOrType result = ParserTestCase.parse(
7999 ParserTestCase.parse("parseFinalConstVarOrType", <Object>[false], "p.A<B > a"); 7190 "parseFinalConstVarOrType", <Object>[false], "p.A<B> a");
8000 expect(result.keyword, isNull); 7191 expect(result.keyword, isNull);
8001 expect(result.type, isNotNull); 7192 expect(result.type, isNotNull);
8002 } 7193 }
8003 7194
8004 void test_parseFinalConstVarOrType_type_simple() { 7195 void test_parseFinalConstVarOrType_type_simple() {
8005 FinalConstVarOrType result = 7196 FinalConstVarOrType result = ParserTestCase.parse(
8006 ParserTestCase.parse("parseFinalConstVarOrType", <Object>[false], "A a") ; 7197 "parseFinalConstVarOrType", <Object>[false], "A a");
8007 expect(result.keyword, isNull); 7198 expect(result.keyword, isNull);
8008 expect(result.type, isNotNull); 7199 expect(result.type, isNotNull);
8009 } 7200 }
8010 7201
8011 void test_parseFinalConstVarOrType_var() { 7202 void test_parseFinalConstVarOrType_var() {
8012 FinalConstVarOrType result = 7203 FinalConstVarOrType result = ParserTestCase.parse(
8013 ParserTestCase.parse("parseFinalConstVarOrType", <Object>[false], "var") ; 7204 "parseFinalConstVarOrType", <Object>[false], "var");
8014 Token keyword = result.keyword; 7205 Token keyword = result.keyword;
8015 expect(keyword, isNotNull); 7206 expect(keyword, isNotNull);
8016 expect(keyword.type, TokenType.KEYWORD); 7207 expect(keyword.type, TokenType.KEYWORD);
8017 expect((keyword as KeywordToken).keyword, Keyword.VAR); 7208 expect((keyword as KeywordToken).keyword, Keyword.VAR);
8018 expect(result.type, isNull); 7209 expect(result.type, isNull);
8019 } 7210 }
8020 7211
8021 void test_parseFinalConstVarOrType_void() { 7212 void test_parseFinalConstVarOrType_void() {
8022 FinalConstVarOrType result = 7213 FinalConstVarOrType result = ParserTestCase.parse(
8023 ParserTestCase.parse("parseFinalConstVarOrType", <Object>[false], "void f()"); 7214 "parseFinalConstVarOrType", <Object>[false], "void f()");
8024 expect(result.keyword, isNull); 7215 expect(result.keyword, isNull);
8025 expect(result.type, isNotNull); 7216 expect(result.type, isNotNull);
8026 } 7217 }
8027 7218
8028 void test_parseFinalConstVarOrType_void_noIdentifier() { 7219 void test_parseFinalConstVarOrType_void_noIdentifier() {
8029 FinalConstVarOrType result = 7220 FinalConstVarOrType result = ParserTestCase.parse(
8030 ParserTestCase.parse("parseFinalConstVarOrType", <Object>[false], "void, "); 7221 "parseFinalConstVarOrType", <Object>[false], "void,");
8031 expect(result.keyword, isNull); 7222 expect(result.keyword, isNull);
8032 expect(result.type, isNotNull); 7223 expect(result.type, isNotNull);
8033 } 7224 }
8034 7225
8035 void test_parseFormalParameter_final_withType_named() { 7226 void test_parseFormalParameter_final_withType_named() {
8036 ParameterKind kind = ParameterKind.NAMED; 7227 ParameterKind kind = ParameterKind.NAMED;
8037 DefaultFormalParameter parameter = ParserTestCase.parse( 7228 DefaultFormalParameter parameter = ParserTestCase.parse(
8038 "parseFormalParameter", 7229 "parseFormalParameter", <Object>[kind], "final A a : null");
8039 <Object>[kind],
8040 "final A a : null");
8041 SimpleFormalParameter simpleParameter = 7230 SimpleFormalParameter simpleParameter =
8042 parameter.parameter as SimpleFormalParameter; 7231 parameter.parameter as SimpleFormalParameter;
8043 expect(simpleParameter.identifier, isNotNull); 7232 expect(simpleParameter.identifier, isNotNull);
8044 expect(simpleParameter.keyword, isNotNull); 7233 expect(simpleParameter.keyword, isNotNull);
8045 expect(simpleParameter.type, isNotNull); 7234 expect(simpleParameter.type, isNotNull);
8046 expect(simpleParameter.kind, kind); 7235 expect(simpleParameter.kind, kind);
8047 expect(parameter.separator, isNotNull); 7236 expect(parameter.separator, isNotNull);
8048 expect(parameter.defaultValue, isNotNull); 7237 expect(parameter.defaultValue, isNotNull);
8049 expect(parameter.kind, kind); 7238 expect(parameter.kind, kind);
8050 } 7239 }
8051 7240
8052 void test_parseFormalParameter_final_withType_normal() { 7241 void test_parseFormalParameter_final_withType_normal() {
8053 ParameterKind kind = ParameterKind.REQUIRED; 7242 ParameterKind kind = ParameterKind.REQUIRED;
8054 SimpleFormalParameter parameter = 7243 SimpleFormalParameter parameter = ParserTestCase.parse(
8055 ParserTestCase.parse("parseFormalParameter", <Object>[kind], "final A a" ); 7244 "parseFormalParameter", <Object>[kind], "final A a");
8056 expect(parameter.identifier, isNotNull); 7245 expect(parameter.identifier, isNotNull);
8057 expect(parameter.keyword, isNotNull); 7246 expect(parameter.keyword, isNotNull);
8058 expect(parameter.type, isNotNull); 7247 expect(parameter.type, isNotNull);
8059 expect(parameter.kind, kind); 7248 expect(parameter.kind, kind);
8060 } 7249 }
8061 7250
8062 void test_parseFormalParameter_final_withType_positional() { 7251 void test_parseFormalParameter_final_withType_positional() {
8063 ParameterKind kind = ParameterKind.POSITIONAL; 7252 ParameterKind kind = ParameterKind.POSITIONAL;
8064 DefaultFormalParameter parameter = ParserTestCase.parse( 7253 DefaultFormalParameter parameter = ParserTestCase.parse(
8065 "parseFormalParameter", 7254 "parseFormalParameter", <Object>[kind], "final A a = null");
8066 <Object>[kind],
8067 "final A a = null");
8068 SimpleFormalParameter simpleParameter = 7255 SimpleFormalParameter simpleParameter =
8069 parameter.parameter as SimpleFormalParameter; 7256 parameter.parameter as SimpleFormalParameter;
8070 expect(simpleParameter.identifier, isNotNull); 7257 expect(simpleParameter.identifier, isNotNull);
8071 expect(simpleParameter.keyword, isNotNull); 7258 expect(simpleParameter.keyword, isNotNull);
8072 expect(simpleParameter.type, isNotNull); 7259 expect(simpleParameter.type, isNotNull);
8073 expect(simpleParameter.kind, kind); 7260 expect(simpleParameter.kind, kind);
8074 expect(parameter.separator, isNotNull); 7261 expect(parameter.separator, isNotNull);
8075 expect(parameter.defaultValue, isNotNull); 7262 expect(parameter.defaultValue, isNotNull);
8076 expect(parameter.kind, kind); 7263 expect(parameter.kind, kind);
8077 } 7264 }
8078 7265
8079 void test_parseFormalParameter_nonFinal_withType_named() { 7266 void test_parseFormalParameter_nonFinal_withType_named() {
8080 ParameterKind kind = ParameterKind.NAMED; 7267 ParameterKind kind = ParameterKind.NAMED;
8081 DefaultFormalParameter parameter = 7268 DefaultFormalParameter parameter = ParserTestCase.parse(
8082 ParserTestCase.parse("parseFormalParameter", <Object>[kind], "A a : null "); 7269 "parseFormalParameter", <Object>[kind], "A a : null");
8083 SimpleFormalParameter simpleParameter = 7270 SimpleFormalParameter simpleParameter =
8084 parameter.parameter as SimpleFormalParameter; 7271 parameter.parameter as SimpleFormalParameter;
8085 expect(simpleParameter.identifier, isNotNull); 7272 expect(simpleParameter.identifier, isNotNull);
8086 expect(simpleParameter.keyword, isNull); 7273 expect(simpleParameter.keyword, isNull);
8087 expect(simpleParameter.type, isNotNull); 7274 expect(simpleParameter.type, isNotNull);
8088 expect(simpleParameter.kind, kind); 7275 expect(simpleParameter.kind, kind);
8089 expect(parameter.separator, isNotNull); 7276 expect(parameter.separator, isNotNull);
8090 expect(parameter.defaultValue, isNotNull); 7277 expect(parameter.defaultValue, isNotNull);
8091 expect(parameter.kind, kind); 7278 expect(parameter.kind, kind);
8092 } 7279 }
8093 7280
8094 void test_parseFormalParameter_nonFinal_withType_normal() { 7281 void test_parseFormalParameter_nonFinal_withType_normal() {
8095 ParameterKind kind = ParameterKind.REQUIRED; 7282 ParameterKind kind = ParameterKind.REQUIRED;
8096 SimpleFormalParameter parameter = 7283 SimpleFormalParameter parameter =
8097 ParserTestCase.parse("parseFormalParameter", <Object>[kind], "A a"); 7284 ParserTestCase.parse("parseFormalParameter", <Object>[kind], "A a");
8098 expect(parameter.identifier, isNotNull); 7285 expect(parameter.identifier, isNotNull);
8099 expect(parameter.keyword, isNull); 7286 expect(parameter.keyword, isNull);
8100 expect(parameter.type, isNotNull); 7287 expect(parameter.type, isNotNull);
8101 expect(parameter.kind, kind); 7288 expect(parameter.kind, kind);
8102 } 7289 }
8103 7290
8104 void test_parseFormalParameter_nonFinal_withType_positional() { 7291 void test_parseFormalParameter_nonFinal_withType_positional() {
8105 ParameterKind kind = ParameterKind.POSITIONAL; 7292 ParameterKind kind = ParameterKind.POSITIONAL;
8106 DefaultFormalParameter parameter = 7293 DefaultFormalParameter parameter = ParserTestCase.parse(
8107 ParserTestCase.parse("parseFormalParameter", <Object>[kind], "A a = null "); 7294 "parseFormalParameter", <Object>[kind], "A a = null");
8108 SimpleFormalParameter simpleParameter = 7295 SimpleFormalParameter simpleParameter =
8109 parameter.parameter as SimpleFormalParameter; 7296 parameter.parameter as SimpleFormalParameter;
8110 expect(simpleParameter.identifier, isNotNull); 7297 expect(simpleParameter.identifier, isNotNull);
8111 expect(simpleParameter.keyword, isNull); 7298 expect(simpleParameter.keyword, isNull);
8112 expect(simpleParameter.type, isNotNull); 7299 expect(simpleParameter.type, isNotNull);
8113 expect(simpleParameter.kind, kind); 7300 expect(simpleParameter.kind, kind);
8114 expect(parameter.separator, isNotNull); 7301 expect(parameter.separator, isNotNull);
8115 expect(parameter.defaultValue, isNotNull); 7302 expect(parameter.defaultValue, isNotNull);
8116 expect(parameter.kind, kind); 7303 expect(parameter.kind, kind);
8117 } 7304 }
8118 7305
8119 void test_parseFormalParameter_var() { 7306 void test_parseFormalParameter_var() {
8120 ParameterKind kind = ParameterKind.REQUIRED; 7307 ParameterKind kind = ParameterKind.REQUIRED;
8121 SimpleFormalParameter parameter = 7308 SimpleFormalParameter parameter =
8122 ParserTestCase.parse("parseFormalParameter", <Object>[kind], "var a"); 7309 ParserTestCase.parse("parseFormalParameter", <Object>[kind], "var a");
8123 expect(parameter.identifier, isNotNull); 7310 expect(parameter.identifier, isNotNull);
8124 expect(parameter.keyword, isNotNull); 7311 expect(parameter.keyword, isNotNull);
8125 expect(parameter.type, isNull); 7312 expect(parameter.type, isNull);
8126 expect(parameter.kind, kind); 7313 expect(parameter.kind, kind);
8127 } 7314 }
8128 7315
8129 void test_parseFormalParameter_var_named() { 7316 void test_parseFormalParameter_var_named() {
8130 ParameterKind kind = ParameterKind.NAMED; 7317 ParameterKind kind = ParameterKind.NAMED;
8131 DefaultFormalParameter parameter = 7318 DefaultFormalParameter parameter = ParserTestCase.parse(
8132 ParserTestCase.parse("parseFormalParameter", <Object>[kind], "var a : nu ll"); 7319 "parseFormalParameter", <Object>[kind], "var a : null");
8133 SimpleFormalParameter simpleParameter = 7320 SimpleFormalParameter simpleParameter =
8134 parameter.parameter as SimpleFormalParameter; 7321 parameter.parameter as SimpleFormalParameter;
8135 expect(simpleParameter.identifier, isNotNull); 7322 expect(simpleParameter.identifier, isNotNull);
8136 expect(simpleParameter.keyword, isNotNull); 7323 expect(simpleParameter.keyword, isNotNull);
8137 expect(simpleParameter.type, isNull); 7324 expect(simpleParameter.type, isNull);
8138 expect(simpleParameter.kind, kind); 7325 expect(simpleParameter.kind, kind);
8139 expect(parameter.separator, isNotNull); 7326 expect(parameter.separator, isNotNull);
8140 expect(parameter.defaultValue, isNotNull); 7327 expect(parameter.defaultValue, isNotNull);
8141 expect(parameter.kind, kind); 7328 expect(parameter.kind, kind);
8142 } 7329 }
8143 7330
8144 void test_parseFormalParameter_var_positional() { 7331 void test_parseFormalParameter_var_positional() {
8145 ParameterKind kind = ParameterKind.POSITIONAL; 7332 ParameterKind kind = ParameterKind.POSITIONAL;
8146 DefaultFormalParameter parameter = 7333 DefaultFormalParameter parameter = ParserTestCase.parse(
8147 ParserTestCase.parse("parseFormalParameter", <Object>[kind], "var a = nu ll"); 7334 "parseFormalParameter", <Object>[kind], "var a = null");
8148 SimpleFormalParameter simpleParameter = 7335 SimpleFormalParameter simpleParameter =
8149 parameter.parameter as SimpleFormalParameter; 7336 parameter.parameter as SimpleFormalParameter;
8150 expect(simpleParameter.identifier, isNotNull); 7337 expect(simpleParameter.identifier, isNotNull);
8151 expect(simpleParameter.keyword, isNotNull); 7338 expect(simpleParameter.keyword, isNotNull);
8152 expect(simpleParameter.type, isNull); 7339 expect(simpleParameter.type, isNull);
8153 expect(simpleParameter.kind, kind); 7340 expect(simpleParameter.kind, kind);
8154 expect(parameter.separator, isNotNull); 7341 expect(parameter.separator, isNotNull);
8155 expect(parameter.defaultValue, isNotNull); 7342 expect(parameter.defaultValue, isNotNull);
8156 expect(parameter.kind, kind); 7343 expect(parameter.kind, kind);
8157 } 7344 }
8158 7345
8159 void test_parseFormalParameterList_empty() { 7346 void test_parseFormalParameterList_empty() {
8160 FormalParameterList parameterList = 7347 FormalParameterList parameterList =
8161 ParserTestCase.parse4("parseFormalParameterList", "()"); 7348 ParserTestCase.parse4("parseFormalParameterList", "()");
8162 expect(parameterList.leftParenthesis, isNotNull); 7349 expect(parameterList.leftParenthesis, isNotNull);
8163 expect(parameterList.leftDelimiter, isNull); 7350 expect(parameterList.leftDelimiter, isNull);
8164 expect(parameterList.parameters, hasLength(0)); 7351 expect(parameterList.parameters, hasLength(0));
8165 expect(parameterList.rightDelimiter, isNull); 7352 expect(parameterList.rightDelimiter, isNull);
8166 expect(parameterList.rightParenthesis, isNotNull); 7353 expect(parameterList.rightParenthesis, isNotNull);
8167 } 7354 }
8168 7355
8169 void test_parseFormalParameterList_named_multiple() { 7356 void test_parseFormalParameterList_named_multiple() {
8170 FormalParameterList parameterList = 7357 FormalParameterList parameterList = ParserTestCase.parse4(
8171 ParserTestCase.parse4("parseFormalParameterList", "({A a : 1, B b, C c : 3})"); 7358 "parseFormalParameterList", "({A a : 1, B b, C c : 3})");
8172 expect(parameterList.leftParenthesis, isNotNull); 7359 expect(parameterList.leftParenthesis, isNotNull);
8173 expect(parameterList.leftDelimiter, isNotNull); 7360 expect(parameterList.leftDelimiter, isNotNull);
8174 expect(parameterList.parameters, hasLength(3)); 7361 expect(parameterList.parameters, hasLength(3));
8175 expect(parameterList.rightDelimiter, isNotNull); 7362 expect(parameterList.rightDelimiter, isNotNull);
8176 expect(parameterList.rightParenthesis, isNotNull); 7363 expect(parameterList.rightParenthesis, isNotNull);
8177 } 7364 }
8178 7365
8179 void test_parseFormalParameterList_named_single() { 7366 void test_parseFormalParameterList_named_single() {
8180 FormalParameterList parameterList = 7367 FormalParameterList parameterList =
8181 ParserTestCase.parse4("parseFormalParameterList", "({A a})"); 7368 ParserTestCase.parse4("parseFormalParameterList", "({A a})");
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
8221 ParserTestCase.parse4("parseFormalParameterList", "(A a)"); 7408 ParserTestCase.parse4("parseFormalParameterList", "(A a)");
8222 expect(parameterList.leftParenthesis, isNotNull); 7409 expect(parameterList.leftParenthesis, isNotNull);
8223 expect(parameterList.leftDelimiter, isNull); 7410 expect(parameterList.leftDelimiter, isNull);
8224 expect(parameterList.parameters, hasLength(1)); 7411 expect(parameterList.parameters, hasLength(1));
8225 expect(parameterList.rightDelimiter, isNull); 7412 expect(parameterList.rightDelimiter, isNull);
8226 expect(parameterList.rightParenthesis, isNotNull); 7413 expect(parameterList.rightParenthesis, isNotNull);
8227 } 7414 }
8228 7415
8229 void test_parseFormalParameterList_positional_multiple() { 7416 void test_parseFormalParameterList_positional_multiple() {
8230 FormalParameterList parameterList = ParserTestCase.parse4( 7417 FormalParameterList parameterList = ParserTestCase.parse4(
8231 "parseFormalParameterList", 7418 "parseFormalParameterList", "([A a = null, B b, C c = null])");
8232 "([A a = null, B b, C c = null])");
8233 expect(parameterList.leftParenthesis, isNotNull); 7419 expect(parameterList.leftParenthesis, isNotNull);
8234 expect(parameterList.leftDelimiter, isNotNull); 7420 expect(parameterList.leftDelimiter, isNotNull);
8235 expect(parameterList.parameters, hasLength(3)); 7421 expect(parameterList.parameters, hasLength(3));
8236 expect(parameterList.rightDelimiter, isNotNull); 7422 expect(parameterList.rightDelimiter, isNotNull);
8237 expect(parameterList.rightParenthesis, isNotNull); 7423 expect(parameterList.rightParenthesis, isNotNull);
8238 } 7424 }
8239 7425
8240 void test_parseFormalParameterList_positional_single() { 7426 void test_parseFormalParameterList_positional_single() {
8241 FormalParameterList parameterList = 7427 FormalParameterList parameterList =
8242 ParserTestCase.parse4("parseFormalParameterList", "([A a = null])"); 7428 ParserTestCase.parse4("parseFormalParameterList", "([A a = null])");
8243 expect(parameterList.leftParenthesis, isNotNull); 7429 expect(parameterList.leftParenthesis, isNotNull);
8244 expect(parameterList.leftDelimiter, isNotNull); 7430 expect(parameterList.leftDelimiter, isNotNull);
8245 expect(parameterList.parameters, hasLength(1)); 7431 expect(parameterList.parameters, hasLength(1));
8246 expect(parameterList.rightDelimiter, isNotNull); 7432 expect(parameterList.rightDelimiter, isNotNull);
8247 expect(parameterList.rightParenthesis, isNotNull); 7433 expect(parameterList.rightParenthesis, isNotNull);
8248 } 7434 }
8249 7435
8250 void test_parseForStatement_each_await() { 7436 void test_parseForStatement_each_await() {
8251 ForEachStatement statement = 7437 ForEachStatement statement = ParserTestCase.parse4(
8252 ParserTestCase.parse4("parseForStatement", "await for (element in list) {}"); 7438 "parseForStatement", "await for (element in list) {}");
8253 expect(statement.awaitKeyword, isNotNull); 7439 expect(statement.awaitKeyword, isNotNull);
8254 expect(statement.forKeyword, isNotNull); 7440 expect(statement.forKeyword, isNotNull);
8255 expect(statement.leftParenthesis, isNotNull); 7441 expect(statement.leftParenthesis, isNotNull);
8256 expect(statement.loopVariable, isNull); 7442 expect(statement.loopVariable, isNull);
8257 expect(statement.identifier, isNotNull); 7443 expect(statement.identifier, isNotNull);
8258 expect(statement.inKeyword, isNotNull); 7444 expect(statement.inKeyword, isNotNull);
8259 expect(statement.iterable, isNotNull); 7445 expect(statement.iterable, isNotNull);
8260 expect(statement.rightParenthesis, isNotNull); 7446 expect(statement.rightParenthesis, isNotNull);
8261 expect(statement.body, isNotNull); 7447 expect(statement.body, isNotNull);
8262 } 7448 }
8263 7449
8264 void test_parseForStatement_each_identifier() { 7450 void test_parseForStatement_each_identifier() {
8265 ForEachStatement statement = 7451 ForEachStatement statement =
8266 ParserTestCase.parse4("parseForStatement", "for (element in list) {}"); 7452 ParserTestCase.parse4("parseForStatement", "for (element in list) {}");
8267 expect(statement.awaitKeyword, isNull); 7453 expect(statement.awaitKeyword, isNull);
8268 expect(statement.forKeyword, isNotNull); 7454 expect(statement.forKeyword, isNotNull);
8269 expect(statement.leftParenthesis, isNotNull); 7455 expect(statement.leftParenthesis, isNotNull);
8270 expect(statement.loopVariable, isNull); 7456 expect(statement.loopVariable, isNull);
8271 expect(statement.identifier, isNotNull); 7457 expect(statement.identifier, isNotNull);
8272 expect(statement.inKeyword, isNotNull); 7458 expect(statement.inKeyword, isNotNull);
8273 expect(statement.iterable, isNotNull); 7459 expect(statement.iterable, isNotNull);
8274 expect(statement.rightParenthesis, isNotNull); 7460 expect(statement.rightParenthesis, isNotNull);
8275 expect(statement.body, isNotNull); 7461 expect(statement.body, isNotNull);
8276 } 7462 }
8277 7463
8278 void test_parseForStatement_each_noType_metadata() { 7464 void test_parseForStatement_each_noType_metadata() {
8279 ForEachStatement statement = 7465 ForEachStatement statement = ParserTestCase.parse4(
8280 ParserTestCase.parse4("parseForStatement", "for (@A var element in list) {}"); 7466 "parseForStatement", "for (@A var element in list) {}");
8281 expect(statement.awaitKeyword, isNull); 7467 expect(statement.awaitKeyword, isNull);
8282 expect(statement.forKeyword, isNotNull); 7468 expect(statement.forKeyword, isNotNull);
8283 expect(statement.leftParenthesis, isNotNull); 7469 expect(statement.leftParenthesis, isNotNull);
8284 expect(statement.loopVariable, isNotNull); 7470 expect(statement.loopVariable, isNotNull);
8285 expect(statement.loopVariable.metadata, hasLength(1)); 7471 expect(statement.loopVariable.metadata, hasLength(1));
8286 expect(statement.identifier, isNull); 7472 expect(statement.identifier, isNull);
8287 expect(statement.inKeyword, isNotNull); 7473 expect(statement.inKeyword, isNotNull);
8288 expect(statement.iterable, isNotNull); 7474 expect(statement.iterable, isNotNull);
8289 expect(statement.rightParenthesis, isNotNull); 7475 expect(statement.rightParenthesis, isNotNull);
8290 expect(statement.body, isNotNull); 7476 expect(statement.body, isNotNull);
8291 } 7477 }
8292 7478
8293 void test_parseForStatement_each_type() { 7479 void test_parseForStatement_each_type() {
8294 ForEachStatement statement = 7480 ForEachStatement statement = ParserTestCase.parse4(
8295 ParserTestCase.parse4("parseForStatement", "for (A element in list) {}") ; 7481 "parseForStatement", "for (A element in list) {}");
8296 expect(statement.awaitKeyword, isNull); 7482 expect(statement.awaitKeyword, isNull);
8297 expect(statement.forKeyword, isNotNull); 7483 expect(statement.forKeyword, isNotNull);
8298 expect(statement.leftParenthesis, isNotNull); 7484 expect(statement.leftParenthesis, isNotNull);
8299 expect(statement.loopVariable, isNotNull); 7485 expect(statement.loopVariable, isNotNull);
8300 expect(statement.identifier, isNull); 7486 expect(statement.identifier, isNull);
8301 expect(statement.inKeyword, isNotNull); 7487 expect(statement.inKeyword, isNotNull);
8302 expect(statement.iterable, isNotNull); 7488 expect(statement.iterable, isNotNull);
8303 expect(statement.rightParenthesis, isNotNull); 7489 expect(statement.rightParenthesis, isNotNull);
8304 expect(statement.body, isNotNull); 7490 expect(statement.body, isNotNull);
8305 } 7491 }
8306 7492
8307 void test_parseForStatement_each_var() { 7493 void test_parseForStatement_each_var() {
8308 ForEachStatement statement = 7494 ForEachStatement statement = ParserTestCase.parse4(
8309 ParserTestCase.parse4("parseForStatement", "for (var element in list) {} "); 7495 "parseForStatement", "for (var element in list) {}");
8310 expect(statement.awaitKeyword, isNull); 7496 expect(statement.awaitKeyword, isNull);
8311 expect(statement.forKeyword, isNotNull); 7497 expect(statement.forKeyword, isNotNull);
8312 expect(statement.leftParenthesis, isNotNull); 7498 expect(statement.leftParenthesis, isNotNull);
8313 expect(statement.loopVariable, isNotNull); 7499 expect(statement.loopVariable, isNotNull);
8314 expect(statement.identifier, isNull); 7500 expect(statement.identifier, isNull);
8315 expect(statement.inKeyword, isNotNull); 7501 expect(statement.inKeyword, isNotNull);
8316 expect(statement.iterable, isNotNull); 7502 expect(statement.iterable, isNotNull);
8317 expect(statement.rightParenthesis, isNotNull); 7503 expect(statement.rightParenthesis, isNotNull);
8318 expect(statement.body, isNotNull); 7504 expect(statement.body, isNotNull);
8319 } 7505 }
(...skipping 22 matching lines...) Expand all
8342 expect(statement.initialization, isNull); 7528 expect(statement.initialization, isNull);
8343 expect(statement.leftSeparator, isNotNull); 7529 expect(statement.leftSeparator, isNotNull);
8344 expect(statement.condition, isNotNull); 7530 expect(statement.condition, isNotNull);
8345 expect(statement.rightSeparator, isNotNull); 7531 expect(statement.rightSeparator, isNotNull);
8346 expect(statement.updaters, hasLength(1)); 7532 expect(statement.updaters, hasLength(1));
8347 expect(statement.rightParenthesis, isNotNull); 7533 expect(statement.rightParenthesis, isNotNull);
8348 expect(statement.body, isNotNull); 7534 expect(statement.body, isNotNull);
8349 } 7535 }
8350 7536
8351 void test_parseForStatement_loop_ecu() { 7537 void test_parseForStatement_loop_ecu() {
8352 ForStatement statement = 7538 ForStatement statement = ParserTestCase.parse4(
8353 ParserTestCase.parse4("parseForStatement", "for (i--; i < count; i++) {} "); 7539 "parseForStatement", "for (i--; i < count; i++) {}");
8354 expect(statement.forKeyword, isNotNull); 7540 expect(statement.forKeyword, isNotNull);
8355 expect(statement.leftParenthesis, isNotNull); 7541 expect(statement.leftParenthesis, isNotNull);
8356 expect(statement.variables, isNull); 7542 expect(statement.variables, isNull);
8357 expect(statement.initialization, isNotNull); 7543 expect(statement.initialization, isNotNull);
8358 expect(statement.leftSeparator, isNotNull); 7544 expect(statement.leftSeparator, isNotNull);
8359 expect(statement.condition, isNotNull); 7545 expect(statement.condition, isNotNull);
8360 expect(statement.rightSeparator, isNotNull); 7546 expect(statement.rightSeparator, isNotNull);
8361 expect(statement.updaters, hasLength(1)); 7547 expect(statement.updaters, hasLength(1));
8362 expect(statement.rightParenthesis, isNotNull); 7548 expect(statement.rightParenthesis, isNotNull);
8363 expect(statement.body, isNotNull); 7549 expect(statement.body, isNotNull);
(...skipping 29 matching lines...) Expand all
8393 expect(statement.initialization, isNull); 7579 expect(statement.initialization, isNull);
8394 expect(statement.leftSeparator, isNotNull); 7580 expect(statement.leftSeparator, isNotNull);
8395 expect(statement.condition, isNull); 7581 expect(statement.condition, isNull);
8396 expect(statement.rightSeparator, isNotNull); 7582 expect(statement.rightSeparator, isNotNull);
8397 expect(statement.updaters, hasLength(0)); 7583 expect(statement.updaters, hasLength(0));
8398 expect(statement.rightParenthesis, isNotNull); 7584 expect(statement.rightParenthesis, isNotNull);
8399 expect(statement.body, isNotNull); 7585 expect(statement.body, isNotNull);
8400 } 7586 }
8401 7587
8402 void test_parseForStatement_loop_ic() { 7588 void test_parseForStatement_loop_ic() {
8403 ForStatement statement = 7589 ForStatement statement = ParserTestCase.parse4(
8404 ParserTestCase.parse4("parseForStatement", "for (var i = 0; i < count;) {}"); 7590 "parseForStatement", "for (var i = 0; i < count;) {}");
8405 expect(statement.forKeyword, isNotNull); 7591 expect(statement.forKeyword, isNotNull);
8406 expect(statement.leftParenthesis, isNotNull); 7592 expect(statement.leftParenthesis, isNotNull);
8407 VariableDeclarationList variables = statement.variables; 7593 VariableDeclarationList variables = statement.variables;
8408 expect(variables, isNotNull); 7594 expect(variables, isNotNull);
8409 expect(variables.variables, hasLength(1)); 7595 expect(variables.variables, hasLength(1));
8410 expect(statement.initialization, isNull); 7596 expect(statement.initialization, isNull);
8411 expect(statement.leftSeparator, isNotNull); 7597 expect(statement.leftSeparator, isNotNull);
8412 expect(statement.condition, isNotNull); 7598 expect(statement.condition, isNotNull);
8413 expect(statement.rightSeparator, isNotNull); 7599 expect(statement.rightSeparator, isNotNull);
8414 expect(statement.updaters, hasLength(0)); 7600 expect(statement.updaters, hasLength(0));
8415 expect(statement.rightParenthesis, isNotNull); 7601 expect(statement.rightParenthesis, isNotNull);
8416 expect(statement.body, isNotNull); 7602 expect(statement.body, isNotNull);
8417 } 7603 }
8418 7604
8419 void test_parseForStatement_loop_icu() { 7605 void test_parseForStatement_loop_icu() {
8420 ForStatement statement = ParserTestCase.parse4( 7606 ForStatement statement = ParserTestCase.parse4(
8421 "parseForStatement", 7607 "parseForStatement", "for (var i = 0; i < count; i++) {}");
8422 "for (var i = 0; i < count; i++) {}");
8423 expect(statement.forKeyword, isNotNull); 7608 expect(statement.forKeyword, isNotNull);
8424 expect(statement.leftParenthesis, isNotNull); 7609 expect(statement.leftParenthesis, isNotNull);
8425 VariableDeclarationList variables = statement.variables; 7610 VariableDeclarationList variables = statement.variables;
8426 expect(variables, isNotNull); 7611 expect(variables, isNotNull);
8427 expect(variables.variables, hasLength(1)); 7612 expect(variables.variables, hasLength(1));
8428 expect(statement.initialization, isNull); 7613 expect(statement.initialization, isNull);
8429 expect(statement.leftSeparator, isNotNull); 7614 expect(statement.leftSeparator, isNotNull);
8430 expect(statement.condition, isNotNull); 7615 expect(statement.condition, isNotNull);
8431 expect(statement.rightSeparator, isNotNull); 7616 expect(statement.rightSeparator, isNotNull);
8432 expect(statement.updaters, hasLength(1)); 7617 expect(statement.updaters, hasLength(1));
8433 expect(statement.rightParenthesis, isNotNull); 7618 expect(statement.rightParenthesis, isNotNull);
8434 expect(statement.body, isNotNull); 7619 expect(statement.body, isNotNull);
8435 } 7620 }
8436 7621
8437 void test_parseForStatement_loop_iicuu() { 7622 void test_parseForStatement_loop_iicuu() {
8438 ForStatement statement = ParserTestCase.parse4( 7623 ForStatement statement = ParserTestCase.parse4(
8439 "parseForStatement", 7624 "parseForStatement", "for (int i = 0, j = count; i < j; i++, j--) {}");
8440 "for (int i = 0, j = count; i < j; i++, j--) {}");
8441 expect(statement.forKeyword, isNotNull); 7625 expect(statement.forKeyword, isNotNull);
8442 expect(statement.leftParenthesis, isNotNull); 7626 expect(statement.leftParenthesis, isNotNull);
8443 VariableDeclarationList variables = statement.variables; 7627 VariableDeclarationList variables = statement.variables;
8444 expect(variables, isNotNull); 7628 expect(variables, isNotNull);
8445 expect(variables.variables, hasLength(2)); 7629 expect(variables.variables, hasLength(2));
8446 expect(statement.initialization, isNull); 7630 expect(statement.initialization, isNull);
8447 expect(statement.leftSeparator, isNotNull); 7631 expect(statement.leftSeparator, isNotNull);
8448 expect(statement.condition, isNotNull); 7632 expect(statement.condition, isNotNull);
8449 expect(statement.rightSeparator, isNotNull); 7633 expect(statement.rightSeparator, isNotNull);
8450 expect(statement.updaters, hasLength(2)); 7634 expect(statement.updaters, hasLength(2));
(...skipping 27 matching lines...) Expand all
8478 expect(statement.initialization, isNull); 7662 expect(statement.initialization, isNull);
8479 expect(statement.leftSeparator, isNotNull); 7663 expect(statement.leftSeparator, isNotNull);
8480 expect(statement.condition, isNull); 7664 expect(statement.condition, isNull);
8481 expect(statement.rightSeparator, isNotNull); 7665 expect(statement.rightSeparator, isNotNull);
8482 expect(statement.updaters, hasLength(1)); 7666 expect(statement.updaters, hasLength(1));
8483 expect(statement.rightParenthesis, isNotNull); 7667 expect(statement.rightParenthesis, isNotNull);
8484 expect(statement.body, isNotNull); 7668 expect(statement.body, isNotNull);
8485 } 7669 }
8486 7670
8487 void test_parseFunctionBody_block() { 7671 void test_parseFunctionBody_block() {
8488 BlockFunctionBody functionBody = 7672 BlockFunctionBody functionBody = ParserTestCase.parse(
8489 ParserTestCase.parse("parseFunctionBody", <Object>[false, null, false], "{}"); 7673 "parseFunctionBody", <Object>[false, null, false], "{}");
8490 expect(functionBody.keyword, isNull); 7674 expect(functionBody.keyword, isNull);
8491 expect(functionBody.star, isNull); 7675 expect(functionBody.star, isNull);
8492 expect(functionBody.block, isNotNull); 7676 expect(functionBody.block, isNotNull);
8493 expect(functionBody.isAsynchronous, isFalse); 7677 expect(functionBody.isAsynchronous, isFalse);
8494 expect(functionBody.isGenerator, isFalse); 7678 expect(functionBody.isGenerator, isFalse);
8495 expect(functionBody.isSynchronous, isTrue); 7679 expect(functionBody.isSynchronous, isTrue);
8496 } 7680 }
8497 7681
8498 void test_parseFunctionBody_block_async() { 7682 void test_parseFunctionBody_block_async() {
8499 BlockFunctionBody functionBody = ParserTestCase.parse( 7683 BlockFunctionBody functionBody = ParserTestCase.parse(
8500 "parseFunctionBody", 7684 "parseFunctionBody", <Object>[false, null, false], "async {}");
8501 <Object>[false, null, false],
8502 "async {}");
8503 expect(functionBody.keyword, isNotNull); 7685 expect(functionBody.keyword, isNotNull);
8504 expect(functionBody.keyword.lexeme, Parser.ASYNC); 7686 expect(functionBody.keyword.lexeme, Parser.ASYNC);
8505 expect(functionBody.star, isNull); 7687 expect(functionBody.star, isNull);
8506 expect(functionBody.block, isNotNull); 7688 expect(functionBody.block, isNotNull);
8507 expect(functionBody.isAsynchronous, isTrue); 7689 expect(functionBody.isAsynchronous, isTrue);
8508 expect(functionBody.isGenerator, isFalse); 7690 expect(functionBody.isGenerator, isFalse);
8509 expect(functionBody.isSynchronous, isFalse); 7691 expect(functionBody.isSynchronous, isFalse);
8510 } 7692 }
8511 7693
8512 void test_parseFunctionBody_block_asyncGenerator() { 7694 void test_parseFunctionBody_block_asyncGenerator() {
8513 BlockFunctionBody functionBody = ParserTestCase.parse( 7695 BlockFunctionBody functionBody = ParserTestCase.parse(
8514 "parseFunctionBody", 7696 "parseFunctionBody", <Object>[false, null, false], "async* {}");
8515 <Object>[false, null, false],
8516 "async* {}");
8517 expect(functionBody.keyword, isNotNull); 7697 expect(functionBody.keyword, isNotNull);
8518 expect(functionBody.keyword.lexeme, Parser.ASYNC); 7698 expect(functionBody.keyword.lexeme, Parser.ASYNC);
8519 expect(functionBody.star, isNotNull); 7699 expect(functionBody.star, isNotNull);
8520 expect(functionBody.block, isNotNull); 7700 expect(functionBody.block, isNotNull);
8521 expect(functionBody.isAsynchronous, isTrue); 7701 expect(functionBody.isAsynchronous, isTrue);
8522 expect(functionBody.isGenerator, isTrue); 7702 expect(functionBody.isGenerator, isTrue);
8523 expect(functionBody.isSynchronous, isFalse); 7703 expect(functionBody.isSynchronous, isFalse);
8524 } 7704 }
8525 7705
8526 void test_parseFunctionBody_block_syncGenerator() { 7706 void test_parseFunctionBody_block_syncGenerator() {
8527 BlockFunctionBody functionBody = ParserTestCase.parse( 7707 BlockFunctionBody functionBody = ParserTestCase.parse(
8528 "parseFunctionBody", 7708 "parseFunctionBody", <Object>[false, null, false], "sync* {}");
8529 <Object>[false, null, false],
8530 "sync* {}");
8531 expect(functionBody.keyword, isNotNull); 7709 expect(functionBody.keyword, isNotNull);
8532 expect(functionBody.keyword.lexeme, Parser.SYNC); 7710 expect(functionBody.keyword.lexeme, Parser.SYNC);
8533 expect(functionBody.star, isNotNull); 7711 expect(functionBody.star, isNotNull);
8534 expect(functionBody.block, isNotNull); 7712 expect(functionBody.block, isNotNull);
8535 expect(functionBody.isAsynchronous, isFalse); 7713 expect(functionBody.isAsynchronous, isFalse);
8536 expect(functionBody.isGenerator, isTrue); 7714 expect(functionBody.isGenerator, isTrue);
8537 expect(functionBody.isSynchronous, isTrue); 7715 expect(functionBody.isSynchronous, isTrue);
8538 } 7716 }
8539 7717
8540 void test_parseFunctionBody_empty() { 7718 void test_parseFunctionBody_empty() {
8541 EmptyFunctionBody functionBody = 7719 EmptyFunctionBody functionBody = ParserTestCase.parse(
8542 ParserTestCase.parse("parseFunctionBody", <Object>[true, null, false], " ;"); 7720 "parseFunctionBody", <Object>[true, null, false], ";");
8543 expect(functionBody.semicolon, isNotNull); 7721 expect(functionBody.semicolon, isNotNull);
8544 } 7722 }
8545 7723
8546 void test_parseFunctionBody_expression() { 7724 void test_parseFunctionBody_expression() {
8547 ExpressionFunctionBody functionBody = ParserTestCase.parse( 7725 ExpressionFunctionBody functionBody = ParserTestCase.parse(
8548 "parseFunctionBody", 7726 "parseFunctionBody", <Object>[false, null, false], "=> y;");
8549 <Object>[false, null, false],
8550 "=> y;");
8551 expect(functionBody.keyword, isNull); 7727 expect(functionBody.keyword, isNull);
8552 expect(functionBody.functionDefinition, isNotNull); 7728 expect(functionBody.functionDefinition, isNotNull);
8553 expect(functionBody.expression, isNotNull); 7729 expect(functionBody.expression, isNotNull);
8554 expect(functionBody.semicolon, isNotNull); 7730 expect(functionBody.semicolon, isNotNull);
8555 expect(functionBody.isAsynchronous, isFalse); 7731 expect(functionBody.isAsynchronous, isFalse);
8556 expect(functionBody.isGenerator, isFalse); 7732 expect(functionBody.isGenerator, isFalse);
8557 expect(functionBody.isSynchronous, isTrue); 7733 expect(functionBody.isSynchronous, isTrue);
8558 } 7734 }
8559 7735
8560 void test_parseFunctionBody_expression_async() { 7736 void test_parseFunctionBody_expression_async() {
8561 ExpressionFunctionBody functionBody = ParserTestCase.parse( 7737 ExpressionFunctionBody functionBody = ParserTestCase.parse(
8562 "parseFunctionBody", 7738 "parseFunctionBody", <Object>[false, null, false], "async => y;");
8563 <Object>[false, null, false],
8564 "async => y;");
8565 expect(functionBody.keyword, isNotNull); 7739 expect(functionBody.keyword, isNotNull);
8566 expect(functionBody.keyword.lexeme, Parser.ASYNC); 7740 expect(functionBody.keyword.lexeme, Parser.ASYNC);
8567 expect(functionBody.functionDefinition, isNotNull); 7741 expect(functionBody.functionDefinition, isNotNull);
8568 expect(functionBody.expression, isNotNull); 7742 expect(functionBody.expression, isNotNull);
8569 expect(functionBody.semicolon, isNotNull); 7743 expect(functionBody.semicolon, isNotNull);
8570 expect(functionBody.isAsynchronous, isTrue); 7744 expect(functionBody.isAsynchronous, isTrue);
8571 expect(functionBody.isGenerator, isFalse); 7745 expect(functionBody.isGenerator, isFalse);
8572 expect(functionBody.isSynchronous, isFalse); 7746 expect(functionBody.isSynchronous, isFalse);
8573 } 7747 }
8574 7748
8575 void test_parseFunctionBody_nativeFunctionBody() { 7749 void test_parseFunctionBody_nativeFunctionBody() {
8576 NativeFunctionBody functionBody = ParserTestCase.parse( 7750 NativeFunctionBody functionBody = ParserTestCase.parse(
8577 "parseFunctionBody", 7751 "parseFunctionBody", <Object>[false, null, false], "native 'str';");
8578 <Object>[false, null, false],
8579 "native 'str';");
8580 expect(functionBody.nativeKeyword, isNotNull); 7752 expect(functionBody.nativeKeyword, isNotNull);
8581 expect(functionBody.stringLiteral, isNotNull); 7753 expect(functionBody.stringLiteral, isNotNull);
8582 expect(functionBody.semicolon, isNotNull); 7754 expect(functionBody.semicolon, isNotNull);
8583 } 7755 }
8584 7756
8585 void test_parseFunctionBody_skip_block() { 7757 void test_parseFunctionBody_skip_block() {
8586 ParserTestCase.parseFunctionBodies = false; 7758 ParserTestCase.parseFunctionBodies = false;
8587 FunctionBody functionBody = 7759 FunctionBody functionBody = ParserTestCase.parse(
8588 ParserTestCase.parse("parseFunctionBody", <Object>[false, null, false], "{}"); 7760 "parseFunctionBody", <Object>[false, null, false], "{}");
8589 EngineTestCase.assertInstanceOf( 7761 EngineTestCase.assertInstanceOf(
8590 (obj) => obj is EmptyFunctionBody, 7762 (obj) => obj is EmptyFunctionBody, EmptyFunctionBody, functionBody);
8591 EmptyFunctionBody,
8592 functionBody);
8593 } 7763 }
8594 7764
8595 void test_parseFunctionBody_skip_block_invalid() { 7765 void test_parseFunctionBody_skip_block_invalid() {
8596 ParserTestCase.parseFunctionBodies = false; 7766 ParserTestCase.parseFunctionBodies = false;
8597 FunctionBody functionBody = ParserTestCase.parse3( 7767 FunctionBody functionBody = ParserTestCase.parse3("parseFunctionBody",
8598 "parseFunctionBody", 7768 <Object>[false, null, false], "{", [ParserErrorCode.EXPECTED_TOKEN]);
8599 <Object>[false, null, false],
8600 "{",
8601 [ParserErrorCode.EXPECTED_TOKEN]);
8602 EngineTestCase.assertInstanceOf( 7769 EngineTestCase.assertInstanceOf(
8603 (obj) => obj is EmptyFunctionBody, 7770 (obj) => obj is EmptyFunctionBody, EmptyFunctionBody, functionBody);
8604 EmptyFunctionBody,
8605 functionBody);
8606 } 7771 }
8607 7772
8608 void test_parseFunctionBody_skip_blocks() { 7773 void test_parseFunctionBody_skip_blocks() {
8609 ParserTestCase.parseFunctionBodies = false; 7774 ParserTestCase.parseFunctionBodies = false;
8610 FunctionBody functionBody = ParserTestCase.parse( 7775 FunctionBody functionBody = ParserTestCase.parse(
8611 "parseFunctionBody", 7776 "parseFunctionBody", <Object>[false, null, false], "{ {} }");
8612 <Object>[false, null, false],
8613 "{ {} }");
8614 EngineTestCase.assertInstanceOf( 7777 EngineTestCase.assertInstanceOf(
8615 (obj) => obj is EmptyFunctionBody, 7778 (obj) => obj is EmptyFunctionBody, EmptyFunctionBody, functionBody);
8616 EmptyFunctionBody,
8617 functionBody);
8618 } 7779 }
8619 7780
8620 void test_parseFunctionBody_skip_expression() { 7781 void test_parseFunctionBody_skip_expression() {
8621 ParserTestCase.parseFunctionBodies = false; 7782 ParserTestCase.parseFunctionBodies = false;
8622 FunctionBody functionBody = ParserTestCase.parse( 7783 FunctionBody functionBody = ParserTestCase.parse(
8623 "parseFunctionBody", 7784 "parseFunctionBody", <Object>[false, null, false], "=> y;");
8624 <Object>[false, null, false],
8625 "=> y;");
8626 EngineTestCase.assertInstanceOf( 7785 EngineTestCase.assertInstanceOf(
8627 (obj) => obj is EmptyFunctionBody, 7786 (obj) => obj is EmptyFunctionBody, EmptyFunctionBody, functionBody);
8628 EmptyFunctionBody,
8629 functionBody);
8630 } 7787 }
8631 7788
8632 void test_parseFunctionDeclaration_function() { 7789 void test_parseFunctionDeclaration_function() {
8633 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); 7790 Comment comment = Comment.createDocumentationComment(new List<Token>(0));
8634 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); 7791 TypeName returnType = new TypeName(new SimpleIdentifier(null), null);
8635 FunctionDeclaration declaration = ParserTestCase.parse( 7792 FunctionDeclaration declaration = ParserTestCase.parse(
8636 "parseFunctionDeclaration", 7793 "parseFunctionDeclaration", <Object>[
8637 <Object>[commentAndMetadata(comment), null, returnType], 7794 commentAndMetadata(comment),
8638 "f() {}"); 7795 null,
7796 returnType
7797 ], "f() {}");
8639 expect(declaration.documentationComment, comment); 7798 expect(declaration.documentationComment, comment);
8640 expect(declaration.returnType, returnType); 7799 expect(declaration.returnType, returnType);
8641 expect(declaration.name, isNotNull); 7800 expect(declaration.name, isNotNull);
8642 FunctionExpression expression = declaration.functionExpression; 7801 FunctionExpression expression = declaration.functionExpression;
8643 expect(expression, isNotNull); 7802 expect(expression, isNotNull);
8644 expect(expression.body, isNotNull); 7803 expect(expression.body, isNotNull);
8645 expect(expression.parameters, isNotNull); 7804 expect(expression.parameters, isNotNull);
8646 expect(declaration.propertyKeyword, isNull); 7805 expect(declaration.propertyKeyword, isNull);
8647 } 7806 }
8648 7807
8649 void test_parseFunctionDeclaration_getter() { 7808 void test_parseFunctionDeclaration_getter() {
8650 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); 7809 Comment comment = Comment.createDocumentationComment(new List<Token>(0));
8651 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); 7810 TypeName returnType = new TypeName(new SimpleIdentifier(null), null);
8652 FunctionDeclaration declaration = ParserTestCase.parse( 7811 FunctionDeclaration declaration = ParserTestCase.parse(
8653 "parseFunctionDeclaration", 7812 "parseFunctionDeclaration", <Object>[
8654 <Object>[commentAndMetadata(comment), null, returnType], 7813 commentAndMetadata(comment),
8655 "get p => 0;"); 7814 null,
7815 returnType
7816 ], "get p => 0;");
8656 expect(declaration.documentationComment, comment); 7817 expect(declaration.documentationComment, comment);
8657 expect(declaration.returnType, returnType); 7818 expect(declaration.returnType, returnType);
8658 expect(declaration.name, isNotNull); 7819 expect(declaration.name, isNotNull);
8659 FunctionExpression expression = declaration.functionExpression; 7820 FunctionExpression expression = declaration.functionExpression;
8660 expect(expression, isNotNull); 7821 expect(expression, isNotNull);
8661 expect(expression.body, isNotNull); 7822 expect(expression.body, isNotNull);
8662 expect(expression.parameters, isNull); 7823 expect(expression.parameters, isNull);
8663 expect(declaration.propertyKeyword, isNotNull); 7824 expect(declaration.propertyKeyword, isNotNull);
8664 } 7825 }
8665 7826
8666 void test_parseFunctionDeclaration_setter() { 7827 void test_parseFunctionDeclaration_setter() {
8667 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); 7828 Comment comment = Comment.createDocumentationComment(new List<Token>(0));
8668 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); 7829 TypeName returnType = new TypeName(new SimpleIdentifier(null), null);
8669 FunctionDeclaration declaration = ParserTestCase.parse( 7830 FunctionDeclaration declaration = ParserTestCase.parse(
8670 "parseFunctionDeclaration", 7831 "parseFunctionDeclaration", <Object>[
8671 <Object>[commentAndMetadata(comment), null, returnType], 7832 commentAndMetadata(comment),
8672 "set p(v) {}"); 7833 null,
7834 returnType
7835 ], "set p(v) {}");
8673 expect(declaration.documentationComment, comment); 7836 expect(declaration.documentationComment, comment);
8674 expect(declaration.returnType, returnType); 7837 expect(declaration.returnType, returnType);
8675 expect(declaration.name, isNotNull); 7838 expect(declaration.name, isNotNull);
8676 FunctionExpression expression = declaration.functionExpression; 7839 FunctionExpression expression = declaration.functionExpression;
8677 expect(expression, isNotNull); 7840 expect(expression, isNotNull);
8678 expect(expression.body, isNotNull); 7841 expect(expression.body, isNotNull);
8679 expect(expression.parameters, isNotNull); 7842 expect(expression.parameters, isNotNull);
8680 expect(declaration.propertyKeyword, isNotNull); 7843 expect(declaration.propertyKeyword, isNotNull);
8681 } 7844 }
8682 7845
8683 void test_parseFunctionDeclarationStatement() { 7846 void test_parseFunctionDeclarationStatement() {
8684 FunctionDeclarationStatement statement = ParserTestCase.parse4( 7847 FunctionDeclarationStatement statement = ParserTestCase.parse4(
8685 "parseFunctionDeclarationStatement", 7848 "parseFunctionDeclarationStatement", "void f(int p) => p * 2;");
8686 "void f(int p) => p * 2;");
8687 expect(statement.functionDeclaration, isNotNull); 7849 expect(statement.functionDeclaration, isNotNull);
8688 } 7850 }
8689 7851
8690 void test_parseFunctionExpression_body_inExpression() { 7852 void test_parseFunctionExpression_body_inExpression() {
8691 FunctionExpression expression = 7853 FunctionExpression expression =
8692 ParserTestCase.parse4("parseFunctionExpression", "(int i) => i++"); 7854 ParserTestCase.parse4("parseFunctionExpression", "(int i) => i++");
8693 expect(expression.body, isNotNull); 7855 expect(expression.body, isNotNull);
8694 expect(expression.parameters, isNotNull); 7856 expect(expression.parameters, isNotNull);
8695 expect((expression.body as ExpressionFunctionBody).semicolon, isNull); 7857 expect((expression.body as ExpressionFunctionBody).semicolon, isNull);
8696 } 7858 }
8697 7859
8698 void test_parseGetter_nonStatic() { 7860 void test_parseGetter_nonStatic() {
8699 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); 7861 Comment comment = Comment.createDocumentationComment(new List<Token>(0));
8700 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); 7862 TypeName returnType = new TypeName(new SimpleIdentifier(null), null);
8701 MethodDeclaration method = ParserTestCase.parse( 7863 MethodDeclaration method = ParserTestCase.parse("parseGetter", <Object>[
8702 "parseGetter", 7864 commentAndMetadata(comment),
8703 <Object>[commentAndMetadata(comment), null, null, returnType], 7865 null,
8704 "get a;"); 7866 null,
7867 returnType
7868 ], "get a;");
8705 expect(method.body, isNotNull); 7869 expect(method.body, isNotNull);
8706 expect(method.documentationComment, comment); 7870 expect(method.documentationComment, comment);
8707 expect(method.externalKeyword, isNull); 7871 expect(method.externalKeyword, isNull);
8708 expect(method.modifierKeyword, isNull); 7872 expect(method.modifierKeyword, isNull);
8709 expect(method.name, isNotNull); 7873 expect(method.name, isNotNull);
8710 expect(method.operatorKeyword, isNull); 7874 expect(method.operatorKeyword, isNull);
8711 expect(method.parameters, isNull); 7875 expect(method.parameters, isNull);
8712 expect(method.propertyKeyword, isNotNull); 7876 expect(method.propertyKeyword, isNotNull);
8713 expect(method.returnType, returnType); 7877 expect(method.returnType, returnType);
8714 } 7878 }
8715 7879
8716 void test_parseGetter_static() { 7880 void test_parseGetter_static() {
8717 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); 7881 Comment comment = Comment.createDocumentationComment(new List<Token>(0));
8718 Token staticKeyword = TokenFactory.tokenFromKeyword(Keyword.STATIC); 7882 Token staticKeyword = TokenFactory.tokenFromKeyword(Keyword.STATIC);
8719 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); 7883 TypeName returnType = new TypeName(new SimpleIdentifier(null), null);
8720 MethodDeclaration method = ParserTestCase.parse( 7884 MethodDeclaration method = ParserTestCase.parse("parseGetter", <Object>[
8721 "parseGetter", 7885 commentAndMetadata(comment),
8722 <Object>[commentAndMetadata(comment), null, staticKeyword, returnType], 7886 null,
8723 "get a => 42;"); 7887 staticKeyword,
7888 returnType
7889 ], "get a => 42;");
8724 expect(method.body, isNotNull); 7890 expect(method.body, isNotNull);
8725 expect(method.documentationComment, comment); 7891 expect(method.documentationComment, comment);
8726 expect(method.externalKeyword, isNull); 7892 expect(method.externalKeyword, isNull);
8727 expect(method.modifierKeyword, staticKeyword); 7893 expect(method.modifierKeyword, staticKeyword);
8728 expect(method.name, isNotNull); 7894 expect(method.name, isNotNull);
8729 expect(method.operatorKeyword, isNull); 7895 expect(method.operatorKeyword, isNull);
8730 expect(method.parameters, isNull); 7896 expect(method.parameters, isNull);
8731 expect(method.propertyKeyword, isNotNull); 7897 expect(method.propertyKeyword, isNotNull);
8732 expect(method.returnType, returnType); 7898 expect(method.returnType, returnType);
8733 } 7899 }
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
8800 } 7966 }
8801 7967
8802 void test_parseImplementsClause_single() { 7968 void test_parseImplementsClause_single() {
8803 ImplementsClause clause = 7969 ImplementsClause clause =
8804 ParserTestCase.parse4("parseImplementsClause", "implements A"); 7970 ParserTestCase.parse4("parseImplementsClause", "implements A");
8805 expect(clause.interfaces, hasLength(1)); 7971 expect(clause.interfaces, hasLength(1));
8806 expect(clause.implementsKeyword, isNotNull); 7972 expect(clause.implementsKeyword, isNotNull);
8807 } 7973 }
8808 7974
8809 void test_parseImportDirective_deferred() { 7975 void test_parseImportDirective_deferred() {
8810 ImportDirective directive = ParserTestCase.parse( 7976 ImportDirective directive = ParserTestCase.parse("parseImportDirective",
8811 "parseImportDirective", 7977 <Object>[
8812 <Object>[emptyCommentAndMetadata()], 7978 emptyCommentAndMetadata()
8813 "import 'lib/lib.dart' deferred as a;"); 7979 ], "import 'lib/lib.dart' deferred as a;");
8814 expect(directive.keyword, isNotNull); 7980 expect(directive.keyword, isNotNull);
8815 expect(directive.uri, isNotNull); 7981 expect(directive.uri, isNotNull);
8816 expect(directive.deferredKeyword, isNotNull); 7982 expect(directive.deferredKeyword, isNotNull);
8817 expect(directive.asKeyword, isNotNull); 7983 expect(directive.asKeyword, isNotNull);
8818 expect(directive.prefix, isNotNull); 7984 expect(directive.prefix, isNotNull);
8819 expect(directive.combinators, hasLength(0)); 7985 expect(directive.combinators, hasLength(0));
8820 expect(directive.semicolon, isNotNull); 7986 expect(directive.semicolon, isNotNull);
8821 } 7987 }
8822 7988
8823 void test_parseImportDirective_hide() { 7989 void test_parseImportDirective_hide() {
8824 ImportDirective directive = ParserTestCase.parse( 7990 ImportDirective directive = ParserTestCase.parse("parseImportDirective",
8825 "parseImportDirective", 7991 <Object>[
8826 <Object>[emptyCommentAndMetadata()], 7992 emptyCommentAndMetadata()
8827 "import 'lib/lib.dart' hide A, B;"); 7993 ], "import 'lib/lib.dart' hide A, B;");
8828 expect(directive.keyword, isNotNull); 7994 expect(directive.keyword, isNotNull);
8829 expect(directive.uri, isNotNull); 7995 expect(directive.uri, isNotNull);
8830 expect(directive.deferredKeyword, isNull); 7996 expect(directive.deferredKeyword, isNull);
8831 expect(directive.asKeyword, isNull); 7997 expect(directive.asKeyword, isNull);
8832 expect(directive.prefix, isNull); 7998 expect(directive.prefix, isNull);
8833 expect(directive.combinators, hasLength(1)); 7999 expect(directive.combinators, hasLength(1));
8834 expect(directive.semicolon, isNotNull); 8000 expect(directive.semicolon, isNotNull);
8835 } 8001 }
8836 8002
8837 void test_parseImportDirective_noCombinator() { 8003 void test_parseImportDirective_noCombinator() {
8838 ImportDirective directive = ParserTestCase.parse( 8004 ImportDirective directive = ParserTestCase.parse("parseImportDirective",
8839 "parseImportDirective", 8005 <Object>[emptyCommentAndMetadata()], "import 'lib/lib.dart';");
8840 <Object>[emptyCommentAndMetadata()],
8841 "import 'lib/lib.dart';");
8842 expect(directive.keyword, isNotNull); 8006 expect(directive.keyword, isNotNull);
8843 expect(directive.uri, isNotNull); 8007 expect(directive.uri, isNotNull);
8844 expect(directive.deferredKeyword, isNull); 8008 expect(directive.deferredKeyword, isNull);
8845 expect(directive.asKeyword, isNull); 8009 expect(directive.asKeyword, isNull);
8846 expect(directive.prefix, isNull); 8010 expect(directive.prefix, isNull);
8847 expect(directive.combinators, hasLength(0)); 8011 expect(directive.combinators, hasLength(0));
8848 expect(directive.semicolon, isNotNull); 8012 expect(directive.semicolon, isNotNull);
8849 } 8013 }
8850 8014
8851 void test_parseImportDirective_prefix() { 8015 void test_parseImportDirective_prefix() {
8852 ImportDirective directive = ParserTestCase.parse( 8016 ImportDirective directive = ParserTestCase.parse("parseImportDirective",
8853 "parseImportDirective", 8017 <Object>[emptyCommentAndMetadata()], "import 'lib/lib.dart' as a;");
8854 <Object>[emptyCommentAndMetadata()],
8855 "import 'lib/lib.dart' as a;");
8856 expect(directive.keyword, isNotNull); 8018 expect(directive.keyword, isNotNull);
8857 expect(directive.uri, isNotNull); 8019 expect(directive.uri, isNotNull);
8858 expect(directive.deferredKeyword, isNull); 8020 expect(directive.deferredKeyword, isNull);
8859 expect(directive.asKeyword, isNotNull); 8021 expect(directive.asKeyword, isNotNull);
8860 expect(directive.prefix, isNotNull); 8022 expect(directive.prefix, isNotNull);
8861 expect(directive.combinators, hasLength(0)); 8023 expect(directive.combinators, hasLength(0));
8862 expect(directive.semicolon, isNotNull); 8024 expect(directive.semicolon, isNotNull);
8863 } 8025 }
8864 8026
8865 void test_parseImportDirective_prefix_hide_show() { 8027 void test_parseImportDirective_prefix_hide_show() {
8866 ImportDirective directive = ParserTestCase.parse( 8028 ImportDirective directive = ParserTestCase.parse("parseImportDirective",
8867 "parseImportDirective", 8029 <Object>[
8868 <Object>[emptyCommentAndMetadata()], 8030 emptyCommentAndMetadata()
8869 "import 'lib/lib.dart' as a hide A show B;"); 8031 ], "import 'lib/lib.dart' as a hide A show B;");
8870 expect(directive.keyword, isNotNull); 8032 expect(directive.keyword, isNotNull);
8871 expect(directive.uri, isNotNull); 8033 expect(directive.uri, isNotNull);
8872 expect(directive.deferredKeyword, isNull); 8034 expect(directive.deferredKeyword, isNull);
8873 expect(directive.asKeyword, isNotNull); 8035 expect(directive.asKeyword, isNotNull);
8874 expect(directive.prefix, isNotNull); 8036 expect(directive.prefix, isNotNull);
8875 expect(directive.combinators, hasLength(2)); 8037 expect(directive.combinators, hasLength(2));
8876 expect(directive.semicolon, isNotNull); 8038 expect(directive.semicolon, isNotNull);
8877 } 8039 }
8878 8040
8879 void test_parseImportDirective_prefix_show_hide() { 8041 void test_parseImportDirective_prefix_show_hide() {
8880 ImportDirective directive = ParserTestCase.parse( 8042 ImportDirective directive = ParserTestCase.parse("parseImportDirective",
8881 "parseImportDirective", 8043 <Object>[
8882 <Object>[emptyCommentAndMetadata()], 8044 emptyCommentAndMetadata()
8883 "import 'lib/lib.dart' as a show B hide A;"); 8045 ], "import 'lib/lib.dart' as a show B hide A;");
8884 expect(directive.keyword, isNotNull); 8046 expect(directive.keyword, isNotNull);
8885 expect(directive.uri, isNotNull); 8047 expect(directive.uri, isNotNull);
8886 expect(directive.deferredKeyword, isNull); 8048 expect(directive.deferredKeyword, isNull);
8887 expect(directive.asKeyword, isNotNull); 8049 expect(directive.asKeyword, isNotNull);
8888 expect(directive.prefix, isNotNull); 8050 expect(directive.prefix, isNotNull);
8889 expect(directive.combinators, hasLength(2)); 8051 expect(directive.combinators, hasLength(2));
8890 expect(directive.semicolon, isNotNull); 8052 expect(directive.semicolon, isNotNull);
8891 } 8053 }
8892 8054
8893 void test_parseImportDirective_show() { 8055 void test_parseImportDirective_show() {
8894 ImportDirective directive = ParserTestCase.parse( 8056 ImportDirective directive = ParserTestCase.parse("parseImportDirective",
8895 "parseImportDirective", 8057 <Object>[
8896 <Object>[emptyCommentAndMetadata()], 8058 emptyCommentAndMetadata()
8897 "import 'lib/lib.dart' show A, B;"); 8059 ], "import 'lib/lib.dart' show A, B;");
8898 expect(directive.keyword, isNotNull); 8060 expect(directive.keyword, isNotNull);
8899 expect(directive.uri, isNotNull); 8061 expect(directive.uri, isNotNull);
8900 expect(directive.deferredKeyword, isNull); 8062 expect(directive.deferredKeyword, isNull);
8901 expect(directive.asKeyword, isNull); 8063 expect(directive.asKeyword, isNull);
8902 expect(directive.prefix, isNull); 8064 expect(directive.prefix, isNull);
8903 expect(directive.combinators, hasLength(1)); 8065 expect(directive.combinators, hasLength(1));
8904 expect(directive.semicolon, isNotNull); 8066 expect(directive.semicolon, isNotNull);
8905 } 8067 }
8906 8068
8907 void test_parseInitializedIdentifierList_type() { 8069 void test_parseInitializedIdentifierList_type() {
8908 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); 8070 Comment comment = Comment.createDocumentationComment(new List<Token>(0));
8909 Token staticKeyword = TokenFactory.tokenFromKeyword(Keyword.STATIC); 8071 Token staticKeyword = TokenFactory.tokenFromKeyword(Keyword.STATIC);
8910 TypeName type = new TypeName(new SimpleIdentifier(null), null); 8072 TypeName type = new TypeName(new SimpleIdentifier(null), null);
8911 FieldDeclaration declaration = ParserTestCase.parse( 8073 FieldDeclaration declaration = ParserTestCase.parse(
8912 "parseInitializedIdentifierList", 8074 "parseInitializedIdentifierList", <Object>[
8913 <Object>[commentAndMetadata(comment), staticKeyword, null, type], 8075 commentAndMetadata(comment),
8914 "a = 1, b, c = 3;"); 8076 staticKeyword,
8077 null,
8078 type
8079 ], "a = 1, b, c = 3;");
8915 expect(declaration.documentationComment, comment); 8080 expect(declaration.documentationComment, comment);
8916 VariableDeclarationList fields = declaration.fields; 8081 VariableDeclarationList fields = declaration.fields;
8917 expect(fields, isNotNull); 8082 expect(fields, isNotNull);
8918 expect(fields.keyword, isNull); 8083 expect(fields.keyword, isNull);
8919 expect(fields.type, type); 8084 expect(fields.type, type);
8920 expect(fields.variables, hasLength(3)); 8085 expect(fields.variables, hasLength(3));
8921 expect(declaration.staticKeyword, staticKeyword); 8086 expect(declaration.staticKeyword, staticKeyword);
8922 expect(declaration.semicolon, isNotNull); 8087 expect(declaration.semicolon, isNotNull);
8923 } 8088 }
8924 8089
8925 void test_parseInitializedIdentifierList_var() { 8090 void test_parseInitializedIdentifierList_var() {
8926 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); 8091 Comment comment = Comment.createDocumentationComment(new List<Token>(0));
8927 Token staticKeyword = TokenFactory.tokenFromKeyword(Keyword.STATIC); 8092 Token staticKeyword = TokenFactory.tokenFromKeyword(Keyword.STATIC);
8928 Token varKeyword = TokenFactory.tokenFromKeyword(Keyword.VAR); 8093 Token varKeyword = TokenFactory.tokenFromKeyword(Keyword.VAR);
8929 FieldDeclaration declaration = ParserTestCase.parse( 8094 FieldDeclaration declaration = ParserTestCase.parse(
8930 "parseInitializedIdentifierList", 8095 "parseInitializedIdentifierList", <Object>[
8931 <Object>[commentAndMetadata(comment), staticKeyword, varKeyword, null], 8096 commentAndMetadata(comment),
8932 "a = 1, b, c = 3;"); 8097 staticKeyword,
8098 varKeyword,
8099 null
8100 ], "a = 1, b, c = 3;");
8933 expect(declaration.documentationComment, comment); 8101 expect(declaration.documentationComment, comment);
8934 VariableDeclarationList fields = declaration.fields; 8102 VariableDeclarationList fields = declaration.fields;
8935 expect(fields, isNotNull); 8103 expect(fields, isNotNull);
8936 expect(fields.keyword, varKeyword); 8104 expect(fields.keyword, varKeyword);
8937 expect(fields.type, isNull); 8105 expect(fields.type, isNull);
8938 expect(fields.variables, hasLength(3)); 8106 expect(fields.variables, hasLength(3));
8939 expect(declaration.staticKeyword, staticKeyword); 8107 expect(declaration.staticKeyword, staticKeyword);
8940 expect(declaration.semicolon, isNotNull); 8108 expect(declaration.semicolon, isNotNull);
8941 } 8109 }
8942 8110
8943 void test_parseInstanceCreationExpression_qualifiedType() { 8111 void test_parseInstanceCreationExpression_qualifiedType() {
8944 Token token = TokenFactory.tokenFromKeyword(Keyword.NEW); 8112 Token token = TokenFactory.tokenFromKeyword(Keyword.NEW);
8945 InstanceCreationExpression expression = ParserTestCase.parse( 8113 InstanceCreationExpression expression = ParserTestCase.parse(
8946 "parseInstanceCreationExpression", 8114 "parseInstanceCreationExpression", <Object>[token], "A.B()");
8947 <Object>[token],
8948 "A.B()");
8949 expect(expression.keyword, token); 8115 expect(expression.keyword, token);
8950 ConstructorName name = expression.constructorName; 8116 ConstructorName name = expression.constructorName;
8951 expect(name, isNotNull); 8117 expect(name, isNotNull);
8952 expect(name.type, isNotNull); 8118 expect(name.type, isNotNull);
8953 expect(name.period, isNull); 8119 expect(name.period, isNull);
8954 expect(name.name, isNull); 8120 expect(name.name, isNull);
8955 expect(expression.argumentList, isNotNull); 8121 expect(expression.argumentList, isNotNull);
8956 } 8122 }
8957 8123
8958 void test_parseInstanceCreationExpression_qualifiedType_named() { 8124 void test_parseInstanceCreationExpression_qualifiedType_named() {
8959 Token token = TokenFactory.tokenFromKeyword(Keyword.NEW); 8125 Token token = TokenFactory.tokenFromKeyword(Keyword.NEW);
8960 InstanceCreationExpression expression = ParserTestCase.parse( 8126 InstanceCreationExpression expression = ParserTestCase.parse(
8961 "parseInstanceCreationExpression", 8127 "parseInstanceCreationExpression", <Object>[token], "A.B.c()");
8962 <Object>[token],
8963 "A.B.c()");
8964 expect(expression.keyword, token); 8128 expect(expression.keyword, token);
8965 ConstructorName name = expression.constructorName; 8129 ConstructorName name = expression.constructorName;
8966 expect(name, isNotNull); 8130 expect(name, isNotNull);
8967 expect(name.type, isNotNull); 8131 expect(name.type, isNotNull);
8968 expect(name.period, isNotNull); 8132 expect(name.period, isNotNull);
8969 expect(name.name, isNotNull); 8133 expect(name.name, isNotNull);
8970 expect(expression.argumentList, isNotNull); 8134 expect(expression.argumentList, isNotNull);
8971 } 8135 }
8972 8136
8973 void test_parseInstanceCreationExpression_type() { 8137 void test_parseInstanceCreationExpression_type() {
8974 Token token = TokenFactory.tokenFromKeyword(Keyword.NEW); 8138 Token token = TokenFactory.tokenFromKeyword(Keyword.NEW);
8975 InstanceCreationExpression expression = ParserTestCase.parse( 8139 InstanceCreationExpression expression = ParserTestCase.parse(
8976 "parseInstanceCreationExpression", 8140 "parseInstanceCreationExpression", <Object>[token], "A()");
8977 <Object>[token],
8978 "A()");
8979 expect(expression.keyword, token); 8141 expect(expression.keyword, token);
8980 ConstructorName name = expression.constructorName; 8142 ConstructorName name = expression.constructorName;
8981 expect(name, isNotNull); 8143 expect(name, isNotNull);
8982 expect(name.type, isNotNull); 8144 expect(name.type, isNotNull);
8983 expect(name.period, isNull); 8145 expect(name.period, isNull);
8984 expect(name.name, isNull); 8146 expect(name.name, isNull);
8985 expect(expression.argumentList, isNotNull); 8147 expect(expression.argumentList, isNotNull);
8986 } 8148 }
8987 8149
8988 void test_parseInstanceCreationExpression_type_named() { 8150 void test_parseInstanceCreationExpression_type_named() {
8989 Token token = TokenFactory.tokenFromKeyword(Keyword.NEW); 8151 Token token = TokenFactory.tokenFromKeyword(Keyword.NEW);
8990 InstanceCreationExpression expression = ParserTestCase.parse( 8152 InstanceCreationExpression expression = ParserTestCase.parse(
8991 "parseInstanceCreationExpression", 8153 "parseInstanceCreationExpression", <Object>[token], "A<B>.c()");
8992 <Object>[token],
8993 "A<B>.c()");
8994 expect(expression.keyword, token); 8154 expect(expression.keyword, token);
8995 ConstructorName name = expression.constructorName; 8155 ConstructorName name = expression.constructorName;
8996 expect(name, isNotNull); 8156 expect(name, isNotNull);
8997 expect(name.type, isNotNull); 8157 expect(name.type, isNotNull);
8998 expect(name.period, isNotNull); 8158 expect(name.period, isNotNull);
8999 expect(name.name, isNotNull); 8159 expect(name.name, isNotNull);
9000 expect(expression.argumentList, isNotNull); 8160 expect(expression.argumentList, isNotNull);
9001 } 8161 }
9002 8162
9003 void test_parseLibraryDirective() { 8163 void test_parseLibraryDirective() {
9004 LibraryDirective directive = ParserTestCase.parse( 8164 LibraryDirective directive = ParserTestCase.parse("parseLibraryDirective",
9005 "parseLibraryDirective", 8165 <Object>[emptyCommentAndMetadata()], "library l;");
9006 <Object>[emptyCommentAndMetadata()],
9007 "library l;");
9008 expect(directive.libraryKeyword, isNotNull); 8166 expect(directive.libraryKeyword, isNotNull);
9009 expect(directive.name, isNotNull); 8167 expect(directive.name, isNotNull);
9010 expect(directive.semicolon, isNotNull); 8168 expect(directive.semicolon, isNotNull);
9011 } 8169 }
9012 8170
9013 void test_parseLibraryIdentifier_multiple() { 8171 void test_parseLibraryIdentifier_multiple() {
9014 String name = "a.b.c"; 8172 String name = "a.b.c";
9015 LibraryIdentifier identifier = 8173 LibraryIdentifier identifier =
9016 ParserTestCase.parse4("parseLibraryIdentifier", name); 8174 ParserTestCase.parse4("parseLibraryIdentifier", name);
9017 expect(identifier.name, name); 8175 expect(identifier.name, name);
9018 } 8176 }
9019 8177
9020 void test_parseLibraryIdentifier_single() { 8178 void test_parseLibraryIdentifier_single() {
9021 String name = "a"; 8179 String name = "a";
9022 LibraryIdentifier identifier = 8180 LibraryIdentifier identifier =
9023 ParserTestCase.parse4("parseLibraryIdentifier", name); 8181 ParserTestCase.parse4("parseLibraryIdentifier", name);
9024 expect(identifier.name, name); 8182 expect(identifier.name, name);
9025 } 8183 }
9026 8184
9027 void test_parseListLiteral_empty_oneToken() { 8185 void test_parseListLiteral_empty_oneToken() {
9028 Token token = TokenFactory.tokenFromKeyword(Keyword.CONST); 8186 Token token = TokenFactory.tokenFromKeyword(Keyword.CONST);
9029 TypeArgumentList typeArguments = null; 8187 TypeArgumentList typeArguments = null;
9030 ListLiteral literal = 8188 ListLiteral literal = ParserTestCase.parse(
9031 ParserTestCase.parse("parseListLiteral", <Object>[token, typeArguments], "[]"); 8189 "parseListLiteral", <Object>[token, typeArguments], "[]");
9032 expect(literal.constKeyword, token); 8190 expect(literal.constKeyword, token);
9033 expect(literal.typeArguments, typeArguments); 8191 expect(literal.typeArguments, typeArguments);
9034 expect(literal.leftBracket, isNotNull); 8192 expect(literal.leftBracket, isNotNull);
9035 expect(literal.elements, hasLength(0)); 8193 expect(literal.elements, hasLength(0));
9036 expect(literal.rightBracket, isNotNull); 8194 expect(literal.rightBracket, isNotNull);
9037 } 8195 }
9038 8196
9039 void test_parseListLiteral_empty_oneToken_withComment() { 8197 void test_parseListLiteral_empty_oneToken_withComment() {
9040 Token constToken = null; 8198 Token constToken = null;
9041 TypeArgumentList typeArguments = null; 8199 TypeArgumentList typeArguments = null;
9042 ListLiteral literal = ParserTestCase.parse( 8200 ListLiteral literal = ParserTestCase.parse(
9043 "parseListLiteral", 8201 "parseListLiteral", <Object>[constToken, typeArguments], "/* 0 */ []");
9044 <Object>[constToken, typeArguments],
9045 "/* 0 */ []");
9046 expect(literal.constKeyword, constToken); 8202 expect(literal.constKeyword, constToken);
9047 expect(literal.typeArguments, typeArguments); 8203 expect(literal.typeArguments, typeArguments);
9048 Token leftBracket = literal.leftBracket; 8204 Token leftBracket = literal.leftBracket;
9049 expect(leftBracket, isNotNull); 8205 expect(leftBracket, isNotNull);
9050 expect(leftBracket.precedingComments, isNotNull); 8206 expect(leftBracket.precedingComments, isNotNull);
9051 expect(literal.elements, hasLength(0)); 8207 expect(literal.elements, hasLength(0));
9052 expect(literal.rightBracket, isNotNull); 8208 expect(literal.rightBracket, isNotNull);
9053 } 8209 }
9054 8210
9055 void test_parseListLiteral_empty_twoTokens() { 8211 void test_parseListLiteral_empty_twoTokens() {
9056 Token token = TokenFactory.tokenFromKeyword(Keyword.CONST); 8212 Token token = TokenFactory.tokenFromKeyword(Keyword.CONST);
9057 TypeArgumentList typeArguments = null; 8213 TypeArgumentList typeArguments = null;
9058 ListLiteral literal = ParserTestCase.parse( 8214 ListLiteral literal = ParserTestCase.parse(
9059 "parseListLiteral", 8215 "parseListLiteral", <Object>[token, typeArguments], "[ ]");
9060 <Object>[token, typeArguments],
9061 "[ ]");
9062 expect(literal.constKeyword, token); 8216 expect(literal.constKeyword, token);
9063 expect(literal.typeArguments, typeArguments); 8217 expect(literal.typeArguments, typeArguments);
9064 expect(literal.leftBracket, isNotNull); 8218 expect(literal.leftBracket, isNotNull);
9065 expect(literal.elements, hasLength(0)); 8219 expect(literal.elements, hasLength(0));
9066 expect(literal.rightBracket, isNotNull); 8220 expect(literal.rightBracket, isNotNull);
9067 } 8221 }
9068 8222
9069 void test_parseListLiteral_multiple() { 8223 void test_parseListLiteral_multiple() {
9070 ListLiteral literal = 8224 ListLiteral literal = ParserTestCase.parse(
9071 ParserTestCase.parse("parseListLiteral", <Object>[null, null], "[1, 2, 3 ]"); 8225 "parseListLiteral", <Object>[null, null], "[1, 2, 3]");
9072 expect(literal.constKeyword, isNull); 8226 expect(literal.constKeyword, isNull);
9073 expect(literal.typeArguments, isNull); 8227 expect(literal.typeArguments, isNull);
9074 expect(literal.leftBracket, isNotNull); 8228 expect(literal.leftBracket, isNotNull);
9075 expect(literal.elements, hasLength(3)); 8229 expect(literal.elements, hasLength(3));
9076 expect(literal.rightBracket, isNotNull); 8230 expect(literal.rightBracket, isNotNull);
9077 } 8231 }
9078 8232
9079 void test_parseListLiteral_single() { 8233 void test_parseListLiteral_single() {
9080 ListLiteral literal = 8234 ListLiteral literal =
9081 ParserTestCase.parse("parseListLiteral", <Object>[null, null], "[1]"); 8235 ParserTestCase.parse("parseListLiteral", <Object>[null, null], "[1]");
9082 expect(literal.constKeyword, isNull); 8236 expect(literal.constKeyword, isNull);
9083 expect(literal.typeArguments, isNull); 8237 expect(literal.typeArguments, isNull);
9084 expect(literal.leftBracket, isNotNull); 8238 expect(literal.leftBracket, isNotNull);
9085 expect(literal.elements, hasLength(1)); 8239 expect(literal.elements, hasLength(1));
9086 expect(literal.rightBracket, isNotNull); 8240 expect(literal.rightBracket, isNotNull);
9087 } 8241 }
9088 8242
9089 void test_parseListOrMapLiteral_list_noType() { 8243 void test_parseListOrMapLiteral_list_noType() {
9090 ListLiteral literal = 8244 ListLiteral literal =
9091 ParserTestCase.parse("parseListOrMapLiteral", <Object>[null], "[1]"); 8245 ParserTestCase.parse("parseListOrMapLiteral", <Object>[null], "[1]");
9092 expect(literal.constKeyword, isNull); 8246 expect(literal.constKeyword, isNull);
9093 expect(literal.typeArguments, isNull); 8247 expect(literal.typeArguments, isNull);
9094 expect(literal.leftBracket, isNotNull); 8248 expect(literal.leftBracket, isNotNull);
9095 expect(literal.elements, hasLength(1)); 8249 expect(literal.elements, hasLength(1));
9096 expect(literal.rightBracket, isNotNull); 8250 expect(literal.rightBracket, isNotNull);
9097 } 8251 }
9098 8252
9099 void test_parseListOrMapLiteral_list_type() { 8253 void test_parseListOrMapLiteral_list_type() {
9100 ListLiteral literal = 8254 ListLiteral literal = ParserTestCase.parse(
9101 ParserTestCase.parse("parseListOrMapLiteral", <Object>[null], "<int> [1] "); 8255 "parseListOrMapLiteral", <Object>[null], "<int> [1]");
9102 expect(literal.constKeyword, isNull); 8256 expect(literal.constKeyword, isNull);
9103 expect(literal.typeArguments, isNotNull); 8257 expect(literal.typeArguments, isNotNull);
9104 expect(literal.leftBracket, isNotNull); 8258 expect(literal.leftBracket, isNotNull);
9105 expect(literal.elements, hasLength(1)); 8259 expect(literal.elements, hasLength(1));
9106 expect(literal.rightBracket, isNotNull); 8260 expect(literal.rightBracket, isNotNull);
9107 } 8261 }
9108 8262
9109 void test_parseListOrMapLiteral_map_noType() { 8263 void test_parseListOrMapLiteral_map_noType() {
9110 MapLiteral literal = 8264 MapLiteral literal = ParserTestCase.parse(
9111 ParserTestCase.parse("parseListOrMapLiteral", <Object>[null], "{'1' : 1} "); 8265 "parseListOrMapLiteral", <Object>[null], "{'1' : 1}");
9112 expect(literal.constKeyword, isNull); 8266 expect(literal.constKeyword, isNull);
9113 expect(literal.typeArguments, isNull); 8267 expect(literal.typeArguments, isNull);
9114 expect(literal.leftBracket, isNotNull); 8268 expect(literal.leftBracket, isNotNull);
9115 expect(literal.entries, hasLength(1)); 8269 expect(literal.entries, hasLength(1));
9116 expect(literal.rightBracket, isNotNull); 8270 expect(literal.rightBracket, isNotNull);
9117 } 8271 }
9118 8272
9119 void test_parseListOrMapLiteral_map_type() { 8273 void test_parseListOrMapLiteral_map_type() {
9120 MapLiteral literal = ParserTestCase.parse( 8274 MapLiteral literal = ParserTestCase.parse(
9121 "parseListOrMapLiteral", 8275 "parseListOrMapLiteral", <Object>[null], "<String, int> {'1' : 1}");
9122 <Object>[null],
9123 "<String, int> {'1' : 1}");
9124 expect(literal.constKeyword, isNull); 8276 expect(literal.constKeyword, isNull);
9125 expect(literal.typeArguments, isNotNull); 8277 expect(literal.typeArguments, isNotNull);
9126 expect(literal.leftBracket, isNotNull); 8278 expect(literal.leftBracket, isNotNull);
9127 expect(literal.entries, hasLength(1)); 8279 expect(literal.entries, hasLength(1));
9128 expect(literal.rightBracket, isNotNull); 8280 expect(literal.rightBracket, isNotNull);
9129 } 8281 }
9130 8282
9131 void test_parseLogicalAndExpression() { 8283 void test_parseLogicalAndExpression() {
9132 BinaryExpression expression = 8284 BinaryExpression expression =
9133 ParserTestCase.parse4("parseLogicalAndExpression", "x && y"); 8285 ParserTestCase.parse4("parseLogicalAndExpression", "x && y");
9134 expect(expression.leftOperand, isNotNull); 8286 expect(expression.leftOperand, isNotNull);
9135 expect(expression.operator, isNotNull); 8287 expect(expression.operator, isNotNull);
9136 expect(expression.operator.type, TokenType.AMPERSAND_AMPERSAND); 8288 expect(expression.operator.type, TokenType.AMPERSAND_AMPERSAND);
9137 expect(expression.rightOperand, isNotNull); 8289 expect(expression.rightOperand, isNotNull);
9138 } 8290 }
9139 8291
9140 void test_parseLogicalOrExpression() { 8292 void test_parseLogicalOrExpression() {
9141 BinaryExpression expression = 8293 BinaryExpression expression =
9142 ParserTestCase.parse4("parseLogicalOrExpression", "x || y"); 8294 ParserTestCase.parse4("parseLogicalOrExpression", "x || y");
9143 expect(expression.leftOperand, isNotNull); 8295 expect(expression.leftOperand, isNotNull);
9144 expect(expression.operator, isNotNull); 8296 expect(expression.operator, isNotNull);
9145 expect(expression.operator.type, TokenType.BAR_BAR); 8297 expect(expression.operator.type, TokenType.BAR_BAR);
9146 expect(expression.rightOperand, isNotNull); 8298 expect(expression.rightOperand, isNotNull);
9147 } 8299 }
9148 8300
9149 void test_parseMapLiteral_empty() { 8301 void test_parseMapLiteral_empty() {
9150 Token token = TokenFactory.tokenFromKeyword(Keyword.CONST); 8302 Token token = TokenFactory.tokenFromKeyword(Keyword.CONST);
9151 TypeArgumentList typeArguments = AstFactory.typeArgumentList( 8303 TypeArgumentList typeArguments = AstFactory.typeArgumentList(
9152 [AstFactory.typeName4("String"), AstFactory.typeName4("int")]); 8304 [AstFactory.typeName4("String"), AstFactory.typeName4("int")]);
9153 MapLiteral literal = 8305 MapLiteral literal = ParserTestCase.parse(
9154 ParserTestCase.parse("parseMapLiteral", <Object>[token, typeArguments], "{}"); 8306 "parseMapLiteral", <Object>[token, typeArguments], "{}");
9155 expect(literal.constKeyword, token); 8307 expect(literal.constKeyword, token);
9156 expect(literal.typeArguments, typeArguments); 8308 expect(literal.typeArguments, typeArguments);
9157 expect(literal.leftBracket, isNotNull); 8309 expect(literal.leftBracket, isNotNull);
9158 expect(literal.entries, hasLength(0)); 8310 expect(literal.entries, hasLength(0));
9159 expect(literal.rightBracket, isNotNull); 8311 expect(literal.rightBracket, isNotNull);
9160 } 8312 }
9161 8313
9162 void test_parseMapLiteral_multiple() { 8314 void test_parseMapLiteral_multiple() {
9163 MapLiteral literal = ParserTestCase.parse( 8315 MapLiteral literal = ParserTestCase.parse(
9164 "parseMapLiteral", 8316 "parseMapLiteral", <Object>[null, null], "{'a' : b, 'x' : y}");
9165 <Object>[null, null],
9166 "{'a' : b, 'x' : y}");
9167 expect(literal.leftBracket, isNotNull); 8317 expect(literal.leftBracket, isNotNull);
9168 expect(literal.entries, hasLength(2)); 8318 expect(literal.entries, hasLength(2));
9169 expect(literal.rightBracket, isNotNull); 8319 expect(literal.rightBracket, isNotNull);
9170 } 8320 }
9171 8321
9172 void test_parseMapLiteral_single() { 8322 void test_parseMapLiteral_single() {
9173 MapLiteral literal = 8323 MapLiteral literal = ParserTestCase.parse(
9174 ParserTestCase.parse("parseMapLiteral", <Object>[null, null], "{'x' : y} "); 8324 "parseMapLiteral", <Object>[null, null], "{'x' : y}");
9175 expect(literal.leftBracket, isNotNull); 8325 expect(literal.leftBracket, isNotNull);
9176 expect(literal.entries, hasLength(1)); 8326 expect(literal.entries, hasLength(1));
9177 expect(literal.rightBracket, isNotNull); 8327 expect(literal.rightBracket, isNotNull);
9178 } 8328 }
9179 8329
9180 void test_parseMapLiteralEntry_complex() { 8330 void test_parseMapLiteralEntry_complex() {
9181 MapLiteralEntry entry = 8331 MapLiteralEntry entry =
9182 ParserTestCase.parse4("parseMapLiteralEntry", "2 + 2 : y"); 8332 ParserTestCase.parse4("parseMapLiteralEntry", "2 + 2 : y");
9183 expect(entry.key, isNotNull); 8333 expect(entry.key, isNotNull);
9184 expect(entry.separator, isNotNull); 8334 expect(entry.separator, isNotNull);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
9241 ParserTestCase.parse4("parseMultiplicativeExpression", "x * y"); 8391 ParserTestCase.parse4("parseMultiplicativeExpression", "x * y");
9242 expect(expression.leftOperand, isNotNull); 8392 expect(expression.leftOperand, isNotNull);
9243 expect(expression.operator, isNotNull); 8393 expect(expression.operator, isNotNull);
9244 expect(expression.operator.type, TokenType.STAR); 8394 expect(expression.operator.type, TokenType.STAR);
9245 expect(expression.rightOperand, isNotNull); 8395 expect(expression.rightOperand, isNotNull);
9246 } 8396 }
9247 8397
9248 void test_parseMultiplicativeExpression_super() { 8398 void test_parseMultiplicativeExpression_super() {
9249 BinaryExpression expression = 8399 BinaryExpression expression =
9250 ParserTestCase.parse4("parseMultiplicativeExpression", "super * y"); 8400 ParserTestCase.parse4("parseMultiplicativeExpression", "super * y");
9251 EngineTestCase.assertInstanceOf( 8401 EngineTestCase.assertInstanceOf((obj) => obj is SuperExpression,
9252 (obj) => obj is SuperExpression, 8402 SuperExpression, expression.leftOperand);
9253 SuperExpression,
9254 expression.leftOperand);
9255 expect(expression.operator, isNotNull); 8403 expect(expression.operator, isNotNull);
9256 expect(expression.operator.type, TokenType.STAR); 8404 expect(expression.operator.type, TokenType.STAR);
9257 expect(expression.rightOperand, isNotNull); 8405 expect(expression.rightOperand, isNotNull);
9258 } 8406 }
9259 8407
9260 void test_parseNewExpression() { 8408 void test_parseNewExpression() {
9261 InstanceCreationExpression expression = 8409 InstanceCreationExpression expression =
9262 ParserTestCase.parse4("parseNewExpression", "new A()"); 8410 ParserTestCase.parse4("parseNewExpression", "new A()");
9263 expect(expression.keyword, isNotNull); 8411 expect(expression.keyword, isNotNull);
9264 ConstructorName name = expression.constructorName; 8412 ConstructorName name = expression.constructorName;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
9330 ParserTestCase.parse4("parseNonLabeledStatement", "() {}[0] = null;"); 8478 ParserTestCase.parse4("parseNonLabeledStatement", "() {}[0] = null;");
9331 } 8479 }
9332 8480
9333 void test_parseNonLabeledStatement_functionInvocation() { 8481 void test_parseNonLabeledStatement_functionInvocation() {
9334 ExpressionStatement statement = 8482 ExpressionStatement statement =
9335 ParserTestCase.parse4("parseNonLabeledStatement", "f();"); 8483 ParserTestCase.parse4("parseNonLabeledStatement", "f();");
9336 expect(statement.expression, isNotNull); 8484 expect(statement.expression, isNotNull);
9337 } 8485 }
9338 8486
9339 void test_parseNonLabeledStatement_invokeFunctionExpression() { 8487 void test_parseNonLabeledStatement_invokeFunctionExpression() {
9340 ExpressionStatement statement = 8488 ExpressionStatement statement = ParserTestCase.parse4(
9341 ParserTestCase.parse4("parseNonLabeledStatement", "(a) {return a + a;} ( 3);"); 8489 "parseNonLabeledStatement", "(a) {return a + a;} (3);");
9342 EngineTestCase.assertInstanceOf( 8490 EngineTestCase.assertInstanceOf(
9343 (obj) => obj is FunctionExpressionInvocation, 8491 (obj) => obj is FunctionExpressionInvocation,
9344 FunctionExpressionInvocation, 8492 FunctionExpressionInvocation, statement.expression);
9345 statement.expression);
9346 FunctionExpressionInvocation invocation = 8493 FunctionExpressionInvocation invocation =
9347 statement.expression as FunctionExpressionInvocation; 8494 statement.expression as FunctionExpressionInvocation;
9348 EngineTestCase.assertInstanceOf( 8495 EngineTestCase.assertInstanceOf((obj) => obj is FunctionExpression,
9349 (obj) => obj is FunctionExpression, 8496 FunctionExpression, invocation.function);
9350 FunctionExpression,
9351 invocation.function);
9352 FunctionExpression expression = invocation.function as FunctionExpression; 8497 FunctionExpression expression = invocation.function as FunctionExpression;
9353 expect(expression.parameters, isNotNull); 8498 expect(expression.parameters, isNotNull);
9354 expect(expression.body, isNotNull); 8499 expect(expression.body, isNotNull);
9355 ArgumentList list = invocation.argumentList; 8500 ArgumentList list = invocation.argumentList;
9356 expect(list, isNotNull); 8501 expect(list, isNotNull);
9357 expect(list.arguments, hasLength(1)); 8502 expect(list.arguments, hasLength(1));
9358 } 8503 }
9359 8504
9360 void test_parseNonLabeledStatement_null() { 8505 void test_parseNonLabeledStatement_null() {
9361 ExpressionStatement statement = 8506 ExpressionStatement statement =
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
9534 SimpleFormalParameter parameter = 8679 SimpleFormalParameter parameter =
9535 ParserTestCase.parse4("parseNormalFormalParameter", "A a)"); 8680 ParserTestCase.parse4("parseNormalFormalParameter", "A a)");
9536 expect(parameter.keyword, isNull); 8681 expect(parameter.keyword, isNull);
9537 expect(parameter.type, isNotNull); 8682 expect(parameter.type, isNotNull);
9538 expect(parameter.identifier, isNotNull); 8683 expect(parameter.identifier, isNotNull);
9539 } 8684 }
9540 8685
9541 void test_parseOperator() { 8686 void test_parseOperator() {
9542 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); 8687 Comment comment = Comment.createDocumentationComment(new List<Token>(0));
9543 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); 8688 TypeName returnType = new TypeName(new SimpleIdentifier(null), null);
9544 MethodDeclaration method = ParserTestCase.parse( 8689 MethodDeclaration method = ParserTestCase.parse("parseOperator", <Object>[
9545 "parseOperator", 8690 commentAndMetadata(comment),
9546 <Object>[commentAndMetadata(comment), null, returnType], 8691 null,
9547 "operator +(A a);"); 8692 returnType
8693 ], "operator +(A a);");
9548 expect(method.body, isNotNull); 8694 expect(method.body, isNotNull);
9549 expect(method.documentationComment, comment); 8695 expect(method.documentationComment, comment);
9550 expect(method.externalKeyword, isNull); 8696 expect(method.externalKeyword, isNull);
9551 expect(method.modifierKeyword, isNull); 8697 expect(method.modifierKeyword, isNull);
9552 expect(method.name, isNotNull); 8698 expect(method.name, isNotNull);
9553 expect(method.operatorKeyword, isNotNull); 8699 expect(method.operatorKeyword, isNotNull);
9554 expect(method.parameters, isNotNull); 8700 expect(method.parameters, isNotNull);
9555 expect(method.propertyKeyword, isNull); 8701 expect(method.propertyKeyword, isNull);
9556 expect(method.returnType, returnType); 8702 expect(method.returnType, returnType);
9557 } 8703 }
9558 8704
9559 void test_parseOptionalReturnType() { 8705 void test_parseOptionalReturnType() {
9560 // TODO(brianwilkerson) Implement tests for this method. 8706 // TODO(brianwilkerson) Implement tests for this method.
9561 } 8707 }
9562 8708
9563 void test_parsePartDirective_part() { 8709 void test_parsePartDirective_part() {
9564 PartDirective directive = ParserTestCase.parse( 8710 PartDirective directive = ParserTestCase.parse("parsePartDirective",
9565 "parsePartDirective", 8711 <Object>[emptyCommentAndMetadata()], "part 'lib/lib.dart';");
9566 <Object>[emptyCommentAndMetadata()],
9567 "part 'lib/lib.dart';");
9568 expect(directive.partKeyword, isNotNull); 8712 expect(directive.partKeyword, isNotNull);
9569 expect(directive.uri, isNotNull); 8713 expect(directive.uri, isNotNull);
9570 expect(directive.semicolon, isNotNull); 8714 expect(directive.semicolon, isNotNull);
9571 } 8715 }
9572 8716
9573 void test_parsePartDirective_partOf() { 8717 void test_parsePartDirective_partOf() {
9574 PartOfDirective directive = ParserTestCase.parse( 8718 PartOfDirective directive = ParserTestCase.parse("parsePartDirective",
9575 "parsePartDirective", 8719 <Object>[emptyCommentAndMetadata()], "part of l;");
9576 <Object>[emptyCommentAndMetadata()],
9577 "part of l;");
9578 expect(directive.partKeyword, isNotNull); 8720 expect(directive.partKeyword, isNotNull);
9579 expect(directive.ofKeyword, isNotNull); 8721 expect(directive.ofKeyword, isNotNull);
9580 expect(directive.libraryName, isNotNull); 8722 expect(directive.libraryName, isNotNull);
9581 expect(directive.semicolon, isNotNull); 8723 expect(directive.semicolon, isNotNull);
9582 } 8724 }
9583 8725
9584 void test_parsePostfixExpression_decrement() { 8726 void test_parsePostfixExpression_decrement() {
9585 PostfixExpression expression = 8727 PostfixExpression expression =
9586 ParserTestCase.parse4("parsePostfixExpression", "i--"); 8728 ParserTestCase.parse4("parsePostfixExpression", "i--");
9587 expect(expression.operand, isNotNull); 8729 expect(expression.operand, isNotNull);
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
9785 ParserTestCase.parse4("parsePrimaryExpression", "true"); 8927 ParserTestCase.parse4("parsePrimaryExpression", "true");
9786 expect(literal.literal, isNotNull); 8928 expect(literal.literal, isNotNull);
9787 expect(literal.value, isTrue); 8929 expect(literal.value, isTrue);
9788 } 8930 }
9789 8931
9790 void test_Parser() { 8932 void test_Parser() {
9791 expect(new Parser(null, null), isNotNull); 8933 expect(new Parser(null, null), isNotNull);
9792 } 8934 }
9793 8935
9794 void test_parseRedirectingConstructorInvocation_named() { 8936 void test_parseRedirectingConstructorInvocation_named() {
9795 RedirectingConstructorInvocation invocation = 8937 RedirectingConstructorInvocation invocation = ParserTestCase.parse4(
9796 ParserTestCase.parse4("parseRedirectingConstructorInvocation", "this.a() "); 8938 "parseRedirectingConstructorInvocation", "this.a()");
9797 expect(invocation.argumentList, isNotNull); 8939 expect(invocation.argumentList, isNotNull);
9798 expect(invocation.constructorName, isNotNull); 8940 expect(invocation.constructorName, isNotNull);
9799 expect(invocation.thisKeyword, isNotNull); 8941 expect(invocation.thisKeyword, isNotNull);
9800 expect(invocation.period, isNotNull); 8942 expect(invocation.period, isNotNull);
9801 } 8943 }
9802 8944
9803 void test_parseRedirectingConstructorInvocation_unnamed() { 8945 void test_parseRedirectingConstructorInvocation_unnamed() {
9804 RedirectingConstructorInvocation invocation = 8946 RedirectingConstructorInvocation invocation = ParserTestCase.parse4(
9805 ParserTestCase.parse4("parseRedirectingConstructorInvocation", "this()") ; 8947 "parseRedirectingConstructorInvocation", "this()");
9806 expect(invocation.argumentList, isNotNull); 8948 expect(invocation.argumentList, isNotNull);
9807 expect(invocation.constructorName, isNull); 8949 expect(invocation.constructorName, isNull);
9808 expect(invocation.thisKeyword, isNotNull); 8950 expect(invocation.thisKeyword, isNotNull);
9809 expect(invocation.period, isNull); 8951 expect(invocation.period, isNull);
9810 } 8952 }
9811 8953
9812 void test_parseRelationalExpression_as() { 8954 void test_parseRelationalExpression_as() {
9813 AsExpression expression = 8955 AsExpression expression =
9814 ParserTestCase.parse4("parseRelationalExpression", "x as Y"); 8956 ParserTestCase.parse4("parseRelationalExpression", "x as Y");
9815 expect(expression.expression, isNotNull); 8957 expect(expression.expression, isNotNull);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
9883 9025
9884 void test_parseReturnType_void() { 9026 void test_parseReturnType_void() {
9885 TypeName typeName = ParserTestCase.parse4("parseReturnType", "void"); 9027 TypeName typeName = ParserTestCase.parse4("parseReturnType", "void");
9886 expect(typeName.name, isNotNull); 9028 expect(typeName.name, isNotNull);
9887 expect(typeName.typeArguments, isNull); 9029 expect(typeName.typeArguments, isNull);
9888 } 9030 }
9889 9031
9890 void test_parseSetter_nonStatic() { 9032 void test_parseSetter_nonStatic() {
9891 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); 9033 Comment comment = Comment.createDocumentationComment(new List<Token>(0));
9892 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); 9034 TypeName returnType = new TypeName(new SimpleIdentifier(null), null);
9893 MethodDeclaration method = ParserTestCase.parse( 9035 MethodDeclaration method = ParserTestCase.parse("parseSetter", <Object>[
9894 "parseSetter", 9036 commentAndMetadata(comment),
9895 <Object>[commentAndMetadata(comment), null, null, returnType], 9037 null,
9896 "set a(var x);"); 9038 null,
9039 returnType
9040 ], "set a(var x);");
9897 expect(method.body, isNotNull); 9041 expect(method.body, isNotNull);
9898 expect(method.documentationComment, comment); 9042 expect(method.documentationComment, comment);
9899 expect(method.externalKeyword, isNull); 9043 expect(method.externalKeyword, isNull);
9900 expect(method.modifierKeyword, isNull); 9044 expect(method.modifierKeyword, isNull);
9901 expect(method.name, isNotNull); 9045 expect(method.name, isNotNull);
9902 expect(method.operatorKeyword, isNull); 9046 expect(method.operatorKeyword, isNull);
9903 expect(method.parameters, isNotNull); 9047 expect(method.parameters, isNotNull);
9904 expect(method.propertyKeyword, isNotNull); 9048 expect(method.propertyKeyword, isNotNull);
9905 expect(method.returnType, returnType); 9049 expect(method.returnType, returnType);
9906 } 9050 }
9907 9051
9908 void test_parseSetter_static() { 9052 void test_parseSetter_static() {
9909 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); 9053 Comment comment = Comment.createDocumentationComment(new List<Token>(0));
9910 Token staticKeyword = TokenFactory.tokenFromKeyword(Keyword.STATIC); 9054 Token staticKeyword = TokenFactory.tokenFromKeyword(Keyword.STATIC);
9911 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); 9055 TypeName returnType = new TypeName(new SimpleIdentifier(null), null);
9912 MethodDeclaration method = ParserTestCase.parse( 9056 MethodDeclaration method = ParserTestCase.parse("parseSetter", <Object>[
9913 "parseSetter", 9057 commentAndMetadata(comment),
9914 <Object>[commentAndMetadata(comment), null, staticKeyword, returnType], 9058 null,
9915 "set a(var x) {}"); 9059 staticKeyword,
9060 returnType
9061 ], "set a(var x) {}");
9916 expect(method.body, isNotNull); 9062 expect(method.body, isNotNull);
9917 expect(method.documentationComment, comment); 9063 expect(method.documentationComment, comment);
9918 expect(method.externalKeyword, isNull); 9064 expect(method.externalKeyword, isNull);
9919 expect(method.modifierKeyword, staticKeyword); 9065 expect(method.modifierKeyword, staticKeyword);
9920 expect(method.name, isNotNull); 9066 expect(method.name, isNotNull);
9921 expect(method.operatorKeyword, isNull); 9067 expect(method.operatorKeyword, isNull);
9922 expect(method.parameters, isNotNull); 9068 expect(method.parameters, isNotNull);
9923 expect(method.propertyKeyword, isNotNull); 9069 expect(method.propertyKeyword, isNotNull);
9924 expect(method.returnType, returnType); 9070 expect(method.returnType, returnType);
9925 } 9071 }
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
10041 SuperConstructorInvocation invocation = 9187 SuperConstructorInvocation invocation =
10042 ParserTestCase.parse4("parseSuperConstructorInvocation", "super()"); 9188 ParserTestCase.parse4("parseSuperConstructorInvocation", "super()");
10043 expect(invocation.argumentList, isNotNull); 9189 expect(invocation.argumentList, isNotNull);
10044 expect(invocation.constructorName, isNull); 9190 expect(invocation.constructorName, isNull);
10045 expect(invocation.superKeyword, isNotNull); 9191 expect(invocation.superKeyword, isNotNull);
10046 expect(invocation.period, isNull); 9192 expect(invocation.period, isNull);
10047 } 9193 }
10048 9194
10049 void test_parseSwitchStatement_case() { 9195 void test_parseSwitchStatement_case() {
10050 SwitchStatement statement = ParserTestCase.parse4( 9196 SwitchStatement statement = ParserTestCase.parse4(
10051 "parseSwitchStatement", 9197 "parseSwitchStatement", "switch (a) {case 1: return 'I';}");
10052 "switch (a) {case 1: return 'I';}");
10053 expect(statement.switchKeyword, isNotNull); 9198 expect(statement.switchKeyword, isNotNull);
10054 expect(statement.leftParenthesis, isNotNull); 9199 expect(statement.leftParenthesis, isNotNull);
10055 expect(statement.expression, isNotNull); 9200 expect(statement.expression, isNotNull);
10056 expect(statement.rightParenthesis, isNotNull); 9201 expect(statement.rightParenthesis, isNotNull);
10057 expect(statement.leftBracket, isNotNull); 9202 expect(statement.leftBracket, isNotNull);
10058 expect(statement.members, hasLength(1)); 9203 expect(statement.members, hasLength(1));
10059 expect(statement.rightBracket, isNotNull); 9204 expect(statement.rightBracket, isNotNull);
10060 } 9205 }
10061 9206
10062 void test_parseSwitchStatement_empty() { 9207 void test_parseSwitchStatement_empty() {
10063 SwitchStatement statement = 9208 SwitchStatement statement =
10064 ParserTestCase.parse4("parseSwitchStatement", "switch (a) {}"); 9209 ParserTestCase.parse4("parseSwitchStatement", "switch (a) {}");
10065 expect(statement.switchKeyword, isNotNull); 9210 expect(statement.switchKeyword, isNotNull);
10066 expect(statement.leftParenthesis, isNotNull); 9211 expect(statement.leftParenthesis, isNotNull);
10067 expect(statement.expression, isNotNull); 9212 expect(statement.expression, isNotNull);
10068 expect(statement.rightParenthesis, isNotNull); 9213 expect(statement.rightParenthesis, isNotNull);
10069 expect(statement.leftBracket, isNotNull); 9214 expect(statement.leftBracket, isNotNull);
10070 expect(statement.members, hasLength(0)); 9215 expect(statement.members, hasLength(0));
10071 expect(statement.rightBracket, isNotNull); 9216 expect(statement.rightBracket, isNotNull);
10072 } 9217 }
10073 9218
10074 void test_parseSwitchStatement_labeledCase() { 9219 void test_parseSwitchStatement_labeledCase() {
10075 SwitchStatement statement = ParserTestCase.parse4( 9220 SwitchStatement statement = ParserTestCase.parse4(
10076 "parseSwitchStatement", 9221 "parseSwitchStatement", "switch (a) {l1: l2: l3: case(1):}");
10077 "switch (a) {l1: l2: l3: case(1):}");
10078 expect(statement.switchKeyword, isNotNull); 9222 expect(statement.switchKeyword, isNotNull);
10079 expect(statement.leftParenthesis, isNotNull); 9223 expect(statement.leftParenthesis, isNotNull);
10080 expect(statement.expression, isNotNull); 9224 expect(statement.expression, isNotNull);
10081 expect(statement.rightParenthesis, isNotNull); 9225 expect(statement.rightParenthesis, isNotNull);
10082 expect(statement.leftBracket, isNotNull); 9226 expect(statement.leftBracket, isNotNull);
10083 expect(statement.members, hasLength(1)); 9227 expect(statement.members, hasLength(1));
10084 expect(statement.members[0].labels, hasLength(3)); 9228 expect(statement.members[0].labels, hasLength(3));
10085 expect(statement.rightBracket, isNotNull); 9229 expect(statement.rightBracket, isNotNull);
10086 } 9230 }
10087 9231
10088 void test_parseSwitchStatement_labeledStatementInCase() { 9232 void test_parseSwitchStatement_labeledStatementInCase() {
10089 SwitchStatement statement = ParserTestCase.parse4( 9233 SwitchStatement statement = ParserTestCase.parse4(
10090 "parseSwitchStatement", 9234 "parseSwitchStatement", "switch (a) {case 0: f(); l1: g(); break;}");
10091 "switch (a) {case 0: f(); l1: g(); break;}");
10092 expect(statement.switchKeyword, isNotNull); 9235 expect(statement.switchKeyword, isNotNull);
10093 expect(statement.leftParenthesis, isNotNull); 9236 expect(statement.leftParenthesis, isNotNull);
10094 expect(statement.expression, isNotNull); 9237 expect(statement.expression, isNotNull);
10095 expect(statement.rightParenthesis, isNotNull); 9238 expect(statement.rightParenthesis, isNotNull);
10096 expect(statement.leftBracket, isNotNull); 9239 expect(statement.leftBracket, isNotNull);
10097 expect(statement.members, hasLength(1)); 9240 expect(statement.members, hasLength(1));
10098 expect(statement.members[0].statements, hasLength(3)); 9241 expect(statement.members[0].statements, hasLength(3));
10099 expect(statement.rightBracket, isNotNull); 9242 expect(statement.rightBracket, isNotNull);
10100 } 9243 }
10101 9244
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
10174 expect(clause.exceptionParameter, isNotNull); 9317 expect(clause.exceptionParameter, isNotNull);
10175 expect(clause.comma, isNull); 9318 expect(clause.comma, isNull);
10176 expect(clause.stackTraceParameter, isNull); 9319 expect(clause.stackTraceParameter, isNull);
10177 expect(clause.body, isNotNull); 9320 expect(clause.body, isNotNull);
10178 expect(statement.finallyKeyword, isNull); 9321 expect(statement.finallyKeyword, isNull);
10179 expect(statement.finallyBlock, isNull); 9322 expect(statement.finallyBlock, isNull);
10180 } 9323 }
10181 9324
10182 void test_parseTryStatement_catch_finally() { 9325 void test_parseTryStatement_catch_finally() {
10183 TryStatement statement = ParserTestCase.parse4( 9326 TryStatement statement = ParserTestCase.parse4(
10184 "parseTryStatement", 9327 "parseTryStatement", "try {} catch (e, s) {} finally {}");
10185 "try {} catch (e, s) {} finally {}");
10186 expect(statement.tryKeyword, isNotNull); 9328 expect(statement.tryKeyword, isNotNull);
10187 expect(statement.body, isNotNull); 9329 expect(statement.body, isNotNull);
10188 NodeList<CatchClause> catchClauses = statement.catchClauses; 9330 NodeList<CatchClause> catchClauses = statement.catchClauses;
10189 expect(catchClauses, hasLength(1)); 9331 expect(catchClauses, hasLength(1));
10190 CatchClause clause = catchClauses[0]; 9332 CatchClause clause = catchClauses[0];
10191 expect(clause.onKeyword, isNull); 9333 expect(clause.onKeyword, isNull);
10192 expect(clause.exceptionType, isNull); 9334 expect(clause.exceptionType, isNull);
10193 expect(clause.catchKeyword, isNotNull); 9335 expect(clause.catchKeyword, isNotNull);
10194 expect(clause.exceptionParameter, isNotNull); 9336 expect(clause.exceptionParameter, isNotNull);
10195 expect(clause.comma, isNotNull); 9337 expect(clause.comma, isNotNull);
10196 expect(clause.stackTraceParameter, isNotNull); 9338 expect(clause.stackTraceParameter, isNotNull);
10197 expect(clause.body, isNotNull); 9339 expect(clause.body, isNotNull);
10198 expect(statement.finallyKeyword, isNotNull); 9340 expect(statement.finallyKeyword, isNotNull);
10199 expect(statement.finallyBlock, isNotNull); 9341 expect(statement.finallyBlock, isNotNull);
10200 } 9342 }
10201 9343
10202 void test_parseTryStatement_finally() { 9344 void test_parseTryStatement_finally() {
10203 TryStatement statement = 9345 TryStatement statement =
10204 ParserTestCase.parse4("parseTryStatement", "try {} finally {}"); 9346 ParserTestCase.parse4("parseTryStatement", "try {} finally {}");
10205 expect(statement.tryKeyword, isNotNull); 9347 expect(statement.tryKeyword, isNotNull);
10206 expect(statement.body, isNotNull); 9348 expect(statement.body, isNotNull);
10207 expect(statement.catchClauses, hasLength(0)); 9349 expect(statement.catchClauses, hasLength(0));
10208 expect(statement.finallyKeyword, isNotNull); 9350 expect(statement.finallyKeyword, isNotNull);
10209 expect(statement.finallyBlock, isNotNull); 9351 expect(statement.finallyBlock, isNotNull);
10210 } 9352 }
10211 9353
10212 void test_parseTryStatement_multiple() { 9354 void test_parseTryStatement_multiple() {
10213 TryStatement statement = ParserTestCase.parse4( 9355 TryStatement statement = ParserTestCase.parse4("parseTryStatement",
10214 "parseTryStatement",
10215 "try {} on NPE catch (e) {} on Error {} catch (e) {}"); 9356 "try {} on NPE catch (e) {} on Error {} catch (e) {}");
10216 expect(statement.tryKeyword, isNotNull); 9357 expect(statement.tryKeyword, isNotNull);
10217 expect(statement.body, isNotNull); 9358 expect(statement.body, isNotNull);
10218 expect(statement.catchClauses, hasLength(3)); 9359 expect(statement.catchClauses, hasLength(3));
10219 expect(statement.finallyKeyword, isNull); 9360 expect(statement.finallyKeyword, isNull);
10220 expect(statement.finallyBlock, isNull); 9361 expect(statement.finallyBlock, isNull);
10221 } 9362 }
10222 9363
10223 void test_parseTryStatement_on() { 9364 void test_parseTryStatement_on() {
10224 TryStatement statement = 9365 TryStatement statement =
10225 ParserTestCase.parse4("parseTryStatement", "try {} on Error {}"); 9366 ParserTestCase.parse4("parseTryStatement", "try {} on Error {}");
10226 expect(statement.tryKeyword, isNotNull); 9367 expect(statement.tryKeyword, isNotNull);
10227 expect(statement.body, isNotNull); 9368 expect(statement.body, isNotNull);
10228 NodeList<CatchClause> catchClauses = statement.catchClauses; 9369 NodeList<CatchClause> catchClauses = statement.catchClauses;
10229 expect(catchClauses, hasLength(1)); 9370 expect(catchClauses, hasLength(1));
10230 CatchClause clause = catchClauses[0]; 9371 CatchClause clause = catchClauses[0];
10231 expect(clause.onKeyword, isNotNull); 9372 expect(clause.onKeyword, isNotNull);
10232 expect(clause.exceptionType, isNotNull); 9373 expect(clause.exceptionType, isNotNull);
10233 expect(clause.catchKeyword, isNull); 9374 expect(clause.catchKeyword, isNull);
10234 expect(clause.exceptionParameter, isNull); 9375 expect(clause.exceptionParameter, isNull);
10235 expect(clause.comma, isNull); 9376 expect(clause.comma, isNull);
10236 expect(clause.stackTraceParameter, isNull); 9377 expect(clause.stackTraceParameter, isNull);
10237 expect(clause.body, isNotNull); 9378 expect(clause.body, isNotNull);
10238 expect(statement.finallyKeyword, isNull); 9379 expect(statement.finallyKeyword, isNull);
10239 expect(statement.finallyBlock, isNull); 9380 expect(statement.finallyBlock, isNull);
10240 } 9381 }
10241 9382
10242 void test_parseTryStatement_on_catch() { 9383 void test_parseTryStatement_on_catch() {
10243 TryStatement statement = 9384 TryStatement statement = ParserTestCase.parse4(
10244 ParserTestCase.parse4("parseTryStatement", "try {} on Error catch (e, s) {}"); 9385 "parseTryStatement", "try {} on Error catch (e, s) {}");
10245 expect(statement.tryKeyword, isNotNull); 9386 expect(statement.tryKeyword, isNotNull);
10246 expect(statement.body, isNotNull); 9387 expect(statement.body, isNotNull);
10247 NodeList<CatchClause> catchClauses = statement.catchClauses; 9388 NodeList<CatchClause> catchClauses = statement.catchClauses;
10248 expect(catchClauses, hasLength(1)); 9389 expect(catchClauses, hasLength(1));
10249 CatchClause clause = catchClauses[0]; 9390 CatchClause clause = catchClauses[0];
10250 expect(clause.onKeyword, isNotNull); 9391 expect(clause.onKeyword, isNotNull);
10251 expect(clause.exceptionType, isNotNull); 9392 expect(clause.exceptionType, isNotNull);
10252 expect(clause.catchKeyword, isNotNull); 9393 expect(clause.catchKeyword, isNotNull);
10253 expect(clause.exceptionParameter, isNotNull); 9394 expect(clause.exceptionParameter, isNotNull);
10254 expect(clause.comma, isNotNull); 9395 expect(clause.comma, isNotNull);
10255 expect(clause.stackTraceParameter, isNotNull); 9396 expect(clause.stackTraceParameter, isNotNull);
10256 expect(clause.body, isNotNull); 9397 expect(clause.body, isNotNull);
10257 expect(statement.finallyKeyword, isNull); 9398 expect(statement.finallyKeyword, isNull);
10258 expect(statement.finallyBlock, isNull); 9399 expect(statement.finallyBlock, isNull);
10259 } 9400 }
10260 9401
10261 void test_parseTryStatement_on_catch_finally() { 9402 void test_parseTryStatement_on_catch_finally() {
10262 TryStatement statement = ParserTestCase.parse4( 9403 TryStatement statement = ParserTestCase.parse4(
10263 "parseTryStatement", 9404 "parseTryStatement", "try {} on Error catch (e, s) {} finally {}");
10264 "try {} on Error catch (e, s) {} finally {}");
10265 expect(statement.tryKeyword, isNotNull); 9405 expect(statement.tryKeyword, isNotNull);
10266 expect(statement.body, isNotNull); 9406 expect(statement.body, isNotNull);
10267 NodeList<CatchClause> catchClauses = statement.catchClauses; 9407 NodeList<CatchClause> catchClauses = statement.catchClauses;
10268 expect(catchClauses, hasLength(1)); 9408 expect(catchClauses, hasLength(1));
10269 CatchClause clause = catchClauses[0]; 9409 CatchClause clause = catchClauses[0];
10270 expect(clause.onKeyword, isNotNull); 9410 expect(clause.onKeyword, isNotNull);
10271 expect(clause.exceptionType, isNotNull); 9411 expect(clause.exceptionType, isNotNull);
10272 expect(clause.catchKeyword, isNotNull); 9412 expect(clause.catchKeyword, isNotNull);
10273 expect(clause.exceptionParameter, isNotNull); 9413 expect(clause.exceptionParameter, isNotNull);
10274 expect(clause.comma, isNotNull); 9414 expect(clause.comma, isNotNull);
10275 expect(clause.stackTraceParameter, isNotNull); 9415 expect(clause.stackTraceParameter, isNotNull);
10276 expect(clause.body, isNotNull); 9416 expect(clause.body, isNotNull);
10277 expect(statement.finallyKeyword, isNotNull); 9417 expect(statement.finallyKeyword, isNotNull);
10278 expect(statement.finallyBlock, isNotNull); 9418 expect(statement.finallyBlock, isNotNull);
10279 } 9419 }
10280 9420
10281 void test_parseTypeAlias_function_noParameters() { 9421 void test_parseTypeAlias_function_noParameters() {
10282 FunctionTypeAlias typeAlias = ParserTestCase.parse( 9422 FunctionTypeAlias typeAlias = ParserTestCase.parse("parseTypeAlias",
10283 "parseTypeAlias", 9423 <Object>[emptyCommentAndMetadata()], "typedef bool F();");
10284 <Object>[emptyCommentAndMetadata()],
10285 "typedef bool F();");
10286 expect(typeAlias.typedefKeyword, isNotNull); 9424 expect(typeAlias.typedefKeyword, isNotNull);
10287 expect(typeAlias.name, isNotNull); 9425 expect(typeAlias.name, isNotNull);
10288 expect(typeAlias.parameters, isNotNull); 9426 expect(typeAlias.parameters, isNotNull);
10289 expect(typeAlias.returnType, isNotNull); 9427 expect(typeAlias.returnType, isNotNull);
10290 expect(typeAlias.semicolon, isNotNull); 9428 expect(typeAlias.semicolon, isNotNull);
10291 expect(typeAlias.typeParameters, isNull); 9429 expect(typeAlias.typeParameters, isNull);
10292 } 9430 }
10293 9431
10294 void test_parseTypeAlias_function_noReturnType() { 9432 void test_parseTypeAlias_function_noReturnType() {
10295 FunctionTypeAlias typeAlias = ParserTestCase.parse( 9433 FunctionTypeAlias typeAlias = ParserTestCase.parse(
10296 "parseTypeAlias", 9434 "parseTypeAlias", <Object>[emptyCommentAndMetadata()], "typedef F();");
10297 <Object>[emptyCommentAndMetadata()],
10298 "typedef F();");
10299 expect(typeAlias.typedefKeyword, isNotNull); 9435 expect(typeAlias.typedefKeyword, isNotNull);
10300 expect(typeAlias.name, isNotNull); 9436 expect(typeAlias.name, isNotNull);
10301 expect(typeAlias.parameters, isNotNull); 9437 expect(typeAlias.parameters, isNotNull);
10302 expect(typeAlias.returnType, isNull); 9438 expect(typeAlias.returnType, isNull);
10303 expect(typeAlias.semicolon, isNotNull); 9439 expect(typeAlias.semicolon, isNotNull);
10304 expect(typeAlias.typeParameters, isNull); 9440 expect(typeAlias.typeParameters, isNull);
10305 } 9441 }
10306 9442
10307 void test_parseTypeAlias_function_parameterizedReturnType() { 9443 void test_parseTypeAlias_function_parameterizedReturnType() {
10308 FunctionTypeAlias typeAlias = ParserTestCase.parse( 9444 FunctionTypeAlias typeAlias = ParserTestCase.parse("parseTypeAlias",
10309 "parseTypeAlias", 9445 <Object>[emptyCommentAndMetadata()], "typedef A<B> F();");
10310 <Object>[emptyCommentAndMetadata()],
10311 "typedef A<B> F();");
10312 expect(typeAlias.typedefKeyword, isNotNull); 9446 expect(typeAlias.typedefKeyword, isNotNull);
10313 expect(typeAlias.name, isNotNull); 9447 expect(typeAlias.name, isNotNull);
10314 expect(typeAlias.parameters, isNotNull); 9448 expect(typeAlias.parameters, isNotNull);
10315 expect(typeAlias.returnType, isNotNull); 9449 expect(typeAlias.returnType, isNotNull);
10316 expect(typeAlias.semicolon, isNotNull); 9450 expect(typeAlias.semicolon, isNotNull);
10317 expect(typeAlias.typeParameters, isNull); 9451 expect(typeAlias.typeParameters, isNull);
10318 } 9452 }
10319 9453
10320 void test_parseTypeAlias_function_parameters() { 9454 void test_parseTypeAlias_function_parameters() {
10321 FunctionTypeAlias typeAlias = ParserTestCase.parse( 9455 FunctionTypeAlias typeAlias = ParserTestCase.parse("parseTypeAlias",
10322 "parseTypeAlias", 9456 <Object>[emptyCommentAndMetadata()], "typedef bool F(Object value);");
10323 <Object>[emptyCommentAndMetadata()],
10324 "typedef bool F(Object value);");
10325 expect(typeAlias.typedefKeyword, isNotNull); 9457 expect(typeAlias.typedefKeyword, isNotNull);
10326 expect(typeAlias.name, isNotNull); 9458 expect(typeAlias.name, isNotNull);
10327 expect(typeAlias.parameters, isNotNull); 9459 expect(typeAlias.parameters, isNotNull);
10328 expect(typeAlias.returnType, isNotNull); 9460 expect(typeAlias.returnType, isNotNull);
10329 expect(typeAlias.semicolon, isNotNull); 9461 expect(typeAlias.semicolon, isNotNull);
10330 expect(typeAlias.typeParameters, isNull); 9462 expect(typeAlias.typeParameters, isNull);
10331 } 9463 }
10332 9464
10333 void test_parseTypeAlias_function_typeParameters() { 9465 void test_parseTypeAlias_function_typeParameters() {
10334 FunctionTypeAlias typeAlias = ParserTestCase.parse( 9466 FunctionTypeAlias typeAlias = ParserTestCase.parse("parseTypeAlias",
10335 "parseTypeAlias", 9467 <Object>[emptyCommentAndMetadata()], "typedef bool F<E>();");
10336 <Object>[emptyCommentAndMetadata()],
10337 "typedef bool F<E>();");
10338 expect(typeAlias.typedefKeyword, isNotNull); 9468 expect(typeAlias.typedefKeyword, isNotNull);
10339 expect(typeAlias.name, isNotNull); 9469 expect(typeAlias.name, isNotNull);
10340 expect(typeAlias.parameters, isNotNull); 9470 expect(typeAlias.parameters, isNotNull);
10341 expect(typeAlias.returnType, isNotNull); 9471 expect(typeAlias.returnType, isNotNull);
10342 expect(typeAlias.semicolon, isNotNull); 9472 expect(typeAlias.semicolon, isNotNull);
10343 expect(typeAlias.typeParameters, isNotNull); 9473 expect(typeAlias.typeParameters, isNotNull);
10344 } 9474 }
10345 9475
10346 void test_parseTypeAlias_function_voidReturnType() { 9476 void test_parseTypeAlias_function_voidReturnType() {
10347 FunctionTypeAlias typeAlias = ParserTestCase.parse( 9477 FunctionTypeAlias typeAlias = ParserTestCase.parse("parseTypeAlias",
10348 "parseTypeAlias", 9478 <Object>[emptyCommentAndMetadata()], "typedef void F();");
10349 <Object>[emptyCommentAndMetadata()],
10350 "typedef void F();");
10351 expect(typeAlias.typedefKeyword, isNotNull); 9479 expect(typeAlias.typedefKeyword, isNotNull);
10352 expect(typeAlias.name, isNotNull); 9480 expect(typeAlias.name, isNotNull);
10353 expect(typeAlias.parameters, isNotNull); 9481 expect(typeAlias.parameters, isNotNull);
10354 expect(typeAlias.returnType, isNotNull); 9482 expect(typeAlias.returnType, isNotNull);
10355 expect(typeAlias.semicolon, isNotNull); 9483 expect(typeAlias.semicolon, isNotNull);
10356 expect(typeAlias.typeParameters, isNull); 9484 expect(typeAlias.typeParameters, isNull);
10357 } 9485 }
10358 9486
10359 void test_parseTypeArgumentList_multiple() { 9487 void test_parseTypeArgumentList_multiple() {
10360 TypeArgumentList argumentList = 9488 TypeArgumentList argumentList =
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
10626 void test_parseVariableDeclaration_noEquals() { 9754 void test_parseVariableDeclaration_noEquals() {
10627 VariableDeclaration declaration = 9755 VariableDeclaration declaration =
10628 ParserTestCase.parse4("parseVariableDeclaration", "a"); 9756 ParserTestCase.parse4("parseVariableDeclaration", "a");
10629 expect(declaration.name, isNotNull); 9757 expect(declaration.name, isNotNull);
10630 expect(declaration.equals, isNull); 9758 expect(declaration.equals, isNull);
10631 expect(declaration.initializer, isNull); 9759 expect(declaration.initializer, isNull);
10632 } 9760 }
10633 9761
10634 void test_parseVariableDeclarationListAfterMetadata_const_noType() { 9762 void test_parseVariableDeclarationListAfterMetadata_const_noType() {
10635 VariableDeclarationList declarationList = ParserTestCase.parse( 9763 VariableDeclarationList declarationList = ParserTestCase.parse(
10636 "parseVariableDeclarationListAfterMetadata", 9764 "parseVariableDeclarationListAfterMetadata", <Object>[
10637 <Object>[emptyCommentAndMetadata()], 9765 emptyCommentAndMetadata()
10638 "const a"); 9766 ], "const a");
10639 expect(declarationList.keyword, isNotNull); 9767 expect(declarationList.keyword, isNotNull);
10640 expect(declarationList.type, isNull); 9768 expect(declarationList.type, isNull);
10641 expect(declarationList.variables, hasLength(1)); 9769 expect(declarationList.variables, hasLength(1));
10642 } 9770 }
10643 9771
10644 void test_parseVariableDeclarationListAfterMetadata_const_type() { 9772 void test_parseVariableDeclarationListAfterMetadata_const_type() {
10645 VariableDeclarationList declarationList = ParserTestCase.parse( 9773 VariableDeclarationList declarationList = ParserTestCase.parse(
10646 "parseVariableDeclarationListAfterMetadata", 9774 "parseVariableDeclarationListAfterMetadata", <Object>[
10647 <Object>[emptyCommentAndMetadata()], 9775 emptyCommentAndMetadata()
10648 "const A a"); 9776 ], "const A a");
10649 expect(declarationList.keyword, isNotNull); 9777 expect(declarationList.keyword, isNotNull);
10650 expect(declarationList.type, isNotNull); 9778 expect(declarationList.type, isNotNull);
10651 expect(declarationList.variables, hasLength(1)); 9779 expect(declarationList.variables, hasLength(1));
10652 } 9780 }
10653 9781
10654 void test_parseVariableDeclarationListAfterMetadata_final_noType() { 9782 void test_parseVariableDeclarationListAfterMetadata_final_noType() {
10655 VariableDeclarationList declarationList = ParserTestCase.parse( 9783 VariableDeclarationList declarationList = ParserTestCase.parse(
10656 "parseVariableDeclarationListAfterMetadata", 9784 "parseVariableDeclarationListAfterMetadata", <Object>[
10657 <Object>[emptyCommentAndMetadata()], 9785 emptyCommentAndMetadata()
10658 "final a"); 9786 ], "final a");
10659 expect(declarationList.keyword, isNotNull); 9787 expect(declarationList.keyword, isNotNull);
10660 expect(declarationList.type, isNull); 9788 expect(declarationList.type, isNull);
10661 expect(declarationList.variables, hasLength(1)); 9789 expect(declarationList.variables, hasLength(1));
10662 } 9790 }
10663 9791
10664 void test_parseVariableDeclarationListAfterMetadata_final_type() { 9792 void test_parseVariableDeclarationListAfterMetadata_final_type() {
10665 VariableDeclarationList declarationList = ParserTestCase.parse( 9793 VariableDeclarationList declarationList = ParserTestCase.parse(
10666 "parseVariableDeclarationListAfterMetadata", 9794 "parseVariableDeclarationListAfterMetadata", <Object>[
10667 <Object>[emptyCommentAndMetadata()], 9795 emptyCommentAndMetadata()
10668 "final A a"); 9796 ], "final A a");
10669 expect(declarationList.keyword, isNotNull); 9797 expect(declarationList.keyword, isNotNull);
10670 expect(declarationList.type, isNotNull); 9798 expect(declarationList.type, isNotNull);
10671 expect(declarationList.variables, hasLength(1)); 9799 expect(declarationList.variables, hasLength(1));
10672 } 9800 }
10673 9801
10674 void test_parseVariableDeclarationListAfterMetadata_type_multiple() { 9802 void test_parseVariableDeclarationListAfterMetadata_type_multiple() {
10675 VariableDeclarationList declarationList = ParserTestCase.parse( 9803 VariableDeclarationList declarationList = ParserTestCase.parse(
10676 "parseVariableDeclarationListAfterMetadata", 9804 "parseVariableDeclarationListAfterMetadata", <Object>[
10677 <Object>[emptyCommentAndMetadata()], 9805 emptyCommentAndMetadata()
10678 "A a, b, c"); 9806 ], "A a, b, c");
10679 expect(declarationList.keyword, isNull); 9807 expect(declarationList.keyword, isNull);
10680 expect(declarationList.type, isNotNull); 9808 expect(declarationList.type, isNotNull);
10681 expect(declarationList.variables, hasLength(3)); 9809 expect(declarationList.variables, hasLength(3));
10682 } 9810 }
10683 9811
10684 void test_parseVariableDeclarationListAfterMetadata_type_single() { 9812 void test_parseVariableDeclarationListAfterMetadata_type_single() {
10685 VariableDeclarationList declarationList = ParserTestCase.parse( 9813 VariableDeclarationList declarationList = ParserTestCase.parse(
10686 "parseVariableDeclarationListAfterMetadata", 9814 "parseVariableDeclarationListAfterMetadata", <Object>[
10687 <Object>[emptyCommentAndMetadata()], 9815 emptyCommentAndMetadata()
10688 "A a"); 9816 ], "A a");
10689 expect(declarationList.keyword, isNull); 9817 expect(declarationList.keyword, isNull);
10690 expect(declarationList.type, isNotNull); 9818 expect(declarationList.type, isNotNull);
10691 expect(declarationList.variables, hasLength(1)); 9819 expect(declarationList.variables, hasLength(1));
10692 } 9820 }
10693 9821
10694 void test_parseVariableDeclarationListAfterMetadata_var_multiple() { 9822 void test_parseVariableDeclarationListAfterMetadata_var_multiple() {
10695 VariableDeclarationList declarationList = ParserTestCase.parse( 9823 VariableDeclarationList declarationList = ParserTestCase.parse(
10696 "parseVariableDeclarationListAfterMetadata", 9824 "parseVariableDeclarationListAfterMetadata", <Object>[
10697 <Object>[emptyCommentAndMetadata()], 9825 emptyCommentAndMetadata()
10698 "var a, b, c"); 9826 ], "var a, b, c");
10699 expect(declarationList.keyword, isNotNull); 9827 expect(declarationList.keyword, isNotNull);
10700 expect(declarationList.type, isNull); 9828 expect(declarationList.type, isNull);
10701 expect(declarationList.variables, hasLength(3)); 9829 expect(declarationList.variables, hasLength(3));
10702 } 9830 }
10703 9831
10704 void test_parseVariableDeclarationListAfterMetadata_var_single() { 9832 void test_parseVariableDeclarationListAfterMetadata_var_single() {
10705 VariableDeclarationList declarationList = ParserTestCase.parse( 9833 VariableDeclarationList declarationList = ParserTestCase.parse(
10706 "parseVariableDeclarationListAfterMetadata", 9834 "parseVariableDeclarationListAfterMetadata", <Object>[
10707 <Object>[emptyCommentAndMetadata()], 9835 emptyCommentAndMetadata()
10708 "var a"); 9836 ], "var a");
10709 expect(declarationList.keyword, isNotNull); 9837 expect(declarationList.keyword, isNotNull);
10710 expect(declarationList.type, isNull); 9838 expect(declarationList.type, isNull);
10711 expect(declarationList.variables, hasLength(1)); 9839 expect(declarationList.variables, hasLength(1));
10712 } 9840 }
10713 9841
10714 void test_parseVariableDeclarationListAfterType_type() { 9842 void test_parseVariableDeclarationListAfterType_type() {
10715 TypeName type = new TypeName(new SimpleIdentifier(null), null); 9843 TypeName type = new TypeName(new SimpleIdentifier(null), null);
10716 VariableDeclarationList declarationList = ParserTestCase.parse( 9844 VariableDeclarationList declarationList = ParserTestCase.parse(
10717 "parseVariableDeclarationListAfterType", 9845 "parseVariableDeclarationListAfterType", <Object>[
10718 <Object>[emptyCommentAndMetadata(), null, type], 9846 emptyCommentAndMetadata(),
10719 "a"); 9847 null,
9848 type
9849 ], "a");
10720 expect(declarationList.keyword, isNull); 9850 expect(declarationList.keyword, isNull);
10721 expect(declarationList.type, type); 9851 expect(declarationList.type, type);
10722 expect(declarationList.variables, hasLength(1)); 9852 expect(declarationList.variables, hasLength(1));
10723 } 9853 }
10724 9854
10725 void test_parseVariableDeclarationListAfterType_var() { 9855 void test_parseVariableDeclarationListAfterType_var() {
10726 Token keyword = TokenFactory.tokenFromKeyword(Keyword.VAR); 9856 Token keyword = TokenFactory.tokenFromKeyword(Keyword.VAR);
10727 VariableDeclarationList declarationList = ParserTestCase.parse( 9857 VariableDeclarationList declarationList = ParserTestCase.parse(
10728 "parseVariableDeclarationListAfterType", 9858 "parseVariableDeclarationListAfterType", <Object>[
10729 <Object>[emptyCommentAndMetadata(), keyword, null], 9859 emptyCommentAndMetadata(),
10730 "a, b, c"); 9860 keyword,
9861 null
9862 ], "a, b, c");
10731 expect(declarationList.keyword, keyword); 9863 expect(declarationList.keyword, keyword);
10732 expect(declarationList.type, isNull); 9864 expect(declarationList.type, isNull);
10733 expect(declarationList.variables, hasLength(3)); 9865 expect(declarationList.variables, hasLength(3));
10734 } 9866 }
10735 9867
10736 void test_parseVariableDeclarationStatementAfterMetadata_multiple() { 9868 void test_parseVariableDeclarationStatementAfterMetadata_multiple() {
10737 VariableDeclarationStatement statement = ParserTestCase.parse( 9869 VariableDeclarationStatement statement = ParserTestCase.parse(
10738 "parseVariableDeclarationStatementAfterMetadata", 9870 "parseVariableDeclarationStatementAfterMetadata", <Object>[
10739 <Object>[emptyCommentAndMetadata()], 9871 emptyCommentAndMetadata()
10740 "var x, y, z;"); 9872 ], "var x, y, z;");
10741 expect(statement.semicolon, isNotNull); 9873 expect(statement.semicolon, isNotNull);
10742 VariableDeclarationList variableList = statement.variables; 9874 VariableDeclarationList variableList = statement.variables;
10743 expect(variableList, isNotNull); 9875 expect(variableList, isNotNull);
10744 expect(variableList.variables, hasLength(3)); 9876 expect(variableList.variables, hasLength(3));
10745 } 9877 }
10746 9878
10747 void test_parseVariableDeclarationStatementAfterMetadata_single() { 9879 void test_parseVariableDeclarationStatementAfterMetadata_single() {
10748 VariableDeclarationStatement statement = ParserTestCase.parse( 9880 VariableDeclarationStatement statement = ParserTestCase.parse(
10749 "parseVariableDeclarationStatementAfterMetadata", 9881 "parseVariableDeclarationStatementAfterMetadata", <Object>[
10750 <Object>[emptyCommentAndMetadata()], 9882 emptyCommentAndMetadata()
10751 "var x;"); 9883 ], "var x;");
10752 expect(statement.semicolon, isNotNull); 9884 expect(statement.semicolon, isNotNull);
10753 VariableDeclarationList variableList = statement.variables; 9885 VariableDeclarationList variableList = statement.variables;
10754 expect(variableList, isNotNull); 9886 expect(variableList, isNotNull);
10755 expect(variableList.variables, hasLength(1)); 9887 expect(variableList.variables, hasLength(1));
10756 } 9888 }
10757 9889
10758 void test_parseWhileStatement() { 9890 void test_parseWhileStatement() {
10759 WhileStatement statement = 9891 WhileStatement statement =
10760 ParserTestCase.parse4("parseWhileStatement", "while (x) {}"); 9892 ParserTestCase.parse4("parseWhileStatement", "while (x) {}");
10761 expect(statement.whileKeyword, isNotNull); 9893 expect(statement.whileKeyword, isNotNull);
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
10910 * @param lexeme the argument to the method 10042 * @param lexeme the argument to the method
10911 * @param first `true` if this is the first token in a string literal 10043 * @param first `true` if this is the first token in a string literal
10912 * @param last `true` if this is the last token in a string literal 10044 * @param last `true` if this is the last token in a string literal
10913 * @return the result of invoking the method 10045 * @return the result of invoking the method
10914 * @throws Exception if the method could not be invoked or throws an exception 10046 * @throws Exception if the method could not be invoked or throws an exception
10915 */ 10047 */
10916 String _computeStringValue(String lexeme, bool first, bool last) { 10048 String _computeStringValue(String lexeme, bool first, bool last) {
10917 AnalysisErrorListener listener = 10049 AnalysisErrorListener listener =
10918 new AnalysisErrorListener_SimpleParserTest_computeStringValue(); 10050 new AnalysisErrorListener_SimpleParserTest_computeStringValue();
10919 Parser parser = new Parser(null, listener); 10051 Parser parser = new Parser(null, listener);
10920 return invokeParserMethodImpl( 10052 return invokeParserMethodImpl(parser, "computeStringValue", <Object>[
10921 parser, 10053 lexeme,
10922 "computeStringValue", 10054 first,
10923 <Object>[lexeme, first, last], 10055 last
10924 null) as String; 10056 ], null) as String;
10925 } 10057 }
10926 10058
10927 /** 10059 /**
10928 * Invoke the method [Parser.createSyntheticIdentifier] with the parser set to the token 10060 * Invoke the method [Parser.createSyntheticIdentifier] with the parser set to the token
10929 * stream produced by scanning the given source. 10061 * stream produced by scanning the given source.
10930 * 10062 *
10931 * @param source the source to be scanned to produce the token stream being te sted 10063 * @param source the source to be scanned to produce the token stream being te sted
10932 * @return the result of invoking the method 10064 * @return the result of invoking the method
10933 * @throws Exception if the method could not be invoked or throws an exception 10065 * @throws Exception if the method could not be invoked or throws an exception
10934 */ 10066 */
10935 SimpleIdentifier _createSyntheticIdentifier() { 10067 SimpleIdentifier _createSyntheticIdentifier() {
10936 GatheringErrorListener listener = new GatheringErrorListener(); 10068 GatheringErrorListener listener = new GatheringErrorListener();
10937 return ParserTestCase.invokeParserMethod2( 10069 return ParserTestCase.invokeParserMethod2(
10938 "createSyntheticIdentifier", 10070 "createSyntheticIdentifier", "", listener);
10939 "",
10940 listener);
10941 } 10071 }
10942 10072
10943 /** 10073 /**
10944 * Invoke the method [Parser.createSyntheticIdentifier] with the parser set to the token 10074 * Invoke the method [Parser.createSyntheticIdentifier] with the parser set to the token
10945 * stream produced by scanning the given source. 10075 * stream produced by scanning the given source.
10946 * 10076 *
10947 * @param source the source to be scanned to produce the token stream being te sted 10077 * @param source the source to be scanned to produce the token stream being te sted
10948 * @return the result of invoking the method 10078 * @return the result of invoking the method
10949 * @throws Exception if the method could not be invoked or throws an exception 10079 * @throws Exception if the method could not be invoked or throws an exception
10950 */ 10080 */
10951 SimpleStringLiteral _createSyntheticStringLiteral() { 10081 SimpleStringLiteral _createSyntheticStringLiteral() {
10952 GatheringErrorListener listener = new GatheringErrorListener(); 10082 GatheringErrorListener listener = new GatheringErrorListener();
10953 return ParserTestCase.invokeParserMethod2( 10083 return ParserTestCase.invokeParserMethod2(
10954 "createSyntheticStringLiteral", 10084 "createSyntheticStringLiteral", "", listener);
10955 "",
10956 listener);
10957 } 10085 }
10958 10086
10959 /** 10087 /**
10960 * Invoke the method [Parser.isFunctionDeclaration] with the parser set to the token 10088 * Invoke the method [Parser.isFunctionDeclaration] with the parser set to the token
10961 * stream produced by scanning the given source. 10089 * stream produced by scanning the given source.
10962 * 10090 *
10963 * @param source the source to be scanned to produce the token stream being te sted 10091 * @param source the source to be scanned to produce the token stream being te sted
10964 * @return the result of invoking the method 10092 * @return the result of invoking the method
10965 * @throws Exception if the method could not be invoked or throws an exception 10093 * @throws Exception if the method could not be invoked or throws an exception
10966 */ 10094 */
10967 bool _isFunctionDeclaration(String source) { 10095 bool _isFunctionDeclaration(String source) {
10968 GatheringErrorListener listener = new GatheringErrorListener(); 10096 GatheringErrorListener listener = new GatheringErrorListener();
10969 return ParserTestCase.invokeParserMethod2( 10097 return ParserTestCase.invokeParserMethod2(
10970 "isFunctionDeclaration", 10098 "isFunctionDeclaration", source, listener) as bool;
10971 source,
10972 listener) as bool;
10973 } 10099 }
10974 10100
10975 /** 10101 /**
10976 * Invoke the method [Parser.isFunctionExpression] with the parser set to the token stream 10102 * Invoke the method [Parser.isFunctionExpression] with the parser set to the token stream
10977 * produced by scanning the given source. 10103 * produced by scanning the given source.
10978 * 10104 *
10979 * @param source the source to be scanned to produce the token stream being te sted 10105 * @param source the source to be scanned to produce the token stream being te sted
10980 * @return the result of invoking the method 10106 * @return the result of invoking the method
10981 * @throws Exception if the method could not be invoked or throws an exception 10107 * @throws Exception if the method could not be invoked or throws an exception
10982 */ 10108 */
10983 bool _isFunctionExpression(String source) { 10109 bool _isFunctionExpression(String source) {
10984 GatheringErrorListener listener = new GatheringErrorListener(); 10110 GatheringErrorListener listener = new GatheringErrorListener();
10985 // 10111 //
10986 // Scan the source. 10112 // Scan the source.
10987 // 10113 //
10988 Scanner scanner = 10114 Scanner scanner =
10989 new Scanner(null, new CharSequenceReader(source), listener); 10115 new Scanner(null, new CharSequenceReader(source), listener);
10990 Token tokenStream = scanner.tokenize(); 10116 Token tokenStream = scanner.tokenize();
10991 // 10117 //
10992 // Parse the source. 10118 // Parse the source.
10993 // 10119 //
10994 Parser parser = new Parser(null, listener); 10120 Parser parser = new Parser(null, listener);
10995 return invokeParserMethodImpl( 10121 return invokeParserMethodImpl(parser, "isFunctionExpression", <Object>[
10996 parser, 10122 tokenStream
10997 "isFunctionExpression", 10123 ], tokenStream) as bool;
10998 <Object>[tokenStream],
10999 tokenStream) as bool;
11000 } 10124 }
11001 10125
11002 /** 10126 /**
11003 * Invoke the method [Parser.isInitializedVariableDeclaration] with the parser set to the 10127 * Invoke the method [Parser.isInitializedVariableDeclaration] with the parser set to the
11004 * token stream produced by scanning the given source. 10128 * token stream produced by scanning the given source.
11005 * 10129 *
11006 * @param source the source to be scanned to produce the token stream being te sted 10130 * @param source the source to be scanned to produce the token stream being te sted
11007 * @return the result of invoking the method 10131 * @return the result of invoking the method
11008 * @throws Exception if the method could not be invoked or throws an exception 10132 * @throws Exception if the method could not be invoked or throws an exception
11009 */ 10133 */
11010 bool _isInitializedVariableDeclaration(String source) { 10134 bool _isInitializedVariableDeclaration(String source) {
11011 GatheringErrorListener listener = new GatheringErrorListener(); 10135 GatheringErrorListener listener = new GatheringErrorListener();
11012 return ParserTestCase.invokeParserMethod2( 10136 return ParserTestCase.invokeParserMethod2(
11013 "isInitializedVariableDeclaration", 10137 "isInitializedVariableDeclaration", source, listener) as bool;
11014 source,
11015 listener) as bool;
11016 } 10138 }
11017 10139
11018 /** 10140 /**
11019 * Invoke the method [Parser.isSwitchMember] with the parser set to the token stream 10141 * Invoke the method [Parser.isSwitchMember] with the parser set to the token stream
11020 * produced by scanning the given source. 10142 * produced by scanning the given source.
11021 * 10143 *
11022 * @param source the source to be scanned to produce the token stream being te sted 10144 * @param source the source to be scanned to produce the token stream being te sted
11023 * @return the result of invoking the method 10145 * @return the result of invoking the method
11024 * @throws Exception if the method could not be invoked or throws an exception 10146 * @throws Exception if the method could not be invoked or throws an exception
11025 */ 10147 */
11026 bool _isSwitchMember(String source) { 10148 bool _isSwitchMember(String source) {
11027 GatheringErrorListener listener = new GatheringErrorListener(); 10149 GatheringErrorListener listener = new GatheringErrorListener();
11028 return ParserTestCase.invokeParserMethod2( 10150 return ParserTestCase.invokeParserMethod2(
11029 "isSwitchMember", 10151 "isSwitchMember", source, listener) as bool;
11030 source,
11031 listener) as bool;
11032 } 10152 }
11033 10153
11034 /** 10154 /**
11035 * Parse the given source as a compilation unit. 10155 * Parse the given source as a compilation unit.
11036 * 10156 *
11037 * @param source the source to be parsed 10157 * @param source the source to be parsed
11038 * @param errorCodes the error codes of the errors that are expected to be fou nd 10158 * @param errorCodes the error codes of the errors that are expected to be fou nd
11039 * @return the compilation unit that was parsed 10159 * @return the compilation unit that was parsed
11040 * @throws Exception if the source could not be parsed, if the compilation err ors in the source do 10160 * @throws Exception if the source could not be parsed, if the compilation err ors in the source do
11041 * not match those that are expected, or if the result would have be en `null` 10161 * not match those that are expected, or if the result would have be en `null`
11042 */ 10162 */
11043 CompilationUnit _parseDirectives(String source, [List<ErrorCode> errorCodes = 10163 CompilationUnit _parseDirectives(String source,
11044 ErrorCode.EMPTY_LIST]) { 10164 [List<ErrorCode> errorCodes = ErrorCode.EMPTY_LIST]) {
11045 GatheringErrorListener listener = new GatheringErrorListener(); 10165 GatheringErrorListener listener = new GatheringErrorListener();
11046 Scanner scanner = 10166 Scanner scanner =
11047 new Scanner(null, new CharSequenceReader(source), listener); 10167 new Scanner(null, new CharSequenceReader(source), listener);
11048 listener.setLineInfo(new TestSource(), scanner.lineStarts); 10168 listener.setLineInfo(new TestSource(), scanner.lineStarts);
11049 Token token = scanner.tokenize(); 10169 Token token = scanner.tokenize();
11050 Parser parser = new Parser(null, listener); 10170 Parser parser = new Parser(null, listener);
11051 CompilationUnit unit = parser.parseDirectives(token); 10171 CompilationUnit unit = parser.parseDirectives(token);
11052 expect(unit, isNotNull); 10172 expect(unit, isNotNull);
11053 expect(unit.declarations, hasLength(0)); 10173 expect(unit.declarations, hasLength(0));
11054 listener.assertErrorsWithCodes(errorCodes); 10174 listener.assertErrorsWithCodes(errorCodes);
(...skipping 16 matching lines...) Expand all
11071 // Scan the source. 10191 // Scan the source.
11072 // 10192 //
11073 Scanner scanner = 10193 Scanner scanner =
11074 new Scanner(null, new CharSequenceReader(source), listener); 10194 new Scanner(null, new CharSequenceReader(source), listener);
11075 Token tokenStream = scanner.tokenize(); 10195 Token tokenStream = scanner.tokenize();
11076 // 10196 //
11077 // Parse the source. 10197 // Parse the source.
11078 // 10198 //
11079 Parser parser = new Parser(null, listener); 10199 Parser parser = new Parser(null, listener);
11080 return invokeParserMethodImpl( 10200 return invokeParserMethodImpl(
11081 parser, 10201 parser, methodName, <Object>[tokenStream], tokenStream) as Token;
11082 methodName,
11083 <Object>[tokenStream],
11084 tokenStream) as Token;
11085 } 10202 }
11086 } 10203 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/generated/non_error_resolver_test.dart ('k') | pkg/analyzer/test/generated/resolver_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698