Skip to content

Commit b6d7682

Browse files
committed
S8346 improve test file to test += operators, and all others spec examples
1 parent 4ce49a6 commit b6d7682

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

java-checks/src/test/files/checks/IncDecOnFPCheck.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,28 @@
11
class A {
2-
void specExample() {
3-
for (float x = 16_000_000; x < 17_000_000; x++) { // Noncompliant {{Increment and decrement operators (++/--) should not be used with floating point variables}}
2+
void specNonCompliantExamples() {
3+
for (float i = 16_000_000; i < 17_000_000; i++) { // Noncompliant {{Increment and decrement operators (++/--) should not be used with floating point variables}}
44
// ^^^
55
// ...
66
}
7+
8+
9+
float x = 0f;
10+
double y = 1.0;
11+
12+
x++; // Noncompliant {{Increment and decrement operators (++/--) should not be used with floating point variables}}
13+
// ^^^
14+
y--; // Noncompliant {{Increment and decrement operators (++/--) should not be used with floating point variables}}
15+
// ^^^
716
}
17+
18+
void specCompliantExamples() {
19+
float x = 0f;
20+
double y = 1.0;
21+
22+
x += 1.0; // Compliant
23+
y -= 1.0; // Compliant
24+
}
25+
826
void floatIsNotCompliant() {
927
float y = 0.1f;
1028
y++; // Noncompliant {{Increment and decrement operators (++/--) should not be used with floating point variables}}

0 commit comments

Comments
 (0)