diff options
Diffstat (limited to 'test/transform')
13 files changed, 307 insertions, 0 deletions
diff --git a/test/transform/resource/after-delombok/ValComplex.java b/test/transform/resource/after-delombok/ValComplex.java new file mode 100644 index 00000000..54ef5c78 --- /dev/null +++ b/test/transform/resource/after-delombok/ValComplex.java @@ -0,0 +1,20 @@ +public class ValComplex { + private ValSimple field = new ValSimple(); + private static final int CONSTANT = 20; + public void testReferencingOtherFiles() { + final java.lang.String shouldBeString = field.method(); + final int shouldBeInt = CONSTANT; + final java.lang.Object lock = new Object(); + synchronized (lock) { + final int field = 20; //Shadowing + final int inner = 10; + switch (field) { + case 5: + final java.lang.String shouldBeString2 = shouldBeString; + final int innerInner = inner; + + } + } + final ValSimple shouldBeValSimple = field; //Unshadowing + } +}
\ No newline at end of file diff --git a/test/transform/resource/after-delombok/ValErrors.java b/test/transform/resource/after-delombok/ValErrors.java new file mode 100644 index 00000000..5ac785ab --- /dev/null +++ b/test/transform/resource/after-delombok/ValErrors.java @@ -0,0 +1,8 @@ +public class ValErrors { + public void nullType() { + final val a = null; + } + public void unresolvableExpression() { + final val c = d; + } +}
\ No newline at end of file diff --git a/test/transform/resource/after-delombok/ValInFor.java b/test/transform/resource/after-delombok/ValInFor.java new file mode 100644 index 00000000..d97ce732 --- /dev/null +++ b/test/transform/resource/after-delombok/ValInFor.java @@ -0,0 +1,20 @@ +public class ValInFor { + { + final int x = 10; + final int x2 = -1; + final java.lang.String a = "Hello"; + for (final int y = x, z = x2; y < 20; y++) { + final int q = y; + final int w = z; + final java.lang.String v = a; + } + } +/* public void enhancedFor() { + java.util.List<String> list = java.util.Arrays.asList("Hello, World!"); + for (val shouldBeString : list) { + System.out.println(shouldBeString.toLowerCase()); + val shouldBeString2 = shouldBeString; + } + } +*/ +}
\ No newline at end of file diff --git a/test/transform/resource/after-delombok/ValLessSimple.java b/test/transform/resource/after-delombok/ValLessSimple.java new file mode 100644 index 00000000..678b419e --- /dev/null +++ b/test/transform/resource/after-delombok/ValLessSimple.java @@ -0,0 +1,26 @@ +public class ValLessSimple { + private short field2 = 5; + private String method() { + return "method"; + } + private double method2() { + return 2.0; + } + { + System.out.println("Hello"); + final int z = 20; + final int x = 10; + final int a = z; + final short y = field2; + } + private void testVal(String param) { + final java.lang.String fieldV = field; + final int a = 10; + final int b = 20; + { + final java.lang.String methodV = method(); + final java.lang.String foo = fieldV + methodV; + } + } + private String field = "field"; +}
\ No newline at end of file diff --git a/test/transform/resource/after-delombok/ValSimple.java b/test/transform/resource/after-delombok/ValSimple.java new file mode 100644 index 00000000..b2783eac --- /dev/null +++ b/test/transform/resource/after-delombok/ValSimple.java @@ -0,0 +1,24 @@ +public class ValSimple { + private String field = "field"; + private short field2 = 5; + + private String method() { + return "method"; + } + + private double method2() { + return 2.0; + } + + private void testVal(String param) { + final java.lang.String fieldV = field; + final java.lang.String methodV = method(); + final java.lang.String paramV = param; + final java.lang.String valOfVal = fieldV; + final java.lang.String operatorV = fieldV + valOfVal; + final short fieldW = field2; + final double methodW = method2(); + byte localVar = 3; + final int operatorW = fieldW + localVar; + } +} diff --git a/test/transform/resource/after-delombok/ValWeirdTypes.java b/test/transform/resource/after-delombok/ValWeirdTypes.java new file mode 100644 index 00000000..66212906 --- /dev/null +++ b/test/transform/resource/after-delombok/ValWeirdTypes.java @@ -0,0 +1,47 @@ +import java.util.*; +public class ValWeirdTypes<Z> { + private final List<Z> fieldList; + public void testGenerics() { + List<String> list = new ArrayList<String>(); + list.add("Hello, World!"); + final java.lang.String shouldBeString = list.get(0); + final java.util.List<java.lang.String> shouldBeListOfString = list; + final java.util.List<java.lang.String> shouldBeListOfStringToo = Arrays.asList("hello", "world"); + final java.lang.String shouldBeString2 = shouldBeListOfString.get(0); + } + public void testGenericsInference() { + final java.util.List<java.lang.Object> huh = Collections.emptyList(); + final java.util.List<java.lang.Number> huh2 = Collections.<Number>emptyList(); + } + public void testPrimitives() { + final int x = 10; + final long y = 5 + 3L; + } + public void testAnonymousInnerClass() { + final java.lang.Runnable y = new Runnable(){ + public void run() { + } + }; + } + public <T extends Number>void testTypeParams(List<T> param) { + final T t = param.get(0); + final Z z = fieldList.get(0); + final java.util.List<T> k = param; + final java.util.List<Z> y = fieldList; + } + public void testBounds(List<? extends Number> lower, List<? super Number> upper) { + final java.lang.Number a = lower.get(0); + final java.lang.Object b = upper.get(0); + final java.util.List<? extends java.lang.Number> c = lower; + final java.util.List<? super java.lang.Number> d = upper; + List<?> unbound = lower; + final java.util.List<?> e = unbound; + } + public void testCompound() { + final java.util.ArrayList<java.lang.String> a = new ArrayList<String>(); + final java.util.Vector<java.lang.String> b = new Vector<String>(); + final boolean c = 1 < System.currentTimeMillis(); + final java.util.AbstractList<java.lang.String> d = c ? a : b; + java.util.RandomAccess confirm = c ? a : b; + } +}
\ No newline at end of file diff --git a/test/transform/resource/before/ValComplex.java b/test/transform/resource/before/ValComplex.java new file mode 100644 index 00000000..5f718003 --- /dev/null +++ b/test/transform/resource/before/ValComplex.java @@ -0,0 +1,20 @@ +public class ValComplex { + private ValSimple field = new ValSimple(); + private static final int CONSTANT = 20; + + public void testReferencingOtherFiles() { + val shouldBeString = field.method(); + val shouldBeInt = CONSTANT; + val lock = new Object(); + synchronized (lock) { + val field = 20; //Shadowing + val inner = 10; + switch (field) { + case 5: + val shouldBeString2 = shouldBeString; + val innerInner = inner; + } + } + val shouldBeValSimple = field; //Unshadowing + } +}
\ No newline at end of file diff --git a/test/transform/resource/before/ValErrors.java b/test/transform/resource/before/ValErrors.java new file mode 100644 index 00000000..742bca6d --- /dev/null +++ b/test/transform/resource/before/ValErrors.java @@ -0,0 +1,9 @@ +public class ValErrors { + public void nullType() { + val a = null; + } + + public void unresolvableExpression() { + val c = d; + } +}
\ No newline at end of file diff --git a/test/transform/resource/before/ValInFor.java b/test/transform/resource/before/ValInFor.java new file mode 100644 index 00000000..af13540e --- /dev/null +++ b/test/transform/resource/before/ValInFor.java @@ -0,0 +1,20 @@ +public class ValInFor { + { + val x = 10; + val x2 = -1; + val a = "Hello"; + for (val y = x, z = x2; y < 20; y++) { + val q = y; + val w = z; + val v = a; + } + } + +/* public void enhancedFor() { + java.util.List<String> list = java.util.Arrays.asList("Hello, World!"); + for (val shouldBeString : list) { + System.out.println(shouldBeString.toLowerCase()); + val shouldBeString2 = shouldBeString; + } + }*/ +}
\ No newline at end of file diff --git a/test/transform/resource/before/ValLessSimple.java b/test/transform/resource/before/ValLessSimple.java new file mode 100644 index 00000000..bae7b73b --- /dev/null +++ b/test/transform/resource/before/ValLessSimple.java @@ -0,0 +1,31 @@ +public class ValLessSimple { + private short field2 = 5; + + private String method() { + return "method"; + } + + private double method2() { + return 2.0; + } + + { + System.out.println("Hello"); + val z = 20; + val x = 10; + val a = z; + val y = field2; + } + + private void testVal(String param) { + val fieldV = field; + val a = 10; + val b = 20; + { + val methodV = method(); + val foo = fieldV + methodV; + } + } + + private String field = "field"; +} diff --git a/test/transform/resource/before/ValSimple.java b/test/transform/resource/before/ValSimple.java new file mode 100644 index 00000000..15508bbc --- /dev/null +++ b/test/transform/resource/before/ValSimple.java @@ -0,0 +1,26 @@ +public class ValSimple { + private String field = "field"; + private short field2 = 5; + + private String method() { + return "method"; + } + + private double method2() { + return 2.0; + } + + private void testVal(String param) { + val fieldV = field; + val methodV = method(); + val paramV = param; + + val valOfVal = fieldV; + val operatorV = fieldV + valOfVal; + + val fieldW = field2; + val methodW = method2(); + byte localVar = 3; + val operatorW = fieldW + localVar; + } +} diff --git a/test/transform/resource/before/ValWeirdTypes.java b/test/transform/resource/before/ValWeirdTypes.java new file mode 100644 index 00000000..6f6eb9db --- /dev/null +++ b/test/transform/resource/before/ValWeirdTypes.java @@ -0,0 +1,54 @@ +import java.util.*; + +public class ValWeirdTypes<Z> { + private final List<Z> fieldList; + + public void testGenerics() { + List<String> list = new ArrayList<String>(); + list.add("Hello, World!"); + val shouldBeString = list.get(0); + val shouldBeListOfString = list; + val shouldBeListOfStringToo = Arrays.asList("hello", "world"); + val shouldBeString2 = shouldBeListOfString.get(0); + } + + public void testGenericsInference() { + val huh = Collections.emptyList(); + val huh2 = Collections.<Number>emptyList(); + } + + public void testPrimitives() { + val x = 10; + val y = 5 + 3L; + } + + public void testAnonymousInnerClass() { + val y = new Runnable() { + public void run() {} + }; + } + + public <T extends Number> void testTypeParams(List<T> param) { + val t = param.get(0); + val z = fieldList.get(0); + val k = param; + val y = fieldList; + } + + public void testBounds(List<? extends Number> lower, List<? super Number> upper) { + val a = lower.get(0); + val b = upper.get(0); + val c = lower; + val d = upper; + List<?> unbound = lower; + val e = unbound; + } + + public void testCompound() { + val a = new ArrayList<String>(); + val b = new Vector<String>(); + val c = 1 < System.currentTimeMillis(); + val d = c ? a : b; + java.util.RandomAccess confirm = c ? a : b; + } +}
\ No newline at end of file diff --git a/test/transform/resource/messages-delombok/ValErrors.java.messages b/test/transform/resource/messages-delombok/ValErrors.java.messages new file mode 100644 index 00000000..feba6912 --- /dev/null +++ b/test/transform/resource/messages-delombok/ValErrors.java.messages @@ -0,0 +1,2 @@ +3:21 ERROR Cannot use 'val' here because initializer expression does not have a representable type: <nulltype> +7:21 ERROR Cannot use 'val' here because initializer expression does not have a representable type: Type cannot be resolved |