Some inline tests that do not work

This commit is contained in:
Mikhail Glukhikh
2017-03-16 16:30:21 +03:00
parent 1d5b8ea029
commit 127b7c80df
10 changed files with 106 additions and 2 deletions
@@ -0,0 +1,12 @@
fun bar(s: String) {}
fun foo() {
val t = "Test"
fun local() {
bar(t)
}
// TODO: should be available
<caret>local()
}
@@ -0,0 +1,10 @@
fun bar(s: String) {}
fun foo() {
fun local() {
bar("Test")
}
// TODO: should be available
<caret>local()
}
@@ -9,7 +9,6 @@ fun g(p: String?) {
p?.let {
println(3)
nonUnit(4)
Unit
}
}
@@ -21,5 +20,5 @@ fun h() {
fun x() = doIt {
println(7)
nonUnit(8)
Unit
// Unit should be here
}
@@ -0,0 +1,7 @@
fun <caret>sqr(x: Double) = x * x
class Point(val x: Double, val y: Double) {
// After sqr inlining, only first usage of sqr is replaced
fun distance(other: Point) = Math.sqrt(sqr(x - other.x) + sqr(y - other.y))
}
@@ -0,0 +1,8 @@
class Point(val x: Double, val y: Double) {
// After sqr inlining, only first usage of sqr is replaced
fun distance(other: Point): Double {
val x = x - other.x
// See KT-17022
return Math.sqrt(x * x + sqr(y - other.y))
}
}
@@ -0,0 +1,12 @@
class My {
fun run() {
// TODO: should be available
val foo = <caret>doThing()
System.out.println(foo)
}
private fun doThing(): Int {
val foo = 1 + 2
return foo
}
}
@@ -0,0 +1,11 @@
class My {
fun run() {
val foo = <caret>doThing()
System.out.println(foo)
}
fun doThing(): Int {
val foo = 1 + 2
return foo
}
}
@@ -0,0 +1,9 @@
class My {
fun run() {
// foo1 should be here
val foo = 1 + 2
val foo = foo
System.out.println(foo)
}
}
@@ -50,6 +50,18 @@ public class InlineTestGenerated extends AbstractInlineTest {
doTest(fileName);
}
@TestMetadata("LocalCapturing.kt")
public void testLocalCapturing() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/inline/function/LocalCapturing.kt");
doTest(fileName);
}
@TestMetadata("LocalSimple.kt")
public void testLocalSimple() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/inline/function/LocalSimple.kt");
doTest(fileName);
}
@TestMetadata("MultipleReturns.kt")
public void testMultipleReturns() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/inline/function/MultipleReturns.kt");
@@ -68,6 +80,12 @@ public class InlineTestGenerated extends AbstractInlineTest {
doTest(fileName);
}
@TestMetadata("UnitReturnType2.kt")
public void testUnitReturnType2() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/inline/function/UnitReturnType2.kt");
doTest(fileName);
}
@TestMetadata("idea/testData/refactoring/inline/function/expressionBody")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -112,6 +130,12 @@ public class InlineTestGenerated extends AbstractInlineTest {
doTest(fileName);
}
@TestMetadata("MultipleInExpression.kt")
public void testMultipleInExpression() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/inline/function/expressionBody/MultipleInExpression.kt");
doTest(fileName);
}
@TestMetadata("SafeCall.kt")
public void testSafeCall() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/inline/function/expressionBody/SafeCall.kt");
@@ -163,6 +187,18 @@ public class InlineTestGenerated extends AbstractInlineTest {
doTest(fileName);
}
@TestMetadata("PrivateMember.kt")
public void testPrivateMember() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/inline/function/returnAtEnd/PrivateMember.kt");
doTest(fileName);
}
@TestMetadata("PublicMember.kt")
public void testPublicMember() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/inline/function/returnAtEnd/PublicMember.kt");
doTest(fileName);
}
@TestMetadata("ReturnFromLambda.kt")
public void testReturnFromLambda() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/inline/function/returnAtEnd/ReturnFromLambda.kt");