diff options
Diffstat (limited to 'test')
41 files changed, 465 insertions, 13 deletions
diff --git a/test/core/src/lombok/AbstractRunTests.java b/test/core/src/lombok/AbstractRunTests.java index f564d0dc..d044a39f 100644 --- a/test/core/src/lombok/AbstractRunTests.java +++ b/test/core/src/lombok/AbstractRunTests.java @@ -57,10 +57,16 @@ public abstract class AbstractRunTests { public final FileTester createTester(final DirectoryRunner.TestParams params, final File file) throws IOException { ConfigurationKeysLoader.LoaderLoader.loadAllConfigurationKeys(); - final LombokTestSource sourceDirectives = LombokTestSource.readDirectives(file); - if (sourceDirectives.isIgnore()) return null; - if (!sourceDirectives.versionWithinLimit(params.getVersion())) return null; - if (!sourceDirectives.versionWithinLimit(getClasspathVersion())) return null; + AssertionError directiveFailure = null; + LombokTestSource sourceDirectives = null; + try { + sourceDirectives = LombokTestSource.readDirectives(file); + if (sourceDirectives.isIgnore()) return null; + if (!sourceDirectives.versionWithinLimit(params.getVersion())) return null; + if (!sourceDirectives.versionWithinLimit(getClasspathVersion())) return null; + } catch (AssertionError ae) { + directiveFailure = ae; + } String fileName = file.getName(); final LombokTestSource expected = LombokTestSource.read(params.getAfterDirectory(), params.getMessagesDirectory(), fileName); @@ -68,23 +74,26 @@ public abstract class AbstractRunTests { if (expected.isIgnore()) return null; if (!expected.versionWithinLimit(params.getVersion())) return null; + 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(); + return sourceDirectives_.getConfiguration(); } }); - boolean changed = transformCode(messages, writer, file, sourceDirectives.getSpecifiedEncoding(), sourceDirectives.getFormatPreferences()); - boolean forceUnchanged = sourceDirectives.forceUnchanged() || sourceDirectives.isSkipCompareContent(); + 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()); + compare(file.getName(), expected, writer.toString(), messages, params.printErrors(), sourceDirectives_.isSkipCompareContent() || expected.isSkipCompareContent()); } }; } diff --git a/test/core/src/lombok/LombokTestSource.java b/test/core/src/lombok/LombokTestSource.java index cd7cd166..16f9f49f 100644 --- a/test/core/src/lombok/LombokTestSource.java +++ b/test/core/src/lombok/LombokTestSource.java @@ -130,7 +130,7 @@ public class LombokTestSource { private static final Pattern IGNORE_PATTERN = Pattern.compile("^\\s*ignore\\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[- ]?content\\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; diff --git a/test/transform/resource/after-delombok/BuilderWithTolerate.java b/test/transform/resource/after-delombok/BuilderWithTolerate.java new file mode 100644 index 00000000..6dc7e248 --- /dev/null +++ b/test/transform/resource/after-delombok/BuilderWithTolerate.java @@ -0,0 +1,59 @@ + +import lombok.experimental.Tolerate; + +public class BuilderWithTolerate { + private final int value; + + public static void main(String[] args) { + BuilderWithTolerate.builder().value("42").build(); + } + + + public static class BuilderWithTolerateBuilder { + @java.lang.SuppressWarnings("all") + @javax.annotation.Generated("lombok") + private int value; + + @Tolerate + public BuilderWithTolerateBuilder value(String s) { + return this.value(Integer.parseInt(s)); + } + + @java.lang.SuppressWarnings("all") + @javax.annotation.Generated("lombok") + BuilderWithTolerateBuilder() { + } + + @java.lang.SuppressWarnings("all") + @javax.annotation.Generated("lombok") + public BuilderWithTolerateBuilder value(final int value) { + this.value = value; + return this; + } + + @java.lang.SuppressWarnings("all") + @javax.annotation.Generated("lombok") + public BuilderWithTolerate build() { + return new BuilderWithTolerate(value); + } + + @java.lang.Override + @java.lang.SuppressWarnings("all") + @javax.annotation.Generated("lombok") + public java.lang.String toString() { + return "BuilderWithTolerate.BuilderWithTolerateBuilder(value=" + this.value + ")"; + } + } + + @java.lang.SuppressWarnings("all") + @javax.annotation.Generated("lombok") + BuilderWithTolerate(final int value) { + this.value = value; + } + + @java.lang.SuppressWarnings("all") + @javax.annotation.Generated("lombok") + public static BuilderWithTolerateBuilder builder() { + return new BuilderWithTolerateBuilder(); + } +}
\ No newline at end of file diff --git a/test/transform/resource/after-delombok/FieldDefaults.java b/test/transform/resource/after-delombok/FieldDefaults.java index 8a84f442..6f866a9a 100644 --- a/test/transform/resource/after-delombok/FieldDefaults.java +++ b/test/transform/resource/after-delombok/FieldDefaults.java @@ -1,4 +1,5 @@ class FieldDefaults1 { + static int STATIC = 3; final int x; int y; FieldDefaults1(int x) { @@ -6,6 +7,7 @@ class FieldDefaults1 { } } class FieldDefaults2 { + static int STATIC = 3; int x; private int y; }
\ No newline at end of file diff --git a/test/transform/resource/after-delombok/GetterLazyTransient.java b/test/transform/resource/after-delombok/GetterLazyTransient.java new file mode 100644 index 00000000..dbebad90 --- /dev/null +++ b/test/transform/resource/after-delombok/GetterLazyTransient.java @@ -0,0 +1,26 @@ +class GetterLazyTransient { + private final java.util.concurrent.atomic.AtomicReference<java.lang.Object> nonTransientField = new java.util.concurrent.atomic.AtomicReference<java.lang.Object>(); + private final transient int transientField = 2; + private final transient int nonLazyTransientField = 3; + @java.lang.SuppressWarnings("all") + @javax.annotation.Generated("lombok") + public int getNonTransientField() { + java.lang.Object value = this.nonTransientField.get(); + if (value == null) { + synchronized (this.nonTransientField) { + value = this.nonTransientField.get(); + if (value == null) { + final int actualValue = 1; + value = actualValue; + this.nonTransientField.set(value); + } + } + } + return (java.lang.Integer) value; + } + @java.lang.SuppressWarnings("all") + @javax.annotation.Generated("lombok") + public int getNonLazyTransientField() { + return this.nonLazyTransientField; + } +} diff --git a/test/transform/resource/after-delombok/NoArgsConstructorForce.java b/test/transform/resource/after-delombok/NoArgsConstructorForce.java new file mode 100644 index 00000000..c1127c7c --- /dev/null +++ b/test/transform/resource/after-delombok/NoArgsConstructorForce.java @@ -0,0 +1,14 @@ + +public class NoArgsConstructorForce { + private final int[] i; + private final Object[] o; + private final java.util.List<?>[] fullQualifiedList; + + @java.lang.SuppressWarnings("all") + @javax.annotation.Generated("lombok") + public NoArgsConstructorForce() { + this.i = null; + this.o = null; + this.fullQualifiedList = null; + } +}
\ No newline at end of file diff --git a/test/transform/resource/after-delombok/ValNullInit.java b/test/transform/resource/after-delombok/ValNullInit.java new file mode 100644 index 00000000..f0834a63 --- /dev/null +++ b/test/transform/resource/after-delombok/ValNullInit.java @@ -0,0 +1,5 @@ +class ValNullInit { + void method() { + final java.lang.Object x = null; + } +}
\ No newline at end of file diff --git a/test/transform/resource/after-delombok/ValueStaticField.java b/test/transform/resource/after-delombok/ValueStaticField.java index cec136f4..b4d60724 100644 --- a/test/transform/resource/after-delombok/ValueStaticField.java +++ b/test/transform/resource/after-delombok/ValueStaticField.java @@ -1,6 +1,6 @@ final class ValueStaticField { - private static int x; - private static final String PASSWORD = "Ken sent me"; + static int x; + static String PASSWORD = "Ken sent me"; @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") public ValueStaticField() { diff --git a/test/transform/resource/after-delombok/VarComplex.java b/test/transform/resource/after-delombok/VarComplex.java new file mode 100644 index 00000000..10b33943 --- /dev/null +++ b/test/transform/resource/after-delombok/VarComplex.java @@ -0,0 +1,20 @@ +public class VarComplex { + private String field = ""; + private static final int CONSTANT = 20; + public void testComplex() { + char[] shouldBeCharArray = field.toCharArray(); + int shouldBeInt = CONSTANT; + java.lang.Object lock = new Object(); + synchronized (lock) { + int field = 20; //Shadowing + int inner = 10; + switch (field) { + case 5: + char[] shouldBeCharArray2 = shouldBeCharArray; + int innerInner = inner; + + } + } + java.lang.String shouldBeString = field; //Unshadowing + } +}
\ No newline at end of file diff --git a/test/transform/resource/after-delombok/VarInFor.java b/test/transform/resource/after-delombok/VarInFor.java new file mode 100644 index 00000000..363aeeff --- /dev/null +++ b/test/transform/resource/after-delombok/VarInFor.java @@ -0,0 +1,9 @@ +public class VarInFor { + public void enhancedFor() { + int[] list = new int[] {1, 2}; + for (int shouldBeInt : list) { + System.out.println(shouldBeInt); + int shouldBeInt2 = shouldBeInt; + } + } +}
\ No newline at end of file diff --git a/test/transform/resource/after-delombok/VarInForOld.java b/test/transform/resource/after-delombok/VarInForOld.java new file mode 100644 index 00000000..bb510c0b --- /dev/null +++ b/test/transform/resource/after-delombok/VarInForOld.java @@ -0,0 +1,7 @@ +public class VarInForOld { + public void oldFor() { + for (int i = 0; i < 100; ++i) { + System.out.println(i); + } + } +}
\ No newline at end of file diff --git a/test/transform/resource/after-delombok/VarModifier.java b/test/transform/resource/after-delombok/VarModifier.java new file mode 100644 index 00000000..9838cdf7 --- /dev/null +++ b/test/transform/resource/after-delombok/VarModifier.java @@ -0,0 +1,7 @@ +public class VarModifier { + private String field = ""; + public void testComplex() { + final char[] shouldBeFinalCharArray = field.toCharArray(); + char[] shouldBeCharArray = field.toCharArray(); + } +}
\ No newline at end of file diff --git a/test/transform/resource/after-delombok/VarNullInit.java b/test/transform/resource/after-delombok/VarNullInit.java new file mode 100644 index 00000000..8ec2ea73 --- /dev/null +++ b/test/transform/resource/after-delombok/VarNullInit.java @@ -0,0 +1,6 @@ + +public class VarNullInit { + void method() { + java.lang.Object x = null; + } +}
\ No newline at end of file diff --git a/test/transform/resource/after-ecj/BuilderWithTolerate.java b/test/transform/resource/after-ecj/BuilderWithTolerate.java new file mode 100644 index 00000000..0b9b46a0 --- /dev/null +++ b/test/transform/resource/after-ecj/BuilderWithTolerate.java @@ -0,0 +1,34 @@ +import lombok.Builder; +import lombok.experimental.Tolerate; +public @Builder class BuilderWithTolerate { + public static class BuilderWithTolerateBuilder { + private @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") int value; + public @Tolerate BuilderWithTolerateBuilder value(String s) { + return this.value(Integer.parseInt(s)); + } + @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") BuilderWithTolerateBuilder() { + super(); + } + public @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") BuilderWithTolerateBuilder value(final int value) { + this.value = value; + return this; + } + public @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") BuilderWithTolerate build() { + return new BuilderWithTolerate(value); + } + public @java.lang.Override @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") java.lang.String toString() { + return (("BuilderWithTolerate.BuilderWithTolerateBuilder(value=" + this.value) + ")"); + } + } + private final int value; + public static void main(String[] args) { + BuilderWithTolerate.builder().value("42").build(); + } + @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") BuilderWithTolerate(final int value) { + super(); + this.value = value; + } + public static @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") BuilderWithTolerateBuilder builder() { + return new BuilderWithTolerateBuilder(); + } +}
\ No newline at end of file diff --git a/test/transform/resource/after-ecj/FieldDefaults.java b/test/transform/resource/after-ecj/FieldDefaults.java index e76c1251..a6941b7b 100644 --- a/test/transform/resource/after-ecj/FieldDefaults.java +++ b/test/transform/resource/after-ecj/FieldDefaults.java @@ -1,14 +1,20 @@ @lombok.experimental.FieldDefaults(makeFinal = true) class FieldDefaults1 { + static int STATIC = 3; final int x; @lombok.experimental.NonFinal int y; + <clinit>() { + } FieldDefaults1(int x) { super(); this.x = x; } } @lombok.experimental.FieldDefaults(level = lombok.AccessLevel.PRIVATE) class FieldDefaults2 { + static int STATIC = 3; @lombok.experimental.PackagePrivate int x; private int y; + <clinit>() { + } FieldDefaults2() { super(); } diff --git a/test/transform/resource/after-ecj/GetterLazyTransient.java b/test/transform/resource/after-ecj/GetterLazyTransient.java new file mode 100644 index 00000000..9bc0d9ae --- /dev/null +++ b/test/transform/resource/after-ecj/GetterLazyTransient.java @@ -0,0 +1,28 @@ +class GetterLazyTransient { + private final @lombok.Getter(lazy = true) java.util.concurrent.atomic.AtomicReference<java.lang.Object> nonTransientField = new java.util.concurrent.atomic.AtomicReference<java.lang.Object>(); + private final transient @lombok.Getter(lazy = true) int transientField = 2; + private final transient @lombok.Getter int nonLazyTransientField = 3; + GetterLazyTransient() { + super(); + } + public @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") int getNonTransientField() { + java.lang.Object value = this.nonTransientField.get(); + if ((value == null)) + { + synchronized (this.nonTransientField) + { + value = this.nonTransientField.get(); + if ((value == null)) + { + final int actualValue = 1; + value = actualValue; + this.nonTransientField.set(value); + } + } + } + return (java.lang.Integer) value; + } + public @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") int getNonLazyTransientField() { + return this.nonLazyTransientField; + } +}
\ No newline at end of file diff --git a/test/transform/resource/after-ecj/NoArgsConstructorForce.java b/test/transform/resource/after-ecj/NoArgsConstructorForce.java new file mode 100644 index 00000000..d0e69b0d --- /dev/null +++ b/test/transform/resource/after-ecj/NoArgsConstructorForce.java @@ -0,0 +1,12 @@ +import lombok.NoArgsConstructor; +public @NoArgsConstructor(force = true) class NoArgsConstructorForce { + private final int[] i; + private final Object[] o; + private final java.util.List<?>[] fullQualifiedList; + public @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") NoArgsConstructorForce() { + super(); + this.i = null; + this.o = null; + this.fullQualifiedList = null; + } +}
\ No newline at end of file diff --git a/test/transform/resource/after-ecj/ValNullInit.java b/test/transform/resource/after-ecj/ValNullInit.java new file mode 100644 index 00000000..bd89c023 --- /dev/null +++ b/test/transform/resource/after-ecj/ValNullInit.java @@ -0,0 +1,10 @@ +import lombok.val; + +class ValNullInit { + ValNullInit() { + super(); + } + void method() { + final @val java.lang.Object x = null; + } +}
\ No newline at end of file diff --git a/test/transform/resource/after-ecj/ValueStaticField.java b/test/transform/resource/after-ecj/ValueStaticField.java index 4ce84a02..75e337ce 100644 --- a/test/transform/resource/after-ecj/ValueStaticField.java +++ b/test/transform/resource/after-ecj/ValueStaticField.java @@ -1,7 +1,7 @@ import lombok.Value; final @Value class ValueStaticField { - private static int x; - private static final String PASSWORD = "Ken sent me"; + static int x; + static String PASSWORD = "Ken sent me"; <clinit>() { } public @java.lang.Override @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") boolean equals(final java.lang.Object o) { diff --git a/test/transform/resource/after-ecj/VarComplex.java b/test/transform/resource/after-ecj/VarComplex.java new file mode 100644 index 00000000..10c456eb --- /dev/null +++ b/test/transform/resource/after-ecj/VarComplex.java @@ -0,0 +1,26 @@ +import lombok.experimental.var; +public class VarComplex { + private String field = ""; + private static final int CONSTANT = 20; + <clinit>() { + } + public VarComplex() { + super(); + } + public void testComplex() { + @var char[] shouldBeCharArray = field.toCharArray(); + @var int shouldBeInt = CONSTANT; + @var java.lang.Object lock = new Object(); + synchronized (lock) + { + @var int field = 20; + @var int inner = 10; + switch (field) { + case 5 : + @var char[] shouldBeCharArray2 = shouldBeCharArray; + @var int innerInner = inner; + } + } + @var java.lang.String shouldBeString = field; + } +}
\ No newline at end of file diff --git a/test/transform/resource/after-ecj/VarInFor.java b/test/transform/resource/after-ecj/VarInFor.java new file mode 100644 index 00000000..0192aaed --- /dev/null +++ b/test/transform/resource/after-ecj/VarInFor.java @@ -0,0 +1,14 @@ +import lombok.experimental.var; +public class VarInFor { + public VarInFor() { + super(); + } + public void enhancedFor() { + int[] list = new int[]{1, 2}; + for (@var int shouldBeInt : list) + { + System.out.println(shouldBeInt); + @var int shouldBeInt2 = shouldBeInt; + } + } +}
\ No newline at end of file diff --git a/test/transform/resource/after-ecj/VarInForOld.java b/test/transform/resource/after-ecj/VarInForOld.java new file mode 100644 index 00000000..98fedf03 --- /dev/null +++ b/test/transform/resource/after-ecj/VarInForOld.java @@ -0,0 +1,12 @@ +import lombok.experimental.var; +public class VarInForOld { + public VarInForOld() { + super(); + } + public void oldFor() { + for (@var int i = 0;; (i < 100); ++ i) + { + System.out.println(i); + } + } +}
\ No newline at end of file diff --git a/test/transform/resource/after-ecj/VarModifier.java b/test/transform/resource/after-ecj/VarModifier.java new file mode 100644 index 00000000..d11142ca --- /dev/null +++ b/test/transform/resource/after-ecj/VarModifier.java @@ -0,0 +1,12 @@ +import lombok.experimental.var; +public class VarModifier { + private String field = ""; + public VarModifier() { + super(); + } + public void testComplex() { + final @var char[] shouldBeFinalCharArray = field.toCharArray(); + @var char[] shouldBeCharArray = field.toCharArray(); + + } +}
\ No newline at end of file diff --git a/test/transform/resource/after-ecj/VarNullInit.java b/test/transform/resource/after-ecj/VarNullInit.java new file mode 100644 index 00000000..3eb2d506 --- /dev/null +++ b/test/transform/resource/after-ecj/VarNullInit.java @@ -0,0 +1,9 @@ +import lombok.experimental.var; +public class VarNullInit { + public VarNullInit() { + super(); + } + void method() { + @var java.lang.Object x = null; + } +}
\ No newline at end of file diff --git a/test/transform/resource/before/BuilderWithTolerate.java b/test/transform/resource/before/BuilderWithTolerate.java new file mode 100644 index 00000000..48fefce5 --- /dev/null +++ b/test/transform/resource/before/BuilderWithTolerate.java @@ -0,0 +1,18 @@ +import lombok.Builder; +import lombok.experimental.Tolerate; + +@Builder +public class BuilderWithTolerate { + private final int value; + + public static void main(String[] args) { + BuilderWithTolerate.builder().value("42").build(); + } + + public static class BuilderWithTolerateBuilder { + @Tolerate + public BuilderWithTolerateBuilder value(String s) { + return this.value(Integer.parseInt(s)); + } + } +}
\ No newline at end of file diff --git a/test/transform/resource/before/FieldDefaults.java b/test/transform/resource/before/FieldDefaults.java index ffe89734..97389411 100644 --- a/test/transform/resource/before/FieldDefaults.java +++ b/test/transform/resource/before/FieldDefaults.java @@ -1,5 +1,6 @@ @lombok.experimental.FieldDefaults(makeFinal = true) class FieldDefaults1 { + static int STATIC = 3; int x; @lombok.experimental.NonFinal int y; @@ -10,6 +11,7 @@ class FieldDefaults1 { @lombok.experimental.FieldDefaults(level = lombok.AccessLevel.PRIVATE) class FieldDefaults2 { + static int STATIC = 3; @lombok.experimental.PackagePrivate int x; int y; }
\ No newline at end of file diff --git a/test/transform/resource/before/GetterLazyTransient.java b/test/transform/resource/before/GetterLazyTransient.java new file mode 100644 index 00000000..1a913669 --- /dev/null +++ b/test/transform/resource/before/GetterLazyTransient.java @@ -0,0 +1,10 @@ +class GetterLazyTransient { + @lombok.Getter(lazy=true) + private final int nonTransientField = 1; + + @lombok.Getter(lazy=true) + private final transient int transientField = 2; + + @lombok.Getter + private final transient int nonLazyTransientField = 3; +} diff --git a/test/transform/resource/before/NoArgsConstructorForce.java b/test/transform/resource/before/NoArgsConstructorForce.java new file mode 100644 index 00000000..48df1a37 --- /dev/null +++ b/test/transform/resource/before/NoArgsConstructorForce.java @@ -0,0 +1,8 @@ +import lombok.NoArgsConstructor; + +@NoArgsConstructor(force = true) +public class NoArgsConstructorForce { + private final int[] i; + private final Object[] o; + private final java.util.List<?>[] fullQualifiedList; +}
\ No newline at end of file diff --git a/test/transform/resource/before/ValNullInit.java b/test/transform/resource/before/ValNullInit.java new file mode 100644 index 00000000..649bc0cd --- /dev/null +++ b/test/transform/resource/before/ValNullInit.java @@ -0,0 +1,7 @@ +import lombok.val; + +class ValNullInit { + void method() { + val x = null; + } +}
\ No newline at end of file diff --git a/test/transform/resource/before/VarComplex.java b/test/transform/resource/before/VarComplex.java new file mode 100644 index 00000000..bfaa8804 --- /dev/null +++ b/test/transform/resource/before/VarComplex.java @@ -0,0 +1,23 @@ +//CONF: lombok.var.flagUsage = ALLOW +import lombok.experimental.var; + +public class VarComplex { + private String field = ""; + private static final int CONSTANT = 20; + + public void testComplex() { + var shouldBeCharArray = field.toCharArray(); + var shouldBeInt = CONSTANT; + var lock = new Object(); + synchronized (lock) { + var field = 20; //Shadowing + var inner = 10; + switch (field) { + case 5: + var shouldBeCharArray2 = shouldBeCharArray; + var innerInner = inner; + } + } + var shouldBeString = field; //Unshadowing + } +}
\ No newline at end of file diff --git a/test/transform/resource/before/VarInFor.java b/test/transform/resource/before/VarInFor.java new file mode 100644 index 00000000..cc8c387e --- /dev/null +++ b/test/transform/resource/before/VarInFor.java @@ -0,0 +1,12 @@ +//CONF: lombok.var.flagUsage = ALLOW +import lombok.experimental.var; + +public class VarInFor { + public void enhancedFor() { + int[] list = new int[] {1, 2}; + for (var shouldBeInt : list) { + System.out.println(shouldBeInt); + var shouldBeInt2 = shouldBeInt; + } + } +}
\ No newline at end of file diff --git a/test/transform/resource/before/VarInForOld.java b/test/transform/resource/before/VarInForOld.java new file mode 100644 index 00000000..f90aba7f --- /dev/null +++ b/test/transform/resource/before/VarInForOld.java @@ -0,0 +1,10 @@ +//CONF: lombok.var.flagUsage = ALLOW +import lombok.experimental.var; + +public class VarInForOld { + public void oldFor() { + for (var i = 0; i < 100; ++i) { + System.out.println(i); + } + } +}
\ No newline at end of file diff --git a/test/transform/resource/before/VarModifier.java b/test/transform/resource/before/VarModifier.java new file mode 100644 index 00000000..7250c1c5 --- /dev/null +++ b/test/transform/resource/before/VarModifier.java @@ -0,0 +1,11 @@ +//CONF: lombok.var.flagUsage = ALLOW +import lombok.experimental.var; + +public class VarModifier { + private String field = ""; + + public void testComplex() { + final var shouldBeFinalCharArray = field.toCharArray(); + var shouldBeCharArray = field.toCharArray(); + } +}
\ No newline at end of file diff --git a/test/transform/resource/before/VarNullInit.java b/test/transform/resource/before/VarNullInit.java new file mode 100644 index 00000000..efdc9d9e --- /dev/null +++ b/test/transform/resource/before/VarNullInit.java @@ -0,0 +1,8 @@ +//CONF: lombok.var.flagUsage = ALLOW +import lombok.experimental.var; + +public class VarNullInit { + void method() { + var x = null; + } +}
\ No newline at end of file diff --git a/test/transform/resource/before/VarWarning.java b/test/transform/resource/before/VarWarning.java new file mode 100644 index 00000000..85559587 --- /dev/null +++ b/test/transform/resource/before/VarWarning.java @@ -0,0 +1,10 @@ +//CONF: lombok.var.flagUsage = WARNING +//skip compare contents +import lombok.experimental.var; + +public class VarWarning { + public void isOkay() { + var x = "Warning"; + x.toLowerCase(); + } +}
\ No newline at end of file diff --git a/test/transform/resource/messages-delombok/GetterLazyTransient.java.messages b/test/transform/resource/messages-delombok/GetterLazyTransient.java.messages new file mode 100644 index 00000000..8c1873eb --- /dev/null +++ b/test/transform/resource/messages-delombok/GetterLazyTransient.java.messages @@ -0,0 +1 @@ +5 'lazy' is not supported on transient fields.
\ No newline at end of file diff --git a/test/transform/resource/messages-delombok/VarNullInit.java.messages b/test/transform/resource/messages-delombok/VarNullInit.java.messages new file mode 100644 index 00000000..190ab7c4 --- /dev/null +++ b/test/transform/resource/messages-delombok/VarNullInit.java.messages @@ -0,0 +1 @@ +6 variable initializer is 'null'
\ No newline at end of file diff --git a/test/transform/resource/messages-delombok/VarWarning.java.messages b/test/transform/resource/messages-delombok/VarWarning.java.messages new file mode 100644 index 00000000..48c89581 --- /dev/null +++ b/test/transform/resource/messages-delombok/VarWarning.java.messages @@ -0,0 +1 @@ +7 Use of var is flagged according to lombok configuration
\ No newline at end of file diff --git a/test/transform/resource/messages-ecj/GetterLazyTransient.java.messages b/test/transform/resource/messages-ecj/GetterLazyTransient.java.messages new file mode 100644 index 00000000..8c1873eb --- /dev/null +++ b/test/transform/resource/messages-ecj/GetterLazyTransient.java.messages @@ -0,0 +1 @@ +5 'lazy' is not supported on transient fields.
\ No newline at end of file diff --git a/test/transform/resource/messages-ecj/VarNullInit.java.messages b/test/transform/resource/messages-ecj/VarNullInit.java.messages new file mode 100644 index 00000000..190ab7c4 --- /dev/null +++ b/test/transform/resource/messages-ecj/VarNullInit.java.messages @@ -0,0 +1 @@ +6 variable initializer is 'null'
\ No newline at end of file diff --git a/test/transform/resource/messages-ecj/VarWarning.java.messages b/test/transform/resource/messages-ecj/VarWarning.java.messages new file mode 100644 index 00000000..48c89581 --- /dev/null +++ b/test/transform/resource/messages-ecj/VarWarning.java.messages @@ -0,0 +1 @@ +7 Use of var is flagged according to lombok configuration
\ No newline at end of file |