From cb76e672053ac6da521268c796a3eda1492de750 Mon Sep 17 00:00:00 2001 From: Rawi01 Date: Sat, 24 Jun 2023 16:57:26 +0200 Subject: [PATCH] [jdk21] Remove test for parenthesized pattern (removed in JEP 441) --- test/pretty/resource/after/Switch21.java | 25 ++++++++++++++++++++++ test/pretty/resource/before/Switch19.java | 2 +- test/pretty/resource/before/Switch21.java | 26 +++++++++++++++++++++++ 3 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 test/pretty/resource/after/Switch21.java create mode 100644 test/pretty/resource/before/Switch21.java diff --git a/test/pretty/resource/after/Switch21.java b/test/pretty/resource/after/Switch21.java new file mode 100644 index 00000000..d56ab16a --- /dev/null +++ b/test/pretty/resource/after/Switch21.java @@ -0,0 +1,25 @@ +public class Switch21 { + 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(); + }; + } +} diff --git a/test/pretty/resource/before/Switch19.java b/test/pretty/resource/before/Switch19.java index 05b27928..3a4f08bf 100644 --- a/test/pretty/resource/before/Switch19.java +++ b/test/pretty/resource/before/Switch19.java @@ -1,4 +1,4 @@ -// version 19: +// version 19:20 public class Switch19 { String switchPatternMatching(Object o) { return switch (o) { diff --git a/test/pretty/resource/before/Switch21.java b/test/pretty/resource/before/Switch21.java new file mode 100644 index 00000000..d32cdc5e --- /dev/null +++ b/test/pretty/resource/before/Switch21.java @@ -0,0 +1,26 @@ +// version 21: +public class Switch21 { + 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(); + }; + } +}