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

Unified Diff: compiler/javatests/com/google/dart/compiler/resolver/NegativeResolverTest.java

Issue 8479041: https://code.google.com/p/dart/issues/detail?id=255 (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' 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/resolver/NegativeResolverTest.java
===================================================================
--- compiler/javatests/com/google/dart/compiler/resolver/NegativeResolverTest.java (revision 1268)
+++ compiler/javatests/com/google/dart/compiler/resolver/NegativeResolverTest.java (working copy)
@@ -10,6 +10,7 @@
import com.google.dart.compiler.ast.DartUnit;
import com.google.dart.compiler.testing.TestCompilerContext;
+import java.net.URL;
import java.util.ArrayList;
import java.util.List;
@@ -22,29 +23,50 @@
final ErrorCode errorCode;
final int line;
final int column;
+
public ErrorExpectation(ErrorCode errorCode, int line, int column) {
this.errorCode = errorCode;
this.line = line;
this.column = column;
}
-
}
-
+
private static ErrorExpectation errEx(ErrorCode errorCode, int line, int column) {
return new ErrorExpectation(errorCode, line, column);
-
}
-
+
public void checkNumErrors(String fileName, int expectedErrorCount) {
DartUnit unit = parseUnit(fileName);
resolve(unit);
assertEquals(new ArrayList<DartCompilationError>(), typeErrors);
if (errors.size() != expectedErrorCount) {
- fail(String.format("Expected %s errors, but got %s: %s",
- expectedErrorCount, errors.size(), errors));
+ fail(String.format("Expected %s errors, but got %s: %s", expectedErrorCount, errors.size(),
+ errors));
}
}
-
+
+ public void checkNumErrors(String fileName, ErrorExpectation ...expectedErrors) {
+ DartUnit unit = parseUnit(fileName);
+ resolve(unit);
+ assertEquals(expectedErrors.length, errors.size());
+ 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) {
+ fail(String.format(
+ "Expected %s:%s:%s, but got %s:%s:%s",
+ expectedError.errorCode,
+ expectedError.line,
+ expectedError.column,
+ actualError.getErrorCode(),
+ actualError.getLineNumber(),
+ actualError.getColumnNumber()));
+ }
+ }
+ }
+
private void resolve(DartUnit unit) {
unit.addTopLevelNode(ResolverTestCase.makeClass("int", null));
unit.addTopLevelNode(ResolverTestCase.makeClass("Object", null));
@@ -54,7 +76,7 @@
unit.addTopLevelNode(ResolverTestCase.makeClass("Map", null, "K", "V"));
ResolverTestCase.resolve(unit, getContext());
}
-
+
/**
* Parses given Dart source, runs {@link Resolver} and checks that expected errors were generated.
*/
@@ -86,7 +108,7 @@
actualError.getColumnNumber()));
}
}
- }
+ }
public void testInitializer1() {
checkNumErrors("Initializer1NegativeTest.dart", 1);
@@ -253,7 +275,12 @@
public void testRawTypesNegativeTest() {
checkNumErrors("RawTypesNegativeTest.dart", 4);
}
-
+
+ public void testSuperMultipleInvocationsTest() {
+ checkNumErrors("SuperMultipleInvocationsTest.dart",
+ errEx(ResolverErrorCode.SUPER_INVOCATION_NOT_UNIQUE, 14, 52));
+ }
+
private TestCompilerContext getContext() {
return new TestCompilerContext() {
@Override

Powered by Google App Engine
This is Rietveld 408576698