catch error of string comparison in JetDiagnosticTest
This commit is contained in:
@@ -53,7 +53,8 @@ public class JetDiagnosticsTest extends JetLiteFixture {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getActualText(BindingContext bindingContext, StringBuilder actualText) {
|
public boolean getActualText(BindingContext bindingContext, StringBuilder actualText) {
|
||||||
|
final boolean ok[] = { true };
|
||||||
CheckerTestUtil.diagnosticsDiff(diagnosedRanges, CheckerTestUtil.getDiagnosticsIncludingSyntaxErrors(bindingContext, jetFile), new CheckerTestUtil.DiagnosticDiffCallbacks() {
|
CheckerTestUtil.diagnosticsDiff(diagnosedRanges, CheckerTestUtil.getDiagnosticsIncludingSyntaxErrors(bindingContext, jetFile), new CheckerTestUtil.DiagnosticDiffCallbacks() {
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
@@ -65,16 +66,19 @@ public class JetDiagnosticsTest extends JetLiteFixture {
|
|||||||
public void missingDiagnostic(String type, int expectedStart, int expectedEnd) {
|
public void missingDiagnostic(String type, int expectedStart, int expectedEnd) {
|
||||||
String message = "Missing " + type + DiagnosticUtils.atLocation(jetFile, new TextRange(expectedStart, expectedEnd));
|
String message = "Missing " + type + DiagnosticUtils.atLocation(jetFile, new TextRange(expectedStart, expectedEnd));
|
||||||
System.err.println(message);
|
System.err.println(message);
|
||||||
|
ok[0] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void unexpectedDiagnostic(String type, int actualStart, int actualEnd) {
|
public void unexpectedDiagnostic(String type, int actualStart, int actualEnd) {
|
||||||
String message = "Unexpected " + type + DiagnosticUtils.atLocation(jetFile, new TextRange(actualStart, actualEnd));
|
String message = "Unexpected " + type + DiagnosticUtils.atLocation(jetFile, new TextRange(actualStart, actualEnd));
|
||||||
System.err.println(message);
|
System.err.println(message);
|
||||||
|
ok[0] = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
actualText.append(CheckerTestUtil.addDiagnosticMarkersToText(jetFile, bindingContext, AnalyzingUtils.getSyntaxErrorRanges(jetFile)));
|
actualText.append(CheckerTestUtil.addDiagnosticMarkersToText(jetFile, bindingContext, AnalyzingUtils.getSyntaxErrorRanges(jetFile)));
|
||||||
|
return ok[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -108,12 +112,16 @@ public class JetDiagnosticsTest extends JetLiteFixture {
|
|||||||
bindingContext = AnalyzingUtils.analyzeFiles(getProject(), Configuration.EMPTY, jetFiles, Predicates.<PsiFile>alwaysTrue(), JetControlFlowDataTraceFactory.EMPTY);
|
bindingContext = AnalyzingUtils.analyzeFiles(getProject(), Configuration.EMPTY, jetFiles, Predicates.<PsiFile>alwaysTrue(), JetControlFlowDataTraceFactory.EMPTY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean ok = true;
|
||||||
|
|
||||||
StringBuilder actualText = new StringBuilder();
|
StringBuilder actualText = new StringBuilder();
|
||||||
for (TestFile testFileFile : testFileFiles) {
|
for (TestFile testFileFile : testFileFiles) {
|
||||||
testFileFile.getActualText(bindingContext, actualText);
|
ok &= testFileFile.getActualText(bindingContext, actualText);
|
||||||
}
|
}
|
||||||
|
|
||||||
assertEquals(expectedText, actualText.toString());
|
assertEquals(expectedText, actualText.toString());
|
||||||
|
|
||||||
|
assertTrue("something is wrong is this test", ok);
|
||||||
}
|
}
|
||||||
|
|
||||||
// private void convert(File src, File dest) throws IOException {
|
// private void convert(File src, File dest) throws IOException {
|
||||||
|
|||||||
Reference in New Issue
Block a user