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

Side by Side Diff: tests/compiler/dart2js/parser_test.dart

Issue 2345083003: dart2js: run dartfmt on tests (Closed)
Patch Set: revert another multipart test Created 4 years, 3 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
« no previous file with comments | « tests/compiler/dart2js/parser_helper.dart ('k') | tests/compiler/dart2js/part_of_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 import "package:expect/expect.dart"; 5 import "package:expect/expect.dart";
6 import 'parser_helper.dart'; 6 import 'parser_helper.dart';
7 import 'package:compiler/src/tree/tree.dart'; 7 import 'package:compiler/src/tree/tree.dart';
8 8
9 void testStatement(String statement) { 9 void testStatement(String statement) {
10 Node node = parseStatement(statement); 10 Node node = parseStatement(statement);
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 } 297 }
298 298
299 class Collector extends DiagnosticReporter { 299 class Collector extends DiagnosticReporter {
300 int token = -1; 300 int token = -1;
301 301
302 void reportFatalError(Token token) { 302 void reportFatalError(Token token) {
303 this.token = token.kind; 303 this.token = token.kind;
304 throw this; 304 throw this;
305 } 305 }
306 306
307 void reportError( 307 void reportError(DiagnosticMessage message,
308 DiagnosticMessage message,
309 [List<DiagnosticMessage> infos = const <DiagnosticMessage>[]]) { 308 [List<DiagnosticMessage> infos = const <DiagnosticMessage>[]]) {
310 reportFatalError(message.spannable); 309 reportFatalError(message.spannable);
311 } 310 }
312 311
313 void log(message) { 312 void log(message) {
314 print(message); 313 print(message);
315 } 314 }
316 315
317 noSuchMethod(Invocation invocation) { 316 noSuchMethod(Invocation invocation) {
318 throw 'unsupported operation'; 317 throw 'unsupported operation';
319 } 318 }
320 319
321 @override 320 @override
322 DiagnosticMessage createMessage( 321 DiagnosticMessage createMessage(spannable, messageKind,
323 spannable, messageKind, [arguments = const {}]) { 322 [arguments = const {}]) {
324 return new DiagnosticMessage(null, spannable, null); 323 return new DiagnosticMessage(null, spannable, null);
325 } 324 }
326 } 325 }
327 326
328 void testMissingCloseParen() { 327 void testMissingCloseParen() {
329 final String source = 328 final String source = '''foo(x { // <= missing closing ")"
330 '''foo(x { // <= missing closing ")"
331 return x; 329 return x;
332 }'''; 330 }''';
333 parse() { 331 parse() {
334 parseMember(source, reporter: new Collector()); 332 parseMember(source, reporter: new Collector());
335 } 333 }
334
336 check(Collector c) { 335 check(Collector c) {
337 Expect.equals(OPEN_CURLY_BRACKET_TOKEN, c.token); 336 Expect.equals(OPEN_CURLY_BRACKET_TOKEN, c.token);
338 return true; 337 return true;
339 } 338 }
339
340 Expect.throws(parse, check); 340 Expect.throws(parse, check);
341 } 341 }
342 342
343 void testMissingCloseBraceInClass() { 343 void testMissingCloseBraceInClass() {
344 final String source = 'class Foo {'; // Missing close '}'. 344 final String source = 'class Foo {'; // Missing close '}'.
345 parse() { 345 parse() {
346 fullParseUnit(source, reporter: new Collector()); 346 fullParseUnit(source, reporter: new Collector());
347 } 347 }
348
348 check(Collector c) { 349 check(Collector c) {
349 Expect.equals(BAD_INPUT_TOKEN, c.token); 350 Expect.equals(BAD_INPUT_TOKEN, c.token);
350 return true; 351 return true;
351 } 352 }
353
352 Expect.throws(parse, check); 354 Expect.throws(parse, check);
353 } 355 }
354 356
355 void testUnmatchedAngleBracket() { 357 void testUnmatchedAngleBracket() {
356 final String source = 'A<'; // unmatched '<' 358 final String source = 'A<'; // unmatched '<'
357 parse() { 359 parse() {
358 fullParseUnit(source, reporter: new Collector()); 360 fullParseUnit(source, reporter: new Collector());
359 } 361 }
362
360 check(Collector c) { 363 check(Collector c) {
361 Expect.equals(LT_TOKEN, c.token); 364 Expect.equals(LT_TOKEN, c.token);
362 return true; 365 return true;
363 } 366 }
367
364 Expect.throws(parse, check); 368 Expect.throws(parse, check);
365 } 369 }
366 370
367 void main() { 371 void main() {
368 testGenericTypes(); 372 testGenericTypes();
369 // TODO(ahe): Enable this test when we handle library prefixes. 373 // TODO(ahe): Enable this test when we handle library prefixes.
370 // testPrefixedGenericTypes(); 374 // testPrefixedGenericTypes();
371 testUnaryExpression(); 375 testUnaryExpression();
372 testChainedMethodCalls(); 376 testChainedMethodCalls();
373 testFunctionStatement(); 377 testFunctionStatement();
374 testDoStatement(); 378 testDoStatement();
375 testWhileStatement(); 379 testWhileStatement();
376 testConditionalExpression(); 380 testConditionalExpression();
377 testNullOperators(); 381 testNullOperators();
378 testAssignment(); 382 testAssignment();
379 testIndex(); 383 testIndex();
380 testPostfix(); 384 testPostfix();
381 testOperatorParse(); 385 testOperatorParse();
382 testMissingCloseParen(); 386 testMissingCloseParen();
383 testMissingCloseBraceInClass(); 387 testMissingCloseBraceInClass();
384 testUnmatchedAngleBracket(); 388 testUnmatchedAngleBracket();
385 } 389 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/parser_helper.dart ('k') | tests/compiler/dart2js/part_of_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698