All tests pass! - The test framework has been updated a bit to fit with the new way delombok works.

This commit is contained in:
Reinier Zwitserloot committed 2010-11-10 22:19:46 +01:00
1 parent 2495668131
commit 632027249b
17 files changed
+61 -25

No files matched your search

+13 -3
View File
@@ -28,6 +28,7 @@ import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.StringReader;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.List;
@@ -35,17 +36,26 @@ import java.util.List;
public abstract class AbstractRunTests {
protected static final String LINE_SEPARATOR = System.getProperty("line.separator");
public void compareFile(DirectoryRunner.TestParams params, File file) throws Throwable {
public boolean compareFile(DirectoryRunner.TestParams params, File file) throws Throwable {
StringBuilder messages = new StringBuilder();
StringWriter writer = new StringWriter();
transformCode(messages, writer, file);
String expectedFile = readFile(params.getAfterDirectory(), file, false);
String expectedMessages = readFile(params.getMessagesDirectory(), file, true);
StringReader r = new StringReader(expectedFile);
BufferedReader br = new BufferedReader(r);
if ("//ignore".equals(br.readLine())) return false;
compare(
file.getName(),
readFile(params.getAfterDirectory(), file, false),
expectedFile,
writer.toString(),
readFile(params.getMessagesDirectory(), file, true),
expectedMessages,
messages.toString(),
params.printErrors());
return true;
}
protected abstract void transformCode(StringBuilder message, StringWriter result, File file) throws Throwable;
+3 -5
View File
@@ -118,15 +118,13 @@ public class DirectoryRunner extends Runner {
}
switch (params.getCompiler()) {
case DELOMBOK:
new RunTestsViaDelombok().compareFile(params, file);
break;
return new RunTestsViaDelombok().compareFile(params, file);
case ECJ:
new RunTestsViaEcj().compareFile(params, file);
break;
return new RunTestsViaEcj().compareFile(params, file);
default:
case JAVAC:
throw new UnsupportedOperationException();
}
return true;
}
private boolean mustIgnore(File file) throws FileNotFoundException, IOException {
+1 -1
View File
@@ -6,7 +6,7 @@ class Annotation {
}
public void method(@SuppressWarnings("unused") int x) {
}
public void method2(@SuppressWarnings(value = {"unused"}) int y) {
public void method2(@SuppressWarnings({"unused"}) int y) {
}
public void method3(@SuppressWarnings({"unused", "unchecked"}) int z) {
}
@@ -1,4 +1,3 @@
//ignore
@SuppressWarnings("all")
class Annotation {
@Override
@@ -1,8 +1,8 @@
public class ValErrors {
public void nullType() {
final val a = null;
}
public void unresolvableExpression() {
final val c = d;
final java.lang.Object c = d;
}
public void arrayInitializer() {
val e = {"foo", "bar"};
}
}
@@ -44,4 +44,14 @@ public class ValWeirdTypes<Z> {
final java.util.AbstractList<java.lang.String> d = c ? a : b;
java.util.RandomAccess confirm = c ? a : b;
}
public void nullType() {
final java.lang.Object nully = null;
}
public void testArrays() {
final int[] intArray = new int[]{1, 2, 3};
final java.lang.Object[][] multiDimArray = new Object[][]{{}};
final int[] copy = intArray;
final java.lang.Object[] single = multiDimArray[0];
final int singleInt = copy[0];
}
}
@@ -0,0 +1 @@
//ignore
@@ -0,0 +1 @@
//ignore
@@ -0,0 +1 @@
//ignore
@@ -0,0 +1 @@
//ignore
@@ -0,0 +1 @@
//ignore
@@ -0,0 +1 @@
//ignore
@@ -1,9 +1,9 @@
public class ValErrors {
public void nullType() {
val a = null;
}
public void unresolvableExpression() {
val c = d;
}
public void arrayInitializer() {
val e = { "foo", "bar"};
}
}
@@ -51,4 +51,16 @@ public class ValWeirdTypes<Z> {
val d = c ? a : b;
java.util.RandomAccess confirm = c ? a : b;
}
public void nullType() {
val nully = null;
}
public void testArrays() {
val intArray = new int[] {1, 2, 3};
val multiDimArray = new Object[][] {{}};
val copy = intArray;
val single = multiDimArray[0];
val singleInt = copy[0];
}
}
@@ -1,2 +1,2 @@
3:21 ERROR Cannot use 'val' here because initializer expression does not have a representable type: <nulltype>
7:21 ERROR Cannot use 'val' here because initializer expression does not have a representable type: Type cannot be resolved
3:21 ERROR Cannot use 'val' here because initializer expression does not have a representable type: Type cannot be resolved
7:21 ERROR 'val' is not compatible with array initializer expressions. Use the full form (new int[] { ... } instead of just { ... })
@@ -0,0 +1 @@
6:21 ERROR 'val' is not compatible with array initializer expressions. Use the full form (new int[] { ... } instead of just { ... })
@@ -39,6 +39,11 @@ public class TestLombokFilesIdempotent implements DirectoryRunner.TestParams {
return new File("test/transform/resource/after-delombok");
}
@Override
public File getMessagesDirectory() {
return new File("test/transform/resource/messages-idempotent");
}
@Override
public DirectoryRunner.Compiler getCompiler() {
return DirectoryRunner.Compiler.DELOMBOK;
@@ -48,9 +53,4 @@ public class TestLombokFilesIdempotent implements DirectoryRunner.TestParams {
public boolean printErrors() {
return true;
}
@Override
public File getMessagesDirectory() {
return null;
}
}