-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#303 PiperOrigin-RevId: 602458900
- Loading branch information
Showing
7 changed files
with
195 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
javatests/com/google/turbine/lower/testdata/string_template.test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
=== StringTemplates.java === | ||
public class StringTemplates { | ||
interface Example { | ||
Object foo(); | ||
boolean test(String string); | ||
} | ||
void test(Example example, Example example0, Example example1, Example example2){ | ||
var m = STR."template \{example}xxx"; | ||
var nested = STR."template \{example.foo()+ STR."templateInner\{example}"}xxx }"; | ||
var nestNested = STR."template \{example0. | ||
foo() + | ||
STR."templateInner\{example1.test(STR."\{example2 | ||
}")}"}xxx }"; | ||
} | ||
} | ||
=== Foo.java === | ||
class Foo { | ||
public static final int X = 42; | ||
public static final String A = STR."\{X} = \{X}"; | ||
public static final String B = STR.""; | ||
public static final String C = STR."\{X}"; | ||
public static final String D = STR."\{X}\{X}"; | ||
public static final String E = STR."\{X}\{X}\{X}"; | ||
public static final String F = STR." \{X}"; | ||
public static final String G = STR."\{X} "; | ||
public static final String H = STR."\{X} one long incredibly unbroken sentence moving from "+"topic to topic so that no-one had a chance to interrupt"; | ||
public static final String I = STR."\{X} \uD83D\uDCA9 "; | ||
} | ||
=== Multiline.java === | ||
import static java.lang.StringTemplate.STR; | ||
|
||
public class Multiline { | ||
static String planet = "world"; | ||
|
||
static String s1 = STR."hello, \{planet}"; | ||
|
||
static String s2 = STR.""" | ||
hello, \{planet} | ||
"""; | ||
|
||
static String s3 = STR.""" | ||
hello, \{ | ||
STR.""" | ||
recursion, \{ | ||
} | ||
""" | ||
} | ||
"""; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters