Udate test framework for confidence tests. Move type directive to test files

This commit is contained in:
Nikolay Krasko
2012-09-20 16:49:36 +04:00
parent bce5cb9034
commit f1059271b2
15 changed files with 67 additions and 26 deletions
@@ -1,3 +1,5 @@
fun test() {
12.in<caret>
}
}
// TYPE: "."
@@ -1,3 +1,5 @@
fun test() {
12.inc(). <caret>
}
12.inc().<caret>
}
// TYPE: "."
@@ -1 +1,3 @@
import kotlin.util <caret>// Comment to prevent for removing trailing spaces
import kotlin.util <caret>// Comment to prevent for removing trailing spaces
// TYPE: "as"
@@ -1 +1,3 @@
import kotlin.util as // Comment to prevent for removing trailing spaces
import kotlin.util as// Comment to prevent for removing trailing spaces
// TYPE: "as"
@@ -1,4 +1,6 @@
fun main(args : Array<String>) {
val mmm = 12
val t = { <caret>}
}
}
// TYPE: "mm "
@@ -1,4 +1,6 @@
fun main(args : Array<String>) {
val mmm = 12
val t = { mm }
}
}
// TYPE: "mm "
@@ -1,4 +1,6 @@
fun main(args : Array<String>) {
val mmm = 12
val t = { (<caret>) }
}
}
// TYPE: "mm "
@@ -1,4 +1,6 @@
fun main(args : Array<String>) {
val mmm = 12
val t = { (mm ) }
}
}
// TYPE: "mm "
@@ -1,4 +1,6 @@
fun main(args : Array<String>) {
val mmm = 12
val t = { i -> <caret>}
}
}
// TYPE: "mm "
@@ -1,4 +1,6 @@
fun main(args : Array<String>) {
val mmm = 12
val t = { i -> mmm }
}
}
// TYPE: "mm "
@@ -2,4 +2,6 @@ package test
import java.util.AbstractSet as Hello
<caret>// Comment to prevent for removing trailing spaces
<caret>// Comment to prevent for removing trailing spaces
// TYPE: "pub "
@@ -2,4 +2,6 @@ package test
import java.util.AbstractSet as Hello
public // Comment to prevent for removing trailing spaces
public // Comment to prevent for removing trailing spaces
// TYPE: "pub "
@@ -2,3 +2,5 @@ fun test() {
for (i in 12.<caret>) {
}
}
// TYPE: "."
@@ -1,4 +1,6 @@
fun test() {
for (i in 12.. ) {
for (i in 12..) {
}
}
// TYPE: "."
@@ -21,8 +21,10 @@ import com.intellij.codeInsight.completion.CompletionType;
import com.intellij.codeInsight.completion.LightCompletionTestCase;
import com.intellij.openapi.projectRoots.JavaSdk;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.util.text.StringUtil;
import org.apache.commons.lang.SystemUtils;
import org.jetbrains.jet.plugin.PluginTestCaseBase;
import org.jetbrains.jet.testing.InTextDirectivesUtils;
import java.io.File;
@@ -30,40 +32,51 @@ import java.io.File;
* @author Nikolay Krasko
*/
public class JetConfidenceTest extends LightCompletionTestCase {
private static final String TYPE_DIRECTIVE_PREFIX = "// TYPE:";
public void testCompleteOnDotOutOfRanges() {
doTest(".");
doTest();
}
public void testImportAsConfidence() {
doTest("as");
}
public void testInModifierList() {
doTest("pub");
doTest();
}
public void testInBeginningOfFunctionLiteral() {
doTest("mm");
doTest();
}
public void testInBeginningOfFunctionLiteralInBrackets() {
doTest("mm");
doTest();
}
public void testInBlockOfFunctionLiteral() {
doTest("mm");
doTest();
}
public void testInModifierList() {
doTest();
}
public void testNoAutoCompletionForRangeOperator() {
doTest(".");
doTest();
}
protected void doTest(String completionActivateType) {
protected void doTest() {
configureByFile(getBeforeFileName());
type(completionActivateType + " ");
type(getTypeTextFromFile());
checkResultByFile(getAfterFileName());
}
protected static String getTypeTextFromFile() {
String text = getEditor().getDocument().getText();
String[] directives = InTextDirectivesUtils.findListWithPrefix(TYPE_DIRECTIVE_PREFIX, text);
assertEquals("One directive with \"" + TYPE_DIRECTIVE_PREFIX +"\" expected", 1, directives.length);
return StringUtil.unquoteString(directives[0]);
}
protected String getBeforeFileName() {
return getTestName(false) + ".kt";
}