Partial body resolve: added more tests

This commit is contained in:
Valentin Kipyatkov
2014-11-21 12:19:23 +03:00
parent 0dd77a8ed3
commit 058af69078
13 changed files with 181 additions and 3 deletions
@@ -0,0 +1,7 @@
Resolve target: null
----------------------------------------------
fun foo(p: Any?, c: Collection<String>) {
// STATEMENT DELETED: for (e in c) { print(p!!) }
<caret>xxx
}
@@ -0,0 +1,7 @@
fun foo(p: Any?, c: Collection<String>) {
for (e in c) {
print(p!!)
}
<caret>xxx
}
@@ -0,0 +1,31 @@
Resolve target: value-parameter val p: kotlin.String? smart-cast to kotlin.String
----------------------------------------------
fun foo(p: String?, x: Boolean, y: Boolean, z: Boolean, t: Boolean) {
if (p == null) {
if (x) {
// STATEMENT DELETED: print("x")
error("error")
}
else if (y) {
// STATEMENT DELETED: print("y")
if (z) {
// STATEMENT DELETED: print("z")
return
}
else {
throw Exception()
}
}
else {
if (t) {
// STATEMENT DELETED: print("t")
return
}
else {
return
}
}
}
<caret>p.length
}
@@ -0,0 +1,29 @@
fun foo(p: String?, x: Boolean, y: Boolean, z: Boolean, t: Boolean) {
if (p == null) {
if (x) {
print("x")
error("error")
}
else if (y) {
print("y")
if (z) {
print("z")
return
}
else {
throw Exception()
}
}
else {
if (t) {
print("t")
return
}
else {
return
}
}
}
<caret>p.length
}
@@ -0,0 +1,16 @@
Resolve target: val x: kotlin.Any?
----------------------------------------------
fun foo() {
@MainLoop
for (i in 1..10) {
val x = take()
if (x == null) {
while (true) {
break@MainLoop
}
}
<caret>x.hashCode()
}
}
fun take(): Any? = null
@@ -0,0 +1,14 @@
fun foo() {
@MainLoop
for (i in 1..10) {
val x = take()
if (x == null) {
while (true) {
break@MainLoop
}
}
<caret>x.hashCode()
}
}
fun take(): Any? = null
@@ -0,0 +1,16 @@
Resolve target: val x: kotlin.Any?
----------------------------------------------
fun foo() {
@MainLoop
for (i in 1..10) {
val x = take()
if (x == null) {
while (true) {
continue@MainLoop
}
}
<caret>x.hashCode()
}
}
fun take(): Any? = null
@@ -0,0 +1,14 @@
fun foo() {
@MainLoop
for (i in 1..10) {
val x = take()
if (x == null) {
while (true) {
continue@MainLoop
}
}
<caret>x.hashCode()
}
}
fun take(): Any? = null
@@ -0,0 +1,8 @@
Resolve target: val v: kotlin.String
----------------------------------------------
val v = ""
fun foo(s: String = <caret>v) {
// STATEMENT DELETED: val local = 1
// STATEMENT DELETED: print("foo" + local)
}
@@ -0,0 +1,6 @@
val v = ""
fun foo(s: String = <caret>v) {
val local = 1
print("foo" + local)
}
@@ -72,9 +72,15 @@ public class PartialBodyResolveTestGenerated extends AbstractPartialBodyResolveT
doTest(fileName);
}
@TestMetadata("For.kt")
public void testFor() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/resolve/partialBodyResolve/For.kt");
@TestMetadata("For1.kt")
public void testFor1() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/resolve/partialBodyResolve/For1.kt");
doTest(fileName);
}
@TestMetadata("For2.kt")
public void testFor2() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/resolve/partialBodyResolve/For2.kt");
doTest(fileName);
}
@@ -156,6 +162,12 @@ public class PartialBodyResolveTestGenerated extends AbstractPartialBodyResolveT
doTest(fileName);
}
@TestMetadata("IfNullAlwaysExits.kt")
public void testIfNullAlwaysExits() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/resolve/partialBodyResolve/IfNullAlwaysExits.kt");
doTest(fileName);
}
@TestMetadata("IfNullBreak.kt")
public void testIfNullBreak() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/resolve/partialBodyResolve/IfNullBreak.kt");
@@ -234,6 +246,18 @@ public class PartialBodyResolveTestGenerated extends AbstractPartialBodyResolveT
doTest(fileName);
}
@TestMetadata("LabeledBreak.kt")
public void testLabeledBreak() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/resolve/partialBodyResolve/LabeledBreak.kt");
doTest(fileName);
}
@TestMetadata("LabeledContinue.kt")
public void testLabeledContinue() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/resolve/partialBodyResolve/LabeledContinue.kt");
doTest(fileName);
}
@TestMetadata("Lambda.kt")
public void testLambda() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/resolve/partialBodyResolve/Lambda.kt");
@@ -270,6 +294,12 @@ public class PartialBodyResolveTestGenerated extends AbstractPartialBodyResolveT
doTest(fileName);
}
@TestMetadata("OutOfBodyResolve.kt")
public void testOutOfBodyResolve() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/resolve/partialBodyResolve/OutOfBodyResolve.kt");
doTest(fileName);
}
@TestMetadata("ReturnLambda.kt")
public void testReturnLambda() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/resolve/partialBodyResolve/ReturnLambda.kt");