diff options
author | Reinier Zwitserloot <reinier@zwitserloot.com> | 2012-10-29 23:12:14 +0100 |
---|---|---|
committer | Reinier Zwitserloot <reinier@zwitserloot.com> | 2012-10-29 23:12:14 +0100 |
commit | b8e1f3bdeb622ba92b25f12a4eff35ea5f75908c (patch) | |
tree | d95847e42ac944cab8ed557d7d3eb917756a0261 /test | |
parent | 7bd3851f68c8aadf6fcc9cd6c37fd1b4737ff906 (diff) | |
download | lombok-b8e1f3bdeb622ba92b25f12a4eff35ea5f75908c.tar.gz lombok-b8e1f3bdeb622ba92b25f12a4eff35ea5f75908c.tar.bz2 lombok-b8e1f3bdeb622ba92b25f12a4eff35ea5f75908c.zip |
added tests for lub and val (lub = finding the common supertype, for example in a ternary expression).
Diffstat (limited to 'test')
-rw-r--r-- | test/transform/resource/after-delombok/ValLub.java | 18 | ||||
-rw-r--r-- | test/transform/resource/after-ecj/ValLub.java | 21 | ||||
-rw-r--r-- | test/transform/resource/before/ValLub.java | 23 |
3 files changed, 62 insertions, 0 deletions
diff --git a/test/transform/resource/after-delombok/ValLub.java b/test/transform/resource/after-delombok/ValLub.java new file mode 100644 index 00000000..d7e8f944 --- /dev/null +++ b/test/transform/resource/after-delombok/ValLub.java @@ -0,0 +1,18 @@ +class ValLub { + public void easyLub() { + java.util.Map<String, Number> m = java.util.Collections.emptyMap(); + final java.util.Map<java.lang.String, java.lang.Number> foo = (System.currentTimeMillis() > 0) ? m : java.util.Collections.<String, Number>emptyMap(); + } + public void sillyLubWithUnboxingThatProducesErrorThatVarIsPrimitive() { + Integer i = 20; + Double d = 20.0; + final double thisShouldBePrimitiveDouble = (System.currentTimeMillis() > 0) ? i : d; + } + public void hardLub() { + java.util.List<String> list = new java.util.ArrayList<String>(); + java.util.Set<String> set = new java.util.HashSet<String>(); + final java.util.Collection<java.lang.String> thisShouldBeCollection = (System.currentTimeMillis() > 0) ? list : set; + thisShouldBeCollection.add(""); + String foo = thisShouldBeCollection.iterator().next(); + } +}
\ No newline at end of file diff --git a/test/transform/resource/after-ecj/ValLub.java b/test/transform/resource/after-ecj/ValLub.java new file mode 100644 index 00000000..6fee1ae6 --- /dev/null +++ b/test/transform/resource/after-ecj/ValLub.java @@ -0,0 +1,21 @@ +class ValLub { + ValLub() { + super(); + } + public void easyLub() { + java.util.Map<String, Number> m = java.util.Collections.emptyMap(); + final @lombok.val java.util.Map<java.lang.String, java.lang.Number> foo = ((System.currentTimeMillis() > 0) ? m : java.util.Collections.<String, Number>emptyMap()); + } + public void sillyLubWithUnboxingThatProducesErrorThatVarIsPrimitive() { + Integer i = 20; + Double d = 20.0; + final @lombok.val double thisShouldBePrimitiveDouble = ((System.currentTimeMillis() > 0) ? i : d); + } + public void hardLub() { + java.util.List<String> list = new java.util.ArrayList<String>(); + java.util.Set<String> set = new java.util.HashSet<String>(); + final @lombok.val java.util.Collection<java.lang.String> thisShouldBeCollection = ((System.currentTimeMillis() > 0) ? list : set); + thisShouldBeCollection.add(""); + String foo = thisShouldBeCollection.iterator().next(); + } +} diff --git a/test/transform/resource/before/ValLub.java b/test/transform/resource/before/ValLub.java new file mode 100644 index 00000000..c1b41c26 --- /dev/null +++ b/test/transform/resource/before/ValLub.java @@ -0,0 +1,23 @@ +class ValLub { + public void easyLub() { + java.util.Map<String, Number> m = java.util.Collections.emptyMap(); + + lombok.val foo = (System.currentTimeMillis() > 0) ? m : java.util.Collections.<String, Number>emptyMap(); + } + + public void sillyLubWithUnboxingThatProducesErrorThatVarIsPrimitive() { + Integer i = 20; + Double d = 20.0; + + lombok.val thisShouldBePrimitiveDouble = (System.currentTimeMillis() > 0) ? i : d; + } + + public void hardLub() { + java.util.List<String> list = new java.util.ArrayList<String>(); + java.util.Set<String> set = new java.util.HashSet<String>(); + + lombok.val thisShouldBeCollection = (System.currentTimeMillis() > 0) ? list : set; + thisShouldBeCollection.add(""); + String foo = thisShouldBeCollection.iterator().next(); + } +} |