Skip to content

Issue #13109: Kill mutation for FileContents#13156

Merged
romani merged 1 commit intocheckstyle:masterfrom
Kevin222004:API1
Jun 7, 2023
Merged

Issue #13109: Kill mutation for FileContents#13156
romani merged 1 commit intocheckstyle:masterfrom
Kevin222004:API1

Conversation

@Kevin222004
Copy link
Copy Markdown
Contributor

@Kevin222004 Kevin222004 commented Jun 4, 2023

Issue #13109: Kill mutation for FileContents


Mutation covered

<mutation unstable="false">
<sourceFile>FileContents.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.api.FileContents</mutatedClass>
<mutatedMethod>getBlockComments</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.experimental.ArgumentPropagationMutator</mutator>
<description>replaced call to java/util/Collections::unmodifiableMap with argument</description>
<lineContent>return Collections.unmodifiableMap(clangComments);</lineContent>
</mutation>
<mutation unstable="false">
<sourceFile>FileContents.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.api.FileContents</mutatedClass>
<mutatedMethod>getSingleLineComments</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.experimental.ArgumentPropagationMutator</mutator>
<description>replaced call to java/util/Collections::unmodifiableMap with argument</description>
<lineContent>return Collections.unmodifiableMap(cppComments);</lineContent>
</mutation>


Explaination

Test cases expanded.
If we see return Collections.unmodifiableMap(cppComments); is mutated to return cppComments;. basically Collections. unmodifiable will not allow us to make any updates to the map. if we try to update it it will throw UnsupportedOperationException. so in this test case if we try to remove data from the comment so it will throw the exception

@Kevin222004
Copy link
Copy Markdown
Contributor Author

Ready for review

Copy link
Copy Markdown
Member

@romani romani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again replaced call to java/util/Collections::unmodifiableMap with argument

but
interesting case.
it is API, so we are ok to merge by pure unit test it as it is api, and we do not know how it will be used so we need to test api method.

I added it to #13142.

Copy link
Copy Markdown
Member

@rdiachenko rdiachenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@rdiachenko rdiachenko assigned Vyom-Yadav and unassigned rdiachenko Jun 5, 2023
Copy link
Copy Markdown
Member

@Vyom-Yadav Vyom-Yadav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@Vyom-Yadav Vyom-Yadav assigned romani and unassigned Vyom-Yadav Jun 7, 2023
@romani romani merged commit d4ccb63 into checkstyle:master Jun 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants