Simplified CodeTransformationTest. Only one doTest method remains, intention class is moved to test data. Merged other intention tests (SpecifyTypeExplicitlyTest, ConvertToBlock/ExpressionBodyTest) into this one.

This commit is contained in:
Evgeny Gerashchenko
2014-07-07 21:09:31 +04:00
parent b1003fc034
commit fda7aeecfb
169 changed files with 4764 additions and 4969 deletions
@@ -87,7 +87,6 @@ import org.jetbrains.jet.resolve.AbstractReferenceResolveInLibrarySourcesTest
import org.jetbrains.jet.resolve.constraintSystem.AbstractConstraintSystemTest
import org.jetbrains.jet.completion.AbstractCompiledKotlinInJavaCompletionTest
import org.jetbrains.jet.completion.AbstractKotlinSourceInJavaCompletionTest
import org.jetbrains.jet.plugin.intentions.AbstractIntentionTest
import org.jetbrains.jet.checkers.AbstractJetDiagnosticsTestWithStdLib
import org.jetbrains.jet.plugin.codeInsight.AbstractInsertImportOnPasteTest
import org.jetbrains.jet.resolve.AbstractReferenceToJavaWithWrongFileStructureTest
@@ -313,14 +312,6 @@ fun main(args: Array<String>) {
model("quickfix", pattern = "^before(\\w+)\\.kt$")
}
testClass(javaClass<AbstractIntentionTest>(), "ConvertToExpressionBodyTestGenerated") {
model("intentions/convertToExpressionBody", pattern = "^before(\\w+)\\.kt$")
}
testClass(javaClass<AbstractIntentionTest>(), "ConvertToBlockBodyTestGenerated") {
model("intentions/convertToBlockBody", pattern = "^before(\\w+)\\.kt$")
}
testClass(javaClass<AbstractJSBasicCompletionTest>()) {
model("completion/basic/common")
model("completion/basic/js")
@@ -391,68 +382,7 @@ fun main(args: Array<String>) {
}
testClass(javaClass<AbstractCodeTransformationTest>()) {
model("intentions/branched/doubleBangToIfThen", testMethod = "doTestDoubleBangToIfThen")
model("intentions/branched/ifThenToDoubleBang", testMethod = "doTestIfThenToDoubleBang")
model("intentions/branched/elvisToIfThen", testMethod = "doTestElvisToIfThen")
model("intentions/branched/ifThenToElvis", testMethod = "doTestIfThenToElvis")
model("intentions/branched/safeAccessToIfThen", testMethod = "doTestSafeAccessToIfThen")
model("intentions/branched/ifThenToSafeAccess", testMethod = "doTestIfThenToSafeAccess")
model("intentions/branched/folding/ifToAssignment", testMethod = "doTestFoldIfToAssignment")
model("intentions/branched/folding/ifToReturn", testMethod = "doTestFoldIfToReturn")
model("intentions/branched/folding/ifToReturnAsymmetrically", testMethod = "doTestFoldIfToReturnAsymmetrically")
model("intentions/branched/folding/whenToAssignment", testMethod = "doTestFoldWhenToAssignment")
model("intentions/branched/folding/whenToReturn", testMethod = "doTestFoldWhenToReturn")
model("intentions/branched/unfolding/assignmentToIf", testMethod = "doTestUnfoldAssignmentToIf")
model("intentions/branched/unfolding/assignmentToWhen", testMethod = "doTestUnfoldAssignmentToWhen")
model("intentions/branched/unfolding/propertyToIf", testMethod = "doTestUnfoldPropertyToIf")
model("intentions/branched/unfolding/propertyToWhen", testMethod = "doTestUnfoldPropertyToWhen")
model("intentions/branched/unfolding/returnToIf", testMethod = "doTestUnfoldReturnToIf")
model("intentions/branched/unfolding/returnToWhen", testMethod = "doTestUnfoldReturnToWhen")
model("intentions/branched/ifWhen/ifToWhen", testMethod = "doTestIfToWhen")
model("intentions/branched/ifWhen/whenToIf", testMethod = "doTestWhenToIf")
model("intentions/branched/when/flatten", testMethod = "doTestFlattenWhen")
model("intentions/branched/when/merge", testMethod = "doTestMergeWhen")
model("intentions/branched/when/introduceSubject", testMethod = "doTestIntroduceWhenSubject")
model("intentions/branched/when/eliminateSubject", testMethod = "doTestEliminateWhenSubject")
model("intentions/declarations/split", testMethod = "doTestSplitProperty")
model("intentions/declarations/convertMemberToExtension", testMethod = "doTestConvertMemberToExtension")
model("intentions/reconstructedType", testMethod = "doTestReconstructType")
model("intentions/removeUnnecessaryParentheses", testMethod = "doTestRemoveUnnecessaryParentheses")
model("intentions/replaceWithDotQualifiedMethodCall", testMethod = "doTestReplaceWithDotQualifiedMethodCall")
model("intentions/replaceWithInfixFunctionCall", testMethod = "doTestReplaceWithInfixFunctionCall")
model("intentions/removeCurlyBracesFromTemplate", testMethod = "doTestRemoveCurlyFromTemplate")
model("intentions/convertToStringTemplateIntention", testMethod = "doTestConvertToStringTemplate")
model("intentions/convertToConcatenatedStringIntention", testMethod = "doTestConvertToConcatenatedStringIntention")
model("intentions/insertCurlyBracestsToTemplate", testMethod = "doTestInsertCurlyToTemplate")
model("intentions/moveLambdaInsideParentheses", testMethod = "doTestMoveLambdaInsideParentheses")
model("intentions/moveLambdaOutsideParentheses", testMethod = "doTestMoveLambdaOutsideParentheses")
model("intentions/replaceExplicitFunctionLiteralParamWithIt", testMethod = "doTestReplaceExplicitFunctionLiteralParamWithIt")
model("intentions/replaceItWithExplicitFunctionLiteralParam", testMethod = "doTestReplaceItWithExplicitFunctionLiteralParam")
model("intentions/removeBraces", testMethod = "doTestRemoveBraces")
model("intentions/addBraces", testMethod = "doTestAddBraces")
model("intentions/attributeCallReplacements/replaceGetIntention", testMethod = "doTestReplaceGetIntention")
model("intentions/attributeCallReplacements/replaceContainsIntention", testMethod = "doTestReplaceContainsIntention")
model("intentions/attributeCallReplacements/replaceBinaryInfixIntention", testMethod = "doTestReplaceBinaryInfixIntention")
model("intentions/attributeCallReplacements/replaceUnaryPrefixIntention", testMethod = "doTestReplaceUnaryPrefixIntention")
model("intentions/attributeCallReplacements/replaceInvokeIntention", testMethod = "doTestReplaceInvokeIntention")
model("intentions/simplifyNegatedBinaryExpressionIntention", testMethod = "doTestSimplifyNegatedBinaryExpressionIntention")
model("intentions/convertNegatedBooleanSequence", testMethod="doTestConvertNegatedBooleanSequence")
model("intentions/convertNegatedExpressionWithDemorgansLaw", testMethod = "doTestConvertNegatedExpressionWithDemorgansLaw")
model("intentions/swapBinaryExpression", testMethod = "doTestSwapBinaryExpression")
model("intentions/splitIf", testMethod = "doTestSplitIf")
model("intentions/replaceWithOperatorAssign", testMethod = "doTestReplaceWithOperatorAssign")
model("intentions/replaceWithTraditionalAssignment", testMethod = "doTestReplaceWithTraditionalAssignment")
model("intentions/simplifyBooleanWithConstants", testMethod = "doTestSimplifyBooleanWithConstants")
model("intentions/insertExplicitTypeArguments", testMethod = "doTestInsertExplicitTypeArguments")
model("intentions/removeExplicitTypeArguments", testMethod = "doTestRemoveExplicitTypeArguments")
model("intentions/convertAssertToIf", testMethod = "doTestConvertAssertToIfWithThrowIntention")
model("intentions/convertIfToAssert", testMethod = "doTestConvertIfWithThrowToAssertIntention")
model("intentions/makeTypeExplicitInLambda", testMethod = "doTestMakeTypeExplicitInLambda")
model("intentions/makeTypeImplicitInLambda", testMethod = "doTestMakeTypeImplicitInLambda")
model("intentions/invertIfCondition", testMethod = "doTestInvertIfCondition")
model("intentions/operatorToFunction", testMethod = "doTestOperatorToFunction")
model("intentions/convertToForEachLoop", testMethod = "doTestConvertToForEachLoop")
model("intentions/convertToForEachFunctionCall", testMethod = "doTestConvertToForEachFunctionCall")
model("intentions", testMethod = "doTest")
}
testClass(javaClass<AbstractJetInspectionTest>()) {
@@ -0,0 +1 @@
org.jetbrains.jet.plugin.intentions.AddBracesIntention
@@ -0,0 +1 @@
org.jetbrains.jet.plugin.intentions.TestableReplaceBinaryInfixIntention
@@ -0,0 +1 @@
org.jetbrains.jet.plugin.intentions.TestableReplaceContainsIntention
@@ -0,0 +1 @@
org.jetbrains.jet.plugin.intentions.TestableReplaceGetIntention
@@ -0,0 +1 @@
org.jetbrains.jet.plugin.intentions.TestableReplaceInvokeIntention
@@ -0,0 +1 @@
org.jetbrains.jet.plugin.intentions.TestableReplaceUnaryPrefixIntention
@@ -0,0 +1 @@
org.jetbrains.jet.plugin.intentions.branchedTransformations.intentions.DoubleBangToIfThenIntention
@@ -0,0 +1 @@
org.jetbrains.jet.plugin.intentions.branchedTransformations.intentions.ElvisToIfThenIntention
@@ -0,0 +1 @@
org.jetbrains.jet.plugin.intentions.branchedTransformations.intentions.FoldIfToAssignmentIntention
@@ -0,0 +1 @@
org.jetbrains.jet.plugin.intentions.branchedTransformations.intentions.FoldIfToReturnIntention
@@ -0,0 +1 @@
org.jetbrains.jet.plugin.intentions.branchedTransformations.intentions.FoldIfToReturnAsymmetricallyIntention
@@ -0,0 +1 @@
org.jetbrains.jet.plugin.intentions.branchedTransformations.intentions.FoldWhenToAssignmentIntention
@@ -0,0 +1 @@
org.jetbrains.jet.plugin.intentions.branchedTransformations.intentions.FoldWhenToReturnIntention
@@ -0,0 +1 @@
org.jetbrains.jet.plugin.intentions.branchedTransformations.intentions.IfThenToDoubleBangIntention
@@ -0,0 +1 @@
org.jetbrains.jet.plugin.intentions.branchedTransformations.intentions.IfThenToElvisIntention
@@ -0,0 +1 @@
org.jetbrains.jet.plugin.intentions.branchedTransformations.intentions.IfThenToSafeAccessIntention
@@ -0,0 +1 @@
org.jetbrains.jet.plugin.intentions.branchedTransformations.intentions.IfToWhenIntention
@@ -0,0 +1 @@
org.jetbrains.jet.plugin.intentions.branchedTransformations.intentions.WhenToIfIntention
@@ -0,0 +1 @@
org.jetbrains.jet.plugin.intentions.branchedTransformations.intentions.SafeAccessToIfThenIntention
@@ -0,0 +1 @@
org.jetbrains.jet.plugin.intentions.branchedTransformations.intentions.UnfoldAssignmentToIfIntention
@@ -0,0 +1 @@
org.jetbrains.jet.plugin.intentions.branchedTransformations.intentions.UnfoldAssignmentToWhenIntention
@@ -0,0 +1 @@
org.jetbrains.jet.plugin.intentions.branchedTransformations.intentions.UnfoldPropertyToIfIntention
@@ -0,0 +1 @@
org.jetbrains.jet.plugin.intentions.branchedTransformations.intentions.UnfoldPropertyToWhenIntention
@@ -0,0 +1 @@
org.jetbrains.jet.plugin.intentions.branchedTransformations.intentions.UnfoldReturnToIfIntention
@@ -0,0 +1 @@
org.jetbrains.jet.plugin.intentions.branchedTransformations.intentions.UnfoldReturnToWhenIntention
@@ -0,0 +1 @@
org.jetbrains.jet.plugin.intentions.branchedTransformations.intentions.EliminateWhenSubjectIntention
@@ -0,0 +1 @@
org.jetbrains.jet.plugin.intentions.branchedTransformations.intentions.FlattenWhenIntention
@@ -0,0 +1 @@
org.jetbrains.jet.plugin.intentions.branchedTransformations.intentions.IntroduceWhenSubjectIntention
@@ -0,0 +1 @@
org.jetbrains.jet.plugin.intentions.branchedTransformations.intentions.MergeWhenIntention
@@ -0,0 +1 @@
org.jetbrains.jet.plugin.intentions.ConvertAssertToIfWithThrowIntention
@@ -0,0 +1 @@
org.jetbrains.jet.plugin.intentions.ConvertIfWithThrowToAssertIntention
@@ -0,0 +1 @@
org.jetbrains.jet.plugin.intentions.ConvertNegatedBooleanSequenceIntention
@@ -0,0 +1 @@
org.jetbrains.jet.plugin.intentions.ConvertNegatedExpressionWithDemorgansLawIntention
@@ -0,0 +1 @@
org.jetbrains.jet.plugin.intentions.ConvertToBlockBodyAction
@@ -1,2 +0,0 @@
// "Convert to block body" "true"
fun <caret>foo(): String = "abc"
@@ -0,0 +1 @@
fun <caret>foo(): String = "abc"
@@ -1,4 +1,3 @@
// "Convert to block body" "true"
fun foo(): String {
return "abc"
}
@@ -1,3 +1,2 @@
// "Convert to block body" "true"
// ERROR: Unresolved reference: bar
fun <caret>foo(): String = bar()
@@ -1,4 +1,3 @@
// "Convert to block body" "true"
// ERROR: Unresolved reference: bar
fun <caret>foo(): String {
return bar()
@@ -1,4 +1,3 @@
// "Convert to block body" "true"
// ERROR: Unresolved reference: XXX
// ERROR: Unresolved reference: bar
fun <caret>foo(): XXX = bar()
@@ -1,4 +1,3 @@
// "Convert to block body" "true"
// ERROR: Unresolved reference: XXX
// ERROR: Unresolved reference: bar
fun <caret>foo(): XXX {
@@ -1,4 +1,3 @@
// "Convert to block body" "true"
fun <caret>foo(): Unit = bar()
fun bar() { }
@@ -1,4 +1,3 @@
// "Convert to block body" "true"
fun foo(): Unit {
bar()
}
@@ -1,3 +1,2 @@
// "Convert to block body" "true"
// ERROR: Unresolved reference: bar
fun <caret>foo(): Unit = bar()
@@ -1,4 +1,3 @@
// "Convert to block body" "true"
// ERROR: Unresolved reference: bar
fun <caret>foo(): Unit {
bar()
@@ -1,2 +1,3 @@
// "Convert to block body" "true"
// WITH_RUNTIME
fun <caret>foo(): String = throw UnsupportedOperationException()
@@ -1,4 +1,5 @@
// "Convert to block body" "true"
// WITH_RUNTIME
fun <caret>foo(): String {
throw UnsupportedOperationException()
}
@@ -1,3 +1,2 @@
// "Convert to block body" "true"
val foo: String
<caret>get() = "abc"
@@ -1,4 +1,3 @@
// "Convert to block body" "true"
val foo: String
get() {
return "abc"
@@ -1,3 +1,4 @@
// "Convert to block body" "true"
// WITH_RUNTIME
val foo: String
<caret>get() = throw UnsupportedOperationException()
@@ -1,4 +1,5 @@
// "Convert to block body" "true"
// WITH_RUNTIME
val foo: String
get() {
throw UnsupportedOperationException()
@@ -1,2 +1,3 @@
// "Convert to block body" "true"
// WITH_RUNTIME
fun <caret>foo() = java.io.File("x").toURI()
@@ -1,4 +1,5 @@
// "Convert to block body" "true"
// WITH_RUNTIME
import java.net.URI
fun foo(): URI {
@@ -1,3 +1,3 @@
// "Convert to block body" "false"
// IS_APPLICABLE: false
// ERROR: Unresolved reference: bar
fun <caret>foo() = bar()
@@ -1,4 +1,3 @@
// "Convert to block body" "true"
fun <caret>foo() = bar()
fun bar() { }
@@ -1,4 +1,3 @@
// "Convert to block body" "true"
fun foo() {
bar()
}
@@ -1,2 +1,3 @@
// "Convert to block body" "true"
// WITH_RUNTIME
fun <caret>foo(): Nothing = throw UnsupportedOperationException()
@@ -1,4 +1,5 @@
// "Convert to block body" "true"
// WITH_RUNTIME
fun foo(): Nothing {
throw UnsupportedOperationException()
}
@@ -1,4 +1,3 @@
// "Convert to block body" "true"
var foo: String
get() = "abc"
<caret>set(value) = doSet(value)
@@ -1,4 +1,3 @@
// "Convert to block body" "true"
var foo: String
get() = "abc"
set(value) {
@@ -0,0 +1 @@
org.jetbrains.jet.plugin.intentions.ConvertToConcatenatedStringIntention
@@ -0,0 +1 @@
org.jetbrains.jet.plugin.intentions.ConvertToExpressionBodyAction
@@ -1,2 +0,0 @@
// "Convert to expression body" "true"
fun foo(): String = "abc"
@@ -1,4 +0,0 @@
// "Convert to expression body" "true"
fun foo() = bar()
fun bar() { }
@@ -1,3 +0,0 @@
// "Convert to expression body" "true"
val foo: String
get() = "abc"
@@ -1,4 +1,3 @@
// "Convert to expression body" "true"
trait I {
fun foo(): String
}
@@ -0,0 +1,8 @@
// IS_APPLICABLE: false
var a = 1
var b = 2
fun foo() {
<caret>a = b
}
@@ -1,8 +0,0 @@
// "class org.jetbrains.jet.plugin.intentions.ConvertToExpressionBodyAction" "false"
var a = 1
var b = 2
fun foo() {
<caret>a = b
}
@@ -1,5 +0,0 @@
// "class org.jetbrains.jet.plugin.intentions.ConvertToExpressionBodyAction" "false"
fun foo() {
<caret>val v = 1
}
@@ -1,3 +0,0 @@
// "class org.jetbrains.jet.plugin.intentions.ConvertToExpressionBodyAction" "false"
fun foo() = <caret>"abc"
@@ -1,7 +0,0 @@
// "class org.jetbrains.jet.plugin.intentions.ConvertToExpressionBodyAction" "false"
fun foo() {
<caret>bar()
}
fun bar(): String = "abc"
@@ -1,6 +0,0 @@
// "class org.jetbrains.jet.plugin.intentions.ConvertToExpressionBodyAction" "false"
fun foo(): String {
val v = 1
<caret>return "abc"
}
@@ -1,5 +0,0 @@
// "class org.jetbrains.jet.plugin.intentions.ConvertToExpressionBodyAction" "false"
fun foo() {
<caret>return
}
@@ -1,5 +0,0 @@
// "class org.jetbrains.jet.plugin.intentions.ConvertToExpressionBodyAction" "false"
fun foo(p: Boolean): String {
<caret>while(true) { }
}
@@ -0,0 +1,5 @@
// IS_APPLICABLE: false
fun foo() {
<caret>val v = 1
}
@@ -1,4 +1,4 @@
// "class org.jetbrains.jet.plugin.intentions.ConvertToExpressionBodyAction" "false"
// IS_APPLICABLE: false
fun foo(p: Boolean): String {
return bar() ?: return "a"
@@ -1,4 +1,4 @@
// "class org.jetbrains.jet.plugin.intentions.ConvertToExpressionBodyAction" "false"
// IS_APPLICABLE: false
fun foo(p: Boolean): String {
if (p) {
@@ -1,4 +1,5 @@
// "Convert to expression body" "true"
// WITH_RUNTIME
fun foo() {
<caret>throw UnsupportedOperationException()
}
@@ -1,2 +1,3 @@
// "Convert to expression body" "true"
// WITH_RUNTIME
fun foo(): Unit = throw UnsupportedOperationException()
@@ -0,0 +1,3 @@
// IS_APPLICABLE: false
fun foo() = <caret>"abc"
@@ -1,4 +1,5 @@
// "Convert to expression body" "true"
// WITH_RUNTIME
fun foo(): Nothing {
<caret>throw UnsupportedOperationException()
}
@@ -1,2 +1,3 @@
// "Convert to expression body" "true"
// WITH_RUNTIME
fun foo(): Nothing = throw UnsupportedOperationException()
@@ -1,4 +1,3 @@
// "Convert to expression body" "true"
fun <caret>foo(): String {
return "abc"
}
@@ -0,0 +1 @@
fun foo(): String = "abc"
@@ -1,4 +1,3 @@
// "Convert to expression body" "true"
fun foo() {
<caret>bar()
}
@@ -0,0 +1,3 @@
fun foo() = bar()
fun bar() { }
@@ -0,0 +1,7 @@
// IS_APPLICABLE: false
fun foo() {
<caret>bar()
}
fun bar(): String = "abc"
@@ -1,4 +1,5 @@
// "Convert to expression body" "true"
// WITH_RUNTIME
fun foo(): Unit {
<caret>throw UnsupportedOperationException()
}
@@ -1,2 +1,3 @@
// "Convert to expression body" "true"
// WITH_RUNTIME
fun foo(): Unit = throw UnsupportedOperationException()
@@ -1,4 +1,4 @@
// "class org.jetbrains.jet.plugin.intentions.ConvertToExpressionBodyAction" "false"
// IS_APPLICABLE: false
fun foo(handler: () -> Unit) { }
@@ -1,4 +1,3 @@
// "Convert to expression body" "true"
val foo: String
<caret>get() {
return "abc"
@@ -0,0 +1,2 @@
val foo: String
get() = "abc"
@@ -0,0 +1,6 @@
// IS_APPLICABLE: false
fun foo(): String {
val v = 1
<caret>return "abc"
}
@@ -0,0 +1,5 @@
// IS_APPLICABLE: false
fun foo() {
<caret>return
}
@@ -0,0 +1,5 @@
// IS_APPLICABLE: false
fun foo(p: Boolean): String {
<caret>while(true) { }
}
@@ -0,0 +1 @@
org.jetbrains.jet.plugin.intentions.ConvertToForEachFunctionCallIntention
@@ -0,0 +1 @@
org.jetbrains.jet.plugin.intentions.ConvertToForEachLoopIntention
@@ -0,0 +1 @@
org.jetbrains.jet.plugin.intentions.ConvertToStringTemplateIntention

Some files were not shown because too many files have changed in this diff Show More