FIR IDE: Enable tests for ReplaceInfixOrOperatorCallFix.

This commit is contained in:
Mark Punzalan
2021-05-21 21:41:59 +00:00
committed by teamcityserver
parent afeeec3091
commit 5a7f4ffc99
36 changed files with 244 additions and 28 deletions
@@ -1155,7 +1155,9 @@ fun main(args: Array<String>) {
model("quickfix/expressions", pattern = pattern, filenameStartsLowerCase = true)
model("quickfix/lateinit", pattern = pattern, filenameStartsLowerCase = true)
model("quickfix/modifiers", pattern = pattern, filenameStartsLowerCase = true, recursive = false)
model("quickfix/nullables/unsafeInfixCall", pattern = pattern, filenameStartsLowerCase = true)
model("quickfix/override/typeMismatchOnOverride", pattern = pattern, filenameStartsLowerCase = true, recursive = false)
model("quickfix/replaceInfixOrOperatorCall", pattern = pattern, filenameStartsLowerCase = true)
model("quickfix/replaceWithDotCall", pattern = pattern, filenameStartsLowerCase = true)
model("quickfix/replaceWithSafeCall", pattern = pattern, filenameStartsLowerCase = true)
model("quickfix/variables/changeMutability", pattern = pattern, filenameStartsLowerCase = true)
@@ -1118,6 +1118,79 @@ public class HighLevelQuickFixTestGenerated extends AbstractHighLevelQuickFixTes
}
}
@TestMetadata("idea/testData/quickfix/nullables/unsafeInfixCall")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class UnsafeInfixCall extends AbstractHighLevelQuickFixTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public void testAllFilesPresentInUnsafeInfixCall() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/quickfix/nullables/unsafeInfixCall"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), null, true);
}
@TestMetadata("noComparison.kt")
public void testNoComparison() throws Exception {
runTest("idea/testData/quickfix/nullables/unsafeInfixCall/noComparison.kt");
}
@TestMetadata("unsafeComparisonInCondition.kt")
public void testUnsafeComparisonInCondition() throws Exception {
runTest("idea/testData/quickfix/nullables/unsafeInfixCall/unsafeComparisonInCondition.kt");
}
@TestMetadata("unsafeComparisonInLogic.kt")
public void testUnsafeComparisonInLogic() throws Exception {
runTest("idea/testData/quickfix/nullables/unsafeInfixCall/unsafeComparisonInLogic.kt");
}
@TestMetadata("unsafeComparisonInWhen.kt")
public void testUnsafeComparisonInWhen() throws Exception {
runTest("idea/testData/quickfix/nullables/unsafeInfixCall/unsafeComparisonInWhen.kt");
}
@TestMetadata("unsafeComparisonInWhile.kt")
public void testUnsafeComparisonInWhile() throws Exception {
runTest("idea/testData/quickfix/nullables/unsafeInfixCall/unsafeComparisonInWhile.kt");
}
@TestMetadata("unsafeGet.kt")
public void testUnsafeGet() throws Exception {
runTest("idea/testData/quickfix/nullables/unsafeInfixCall/unsafeGet.kt");
}
@TestMetadata("unsafeInfixCall.kt")
public void testUnsafeInfixCall() throws Exception {
runTest("idea/testData/quickfix/nullables/unsafeInfixCall/unsafeInfixCall.kt");
}
@TestMetadata("unsafeInvoke.kt")
public void testUnsafeInvoke() throws Exception {
runTest("idea/testData/quickfix/nullables/unsafeInfixCall/unsafeInvoke.kt");
}
@TestMetadata("unsafeInvokeWithImplicitReceiver.kt")
public void testUnsafeInvokeWithImplicitReceiver() throws Exception {
runTest("idea/testData/quickfix/nullables/unsafeInfixCall/unsafeInvokeWithImplicitReceiver.kt");
}
@TestMetadata("unsafeInvokeWithReceiver.kt")
public void testUnsafeInvokeWithReceiver() throws Exception {
runTest("idea/testData/quickfix/nullables/unsafeInfixCall/unsafeInvokeWithReceiver.kt");
}
@TestMetadata("unsafePlus.kt")
public void testUnsafePlus() throws Exception {
runTest("idea/testData/quickfix/nullables/unsafeInfixCall/unsafePlus.kt");
}
@TestMetadata("unsafeSet.kt")
public void testUnsafeSet() throws Exception {
runTest("idea/testData/quickfix/nullables/unsafeInfixCall/unsafeSet.kt");
}
}
@TestMetadata("idea/testData/quickfix/override/typeMismatchOnOverride")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -1231,6 +1304,79 @@ public class HighLevelQuickFixTestGenerated extends AbstractHighLevelQuickFixTes
}
}
@TestMetadata("idea/testData/quickfix/replaceInfixOrOperatorCall")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class ReplaceInfixOrOperatorCall extends AbstractHighLevelQuickFixTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public void testAllFilesPresentInReplaceInfixOrOperatorCall() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/quickfix/replaceInfixOrOperatorCall"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), null, true);
}
@TestMetadata("array.kt")
public void testArray() throws Exception {
runTest("idea/testData/quickfix/replaceInfixOrOperatorCall/array.kt");
}
@TestMetadata("arraySet.kt")
public void testArraySet() throws Exception {
runTest("idea/testData/quickfix/replaceInfixOrOperatorCall/arraySet.kt");
}
@TestMetadata("assignmentArray.kt")
public void testAssignmentArray() throws Exception {
runTest("idea/testData/quickfix/replaceInfixOrOperatorCall/assignmentArray.kt");
}
@TestMetadata("assignmentBinaryOperator.kt")
public void testAssignmentBinaryOperator() throws Exception {
runTest("idea/testData/quickfix/replaceInfixOrOperatorCall/assignmentBinaryOperator.kt");
}
@TestMetadata("assignmentCallExpression.kt")
public void testAssignmentCallExpression() throws Exception {
runTest("idea/testData/quickfix/replaceInfixOrOperatorCall/assignmentCallExpression.kt");
}
@TestMetadata("assignmentList.kt")
public void testAssignmentList() throws Exception {
runTest("idea/testData/quickfix/replaceInfixOrOperatorCall/assignmentList.kt");
}
@TestMetadata("augmentedAssignmentAvailable.kt")
public void testAugmentedAssignmentAvailable() throws Exception {
runTest("idea/testData/quickfix/replaceInfixOrOperatorCall/augmentedAssignmentAvailable.kt");
}
@TestMetadata("augmentedAssignmentNotAvailable.kt")
public void testAugmentedAssignmentNotAvailable() throws Exception {
runTest("idea/testData/quickfix/replaceInfixOrOperatorCall/augmentedAssignmentNotAvailable.kt");
}
@TestMetadata("binaryOperator.kt")
public void testBinaryOperator() throws Exception {
runTest("idea/testData/quickfix/replaceInfixOrOperatorCall/binaryOperator.kt");
}
@TestMetadata("callExpression.kt")
public void testCallExpression() throws Exception {
runTest("idea/testData/quickfix/replaceInfixOrOperatorCall/callExpression.kt");
}
@TestMetadata("hasElvis.kt")
public void testHasElvis() throws Exception {
runTest("idea/testData/quickfix/replaceInfixOrOperatorCall/hasElvis.kt");
}
@TestMetadata("list.kt")
public void testList() throws Exception {
runTest("idea/testData/quickfix/replaceInfixOrOperatorCall/list.kt");
}
}
@TestMetadata("idea/testData/quickfix/replaceWithDotCall")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -1,4 +1,6 @@
// "Replace with safe (?.) call" "true"
operator fun Int.get(row: Int, column: Int) = this
fun foo(arg: Int?) = arg<caret>[42, 13]
fun foo(arg: Int?) = arg<caret>[42, 13]
/* IGNORE_FIR */
@@ -1,4 +1,6 @@
// "Replace with safe (?.) call" "true"
operator fun Int.get(row: Int, column: Int) = this
fun foo(arg: Int?) = arg?.get(42, 13)
fun foo(arg: Int?) = arg?.get(42, 13)
/* IGNORE_FIR */
@@ -1,4 +1,6 @@
// "Replace with safe (?.) call" "true"
fun test(a : Int?) : Int? {
return a <caret>compareTo 6;
}
}
/* IGNORE_FIR */
@@ -1,4 +1,6 @@
// "Replace with safe (?.) call" "true"
fun test(a : Int?) : Int? {
return a?.compareTo(6);
}
}
/* IGNORE_FIR */
@@ -1,3 +1,5 @@
// "Replace with safe (?.) call" "true"
fun foo(exec: (() -> Unit)?) = exec<caret>()
fun foo(exec: (() -> Unit)?) = exec<caret>()
/* IGNORE_FIR */
@@ -1,3 +1,5 @@
// "Replace with safe (?.) call" "true"
fun foo(exec: (() -> Unit)?) = exec?.invoke()
fun foo(exec: (() -> Unit)?) = exec?.invoke()
/* IGNORE_FIR */
@@ -2,3 +2,5 @@
operator fun Int.plus(index: Int) = this
fun fox(arg: Int?) = arg <caret>+ 42
/* IGNORE_FIR */
@@ -2,3 +2,5 @@
operator fun Int.plus(index: Int) = this
fun fox(arg: Int?) = arg?.plus(42)
/* IGNORE_FIR */
@@ -3,4 +3,6 @@
operator fun Int.set(row: Int, column: Int, value: Int) {}
fun foo(arg: Int?) {
arg<caret>[42, 13] = 0
}
}
/* IGNORE_FIR */
@@ -3,4 +3,6 @@
operator fun Int.set(row: Int, column: Int, value: Int) {}
fun foo(arg: Int?) {
arg?.set(42, 13, 0)
}
}
/* IGNORE_FIR */
+3 -1
View File
@@ -3,4 +3,6 @@
fun foo(array: Array<String>?) {
array<caret>[0]
}
}
/* IGNORE_FIR */
@@ -3,4 +3,6 @@
fun foo(array: Array<String>?) {
array?.get(0)
}
}
/* IGNORE_FIR */
@@ -3,4 +3,6 @@
fun foo(array: Array<String>?) {
array<caret>[0] = ""
}
}
/* IGNORE_FIR */
@@ -3,4 +3,6 @@
fun foo(array: Array<String>?) {
array?.set(0, "")
}
}
/* IGNORE_FIR */
@@ -4,4 +4,6 @@
fun foo(array: Array<String>?) {
var s = ""
s = array[0]<caret>
}
}
/* IGNORE_FIR */
@@ -4,4 +4,6 @@
fun foo(array: Array<String>?) {
var s = ""
s = array?.get(0) ?: <caret>
}
}
/* IGNORE_FIR */
@@ -4,4 +4,6 @@
fun foo(bar: Int?) {
var i: Int = 1
i = bar +<caret> 1
}
}
/* IGNORE_FIR */
@@ -4,4 +4,6 @@
fun foo(bar: Int?) {
var i: Int = 1
i = bar?.plus(1) ?: <caret>
}
}
/* IGNORE_FIR */
@@ -5,4 +5,6 @@ fun bar() {
val fff: (() -> Int)? = { 1 }
var i: Int = 1
i = fff<caret>()
}
}
/* IGNORE_FIR */
@@ -5,4 +5,6 @@ fun bar() {
val fff: (() -> Int)? = { 1 }
var i: Int = 1
i = fff?.invoke() ?: <caret>
}
}
/* IGNORE_FIR */
@@ -4,4 +4,6 @@
fun foo(list: List<String>?) {
var s = ""
s = list[0]<caret>
}
}
/* IGNORE_FIR */
@@ -4,4 +4,6 @@
fun foo(list: List<String>?) {
var s = ""
s = list?.get(0) ?: <caret>
}
}
/* IGNORE_FIR */
@@ -7,3 +7,5 @@ fun foo(b: A) {
var a: A? = A()
a <caret>+= b
}
/* IGNORE_FIR */
@@ -7,3 +7,5 @@ fun foo(b: A) {
var a: A? = A()
a?.plusAssign(b)
}
/* IGNORE_FIR */
@@ -7,3 +7,5 @@ fun foo(b: A) {
var a: A? = A()
a <caret>+= b
}
/* IGNORE_FIR */
@@ -7,3 +7,5 @@ fun foo(b: A) {
var a: A? = A()
a = a?.plus(b)
}
/* IGNORE_FIR */
@@ -3,4 +3,6 @@
fun foo(bar: Int?) {
bar +<caret> 1
}
}
/* IGNORE_FIR */
@@ -3,4 +3,6 @@
fun foo(bar: Int?) {
bar?.plus(1)
}
}
/* IGNORE_FIR */
@@ -6,4 +6,6 @@ fun foo() {}
fun bar() {
val fff: (() -> Unit)? = ::foo
<caret>fff()
}
}
/* IGNORE_FIR */
@@ -6,4 +6,6 @@ fun foo() {}
fun bar() {
val fff: (() -> Unit)? = ::foo
fff?.invoke()
}
}
/* IGNORE_FIR */
@@ -4,4 +4,6 @@
fun foo(list: List<String>?) {
var s = ""
s = list[0]<caret> ?: ""
}
}
/* IGNORE_FIR */
@@ -4,4 +4,6 @@
fun foo(list: List<String>?) {
var s = ""
s = list?.get(0) ?: ""
}
}
/* IGNORE_FIR */
+3 -1
View File
@@ -3,4 +3,6 @@
fun foo(list: List<String>?) {
list<caret>[0]
}
}
/* IGNORE_FIR */
@@ -3,4 +3,6 @@
fun foo(list: List<String>?) {
list?.get(0)
}
}
/* IGNORE_FIR */