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 a1426a146e7816b3da3cba13bdae8b352863df31..f7dfe4b495c3cc142d8eeafd776316e69b9bd059 100644 |
--- a/compiler/javatests/com/google/dart/compiler/CompilerTestCase.java |
+++ b/compiler/javatests/com/google/dart/compiler/CompilerTestCase.java |
@@ -12,6 +12,8 @@ import com.google.dart.compiler.ast.DartNode; |
import com.google.dart.compiler.ast.DartNodeTraverser; |
import com.google.dart.compiler.ast.DartUnit; |
import com.google.dart.compiler.ast.LibraryUnit; |
+import com.google.dart.compiler.common.ErrorExpectation; |
+import static com.google.dart.compiler.common.ErrorExpectation.assertErrors; |
import com.google.dart.compiler.parser.DartParser; |
import com.google.dart.compiler.parser.DartParserRunner; |
import com.google.dart.compiler.parser.DartScannerParserContext; |
@@ -303,66 +305,6 @@ public abstract class CompilerTestCase extends TestCase { |
assertErrors(errors, expectedErrors); |
} |
- 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) { |
- StringBuffer errorMessage = new StringBuffer(); |
- // count of errors |
- if (errors.size() != expectedErrors.length) { |
- String out = String.format( |
- "Expected %s errors, but got %s: %s", |
- expectedErrors.length, |
- errors.size(), |
- errors); |
- errorMessage.append(out + "\n"); |
- } |
- // 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) { |
- String out = 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()); |
- errorMessage.append(out + "\n"); |
- } |
- } |
- if (errorMessage.length() > 0) { |
- System.err.println(errorMessage); |
- fail(errorMessage.toString()); |
- } |
- } |
- |
/** |
* @return the {@link DartInvocation} with given source. This is inaccurate approach, but good |
* enough for specific tests. |