mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-13 04:15:06 +00:00
refactored the tests to prepare running ecj as well as delombok.
This commit is contained in:
1 parent
1a9f8f168a
commit
59e585a0c6
63 files changed
+386
-186
No files matched your search
@@ -168,7 +168,7 @@ the common tasks and can be called on to run the main aspects of all the sub-scr
|
||||
<srcdir dir="src/installer" />
|
||||
<srcdir dir="src/delombok" />
|
||||
<srcdir dir="experimental/src" />
|
||||
<srcdir dir="test/delombok/src" />
|
||||
<srcdir dir="test/transform/src" />
|
||||
<srcdir dir="test/core/src" />
|
||||
<conf name="build" sources="contrib" />
|
||||
<conf name="test" sources="contrib" />
|
||||
@@ -206,11 +206,11 @@ the common tasks and can be called on to run the main aspects of all the sub-scr
|
||||
<classpath refid="test.path" />
|
||||
<classpath path="build/lombok" />
|
||||
<src path="test/core/src" />
|
||||
<src path="test/delombok/src" />
|
||||
<src path="test/transform/src" />
|
||||
</ivy:compile>
|
||||
<copy todir="build/tests">
|
||||
<fileset dir="test/pretty/resource" />
|
||||
<fileset dir="test/delombok/resource" />
|
||||
<fileset dir="test/transform/resource" />
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
@@ -224,7 +224,7 @@ the common tasks and can be called on to run the main aspects of all the sub-scr
|
||||
<fileset dir="test/core/src">
|
||||
<include name="**/Test*.java" />
|
||||
</fileset>
|
||||
<fileset dir="test/delombok/src">
|
||||
<fileset dir="test/transform/src">
|
||||
<include name="**/Test*.java" />
|
||||
</fileset>
|
||||
</batchtest>
|
||||
|
||||
@@ -0,0 +1,136 @@
|
||||
/*
|
||||
* Copyright © 2009-2010 Reinier Zwitserloot and Roel Spilker.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package lombok;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.util.ArrayList;
|
||||
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 {
|
||||
StringBuilder messages = new StringBuilder();
|
||||
StringWriter result = new StringWriter();
|
||||
transformCode(messages, result, file);
|
||||
compare(
|
||||
file.getName(),
|
||||
readFile(params.getAfterDirectory(), file, false),
|
||||
result.toString(),
|
||||
readFile(params.getMessagesDirectory(), file, true),
|
||||
messages.toString(),
|
||||
params.printErrors());
|
||||
}
|
||||
|
||||
protected abstract void transformCode(StringBuilder message, StringWriter result, File file) throws Throwable;
|
||||
|
||||
protected String readFile(File file) throws IOException {
|
||||
BufferedReader reader;
|
||||
try {
|
||||
reader = new BufferedReader(new FileReader(file));
|
||||
} catch (FileNotFoundException e) {
|
||||
return "";
|
||||
}
|
||||
StringBuilder result = new StringBuilder();
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
result.append(line);
|
||||
result.append(LINE_SEPARATOR);
|
||||
}
|
||||
reader.close();
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
private String readFile(File dir, File file, boolean messages) throws IOException {
|
||||
if (dir == null) return "";
|
||||
return readFile(new File(dir, file.getName() + (messages ? ".messages" : "")));
|
||||
}
|
||||
|
||||
private void compare(String name, String expectedFile, String actualFile, String expectedMessages, String actualMessages, boolean printErrors) throws Throwable {
|
||||
try {
|
||||
compareContent(name, expectedFile, actualFile);
|
||||
} catch (Throwable e) {
|
||||
if (printErrors) {
|
||||
System.out.println("***** " + name + " *****");
|
||||
System.out.println(e.getMessage());
|
||||
System.out.println("**** Expected ******");
|
||||
System.out.println(expectedFile);
|
||||
System.out.println("**** Actual ******");
|
||||
System.out.println(actualFile);
|
||||
System.out.println("*******************");
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
try {
|
||||
compareContent(name, expectedMessages, actualMessages);
|
||||
}
|
||||
catch (Throwable e) {
|
||||
if (printErrors) {
|
||||
System.out.println("***** " + name + " *****");
|
||||
System.out.println(e.getMessage());
|
||||
System.out.println("**** Expected ******");
|
||||
System.out.println(expectedMessages);
|
||||
System.out.println("**** Actual ******");
|
||||
System.out.println(actualMessages);
|
||||
System.out.println("*******************");
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
private static void compareContent(String name, String expectedFile, String actualFile) {
|
||||
String[] expectedLines = expectedFile.split("(\\r?\\n)");
|
||||
String[] actualLines = actualFile.split("(\\r?\\n)");
|
||||
if (actualLines[0].startsWith("// Generated by delombok at ")) {
|
||||
actualLines[0] = "";
|
||||
}
|
||||
expectedLines = removeBlanks(expectedLines);
|
||||
actualLines = removeBlanks(actualLines);
|
||||
int size = Math.min(expectedLines.length, actualLines.length);
|
||||
for (int i = 0; i < size; i++) {
|
||||
String expected = expectedLines[i];
|
||||
String actual = actualLines[i];
|
||||
assertEquals(String.format("Difference in %s on line %d", name, i + 1), expected, actual);
|
||||
}
|
||||
if (expectedLines.length > actualLines.length) {
|
||||
fail(String.format("Missing line %d in generated %s: %s", size + 1, name, expectedLines[size]));
|
||||
}
|
||||
if (expectedLines.length < actualLines.length) {
|
||||
fail(String.format("Extra line %d in generated %s: %s", size + 1, name, actualLines[size]));
|
||||
}
|
||||
}
|
||||
|
||||
private static String[] removeBlanks(String[] in) {
|
||||
List<String> out = new ArrayList<String>();
|
||||
for (String s : in) {
|
||||
if (!s.trim().isEmpty()) out.add(s);
|
||||
}
|
||||
return out.toArray(new String[0]);
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,24 @@
|
||||
/*
|
||||
* Copyright © 2009-2010 Reinier Zwitserloot and Roel Spilker.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package lombok;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
@@ -6,7 +27,6 @@ import java.io.FileFilter;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
@@ -16,6 +36,17 @@ import org.junit.runner.notification.Failure;
|
||||
import org.junit.runner.notification.RunNotifier;
|
||||
|
||||
public class DirectoryRunner extends Runner {
|
||||
public enum Compiler {
|
||||
DELOMBOK, JAVAC, ECJ;
|
||||
}
|
||||
|
||||
public interface TestParams {
|
||||
Compiler getCompiler();
|
||||
boolean printErrors();
|
||||
File getBeforeDirectory();
|
||||
File getAfterDirectory();
|
||||
File getMessagesDirectory();
|
||||
}
|
||||
|
||||
private static final FileFilter JAVA_FILE_FILTER = new FileFilter() {
|
||||
@Override public boolean accept(File file) {
|
||||
@@ -26,11 +57,13 @@ public class DirectoryRunner extends Runner {
|
||||
private final Description description;
|
||||
private final Map<String, Description> tests = new TreeMap<String, Description>();
|
||||
private final Throwable failure;
|
||||
private File beforeDirectory;
|
||||
private File afterDirectory;
|
||||
private final TestParams params;
|
||||
|
||||
public DirectoryRunner(Class<?> testClass) {
|
||||
public DirectoryRunner(Class<?> testClass) throws Exception {
|
||||
description = Description.createSuiteDescription(testClass);
|
||||
|
||||
this.params = (TestParams) testClass.newInstance();
|
||||
|
||||
Throwable error = null;
|
||||
try {
|
||||
addTests(testClass);
|
||||
@@ -40,26 +73,20 @@ public class DirectoryRunner extends Runner {
|
||||
}
|
||||
this.failure = error;
|
||||
}
|
||||
|
||||
|
||||
private void addTests(Class<?> testClass) throws Exception {
|
||||
Method beforeMethod = testClass.getDeclaredMethod("getBeforeDirectory");
|
||||
beforeDirectory = (File) beforeMethod.invoke(null);
|
||||
|
||||
Method afterMethod = testClass.getDeclaredMethod("getAfterDirectory");
|
||||
afterDirectory = (File) afterMethod.invoke(null);
|
||||
|
||||
for (File file : beforeDirectory.listFiles(JAVA_FILE_FILTER)) {
|
||||
for (File file : params.getBeforeDirectory().listFiles(JAVA_FILE_FILTER)) {
|
||||
Description testDescription = Description.createTestDescription(testClass, file.getName());
|
||||
description.addChild(testDescription);
|
||||
tests.put(file.getName(), testDescription);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Description getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void run(RunNotifier notifier) {
|
||||
if (failure != null) {
|
||||
@@ -83,16 +110,25 @@ public class DirectoryRunner extends Runner {
|
||||
notifier.fireTestFinished(testDescription);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private boolean runTest(String fileName) throws Throwable {
|
||||
File file = new File(beforeDirectory, fileName);
|
||||
File file = new File(params.getBeforeDirectory(), fileName);
|
||||
if (mustIgnore(file)) {
|
||||
return false;
|
||||
}
|
||||
RunTestsViaDelombok.compareFile(beforeDirectory, afterDirectory, file);
|
||||
switch (params.getCompiler()) {
|
||||
case DELOMBOK:
|
||||
new RunTestsViaDelombok().compareFile(params, file);
|
||||
break;
|
||||
case ECJ:
|
||||
new RunTestsViaEcj().compareFile(params, file);
|
||||
break;
|
||||
case JAVAC:
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private boolean mustIgnore(File file) throws FileNotFoundException, IOException {
|
||||
BufferedReader reader = new BufferedReader(new FileReader(file));
|
||||
String line = reader.readLine();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright © 2009 Reinier Zwitserloot and Roel Spilker.
|
||||
* Copyright © 2009-2010 Reinier Zwitserloot and Roel Spilker.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -21,17 +21,8 @@
|
||||
*/
|
||||
package lombok;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.tools.Diagnostic;
|
||||
@@ -40,124 +31,21 @@ import javax.tools.JavaFileObject;
|
||||
|
||||
import lombok.delombok.Delombok;
|
||||
|
||||
public class RunTestsViaDelombok {
|
||||
private static final FileFilter JAVA_FILE_FILTER = new FileFilter() {
|
||||
@Override public boolean accept(File file) {
|
||||
return file.isFile() && file.getName().endsWith(".java");
|
||||
}
|
||||
};
|
||||
|
||||
private static Delombok delombok = new Delombok();
|
||||
private static volatile boolean printErrors = false;
|
||||
public class RunTestsViaDelombok extends AbstractRunTests {
|
||||
private Delombok delombok = new Delombok();
|
||||
|
||||
private static final String LINE_SEPARATOR = System.getProperty("line.separator");
|
||||
|
||||
public static void runComparison(File beforeDir, File afterDir) throws Throwable {
|
||||
File[] listFiles = beforeDir.listFiles(JAVA_FILE_FILTER);
|
||||
|
||||
for (File file : listFiles) {
|
||||
compareFile(beforeDir, afterDir, file);
|
||||
}
|
||||
}
|
||||
|
||||
public static void compareFile(File beforeDir, File afterDir, File file) throws Throwable {
|
||||
@Override
|
||||
public void transformCode(final StringBuilder messages, StringWriter result, File file) throws Throwable {
|
||||
delombok.setVerbose(false);
|
||||
delombok.setForceProcess(true);
|
||||
delombok.setCharset("UTF-8");
|
||||
|
||||
final StringBuilder messages = new StringBuilder();
|
||||
|
||||
delombok.setDiagnosticsListener(new DiagnosticListener<JavaFileObject>() {
|
||||
@Override public void report(Diagnostic<? extends JavaFileObject> d) {
|
||||
messages.append(String.format("%d:%d %s %s\n", d.getLineNumber(), d.getColumnNumber(), d.getKind(), d.getMessage(Locale.ENGLISH)));
|
||||
}
|
||||
});
|
||||
|
||||
StringWriter writer = new StringWriter();
|
||||
delombok.delombok(file.getAbsolutePath(), writer);
|
||||
compare(file.getName(), readFile(afterDir, file, false), writer.toString(), readFile(beforeDir, file, true), messages.toString());
|
||||
delombok.delombok(file.getAbsolutePath(), result);
|
||||
}
|
||||
|
||||
public static void printErrors(boolean print) {
|
||||
printErrors = print;
|
||||
}
|
||||
|
||||
private static void compare(String name, String expectedFile, String actualFile, String expectedMessages, String actualMessages) throws Throwable {
|
||||
try {
|
||||
compareContent(name, expectedFile, actualFile);
|
||||
}
|
||||
catch (Throwable e) {
|
||||
if (printErrors) {
|
||||
System.out.println("***** " + name + " *****");
|
||||
System.out.println(e.getMessage());
|
||||
System.out.println("**** Expected ******");
|
||||
System.out.println(expectedFile);
|
||||
System.out.println("**** Actual ******");
|
||||
System.out.println(actualFile);
|
||||
System.out.println("*******************");
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
try {
|
||||
compareContent(name, expectedMessages, actualMessages);
|
||||
}
|
||||
catch (Throwable e) {
|
||||
if (printErrors) {
|
||||
System.out.println("***** " + name + " *****");
|
||||
System.out.println(e.getMessage());
|
||||
System.out.println("**** Expected ******");
|
||||
System.out.println(expectedMessages);
|
||||
System.out.println("**** Actual ******");
|
||||
System.out.println(actualMessages);
|
||||
System.out.println("*******************");
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
private static void compareContent(String name, String expectedFile, String actualFile) {
|
||||
String[] expectedLines = expectedFile.split("(\\r?\\n)");
|
||||
String[] actualLines = actualFile.split("(\\r?\\n)");
|
||||
if (actualLines[0].startsWith("// Generated by delombok at ")) {
|
||||
actualLines[0] = "";
|
||||
}
|
||||
expectedLines = removeBlanks(expectedLines);
|
||||
actualLines = removeBlanks(actualLines);
|
||||
int size = Math.min(expectedLines.length, actualLines.length);
|
||||
for (int i = 0; i < size; i++) {
|
||||
String expected = expectedLines[i];
|
||||
String actual = actualLines[i];
|
||||
assertEquals(String.format("Difference in %s on line %d", name, i + 1), expected, actual);
|
||||
}
|
||||
if (expectedLines.length > actualLines.length) {
|
||||
fail(String.format("Missing line %d in generated %s: %s", size + 1, name, expectedLines[size]));
|
||||
}
|
||||
if (expectedLines.length < actualLines.length) {
|
||||
fail(String.format("Extra line %d in generated %s: %s", size + 1, name, actualLines[size]));
|
||||
}
|
||||
}
|
||||
|
||||
private static String readFile(File afterDir, File file, boolean messages) throws IOException {
|
||||
BufferedReader reader;
|
||||
try {
|
||||
reader = new BufferedReader(new FileReader(new File(afterDir, file.getName() + (messages ? ".messages" : ""))));
|
||||
} catch (FileNotFoundException e) {
|
||||
return "";
|
||||
}
|
||||
StringBuilder result = new StringBuilder();
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
result.append(line);
|
||||
result.append(LINE_SEPARATOR);
|
||||
}
|
||||
reader.close();
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
private static String[] removeBlanks(String[] in) {
|
||||
List<String> out = new ArrayList<String>();
|
||||
for (String s : in) {
|
||||
if (!s.trim().isEmpty()) out.add(s);
|
||||
}
|
||||
return out.toArray(new String[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package lombok;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.StringWriter;
|
||||
import java.util.Locale;
|
||||
|
||||
import lombok.eclipse.TransformEclipseAST;
|
||||
|
||||
import org.eclipse.jdt.core.compiler.CategorizedProblem;
|
||||
import org.eclipse.jdt.internal.compiler.CompilationResult;
|
||||
import org.eclipse.jdt.internal.compiler.IErrorHandlingPolicy;
|
||||
import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
|
||||
import org.eclipse.jdt.internal.compiler.batch.CompilationUnit;
|
||||
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
|
||||
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
|
||||
import org.eclipse.jdt.internal.compiler.parser.Parser;
|
||||
import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory;
|
||||
import org.eclipse.jdt.internal.compiler.problem.ProblemReporter;
|
||||
|
||||
public class RunTestsViaEcj extends AbstractRunTests {
|
||||
protected static CompilerOptions ecjCompilerOptions() {
|
||||
CompilerOptions options = new CompilerOptions();
|
||||
options.complianceLevel = ClassFileConstants.JDK1_6;
|
||||
options.sourceLevel = ClassFileConstants.JDK1_6;
|
||||
options.targetJDK = ClassFileConstants.JDK1_6;
|
||||
options.parseLiteralExpressionsAsConstants = true;
|
||||
return options;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void transformCode(final StringBuilder messages, StringWriter result, File file) throws Throwable {
|
||||
ProblemReporter problemReporter = new ProblemReporter(new IErrorHandlingPolicy() {
|
||||
public boolean proceedOnErrors() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean stopOnFirstError() {
|
||||
return false;
|
||||
}
|
||||
}, ecjCompilerOptions(), new DefaultProblemFactory(Locale.ENGLISH));
|
||||
|
||||
Parser parser = new Parser(problemReporter, true);
|
||||
String source = readFile(file);
|
||||
CompilationUnit sourceUnit = new CompilationUnit(source.toCharArray(), file.getName(), "UTF-8");
|
||||
CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, 0);
|
||||
CompilationUnitDeclaration cud = parser.parse(sourceUnit, compilationResult);
|
||||
|
||||
TransformEclipseAST.transform(parser, cud);
|
||||
|
||||
for (CategorizedProblem p : compilationResult.getErrors()) {
|
||||
messages.append(p.toString()).append("\n");
|
||||
}
|
||||
|
||||
result.append(cud.toString());
|
||||
}
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,37 @@
|
||||
class DataExtended {
|
||||
int x;
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public DataExtended() {
|
||||
}
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public int getX() {
|
||||
return this.x;
|
||||
}
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public void setX(final int x) {
|
||||
this.x = x;
|
||||
}
|
||||
@java.lang.Override
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public boolean equals(final java.lang.Object o) {
|
||||
if (o == this) return true;
|
||||
if (o == null) return false;
|
||||
if (o.getClass() != this.getClass()) return false;
|
||||
final DataExtended other = (DataExtended)o;
|
||||
if (this.getX() != other.getX()) return false;
|
||||
return true;
|
||||
}
|
||||
@java.lang.Override
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public int hashCode() {
|
||||
final int PRIME = 31;
|
||||
int result = 1;
|
||||
result = result * PRIME + this.getX();
|
||||
return result;
|
||||
}
|
||||
@java.lang.Override
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public java.lang.String toString() {
|
||||
return "DataExtended(x=" + this.x + ")";
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -17,7 +17,7 @@ class DataIgnore {
|
||||
if (o == null) return false;
|
||||
if (o.getClass() != this.getClass()) return false;
|
||||
final DataIgnore other = (DataIgnore)o;
|
||||
if (this.x != other.x) return false;
|
||||
if (this.getX() != other.getX()) return false;
|
||||
return true;
|
||||
}
|
||||
@java.lang.Override
|
||||
@@ -25,12 +25,12 @@ class DataIgnore {
|
||||
public int hashCode() {
|
||||
final int PRIME = 31;
|
||||
int result = 1;
|
||||
result = result * PRIME + this.x;
|
||||
result = result * PRIME + this.getX();
|
||||
return result;
|
||||
}
|
||||
@java.lang.Override
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public java.lang.String toString() {
|
||||
return "DataIgnore(x=" + this.x + ")";
|
||||
return "DataIgnore(x=" + this.getX() + ")";
|
||||
}
|
||||
}
|
||||
+10
-10
@@ -25,8 +25,8 @@ class Data1 {
|
||||
if (o == null) return false;
|
||||
if (o.getClass() != this.getClass()) return false;
|
||||
final Data1 other = (Data1)o;
|
||||
if (this.x != other.x) return false;
|
||||
if (this.name == null ? other.name != null : !this.name.equals(other.name)) return false;
|
||||
if (this.getX() != other.getX()) return false;
|
||||
if (this.getName() == null ? other.getName() != null : !this.getName().equals(other.getName())) return false;
|
||||
return true;
|
||||
}
|
||||
@java.lang.Override
|
||||
@@ -34,14 +34,14 @@ class Data1 {
|
||||
public int hashCode() {
|
||||
final int PRIME = 31;
|
||||
int result = 1;
|
||||
result = result * PRIME + this.x;
|
||||
result = result * PRIME + (this.name == null ? 0 : this.name.hashCode());
|
||||
result = result * PRIME + this.getX();
|
||||
result = result * PRIME + (this.getName() == null ? 0 : this.getName().hashCode());
|
||||
return result;
|
||||
}
|
||||
@java.lang.Override
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public java.lang.String toString() {
|
||||
return "Data1(x=" + this.x + ", name=" + this.name + ")";
|
||||
return "Data1(x=" + this.getX() + ", name=" + this.getName() + ")";
|
||||
}
|
||||
}
|
||||
class Data2 {
|
||||
@@ -71,8 +71,8 @@ class Data2 {
|
||||
if (o == null) return false;
|
||||
if (o.getClass() != this.getClass()) return false;
|
||||
final Data2 other = (Data2)o;
|
||||
if (this.x != other.x) return false;
|
||||
if (this.name == null ? other.name != null : !this.name.equals(other.name)) return false;
|
||||
if (this.getX() != other.getX()) return false;
|
||||
if (this.getName() == null ? other.getName() != null : !this.getName().equals(other.getName())) return false;
|
||||
return true;
|
||||
}
|
||||
@java.lang.Override
|
||||
@@ -80,13 +80,13 @@ class Data2 {
|
||||
public int hashCode() {
|
||||
final int PRIME = 31;
|
||||
int result = 1;
|
||||
result = result * PRIME + this.x;
|
||||
result = result * PRIME + (this.name == null ? 0 : this.name.hashCode());
|
||||
result = result * PRIME + this.getX();
|
||||
result = result * PRIME + (this.getName() == null ? 0 : this.getName().hashCode());
|
||||
return result;
|
||||
}
|
||||
@java.lang.Override
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public java.lang.String toString() {
|
||||
return "Data2(x=" + this.x + ", name=" + this.name + ")";
|
||||
return "Data2(x=" + this.getX() + ", name=" + this.getName() + ")";
|
||||
}
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+8
-4
@@ -4,29 +4,33 @@ class ToStringOuter {
|
||||
class ToStringInner {
|
||||
final int y;
|
||||
@java.lang.Override
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public java.lang.String toString() {
|
||||
return "ToStringOuter.ToStringInner(y=" + y + ")";
|
||||
return "ToStringInner(y=" + this.y + ")";
|
||||
}
|
||||
}
|
||||
static class ToStringStaticInner {
|
||||
final int y;
|
||||
@java.lang.Override
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public java.lang.String toString() {
|
||||
return "ToStringOuter.ToStringStaticInner(y=" + y + ")";
|
||||
return "ToStringStaticInner(y=" + this.y + ")";
|
||||
}
|
||||
}
|
||||
class ToStringMiddle {
|
||||
class ToStringMoreInner {
|
||||
final String name;
|
||||
@java.lang.Override
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public java.lang.String toString() {
|
||||
return "ToStringOuter.ToStringMiddle.ToStringMoreInner(name=" + name + ")";
|
||||
return "ToStringMoreInner(name=" + this.name + ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public java.lang.String toString() {
|
||||
return "ToStringOuter(x=" + x + ", name=" + name + ")";
|
||||
return "ToStringOuter(x=" + this.x + ", name=" + this.name + ")";
|
||||
}
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,5 @@
|
||||
@lombok.Data
|
||||
@lombok.ToString(doNotUseGetters = true)
|
||||
class DataExtended {
|
||||
int x;
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
-1
@@ -1,4 +1,3 @@
|
||||
//ignore
|
||||
import lombok.ToString;
|
||||
@ToString class ToStringOuter {
|
||||
final int x;
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+23
-9
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright © 2009 Reinier Zwitserloot and Roel Spilker.
|
||||
* Copyright © 2009-2010 Reinier Zwitserloot and Roel Spilker.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -19,24 +19,38 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package lombok.delombok;
|
||||
package lombok.transform;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import lombok.DirectoryRunner;
|
||||
import lombok.RunTestsViaDelombok;
|
||||
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@RunWith(DirectoryRunner.class)
|
||||
public class TestLombokFilesIdempotent {
|
||||
|
||||
public static File getBeforeDirectory() {
|
||||
RunTestsViaDelombok.printErrors(true);
|
||||
public class TestLombokFilesIdempotent implements DirectoryRunner.TestParams {
|
||||
@Override
|
||||
public File getBeforeDirectory() {
|
||||
return getAfterDirectory();
|
||||
}
|
||||
|
||||
public static File getAfterDirectory() {
|
||||
return new File("test/delombok/resource/after");
|
||||
@Override
|
||||
public File getAfterDirectory() {
|
||||
return new File("test/transform/resource/after-delombok");
|
||||
}
|
||||
|
||||
@Override
|
||||
public DirectoryRunner.Compiler getCompiler() {
|
||||
return DirectoryRunner.Compiler.DELOMBOK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean printErrors() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getMessagesDirectory() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+18
-7
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright © 2009 Reinier Zwitserloot and Roel Spilker.
|
||||
* Copyright © 2009-2010 Reinier Zwitserloot and Roel Spilker.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -19,23 +19,34 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package lombok.delombok;
|
||||
package lombok.transform;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import lombok.DirectoryRunner;
|
||||
import lombok.RunTestsViaDelombok;
|
||||
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@RunWith(DirectoryRunner.class)
|
||||
public class TestSourceFiles {
|
||||
public static File getBeforeDirectory() {
|
||||
RunTestsViaDelombok.printErrors(true);
|
||||
public class TestSourceFiles implements DirectoryRunner.TestParams {
|
||||
public DirectoryRunner.Compiler getCompiler() {
|
||||
return DirectoryRunner.Compiler.DELOMBOK;
|
||||
}
|
||||
|
||||
public boolean printErrors() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public File getBeforeDirectory() {
|
||||
return new File("test/pretty/resource/before");
|
||||
}
|
||||
|
||||
public static File getAfterDirectory() {
|
||||
public File getAfterDirectory() {
|
||||
return new File("test/pretty/resource/after");
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getMessagesDirectory() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+24
-10
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright © 2009 Reinier Zwitserloot and Roel Spilker.
|
||||
* Copyright © 2009-2010 Reinier Zwitserloot and Roel Spilker.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -19,24 +19,38 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package lombok.delombok;
|
||||
package lombok.transform;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import lombok.DirectoryRunner;
|
||||
import lombok.RunTestsViaDelombok;
|
||||
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@RunWith(DirectoryRunner.class)
|
||||
public class TestLombokFiles {
|
||||
|
||||
public static File getBeforeDirectory() {
|
||||
RunTestsViaDelombok.printErrors(true);
|
||||
return new File("test/delombok/resource/before");
|
||||
public class TestWithDelombok implements DirectoryRunner.TestParams {
|
||||
@Override
|
||||
public DirectoryRunner.Compiler getCompiler() {
|
||||
return DirectoryRunner.Compiler.DELOMBOK;
|
||||
}
|
||||
|
||||
public static File getAfterDirectory() {
|
||||
return new File("test/delombok/resource/after");
|
||||
@Override
|
||||
public boolean printErrors() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getBeforeDirectory() {
|
||||
return new File("test/transform/resource/before");
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getAfterDirectory() {
|
||||
return new File("test/transform/resource/after-delombok");
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getMessagesDirectory() {
|
||||
return new File("test/transform/resource/messages-delombok");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user