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

Unified Diff: compiler/javatests/com/google/dart/compiler/common/ErrorExpectation.java

Issue 9148026: Recompile unit with potential conflict/dependency on some top-level symbol. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix for compiling corelib, so NPE in TreeShaker Created 8 years, 11 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
Index: compiler/javatests/com/google/dart/compiler/common/ErrorExpectation.java
diff --git a/compiler/javatests/com/google/dart/compiler/common/ErrorExpectation.java b/compiler/javatests/com/google/dart/compiler/common/ErrorExpectation.java
index ef533db58d02d933b37b462b2d348dd3f53184e6..7312a0d0d0c7ebe43f109ea723fa8b98bc460361 100644
--- a/compiler/javatests/com/google/dart/compiler/common/ErrorExpectation.java
+++ b/compiler/javatests/com/google/dart/compiler/common/ErrorExpectation.java
@@ -1,7 +1,6 @@
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-
package com.google.dart.compiler.common;
import com.google.dart.compiler.DartCompilationError;
@@ -12,20 +11,30 @@ import junit.framework.Assert;
import java.util.List;
public class ErrorExpectation {
+ private final String sourceName;
final ErrorCode errorCode;
final int line;
final int column;
final int length;
- public ErrorExpectation(ErrorCode errorCode, int line, int column, int length) {
+ public ErrorExpectation(String sourceName, ErrorCode errorCode, int line, int column, int length) {
+ this.sourceName = sourceName;
this.errorCode = errorCode;
this.line = line;
this.column = column;
this.length = length;
}
+ public static ErrorExpectation errEx(String sourceName,
+ ErrorCode errorCode,
+ int line,
+ int column,
+ int length) {
+ return new ErrorExpectation(sourceName, errorCode, line, column, length);
+ }
+
public static ErrorExpectation errEx(ErrorCode errorCode, int line, int column, int length) {
- return new ErrorExpectation(errorCode, line, column, length);
+ return new ErrorExpectation(null, errorCode, line, column, length);
codefu 2012/01/19 21:48:54 Nit: could be "", which makes the code in assertEr
scheglov 2012/01/20 15:59:24 Done.
}
/**
@@ -46,23 +55,36 @@ public class ErrorExpectation {
} else {
// 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) {
+ ErrorExpectation expected = expectedErrors[i];
+ DartCompilationError error = errors.get(i);
+ String actualSourceName = error.getSource() != null ? error.getSource().getName() : "";
+ if (error.getErrorCode() != expected.errorCode
+ || error.getLineNumber() != expected.line
+ || error.getColumnNumber() != expected.column
+ || error.getLength() != expected.length
+ || !(expected.sourceName == null || expected.sourceName.equals(actualSourceName))) {
+ // Prepare names of sources.
+ String expectedSourceName;
+ if (expected.sourceName != null) {
+ expectedSourceName = expected.sourceName;
+ } else {
+ expectedSourceName = "";
+ actualSourceName = "";
+ }
+ // Add error mismatch.
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());
+ "Expected %s %s:%d:%d/%d, but got %s %s:%d:%d/%d",
+ expectedSourceName,
+ expected.errorCode,
+ expected.line,
+ expected.column,
+ expected.length,
+ actualSourceName,
+ error.getErrorCode(),
+ error.getLineNumber(),
+ error.getColumnNumber(),
+ error.getLength());
errorMessage.append(out + "\n");
}
}

Powered by Google App Engine
This is Rietveld 408576698