mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
AssertWithSideEffects tests migrated to LightCodeInsightFixtureTestCase
An example of using LightTestMigration
This commit is contained in:
+3
-3
@@ -10,11 +10,11 @@ public class AssertWithSideEffects {
|
||||
}
|
||||
|
||||
void bar(int i) {
|
||||
assert i++ < 10;
|
||||
<warning descr="'assert' has side effects">assert</warning> i++ < 10;
|
||||
}
|
||||
|
||||
void abc() {
|
||||
assert isSideEffect();
|
||||
<warning descr="'assert' has side effects">assert</warning> isSideEffect();
|
||||
}
|
||||
|
||||
boolean isSideEffect() {
|
||||
@@ -28,6 +28,6 @@ public class AssertWithSideEffects {
|
||||
}
|
||||
|
||||
void jdbc(ResultSet rs) throws SQLException {
|
||||
assert rs.last();
|
||||
<warning descr="'assert' has side effects">assert</warning> rs.last();
|
||||
}
|
||||
}
|
||||
-23
@@ -1,23 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<problems>
|
||||
<problem>
|
||||
<file>AssertWithSideEffects.java</file>
|
||||
<line>13</line>
|
||||
<problem_class>'assert' statement with side effects</problem_class>
|
||||
<description><code>assert</code> has side effects #loc</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>AssertWithSideEffects.java</file>
|
||||
<line>17</line>
|
||||
<problem_class>'assert' statement with side effects</problem_class>
|
||||
<description><code>assert</code> has side effects #loc</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>AssertWithSideEffects.java</file>
|
||||
<line>31</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">'assert' statement with side effects</problem_class>
|
||||
<description><code>assert</code> has side effects #loc</description>
|
||||
</problem>
|
||||
</problems>
|
||||
+2
-2
@@ -4,13 +4,13 @@ import java.util.*;
|
||||
public class AssertWithSideEffects {
|
||||
void assertMutation() {
|
||||
Matcher m = Pattern.compile("foobar").matcher("foo");
|
||||
assert m.matches();
|
||||
<warning descr="'assert' has side effects">assert</warning> m.matches();
|
||||
|
||||
assert Pattern.compile("foobar").matcher("foo").matches();
|
||||
}
|
||||
|
||||
void assertMutation(Set<String> set) {
|
||||
assert set.add("foo");
|
||||
<warning descr="'assert' has side effects">assert</warning> set.add("foo");
|
||||
|
||||
assert new HashSet<>().add("bar");
|
||||
|
||||
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<problems>
|
||||
<problem>
|
||||
<file>AssertWithSideEffects.java</file>
|
||||
<line>7</line>
|
||||
<problem_class>'assert' statement with side effects</problem_class>
|
||||
<description><code>assert</code> has side effects #loc</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>AssertWithSideEffects.java</file>
|
||||
<line>13</line>
|
||||
<problem_class>'assert' statement with side effects</problem_class>
|
||||
<description><code>assert</code> has side effects #loc</description>
|
||||
</problem>
|
||||
</problems>
|
||||
+19
-11
@@ -1,20 +1,28 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.siyeh.ig.bugs;
|
||||
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.testFramework.IdeaTestUtil;
|
||||
import com.intellij.testFramework.PsiTestUtil;
|
||||
import com.siyeh.ig.IGInspectionTestCase;
|
||||
import com.intellij.testFramework.LightProjectDescriptor;
|
||||
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class AssertWithSideEffectsInspection8Test extends IGInspectionTestCase {
|
||||
public class AssertWithSideEffectsInspection8Test extends LightCodeInsightFixtureTestCase {
|
||||
@Override
|
||||
protected Sdk getTestProjectSdk() {
|
||||
// uses Regex
|
||||
return PsiTestUtil.addJdkAnnotations(IdeaTestUtil.getMockJdk18());
|
||||
protected String getBasePath() {
|
||||
return "/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/assert_with_side_effects8";
|
||||
}
|
||||
|
||||
public void test() {
|
||||
doTest("com/siyeh/igtest/bugs/assert_with_side_effects8",
|
||||
new AssertWithSideEffectsInspection());
|
||||
@NotNull
|
||||
@Override
|
||||
protected LightProjectDescriptor getProjectDescriptor() {
|
||||
return JAVA_8_ANNOTATED;
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
myFixture.enableInspections(new AssertWithSideEffectsInspection());
|
||||
myFixture.testHighlighting(getTestName(false) + ".java");
|
||||
}
|
||||
|
||||
public void testAssertWithSideEffects() {
|
||||
doTest();
|
||||
}
|
||||
}
|
||||
+21
-11
@@ -1,19 +1,29 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.siyeh.ig.bugs;
|
||||
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.testFramework.IdeaTestUtil;
|
||||
import com.intellij.testFramework.PsiTestUtil;
|
||||
import com.siyeh.ig.IGInspectionTestCase;
|
||||
import com.intellij.testFramework.LightProjectDescriptor;
|
||||
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class AssertWithSideEffectsInspectionTest extends IGInspectionTestCase {
|
||||
public class AssertWithSideEffectsInspectionTest extends LightCodeInsightFixtureTestCase {
|
||||
@Override
|
||||
protected Sdk getTestProjectSdk() {
|
||||
// uses SQL
|
||||
return PsiTestUtil.addJdkAnnotations(IdeaTestUtil.getMockJdk17());
|
||||
protected String getBasePath() {
|
||||
return "/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/assert_with_side_effects";
|
||||
}
|
||||
|
||||
public void test() {
|
||||
doTest("com/siyeh/igtest/bugs/assert_with_side_effects",
|
||||
new AssertWithSideEffectsInspection());
|
||||
@NotNull
|
||||
@Override
|
||||
protected LightProjectDescriptor getProjectDescriptor() {
|
||||
// uses SQL
|
||||
return JAVA_1_7_ANNOTATED;
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
myFixture.enableInspections(new AssertWithSideEffectsInspection());
|
||||
myFixture.testHighlighting(getTestName(false) + ".java");
|
||||
}
|
||||
|
||||
public void testAssertWithSideEffects() {
|
||||
doTest();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user