forked from checkstyle/checkstyle
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue checkstyle#12331: Test cases add to kill mutation for ModifedCo…
…ntrolVariableCheck
- Loading branch information
1 parent
811983e
commit 23e1a25
Showing
3 changed files
with
118 additions
and
198 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
...ks/coding/modifiedcontrolvariable/InputModifiedControlVariableTestVariousAssignments.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/* | ||
ModifiedControlVariable | ||
skipEnhancedForLoopVariable = (default)false | ||
*/ | ||
|
||
package com.puppycrawl.tools.checkstyle.checks.coding.modifiedcontrolvariable; | ||
|
||
public class InputModifiedControlVariableTestVariousAssignments { | ||
|
||
void method() { | ||
for (int i=0,k=0; i<10 && k < 10; ++i,++k) { | ||
i -= 3; // violation 'Control variable 'i' is modified' | ||
k -= 4; // violation 'Control variable 'k' is modified' | ||
} | ||
} | ||
|
||
void method1() { | ||
for (int i=0,k=0; i<10 && k < 10; ++i,++k) { | ||
i *= 3; // violation 'Control variable 'i' is modified' | ||
k *= 4; // violation 'Control variable 'k' is modified' | ||
} | ||
} | ||
|
||
void method2() { | ||
for (int i=0,k=0; i<10 && k < 10; ++i,++k) { | ||
i /= 3; // violation 'Control variable 'i' is modified' | ||
k /= 4; // violation 'Control variable 'k' is modified' | ||
} | ||
} | ||
|
||
void method3() { | ||
for (int i=0,k=0; i<10 && k < 10; ++i,++k) { | ||
i %= 3; // violation 'Control variable 'i' is modified' | ||
k %= 4; // violation 'Control variable 'k' is modified' | ||
} | ||
} | ||
|
||
void method4() { | ||
for (int i=0,k=0; i<10 && k < 10; ++i,++k) { | ||
i >>= 3; // violation 'Control variable 'i' is modified' | ||
k >>= 4; // violation 'Control variable 'k' is modified' | ||
} | ||
} | ||
void method5() { | ||
for (int i=0,k=0; i<10 && k < 10; ++i,++k) { | ||
i >>>= 3; // violation 'Control variable 'i' is modified' | ||
k >>>= 4; // violation 'Control variable 'k' is modified' | ||
} | ||
} | ||
|
||
void method6() { | ||
for (int i=0,k=0; i<10 && k < 10; ++i,++k) { | ||
i <<= 3; // violation 'Control variable 'i' is modified' | ||
k <<= 4; // violation 'Control variable 'k' is modified' | ||
} | ||
} | ||
|
||
void method7() { | ||
for (int i=0,k=0; i<10 && k < 10; ++i,++k) { | ||
i &= 3; // violation 'Control variable 'i' is modified' | ||
k &= 4; // violation 'Control variable 'k' is modified' | ||
} | ||
} | ||
|
||
void method8() { | ||
for (int i=0,k=0; i<10 && k < 10; ++i,++k) { | ||
i ^= 3; // violation 'Control variable 'i' is modified' | ||
k ^= 4; // violation 'Control variable 'k' is modified' | ||
} | ||
} | ||
|
||
void method9() { | ||
for (int i=0,k=0; i<10 && k < 10; ++i,++k) { | ||
i |= 3; // violation 'Control variable 'i' is modified' | ||
k |= 4; // violation 'Control variable 'k' is modified' | ||
} | ||
} | ||
|
||
void method10() { | ||
for (int i=0,k=0; i<10 && k < 10; ++i,++k) { | ||
i--; // violation 'Control variable 'i' is modified' | ||
k--; // violation 'Control variable 'k' is modified' | ||
} | ||
} | ||
} |