Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7027d9f

Browse files
graememorganError Prone Team
authored and
Error Prone Team
committed
Add negative test cases for AlwaysThrows with non-literal arguments.
PiperOrigin-RevId: 837246366
1 parent8669adb commit7027d9f

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

‎core/src/test/java/com/google/errorprone/bugpatterns/AlwaysThrowsTest.java‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,23 @@ void f() {
4545
.doTest();
4646
}
4747

48+
@Test
49+
publicvoidnegative_nonLiteral() {
50+
testHelper
51+
.addSourceLines(
52+
"Test.java",
53+
"""
54+
import java.time.Instant;
55+
56+
class T {
57+
void f() {
58+
Instant.parse(toString() + "foo");
59+
}
60+
}
61+
""")
62+
.doTest();
63+
}
64+
4865
@Test
4966
publicvoidimmutableMapThrows() {
5067
testHelper
@@ -218,4 +235,19 @@ class Test {
218235
""")
219236
.doTest();
220237
}
238+
239+
@Test
240+
publicvoiduuidFromString_withNonLiteral() {
241+
testHelper
242+
.addSourceLines(
243+
"Test.java",
244+
"""
245+
import java.util.UUID;
246+
247+
class Test {
248+
private final UUID uuid = UUID.fromString(toString());
249+
}
250+
""")
251+
.doTest();
252+
}
221253
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp