Skip to content

Issue #13672: Kill mutation related to Charset in FileText#13728

Merged
romani merged 1 commit intocheckstyle:masterfrom
Vyom-Yadav:killMutationFileText
Sep 23, 2023
Merged

Issue #13672: Kill mutation related to Charset in FileText#13728
romani merged 1 commit intocheckstyle:masterfrom
Vyom-Yadav:killMutationFileText

Conversation

@Vyom-Yadav
Copy link
Copy Markdown
Member

@Vyom-Yadav Vyom-Yadav commented Sep 11, 2023

Issue #13672: Kill mutation related to Charset in FileText

originally discussed at #13181 (comment)


Mutation Covered

<mutation unstable="false">
<sourceFile>FileText.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.api.FileText</mutatedClass>
<mutatedMethod>&lt;init&gt;</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.NonVoidMethodCallMutator</mutator>
<description>removed call to java/nio/charset/CharsetDecoder::onMalformedInput</description>
<lineContent>decoder.onMalformedInput(CodingErrorAction.REPLACE);</lineContent>
</mutation>
<mutation unstable="false">
<sourceFile>FileText.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.api.FileText</mutatedClass>
<mutatedMethod>&lt;init&gt;</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.experimental.NakedReceiverMutator</mutator>
<description>replaced call to java/nio/charset/CharsetDecoder::onMalformedInput with receiver</description>
<lineContent>decoder.onMalformedInput(CodingErrorAction.REPLACE);</lineContent>
</mutation>

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.

items:


try (OutputStream fileOutputStream = Files.newOutputStream(tempFile)) {
fileOutputStream.write(0x80);
fileOutputStream.write(0x80);
Copy link
Copy Markdown
Member

@romani romani Sep 11, 2023

Choose a reason for hiding this comment

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

we need a comment over test method to explain it.
This test exists to make to show how we drop symbols that can not be mapped during loading by some encoding, example of unmapped symbols can be found at https://www.fileformat.info/info/charset/x-IBM1098/decode.htm 0x80, 0x81, 0xCF

or better:
https://www.fileformat.info/info/charset/ISO-8859-6/decode.htm a1 | (unmappable) but mappable at https://www.fileformat.info/info/charset/windows-1251/list.htm Ў CYRILLIC CAPITAL LETTER SHORT U (U+040E) a1
so we can create file that has visual character and it works with one charset and does not work in another charset. We can have single test method that just try run same file two time by different charsets.

I found this by: https://www.google.com/search?q=site%3Afileformat.info+%22unmappable%22&client=ubuntu&hs=fpP&sca_esv=564339272&channel=fs&ei=mAr_ZKC9E5jfkPIP-NyeIA&ved=0ahUKEwig6ar7yaKBAxWYL0QIHXiuBwQQ4dUDCA8&uact=5&oq=site%3Afileformat.info+%22unmappable%22

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done, I added Javadoc comments and converted it to a non-temporary input file-based test.

@romani romani assigned Vyom-Yadav and unassigned romani Sep 18, 2023
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.

This is very good.

@romani romani merged commit 23eff22 into checkstyle:master Sep 23, 2023
*
* @throws Exception exception
*/
@SuppressForbidden
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What is suppress forbidden for?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Verify method, as we supposed to use verify that use input based config. But we need to set charset, and this type set we do not support yet.
So for now old style testing on Input file, without embedded config.

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.

3 participants