aboutsummaryrefslogtreecommitdiff
path: root/test/core/src/lombok
diff options
context:
space:
mode:
Diffstat (limited to 'test/core/src/lombok')
-rw-r--r--test/core/src/lombok/AbstractRunTests.java76
-rw-r--r--test/core/src/lombok/DirectoryRunner.java44
-rw-r--r--test/core/src/lombok/LombokTestSource.java165
-rw-r--r--test/core/src/lombok/RunAllTests.java4
-rw-r--r--test/core/src/lombok/RunTestsViaDelombok.java28
-rw-r--r--test/core/src/lombok/RunTestsViaEcj.java15
-rw-r--r--test/core/src/lombok/core/RunCoreTests.java31
-rw-r--r--test/core/src/lombok/core/TestSingulars.java56
8 files changed, 326 insertions, 93 deletions
diff --git a/test/core/src/lombok/AbstractRunTests.java b/test/core/src/lombok/AbstractRunTests.java
index a1f535b4..1a454585 100644
--- a/test/core/src/lombok/AbstractRunTests.java
+++ b/test/core/src/lombok/AbstractRunTests.java
@@ -35,9 +35,11 @@ import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
+import java.util.Map;
import org.junit.Assert;
+import lombok.DirectoryRunner.FileTester;
import lombok.core.AST;
import lombok.core.LombokConfiguration;
import lombok.core.LombokImmutableList;
@@ -53,51 +55,51 @@ public abstract class AbstractRunTests {
this.dumpActualFilesHere = findPlaceToDumpActualFiles();
}
- public boolean compareFile(DirectoryRunner.TestParams params, File file) throws Throwable {
+ public final FileTester createTester(final DirectoryRunner.TestParams params, final File file, String platform, int version) throws IOException {
ConfigurationKeysLoader.LoaderLoader.loadAllConfigurationKeys();
- final LombokTestSource sourceDirectives = LombokTestSource.readDirectives(file);
- if (sourceDirectives.isIgnore()) return false;
- if (!sourceDirectives.versionWithinLimit(params.getVersion())) return false;
- if (!sourceDirectives.versionWithinLimit(getClasspathVersion())) return false;
+ AssertionError directiveFailure = null;
+ LombokTestSource sourceDirectives = null;
+ try {
+ sourceDirectives = LombokTestSource.readDirectives(file);
+ if (sourceDirectives.isIgnore()) return null;
+ if (!sourceDirectives.versionWithinLimit(version)) return null;
+ if (!sourceDirectives.runOnPlatform(platform)) return null;
+ } catch (AssertionError ae) {
+ directiveFailure = ae;
+ }
String fileName = file.getName();
- LombokTestSource expected = LombokTestSource.read(params.getAfterDirectory(), params.getMessagesDirectory(), fileName);
+ final LombokTestSource expected = LombokTestSource.read(params.getAfterDirectory(), params.getMessagesDirectory(), fileName);
- if (expected.isIgnore()) return false;
- if (!expected.versionWithinLimit(params.getVersion())) return false;
+ if (expected.isIgnore()) return null;
+ if (!expected.versionWithinLimit(params.getVersion())) return null;
+ if (!expected.versionWithinLimit(version)) return null;
- LinkedHashSet<CompilerMessage> messages = new LinkedHashSet<CompilerMessage>();
- StringWriter writer = new StringWriter();
-
- LombokConfiguration.overrideConfigurationResolverFactory(new ConfigurationResolverFactory() {
- @Override public ConfigurationResolver createResolver(AST<?, ?, ?> ast) {
- return sourceDirectives.getConfiguration();
+ final LombokTestSource sourceDirectives_ = sourceDirectives;
+ final AssertionError directiveFailure_ = directiveFailure;
+ return new FileTester() {
+ @Override public void runTest() throws Throwable {
+ if (directiveFailure_ != null) throw directiveFailure_;
+ LinkedHashSet<CompilerMessage> messages = new LinkedHashSet<CompilerMessage>();
+ StringWriter writer = new StringWriter();
+
+ LombokConfiguration.overrideConfigurationResolverFactory(new ConfigurationResolverFactory() {
+ @Override public ConfigurationResolver createResolver(AST<?, ?, ?> ast) {
+ return sourceDirectives_.getConfiguration();
+ }
+ });
+
+ boolean changed = transformCode(messages, writer, file, sourceDirectives_.getSpecifiedEncoding(), sourceDirectives_.getFormatPreferences());
+ boolean forceUnchanged = sourceDirectives_.forceUnchanged() || sourceDirectives_.isSkipCompareContent();
+ if (params.expectChanges() && !forceUnchanged && !changed) messages.add(new CompilerMessage(-1, -1, true, "not flagged modified"));
+ if (!params.expectChanges() && changed) messages.add(new CompilerMessage(-1, -1, true, "unexpected modification"));
+
+ compare(file.getName(), expected, writer.toString(), messages, params.printErrors(), sourceDirectives_.isSkipCompareContent() || expected.isSkipCompareContent());
}
- });
-
- transformCode(messages, writer, file);
-
- compare(file.getName(), expected, writer.toString(), messages, params.printErrors(), sourceDirectives.isSkipCompareContent() || expected.isSkipCompareContent());
- return true;
- }
-
- private static int getClasspathVersion() {
- try {
- Class.forName("java.lang.AutoCloseable");
- } catch (ClassNotFoundException e) {
- return 6;
- }
-
- try {
- Class.forName("java.util.stream.Stream");
- } catch (ClassNotFoundException e) {
- return 7;
- }
-
- return 8;
+ };
}
- protected abstract void transformCode(Collection<CompilerMessage> messages, StringWriter result, File file) throws Throwable;
+ protected abstract boolean transformCode(Collection<CompilerMessage> messages, StringWriter result, File file, String encoding, Map<String, String> formatPreferences) throws Throwable;
protected String readFile(File file) throws IOException {
BufferedReader reader;
diff --git a/test/core/src/lombok/DirectoryRunner.java b/test/core/src/lombok/DirectoryRunner.java
index 9062f523..72f01de1 100644
--- a/test/core/src/lombok/DirectoryRunner.java
+++ b/test/core/src/lombok/DirectoryRunner.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2014 The Project Lombok Authors.
+ * Copyright (C) 2009-2015 The Project Lombok Authors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -23,6 +23,7 @@ package lombok;
import java.io.File;
import java.io.FileFilter;
+import java.io.IOException;
import java.util.Map;
import java.util.TreeMap;
@@ -69,6 +70,8 @@ public class DirectoryRunner extends Runner {
public boolean accept(File file) {
return true;
}
+
+ public abstract boolean expectChanges();
}
private static final FileFilter JAVA_FILE_FILTER = new FileFilter() {
@@ -114,19 +117,29 @@ public class DirectoryRunner extends Runner {
@Override
public void run(RunNotifier notifier) {
if (failure != null) {
- notifier.fireTestStarted(description);
- notifier.fireTestFailure(new Failure(description, failure));
- notifier.fireTestFinished(description);
+ reportInitializationFailure(notifier, description, failure);
return;
}
for (Map.Entry<String, Description> entry : tests.entrySet()) {
Description testDescription = entry.getValue();
+
+ FileTester tester;
+ try {
+ tester = createTester(entry.getKey());
+ } catch (IOException e) {
+ reportInitializationFailure(notifier, testDescription, e);
+ continue;
+ }
+
+ if (tester == null) {
+ notifier.fireTestIgnored(testDescription);
+ continue;
+ }
+
notifier.fireTestStarted(testDescription);
try {
- if (!runTest(entry.getKey())) {
- notifier.fireTestIgnored(testDescription);
- }
+ tester.runTest();
} catch (Throwable t) {
notifier.fireTestFailure(new Failure(testDescription, t));
}
@@ -134,17 +147,26 @@ public class DirectoryRunner extends Runner {
}
}
- private boolean runTest(String fileName) throws Throwable {
+ private void reportInitializationFailure(RunNotifier notifier, Description description, Throwable throwable) {
+ notifier.fireTestStarted(description);
+ notifier.fireTestFailure(new Failure(description, throwable));
+ notifier.fireTestFinished(description);
+ }
+
+ private FileTester createTester(String fileName) throws IOException {
File file = new File(params.getBeforeDirectory(), fileName);
-
switch (params.getCompiler()) {
case DELOMBOK:
- return new RunTestsViaDelombok().compareFile(params, file);
+ return new RunTestsViaDelombok().createTester(params, file, "javac", params.getVersion());
case ECJ:
- return new RunTestsViaEcj().compareFile(params, file);
+ return new RunTestsViaEcj().createTester(params, file, "ecj", params.getVersion());
default:
case JAVAC:
throw new UnsupportedOperationException();
}
}
+
+ public interface FileTester {
+ void runTest() throws Throwable;
+ }
}
diff --git a/test/core/src/lombok/LombokTestSource.java b/test/core/src/lombok/LombokTestSource.java
index 402001e9..31f7db3e 100644
--- a/test/core/src/lombok/LombokTestSource.java
+++ b/test/core/src/lombok/LombokTestSource.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014 The Project Lombok Authors.
+ * Copyright (C) 2014-2015 The Project Lombok Authors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -26,10 +26,14 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
+import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -45,10 +49,20 @@ public class LombokTestSource {
private final File file;
private final String content;
private final LombokImmutableList<CompilerMessageMatcher> messages;
+ private final Map<String, String> formatPreferences;
private final boolean ignore;
private final boolean skipCompareContent;
+ private final boolean unchanged;
private final int versionLowerLimit, versionUpperLimit;
private final ConfigurationResolver configuration;
+ private final String specifiedEncoding;
+ private final List<String> platforms;
+
+ public boolean runOnPlatform(String platform) {
+ if (platforms == null || platforms.isEmpty()) return true;
+ for (String pl : platforms) if (pl.equalsIgnoreCase(platform)) return true;
+ return false;
+ }
public boolean versionWithinLimit(int version) {
return version >= versionLowerLimit && version <= versionUpperLimit;
@@ -70,14 +84,26 @@ public class LombokTestSource {
return ignore;
}
+ public boolean forceUnchanged() {
+ return unchanged;
+ }
+
public boolean isSkipCompareContent() {
return skipCompareContent;
}
+ public String getSpecifiedEncoding() {
+ return specifiedEncoding;
+ }
+
public ConfigurationResolver getConfiguration() {
return configuration;
}
+ public Map<String, String> getFormatPreferences() {
+ return formatPreferences;
+ }
+
private static final Pattern VERSION_STYLE_1 = Pattern.compile("^(\\d+)$");
private static final Pattern VERSION_STYLE_2 = Pattern.compile("^\\:(\\d+)$");
private static final Pattern VERSION_STYLE_3 = Pattern.compile("^(\\d+):$");
@@ -111,7 +137,8 @@ public class LombokTestSource {
}
private static final Pattern IGNORE_PATTERN = Pattern.compile("^\\s*ignore\\s*(?:[-:].*)?$", Pattern.CASE_INSENSITIVE);
- private static final Pattern SKIP_COMPARE_CONTENT_PATTERN = Pattern.compile("^\\s*skip[- ]?compare[- ]?content\\s*(?:[-:].*)?$", Pattern.CASE_INSENSITIVE);
+ private static final Pattern UNCHANGED_PATTERN = Pattern.compile("^\\s*unchanged\\s*(?:[-:].*)?$", Pattern.CASE_INSENSITIVE);
+ private static final Pattern SKIP_COMPARE_CONTENT_PATTERN = Pattern.compile("^\\s*skip[- ]?compare[- ]?contents?\\s*(?:[-:].*)?$", Pattern.CASE_INSENSITIVE);
private LombokTestSource(File file, String content, List<CompilerMessageMatcher> messages, List<String> directives) {
this.file = file;
@@ -123,6 +150,10 @@ public class LombokTestSource {
int versionUpper = Integer.MAX_VALUE;
boolean ignore = false;
boolean skipCompareContent = false;
+ boolean unchanged = false;
+ String encoding = null;
+ Map<String, String> formats = new HashMap<String, String>();
+ String[] platformLimit = null;
for (String directive : directives) {
directive = directive.trim();
@@ -132,11 +163,24 @@ public class LombokTestSource {
continue;
}
+ if (UNCHANGED_PATTERN.matcher(directive).matches()) {
+ unchanged = true;
+ continue;
+ }
+
if (SKIP_COMPARE_CONTENT_PATTERN.matcher(directive).matches()) {
skipCompareContent = true;
continue;
}
+ if (lc.startsWith("platform ")) {
+ String platformDesc = lc.substring("platform ".length());
+ int idx = platformDesc.indexOf(':');
+ if (idx != -1) platformDesc = platformDesc.substring(0, idx).trim();
+ platformLimit = platformDesc.split("\\s*,\\s*");
+ continue;
+ }
+
if (lc.startsWith("version ")) {
int[] limits = parseVersionLimit(lc.substring(7).trim());
if (limits == null) {
@@ -154,14 +198,33 @@ public class LombokTestSource {
continue;
}
+ if (lc.startsWith("encoding:")) {
+ encoding = directive.substring(9).trim();
+ continue;
+ }
+
+ if (lc.startsWith("format:")) {
+ String formatLine = directive.substring(7).trim();
+ int idx = formatLine.indexOf('=');
+ if (idx == -1) throw new IllegalArgumentException("To add a format directive, use: \"//FORMAT: javaLangAsFQN = skip\"");
+ String key = formatLine.substring(0, idx).trim();
+ String value = formatLine.substring(idx + 1).trim();
+ formats.put(key.toLowerCase(), value);
+ continue;
+ }
+
+ if (lc.startsWith("issue ")) continue;
+
Assert.fail("Directive line \"" + directive + "\" in '" + file.getAbsolutePath() + "' invalid: unrecognized directive.");
throw new RuntimeException();
}
-
+ this.specifiedEncoding = encoding;
this.versionLowerLimit = versionLower;
this.versionUpperLimit = versionUpper;
this.ignore = ignore;
this.skipCompareContent = skipCompareContent;
+ this.unchanged = unchanged;
+ this.platforms = platformLimit == null ? null : Arrays.asList(platformLimit);
ConfigurationProblemReporter reporter = new ConfigurationProblemReporter() {
@Override public void report(String sourceDescription, String problem, int lineNumber, CharSequence line) {
Assert.fail("Problem on directive line: " + problem + " at conf line #" + lineNumber + " (" + line + ")");
@@ -169,55 +232,76 @@ public class LombokTestSource {
};
this.configuration = new BubblingConfigurationResolver(Collections.singleton(StringConfigurationSource.forString(conf, reporter, file.getAbsolutePath())));
+ this.formatPreferences = Collections.unmodifiableMap(formats);
}
public static LombokTestSource readDirectives(File file) throws IOException {
List<String> directives = new ArrayList<String>();
{
- @Cleanup val rawIn = new FileInputStream(file);
- BufferedReader in = new BufferedReader(new InputStreamReader(rawIn, "UTF-8"));
- for (String i = in.readLine(); i != null; i = in.readLine()) {
- if (i.isEmpty()) continue;
-
- if (i.startsWith("//")) {
- directives.add(i.substring(2));
- } else {
- break;
+ InputStream rawIn = new FileInputStream(file);
+ try {
+ BufferedReader in = new BufferedReader(new InputStreamReader(rawIn, "UTF-8"));
+ try {
+ for (String i = in.readLine(); i != null; i = in.readLine()) {
+ if (i.isEmpty()) continue;
+
+ if (i.startsWith("//")) {
+ directives.add(i.substring(2));
+ } else {
+ break;
+ }
+ }
}
+ finally {
+ in.close();
+ }
+ }
+ finally {
+ rawIn.close();
}
- in.close();
- rawIn.close();
}
return new LombokTestSource(file, "", null, directives);
}
public static LombokTestSource read(File sourceFolder, File messagesFolder, String fileName) throws IOException {
+ return read0(sourceFolder, messagesFolder, fileName, "UTF-8");
+ }
+
+ private static LombokTestSource read0(File sourceFolder, File messagesFolder, String fileName, String encoding) throws IOException {
StringBuilder content = null;
List<String> directives = new ArrayList<String>();
File sourceFile = new File(sourceFolder, fileName);
if (sourceFile.exists()) {
- @Cleanup val rawIn = new FileInputStream(sourceFile);
- BufferedReader in = new BufferedReader(new InputStreamReader(rawIn, "UTF-8"));
- for (String i = in.readLine(); i != null; i = in.readLine()) {
- if (content != null) {
- content.append(i).append("\n");
- continue;
+ InputStream rawIn = new FileInputStream(sourceFile);
+ try {
+ BufferedReader in = new BufferedReader(new InputStreamReader(rawIn, encoding));
+ try {
+ for (String i = in.readLine(); i != null; i = in.readLine()) {
+ if (content != null) {
+ content.append(i).append("\n");
+ continue;
+ }
+
+ if (i.isEmpty()) continue;
+
+ if (i.startsWith("//")) {
+ directives.add(i.substring(2));
+ } else {
+ content = new StringBuilder();
+ content.append(i).append("\n");
+ }
+ }
}
-
- if (i.isEmpty()) continue;
-
- if (i.startsWith("//")) {
- directives.add(i.substring(2));
- } else {
- content = new StringBuilder();
- content.append(i).append("\n");
+ finally {
+ in.close();
}
}
- in.close();
- rawIn.close();
+ finally {
+ rawIn.close();
+ }
}
if (content == null) content = new StringBuilder();
@@ -226,14 +310,27 @@ public class LombokTestSource {
if (messagesFolder != null) {
File messagesFile = new File(messagesFolder, fileName + ".messages");
try {
- @Cleanup val rawIn = new FileInputStream(messagesFile);
- messages = CompilerMessageMatcher.readAll(rawIn);
- rawIn.close();
+ InputStream rawIn = new FileInputStream(messagesFile);
+ try {
+ messages = CompilerMessageMatcher.readAll(rawIn);
+ }
+ finally {
+ rawIn.close();
+ }
} catch (FileNotFoundException e) {
messages = null;
}
}
- return new LombokTestSource(sourceFile, content.toString(), messages, directives);
+ LombokTestSource source = new LombokTestSource(sourceFile, content.toString(), messages, directives);
+ String specifiedEncoding = source.getSpecifiedEncoding();
+
+ // The source file has an 'encoding' header to test encoding issues. Of course, reading the encoding header
+ // requires knowing the encoding of the file first. In practice we get away with it, because UTF-8 and US-ASCII are compatible enough.
+ // The fix is therefore to read in as UTF-8 initially, and if the file requests that it should be read as another encoding, toss it all
+ // and reread that way.
+
+ if (specifiedEncoding == null || specifiedEncoding.equalsIgnoreCase(encoding)) return source;
+ return read0(sourceFolder, messagesFolder, fileName, specifiedEncoding);
}
}
diff --git a/test/core/src/lombok/RunAllTests.java b/test/core/src/lombok/RunAllTests.java
index 9f56b45b..1ca76af5 100644
--- a/test/core/src/lombok/RunAllTests.java
+++ b/test/core/src/lombok/RunAllTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011-2014 The Project Lombok Authors.
+ * Copyright (C) 2011-2015 The Project Lombok Authors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -26,6 +26,6 @@ import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
@RunWith(Suite.class)
-@SuiteClasses({lombok.transform.RunTransformTests.class, lombok.bytecode.RunBytecodeTests.class, lombok.core.configuration.RunConfigurationTests.class})
+@SuiteClasses({lombok.transform.RunTransformTests.class, lombok.bytecode.RunBytecodeTests.class, lombok.core.configuration.RunConfigurationTests.class, lombok.core.RunCoreTests.class})
public class RunAllTests {
}
diff --git a/test/core/src/lombok/RunTestsViaDelombok.java b/test/core/src/lombok/RunTestsViaDelombok.java
index 6a08642b..0887de32 100644
--- a/test/core/src/lombok/RunTestsViaDelombok.java
+++ b/test/core/src/lombok/RunTestsViaDelombok.java
@@ -21,10 +21,14 @@
*/
package lombok;
+import java.io.ByteArrayOutputStream;
import java.io.File;
+import java.io.PrintStream;
import java.io.StringWriter;
+import java.io.UnsupportedEncodingException;
import java.util.Collection;
import java.util.Locale;
+import java.util.Map;
import lombok.delombok.Delombok;
import lombok.javac.CapturingDiagnosticListener;
@@ -34,10 +38,13 @@ public class RunTestsViaDelombok extends AbstractRunTests {
private Delombok delombok = new Delombok();
@Override
- public void transformCode(Collection<CompilerMessage> messages, StringWriter result, final File file) throws Throwable {
- delombok.setVerbose(false);
+ public boolean transformCode(Collection<CompilerMessage> messages, StringWriter result, final File file, String encoding, Map<String, String> formatPreferences) throws Throwable {
+ delombok.setVerbose(true);
+ ChangedChecker cc = new ChangedChecker();
+ delombok.setFeedback(cc.feedback);
delombok.setForceProcess(true);
- delombok.setCharset("UTF-8");
+ delombok.setCharset(encoding == null ? "UTF-8" : encoding);
+ delombok.setFormatPreferences(formatPreferences);
delombok.setDiagnosticsListener(new CapturingDiagnosticListener(file, messages));
@@ -50,8 +57,23 @@ public class RunTestsViaDelombok extends AbstractRunTests {
try {
Locale.setDefault(Locale.ENGLISH);
delombok.delombok();
+ return cc.isChanged();
} finally {
Locale.setDefault(originalLocale);
}
}
+
+ static class ChangedChecker {
+ private final ByteArrayOutputStream bytes = new ByteArrayOutputStream();
+ private final PrintStream feedback;
+
+ ChangedChecker() throws UnsupportedEncodingException {
+ feedback = new PrintStream(bytes, true, "UTF-8");
+ }
+
+ boolean isChanged() throws UnsupportedEncodingException {
+ feedback.flush();
+ return bytes.toString("UTF-8").endsWith("[delomboked]\n");
+ }
+ }
}
diff --git a/test/core/src/lombok/RunTestsViaEcj.java b/test/core/src/lombok/RunTestsViaEcj.java
index f4584493..6ed1e950 100644
--- a/test/core/src/lombok/RunTestsViaEcj.java
+++ b/test/core/src/lombok/RunTestsViaEcj.java
@@ -24,7 +24,6 @@ package lombok;
import java.io.File;
import java.io.StringWriter;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
@@ -93,7 +92,7 @@ public class RunTestsViaEcj extends AbstractRunTests {
}
@Override
- public void transformCode(Collection<CompilerMessage> messages, StringWriter result, File file) throws Throwable {
+ public boolean transformCode(Collection<CompilerMessage> messages, StringWriter result, File file, String encoding, Map<String, String> formatPreferences) throws Throwable {
final AtomicReference<CompilationResult> compilationResult_ = new AtomicReference<CompilationResult>();
final AtomicReference<CompilationUnitDeclaration> compilationUnit_ = new AtomicReference<CompilationUnitDeclaration>();
ICompilerRequestor bitbucketRequestor = new ICompilerRequestor() {
@@ -103,7 +102,7 @@ public class RunTestsViaEcj extends AbstractRunTests {
};
String source = readFile(file);
- final CompilationUnit sourceUnit = new CompilationUnit(source.toCharArray(), file.getName(), "UTF-8");
+ final CompilationUnit sourceUnit = new CompilationUnit(source.toCharArray(), file.getName(), encoding == null ? "UTF-8" : encoding);
Compiler ecjCompiler = new Compiler(createFileSystem(file), ecjErrorHandlingPolicy(), ecjCompilerOptions(), bitbucketRequestor, new DefaultProblemFactory(Locale.ENGLISH)) {
@Override protected synchronized void addCompilationUnit(ICompilationUnit inUnit, CompilationUnitDeclaration parsedUnit) {
@@ -112,8 +111,6 @@ public class RunTestsViaEcj extends AbstractRunTests {
}
};
- // TODO: Create a configuration based on confLines and set this up so that this compile run will use them.
-
ecjCompiler.compile(new ICompilationUnit[] {sourceUnit});
CompilationResult compilationResult = compilationResult_.get();
@@ -127,22 +124,28 @@ public class RunTestsViaEcj extends AbstractRunTests {
if (cud == null) result.append("---- NO CompilationUnit provided by ecj ----");
else result.append(cud.toString());
+
+ return true;
}
private FileSystem createFileSystem(File file) {
List<String> classpath = new ArrayList<String>();
- classpath.addAll(Arrays.asList(System.getProperty("sun.boot.class.path").split(File.pathSeparator)));
for (Iterator<String> i = classpath.iterator(); i.hasNext();) {
if (FileSystem.getClasspath(i.next(), "UTF-8", null) == null) {
i.remove();
}
}
+ if (new File("bin").exists()) classpath.add("bin");
classpath.add("dist/lombok.jar");
+ classpath.add("lib/oracleJDK8Environment/rt.jar");
classpath.add("lib/test/commons-logging-commons-logging.jar");
classpath.add("lib/test/org.slf4j-slf4j-api.jar");
classpath.add("lib/test/org.slf4j-slf4j-ext.jar");
classpath.add("lib/test/log4j-log4j.jar");
classpath.add("lib/test/org.apache.logging.log4j-log4j-api.jar");
+ classpath.add("lib/test/org.jboss.logging-jboss-logging.jar");
+ classpath.add("lib/test/com.google.guava-guava.jar");
+ classpath.add("lib/test/com.google.code.findbugs-findbugs.jar");
return new FileSystem(classpath.toArray(new String[0]), new String[] {file.getAbsolutePath()}, "UTF-8");
}
}
diff --git a/test/core/src/lombok/core/RunCoreTests.java b/test/core/src/lombok/core/RunCoreTests.java
new file mode 100644
index 00000000..8ac7cf81
--- /dev/null
+++ b/test/core/src/lombok/core/RunCoreTests.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2015 The Project Lombok Authors.
+ *
+ * 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.core;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+
+@RunWith(Suite.class)
+@SuiteClasses({TestSingulars.class})
+public class RunCoreTests {
+}
diff --git a/test/core/src/lombok/core/TestSingulars.java b/test/core/src/lombok/core/TestSingulars.java
new file mode 100644
index 00000000..4560615d
--- /dev/null
+++ b/test/core/src/lombok/core/TestSingulars.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2015-2017 The Project Lombok Authors.
+ *
+ * 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.core;
+
+import static lombok.core.handlers.Singulars.autoSingularize;
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class TestSingulars {
+ @Test
+ public void testSingulars() {
+ assertNull("axes", autoSingularize("axes"));
+ assertEquals("adjective", autoSingularize("adjectives"));
+ assertEquals("bus", autoSingularize("buses"));
+ assertEquals("octopus", autoSingularize("octopodes"));
+ assertNull("octopi", autoSingularize("octopi"));
+ assertEquals("elf", autoSingularize("elves"));
+ assertEquals("jack", autoSingularize("jacks"));
+ assertEquals("colloquy", autoSingularize("colloquies"));
+ assertNull("series", autoSingularize("series"));
+ assertEquals("man", autoSingularize("men"));
+ assertNull("highwaymen", autoSingularize("highwaymen"));
+ assertEquals("caveMan", autoSingularize("caveMen"));
+ assertNull("jackss", autoSingularize("jackss"));
+ assertNull("virus", autoSingularize("virus"));
+ assertEquals("quiz", autoSingularize("quizzes"));
+ assertEquals("database", autoSingularize("databases"));
+ assertEquals("dataBase", autoSingularize("dataBases"));
+ assertEquals("Query", autoSingularize("Queries"));
+ assertEquals("Movie", autoSingularize("Movies"));
+ assertEquals("cafe", autoSingularize("cafes"));
+ assertNull("caves", autoSingularize("caves"));
+ assertEquals("leaf", autoSingularize("leaves"));
+ assertEquals("autosave", autoSingularize("autosaves"));
+ }
+}