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

Unified Diff: compiler/javatests/com/google/dart/compiler/CompilerTestCase.java

Issue 8527005: Better redirecting constructor and initializers problems reporting. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Report problems for all nodes Created 9 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 side-by-side diff with in-line comments
Download patch
Index: compiler/javatests/com/google/dart/compiler/CompilerTestCase.java
diff --git a/compiler/javatests/com/google/dart/compiler/CompilerTestCase.java b/compiler/javatests/com/google/dart/compiler/CompilerTestCase.java
index 55801c4c238cd7af3dc8bd34fedb3a3f7452ed91..c983d061327f09395f4ed8e20517b574ded83047 100644
--- a/compiler/javatests/com/google/dart/compiler/CompilerTestCase.java
+++ b/compiler/javatests/com/google/dart/compiler/CompilerTestCase.java
@@ -273,4 +273,57 @@ public abstract class CompilerTestCase extends TestCase {
DartCompilerListener listener) {
return new DartScannerParserContext(src, sourceCode, listener);
}
+
+ protected static class ErrorExpectation {
+ final ErrorCode errorCode;
+ final int line;
+ final int column;
+ final int length;
+
+ public ErrorExpectation(ErrorCode errorCode, int line, int column, int length) {
+ this.errorCode = errorCode;
+ this.line = line;
+ this.column = column;
+ this.length = length;
+ }
+ }
+
+ protected static ErrorExpectation errEx(ErrorCode errorCode, int line, int column, int length) {
+ return new ErrorExpectation(errorCode, line, column, length);
+ }
+
+ /**
+ * Asserts that given list of {@link DartCompilationError} is exactly same as expected.
+ */
+ protected static void assertErrors(List<DartCompilationError> errors,
+ ErrorExpectation... expectedErrors) {
+ // count of errors
+ if (errors.size() != expectedErrors.length) {
+ fail(String.format(
+ "Expected %s errors, but got %s: %s",
+ expectedErrors.length,
+ errors.size(),
+ errors));
+ }
+ // content of errors
+ for (int i = 0; i < expectedErrors.length; i++) {
+ ErrorExpectation expectedError = expectedErrors[i];
+ DartCompilationError actualError = errors.get(i);
+ if (actualError.getErrorCode() != expectedError.errorCode
+ || actualError.getLineNumber() != expectedError.line
+ || actualError.getColumnNumber() != expectedError.column
+ || actualError.getLength() != expectedError.length) {
+ fail(String.format(
+ "Expected %s:%d:%d/%d, but got %s:%d:%d/%d",
+ expectedError.errorCode,
+ expectedError.line,
+ expectedError.column,
+ expectedError.length,
+ actualError.getErrorCode(),
+ actualError.getLineNumber(),
+ actualError.getColumnNumber(),
+ actualError.getLength()));
+ }
+ }
+ }
}

Powered by Google App Engine
This is Rietveld 408576698