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

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

Issue 152593002: Version 1.2.0-dev.3.1 (Closed) Base URL: http://dart.googlecode.com/svn/trunk/dart/
Patch Set: Created 6 years, 10 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 mock_compiler; 5 library mock_compiler;
6 6
7 import "package:expect/expect.dart"; 7 import "package:expect/expect.dart";
8 import 'dart:async'; 8 import 'dart:async';
9 import 'dart:collection'; 9 import 'dart:collection';
10 10
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 String foundValue = '${message.arguments[key]}'; 471 String foundValue = '${message.arguments[key]}';
472 if (expectedValue != foundValue) { 472 if (expectedValue != foundValue) {
473 return 'Expected argument $key with value $expectedValue, ' 473 return 'Expected argument $key with value $expectedValue, '
474 'found $foundValue.'; 474 'found $foundValue.';
475 } 475 }
476 } 476 }
477 return null; 477 return null;
478 }; 478 };
479 } 479 }
480 480
481 /// [expectedWarnings] must be a list of either [MessageKind] or [CheckMessage].
482 void compareWarningKinds(String text, 481 void compareWarningKinds(String text,
483 List expectedWarnings, 482 List expectedWarnings,
484 List<WarningMessage> foundWarnings) { 483 List<WarningMessage> foundWarnings) {
484 compareMessageKinds(text, expectedWarnings, foundWarnings, 'warning');
485 }
486
487 /// [expectedMessages] must be a list of either [MessageKind] or [CheckMessage].
488 void compareMessageKinds(String text,
489 List expectedMessages,
490 List<WarningMessage> foundMessages,
491 String kind) {
485 var fail = (message) => Expect.fail('$text: $message'); 492 var fail = (message) => Expect.fail('$text: $message');
486 HasNextIterator expectedIterator = 493 HasNextIterator expectedIterator =
487 new HasNextIterator(expectedWarnings.iterator); 494 new HasNextIterator(expectedMessages.iterator);
488 HasNextIterator<WarningMessage> foundIterator = 495 HasNextIterator<WarningMessage> foundIterator =
489 new HasNextIterator(foundWarnings.iterator); 496 new HasNextIterator(foundMessages.iterator);
490 while (expectedIterator.hasNext && foundIterator.hasNext) { 497 while (expectedIterator.hasNext && foundIterator.hasNext) {
491 var expected = expectedIterator.next(); 498 var expected = expectedIterator.next();
492 var found = foundIterator.next(); 499 var found = foundIterator.next();
493 if (expected is MessageKind) { 500 if (expected is MessageKind) {
494 Expect.equals(expected, found.message.kind); 501 Expect.equals(expected, found.message.kind);
495 } else if (expected is CheckMessage) { 502 } else if (expected is CheckMessage) {
496 String error = expected(found.message); 503 String error = expected(found.message);
497 Expect.isNull(error, error); 504 Expect.isNull(error, error);
498 } else { 505 } else {
499 Expect.fail("Unexpected expectedWarnings value: $expected."); 506 Expect.fail("Unexpected $kind value: $expected.");
500 } 507 }
501 } 508 }
502 if (expectedIterator.hasNext) { 509 if (expectedIterator.hasNext) {
503 do { 510 do {
504 var expected = expectedIterator.next(); 511 var expected = expectedIterator.next();
505 if (expected is CheckMessage) expected = expected(null); 512 if (expected is CheckMessage) expected = expected(null);
506 print('Expected warning "${expected}" did not occur'); 513 print('Expected $kind "${expected}" did not occur');
507 } while (expectedIterator.hasNext); 514 } while (expectedIterator.hasNext);
508 fail('Too few warnings'); 515 fail('Too few ${kind}s');
509 } 516 }
510 if (foundIterator.hasNext) { 517 if (foundIterator.hasNext) {
511 do { 518 do {
512 print('Additional warning "${foundIterator.next()}"'); 519 print('Additional $kind "${foundIterator.next()}"');
513 } while (foundIterator.hasNext); 520 } while (foundIterator.hasNext);
514 fail('Too many warnings'); 521 fail('Too many ${kind}s');
515 } 522 }
516 } 523 }
517 524
518 void importLibrary(LibraryElement target, LibraryElementX imported, 525 void importLibrary(LibraryElement target, LibraryElementX imported,
519 Compiler compiler) { 526 Compiler compiler) {
520 for (var element in imported.localMembers) { 527 for (var element in imported.localMembers) {
521 compiler.withCurrentElement(element, () { 528 compiler.withCurrentElement(element, () {
522 target.addToScope(element, compiler); 529 target.addToScope(element, compiler);
523 }); 530 });
524 } 531 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 } else { 572 } else {
566 sourceFile = compiler.sourceFiles[uri.toString()]; 573 sourceFile = compiler.sourceFiles[uri.toString()];
567 } 574 }
568 if (sourceFile != null && begin != null && end != null) { 575 if (sourceFile != null && begin != null && end != null) {
569 print(sourceFile.getLocationMessage(message, begin, end, true, (x) => x)); 576 print(sourceFile.getLocationMessage(message, begin, end, true, (x) => x));
570 } else { 577 } else {
571 print(message); 578 print(message);
572 } 579 }
573 }; 580 };
574 } 581 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/message_kind_test.dart ('k') | tests/compiler/dart2js/override_inheritance_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698