Change the way of runtime configuration in JsePsiUnifierTest

This commit is contained in:
Nikolay Krasko
2014-12-16 13:14:15 +03:00
parent 37cea8a720
commit 8f6f404f14
48 changed files with 79 additions and 110 deletions
@@ -1,4 +1,3 @@
// WITH_RUNTIME
fun foo() { fun foo() {
when { when {
true -> <selection>{ true -> <selection>{
@@ -1,4 +1,3 @@
// WITH_RUNTIME
fun foo() { fun foo() {
when { when {
true -> <selection>{ true -> <selection>{
@@ -1,4 +1,3 @@
// WITH_RUNTIME
fun foo() { fun foo() {
when { when {
true -> <selection>{ true -> <selection>{
@@ -1,4 +1,3 @@
// WITH_RUNTIME
fun foo(a: Int, b: Int) { fun foo(a: Int, b: Int) {
var t = a var t = a
<selection>do { <selection>do {
@@ -1,4 +1,3 @@
// WITH_RUNTIME
fun foo(a: Int, b: Int) { fun foo(a: Int, b: Int) {
<selection>for (i in a - b..a + b) { <selection>for (i in a - b..a + b) {
println(i*i) println(i*i)
@@ -1,4 +1,3 @@
// WITH_RUNTIME
fun foo(a: Int, b: Int) { fun foo(a: Int, b: Int) {
if ((a) + b > 0) { if ((a) + b > 0) {
println(a*b) println(a*b)
@@ -1,4 +1,3 @@
// WITH_RUNTIME
fun foo(a: Int, b: Int) { fun foo(a: Int, b: Int) {
<selection>if ((a) + b > 0) { <selection>if ((a) + b > 0) {
println(a*(b)) println(a*(b))
@@ -1,4 +1,3 @@
// WITH_RUNTIME
fun foo(a: Int, b: Int) { fun foo(a: Int, b: Int) {
<selection>when((a)) { <selection>when((a)) {
1 -> println(b) 1 -> println(b)
@@ -1,4 +1,3 @@
// WITH_RUNTIME
fun foo(a: Int, b: Int) { fun foo(a: Int, b: Int) {
<selection>when { <selection>when {
(a == 1) -> println(b) (a == 1) -> println(b)
@@ -1,4 +1,3 @@
// WITH_RUNTIME
fun foo(a: Int, b: Int) { fun foo(a: Int, b: Int) {
var t = a var t = a
<selection>while (t != (a + b)) { <selection>while (t != (a + b)) {
@@ -1,4 +1,3 @@
// WITH_RUNTIME
fun foo(f: (Int) -> Unit) { fun foo(f: (Int) -> Unit) {
<selection>{ (n: Int, s: String) -> <selection>{ (n: Int, s: String) ->
val a = n + 1 val a = n + 1
@@ -1,4 +1,3 @@
// WITH_RUNTIME
fun foo(f: (Int) -> Unit) { fun foo(f: (Int) -> Unit) {
{ (m: Int, n: Int, s: String) -> { (m: Int, n: Int, s: String) ->
val a = n + m val a = n + m
@@ -1,4 +1,3 @@
// WITH_RUNTIME
fun Int.contains(n: Int): Boolean = n < this fun Int.contains(n: Int): Boolean = n < this
fun foo(n: Int): Int { fun foo(n: Int): Int {
@@ -1,4 +1,3 @@
// WITH_RUNTIME
var a = 1 var a = 1
val b = <selection>a</selection> + 1 val b = <selection>a</selection> + 1
@@ -1,4 +1,3 @@
// WITH_RUNTIME
class A { class A {
fun foo() { fun foo() {
println(<selection>this</selection>) println(<selection>this</selection>)
@@ -1,4 +1,3 @@
// WITH_RUNTIME
class A { class A {
fun foo() { fun foo() {
println(this) println(this)
@@ -1,4 +1,3 @@
// WITH_RUNTIME
import java.util.HashMap import java.util.HashMap
val a: <selection>Map<String, MutableList<Any>></selection> = HashMap() val a: <selection>Map<String, MutableList<Any>></selection> = HashMap()
@@ -52,28 +52,16 @@ public abstract class AbstractJetPsiUnifierTest: JetLightCodeInsightFixtureTestC
myFixture.configureByFile(filePath) myFixture.configureByFile(filePath)
val file = myFixture.getFile() as JetFile val file = myFixture.getFile() as JetFile
val withRuntime = InTextDirectivesUtils.findStringWithPrefixes(file.getText(), "// WITH_RUNTIME") != null DirectiveBasedActionUtils.checkForUnexpectedErrors(file)
if (withRuntime) {
ConfigLibraryUtil.configureKotlinRuntime(myModule, PluginTestCaseBase.fullJdk())
}
try { val actualText =
DirectiveBasedActionUtils.checkForUnexpectedErrors(file) findPattern(file)
.toRange()
val actualText = .match(file, JetPsiUnifier.DEFAULT)
findPattern(file) .map { it.range.getTextRange().substring(file.getText()!!) }
.toRange() .joinToString("\n\n")
.match(file, JetPsiUnifier.DEFAULT) JetTestUtils.assertEqualsToFile(File("$filePath.match"), actualText)
.map { it.range.getTextRange().substring(file.getText()!!) }
.joinToString("\n\n")
JetTestUtils.assertEqualsToFile(File("$filePath.match"), actualText)
}
finally {
if (withRuntime) {
ConfigLibraryUtil.unConfigureKotlinRuntime(myModule, PluginTestCaseBase.fullJdk())
}
}
} }
override fun getProjectDescriptor(): LightProjectDescriptor = JetLightProjectDescriptor.INSTANCE override fun getProjectDescriptor(): LightProjectDescriptor = getProjectDescriptorFromTestName()
} }
@@ -67,27 +67,27 @@ public class JetPsiUnifierTestGenerated extends AbstractJetPsiUnifierTest {
doTest(fileName); doTest(fileName);
} }
@TestMetadata("doWhile.kt") @TestMetadata("doWhileRuntime.kt")
public void testDoWhile() throws Exception { public void testDoWhileRuntime() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/unifier/equivalence/controlStructures/doWhile.kt"); String fileName = JetTestUtils.navigationMetadata("idea/testData/unifier/equivalence/controlStructures/doWhileRuntime.kt");
doTest(fileName); doTest(fileName);
} }
@TestMetadata("for.kt") @TestMetadata("forRuntime.kt")
public void testFor() throws Exception { public void testForRuntime() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/unifier/equivalence/controlStructures/for.kt"); String fileName = JetTestUtils.navigationMetadata("idea/testData/unifier/equivalence/controlStructures/forRuntime.kt");
doTest(fileName); doTest(fileName);
} }
@TestMetadata("if.kt") @TestMetadata("ifElseRuntime.kt")
public void testIf() throws Exception { public void testIfElseRuntime() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/unifier/equivalence/controlStructures/if.kt"); String fileName = JetTestUtils.navigationMetadata("idea/testData/unifier/equivalence/controlStructures/ifElseRuntime.kt");
doTest(fileName); doTest(fileName);
} }
@TestMetadata("ifElse.kt") @TestMetadata("ifRuntime.kt")
public void testIfElse() throws Exception { public void testIfRuntime() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/unifier/equivalence/controlStructures/ifElse.kt"); String fileName = JetTestUtils.navigationMetadata("idea/testData/unifier/equivalence/controlStructures/ifRuntime.kt");
doTest(fileName); doTest(fileName);
} }
@@ -115,21 +115,21 @@ public class JetPsiUnifierTestGenerated extends AbstractJetPsiUnifierTest {
doTest(fileName); doTest(fileName);
} }
@TestMetadata("whenWithSubject.kt") @TestMetadata("whenWithSubjectRuntime.kt")
public void testWhenWithSubject() throws Exception { public void testWhenWithSubjectRuntime() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/unifier/equivalence/controlStructures/whenWithSubject.kt"); String fileName = JetTestUtils.navigationMetadata("idea/testData/unifier/equivalence/controlStructures/whenWithSubjectRuntime.kt");
doTest(fileName); doTest(fileName);
} }
@TestMetadata("whenWithoutSubject.kt") @TestMetadata("whenWithoutSubjectRuntime.kt")
public void testWhenWithoutSubject() throws Exception { public void testWhenWithoutSubjectRuntime() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/unifier/equivalence/controlStructures/whenWithoutSubject.kt"); String fileName = JetTestUtils.navigationMetadata("idea/testData/unifier/equivalence/controlStructures/whenWithoutSubjectRuntime.kt");
doTest(fileName); doTest(fileName);
} }
@TestMetadata("while.kt") @TestMetadata("whileRuntime.kt")
public void testWhile() throws Exception { public void testWhileRuntime() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/unifier/equivalence/controlStructures/while.kt"); String fileName = JetTestUtils.navigationMetadata("idea/testData/unifier/equivalence/controlStructures/whileRuntime.kt");
doTest(fileName); doTest(fileName);
} }
@@ -141,21 +141,21 @@ public class JetPsiUnifierTestGenerated extends AbstractJetPsiUnifierTest {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/unifier/equivalence/controlStructures/blocks"), Pattern.compile("^(.+)\\.kt$"), true); JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/unifier/equivalence/controlStructures/blocks"), Pattern.compile("^(.+)\\.kt$"), true);
} }
@TestMetadata("anonymousObjects.kt") @TestMetadata("anonymousObjectsRuntime.kt")
public void testAnonymousObjects() throws Exception { public void testAnonymousObjectsRuntime() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/unifier/equivalence/controlStructures/blocks/anonymousObjects.kt"); String fileName = JetTestUtils.navigationMetadata("idea/testData/unifier/equivalence/controlStructures/blocks/anonymousObjectsRuntime.kt");
doTest(fileName); doTest(fileName);
} }
@TestMetadata("localFunctions.kt") @TestMetadata("localFunctionsRuntime.kt")
public void testLocalFunctions() throws Exception { public void testLocalFunctionsRuntime() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/unifier/equivalence/controlStructures/blocks/localFunctions.kt"); String fileName = JetTestUtils.navigationMetadata("idea/testData/unifier/equivalence/controlStructures/blocks/localFunctionsRuntime.kt");
doTest(fileName); doTest(fileName);
} }
@TestMetadata("localVars.kt") @TestMetadata("localVarsRuntime.kt")
public void testLocalVars() throws Exception { public void testLocalVarsRuntime() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/unifier/equivalence/controlStructures/blocks/localVars.kt"); String fileName = JetTestUtils.navigationMetadata("idea/testData/unifier/equivalence/controlStructures/blocks/localVarsRuntime.kt");
doTest(fileName); doTest(fileName);
} }
} }
@@ -274,9 +274,9 @@ public class JetPsiUnifierTestGenerated extends AbstractJetPsiUnifierTest {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/unifier/equivalence/declarations/localCallables/lambdas"), Pattern.compile("^(.+)\\.kt$"), true); JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/unifier/equivalence/declarations/localCallables/lambdas"), Pattern.compile("^(.+)\\.kt$"), true);
} }
@TestMetadata("multipleParams.kt") @TestMetadata("multipleParamsRuntime.kt")
public void testMultipleParams() throws Exception { public void testMultipleParamsRuntime() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/unifier/equivalence/declarations/localCallables/lambdas/multipleParams.kt"); String fileName = JetTestUtils.navigationMetadata("idea/testData/unifier/equivalence/declarations/localCallables/lambdas/multipleParamsRuntime.kt");
doTest(fileName); doTest(fileName);
} }
@@ -286,9 +286,9 @@ public class JetPsiUnifierTestGenerated extends AbstractJetPsiUnifierTest {
doTest(fileName); doTest(fileName);
} }
@TestMetadata("receiverArguments.kt") @TestMetadata("receiverArgumentsRuntime.kt")
public void testReceiverArguments() throws Exception { public void testReceiverArgumentsRuntime() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/unifier/equivalence/declarations/localCallables/lambdas/receiverArguments.kt"); String fileName = JetTestUtils.navigationMetadata("idea/testData/unifier/equivalence/declarations/localCallables/lambdas/receiverArgumentsRuntime.kt");
doTest(fileName); doTest(fileName);
} }
@@ -349,9 +349,9 @@ public class JetPsiUnifierTestGenerated extends AbstractJetPsiUnifierTest {
doTest(fileName); doTest(fileName);
} }
@TestMetadata("simpleName.kt") @TestMetadata("simpleNameRuntime.kt")
public void testSimpleName() throws Exception { public void testSimpleNameRuntime() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/unifier/equivalence/expressions/simpleName.kt"); String fileName = JetTestUtils.navigationMetadata("idea/testData/unifier/equivalence/expressions/simpleNameRuntime.kt");
doTest(fileName); doTest(fileName);
} }
@@ -369,15 +369,15 @@ public class JetPsiUnifierTestGenerated extends AbstractJetPsiUnifierTest {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/unifier/equivalence/expressions/callableReferences"), Pattern.compile("^(.+)\\.kt$"), true); JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/unifier/equivalence/expressions/callableReferences"), Pattern.compile("^(.+)\\.kt$"), true);
} }
@TestMetadata("classRef.kt") @TestMetadata("classRefRuntime.kt")
public void testClassRef() throws Exception { public void testClassRefRuntime() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/unifier/equivalence/expressions/callableReferences/classRef.kt"); String fileName = JetTestUtils.navigationMetadata("idea/testData/unifier/equivalence/expressions/callableReferences/classRefRuntime.kt");
doTest(fileName); doTest(fileName);
} }
@TestMetadata("functionRef.kt") @TestMetadata("functionRefRuntime.kt")
public void testFunctionRef() throws Exception { public void testFunctionRefRuntime() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/unifier/equivalence/expressions/callableReferences/functionRef.kt"); String fileName = JetTestUtils.navigationMetadata("idea/testData/unifier/equivalence/expressions/callableReferences/functionRefRuntime.kt");
doTest(fileName); doTest(fileName);
} }
} }
@@ -396,9 +396,9 @@ public class JetPsiUnifierTestGenerated extends AbstractJetPsiUnifierTest {
doTest(fileName); doTest(fileName);
} }
@TestMetadata("externalArguments.kt") @TestMetadata("externalArgumentsRuntime.kt")
public void testExternalArguments() throws Exception { public void testExternalArgumentsRuntime() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/unifier/equivalence/expressions/calls/externalArguments.kt"); String fileName = JetTestUtils.navigationMetadata("idea/testData/unifier/equivalence/expressions/calls/externalArgumentsRuntime.kt");
doTest(fileName); doTest(fileName);
} }
@@ -475,9 +475,9 @@ public class JetPsiUnifierTestGenerated extends AbstractJetPsiUnifierTest {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/unifier/equivalence/expressions/conventions"), Pattern.compile("^(.+)\\.kt$"), true); JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/unifier/equivalence/expressions/conventions"), Pattern.compile("^(.+)\\.kt$"), true);
} }
@TestMetadata("contains.kt") @TestMetadata("containsRuntime.kt")
public void testContains() throws Exception { public void testContainsRuntime() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/unifier/equivalence/expressions/conventions/contains.kt"); String fileName = JetTestUtils.navigationMetadata("idea/testData/unifier/equivalence/expressions/conventions/containsRuntime.kt");
doTest(fileName); doTest(fileName);
} }
@@ -487,9 +487,9 @@ public class JetPsiUnifierTestGenerated extends AbstractJetPsiUnifierTest {
doTest(fileName); doTest(fileName);
} }
@TestMetadata("get.kt") @TestMetadata("getRuntime.kt")
public void testGet() throws Exception { public void testGetRuntime() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/unifier/equivalence/expressions/conventions/get.kt"); String fileName = JetTestUtils.navigationMetadata("idea/testData/unifier/equivalence/expressions/conventions/getRuntime.kt");
doTest(fileName); doTest(fileName);
} }
@@ -543,9 +543,9 @@ public class JetPsiUnifierTestGenerated extends AbstractJetPsiUnifierTest {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/unifier/equivalence/expressions/conventions/assignments"), Pattern.compile("^(.+)\\.kt$"), true); JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/unifier/equivalence/expressions/conventions/assignments"), Pattern.compile("^(.+)\\.kt$"), true);
} }
@TestMetadata("indexedPlusAssign.kt") @TestMetadata("indexedPlusAssignRuntime.kt")
public void testIndexedPlusAssign() throws Exception { public void testIndexedPlusAssignRuntime() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/unifier/equivalence/expressions/conventions/assignments/indexedPlusAssign.kt"); String fileName = JetTestUtils.navigationMetadata("idea/testData/unifier/equivalence/expressions/conventions/assignments/indexedPlusAssignRuntime.kt");
doTest(fileName); doTest(fileName);
} }
@@ -567,9 +567,9 @@ public class JetPsiUnifierTestGenerated extends AbstractJetPsiUnifierTest {
doTest(fileName); doTest(fileName);
} }
@TestMetadata("set.kt") @TestMetadata("setRuntime.kt")
public void testSet() throws Exception { public void testSetRuntime() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/unifier/equivalence/expressions/conventions/assignments/set.kt"); String fileName = JetTestUtils.navigationMetadata("idea/testData/unifier/equivalence/expressions/conventions/assignments/setRuntime.kt");
doTest(fileName); doTest(fileName);
} }
} }
@@ -718,15 +718,15 @@ public class JetPsiUnifierTestGenerated extends AbstractJetPsiUnifierTest {
doTest(fileName); doTest(fileName);
} }
@TestMetadata("simpleThis1.kt") @TestMetadata("simpleThis1Runtime.kt")
public void testSimpleThis1() throws Exception { public void testSimpleThis1Runtime() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/unifier/equivalence/expressions/this/simpleThis1.kt"); String fileName = JetTestUtils.navigationMetadata("idea/testData/unifier/equivalence/expressions/this/simpleThis1Runtime.kt");
doTest(fileName); doTest(fileName);
} }
@TestMetadata("simpleThis2.kt") @TestMetadata("simpleThis2Runtime.kt")
public void testSimpleThis2() throws Exception { public void testSimpleThis2Runtime() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/unifier/equivalence/expressions/this/simpleThis2.kt"); String fileName = JetTestUtils.navigationMetadata("idea/testData/unifier/equivalence/expressions/this/simpleThis2Runtime.kt");
doTest(fileName); doTest(fileName);
} }
} }
@@ -770,9 +770,9 @@ public class JetPsiUnifierTestGenerated extends AbstractJetPsiUnifierTest {
doTest(fileName); doTest(fileName);
} }
@TestMetadata("userType.kt") @TestMetadata("userTypeRuntime.kt")
public void testUserType() throws Exception { public void testUserTypeRuntime() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/unifier/equivalence/types/userType.kt"); String fileName = JetTestUtils.navigationMetadata("idea/testData/unifier/equivalence/types/userTypeRuntime.kt");
doTest(fileName); doTest(fileName);
} }
} }