diff options
Diffstat (limited to 'test')
17 files changed, 61 insertions, 25 deletions
diff --git a/test/core/src/lombok/AbstractRunTests.java b/test/core/src/lombok/AbstractRunTests.java index 7d5992be..7bf2f452 100644 --- a/test/core/src/lombok/AbstractRunTests.java +++ b/test/core/src/lombok/AbstractRunTests.java @@ -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; diff --git a/test/core/src/lombok/DirectoryRunner.java b/test/core/src/lombok/DirectoryRunner.java index 89fe6ab0..f84198f8 100644 --- a/test/core/src/lombok/DirectoryRunner.java +++ b/test/core/src/lombok/DirectoryRunner.java @@ -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 { diff --git a/test/pretty/resource/after/Annotation.java b/test/pretty/resource/after/Annotation.java index 06fe62b3..6b3b35b8 100644 --- a/test/pretty/resource/after/Annotation.java +++ b/test/pretty/resource/after/Annotation.java @@ -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) { } diff --git a/test/pretty/resource/before/Annotation.java b/test/pretty/resource/before/Annotation.java index 24868acd..edd1a5e7 100644 --- a/test/pretty/resource/before/Annotation.java +++ b/test/pretty/resource/before/Annotation.java @@ -1,4 +1,3 @@ -//ignore @SuppressWarnings("all") class Annotation { @Override diff --git a/test/transform/resource/after-delombok/ValErrors.java b/test/transform/resource/after-delombok/ValErrors.java index 5ac785ab..770a7e95 100644 --- a/test/transform/resource/after-delombok/ValErrors.java +++ b/test/transform/resource/after-delombok/ValErrors.java @@ -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"}; } }
\ No newline at end of file diff --git a/test/transform/resource/after-delombok/ValWeirdTypes.java b/test/transform/resource/after-delombok/ValWeirdTypes.java index 66212906..34beb80b 100644 --- a/test/transform/resource/after-delombok/ValWeirdTypes.java +++ b/test/transform/resource/after-delombok/ValWeirdTypes.java @@ -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]; + } }
\ No newline at end of file diff --git a/test/transform/resource/after-ecj/ValComplex.java b/test/transform/resource/after-ecj/ValComplex.java new file mode 100644 index 00000000..cb06d3c1 --- /dev/null +++ b/test/transform/resource/after-ecj/ValComplex.java @@ -0,0 +1 @@ +//ignore
\ No newline at end of file diff --git a/test/transform/resource/after-ecj/ValErrors.java b/test/transform/resource/after-ecj/ValErrors.java new file mode 100644 index 00000000..cb06d3c1 --- /dev/null +++ b/test/transform/resource/after-ecj/ValErrors.java @@ -0,0 +1 @@ +//ignore
\ No newline at end of file diff --git a/test/transform/resource/after-ecj/ValInFor.java b/test/transform/resource/after-ecj/ValInFor.java new file mode 100644 index 00000000..cb06d3c1 --- /dev/null +++ b/test/transform/resource/after-ecj/ValInFor.java @@ -0,0 +1 @@ +//ignore
\ No newline at end of file diff --git a/test/transform/resource/after-ecj/ValLessSimple.java b/test/transform/resource/after-ecj/ValLessSimple.java new file mode 100644 index 00000000..cb06d3c1 --- /dev/null +++ b/test/transform/resource/after-ecj/ValLessSimple.java @@ -0,0 +1 @@ +//ignore
\ No newline at end of file diff --git a/test/transform/resource/after-ecj/ValSimple.java b/test/transform/resource/after-ecj/ValSimple.java new file mode 100644 index 00000000..cb06d3c1 --- /dev/null +++ b/test/transform/resource/after-ecj/ValSimple.java @@ -0,0 +1 @@ +//ignore
\ No newline at end of file diff --git a/test/transform/resource/after-ecj/ValWeirdTypes.java b/test/transform/resource/after-ecj/ValWeirdTypes.java new file mode 100644 index 00000000..cb06d3c1 --- /dev/null +++ b/test/transform/resource/after-ecj/ValWeirdTypes.java @@ -0,0 +1 @@ +//ignore
\ No newline at end of file diff --git a/test/transform/resource/before/ValErrors.java b/test/transform/resource/before/ValErrors.java index 742bca6d..7c5c0a8b 100644 --- a/test/transform/resource/before/ValErrors.java +++ b/test/transform/resource/before/ValErrors.java @@ -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"}; + } }
\ No newline at end of file diff --git a/test/transform/resource/before/ValWeirdTypes.java b/test/transform/resource/before/ValWeirdTypes.java index 6f6eb9db..855fb91f 100644 --- a/test/transform/resource/before/ValWeirdTypes.java +++ b/test/transform/resource/before/ValWeirdTypes.java @@ -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]; + } }
\ No newline at end of file diff --git a/test/transform/resource/messages-delombok/ValErrors.java.messages b/test/transform/resource/messages-delombok/ValErrors.java.messages index feba6912..ca7baeab 100644 --- a/test/transform/resource/messages-delombok/ValErrors.java.messages +++ b/test/transform/resource/messages-delombok/ValErrors.java.messages @@ -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 { ... }) diff --git a/test/transform/resource/messages-idempotent/ValErrors.java.messages b/test/transform/resource/messages-idempotent/ValErrors.java.messages new file mode 100644 index 00000000..ebeee317 --- /dev/null +++ b/test/transform/resource/messages-idempotent/ValErrors.java.messages @@ -0,0 +1 @@ +6:21 ERROR 'val' is not compatible with array initializer expressions. Use the full form (new int[] { ... } instead of just { ... }) diff --git a/test/transform/src/lombok/transform/TestLombokFilesIdempotent.java b/test/transform/src/lombok/transform/TestLombokFilesIdempotent.java index 63d34820..6a874bfc 100644 --- a/test/transform/src/lombok/transform/TestLombokFilesIdempotent.java +++ b/test/transform/src/lombok/transform/TestLombokFilesIdempotent.java @@ -40,6 +40,11 @@ public class TestLombokFilesIdempotent implements DirectoryRunner.TestParams { } @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; - } } |