Skip to content

Commit

Permalink
Improve AttributeTest
Browse files Browse the repository at this point in the history
  • Loading branch information
jevanlingen committed Dec 19, 2024
1 parent b7ab6b2 commit 0627f3d
Showing 1 changed file with 0 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,46 +15,30 @@
*/
package org.openrewrite.groovy.tree;

import org.intellij.lang.annotations.Language;
import org.junit.jupiter.api.Test;
import org.openrewrite.test.RewriteTest;

import static org.openrewrite.groovy.Assertions.groovy;
import static org.openrewrite.groovy.Assertions.srcTestGroovy;
import static org.openrewrite.java.Assertions.java;
import static org.openrewrite.java.Assertions.srcTestJava;

@SuppressWarnings({"GroovyUnusedAssignment", "GrUnnecessarySemicolon"})
class AttributeTest implements RewriteTest {

@Language("groovy")
private static final String SOME_USER = """
class User {
public final String name
User(String name) { this.name = name}
}
""";

@Test
void attribute() {
rewriteRun(
srcTestGroovy(groovy(SOME_USER)),
groovy("new User('Bob').@name == 'Bob'")
);
}

@Test
void attributeInClosure() {
rewriteRun(
srcTestGroovy(groovy(SOME_USER)),
groovy("[new User('Bob')].find { it.@name == 'Bob' }")
);
}

@Test
void attributeWithParentheses() {
rewriteRun(
srcTestGroovy(groovy(SOME_USER)),
groovy("(new User('Bob').@name) == 'Bob'")
);
}
Expand Down

0 comments on commit 0627f3d

Please sign in to comment.