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

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

Issue 680863002: Remove JavaStringBuilder (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 1 month 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 // This code was auto-generated, is not intended to be edited, and is subject to 5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information. 6 // significant change. Please see the README file for more information.
7 7
8 library engine.test_support; 8 library engine.test_support;
9 9
10 import 'dart:collection'; 10 import 'dart:collection';
(...skipping 26 matching lines...) Expand all
37 void assertNamedElements(List<Element> elements, List<String> names) { 37 void assertNamedElements(List<Element> elements, List<String> names) {
38 for (String elemName in names) { 38 for (String elemName in names) {
39 bool found = false; 39 bool found = false;
40 for (Element elem in elements) { 40 for (Element elem in elements) {
41 if (elem.name == elemName) { 41 if (elem.name == elemName) {
42 found = true; 42 found = true;
43 break; 43 break;
44 } 44 }
45 } 45 }
46 if (!found) { 46 if (!found) {
47 JavaStringBuilder msg = new JavaStringBuilder(); 47 StringBuffer buffer = new StringBuffer();
48 msg.append("Expected element named: "); 48 buffer.write("Expected element named: ");
49 msg.append(elemName); 49 buffer.write(elemName);
50 msg.append("\n but found: "); 50 buffer.write("\n but found: ");
51 for (Element elem in elements) { 51 for (Element elem in elements) {
52 msg.append(elem.name); 52 buffer.write(elem.name);
53 msg.append(", "); 53 buffer.write(", ");
54 } 54 }
55 JUnitTestCase.fail(msg.toString()); 55 JUnitTestCase.fail(buffer.toString());
56 } 56 }
57 } 57 }
58 assertLength(names.length, elements); 58 assertLength(names.length, elements);
59 } 59 }
60 60
61 AnalysisContextImpl createAnalysisContext() { 61 AnalysisContextImpl createAnalysisContext() {
62 AnalysisContextImpl context = new AnalysisContextImpl(); 62 AnalysisContextImpl context = new AnalysisContextImpl();
63 context.sourceFactory = new SourceFactory([]); 63 context.sourceFactory = new SourceFactory([]);
64 return context; 64 return context;
65 } 65 }
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 /** 596 /**
597 * Assert that the number of errors that have been gathered matches the number of errors that are 597 * Assert that the number of errors that have been gathered matches the number of errors that are
598 * given and that they have the expected error codes. The order in which the e rrors were gathered 598 * given and that they have the expected error codes. The order in which the e rrors were gathered
599 * is ignored. 599 * is ignored.
600 * 600 *
601 * @param expectedErrorCodes the error codes of the errors that should have be en gathered 601 * @param expectedErrorCodes the error codes of the errors that should have be en gathered
602 * @throws AssertionFailedError if a different number of errors have been gath ered than were 602 * @throws AssertionFailedError if a different number of errors have been gath ered than were
603 * expected 603 * expected
604 */ 604 */
605 void assertErrorsWithCodes(List<ErrorCode> expectedErrorCodes) { 605 void assertErrorsWithCodes(List<ErrorCode> expectedErrorCodes) {
606 JavaStringBuilder builder = new JavaStringBuilder(); 606 StringBuffer buffer = new StringBuffer();
607 // 607 //
608 // Verify that the expected error codes have a non-empty message. 608 // Verify that the expected error codes have a non-empty message.
609 // 609 //
610 for (ErrorCode errorCode in expectedErrorCodes) { 610 for (ErrorCode errorCode in expectedErrorCodes) {
611 JUnitTestCase.assertFalseMsg( 611 JUnitTestCase.assertFalseMsg(
612 "Empty error code message", 612 "Empty error code message",
613 errorCode.message.isEmpty); 613 errorCode.message.isEmpty);
614 } 614 }
615 // 615 //
616 // Compute the expected number of each type of error. 616 // Compute the expected number of each type of error.
(...skipping 29 matching lines...) Expand all
646 ErrorCode code = entry.getKey(); 646 ErrorCode code = entry.getKey();
647 int expectedCount = entry.getValue(); 647 int expectedCount = entry.getValue();
648 int actualCount; 648 int actualCount;
649 List<AnalysisError> list = errorsByCode.remove(code); 649 List<AnalysisError> list = errorsByCode.remove(code);
650 if (list == null) { 650 if (list == null) {
651 actualCount = 0; 651 actualCount = 0;
652 } else { 652 } else {
653 actualCount = list.length; 653 actualCount = list.length;
654 } 654 }
655 if (actualCount != expectedCount) { 655 if (actualCount != expectedCount) {
656 if (builder.length == 0) { 656 if (buffer.length == 0) {
657 builder.append("Expected "); 657 buffer.write("Expected ");
658 } else { 658 } else {
659 builder.append("; "); 659 buffer.write("; ");
660 } 660 }
661 builder.append(expectedCount); 661 buffer.write(expectedCount);
662 builder.append(" errors of type "); 662 buffer.write(" errors of type ");
663 builder.append("${code.runtimeType}.$code"); 663 buffer.write("${code.runtimeType}.$code");
664 builder.append(", found "); 664 buffer.write(", found ");
665 builder.append(actualCount); 665 buffer.write(actualCount);
666 } 666 }
667 } 667 }
668 // 668 //
669 // Check that there are no more errors in the actual-errors map, 669 // Check that there are no more errors in the actual-errors map,
670 // otherwise record message. 670 // otherwise record message.
671 // 671 //
672 for (MapEntry<ErrorCode, List<AnalysisError>> entry in getMapEntrySet( 672 for (MapEntry<ErrorCode, List<AnalysisError>> entry in getMapEntrySet(
673 errorsByCode)) { 673 errorsByCode)) {
674 ErrorCode code = entry.getKey(); 674 ErrorCode code = entry.getKey();
675 List<AnalysisError> actualErrors = entry.getValue(); 675 List<AnalysisError> actualErrors = entry.getValue();
676 int actualCount = actualErrors.length; 676 int actualCount = actualErrors.length;
677 if (builder.length == 0) { 677 if (buffer.length == 0) {
678 builder.append("Expected "); 678 buffer.write("Expected ");
679 } else { 679 } else {
680 builder.append("; "); 680 buffer.write("; ");
681 } 681 }
682 builder.append("0 errors of type "); 682 buffer.write("0 errors of type ");
683 builder.append("${code.runtimeType}.$code"); 683 buffer.write("${code.runtimeType}.$code");
684 builder.append(", found "); 684 buffer.write(", found ");
685 builder.append(actualCount); 685 buffer.write(actualCount);
686 builder.append(" ("); 686 buffer.write(" (");
687 for (int i = 0; i < actualErrors.length; i++) { 687 for (int i = 0; i < actualErrors.length; i++) {
688 AnalysisError error = actualErrors[i]; 688 AnalysisError error = actualErrors[i];
689 if (i > 0) { 689 if (i > 0) {
690 builder.append(", "); 690 buffer.write(", ");
691 } 691 }
692 builder.append(error.offset); 692 buffer.write(error.offset);
693 } 693 }
694 builder.append(")"); 694 buffer.write(")");
695 } 695 }
696 if (builder.length > 0) { 696 if (buffer.length > 0) {
697 JUnitTestCase.fail(builder.toString()); 697 JUnitTestCase.fail(buffer.toString());
698 } 698 }
699 } 699 }
700 700
701 /** 701 /**
702 * Assert that the number of errors that have been gathered matches the number of severities that 702 * Assert that the number of errors that have been gathered matches the number of severities that
703 * are given and that there are the same number of errors and warnings as spec ified by the 703 * are given and that there are the same number of errors and warnings as spec ified by the
704 * argument. The order in which the errors were gathered is ignored. 704 * argument. The order in which the errors were gathered is ignored.
705 * 705 *
706 * @param expectedSeverities the severities of the errors that should have bee n gathered 706 * @param expectedSeverities the severities of the errors that should have bee n gathered
707 * @throws AssertionFailedError if a different number of errors have been gath ered than were 707 * @throws AssertionFailedError if a different number of errors have been gath ered than were
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
1005 void getContentsToReceiver(Source_ContentReceiver receiver) { 1005 void getContentsToReceiver(Source_ContentReceiver receiver) {
1006 throw new UnsupportedOperationException(); 1006 throw new UnsupportedOperationException();
1007 } 1007 }
1008 Source resolve(String uri) { 1008 Source resolve(String uri) {
1009 throw new UnsupportedOperationException(); 1009 throw new UnsupportedOperationException();
1010 } 1010 }
1011 Uri resolveRelativeUri(Uri uri) { 1011 Uri resolveRelativeUri(Uri uri) {
1012 return new Uri(scheme: 'file', path: _name).resolveUri(uri); 1012 return new Uri(scheme: 'file', path: _name).resolveUri(uri);
1013 } 1013 }
1014 } 1014 }
OLDNEW
« pkg/analyzer/lib/src/generated/ast.dart ('K') | « pkg/analyzer/test/generated/scanner_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698