blob: 43a7a050ca87b85f644ded9d0be1721bfea42670 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
class StringTests // JDK 21+ (--enable-preview --release 21).
{
static {
String s1 = "A quick brown fox jumps over the lazy dog";
String s2 = "\"Woof\s!\"";
String s3 = """
A\s\
quick \
brown\s\
fox \
jumps\s\
over \
the\s\
lazy \
dog""";
String s4 = """
"Woof\s!\"""";
String s5 = """
String s3 = \"""
A\\s\\
quick \\
brown\\s\\
fox \\
jumps\\s\\
over \\
the\\s\\
lazy \\
dog\""";""";
// There are SPACE, FF, HT, CR, and LF after """.
String empty = """
""";
System.out.println("""
"
""
""\u005c"
""\u005c""
""\"\u0022\u0022
""\"""\u005c\u0022
""\"""\""
""\"""\""\"""");
System.out.println(STR."""
"
\{"\"\""}
\{"\"\""}\{"\u005c\u0022"}
\{"\"\""}\{"\u005c\u0022"}"
\{"\"\""}\"\{"\u005c\u0022\u005c\u0022"}
\{"\"\""}\"\{"\"\""}\{"\u005c\u0022"}
\{"\"\""}\"\{"\"\""}\""
\{"\"\""}\"\{"\"\""}\""\""""); // JDK 21+.
String woof = "Woof", dog = "dog", fox = "fox";
String s6 = STR
."A quick brown \{fox} jumps over the lazy \{dog}";
String s7 = STR.process(StringTemplate.RAW
."\"\{woof}\s!\"");
String s8 = STR."""
A\s\
quick \
brown\s\
\{fox} \
jumps\s\
over \
the\s\
lazy \
\{dog}""";
String s9 = STR.process(StringTemplate.RAW
.
"""
"\{woof}\s!\"""");
String s10 = java.util.FormatProcessor.FMT
. "%-14s\{"A\s" + STR . "quick" + "brown"}%s\{fox} "
+ java.util.FormatProcessor.FMT
. "%-20s\{"jumps\sover the\s"
+ STR . "lazy"}%s\{dog}";
String s11 = STR."""
\"\{ // A nested comment.
(new java.util.function.Function<String, String>() {
public String apply(String bay) { return bay; };
}).apply(woof)
}\s!\"""";
String s12 = java.util.FormatProcessor.FMT
."""
%-14s\{STR."""
A\s\
\{ "quick" } \
brown"""}\
%s\{ fox } \
%-20s\{STR."""
jumps\s\
over \
the\s\
\{ "lazy" } """}\
%s\{ dog }""";
String s13 = STR
."\"\{ /* A nested comment. */
((java.util.function.Function<String, String>) bay -> bay)
.apply(woof)
}\s!\"";
}
}
|