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

Side by Side Diff: editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/parser/ErrorParserTest.java

Issue 14811004: Improve error recovery when using 'var' as a type (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 7 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 /* 1 /*
2 * Copyright (c) 2012, the Dart project authors. 2 * Copyright (c) 2012, the Dart project authors.
3 * 3 *
4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u se this file except 4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u se this file except
5 * in compliance with the License. You may obtain a copy of the License at 5 * in compliance with the License. You may obtain a copy of the License at
6 * 6 *
7 * http://www.eclipse.org/legal/epl-v10.html 7 * http://www.eclipse.org/legal/epl-v10.html
8 * 8 *
9 * Unless required by applicable law or agreed to in writing, software distribut ed under the License 9 * Unless required by applicable law or agreed to in writing, software distribut ed under the License
10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K IND, either express 10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K IND, either express
(...skipping 25 matching lines...) Expand all
36 "parseListOrMapLiteral", 36 "parseListOrMapLiteral",
37 new Object[] {null}, 37 new Object[] {null},
38 "1", 38 "1",
39 ParserErrorCode.EXPECTED_LIST_OR_MAP_LITERAL); 39 ParserErrorCode.EXPECTED_LIST_OR_MAP_LITERAL);
40 assertTrue(literal.isSynthetic()); 40 assertTrue(literal.isSynthetic());
41 } 41 }
42 42
43 public void fail_illegalAssignmentToNonAssignable_superAssigned() throws Excep tion { 43 public void fail_illegalAssignmentToNonAssignable_superAssigned() throws Excep tion {
44 // TODO(brianwilkerson) When this test starts to pass, remove the test 44 // TODO(brianwilkerson) When this test starts to pass, remove the test
45 // test_illegalAssignmentToNonAssignable_superAssigned. 45 // test_illegalAssignmentToNonAssignable_superAssigned.
46 parse("parseExpression", "super = x;", ParserErrorCode.ILLEGAL_ASSIGNMENT_TO _NON_ASSIGNABLE); 46 parseExpression("super = x;", ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSI GNABLE);
47 } 47 }
48 48
49 public void fail_invalidCommentReference__new_nonIdentifier() throws Exception { 49 public void fail_invalidCommentReference__new_nonIdentifier() throws Exception {
50 // This test fails because the method parseCommentReference returns null. 50 // This test fails because the method parseCommentReference returns null.
51 parse( 51 parse(
52 "parseCommentReference", 52 "parseCommentReference",
53 new Object[] {"new 42", 0}, 53 new Object[] {"new 42", 0},
54 "", 54 "",
55 ParserErrorCode.INVALID_COMMENT_REFERENCE); 55 ParserErrorCode.INVALID_COMMENT_REFERENCE);
56 } 56 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 public void fail_missingExpressionInThrow_withoutCascade() throws Exception { 96 public void fail_missingExpressionInThrow_withoutCascade() throws Exception {
97 parse( 97 parse(
98 "parseThrowExpressionWithoutCascade", 98 "parseThrowExpressionWithoutCascade",
99 "throw;", 99 "throw;",
100 ParserErrorCode.MISSING_EXPRESSION_IN_THROW); 100 ParserErrorCode.MISSING_EXPRESSION_IN_THROW);
101 } 101 }
102 102
103 public void fail_missingFunctionParameters_local_nonVoid_block() throws Except ion { 103 public void fail_missingFunctionParameters_local_nonVoid_block() throws Except ion {
104 // The parser does not recognize this as a function declaration, so it tries to parse it as an 104 // The parser does not recognize this as a function declaration, so it tries to parse it as an
105 // expression statement. It isn't clear what the best error message is in th is case. 105 // expression statement. It isn't clear what the best error message is in th is case.
106 parse("parseStatement", "int f { return x;}", ParserErrorCode.MISSING_FUNCTI ON_PARAMETERS); 106 parseStatement("int f { return x;}", ParserErrorCode.MISSING_FUNCTION_PARAME TERS);
107 } 107 }
108 108
109 public void fail_missingFunctionParameters_local_nonVoid_expression() throws E xception { 109 public void fail_missingFunctionParameters_local_nonVoid_expression() throws E xception {
110 // The parser does not recognize this as a function declaration, so it tries to parse it as an 110 // The parser does not recognize this as a function declaration, so it tries to parse it as an
111 // expression statement. It isn't clear what the best error message is in th is case. 111 // expression statement. It isn't clear what the best error message is in th is case.
112 parse("parseStatement", "int f => x;", ParserErrorCode.MISSING_FUNCTION_PARA METERS); 112 parseStatement("int f => x;", ParserErrorCode.MISSING_FUNCTION_PARAMETERS);
113 } 113 }
114 114
115 public void fail_namedFunctionExpression() throws Exception { 115 public void fail_namedFunctionExpression() throws Exception {
116 Expression expression = parse( 116 Expression expression = parse(
117 "parsePrimaryExpression", 117 "parsePrimaryExpression",
118 "f() {}", 118 "f() {}",
119 ParserErrorCode.NAMED_FUNCTION_EXPRESSION); 119 ParserErrorCode.NAMED_FUNCTION_EXPRESSION);
120 assertInstanceOf(FunctionExpression.class, expression); 120 assertInstanceOf(FunctionExpression.class, expression);
121 } 121 }
122 122
123 public void fail_unexpectedToken_invalidPostfixExpression() throws Exception { 123 public void fail_unexpectedToken_invalidPostfixExpression() throws Exception {
124 // Note: this might not be the right error to produce, but some error should be produced 124 // Note: this might not be the right error to produce, but some error should be produced
125 parse("parseExpression", "f()++", ParserErrorCode.UNEXPECTED_TOKEN); 125 parseExpression("f()++", ParserErrorCode.UNEXPECTED_TOKEN);
126 } 126 }
127 127
128 public void fail_voidVariable_initializer() throws Exception { 128 public void fail_voidVariable_initializer() throws Exception {
129 // The parser parses this as a function declaration statement because that i s the only thing 129 // The parser parses this as a function declaration statement because that i s the only thing
130 // that validly starts with 'void'. That causes a different error message to be produced. 130 // that validly starts with 'void'. That causes a different error message to be produced.
131 parse("parseStatement", "void x = 0;", ParserErrorCode.VOID_VARIABLE); 131 parseStatement("void x = 0;", ParserErrorCode.VOID_VARIABLE);
132 } 132 }
133 133
134 public void fail_voidVariable_noInitializer() throws Exception { 134 public void fail_voidVariable_noInitializer() throws Exception {
135 // The parser parses this as a function declaration statement because that i s the only thing 135 // The parser parses this as a function declaration statement because that i s the only thing
136 // that validly starts with 'void'. That causes a different error message to be produced. 136 // that validly starts with 'void'. That causes a different error message to be produced.
137 parse("parseStatement", "void x;", ParserErrorCode.VOID_VARIABLE); 137 parseStatement("void x;", ParserErrorCode.VOID_VARIABLE);
138 } 138 }
139 139
140 public void test_abstractClassMember_constructor() throws Exception { 140 public void test_abstractClassMember_constructor() throws Exception {
141 parse( 141 parse(
142 "parseClassMember", 142 "parseClassMember",
143 new Object[] {"C"}, 143 new Object[] {"C"},
144 "abstract C.c();", 144 "abstract C.c();",
145 ParserErrorCode.ABSTRACT_CLASS_MEMBER); 145 ParserErrorCode.ABSTRACT_CLASS_MEMBER);
146 } 146 }
147 147
(...skipping 23 matching lines...) Expand all
171 171
172 public void test_abstractClassMember_setter() throws Exception { 172 public void test_abstractClassMember_setter() throws Exception {
173 parse( 173 parse(
174 "parseClassMember", 174 "parseClassMember",
175 new Object[] {"C"}, 175 new Object[] {"C"},
176 "abstract set m(v);", 176 "abstract set m(v);",
177 ParserErrorCode.ABSTRACT_CLASS_MEMBER); 177 ParserErrorCode.ABSTRACT_CLASS_MEMBER);
178 } 178 }
179 179
180 public void test_abstractTopLevelFunction_function() throws Exception { 180 public void test_abstractTopLevelFunction_function() throws Exception {
181 parse("parseCompilationUnit", "abstract f(v) {}", ParserErrorCode.ABSTRACT_T OP_LEVEL_FUNCTION); 181 parseCompilationUnit("abstract f(v) {}", ParserErrorCode.ABSTRACT_TOP_LEVEL_ FUNCTION);
182 } 182 }
183 183
184 public void test_abstractTopLevelFunction_getter() throws Exception { 184 public void test_abstractTopLevelFunction_getter() throws Exception {
185 parse("parseCompilationUnit", "abstract get m {}", ParserErrorCode.ABSTRACT_ TOP_LEVEL_FUNCTION); 185 parseCompilationUnit("abstract get m {}", ParserErrorCode.ABSTRACT_TOP_LEVEL _FUNCTION);
186 } 186 }
187 187
188 public void test_abstractTopLevelFunction_setter() throws Exception { 188 public void test_abstractTopLevelFunction_setter() throws Exception {
189 parse( 189 parseCompilationUnit("abstract set m(v) {}", ParserErrorCode.ABSTRACT_TOP_LE VEL_FUNCTION);
190 "parseCompilationUnit",
191 "abstract set m(v) {}",
192 ParserErrorCode.ABSTRACT_TOP_LEVEL_FUNCTION);
193 } 190 }
194 191
195 public void test_abstractTopLevelVariable() throws Exception { 192 public void test_abstractTopLevelVariable() throws Exception {
196 parse("parseCompilationUnit", "abstract C f;", ParserErrorCode.ABSTRACT_TOP_ LEVEL_VARIABLE); 193 parseCompilationUnit("abstract C f;", ParserErrorCode.ABSTRACT_TOP_LEVEL_VAR IABLE);
197 } 194 }
198 195
199 public void test_abstractTypeDef() throws Exception { 196 public void test_abstractTypeDef() throws Exception {
200 parse("parseCompilationUnit", "abstract typedef F();", ParserErrorCode.ABSTR ACT_TYPEDEF); 197 parseCompilationUnit("abstract typedef F();", ParserErrorCode.ABSTRACT_TYPED EF);
201 } 198 }
202 199
203 public void test_breakOutsideOfLoop_breakInDoStatement() throws Exception { 200 public void test_breakOutsideOfLoop_breakInDoStatement() throws Exception {
204 parse("parseDoStatement", "do {break;} while (x);"); 201 parse("parseDoStatement", "do {break;} while (x);");
205 } 202 }
206 203
207 public void test_breakOutsideOfLoop_breakInForStatement() throws Exception { 204 public void test_breakOutsideOfLoop_breakInForStatement() throws Exception {
208 parse("parseForStatement", "for (; x;) {break;}"); 205 parse("parseForStatement", "for (; x;) {break;}");
209 } 206 }
210 207
211 public void test_breakOutsideOfLoop_breakInIfStatement() throws Exception { 208 public void test_breakOutsideOfLoop_breakInIfStatement() throws Exception {
212 parse("parseIfStatement", "if (x) {break;}", ParserErrorCode.BREAK_OUTSIDE_O F_LOOP); 209 parse("parseIfStatement", "if (x) {break;}", ParserErrorCode.BREAK_OUTSIDE_O F_LOOP);
213 } 210 }
214 211
215 public void test_breakOutsideOfLoop_breakInSwitchStatement() throws Exception { 212 public void test_breakOutsideOfLoop_breakInSwitchStatement() throws Exception {
216 parse("parseSwitchStatement", "switch (x) {case 1: break;}"); 213 parse("parseSwitchStatement", "switch (x) {case 1: break;}");
217 } 214 }
218 215
219 public void test_breakOutsideOfLoop_breakInWhileStatement() throws Exception { 216 public void test_breakOutsideOfLoop_breakInWhileStatement() throws Exception {
220 parse("parseWhileStatement", "while (x) {break;}"); 217 parse("parseWhileStatement", "while (x) {break;}");
221 } 218 }
222 219
223 public void test_breakOutsideOfLoop_functionExpression_inALoop() throws Except ion { 220 public void test_breakOutsideOfLoop_functionExpression_inALoop() throws Except ion {
224 parse("parseStatement", "for(; x;) {() {break;};}", ParserErrorCode.BREAK_OU TSIDE_OF_LOOP); 221 parseStatement("for(; x;) {() {break;};}", ParserErrorCode.BREAK_OUTSIDE_OF_ LOOP);
225 } 222 }
226 223
227 public void test_breakOutsideOfLoop_functionExpression_withALoop() throws Exce ption { 224 public void test_breakOutsideOfLoop_functionExpression_withALoop() throws Exce ption {
228 parse("parseStatement", "() {for (; x;) {break;}};"); 225 parseStatement("() {for (; x;) {break;}};");
229 } 226 }
230 227
231 public void test_constAndFinal() throws Exception { 228 public void test_constAndFinal() throws Exception {
232 parse( 229 parse(
233 "parseClassMember", 230 "parseClassMember",
234 new Object[] {"C"}, 231 new Object[] {"C"},
235 "const final int x;", 232 "const final int x;",
236 ParserErrorCode.CONST_AND_FINAL); 233 ParserErrorCode.CONST_AND_FINAL);
237 } 234 }
238 235
239 public void test_constAndVar() throws Exception { 236 public void test_constAndVar() throws Exception {
240 parse("parseClassMember", new Object[] {"C"}, "const var x;", ParserErrorCod e.CONST_AND_VAR); 237 parse("parseClassMember", new Object[] {"C"}, "const var x;", ParserErrorCod e.CONST_AND_VAR);
241 } 238 }
242 239
243 public void test_constClass() throws Exception { 240 public void test_constClass() throws Exception {
244 parse("parseCompilationUnit", "const class C {}", ParserErrorCode.CONST_CLAS S); 241 parseCompilationUnit("const class C {}", ParserErrorCode.CONST_CLASS);
245 } 242 }
246 243
247 public void test_constMethod() throws Exception { 244 public void test_constMethod() throws Exception {
248 parse("parseClassMember", new Object[] {"C"}, "const int m() {}", ParserErro rCode.CONST_METHOD); 245 parse("parseClassMember", new Object[] {"C"}, "const int m() {}", ParserErro rCode.CONST_METHOD);
249 } 246 }
250 247
251 public void test_constTypedef() throws Exception { 248 public void test_constTypedef() throws Exception {
252 parse("parseCompilationUnit", "const typedef F();", ParserErrorCode.CONST_TY PEDEF); 249 parseCompilationUnit("const typedef F();", ParserErrorCode.CONST_TYPEDEF);
253 } 250 }
254 251
255 public void test_continueOutsideOfLoop_continueInDoStatement() throws Exceptio n { 252 public void test_continueOutsideOfLoop_continueInDoStatement() throws Exceptio n {
256 parse("parseDoStatement", "do {continue;} while (x);"); 253 parse("parseDoStatement", "do {continue;} while (x);");
257 } 254 }
258 255
259 public void test_continueOutsideOfLoop_continueInForStatement() throws Excepti on { 256 public void test_continueOutsideOfLoop_continueInForStatement() throws Excepti on {
260 parse("parseForStatement", "for (; x;) {continue;}"); 257 parse("parseForStatement", "for (; x;) {continue;}");
261 } 258 }
262 259
263 public void test_continueOutsideOfLoop_continueInIfStatement() throws Exceptio n { 260 public void test_continueOutsideOfLoop_continueInIfStatement() throws Exceptio n {
264 parse("parseIfStatement", "if (x) {continue;}", ParserErrorCode.CONTINUE_OUT SIDE_OF_LOOP); 261 parse("parseIfStatement", "if (x) {continue;}", ParserErrorCode.CONTINUE_OUT SIDE_OF_LOOP);
265 } 262 }
266 263
267 public void test_continueOutsideOfLoop_continueInSwitchStatement() throws Exce ption { 264 public void test_continueOutsideOfLoop_continueInSwitchStatement() throws Exce ption {
268 parse("parseSwitchStatement", "switch (x) {case 1: continue a;}"); 265 parse("parseSwitchStatement", "switch (x) {case 1: continue a;}");
269 } 266 }
270 267
271 public void test_continueOutsideOfLoop_continueInWhileStatement() throws Excep tion { 268 public void test_continueOutsideOfLoop_continueInWhileStatement() throws Excep tion {
272 parse("parseWhileStatement", "while (x) {continue;}"); 269 parse("parseWhileStatement", "while (x) {continue;}");
273 } 270 }
274 271
275 public void test_continueOutsideOfLoop_functionExpression_inALoop() throws Exc eption { 272 public void test_continueOutsideOfLoop_functionExpression_inALoop() throws Exc eption {
276 parse("parseStatement", "for(; x;) {() {continue;};}", ParserErrorCode.CONTI NUE_OUTSIDE_OF_LOOP); 273 parseStatement("for(; x;) {() {continue;};}", ParserErrorCode.CONTINUE_OUTSI DE_OF_LOOP);
277 } 274 }
278 275
279 public void test_continueOutsideOfLoop_functionExpression_withALoop() throws E xception { 276 public void test_continueOutsideOfLoop_functionExpression_withALoop() throws E xception {
280 parse("parseStatement", "() {for (; x;) {continue;}};"); 277 parseStatement("() {for (; x;) {continue;}};");
281 } 278 }
282 279
283 public void test_continueWithoutLabelInCase_error() throws Exception { 280 public void test_continueWithoutLabelInCase_error() throws Exception {
284 parse( 281 parse(
285 "parseSwitchStatement", 282 "parseSwitchStatement",
286 "switch (x) {case 1: continue;}", 283 "switch (x) {case 1: continue;}",
287 ParserErrorCode.CONTINUE_WITHOUT_LABEL_IN_CASE); 284 ParserErrorCode.CONTINUE_WITHOUT_LABEL_IN_CASE);
288 } 285 }
289 286
290 public void test_continueWithoutLabelInCase_noError() throws Exception { 287 public void test_continueWithoutLabelInCase_noError() throws Exception {
291 parse("parseSwitchStatement", "switch (x) {case 1: continue a;}"); 288 parse("parseSwitchStatement", "switch (x) {case 1: continue a;}");
292 } 289 }
293 290
294 public void test_continueWithoutLabelInCase_noError_switchInLoop() throws Exce ption { 291 public void test_continueWithoutLabelInCase_noError_switchInLoop() throws Exce ption {
295 parse("parseWhileStatement", "while (a) { switch (b) {default: continue;}}") ; 292 parse("parseWhileStatement", "while (a) { switch (b) {default: continue;}}") ;
296 } 293 }
297 294
298 public void test_directiveAfterDeclaration_classBeforeDirective() throws Excep tion { 295 public void test_directiveAfterDeclaration_classBeforeDirective() throws Excep tion {
299 CompilationUnit unit = parse( 296 CompilationUnit unit = parseCompilationUnit(
300 "parseCompilationUnit",
301 "class Foo{} library l;", 297 "class Foo{} library l;",
302 ParserErrorCode.DIRECTIVE_AFTER_DECLARATION); 298 ParserErrorCode.DIRECTIVE_AFTER_DECLARATION);
303 assertNotNull(unit); 299 assertNotNull(unit);
304 } 300 }
305 301
306 public void test_directiveAfterDeclaration_classBetweenDirectives() throws Exc eption { 302 public void test_directiveAfterDeclaration_classBetweenDirectives() throws Exc eption {
307 CompilationUnit unit = parse( 303 CompilationUnit unit = parseCompilationUnit(
308 "parseCompilationUnit",
309 "library l;\nclass Foo{}\npart 'a.dart';", 304 "library l;\nclass Foo{}\npart 'a.dart';",
310 ParserErrorCode.DIRECTIVE_AFTER_DECLARATION); 305 ParserErrorCode.DIRECTIVE_AFTER_DECLARATION);
311 assertNotNull(unit); 306 assertNotNull(unit);
312 } 307 }
313 308
314 public void test_duplicatedModifier_const() throws Exception { 309 public void test_duplicatedModifier_const() throws Exception {
315 parse( 310 parse(
316 "parseClassMember", 311 "parseClassMember",
317 new Object[] {"C"}, 312 new Object[] {"C"},
318 "const const m;", 313 "const const m;",
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 "1", 411 "1",
417 ParserErrorCode.EXPECTED_STRING_LITERAL); 412 ParserErrorCode.EXPECTED_STRING_LITERAL);
418 assertTrue(expression.isSynthetic()); 413 assertTrue(expression.isSynthetic());
419 } 414 }
420 415
421 public void test_expectedToken_commaMissingInArgumentList() throws Exception { 416 public void test_expectedToken_commaMissingInArgumentList() throws Exception {
422 parse("parseArgumentList", "(x, y z)", ParserErrorCode.EXPECTED_TOKEN); 417 parse("parseArgumentList", "(x, y z)", ParserErrorCode.EXPECTED_TOKEN);
423 } 418 }
424 419
425 public void test_expectedToken_semicolonMissingAfterExpression() throws Except ion { 420 public void test_expectedToken_semicolonMissingAfterExpression() throws Except ion {
426 parse("parseStatement", "x", ParserErrorCode.EXPECTED_TOKEN); 421 parseStatement("x", ParserErrorCode.EXPECTED_TOKEN);
427 } 422 }
428 423
429 public void test_expectedToken_whileMissingInDoStatement() throws Exception { 424 public void test_expectedToken_whileMissingInDoStatement() throws Exception {
430 parse("parseStatement", "do {} (x);", ParserErrorCode.EXPECTED_TOKEN); 425 parseStatement("do {} (x);", ParserErrorCode.EXPECTED_TOKEN);
426 }
427
428 public void test_expectedTypeName_is() throws Exception {
429 parseExpression("x is", ParserErrorCode.EXPECTED_TYPE_NAME);
431 } 430 }
432 431
433 public void test_exportDirectiveAfterPartDirective() throws Exception { 432 public void test_exportDirectiveAfterPartDirective() throws Exception {
434 parse( 433 parseCompilationUnit(
435 "parseCompilationUnit",
436 "part 'a.dart'; export 'b.dart';", 434 "part 'a.dart'; export 'b.dart';",
437 ParserErrorCode.EXPORT_DIRECTIVE_AFTER_PART_DIRECTIVE); 435 ParserErrorCode.EXPORT_DIRECTIVE_AFTER_PART_DIRECTIVE);
438 } 436 }
439 437
440 public void test_externalAfterConst() throws Exception { 438 public void test_externalAfterConst() throws Exception {
441 parse( 439 parse(
442 "parseClassMember", 440 "parseClassMember",
443 new Object[] {"C"}, 441 new Object[] {"C"},
444 "const external C();", 442 "const external C();",
445 ParserErrorCode.EXTERNAL_AFTER_CONST); 443 ParserErrorCode.EXTERNAL_AFTER_CONST);
446 } 444 }
447 445
448 public void test_externalAfterFactory() throws Exception { 446 public void test_externalAfterFactory() throws Exception {
449 parse( 447 parse(
450 "parseClassMember", 448 "parseClassMember",
451 new Object[] {"C"}, 449 new Object[] {"C"},
452 "factory external C();", 450 "factory external C();",
453 ParserErrorCode.EXTERNAL_AFTER_FACTORY); 451 ParserErrorCode.EXTERNAL_AFTER_FACTORY);
454 } 452 }
455 453
456 public void test_externalAfterStatic() throws Exception { 454 public void test_externalAfterStatic() throws Exception {
457 parse( 455 parse(
458 "parseClassMember", 456 "parseClassMember",
459 new Object[] {"C"}, 457 new Object[] {"C"},
460 "static external int m();", 458 "static external int m();",
461 ParserErrorCode.EXTERNAL_AFTER_STATIC); 459 ParserErrorCode.EXTERNAL_AFTER_STATIC);
462 } 460 }
463 461
464 public void test_externalClass() throws Exception { 462 public void test_externalClass() throws Exception {
465 parse("parseCompilationUnit", "external class C {}", ParserErrorCode.EXTERNA L_CLASS); 463 parseCompilationUnit("external class C {}", ParserErrorCode.EXTERNAL_CLASS);
466 } 464 }
467 465
468 public void test_externalConstructorWithBody_factory() throws Exception { 466 public void test_externalConstructorWithBody_factory() throws Exception {
469 parse( 467 parse(
470 "parseClassMember", 468 "parseClassMember",
471 new Object[] {"C"}, 469 new Object[] {"C"},
472 "external factory C() {}", 470 "external factory C() {}",
473 ParserErrorCode.EXTERNAL_CONSTRUCTOR_WITH_BODY); 471 ParserErrorCode.EXTERNAL_CONSTRUCTOR_WITH_BODY);
474 } 472 }
475 473
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 537
540 public void test_externalSetterWithBody() throws Exception { 538 public void test_externalSetterWithBody() throws Exception {
541 parse( 539 parse(
542 "parseClassMember", 540 "parseClassMember",
543 new Object[] {"C"}, 541 new Object[] {"C"},
544 "external set x(int value) {}", 542 "external set x(int value) {}",
545 ParserErrorCode.EXTERNAL_SETTER_WITH_BODY); 543 ParserErrorCode.EXTERNAL_SETTER_WITH_BODY);
546 } 544 }
547 545
548 public void test_externalTypedef() throws Exception { 546 public void test_externalTypedef() throws Exception {
549 parse("parseCompilationUnit", "external typedef F();", ParserErrorCode.EXTER NAL_TYPEDEF); 547 parseCompilationUnit("external typedef F();", ParserErrorCode.EXTERNAL_TYPED EF);
550 } 548 }
551 549
552 public void test_factoryTopLevelDeclaration_class() throws Exception { 550 public void test_factoryTopLevelDeclaration_class() throws Exception {
553 parse( 551 parseCompilationUnit("factory class C {}", ParserErrorCode.FACTORY_TOP_LEVEL _DECLARATION);
554 "parseCompilationUnit",
555 "factory class C {}",
556 ParserErrorCode.FACTORY_TOP_LEVEL_DECLARATION);
557 } 552 }
558 553
559 public void test_factoryTopLevelDeclaration_typedef() throws Exception { 554 public void test_factoryTopLevelDeclaration_typedef() throws Exception {
560 parse( 555 parseCompilationUnit("factory typedef F();", ParserErrorCode.FACTORY_TOP_LEV EL_DECLARATION);
561 "parseCompilationUnit",
562 "factory typedef F();",
563 ParserErrorCode.FACTORY_TOP_LEVEL_DECLARATION);
564 } 556 }
565 557
566 public void test_fieldInitializerOutsideConstructor() throws Exception { 558 public void test_fieldInitializerOutsideConstructor() throws Exception {
567 parse( 559 parse(
568 "parseClassMember", 560 "parseClassMember",
569 new Object[] {"C"}, 561 new Object[] {"C"},
570 "void m(this.x);", 562 "void m(this.x);",
571 ParserErrorCode.FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR); 563 ParserErrorCode.FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR);
572 } 564 }
573 565
574 public void test_finalAndVar() throws Exception { 566 public void test_finalAndVar() throws Exception {
575 parse("parseClassMember", new Object[] {"C"}, "final var x;", ParserErrorCod e.FINAL_AND_VAR); 567 parse("parseClassMember", new Object[] {"C"}, "final var x;", ParserErrorCod e.FINAL_AND_VAR);
576 } 568 }
577 569
578 public void test_finalClass() throws Exception { 570 public void test_finalClass() throws Exception {
579 parse("parseCompilationUnit", "final class C {}", ParserErrorCode.FINAL_CLAS S); 571 parseCompilationUnit("final class C {}", ParserErrorCode.FINAL_CLASS);
580 } 572 }
581 573
582 public void test_finalConstructor() throws Exception { 574 public void test_finalConstructor() throws Exception {
583 parse("parseClassMember", new Object[] {"C"}, "final C() {}", ParserErrorCod e.FINAL_CONSTRUCTOR); 575 parse("parseClassMember", new Object[] {"C"}, "final C() {}", ParserErrorCod e.FINAL_CONSTRUCTOR);
584 } 576 }
585 577
586 public void test_finalMethod() throws Exception { 578 public void test_finalMethod() throws Exception {
587 parse("parseClassMember", new Object[] {"C"}, "final int m() {}", ParserErro rCode.FINAL_METHOD); 579 parse("parseClassMember", new Object[] {"C"}, "final int m() {}", ParserErro rCode.FINAL_METHOD);
588 } 580 }
589 581
590 public void test_finalTypedef() throws Exception { 582 public void test_finalTypedef() throws Exception {
591 parse("parseCompilationUnit", "final typedef F();", ParserErrorCode.FINAL_TY PEDEF); 583 parseCompilationUnit("final typedef F();", ParserErrorCode.FINAL_TYPEDEF);
592 } 584 }
593 585
594 public void test_getterWithParameters() throws Exception { 586 public void test_getterWithParameters() throws Exception {
595 parse( 587 parse(
596 "parseClassMember", 588 "parseClassMember",
597 new Object[] {"C"}, 589 new Object[] {"C"},
598 "int get x() {}", 590 "int get x() {}",
599 ParserErrorCode.GETTER_WITH_PARAMETERS); 591 ParserErrorCode.GETTER_WITH_PARAMETERS);
600 } 592 }
601 593
602 public void test_illegalAssignmentToNonAssignable_superAssigned() throws Excep tion { 594 public void test_illegalAssignmentToNonAssignable_superAssigned() throws Excep tion {
603 // TODO(brianwilkerson) When the test fail_illegalAssignmentToNonAssignable_ superAssigned starts 595 // TODO(brianwilkerson) When the test fail_illegalAssignmentToNonAssignable_ superAssigned starts
604 // to pass, remove this test (there should only be one error generated, but we're keeping this 596 // to pass, remove this test (there should only be one error generated, but we're keeping this
605 // test until that time so that we can catch other forms of regressions). 597 // test until that time so that we can catch other forms of regressions).
606 parse( 598 parseExpression(
607 "parseExpression",
608 "super = x;", 599 "super = x;",
609 ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR, 600 ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR,
610 ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE); 601 ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE);
611 } 602 }
612 603
613 public void test_implementsBeforeExtends() throws Exception { 604 public void test_implementsBeforeExtends() throws Exception {
614 parse( 605 parseCompilationUnit(
615 "parseCompilationUnit",
616 "class A implements B extends C {}", 606 "class A implements B extends C {}",
617 ParserErrorCode.IMPLEMENTS_BEFORE_EXTENDS); 607 ParserErrorCode.IMPLEMENTS_BEFORE_EXTENDS);
618 } 608 }
619 609
620 public void test_implementsBeforeWith() throws Exception { 610 public void test_implementsBeforeWith() throws Exception {
621 parse( 611 parseCompilationUnit(
622 "parseCompilationUnit",
623 "class A extends B implements C with D {}", 612 "class A extends B implements C with D {}",
624 ParserErrorCode.IMPLEMENTS_BEFORE_WITH); 613 ParserErrorCode.IMPLEMENTS_BEFORE_WITH);
625 } 614 }
626 615
627 public void test_importDirectiveAfterPartDirective() throws Exception { 616 public void test_importDirectiveAfterPartDirective() throws Exception {
628 parse( 617 parseCompilationUnit(
629 "parseCompilationUnit",
630 "part 'a.dart'; import 'b.dart';", 618 "part 'a.dart'; import 'b.dart';",
631 ParserErrorCode.IMPORT_DIRECTIVE_AFTER_PART_DIRECTIVE); 619 ParserErrorCode.IMPORT_DIRECTIVE_AFTER_PART_DIRECTIVE);
632 } 620 }
633 621
634 public void test_initializedVariableInForEach() throws Exception { 622 public void test_initializedVariableInForEach() throws Exception {
635 parse( 623 parse(
636 "parseForStatement", 624 "parseForStatement",
637 "for (int a = 0 in foo) {}", 625 "for (int a = 0 in foo) {}",
638 ParserErrorCode.INITIALIZED_VARIABLE_IN_FOR_EACH); 626 ParserErrorCode.INITIALIZED_VARIABLE_IN_FOR_EACH);
639 } 627 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 672
685 public void test_invalidUnicodeEscape_tooManyDigits_variable() throws Exceptio n { 673 public void test_invalidUnicodeEscape_tooManyDigits_variable() throws Exceptio n {
686 parse( 674 parse(
687 "parseStringLiteral", 675 "parseStringLiteral",
688 "'\\u{12345678}'", 676 "'\\u{12345678}'",
689 ParserErrorCode.INVALID_UNICODE_ESCAPE, 677 ParserErrorCode.INVALID_UNICODE_ESCAPE,
690 ParserErrorCode.INVALID_CODE_POINT); 678 ParserErrorCode.INVALID_CODE_POINT);
691 } 679 }
692 680
693 public void test_libraryDirectiveNotFirst() throws Exception { 681 public void test_libraryDirectiveNotFirst() throws Exception {
694 parse( 682 parseCompilationUnit("import 'x.dart'; library l;", ParserErrorCode.LIBRARY_ DIRECTIVE_NOT_FIRST);
695 "parseCompilationUnit",
696 "import 'x.dart'; library l;",
697 ParserErrorCode.LIBRARY_DIRECTIVE_NOT_FIRST);
698 } 683 }
699 684
700 public void test_libraryDirectiveNotFirst_afterPart() throws Exception { 685 public void test_libraryDirectiveNotFirst_afterPart() throws Exception {
701 CompilationUnit unit = parse( 686 CompilationUnit unit = parseCompilationUnit(
702 "parseCompilationUnit",
703 "part 'a.dart';\nlibrary l;", 687 "part 'a.dart';\nlibrary l;",
704 ParserErrorCode.LIBRARY_DIRECTIVE_NOT_FIRST); 688 ParserErrorCode.LIBRARY_DIRECTIVE_NOT_FIRST);
705 assertNotNull(unit); 689 assertNotNull(unit);
706 } 690 }
707 691
708 public void test_missingAssignableSelector_identifiersAssigned() throws Except ion { 692 public void test_missingAssignableSelector_identifiersAssigned() throws Except ion {
709 parse("parseExpression", "x.y = y;"); 693 parseExpression("x.y = y;");
710 } 694 }
711 695
712 public void test_missingAssignableSelector_primarySelectorPostfix() throws Exc eption { 696 public void test_missingAssignableSelector_primarySelectorPostfix() throws Exc eption {
713 parse("parseExpression", "x(y)(z)++", ParserErrorCode.MISSING_ASSIGNABLE_SEL ECTOR); 697 parseExpression("x(y)(z)++", ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR);
714 } 698 }
715 699
716 public void test_missingAssignableSelector_selector() throws Exception { 700 public void test_missingAssignableSelector_selector() throws Exception {
717 parse("parseExpression", "x(y)(z).a++"); 701 parseExpression("x(y)(z).a++");
718 } 702 }
719 703
720 public void test_missingAssignableSelector_superPrimaryExpression() throws Exc eption { 704 public void test_missingAssignableSelector_superPrimaryExpression() throws Exc eption {
721 SuperExpression expression = parse( 705 SuperExpression expression = parse(
722 "parsePrimaryExpression", 706 "parsePrimaryExpression",
723 "super", 707 "super",
724 ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR); 708 ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR);
725 assertNotNull(expression.getKeyword()); 709 assertNotNull(expression.getKeyword());
726 } 710 }
727 711
728 public void test_missingAssignableSelector_superPropertyAccessAssigned() throw s Exception { 712 public void test_missingAssignableSelector_superPropertyAccessAssigned() throw s Exception {
729 parse("parseExpression", "super.x = x;"); 713 parseExpression("super.x = x;");
730 } 714 }
731 715
732 public void test_missingCatchOrFinally() throws Exception { 716 public void test_missingCatchOrFinally() throws Exception {
733 TryStatement statement = parse( 717 TryStatement statement = parse(
734 "parseTryStatement", 718 "parseTryStatement",
735 "try {}", 719 "try {}",
736 ParserErrorCode.MISSING_CATCH_OR_FINALLY); 720 ParserErrorCode.MISSING_CATCH_OR_FINALLY);
737 assertNotNull(statement); 721 assertNotNull(statement);
738 } 722 }
739 723
740 public void test_missingClassBody() throws Exception { 724 public void test_missingClassBody() throws Exception {
741 parse("parseCompilationUnit", "class A class B {}", ParserErrorCode.MISSING_ CLASS_BODY); 725 parseCompilationUnit("class A class B {}", ParserErrorCode.MISSING_CLASS_BOD Y);
742 } 726 }
743 727
744 public void test_missingConstFinalVarOrType() throws Exception { 728 public void test_missingConstFinalVarOrType() throws Exception {
745 parse( 729 parse(
746 "parseFinalConstVarOrType", 730 "parseFinalConstVarOrType",
747 new Object[] {false}, 731 new Object[] {false},
748 "a;", 732 "a;",
749 ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE); 733 ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE);
750 } 734 }
751 735
752 public void test_missingFunctionBody_emptyNotAllowed() throws Exception { 736 public void test_missingFunctionBody_emptyNotAllowed() throws Exception {
753 parse( 737 parse(
754 "parseFunctionBody", 738 "parseFunctionBody",
755 new Object[] {false, false}, 739 new Object[] {false, false},
756 ";", 740 ";",
757 ParserErrorCode.MISSING_FUNCTION_BODY); 741 ParserErrorCode.MISSING_FUNCTION_BODY);
758 } 742 }
759 743
760 public void test_missingFunctionBody_invalid() throws Exception { 744 public void test_missingFunctionBody_invalid() throws Exception {
761 parse( 745 parse(
762 "parseFunctionBody", 746 "parseFunctionBody",
763 new Object[] {false, false}, 747 new Object[] {false, false},
764 "return 0;", 748 "return 0;",
765 ParserErrorCode.MISSING_FUNCTION_BODY); 749 ParserErrorCode.MISSING_FUNCTION_BODY);
766 } 750 }
767 751
768 public void test_missingFunctionParameters_local_void_block() throws Exception { 752 public void test_missingFunctionParameters_local_void_block() throws Exception {
769 parse("parseStatement", "void f { return x;}", ParserErrorCode.MISSING_FUNCT ION_PARAMETERS); 753 parseStatement("void f { return x;}", ParserErrorCode.MISSING_FUNCTION_PARAM ETERS);
770 } 754 }
771 755
772 public void test_missingFunctionParameters_local_void_expression() throws Exce ption { 756 public void test_missingFunctionParameters_local_void_expression() throws Exce ption {
773 parse("parseStatement", "void f => x;", ParserErrorCode.MISSING_FUNCTION_PAR AMETERS); 757 parseStatement("void f => x;", ParserErrorCode.MISSING_FUNCTION_PARAMETERS);
774 } 758 }
775 759
776 public void test_missingFunctionParameters_topLevel_nonVoid_block() throws Exc eption { 760 public void test_missingFunctionParameters_topLevel_nonVoid_block() throws Exc eption {
777 parse("parseCompilationUnit", "int f { return x;}", ParserErrorCode.MISSING_ FUNCTION_PARAMETERS); 761 parseCompilationUnit("int f { return x;}", ParserErrorCode.MISSING_FUNCTION_ PARAMETERS);
778 } 762 }
779 763
780 public void test_missingFunctionParameters_topLevel_nonVoid_expression() throw s Exception { 764 public void test_missingFunctionParameters_topLevel_nonVoid_expression() throw s Exception {
781 parse("parseCompilationUnit", "int f => x;", ParserErrorCode.MISSING_FUNCTIO N_PARAMETERS); 765 parseCompilationUnit("int f => x;", ParserErrorCode.MISSING_FUNCTION_PARAMET ERS);
782 } 766 }
783 767
784 public void test_missingFunctionParameters_topLevel_void_block() throws Except ion { 768 public void test_missingFunctionParameters_topLevel_void_block() throws Except ion {
785 parse( 769 parseCompilationUnit("void f { return x;}", ParserErrorCode.MISSING_FUNCTION _PARAMETERS);
786 "parseCompilationUnit",
787 "void f { return x;}",
788 ParserErrorCode.MISSING_FUNCTION_PARAMETERS);
789 } 770 }
790 771
791 public void test_missingFunctionParameters_topLevel_void_expression() throws E xception { 772 public void test_missingFunctionParameters_topLevel_void_expression() throws E xception {
792 parse("parseCompilationUnit", "void f => x;", ParserErrorCode.MISSING_FUNCTI ON_PARAMETERS); 773 parseCompilationUnit("void f => x;", ParserErrorCode.MISSING_FUNCTION_PARAME TERS);
793 } 774 }
794 775
795 public void test_missingIdentifier_functionDeclaration_returnTypeWithoutName() throws Exception { 776 public void test_missingIdentifier_functionDeclaration_returnTypeWithoutName() throws Exception {
796 parse("parseFunctionDeclarationStatement", "A<T> () {}", ParserErrorCode.MIS SING_IDENTIFIER); 777 parse("parseFunctionDeclarationStatement", "A<T> () {}", ParserErrorCode.MIS SING_IDENTIFIER);
797 } 778 }
798 779
799 public void test_missingIdentifier_number() throws Exception { 780 public void test_missingIdentifier_number() throws Exception {
800 SimpleIdentifier expression = parse( 781 SimpleIdentifier expression = parse(
801 "parseSimpleIdentifier", 782 "parseSimpleIdentifier",
802 "1", 783 "1",
803 ParserErrorCode.MISSING_IDENTIFIER); 784 ParserErrorCode.MISSING_IDENTIFIER);
804 assertTrue(expression.isSynthetic()); 785 assertTrue(expression.isSynthetic());
805 } 786 }
806 787
807 public void test_missingKeywordOperator() throws Exception { 788 public void test_missingKeywordOperator() throws Exception {
808 parse( 789 parse(
809 "parseOperator", 790 "parseOperator",
810 new Object[] {emptyCommentAndMetadata(), null, null}, 791 new Object[] {emptyCommentAndMetadata(), null, null},
811 "+(x) {}", 792 "+(x) {}",
812 ParserErrorCode.MISSING_KEYWORD_OPERATOR); 793 ParserErrorCode.MISSING_KEYWORD_OPERATOR);
813 } 794 }
814 795
815 public void test_missingNameInLibraryDirective() throws Exception { 796 public void test_missingNameInLibraryDirective() throws Exception {
816 CompilationUnit unit = parse( 797 CompilationUnit unit = parseCompilationUnit(
817 "parseCompilationUnit",
818 "library;", 798 "library;",
819 ParserErrorCode.MISSING_NAME_IN_LIBRARY_DIRECTIVE); 799 ParserErrorCode.MISSING_NAME_IN_LIBRARY_DIRECTIVE);
820 assertNotNull(unit); 800 assertNotNull(unit);
821 } 801 }
822 802
823 public void test_missingNameInPartOfDirective() throws Exception { 803 public void test_missingNameInPartOfDirective() throws Exception {
824 CompilationUnit unit = parse( 804 CompilationUnit unit = parseCompilationUnit(
825 "parseCompilationUnit",
826 "part of;", 805 "part of;",
827 ParserErrorCode.MISSING_NAME_IN_PART_OF_DIRECTIVE); 806 ParserErrorCode.MISSING_NAME_IN_PART_OF_DIRECTIVE);
828 assertNotNull(unit); 807 assertNotNull(unit);
829 } 808 }
830 809
831 public void test_missingTerminatorForParameterGroup_named() throws Exception { 810 public void test_missingTerminatorForParameterGroup_named() throws Exception {
832 parse( 811 parse(
833 "parseFormalParameterList", 812 "parseFormalParameterList",
834 "(a, {b: 0)", 813 "(a, {b: 0)",
835 ParserErrorCode.MISSING_TERMINATOR_FOR_PARAMETER_GROUP); 814 ParserErrorCode.MISSING_TERMINATOR_FOR_PARAMETER_GROUP);
836 } 815 }
837 816
838 public void test_missingTerminatorForParameterGroup_optional() throws Exceptio n { 817 public void test_missingTerminatorForParameterGroup_optional() throws Exceptio n {
839 parse( 818 parse(
840 "parseFormalParameterList", 819 "parseFormalParameterList",
841 "(a, [b = 0)", 820 "(a, [b = 0)",
842 ParserErrorCode.MISSING_TERMINATOR_FOR_PARAMETER_GROUP); 821 ParserErrorCode.MISSING_TERMINATOR_FOR_PARAMETER_GROUP);
843 } 822 }
844 823
845 public void test_missingTypedefParameters_nonVoid() throws Exception { 824 public void test_missingTypedefParameters_nonVoid() throws Exception {
846 parse("parseCompilationUnit", "typedef int F;", ParserErrorCode.MISSING_TYPE DEF_PARAMETERS); 825 parseCompilationUnit("typedef int F;", ParserErrorCode.MISSING_TYPEDEF_PARAM ETERS);
847 } 826 }
848 827
849 public void test_missingTypedefParameters_typeParameters() throws Exception { 828 public void test_missingTypedefParameters_typeParameters() throws Exception {
850 parse("parseCompilationUnit", "typedef F<E>;", ParserErrorCode.MISSING_TYPED EF_PARAMETERS); 829 parseCompilationUnit("typedef F<E>;", ParserErrorCode.MISSING_TYPEDEF_PARAME TERS);
851 } 830 }
852 831
853 public void test_missingTypedefParameters_void() throws Exception { 832 public void test_missingTypedefParameters_void() throws Exception {
854 parse("parseCompilationUnit", "typedef void F;", ParserErrorCode.MISSING_TYP EDEF_PARAMETERS); 833 parseCompilationUnit("typedef void F;", ParserErrorCode.MISSING_TYPEDEF_PARA METERS);
855 } 834 }
856 835
857 public void test_missingVariableInForEach() throws Exception { 836 public void test_missingVariableInForEach() throws Exception {
858 parse( 837 parse(
859 "parseForStatement", 838 "parseForStatement",
860 "for (a < b in foo) {}", 839 "for (a < b in foo) {}",
861 ParserErrorCode.MISSING_VARIABLE_IN_FOR_EACH); 840 ParserErrorCode.MISSING_VARIABLE_IN_FOR_EACH);
862 } 841 }
863 842
864 public void test_mixedParameterGroups_namedPositional() throws Exception { 843 public void test_mixedParameterGroups_namedPositional() throws Exception {
865 parse("parseFormalParameterList", "(a, {b}, [c])", ParserErrorCode.MIXED_PAR AMETER_GROUPS); 844 parse("parseFormalParameterList", "(a, {b}, [c])", ParserErrorCode.MIXED_PAR AMETER_GROUPS);
866 } 845 }
867 846
868 public void test_mixedParameterGroups_positionalNamed() throws Exception { 847 public void test_mixedParameterGroups_positionalNamed() throws Exception {
869 parse("parseFormalParameterList", "(a, [b], {c})", ParserErrorCode.MIXED_PAR AMETER_GROUPS); 848 parse("parseFormalParameterList", "(a, [b], {c})", ParserErrorCode.MIXED_PAR AMETER_GROUPS);
870 } 849 }
871 850
872 public void test_multipleLibraryDirectives() throws Exception { 851 public void test_multipleLibraryDirectives() throws Exception {
873 parse( 852 parseCompilationUnit("library l; library m;", ParserErrorCode.MULTIPLE_LIBRA RY_DIRECTIVES);
874 "parseCompilationUnit",
875 "library l; library m;",
876 ParserErrorCode.MULTIPLE_LIBRARY_DIRECTIVES);
877 } 853 }
878 854
879 public void test_multipleNamedParameterGroups() throws Exception { 855 public void test_multipleNamedParameterGroups() throws Exception {
880 parse( 856 parse(
881 "parseFormalParameterList", 857 "parseFormalParameterList",
882 "(a, {b}, {c})", 858 "(a, {b}, {c})",
883 ParserErrorCode.MULTIPLE_NAMED_PARAMETER_GROUPS); 859 ParserErrorCode.MULTIPLE_NAMED_PARAMETER_GROUPS);
884 } 860 }
885 861
886 public void test_multiplePartOfDirectives() throws Exception { 862 public void test_multiplePartOfDirectives() throws Exception {
887 parse( 863 parseCompilationUnit("part of l; part of m;", ParserErrorCode.MULTIPLE_PART_ OF_DIRECTIVES);
888 "parseCompilationUnit",
889 "part of l; part of m;",
890 ParserErrorCode.MULTIPLE_PART_OF_DIRECTIVES);
891 } 864 }
892 865
893 public void test_multiplePositionalParameterGroups() throws Exception { 866 public void test_multiplePositionalParameterGroups() throws Exception {
894 parse( 867 parse(
895 "parseFormalParameterList", 868 "parseFormalParameterList",
896 "(a, [b], [c])", 869 "(a, [b], [c])",
897 ParserErrorCode.MULTIPLE_POSITIONAL_PARAMETER_GROUPS); 870 ParserErrorCode.MULTIPLE_POSITIONAL_PARAMETER_GROUPS);
898 } 871 }
899 872
900 public void test_multipleVariablesInForEach() throws Exception { 873 public void test_multipleVariablesInForEach() throws Exception {
(...skipping 17 matching lines...) Expand all
918 891
919 public void test_nonConstructorFactory_method() throws Exception { 892 public void test_nonConstructorFactory_method() throws Exception {
920 parse( 893 parse(
921 "parseClassMember", 894 "parseClassMember",
922 new Object[] {"C"}, 895 new Object[] {"C"},
923 "factory int m() {}", 896 "factory int m() {}",
924 ParserErrorCode.NON_CONSTRUCTOR_FACTORY); 897 ParserErrorCode.NON_CONSTRUCTOR_FACTORY);
925 } 898 }
926 899
927 public void test_nonIdentifierLibraryName_library() throws Exception { 900 public void test_nonIdentifierLibraryName_library() throws Exception {
928 CompilationUnit unit = parse( 901 CompilationUnit unit = parseCompilationUnit(
929 "parseCompilationUnit",
930 "library 'lib';", 902 "library 'lib';",
931 ParserErrorCode.NON_IDENTIFIER_LIBRARY_NAME); 903 ParserErrorCode.NON_IDENTIFIER_LIBRARY_NAME);
932 assertNotNull(unit); 904 assertNotNull(unit);
933 } 905 }
934 906
935 public void test_nonIdentifierLibraryName_partOf() throws Exception { 907 public void test_nonIdentifierLibraryName_partOf() throws Exception {
936 CompilationUnit unit = parse( 908 CompilationUnit unit = parseCompilationUnit(
937 "parseCompilationUnit",
938 "part of 'lib';", 909 "part of 'lib';",
939 ParserErrorCode.NON_IDENTIFIER_LIBRARY_NAME); 910 ParserErrorCode.NON_IDENTIFIER_LIBRARY_NAME);
940 assertNotNull(unit); 911 assertNotNull(unit);
941 } 912 }
942 913
943 public void test_nonPartOfDirectiveInPart_after() throws Exception { 914 public void test_nonPartOfDirectiveInPart_after() throws Exception {
944 parse( 915 parseCompilationUnit("part of l; part 'f.dart';", ParserErrorCode.NON_PART_O F_DIRECTIVE_IN_PART);
945 "parseCompilationUnit",
946 "part of l; part 'f.dart';",
947 ParserErrorCode.NON_PART_OF_DIRECTIVE_IN_PART);
948 } 916 }
949 917
950 public void test_nonPartOfDirectiveInPart_before() throws Exception { 918 public void test_nonPartOfDirectiveInPart_before() throws Exception {
951 parse( 919 parseCompilationUnit("part 'f.dart'; part of m;", ParserErrorCode.NON_PART_O F_DIRECTIVE_IN_PART);
952 "parseCompilationUnit",
953 "part 'f.dart'; part of m;",
954 ParserErrorCode.NON_PART_OF_DIRECTIVE_IN_PART);
955 } 920 }
956 921
957 public void test_nonUserDefinableOperator() throws Exception { 922 public void test_nonUserDefinableOperator() throws Exception {
958 parse( 923 parse(
959 "parseClassMember", 924 "parseClassMember",
960 new Object[] {"C"}, 925 new Object[] {"C"},
961 "operator +=(int x) => x + 1;", 926 "operator +=(int x) => x + 1;",
962 ParserErrorCode.NON_USER_DEFINABLE_OPERATOR); 927 ParserErrorCode.NON_USER_DEFINABLE_OPERATOR);
963 } 928 }
964 929
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1011 976
1012 public void test_staticOperator_returnType() throws Exception { 977 public void test_staticOperator_returnType() throws Exception {
1013 parse( 978 parse(
1014 "parseClassMember", 979 "parseClassMember",
1015 new Object[] {"C"}, 980 new Object[] {"C"},
1016 "static int operator +(int x) => x + 1;", 981 "static int operator +(int x) => x + 1;",
1017 ParserErrorCode.STATIC_OPERATOR); 982 ParserErrorCode.STATIC_OPERATOR);
1018 } 983 }
1019 984
1020 public void test_staticTopLevelDeclaration_class() throws Exception { 985 public void test_staticTopLevelDeclaration_class() throws Exception {
1021 parse("parseCompilationUnit", "static class C {}", ParserErrorCode.STATIC_TO P_LEVEL_DECLARATION); 986 parseCompilationUnit("static class C {}", ParserErrorCode.STATIC_TOP_LEVEL_D ECLARATION);
1022 } 987 }
1023 988
1024 public void test_staticTopLevelDeclaration_typedef() throws Exception { 989 public void test_staticTopLevelDeclaration_typedef() throws Exception {
1025 parse( 990 parseCompilationUnit("static typedef F();", ParserErrorCode.STATIC_TOP_LEVEL _DECLARATION);
1026 "parseCompilationUnit",
1027 "static typedef F();",
1028 ParserErrorCode.STATIC_TOP_LEVEL_DECLARATION);
1029 } 991 }
1030 992
1031 public void test_staticTopLevelDeclaration_variable() throws Exception { 993 public void test_staticTopLevelDeclaration_variable() throws Exception {
1032 parse("parseCompilationUnit", "static var x;", ParserErrorCode.STATIC_TOP_LE VEL_DECLARATION); 994 parseCompilationUnit("static var x;", ParserErrorCode.STATIC_TOP_LEVEL_DECLA RATION);
1033 } 995 }
1034 996
1035 public void test_switchHasCaseAfterDefaultCase() throws Exception { 997 public void test_switchHasCaseAfterDefaultCase() throws Exception {
1036 parse( 998 parse(
1037 "parseSwitchStatement", 999 "parseSwitchStatement",
1038 "switch (a) {default: return 0; case 1: return 1;}", 1000 "switch (a) {default: return 0; case 1: return 1;}",
1039 ParserErrorCode.SWITCH_HAS_CASE_AFTER_DEFAULT_CASE); 1001 ParserErrorCode.SWITCH_HAS_CASE_AFTER_DEFAULT_CASE);
1040 } 1002 }
1041 1003
1042 public void test_switchHasCaseAfterDefaultCase_repeated() throws Exception { 1004 public void test_switchHasCaseAfterDefaultCase_repeated() throws Exception {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1102 1064
1103 public void test_unexpectedToken_semicolonBetweenClassMembers() throws Excepti on { 1065 public void test_unexpectedToken_semicolonBetweenClassMembers() throws Excepti on {
1104 parse( 1066 parse(
1105 "parseClassDeclaration", 1067 "parseClassDeclaration",
1106 new Object[] {emptyCommentAndMetadata(), null}, 1068 new Object[] {emptyCommentAndMetadata(), null},
1107 "class C { int x; ; int y;}", 1069 "class C { int x; ; int y;}",
1108 ParserErrorCode.UNEXPECTED_TOKEN); 1070 ParserErrorCode.UNEXPECTED_TOKEN);
1109 } 1071 }
1110 1072
1111 public void test_unexpectedToken_semicolonBetweenCompilationUnitMembers() thro ws Exception { 1073 public void test_unexpectedToken_semicolonBetweenCompilationUnitMembers() thro ws Exception {
1112 parse("parseCompilationUnit", "int x; ; int y;", ParserErrorCode.UNEXPECTED_ TOKEN); 1074 parseCompilationUnit("int x; ; int y;", ParserErrorCode.UNEXPECTED_TOKEN);
1113 } 1075 }
1114 1076
1115 public void test_useOfUnaryPlusOperator() throws Exception { 1077 public void test_useOfUnaryPlusOperator() throws Exception {
1116 parse("parseUnaryExpression", "+x", ParserErrorCode.USE_OF_UNARY_PLUS_OPERAT OR); 1078 parse("parseUnaryExpression", "+x", ParserErrorCode.USE_OF_UNARY_PLUS_OPERAT OR);
1117 } 1079 }
1118 1080
1081 public void test_varAsTypeName_as() throws Exception {
1082 parseExpression("x as var", ParserErrorCode.VAR_AS_TYPE_NAME);
1083 }
1084
1119 public void test_varClass() throws Exception { 1085 public void test_varClass() throws Exception {
1120 parse("parseCompilationUnit", "var class C {}", ParserErrorCode.VAR_CLASS); 1086 parseCompilationUnit("var class C {}", ParserErrorCode.VAR_CLASS);
1121 } 1087 }
1122 1088
1123 public void test_varConstructor() throws Exception { 1089 public void test_varConstructor() throws Exception {
1124 parse( 1090 parse(
1125 "parseClassMember", 1091 "parseClassMember",
1126 new Object[] {"C"}, 1092 new Object[] {"C"},
1127 "var C() {}", 1093 "var C() {}",
1128 ParserErrorCode.CONSTRUCTOR_WITH_RETURN_TYPE); 1094 ParserErrorCode.CONSTRUCTOR_WITH_RETURN_TYPE);
1129 } 1095 }
1130 1096
1131 public void test_varReturnType() throws Exception { 1097 public void test_varReturnType() throws Exception {
1132 parse("parseClassMember", new Object[] {"C"}, "var m() {}", ParserErrorCode. VAR_RETURN_TYPE); 1098 parse("parseClassMember", new Object[] {"C"}, "var m() {}", ParserErrorCode. VAR_RETURN_TYPE);
1133 } 1099 }
1134 1100
1135 public void test_varTypedef() throws Exception { 1101 public void test_varTypedef() throws Exception {
1136 parse("parseCompilationUnit", "var typedef F();", ParserErrorCode.VAR_TYPEDE F); 1102 parseCompilationUnit("var typedef F();", ParserErrorCode.VAR_TYPEDEF);
1137 } 1103 }
1138 1104
1139 public void test_voidField_initializer() throws Exception { 1105 public void test_voidField_initializer() throws Exception {
1140 parse("parseClassMember", new Object[] {"C"}, "void x = 0;", ParserErrorCode .VOID_VARIABLE); 1106 parse("parseClassMember", new Object[] {"C"}, "void x = 0;", ParserErrorCode .VOID_VARIABLE);
1141 } 1107 }
1142 1108
1143 public void test_voidField_noInitializer() throws Exception { 1109 public void test_voidField_noInitializer() throws Exception {
1144 parse("parseClassMember", new Object[] {"C"}, "void x;", ParserErrorCode.VOI D_VARIABLE); 1110 parse("parseClassMember", new Object[] {"C"}, "void x;", ParserErrorCode.VOI D_VARIABLE);
1145 } 1111 }
1146 1112
1147 public void test_voidParameter() throws Exception { 1113 public void test_voidParameter() throws Exception {
1148 parse("parseNormalFormalParameter", "void a)", ParserErrorCode.VOID_PARAMETE R); 1114 parse("parseNormalFormalParameter", "void a)", ParserErrorCode.VOID_PARAMETE R);
1149 } 1115 }
1150 1116
1151 public void test_withBeforeExtends() throws Exception { 1117 public void test_withBeforeExtends() throws Exception {
1152 parse( 1118 parseCompilationUnit("class A with B extends C {}", ParserErrorCode.WITH_BEF ORE_EXTENDS);
1153 "parseCompilationUnit",
1154 "class A with B extends C {}",
1155 ParserErrorCode.WITH_BEFORE_EXTENDS);
1156 } 1119 }
1157 1120
1158 public void test_withWithoutExtends() throws Exception { 1121 public void test_withWithoutExtends() throws Exception {
1159 parse( 1122 parse(
1160 "parseClassDeclaration", 1123 "parseClassDeclaration",
1161 new Object[] {emptyCommentAndMetadata(), null}, 1124 new Object[] {emptyCommentAndMetadata(), null},
1162 "class A with B, C {}", 1125 "class A with B, C {}",
1163 ParserErrorCode.WITH_WITHOUT_EXTENDS); 1126 ParserErrorCode.WITH_WITHOUT_EXTENDS);
1164 } 1127 }
1165 1128
(...skipping 18 matching lines...) Expand all
1184 ParserErrorCode.WRONG_TERMINATOR_FOR_PARAMETER_GROUP); 1147 ParserErrorCode.WRONG_TERMINATOR_FOR_PARAMETER_GROUP);
1185 } 1148 }
1186 1149
1187 public void test_wrongTerminatorForParameterGroup_optional() throws Exception { 1150 public void test_wrongTerminatorForParameterGroup_optional() throws Exception {
1188 parse( 1151 parse(
1189 "parseFormalParameterList", 1152 "parseFormalParameterList",
1190 "(a, [b, c})", 1153 "(a, [b, c})",
1191 ParserErrorCode.WRONG_TERMINATOR_FOR_PARAMETER_GROUP); 1154 ParserErrorCode.WRONG_TERMINATOR_FOR_PARAMETER_GROUP);
1192 } 1155 }
1193 } 1156 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698