diff options
author | Reinier Zwitserloot <reinier@zwitserloot.com> | 2010-11-03 00:42:58 +0100 |
---|---|---|
committer | Reinier Zwitserloot <reinier@zwitserloot.com> | 2010-11-03 00:42:58 +0100 |
commit | f1cf083890c223bf7245190264438740ee724bc9 (patch) | |
tree | 769894a3fccdbd9c7d44f241f700bbc9550c653b /test/transform/resource/after-delombok | |
parent | d9ba2a191ac71e7d8689f1ad0e99160b1c8dae3d (diff) | |
download | lombok-f1cf083890c223bf7245190264438740ee724bc9.tar.gz lombok-f1cf083890c223bf7245190264438740ee724bc9.tar.bz2 lombok-f1cf083890c223bf7245190264438740ee724bc9.zip |
val in java, including tests and javac resolution utilities.
Diffstat (limited to 'test/transform/resource/after-delombok')
6 files changed, 145 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 |