Refactoring: extract common method
This commit is contained in:
committed by
Nikolay Krasko
parent
9ed900e2be
commit
f6af946215
@@ -18,54 +18,77 @@ package org.jetbrains.jet.editor;
|
|||||||
|
|
||||||
import com.intellij.testFramework.EditorTestUtil;
|
import com.intellij.testFramework.EditorTestUtil;
|
||||||
import com.intellij.testFramework.LightCodeInsightTestCase;
|
import com.intellij.testFramework.LightCodeInsightTestCase;
|
||||||
|
import org.jetbrains.jet.utils.ExceptionUtils;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
public class TypedHandlerTest extends LightCodeInsightTestCase {
|
public class TypedHandlerTest extends LightCodeInsightTestCase {
|
||||||
public void testTypeStringTemplateStart() throws Exception {
|
public void testTypeStringTemplateStart() {
|
||||||
configureFromFileText("a.kt", "val x = \"$<caret>\"");
|
doCharTypeTest(
|
||||||
EditorTestUtil.performTypingAction(getEditor(), '{');
|
'{',
|
||||||
checkResultByText("val x = \"${}\"");
|
|
||||||
|
"val x = \"$<caret>\"",
|
||||||
|
|
||||||
|
"val x = \"${}\""
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAutoIndentRightOpenBrace() throws Exception {
|
public void testAutoIndentRightOpenBrace() {
|
||||||
configureFromFileText("a.kt",
|
doCharTypeTest(
|
||||||
"fun test() {\n" +
|
'{',
|
||||||
"<caret>\n" +
|
|
||||||
"}");
|
"fun test() {\n" +
|
||||||
EditorTestUtil.performTypingAction(getEditor(), '{');
|
"<caret>\n" +
|
||||||
checkResultByText(
|
"}",
|
||||||
|
|
||||||
"fun test() {\n" +
|
"fun test() {\n" +
|
||||||
" {<caret>}\n" +
|
" {<caret>}\n" +
|
||||||
"}");
|
"}"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAutoIndentLeftOpenBrace() throws Exception {
|
public void testAutoIndentLeftOpenBrace() {
|
||||||
configureFromFileText("a.kt",
|
doCharTypeTest(
|
||||||
"fun test() {\n" +
|
'{',
|
||||||
" <caret>\n" +
|
|
||||||
"}");
|
"fun test() {\n" +
|
||||||
EditorTestUtil.performTypingAction(getEditor(), '{');
|
" <caret>\n" +
|
||||||
checkResultByText(
|
"}",
|
||||||
|
|
||||||
"fun test() {\n" +
|
"fun test() {\n" +
|
||||||
" {<caret>}\n" +
|
" {<caret>}\n" +
|
||||||
"}");
|
"}"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testTypeStringTemplateStartWithCloseBraceAfter() throws Exception {
|
public void testTypeStringTemplateStartWithCloseBraceAfter() {
|
||||||
configureFromFileText("a.kt", "fun foo() { \"$<caret>\" }");
|
doCharTypeTest(
|
||||||
EditorTestUtil.performTypingAction(getEditor(), '{');
|
'{',
|
||||||
checkResultByText("fun foo() { \"${}\" }");
|
|
||||||
|
"fun foo() { \"$<caret>\" }",
|
||||||
|
|
||||||
|
"fun foo() { \"${}\" }"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testTypeStringTemplateStartBeforeString() throws Exception {
|
public void testTypeStringTemplateStartBeforeString() {
|
||||||
configureFromFileText("a.kt", "fun foo() { \"$<caret>something\" }");
|
doCharTypeTest(
|
||||||
EditorTestUtil.performTypingAction(getEditor(), '{');
|
'{',
|
||||||
checkResultByText("fun foo() { \"${}something\" }");
|
|
||||||
|
"fun foo() { \"$<caret>something\" }",
|
||||||
|
|
||||||
|
"fun foo() { \"${}something\" }"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testKT3575() throws Exception {
|
public void testKT3575() {
|
||||||
configureFromFileText("a.kt", "val x = \"$<caret>]\"");
|
doCharTypeTest(
|
||||||
EditorTestUtil.performTypingAction(getEditor(), '{');
|
'{',
|
||||||
checkResultByText("val x = \"${}]\"");
|
|
||||||
|
"val x = \"$<caret>]\"",
|
||||||
|
|
||||||
|
"val x = \"${}]\""
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testTypeLtInFunDeclaration() throws Exception {
|
public void testTypeLtInFunDeclaration() throws Exception {
|
||||||
@@ -107,6 +130,17 @@ public class TypedHandlerTest extends LightCodeInsightTestCase {
|
|||||||
checkResultByText("val a: List<Set<Int>><caret>");
|
checkResultByText("val a: List<Set<Int>><caret>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void doCharTypeTest(char ch, String beforeText, String afterText) {
|
||||||
|
try {
|
||||||
|
configureFromFileText("a.kt", beforeText);
|
||||||
|
EditorTestUtil.performTypingAction(getEditor(), ch);
|
||||||
|
checkResultByText(afterText);
|
||||||
|
}
|
||||||
|
catch (IOException e) {
|
||||||
|
throw ExceptionUtils.rethrow(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void doLtGtTestNoAutoClose(String initText) throws Exception {
|
private void doLtGtTestNoAutoClose(String initText) throws Exception {
|
||||||
doLtGtTest(initText, false);
|
doLtGtTest(initText, false);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user