aboutsummaryrefslogtreecommitdiff
path: root/test/pretty
diff options
context:
space:
mode:
Diffstat (limited to 'test/pretty')
-rw-r--r--test/pretty/resource/after/Sealed.java16
-rw-r--r--test/pretty/resource/after/Switch17.java31
-rw-r--r--test/pretty/resource/after/ThisParameter.java6
-rw-r--r--test/pretty/resource/before/Sealed.java17
-rw-r--r--test/pretty/resource/before/Switch17.java32
-rw-r--r--test/pretty/resource/before/ThisParameter.java8
-rw-r--r--test/pretty/resource/messages/DefaultMethod.java.messages1
-rw-r--r--test/pretty/resource/messages/ExoticJava.java.messages1
8 files changed, 105 insertions, 7 deletions
diff --git a/test/pretty/resource/after/Sealed.java b/test/pretty/resource/after/Sealed.java
new file mode 100644
index 00000000..15096034
--- /dev/null
+++ b/test/pretty/resource/after/Sealed.java
@@ -0,0 +1,16 @@
+public class Sealed {
+ public abstract sealed class Parent permits Child1, Child2 {
+ }
+
+ public final class Child1 extends Parent {
+ }
+
+ public abstract non-sealed class Child2 extends Parent {
+ }
+
+ public sealed interface SealedInterface permits ChildInterface1 {
+ }
+
+ public non-sealed interface ChildInterface1 extends SealedInterface {
+ }
+} \ No newline at end of file
diff --git a/test/pretty/resource/after/Switch17.java b/test/pretty/resource/after/Switch17.java
new file mode 100644
index 00000000..038f2cd9
--- /dev/null
+++ b/test/pretty/resource/after/Switch17.java
@@ -0,0 +1,31 @@
+public class Switch17 {
+ 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 && s.length() > 1 -> s;
+ default -> o.toString();
+ };
+ }
+
+ String switchParenthesizedPattern(Object o) {
+ return switch (o) {
+ case (String s) -> s;
+ default -> o.toString();
+ };
+ }
+} \ No newline at end of file
diff --git a/test/pretty/resource/after/ThisParameter.java b/test/pretty/resource/after/ThisParameter.java
index 49452a59..c57916be 100644
--- a/test/pretty/resource/after/ThisParameter.java
+++ b/test/pretty/resource/after/ThisParameter.java
@@ -16,17 +16,17 @@ class ThisParameter {
void runtimeTagged(@RuntimeTagged("runtime") ThisParameter this) {
// no content
}
- @Target(ElementType.PARAMETER)
+ @Target(ElementType.TYPE_USE)
@Retention(RetentionPolicy.SOURCE)
@interface SourceTagged {
String value();
}
- @Target(ElementType.PARAMETER)
+ @Target(ElementType.TYPE_USE)
@Retention(RetentionPolicy.CLASS)
@interface ClassTagged {
String value();
}
- @Target(ElementType.PARAMETER)
+ @Target(ElementType.TYPE_USE)
@Retention(RetentionPolicy.RUNTIME)
@interface RuntimeTagged {
String value();
diff --git a/test/pretty/resource/before/Sealed.java b/test/pretty/resource/before/Sealed.java
new file mode 100644
index 00000000..46828627
--- /dev/null
+++ b/test/pretty/resource/before/Sealed.java
@@ -0,0 +1,17 @@
+// version 15:
+public class Sealed {
+ public abstract sealed class Parent permits Child1, Child2 {
+ }
+
+ public final class Child1 extends Parent {
+ }
+
+ public abstract non-sealed class Child2 extends Parent {
+ }
+
+ public sealed interface SealedInterface permits ChildInterface1 {
+ }
+
+ public non-sealed interface ChildInterface1 extends SealedInterface {
+ }
+} \ No newline at end of file
diff --git a/test/pretty/resource/before/Switch17.java b/test/pretty/resource/before/Switch17.java
new file mode 100644
index 00000000..17754e82
--- /dev/null
+++ b/test/pretty/resource/before/Switch17.java
@@ -0,0 +1,32 @@
+// version 17:
+public class Switch17 {
+ 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 && s.length() > 1 -> 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/ThisParameter.java b/test/pretty/resource/before/ThisParameter.java
index e37651cb..42e4237e 100644
--- a/test/pretty/resource/before/ThisParameter.java
+++ b/test/pretty/resource/before/ThisParameter.java
@@ -1,4 +1,4 @@
-// version 9: the 'this' param option exists in java8, but is bugged, in that annotations are not allowed on them, even without a @Target. The only purpose of the this param is annotations, so, boy, isn't that a punch in the face?
+// version 8:
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -22,19 +22,19 @@ class ThisParameter {
// no content
}
- @Target(ElementType.PARAMETER)
+ @Target(ElementType.TYPE_USE)
@Retention(RetentionPolicy.SOURCE)
@interface SourceTagged {
String value();
}
- @Target(ElementType.PARAMETER)
+ @Target(ElementType.TYPE_USE)
@Retention(RetentionPolicy.CLASS)
@interface ClassTagged {
String value();
}
- @Target(ElementType.PARAMETER)
+ @Target(ElementType.TYPE_USE)
@Retention(RetentionPolicy.RUNTIME)
@interface RuntimeTagged {
String value();
diff --git a/test/pretty/resource/messages/DefaultMethod.java.messages b/test/pretty/resource/messages/DefaultMethod.java.messages
new file mode 100644
index 00000000..766c3d8c
--- /dev/null
+++ b/test/pretty/resource/messages/DefaultMethod.java.messages
@@ -0,0 +1 @@
+OPTIONAL 9 as of release 17, all floating-point expressions are evaluated strictly and 'strictfp' is not required \ No newline at end of file
diff --git a/test/pretty/resource/messages/ExoticJava.java.messages b/test/pretty/resource/messages/ExoticJava.java.messages
new file mode 100644
index 00000000..68e8d281
--- /dev/null
+++ b/test/pretty/resource/messages/ExoticJava.java.messages
@@ -0,0 +1 @@
+OPTIONAL 16 as of release 17, all floating-point expressions are evaluated strictly and 'strictfp' is not required \ No newline at end of file