Skip to content

Commit

Permalink
added missing javac tests of Issue #113
Browse files Browse the repository at this point in the history
and other tests as well
  • Loading branch information
peichhorn committed Jul 28, 2012
1 parent 097a9af commit ca2a7e2
Show file tree
Hide file tree
Showing 25 changed files with 220 additions and 7 deletions.
2 changes: 1 addition & 1 deletion buildScripts/ivy-repo/projectlombok.org-lombok-0.11.3.xml
Expand Up @@ -13,7 +13,7 @@
</configurations>
<publications>
<artifact conf="build"
url="http://cloud.github.com/downloads/peichhorn/lombok-pg/lombok-0.11.3.jar" />
url="http://cloud.github.com/downloads/peichhorn/lombok-pg/lombok-0.11.3b.jar" />
<artifact type="zip" conf="sources"
url="http://cloud.github.com/downloads/peichhorn/lombok-pg/lombok-0.11.3-sources.jar" />
</publications>
Expand Down
@@ -0,0 +1,29 @@
class ConflictingStaticConstructorNames {
@java.lang.Override
@java.lang.SuppressWarnings("all")
public boolean equals(final java.lang.Object o) {
if (o == this) return true;
if (!(o instanceof ConflictingStaticConstructorNames)) return false;
final ConflictingStaticConstructorNames other = (ConflictingStaticConstructorNames)o;
if (!other.canEqual((java.lang.Object)this)) return false;
return true;
}
@java.lang.SuppressWarnings("all")
public boolean canEqual(final java.lang.Object other) {
return other instanceof ConflictingStaticConstructorNames;
}
@java.lang.Override
@java.lang.SuppressWarnings("all")
public int hashCode() {
int result = 1;
return result;
}
@java.lang.Override
@java.lang.SuppressWarnings("all")
public java.lang.String toString() {
return "ConflictingStaticConstructorNames()";
}
@java.lang.SuppressWarnings("all")
public ConflictingStaticConstructorNames() {
}
}
14 changes: 14 additions & 0 deletions test/transform/resource/after-delombok/Constructors.java
Expand Up @@ -58,4 +58,18 @@ private RequiredArgsConstructorStaticNameGenerics(final T x) {
public static <T extends Number> RequiredArgsConstructorStaticNameGenerics<T> of(final T x) {
return new RequiredArgsConstructorStaticNameGenerics<T>(x);
}
}
class RequiredArgsConstructorStaticNameGenerics2<T extends Number> {
final Class<T> x;
String name;

@java.lang.SuppressWarnings("all")
private RequiredArgsConstructorStaticNameGenerics2(final Class<T> x) {
this.x = x;
}

@java.lang.SuppressWarnings("all")
public static <T extends Number> RequiredArgsConstructorStaticNameGenerics2<T> of(final Class<T> x) {
return new RequiredArgsConstructorStaticNameGenerics2<T>(x);
}
}
@@ -1 +1,35 @@
//ignore
class EnumIdAccessorsPrefix {
public enum Status {
WAITING(0),
READY(1),
SKIPPED(-1),
COMPLETED(5);

private static final java.util.Map<java.lang.Integer, Status> $CODE_LOOKUP = new java.util.HashMap<java.lang.Integer, Status>();
private final int _code;

@java.lang.SuppressWarnings("all")
private Status(final int _code) {
this._code = _code;
}

static {
for (Status status : Status.values()) {
$CODE_LOOKUP.put(status._code, status);
}
}

@java.lang.SuppressWarnings("all")
public static Status findByCode(final int code) {
if ($CODE_LOOKUP.containsKey(code)) {
return $CODE_LOOKUP.get(code);
}
throw new java.lang.IllegalArgumentException(java.lang.String.format("Enumeration \'Status\' has no value for \'code = %s\'", code));
}

@java.lang.SuppressWarnings("all")
public int getCode() {
return this._code;
}
}
}
@@ -1 +1,13 @@
//ignore
class FluentSetterAccessorsPrefix<T, K> {
int _fluent;

@java.lang.SuppressWarnings("all")
public FluentSetterAccessorsPrefix() {
}

@java.lang.SuppressWarnings("all")
public FluentSetterAccessorsPrefix<T, K> fluent(final int fluent) {
this._fluent = fluent;
return this;
}
}
10 changes: 6 additions & 4 deletions test/transform/resource/after-delombok/GetterLazyInvalid.java
@@ -1,23 +1,25 @@
class GetterLazyInvalidNotFinal {
@lombok.Getter(lazy = true)
private String fieldName = "";
}
class GetterLazyInvalidNotPrivate {
@lombok.Getter(lazy = true)
final String fieldName = "";
}
class GetterLazyInvalidNotPrivateFinal {
@lombok.Getter(lazy = true)
String fieldName = "";
}
class GetterLazyInvalidNone {
@lombok.Getter(lazy = true, value = lombok.AccessLevel.NONE)
private final String fieldName = "";
}
@lombok.Getter(lazy = true)
class GetterLazyInvalidClass {
private final String fieldName = "";
@java.lang.SuppressWarnings("all")
public String getFieldName() {
return this.fieldName;
}
}
class GetterLazyInvalidNoInit {
@lombok.Getter(lazy = true)
private final String fieldName;
GetterLazyInvalidNoInit() {
this.fieldName = "foo";
Expand Down
@@ -1,4 +1,6 @@
class LoggerSlf4jOnNonType {

@lombok.extern.slf4j.Slf4j
void foo() {
}
}
5 changes: 5 additions & 0 deletions test/transform/resource/after-delombok/LoggerSlf4jTypes.java
@@ -1,16 +1,21 @@
@lombok.extern.slf4j.Slf4j
interface LoggerSlf4jTypesInterface {
}
@lombok.extern.slf4j.Slf4j
@interface LoggerSlf4jTypesAnnotation {
}
@lombok.extern.slf4j.Slf4j
enum LoggerSlf4jTypesEnum {
;
private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(LoggerSlf4jTypesEnum.class);
}
@lombok.extern.slf4j.Slf4j
enum LoggerSlf4jTypesEnumWithElement {
FOO;
private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(LoggerSlf4jTypesEnumWithElement.class);
}
interface LoggerSlf4jTypesInterfaceOuter {
@lombok.extern.slf4j.Slf4j
class Inner {
private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(Inner.class);
}
Expand Down
5 changes: 5 additions & 0 deletions test/transform/resource/after-delombok/SynchronizedName.java
@@ -1,24 +1,29 @@
class SynchronizedName {
private Object read = new Object();
private static Object READ = new Object();
@lombok.Synchronized("read")
void test1() {
synchronized (this.read) {
System.out.println("one");
}
}
@lombok.Synchronized("write")
void test2() {
System.out.println("two");
}
@lombok.Synchronized("read")
static void test3() {
synchronized (SynchronizedName.read) {
System.out.println("three");
}
}
@lombok.Synchronized("READ")
void test4() {
synchronized (this.READ) {
System.out.println("four");
}
}
@lombok.Synchronized("read")
void test5() {
synchronized (this.read) {
System.out.println("five");
Expand Down
@@ -0,0 +1,8 @@
class SynchronizedNameNoSuchField {
private Object read = new Object();
private static Object READ = new Object();
@lombok.Synchronized("write")
void test2() {
System.out.println("two");
}
}
@@ -0,0 +1,9 @@
class SynchronizedNameStaticToInstanceRef {
private Object read = new Object();
private static Object READ = new Object();
static void test3() {
synchronized (SynchronizedNameStaticToInstanceRef.read) {
System.out.println("three");
}
}
}
@@ -0,0 +1,25 @@
@lombok.Data(staticConstructor = "of") @lombok.NoArgsConstructor class ConflictingStaticConstructorNames {
public @java.lang.Override @java.lang.SuppressWarnings("all") boolean equals(final java.lang.Object o) {
if ((o == this))
return true;
if ((! (o instanceof ConflictingStaticConstructorNames)))
return false;
final @java.lang.SuppressWarnings("all") ConflictingStaticConstructorNames other = (ConflictingStaticConstructorNames) o;
if ((! other.canEqual((java.lang.Object) this)))
return false;
return true;
}
public @java.lang.SuppressWarnings("all") boolean canEqual(final java.lang.Object other) {
return (other instanceof ConflictingStaticConstructorNames);
}
public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() {
int result = 1;
return result;
}
public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
return "ConflictingStaticConstructorNames()";
}
public @java.lang.SuppressWarnings("all") ConflictingStaticConstructorNames() {
super();
}
}
11 changes: 11 additions & 0 deletions test/transform/resource/after-ecj/Constructors.java
Expand Up @@ -51,4 +51,15 @@
public static @java.lang.SuppressWarnings("all") <T extends Number>RequiredArgsConstructorStaticNameGenerics<T> of(final T x) {
return new RequiredArgsConstructorStaticNameGenerics<T>(x);
}
}
@lombok.RequiredArgsConstructor(staticName = "of") class RequiredArgsConstructorStaticNameGenerics2<T extends Number> {
final Class<T> x;
String name;
private @java.lang.SuppressWarnings("all") RequiredArgsConstructorStaticNameGenerics2(final Class<T> x) {
super();
this.x = x;
}
public static @java.lang.SuppressWarnings("all") <T extends Number>RequiredArgsConstructorStaticNameGenerics2<T> of(final Class<T> x) {
return new RequiredArgsConstructorStaticNameGenerics2<T>(x);
}
}
12 changes: 12 additions & 0 deletions test/transform/resource/after-ecj/SynchronizedNameNoSuchField.java
@@ -0,0 +1,12 @@
class SynchronizedNameNoSuchField {
private Object read = new Object();
private static Object READ = new Object();
<clinit>() {
}
SynchronizedNameNoSuchField() {
super();
}
@lombok.Synchronized("write") void test2() {
System.out.println("two");
}
}
@@ -0,0 +1,15 @@
class SynchronizedNameStaticToInstanceRef {
private Object read = new Object();
private static Object READ = new Object();
<clinit>() {
}
SynchronizedNameStaticToInstanceRef() {
super();
}
static @lombok.Synchronized("read") void test3() {
synchronized (SynchronizedNameStaticToInstanceRef.read)
{
System.out.println("three");
}
}
}
@@ -0,0 +1,4 @@
@lombok.Data(staticConstructor="of")
@lombok.NoArgsConstructor
class ConflictingStaticConstructorNames {
}
4 changes: 4 additions & 0 deletions test/transform/resource/before/Constructors.java
Expand Up @@ -22,3 +22,7 @@
final T x;
String name;
}
@lombok.RequiredArgsConstructor(staticName="of") class RequiredArgsConstructorStaticNameGenerics2<T extends Number> {
final Class<T> x;
String name;
}
@@ -0,0 +1,8 @@
class SynchronizedNameNoSuchField {
private Object read = new Object();
private static Object READ = new Object();

@lombok.Synchronized("write") void test2() {
System.out.println("two");
}
}
@@ -0,0 +1,8 @@
class SynchronizedNameStaticToInstanceRef {
private Object read = new Object();
private static Object READ = new Object();

@lombok.Synchronized("read") static void test3() {
System.out.println("three");
}
}
@@ -0,0 +1 @@
1:1 WARNING Ignoring static constructor name: explicit @XxxArgsConstructor annotation present; its `staticName` parameter will be used.
@@ -0,0 +1 @@
5:9 ERROR The field write does not exist.
@@ -0,0 +1 @@
5:9 ERROR non-static variable read cannot be referenced from a static context
@@ -0,0 +1 @@
1 warning Ignoring static constructor name: explicit @XxxArgsConstructor annotation present; its `staticName` parameter will be used.
@@ -0,0 +1 @@
5 error The field write does not exist.
@@ -0,0 +1 @@
5 error Cannot make a static reference to the non-static field SynchronizedNameStaticToInstanceRef.read

0 comments on commit ca2a7e2

Please sign in to comment.