Fix negative quickfix tests which use when

This commit is contained in:
Alexey Sedunov
2013-05-16 13:57:09 +04:00
parent 71e76bc690
commit d5739bbe7f
3 changed files with 13 additions and 4 deletions
@@ -1,6 +1,12 @@
// "Add '<*, *>'" "false" // "Add '<*, *>'" "false"
// "Add '<*>'" "false" // "Add '<*>'" "false"
// ERROR: 2 type arguments expected // ERROR: 2 type arguments expected
// ACTION: Disable 'Eliminate Argument of 'when''
// ACTION: Disable 'Replace 'when' with 'if''
// ACTION: Edit intention settings
// ACTION: Edit intention settings
// ACTION: Eliminate argument of 'when'
// ACTION: Replace 'when' with 'if'
public fun foo(a: Any) { public fun foo(a: Any) {
when (a) { when (a) {
is <caret>Map<Int> -> {} is <caret>Map<Int> -> {}
@@ -3,6 +3,9 @@
// ERROR: 'else' entry must be the last one in a when-expression // ERROR: 'else' entry must be the last one in a when-expression
// ERROR: Unreachable code // ERROR: Unreachable code
// ERROR: Unreachable code // ERROR: Unreachable code
// ACTION: Disable 'Eliminate Argument of 'when''
// ACTION: Edit intention settings
// ACTION: Eliminate argument of 'when'
package foo package foo
fun foo() { fun foo() {
@@ -19,8 +19,8 @@ package org.jetbrains.jet.plugin.quickfix;
import com.google.common.base.Function; import com.google.common.base.Function;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
import com.google.common.collect.Collections2; import com.google.common.collect.Collections2;
import com.google.common.collect.Lists;
import com.google.common.collect.Ordering; import com.google.common.collect.Ordering;
import com.google.common.collect.Sets;
import com.intellij.codeInsight.intention.IntentionAction; import com.intellij.codeInsight.intention.IntentionAction;
import com.intellij.testFramework.UsefulTestCase; import com.intellij.testFramework.UsefulTestCase;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@@ -73,16 +73,16 @@ public class QuickFixActionsUtils {
public static void checkAvailableActionsAreExpected(JetFile file, Collection<IntentionAction> availableActions) { public static void checkAvailableActionsAreExpected(JetFile file, Collection<IntentionAction> availableActions) {
List<String> validActions = Ordering.natural().sortedCopy( List<String> validActions = Ordering.natural().sortedCopy(
Sets.newHashSet(InTextDirectivesUtils.findLinesWithPrefixesRemoved(file.getText(), "// ACTION:"))); Lists.newArrayList(InTextDirectivesUtils.findLinesWithPrefixesRemoved(file.getText(), "// ACTION:")));
Collection<String> actualActions = Ordering.natural().sortedCopy( Collection<String> actualActions = Ordering.natural().sortedCopy(
Collections2.transform(availableActions, new Function<IntentionAction, String>() { Lists.newArrayList(Collections2.transform(availableActions, new Function<IntentionAction, String>() {
@Override @Override
public String apply(@Nullable IntentionAction input) { public String apply(@Nullable IntentionAction input) {
assert input != null; assert input != null;
return input.getText(); return input.getText();
} }
})); })));
UsefulTestCase.assertOrderedEquals("Some unexpected actions available at current position: %s. Use // ACTION: directive", UsefulTestCase.assertOrderedEquals("Some unexpected actions available at current position: %s. Use // ACTION: directive",
actualActions, validActions); actualActions, validActions);