diff options
author | Reinier Zwitserloot <r.zwitserloot@projectlombok.org> | 2023-01-11 22:54:04 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-11 22:54:04 +0100 |
commit | 9388dbc1a990386dd7b3af6ac65e123f7cd89013 (patch) | |
tree | 32013941432178d435da9b1ae07ac6b1faa10927 /test | |
parent | 3705ac615a34191e3f05bf02329a9ffe09d5fa65 (diff) | |
parent | 479bd2d75d2046ee1cb337ef6aa929b707868345 (diff) | |
download | lombok-9388dbc1a990386dd7b3af6ac65e123f7cd89013.tar.gz lombok-9388dbc1a990386dd7b3af6ac65e123f7cd89013.tar.bz2 lombok-9388dbc1a990386dd7b3af6ac65e123f7cd89013.zip |
Merge pull request #3251 from Rawi01/jdk19
Add support for JDK 19
Diffstat (limited to 'test')
-rw-r--r-- | test/pretty/resource/after/RecordPattern.java | 15 | ||||
-rw-r--r-- | test/pretty/resource/after/Switch19.java | 32 | ||||
-rw-r--r-- | test/pretty/resource/before/RecordPattern.java | 16 | ||||
-rw-r--r-- | test/pretty/resource/before/Switch17.java | 2 | ||||
-rw-r--r-- | test/pretty/resource/before/Switch19.java | 33 |
5 files changed, 97 insertions, 1 deletions
diff --git a/test/pretty/resource/after/RecordPattern.java b/test/pretty/resource/after/RecordPattern.java new file mode 100644 index 00000000..ad9fae0b --- /dev/null +++ b/test/pretty/resource/after/RecordPattern.java @@ -0,0 +1,15 @@ +record Point(int x, int y) { +} +record Rectangle(Point upperLeft, Point lowerRight) { +} + +public class RecordPattern { + void recordPattern(Object o) { + if (o instanceof Point(int x, int y)) { + } + if (o instanceof Point(int x, int y) p) { + } + if (o instanceof Rectangle(Point(int x1, int y1), Point(int x2, int y2))) { + } + } +}
\ No newline at end of file diff --git a/test/pretty/resource/after/Switch19.java b/test/pretty/resource/after/Switch19.java new file mode 100644 index 00000000..5947830b --- /dev/null +++ b/test/pretty/resource/after/Switch19.java @@ -0,0 +1,32 @@ +public class Switch19 { + String switchPatternMatching(Object o) { + return switch (o) { + case Integer i -> String.format("int %d", i); + case Long l -> String.format("long %d", l); + case Double d -> String.format("double %f", d); + case String s -> String.format("String %s", s); + default -> o.toString(); + }; + } + + String switchNull(Object o) { + return switch (o) { + case null, default -> "?"; + }; + } + + String switchGuardPattern(Object o) { + return switch (o) { + case String s when s.length() > 1 -> s; + case String s -> s; + default -> o.toString(); + }; + } + + String switchParenthesizedPattern(Object o) { + return switch (o) { + case (String s) -> s; + default -> o.toString(); + }; + } +} diff --git a/test/pretty/resource/before/RecordPattern.java b/test/pretty/resource/before/RecordPattern.java new file mode 100644 index 00000000..93c07965 --- /dev/null +++ b/test/pretty/resource/before/RecordPattern.java @@ -0,0 +1,16 @@ +// version 19: +record Point(int x, int y) { +} +record Rectangle(Point upperLeft, Point lowerRight) { +} + +public class RecordPattern { + void recordPattern(Object o) { + if (o instanceof Point(int x, int y)) { + } + if (o instanceof Point(int x, int y) p) { + } + if (o instanceof Rectangle(Point(int x1, int y1), Point(int x2, int y2))) { + } + } +}
\ No newline at end of file diff --git a/test/pretty/resource/before/Switch17.java b/test/pretty/resource/before/Switch17.java index 17754e82..42a8f181 100644 --- a/test/pretty/resource/before/Switch17.java +++ b/test/pretty/resource/before/Switch17.java @@ -1,4 +1,4 @@ -// version 17: +// version 17:18 public class Switch17 { String switchPatternMatching(Object o) { return switch (o) { diff --git a/test/pretty/resource/before/Switch19.java b/test/pretty/resource/before/Switch19.java new file mode 100644 index 00000000..05b27928 --- /dev/null +++ b/test/pretty/resource/before/Switch19.java @@ -0,0 +1,33 @@ +// version 19: +public class Switch19 { + String switchPatternMatching(Object o) { + return switch (o) { + case Integer i -> String.format("int %d", i); + case Long l -> String.format("long %d", l); + case Double d -> String.format("double %f", d); + case String s -> String.format("String %s", s); + default -> o.toString(); + }; + } + + String switchNull(Object o) { + return switch (o) { + case null, default -> "?"; + }; + } + + String switchGuardPattern(Object o) { + return switch (o) { + case String s when s.length() > 1 -> s; + case String s -> s; + default -> o.toString(); + }; + } + + String switchParenthesizedPattern(Object o) { + return switch (o) { + case (String s) -> s; + default -> o.toString(); + }; + } +} |