AssertWithSideEffects: tests fixed (HashSet/TreeSet are absent in mockJDK7, so locality-based tests were not testing anything actually)

This commit is contained in:
Tagir Valeev
2018-09-06 20:15:00 +07:00
parent 1665ac9863
commit 6b8c7b496b
4 changed files with 16 additions and 16 deletions
@@ -30,12 +30,4 @@ public class AssertWithSideEffects {
void jdbc(ResultSet rs) throws SQLException {
assert rs.last();
}
void assertMutation(Set<String> set) {
assert set.add("foo");
assert new HashSet<>().add("bar");
assert (set.isEmpty() ? new TreeSet<>() : new HashSet<>()).add("baz");
}
}
@@ -20,11 +20,4 @@
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">'assert' statement with side effects</problem_class>
<description>&lt;code&gt;assert&lt;/code&gt; has side effects #loc</description>
</problem>
<problem>
<file>AssertWithSideEffects.java</file>
<line>35</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">'assert' statement with side effects</problem_class>
<description>&lt;code&gt;assert&lt;/code&gt; has side effects #loc</description>
</problem>
</problems>
@@ -1,5 +1,6 @@
package com.siyeh.igtest.bugs.assert_with_side_effects;
import java.util.regex.*;
import java.util.*;
public class AssertWithSideEffects {
void assertMutation() {
Matcher m = Pattern.compile("foobar").matcher("foo");
@@ -7,4 +8,12 @@ public class AssertWithSideEffects {
assert Pattern.compile("foobar").matcher("foo").matches();
}
void assertMutation(Set<String> set) {
assert set.add("foo");
assert new HashSet<>().add("bar");
assert (set.isEmpty() ? new TreeSet<>() : new HashSet<>()).add("baz");
}
}
@@ -2,7 +2,13 @@
<problems>
<problem>
<file>AssertWithSideEffects.java</file>
<line>6</line>
<line>7</line>
<problem_class>'assert' statement with side effects</problem_class>
<description>&lt;code&gt;assert&lt;/code&gt; has side effects #loc</description>
</problem>
<problem>
<file>AssertWithSideEffects.java</file>
<line>13</line>
<problem_class>'assert' statement with side effects</problem_class>
<description>&lt;code&gt;assert&lt;/code&gt; has side effects #loc</description>
</problem>