Skip to content

Commit

Permalink
Polish. Fixed a few tests to pass type validation.
Browse files Browse the repository at this point in the history
  • Loading branch information
traceyyoshima committed Nov 30, 2023
1 parent 20aac80 commit 033a1bc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
23 changes: 10 additions & 13 deletions src/test/java/org/openrewrite/kotlin/AssertionsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,22 @@
import static org.openrewrite.kotlin.Assertions.kotlin;
import static org.openrewrite.test.RewriteTest.toRecipe;

// This class may be removed after recipes with Assertions are added.
public class AssertionsTest implements RewriteTest {
@Override
public void defaults(RecipeSpec spec) {
spec.recipe(toRecipe(() -> new KotlinIsoVisitor<>() {
@Override
public J.VariableDeclarations.NamedVariable visitVariable(J.VariableDeclarations.NamedVariable variable, ExecutionContext executionContext) {
if ("a".equals(variable.getSimpleName())) {
return variable.withName(variable.getName().withSimpleName("b"));
}
return variable;
}
}));
}

@Issue("https://github.com/openrewrite/rewrite-kotlin/issues/30")
@Test
void isChanged() {
rewriteRun(
spec -> spec.recipe(toRecipe(() -> new KotlinIsoVisitor<>() {
@Override
public J.VariableDeclarations.NamedVariable visitVariable(J.VariableDeclarations.NamedVariable variable, ExecutionContext executionContext) {
J.VariableDeclarations.NamedVariable n = super.visitVariable(variable, executionContext);
if ("a".equals(n.getSimpleName())) {
return n.withName(n.getName().withSimpleName("b").withType(null).withFieldType(null)).withType(null).withVariableType(null);
}
return n;
}
})),
kotlin(
"""
class A {
Expand Down
2 changes: 2 additions & 0 deletions src/test/java/org/openrewrite/kotlin/format/SpacesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,14 @@ fun foo() {
foo ()
val test = Test ()
}
class Test
""",
"""
fun foo() {
foo()
val test = Test()
}
class Test
"""
)
);
Expand Down

0 comments on commit 033a1bc

Please sign in to comment.