Skip to content

Commit

Permalink
* Killing all mutants
Browse files Browse the repository at this point in the history
  • Loading branch information
DimaLegeza committed Dec 12, 2023
1 parent 8629f98 commit 3de47ce
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,7 @@ public final class MonoZipOfMonoVoidUsage extends BugChecker
allOf(
instanceMethod().onDescendantOf(MONO).named("zipWith"),
toType(MethodInvocationTree.class, staticMethod().onClass(MONO).named("empty"))),
allOf(
onClassWithMethodName(MONO_VOID_TYPE, "zipWith"),
toType(MethodInvocationTree.class, hasGenericArgumentOfType(MONO))));
onClassWithMethodName(MONO_VOID_TYPE, "zipWith"));

// On class Mono.zip, at least one element should match empty in order to proceed.
private static final Matcher<ExpressionTree> STATIC_MONO_ZIP =
Expand Down Expand Up @@ -112,14 +110,6 @@ private static Matcher<ExpressionTree> onClassWithMethodName(
};
}

private static Matcher<MethodInvocationTree> hasGenericArgumentOfType(
Supplier<Type> genericDesiredType) {
return (tree, state) ->
tree.getArguments().stream()
.anyMatch(
arg -> isSameType(ASTHelpers.getType(arg), genericDesiredType.get(state), state));
}

private static Matcher<MethodInvocationTree> hasGenericArgumentOfExactType(
Supplier<Type> genericDesiredType) {
return (tree, state) ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ void replacementSuggestedFix() {
" Mono.zip(a, a);",
" a.zipWith(a);",
" }",
"",
" public void m2() {",
" Class clazz = getClass();",
" }",
"}")
.addOutputLines(
"A.java",
Expand All @@ -96,6 +100,10 @@ void replacementSuggestedFix() {
" Mono.zip(a, a);",
" a.zipWith(a);",
" }",
"",
" public void m2() {",
" Class clazz = getClass();",
" }",
"}")
.doTest(BugCheckerRefactoringTestHelper.TestMode.TEXT_MATCH);
}
Expand Down

0 comments on commit 3de47ce

Please sign in to comment.