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

Unified Diff: pkg/analyzer_experimental/test/generated/test_support.dart

Issue 16337007: Version 0.5.13.1 . (Closed) Base URL: http://dart.googlecode.com/svn/trunk/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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer_experimental/test/generated/scanner_test.dart ('k') | tools/VERSION » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer_experimental/test/generated/test_support.dart
===================================================================
--- pkg/analyzer_experimental/test/generated/test_support.dart (revision 23549)
+++ pkg/analyzer_experimental/test/generated/test_support.dart (working copy)
@@ -11,54 +11,73 @@
import 'package:analyzer_experimental/src/generated/error.dart';
import 'package:analyzer_experimental/src/generated/scanner.dart';
import 'package:analyzer_experimental/src/generated/element.dart' show InterfaceType, MethodElement, PropertyAccessorElement;
-import 'package:analyzer_experimental/src/generated/engine.dart' show AnalysisContext, AnalysisContextImpl;
+import 'package:analyzer_experimental/src/generated/engine.dart' show AnalysisContext, AnalysisContextImpl, RecordingErrorListener;
import 'package:unittest/unittest.dart' as _ut;
+
/**
* Instances of the class {@code GatheringErrorListener} implement an error listener that collects
* all of the errors passed to it for later examination.
*/
class GatheringErrorListener implements AnalysisErrorListener {
+
/**
* The source being parsed.
*/
String _rawSource;
+
/**
* The source being parsed after inserting a marker at the beginning and end of the range of the
* most recent error.
*/
String _markedSource;
+
/**
* A list containing the errors that were collected.
*/
List<AnalysisError> _errors = new List<AnalysisError>();
+
/**
* A table mapping sources to the line information for the source.
*/
Map<Source, LineInfo> _lineInfoMap = new Map<Source, LineInfo>();
+
/**
* An empty array of errors used when no errors are expected.
*/
static List<AnalysisError> _NO_ERRORS = new List<AnalysisError>(0);
+
/**
* Initialize a newly created error listener to collect errors.
*/
GatheringErrorListener() : super() {
- _jtd_constructor_349_impl();
+ _jtd_constructor_357_impl();
}
- _jtd_constructor_349_impl() {
+ _jtd_constructor_357_impl() {
}
+
/**
* Initialize a newly created error listener to collect errors.
*/
GatheringErrorListener.con1(String rawSource2) {
- _jtd_constructor_350_impl(rawSource2);
+ _jtd_constructor_358_impl(rawSource2);
}
- _jtd_constructor_350_impl(String rawSource2) {
+ _jtd_constructor_358_impl(String rawSource2) {
this._rawSource = rawSource2;
this._markedSource = rawSource2;
}
+
/**
+ * Add all of the errors recorded by the given listener to this listener.
+ * @param listener the listener that has recorded the errors to be added
+ */
+ void addAll(RecordingErrorListener listener) {
+ for (AnalysisError error in listener.errors) {
+ onError(error);
+ }
+ }
+
+ /**
* Assert that the number of errors that have been gathered matches the number of errors that are
* given and that they have the expected error codes and locations. The order in which the errors
* were gathered is ignored.
@@ -80,6 +99,7 @@
}
}
}
+
/**
* Assert that the number of errors that have been gathered matches the number of errors that are
* given and that they have the expected error codes. The order in which the errors were gathered
@@ -90,6 +110,9 @@
*/
void assertErrors2(List<ErrorCode> expectedErrorCodes) {
JavaStringBuilder builder = new JavaStringBuilder();
+ for (ErrorCode errorCode in expectedErrorCodes) {
+ JUnitTestCase.assertFalseMsg("Empty error code message", errorCode.message.isEmpty);
+ }
Map<ErrorCode, int> expectedCounts = new Map<ErrorCode, int>();
for (ErrorCode code in expectedErrorCodes) {
int count = expectedCounts[code];
@@ -128,7 +151,7 @@
}
builder.append(expectedCount);
builder.append(" errors of type ");
- builder.append(code);
+ builder.append("${code.runtimeType.toString()}.${code}");
builder.append(", found ");
builder.append(actualCount);
}
@@ -143,7 +166,7 @@
builder.append("; ");
}
builder.append("0 errors of type ");
- builder.append(code);
+ builder.append("${code.runtimeType.toString()}.${code}");
builder.append(", found ");
builder.append(actualCount);
builder.append(" (");
@@ -160,6 +183,7 @@
JUnitTestCase.fail(builder.toString());
}
}
+
/**
* Assert that the number of errors that have been gathered matches the number of severities that
* are given and that there are the same number of errors and warnings as specified by the
@@ -191,6 +215,7 @@
JUnitTestCase.fail("Expected ${expectedErrorCount} errors and ${expectedWarningCount} warnings, found ${actualErrorCount} errors and ${actualWarningCount} warnings");
}
}
+
/**
* Assert that no errors have been gathered.
* @throws AssertionFailedError if any errors have been gathered
@@ -198,11 +223,13 @@
void assertNoErrors() {
assertErrors(_NO_ERRORS);
}
+
/**
* Return the errors that were collected.
* @return the errors that were collected
*/
List<AnalysisError> get errors => _errors;
+
/**
* Return the line information associated with the given source, or {@code null} if no line
* information has been associated with the source.
@@ -210,6 +237,7 @@
* @return the line information associated with the source
*/
LineInfo getLineInfo(Source source) => _lineInfoMap[source];
+
/**
* Return {@code true} if an error with the given error code has been gathered.
* @param errorCode the error code being searched for
@@ -223,6 +251,7 @@
}
return false;
}
+
/**
* Return {@code true} if at least one error has been gathered.
* @return {@code true} if at least one error has been gathered
@@ -236,6 +265,7 @@
}
_errors.add(error);
}
+
/**
* Set the line information associated with the given source to the given information.
* @param source the source with which the line information is associated
@@ -244,6 +274,7 @@
void setLineInfo(Source source, List<int> lineStarts) {
_lineInfoMap[source] = new LineInfo(lineStarts);
}
+
/**
* Set the line information associated with the given source to the given information.
* @param source the source with which the line information is associated
@@ -252,6 +283,7 @@
void setLineInfo2(Source source, LineInfo lineInfo) {
_lineInfoMap[source] = lineInfo;
}
+
/**
* Return {@code true} if the two errors are equivalent.
* @param firstError the first error being compared
@@ -259,6 +291,7 @@
* @return {@code true} if the two errors are equivalent
*/
bool equals3(AnalysisError firstError, AnalysisError secondError) => identical(firstError.errorCode, secondError.errorCode) && firstError.offset == secondError.offset && firstError.length == secondError.length && equals4(firstError.source, secondError.source);
+
/**
* Return {@code true} if the two sources are equivalent.
* @param firstSource the first source being compared
@@ -273,6 +306,7 @@
}
return firstSource == secondSource;
}
+
/**
* Assert that the number of errors that have been gathered matches the number of errors that are
* given and that they have the expected error codes. The order in which the errors were gathered
@@ -315,6 +349,7 @@
}
JUnitTestCase.fail(writer.toString());
}
+
/**
* Search through the given list of errors for an error that is equal to the target error. If one
* is found, remove it from the list and return {@code true}, otherwise return {@code false}without modifying the list.
@@ -332,11 +367,13 @@
return true;
}
}
+
/**
* The class {@code EngineTestCase} defines utility methods for making assertions.
*/
class EngineTestCase extends JUnitTestCase {
static int _PRINT_RANGE = 6;
+
/**
* Assert that the tokens in the actual stream of tokens have the same types and lexemes as the
* tokens in the expected stream of tokens. Note that this does not assert anything about the
@@ -354,6 +391,7 @@
right = right.next;
}
}
+
/**
* Assert that the array of actual values contain exactly the same values as those in the array of
* expected value, with the exception that the order of the elements is not required to be the
@@ -383,6 +421,7 @@
}
}
}
+
/**
* Assert that a given String is equal to an expected value.
* @param expected the expected String value
@@ -408,6 +447,7 @@
JUnitTestCase.assertEqualsMsg(message, expected, actual);
}
}
+
/**
* Assert that the given list is non-{@code null} and has exactly expected elements.
* @param list the list being tested
@@ -430,6 +470,7 @@
}
}
}
+
/**
* Assert that the given array is non-{@code null} and has exactly expected elements.
* @param array the array being tested
@@ -446,13 +487,14 @@
JUnitTestCase.fail("Expected array of size ${expectedSize}; contained ${array.length} elements");
}
for (int i = 0; i < expectedElements.length; i++) {
- Object element = array[0];
+ Object element = array[i];
Object expectedElement = expectedElements[i];
if (!element == expectedElement) {
JUnitTestCase.fail("Expected ${expectedElement} at [${i}]; found ${element}");
}
}
}
+
/**
* Assert that the given list is non-{@code null} and has exactly expected elements.
* @param set the list being tested
@@ -474,6 +516,7 @@
}
}
}
+
/**
* Assert that the given object is an instance of the expected class.
* @param expectedClass the class that the object is expected to be an instance of
@@ -487,6 +530,7 @@
}
return object as Object;
}
+
/**
* Assert that the given array is non-{@code null} and has the expected number of elements.
* @param expectedLength the expected number of elements
@@ -501,6 +545,7 @@
JUnitTestCase.fail("Expected array of length ${expectedLength}; contained ${array.length} elements");
}
}
+
/**
* Assert that the actual token has the same type and lexeme as the expected token. Note that this
* does not assert anything about the offsets of the tokens (although the lengths will be equal).
@@ -518,6 +563,7 @@
JUnitTestCase.assertEquals(((expectedToken as StringToken)).lexeme, ((actualToken as StringToken)).lexeme);
}
}
+
/**
* Assert that the given list is non-{@code null} and has the expected number of elements.
* @param expectedSize the expected number of elements
@@ -532,6 +578,7 @@
JUnitTestCase.fail("Expected list of size ${expectedSize}; contained ${list.length} elements");
}
}
+
/**
* Assert that the given map is non-{@code null} and has the expected number of elements.
* @param expectedSize the expected number of elements
@@ -546,6 +593,7 @@
JUnitTestCase.fail("Expected map of size ${expectedSize}; contained ${map.length} elements");
}
}
+
/**
* Assert that the given set is non-{@code null} and has the expected number of elements.
* @param expectedSize the expected number of elements
@@ -560,6 +608,7 @@
JUnitTestCase.fail("Expected set of size ${expectedSize}; contained ${set.length} elements");
}
}
+
/**
* Convert the given array of lines into a single source string.
* @param lines the lines to be merged into a single source string
@@ -572,6 +621,7 @@
}
return writer.toString();
}
+
/**
* Calculate the offset where the given strings differ.
* @param str1 the first String to compare
@@ -597,6 +647,7 @@
context.sourceFactory = new SourceFactory.con2([]);
return context;
}
+
/**
* Return the getter in the given type with the given name. Inherited getters are ignored.
* @param type the type in which the getter is declared
@@ -609,9 +660,10 @@
return accessor;
}
}
- JUnitTestCase.fail("Could not find getter named ${getterName} in ${type.name}");
+ JUnitTestCase.fail("Could not find getter named ${getterName} in ${type.displayName}");
return null;
}
+
/**
* Return the method in the given type with the given name. Inherited methods are ignored.
* @param type the type in which the method is declared
@@ -624,7 +676,7 @@
return method;
}
}
- JUnitTestCase.fail("Could not find method named ${methodName} in ${type.name}");
+ JUnitTestCase.fail("Could not find method named ${methodName} in ${type.displayName}");
return null;
}
static dartSuite() {
« no previous file with comments | « pkg/analyzer_experimental/test/generated/scanner_test.dart ('k') | tools/VERSION » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698