Skip to content

Commit

Permalink
Remove unnecessary disabled tests (#2678)
Browse files Browse the repository at this point in the history
As I was going over this recipe, I notice we had quite a few
tests that were disabled. These tests were disabled when we
changed the FinalizeLocalVariables recipe to not consider
uninitialized local variables. If we don't plan on reverting
that change, I think we should remove these tests rather
than keep out of date / wrong tests around.

Co-authored-by: Mike Sol <mike-solomon@users.noreply.github.com>
  • Loading branch information
mike-solomon and mike-solomon authored Jan 19, 2023
1 parent f7162f9 commit 8223adc
Showing 1 changed file with 0 additions and 190 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,159 +118,6 @@ public void test() {
);
}

@Disabled("consider uninitialized local variables non final")
@Test
void multipleVariablesDeclarationOnSingleLine() {
rewriteRun(
java(
"""
class A {
public void multiVariables() {
int a, b = 1;
a = 0;
}
}
""",
// the final only applies to any initialized variables (b in this case)
"""
class A {
public void multiVariables() {
final int a, b = 1;
a = 0;
}
}
"""
)
);
}

@Disabled("consider uninitialized local variables non final")
@Test
void calculateLocalVariablesInitializerOffset() {
rewriteRun(
java(
"""
class A {
public void testOne() {
int a;
a = 0;
System.out.println(a);
}
public void testTwo() {
int a;
a = 0;
a = 0;
System.out.println(a);
}
public void testThree() {
int a;
a = 0;
a++;
System.out.println(a);
}
}
""",
"""
class A {
public void testOne() {
final int a;
a = 0;
System.out.println(a);
}
public void testTwo() {
int a;
a = 0;
a = 0;
System.out.println(a);
}
public void testThree() {
int a;
a = 0;
a++;
System.out.println(a);
}
}
"""
)
);
}

@Test
@Disabled
void calculateLocalVariablesInitializerBranching() {
rewriteRun(
java(
"""
class A {
public void test(boolean hasThing) {
int a;
if (hasThing) {
a = 0;
} else {
a = 1;
}
System.out.println(a);
}
}
""",
"""
class A {
public void test(boolean hasThing) {
final int a;
if (hasThing) {
a = 0;
} else {
a = 1;
}
System.out.println(a);
}
}
"""
)
);
}

@Disabled("consider uninitialized local variables non final")
@Test
void forEachLoopAssignmentMadeFinal() {
rewriteRun(
java(
"""
class Test {
public static void testForEach(String[] args) {
for (String a : args) {
System.out.println(a);
}
for (String b : args) {
b = b.toUpperCase();
System.out.println(b);
}
}
}
""",
"""
class Test {
public static void testForEach(String[] args) {
for (final String a : args) {
System.out.println(a);
}
for (String b : args) {
b = b.toUpperCase();
System.out.println(b);
}
}
}
"""
)
);
}

@Test
void localVariableScopeAwareness() {
rewriteRun(
Expand Down Expand Up @@ -303,43 +150,6 @@ public static void testB() {
);
}

@Disabled("consider uninitialized local variables non final")
@Test
void forEachLoopScopeAwareness() {
rewriteRun(
java(
"""
class Test {
public static void testForEach(String[] args) {
for (String i : args) {
System.out.println(i);
}
for (String i : args) {
i = i.toUpperCase();
System.out.println(i);
}
}
}
""",
"""
class Test {
public static void testForEach(String[] args) {
for (final String i : args) {
System.out.println(i);
}
for (String i : args) {
i = i.toUpperCase();
System.out.println(i);
}
}
}
"""
)
);
}

@Test
@Issue("https://github.com/openrewrite/rewrite/issues/549")
void catchBlocksIgnored() {
Expand Down

0 comments on commit 8223adc

Please sign in to comment.