diff options
author | Reinier Zwitserloot <reinier@zwitserloot.com> | 2018-02-06 22:12:42 +0100 |
---|---|---|
committer | Reinier Zwitserloot <reinier@zwitserloot.com> | 2018-02-07 00:01:22 +0100 |
commit | 66469e04fe35e5ceb3723cb563379a03e4883101 (patch) | |
tree | a457e2973556c795a7879279b9c39f4ed5f7cb42 /test | |
parent | 55bcc142d08ac8a4de0c3965333e3816c496799f (diff) | |
download | lombok-66469e04fe35e5ceb3723cb563379a03e4883101.tar.gz lombok-66469e04fe35e5ceb3723cb563379a03e4883101.tar.bz2 lombok-66469e04fe35e5ceb3723cb563379a03e4883101.zip |
[var] various upgrades to var:
* var is promoted to the main package.
* It is no longer an opt-in thing.
* bug: var (unlike val) is allowed in old-style for loops, but if you multi-init: for (var i = 0, j="Foo";;), you now get an error that you can't do that.
* tests both for the multi-for situation and the new main package variant.
Diffstat (limited to 'test')
21 files changed, 45 insertions, 19 deletions
diff --git a/test/transform/resource/after-delombok/VarWarning.java b/test/transform/resource/after-delombok/VarWarning.java new file mode 100644 index 00000000..a333c87c --- /dev/null +++ b/test/transform/resource/after-delombok/VarWarning.java @@ -0,0 +1,6 @@ +public class VarWarning { + public void isOkay() { + java.lang.String x = "Warning"; + x.toLowerCase(); + } +}
\ No newline at end of file diff --git a/test/transform/resource/after-ecj/VarComplex.java b/test/transform/resource/after-ecj/VarComplex.java index 10c456eb..97a0a177 100644 --- a/test/transform/resource/after-ecj/VarComplex.java +++ b/test/transform/resource/after-ecj/VarComplex.java @@ -1,4 +1,4 @@ -import lombok.experimental.var; +import lombok.var; public class VarComplex { private String field = ""; private static final int CONSTANT = 20; diff --git a/test/transform/resource/after-ecj/VarInFor.java b/test/transform/resource/after-ecj/VarInFor.java index 0192aaed..1799d9b7 100644 --- a/test/transform/resource/after-ecj/VarInFor.java +++ b/test/transform/resource/after-ecj/VarInFor.java @@ -1,4 +1,4 @@ -import lombok.experimental.var; +import lombok.var; public class VarInFor { public VarInFor() { super(); diff --git a/test/transform/resource/after-ecj/VarInForOld.java b/test/transform/resource/after-ecj/VarInForOld.java index 98fedf03..065ea94d 100644 --- a/test/transform/resource/after-ecj/VarInForOld.java +++ b/test/transform/resource/after-ecj/VarInForOld.java @@ -1,4 +1,4 @@ -import lombok.experimental.var; +import lombok.var; public class VarInForOld { public VarInForOld() { super(); diff --git a/test/transform/resource/after-ecj/VarNullInit.java b/test/transform/resource/after-ecj/VarNullInit.java index 3eb2d506..848744cc 100644 --- a/test/transform/resource/after-ecj/VarNullInit.java +++ b/test/transform/resource/after-ecj/VarNullInit.java @@ -1,4 +1,4 @@ -import lombok.experimental.var; +import lombok.var; public class VarNullInit { public VarNullInit() { super(); diff --git a/test/transform/resource/after-ecj/VarWarning.java b/test/transform/resource/after-ecj/VarWarning.java new file mode 100644 index 00000000..4caf90f8 --- /dev/null +++ b/test/transform/resource/after-ecj/VarWarning.java @@ -0,0 +1,10 @@ +import lombok.var; +public class VarWarning { + public VarWarning() { + super(); + } + public void isOkay() { + @var java.lang.String x = "Warning"; + x.toLowerCase(); + } +}
\ No newline at end of file diff --git a/test/transform/resource/before/VarComplex.java b/test/transform/resource/before/VarComplex.java index bfaa8804..c93e177a 100644 --- a/test/transform/resource/before/VarComplex.java +++ b/test/transform/resource/before/VarComplex.java @@ -1,5 +1,4 @@ -//CONF: lombok.var.flagUsage = ALLOW -import lombok.experimental.var; +import lombok.var; public class VarComplex { private String field = ""; diff --git a/test/transform/resource/before/VarInFor.java b/test/transform/resource/before/VarInFor.java index cc8c387e..7f7bb7a7 100644 --- a/test/transform/resource/before/VarInFor.java +++ b/test/transform/resource/before/VarInFor.java @@ -1,5 +1,4 @@ -//CONF: lombok.var.flagUsage = ALLOW -import lombok.experimental.var; +import lombok.var; public class VarInFor { public void enhancedFor() { diff --git a/test/transform/resource/before/VarInForOld.java b/test/transform/resource/before/VarInForOld.java index f90aba7f..99e83b57 100644 --- a/test/transform/resource/before/VarInForOld.java +++ b/test/transform/resource/before/VarInForOld.java @@ -1,5 +1,4 @@ -//CONF: lombok.var.flagUsage = ALLOW -import lombok.experimental.var; +import lombok.var; public class VarInForOld { public void oldFor() { diff --git a/test/transform/resource/before/VarInForOldMulti.java b/test/transform/resource/before/VarInForOldMulti.java new file mode 100644 index 00000000..e2ea9682 --- /dev/null +++ b/test/transform/resource/before/VarInForOldMulti.java @@ -0,0 +1,10 @@ +//skip compare contents +import lombok.var; + +public class VarInForOldMulti { + public void oldForMulti() { + for (var i = 0, j = "Hey"; 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 index 7250c1c5..5c68caa7 100644 --- a/test/transform/resource/before/VarModifier.java +++ b/test/transform/resource/before/VarModifier.java @@ -1,4 +1,3 @@ -//CONF: lombok.var.flagUsage = ALLOW import lombok.experimental.var; public class VarModifier { diff --git a/test/transform/resource/before/VarNullInit.java b/test/transform/resource/before/VarNullInit.java index efdc9d9e..f9bb53a3 100644 --- a/test/transform/resource/before/VarNullInit.java +++ b/test/transform/resource/before/VarNullInit.java @@ -1,5 +1,4 @@ -//CONF: lombok.var.flagUsage = ALLOW -import lombok.experimental.var; +import lombok.var; public class VarNullInit { void method() { diff --git a/test/transform/resource/before/VarWarning.java b/test/transform/resource/before/VarWarning.java index 85559587..90464d30 100644 --- a/test/transform/resource/before/VarWarning.java +++ b/test/transform/resource/before/VarWarning.java @@ -1,6 +1,5 @@ //CONF: lombok.var.flagUsage = WARNING -//skip compare contents -import lombok.experimental.var; +import lombok.var; public class VarWarning { public void isOkay() { diff --git a/test/transform/resource/messages-delombok/VarInForOldMulti.java.messages b/test/transform/resource/messages-delombok/VarInForOldMulti.java.messages new file mode 100644 index 00000000..f65fe823 --- /dev/null +++ b/test/transform/resource/messages-delombok/VarInForOldMulti.java.messages @@ -0,0 +1 @@ +6 'var' is not allowed in old-style for loops if there is more than 1 initializer diff --git a/test/transform/resource/messages-delombok/VarNullInit.java.messages b/test/transform/resource/messages-delombok/VarNullInit.java.messages index 190ab7c4..5a2a6ae1 100644 --- a/test/transform/resource/messages-delombok/VarNullInit.java.messages +++ b/test/transform/resource/messages-delombok/VarNullInit.java.messages @@ -1 +1 @@ -6 variable initializer is 'null'
\ No newline at end of file +5 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 index 48c89581..886e98f4 100644 --- a/test/transform/resource/messages-delombok/VarWarning.java.messages +++ b/test/transform/resource/messages-delombok/VarWarning.java.messages @@ -1 +1 @@ -7 Use of var is flagged according to lombok configuration
\ No newline at end of file +6 Use of var is flagged according to lombok configuration
\ No newline at end of file diff --git a/test/transform/resource/messages-ecj/ValInTryWithResources.java.messages b/test/transform/resource/messages-ecj/ValInTryWithResources.java.messages new file mode 100644 index 00000000..9d0d7a6e --- /dev/null +++ b/test/transform/resource/messages-ecj/ValInTryWithResources.java.messages @@ -0,0 +1 @@ +OPTIONAL 8 Resource leak: 'i' is never closed diff --git a/test/transform/resource/messages-ecj/VarInForOldMulti.java.messages b/test/transform/resource/messages-ecj/VarInForOldMulti.java.messages new file mode 100644 index 00000000..0bfd6e65 --- /dev/null +++ b/test/transform/resource/messages-ecj/VarInForOldMulti.java.messages @@ -0,0 +1 @@ +6 'var' is not allowed in old-style for loops if there is more than 1 initializer
\ No newline at end of file diff --git a/test/transform/resource/messages-ecj/VarModifier.java.messages b/test/transform/resource/messages-ecj/VarModifier.java.messages new file mode 100644 index 00000000..051d1ad7 --- /dev/null +++ b/test/transform/resource/messages-ecj/VarModifier.java.messages @@ -0,0 +1,3 @@ +1 The type var is deprecated +7 The type var is deprecated +8 The type var is deprecated diff --git a/test/transform/resource/messages-ecj/VarNullInit.java.messages b/test/transform/resource/messages-ecj/VarNullInit.java.messages index 190ab7c4..5a2a6ae1 100644 --- a/test/transform/resource/messages-ecj/VarNullInit.java.messages +++ b/test/transform/resource/messages-ecj/VarNullInit.java.messages @@ -1 +1 @@ -6 variable initializer is 'null'
\ No newline at end of file +5 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 index 48c89581..25096b84 100644 --- a/test/transform/resource/messages-ecj/VarWarning.java.messages +++ b/test/transform/resource/messages-ecj/VarWarning.java.messages @@ -1 +1 @@ -7 Use of var is flagged according to lombok configuration
\ No newline at end of file +6 Use of var is flagged according to lombok configuration.
\ No newline at end of file |