Skip to content

Commit

Permalink
Issue #13328: Kill mutation for OneStatmentPerLineCheck-4
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin222004 authored and romani committed Jun 30, 2023
1 parent 917c687 commit c3ab3fd
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 15 deletions.
15 changes: 0 additions & 15 deletions config/pitest-suppressions/pitest-coding-2-suppressions.xml
Expand Up @@ -54,21 +54,6 @@
<lineContent>this.query = query;</lineContent>
</mutation>







<mutation unstable="false">
<sourceFile>OneStatementPerLineCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.coding.OneStatementPerLineCheck</mutatedClass>
<mutatedMethod>beginTree</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.experimental.MemberVariableMutator</mutator>
<description>Removed assignment to member variable lastVariableResourceStatementEnd</description>
<lineContent>lastVariableResourceStatementEnd = 0;</lineContent>
</mutation>

<mutation unstable="false">
<sourceFile>StringLiteralEqualityCheck.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.checks.coding.StringLiteralEqualityCheck</mutatedClass>
Expand Down
Expand Up @@ -159,4 +159,23 @@ public void testStateIsClearedOnBeginTreeForLastStatementEnd() throws Exception
inputWithWarnings, expectedFirstInput,
inputWithoutWarnings, expectedSecondInput));
}

@Test
public void testStateIsClearedOnBeginTreeForLastVariableStatement() throws Exception {
final DefaultConfiguration checkConfig = createModuleConfig(OneStatementPerLineCheck.class);
checkConfig.addProperty("treatTryResourcesAsStatement", "true");
final String file1 = getPath(
"InputOneStatementPerLineBeginTreeLastVariableResourcesStatementEnd1.java");
final String file2 = getPath(
"InputOneStatementPerLineBeginTreeLastVariableResourcesStatementEnd2.java");
final List<String> expectedFirstInput = List.of(
"8:59: " + getCheckMessage(MSG_KEY)
);
final List<String> expectedSecondInput = List.of(CommonUtil.EMPTY_STRING_ARRAY);
final File[] inputs = {new File(file1), new File(file2)};

verify(createChecker(checkConfig), inputs, ImmutableMap.of(
file1, expectedFirstInput,
file2, expectedSecondInput));
}
}
@@ -0,0 +1,12 @@
package com.puppycrawl.tools.checkstyle.checks.coding.onestatementperline;

import java.io.*;

// ok
public class InputOneStatementPerLineBeginTreeLastVariableResourcesStatementEnd1 {
public void resourceListExists() throws IOException {
try (FileInputStream f1 = new FileInputStream("1"); FileInputStream f2 =
new FileInputStream("2")) {
}
}
}
@@ -0,0 +1,12 @@
package com.puppycrawl.tools.checkstyle.checks.coding.onestatementperline;

import java.io.*;

// ok
public class InputOneStatementPerLineBeginTreeLastVariableResourcesStatementEnd2 {
void m(OutputStream out) throws IOException {
try (out; InputStream in = new FileInputStream("filename")) {

}
}
}

0 comments on commit c3ab3fd

Please sign in to comment.