-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Java 21 string template tests (#335)
- Loading branch information
Showing
10 changed files
with
199 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package pkg; | ||
|
||
import java.lang.StringTemplate.Processor; | ||
import java.lang.runtime.TemplateRuntime; | ||
|
||
public class TestCustomProcessor { | ||
static Processor<Object, Error> processor; | ||
|
||
public void test() { | ||
String s = "Hello";// 7 | ||
int i = 42;// 8 | ||
double d = 3.14159;// 9 | ||
Object result = processor.process(TemplateRuntime.newStringTemplate<"process","Text: "," "," ","">(s, i, d));// 11 | ||
}// 12 | ||
} | ||
|
||
class 'pkg/TestCustomProcessor' { | ||
method 'test ()V' { | ||
0 9 | ||
1 9 | ||
2 9 | ||
3 10 | ||
4 10 | ||
5 10 | ||
6 11 | ||
7 11 | ||
8 11 | ||
9 11 | ||
a 12 | ||
b 12 | ||
c 12 | ||
d 12 | ||
e 12 | ||
f 12 | ||
10 12 | ||
11 12 | ||
12 12 | ||
13 12 | ||
14 12 | ||
15 12 | ||
16 12 | ||
17 12 | ||
18 12 | ||
19 12 | ||
1a 12 | ||
1b 12 | ||
1c 13 | ||
} | ||
} | ||
|
||
Lines mapping: | ||
7 <-> 10 | ||
8 <-> 11 | ||
9 <-> 12 | ||
11 <-> 13 | ||
12 <-> 14 |
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,43 @@ | ||
package pkg; | ||
|
||
import java.lang.runtime.TemplateRuntime; | ||
|
||
public class TestRawProcessor { | ||
public void test() { | ||
String s = "Hello";// 7 | ||
int i = 42;// 8 | ||
Object o = null;// 9 | ||
StringTemplate template = TemplateRuntime.newStringTemplate<"process","Text: "," "," ","">(s, i, o);// 11 | ||
}// 12 | ||
} | ||
|
||
class 'pkg/TestRawProcessor' { | ||
method 'test ()V' { | ||
0 6 | ||
1 6 | ||
2 6 | ||
3 7 | ||
4 7 | ||
5 7 | ||
6 8 | ||
7 8 | ||
8 9 | ||
9 9 | ||
a 9 | ||
b 9 | ||
c 9 | ||
d 9 | ||
e 9 | ||
f 9 | ||
10 9 | ||
11 9 | ||
12 10 | ||
} | ||
} | ||
|
||
Lines mapping: | ||
7 <-> 7 | ||
8 <-> 8 | ||
9 <-> 9 | ||
11 <-> 10 | ||
12 <-> 11 |
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,45 @@ | ||
package pkg; | ||
|
||
public class TestStrProcessor { | ||
public void test() { | ||
String s = "Hello";// 5 | ||
int i = 42;// 6 | ||
Object o = null;// 7 | ||
System.out.println("Text: " + s + " " + i + " " + o);// 8 | ||
}// 9 | ||
} | ||
|
||
class 'pkg/TestStrProcessor' { | ||
method 'test ()V' { | ||
0 4 | ||
1 4 | ||
2 4 | ||
3 5 | ||
4 5 | ||
5 5 | ||
6 6 | ||
7 6 | ||
8 7 | ||
9 7 | ||
a 7 | ||
b 7 | ||
c 7 | ||
d 7 | ||
11 7 | ||
12 7 | ||
13 7 | ||
14 7 | ||
15 7 | ||
16 7 | ||
17 7 | ||
18 7 | ||
19 8 | ||
} | ||
} | ||
|
||
Lines mapping: | ||
5 <-> 5 | ||
6 <-> 6 | ||
7 <-> 7 | ||
8 <-> 8 | ||
9 <-> 9 |
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,13 @@ | ||
package pkg; | ||
|
||
public class TestCustomProcessor { | ||
static StringTemplate.Processor<Object, Error> processor; | ||
|
||
public void test() { | ||
String s = "Hello"; | ||
int i = 42; | ||
double d = 3.14159; | ||
|
||
Object result = processor."Text: \{s} \{i} \{d}"; | ||
} | ||
} |
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,13 @@ | ||
package pkg; | ||
|
||
import static java.util.FormatProcessor.FMT; | ||
|
||
public class TestFmtProcessor { | ||
public void test() { | ||
String s = "Hello"; | ||
int i = 42; | ||
double d = 3.14159; | ||
|
||
System.out.println(FMT."Text: %s\{s} %4d\{i} %.2f\{d}"); | ||
} | ||
} |
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,13 @@ | ||
package pkg; | ||
|
||
import static java.lang.StringTemplate.RAW; | ||
|
||
public class TestRawProcessor { | ||
public void test() { | ||
String s = "Hello"; | ||
int i = 42; | ||
Object o = null; | ||
|
||
StringTemplate template = RAW."Text: \{s} \{i} \{o}"; | ||
} | ||
} |
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,10 @@ | ||
package pkg; | ||
|
||
public class TestStrProcessor { | ||
public void test() { | ||
String s = "Hello"; | ||
int i = 42; | ||
Object o = null; | ||
System.out.println(STR."Text: \{s} \{i} \{o}"); | ||
} | ||
} |
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