Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@

import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.junitpioneer.jupiter.ExpectedToFail;
import org.openrewrite.DocumentExample;
import org.openrewrite.test.RecipeSpec;
import org.openrewrite.test.RewriteTest;
import org.openrewrite.test.TypeValidation;

import static org.openrewrite.java.Assertions.java;

Expand Down Expand Up @@ -323,5 +325,40 @@ void method() {
)
);
}

@ExpectedToFail("visitParentheses unwraps pre-existing (String.valueOf(..)) even when no concatenation was rewritten")
@Test
void doNotChangeParenthesizedValueOfWithoutConcatenation() {
rewriteRun(
//language=java
java(
"""
class Test {
String method(Object o) {
return (String.valueOf(o));
}
}
"""
)
);
}

@ExpectedToFail("Operand without type attribution is still rewritten; not value-preserving if it is really a char[]")
@Test
void doNotChangeWhenOperandTypeIsMissing() {
rewriteRun(
spec -> spec.typeValidationOptions(TypeValidation.none()),
//language=java
java(
"""
class Test {
String method(Unresolved holder) {
return "" + holder.chars();
}
}
"""
)
);
}
}
}
Loading