Fix test data of QuickFixTest

This commit is contained in:
Alexey Sedunov
2014-03-24 16:31:19 +04:00
parent 1bbec14cc0
commit 028a71273c
15 changed files with 33 additions and 2 deletions
@@ -1,5 +1,7 @@
// "Change 'A.x' type to '(Int) -> Int'" "false"
// ACTION: Change 'C.x' type to '(String) -> Int'
// ACTION: Disable inspection
// ACTION: Edit inspection profile setting
// ERROR: <html>Return type is '(kotlin.Int) &rarr; kotlin.Int', which is not a subtype of overridden<br/><b>internal</b> <b>abstract</b> <b>val</b> x: (kotlin.String) &rarr; kotlin.Int <i>defined in</i> A</html>
trait A {
val x: (String) -> Int
@@ -1,4 +1,5 @@
// "class com.intellij.codeInspection.SuppressIntentionAction" "false"
// ACTION: Suppress 'INTEGER_OVERFLOW' for fun foo
[Ann(Integer.MAX_VALUE<caret> + 1)]
fun foo() {}
@@ -1,4 +1,5 @@
// "class com.intellij.codeInspection.SuppressIntentionAction" "false"
// ACTION: Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for class Child
open class Base(s: String)
class Child: Base(""<caret>!!)
@@ -1,3 +1,5 @@
// "class com.intellij.codeInspection.SuppressIntentionAction" "false"
// ACTION: Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for fun foo
// ACTION: Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for parameter s
fun foo(s: String = ""<caret>!!) {}
@@ -1,3 +1,4 @@
// "class com.intellij.codeInspection.SuppressIntentionAction" "false"
// ACTION: Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for fun foo
fun foo() = ""<caret>!!
@@ -1,4 +1,6 @@
// "class com.intellij.codeInspection.SuppressIntentionAction" "false"
// ACTION: Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for fun foo
// ACTION: Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for val bar
fun foo() {
val bar = ""<caret>!!
@@ -1,3 +1,5 @@
// "class com.intellij.codeInspection.SuppressIntentionAction" "false"
// ACTION: Suppress 'REDUNDANT_NULLABLE' for fun foo
// ACTION: Suppress 'REDUNDANT_NULLABLE' for parameter s
fun foo(s: String?<caret>?) {}
@@ -1,4 +1,6 @@
// "class com.intellij.codeInspection.SuppressIntentionAction" "false"
// ACTION: Suppress 'REDUNDANT_NULLABLE' for fun foo
// ACTION: Suppress 'REDUNDANT_NULLABLE' for parameter x
fun foo() {
any {
@@ -1,3 +1,4 @@
// "class com.intellij.codeInspection.SuppressIntentionAction" "false"
// ACTION: Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for val foo
val foo = ""<caret>!!
@@ -1,4 +1,5 @@
// "class com.intellij.codeInspection.SuppressIntentionAction" "false"
// ACTION: Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for fun foo
fun foo() {
object : Base(""<caret>!!) {
@@ -1,4 +1,6 @@
// "class com.intellij.codeInspection.SuppressIntentionAction" "false"
// ACTION: Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for fun foo
// ACTION: Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for val a
fun foo() {
val a = object : Base(""<caret>!!) {
@@ -1,4 +1,5 @@
// "class com.intellij.codeInspection.SuppressIntentionAction" "false"
// ACTION: Suppress 'REDUNDANT_NULLABLE' for class Child
open class Base<T>
class Child: Base<String?<caret>?>()
@@ -4,6 +4,10 @@
// ACTION: Make 'foo' abstract
// ACTION: Convert to extension
// ACTION: Disable 'Convert to extension'
// ACTION: Disable inspection
// ACTION: Disable inspection
// ACTION: Edit inspection profile setting
// ACTION: Edit inspection profile setting
// ACTION: Edit intention settings
package a
@@ -1,5 +1,7 @@
// "Change 'B.x' type to '(String) -> [ERROR : Ay]'" "false"
// ACTION: Change 'A.x' type to '(Int) -> Int'
// ACTION: Disable inspection
// ACTION: Edit inspection profile setting
// ERROR: <html>Return type is '(kotlin.Int) &rarr; kotlin.Int', which is not a subtype of overridden<br/><b>internal</b> <b>abstract</b> <b>val</b> x: (kotlin.String) &rarr; [ERROR : Ay] <i>defined in</i> A</html>
// ERROR: Unresolved reference: Ay
trait A {
@@ -31,12 +31,15 @@ import com.intellij.psi.PsiElement;
import junit.framework.Assert;
import org.apache.commons.lang.SystemUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.InTextDirectivesUtils;
import org.jetbrains.jet.lang.psi.JetFile;
import org.jetbrains.jet.plugin.PluginTestCaseBase;
import org.jetbrains.jet.test.TestMetadata;
import org.jetbrains.jet.testing.ConfigLibraryUtil;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public abstract class AbstractQuickFixTest extends LightQuickFixTestCase {
@Override
@@ -65,7 +68,8 @@ public abstract class AbstractQuickFixTest extends LightQuickFixTestCase {
}
private void checkForUnexpectedActions() throws ClassNotFoundException {
Pair<String, Boolean> pair = parseActionHintImpl(getFile(), getEditor().getDocument().getText());
String text = getEditor().getDocument().getText();
Pair<String, Boolean> pair = parseActionHintImpl(getFile(), text);
if (!pair.second) {
List<IntentionAction> actions = getAvailableActions();
@@ -74,8 +78,11 @@ public abstract class AbstractQuickFixTest extends LightQuickFixTestCase {
String className = pair.first.substring(prefix.length());
Class<?> aClass = Class.forName(className);
assert IntentionAction.class.isAssignableFrom(aClass) : className + " should be inheritor of IntentionAction";
Set<String> validActions = new HashSet<String>(InTextDirectivesUtils.findLinesWithPrefixesRemoved(text, "// ACTION:"));
for (IntentionAction action : actions) {
if (aClass.isAssignableFrom(action.getClass())) {
if (aClass.isAssignableFrom(action.getClass()) && !validActions.contains(action.getText())) {
Assert.fail("Unexpected intention action " + action.getClass() + " found");
}
}