Added tests on resolved calls

for annotation entry, delegator to super call, array access
This commit is contained in:
Svetlana Isakova
2014-07-10 17:53:13 +04:00
parent 22624186f6
commit eca2c7beea
8 changed files with 81 additions and 1 deletions
@@ -49,6 +49,8 @@ import org.jetbrains.kotlin.util.sure
import org.jetbrains.jet.lang.psi.JetCallElement
import org.jetbrains.jet.lang.psi.psiUtil.getTextWithLocation
import org.jetbrains.jet.lang.psi.JetInstanceExpressionWithLabel
import org.jetbrains.jet.lang.psi.JetConstructorCalleeExpression
import org.jetbrains.jet.lang.psi.JetUserType
/**
* For expressions like <code>a(), a[i], a.b.c(), +a, a + b, (a()), a(): Int, @label a()</code>
@@ -64,6 +66,7 @@ public fun JetElement.getCall(context: BindingContext): Call? {
val parent = element.getParent()
val reference = when {
parent is JetInstanceExpressionWithLabel -> parent : JetInstanceExpressionWithLabel
parent is JetUserType -> parent.getParent()?.getParent() as? JetConstructorCalleeExpression
else -> element.getCalleeExpressionIfAny()
}
if (reference != null) {
@@ -0,0 +1,3 @@
annotation class MyA(val i: Int)
<caret>MyA(1) fun foo() {}
@@ -0,0 +1,16 @@
annotation class MyA(val i: Int)
<caret>MyA(1) fun foo() {}
Resolved call:
Resulting descriptor: constructor MyA(i: Int)
Explicit receiver kind = NO_EXPLICIT_RECEIVER
This object = NO_RECEIVER
Receiver argument = NO_RECEIVER
Value arguments mapping:
SUCCESS i : Int = 1
@@ -0,0 +1,3 @@
open class A {}
class B: <caret>A() {}
@@ -0,0 +1,12 @@
open class A {}
class B: <caret>A() {}
Resolved call:
Resulting descriptor: constructor A()
Explicit receiver kind = NO_EXPLICIT_RECEIVER
This object = NO_RECEIVER
Receiver argument = NO_RECEIVER
@@ -0,0 +1,3 @@
fun foo(array: Array<Int>) {
array<caret>[1]
}
@@ -0,0 +1,16 @@
fun foo(array: Array<Int>) {
array<caret>[1]
}
Resolved call:
Resulting descriptor: fun get(index: Int): Int
Explicit receiver kind = THIS_OBJECT
This object = array {Array<Int>}
Receiver argument = NO_RECEIVER
Value arguments mapping:
SUCCESS index : Int = 1
@@ -31,7 +31,7 @@ import org.jetbrains.jet.resolve.calls.AbstractResolvedCallsTest;
/** This class is generated by {@link org.jetbrains.jet.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@TestMetadata("compiler/testData/resolvedCalls")
@InnerTestClasses({ResolvedCallsTestGenerated.Arguments.class, ResolvedCallsTestGenerated.FunctionTypes.class, ResolvedCallsTestGenerated.Invoke.class, ResolvedCallsTestGenerated.RealExamples.class, ResolvedCallsTestGenerated.ThisOrSuper.class})
@InnerTestClasses({ResolvedCallsTestGenerated.Arguments.class, ResolvedCallsTestGenerated.DifferentCallElements.class, ResolvedCallsTestGenerated.FunctionTypes.class, ResolvedCallsTestGenerated.Invoke.class, ResolvedCallsTestGenerated.RealExamples.class, ResolvedCallsTestGenerated.ThisOrSuper.class})
public class ResolvedCallsTestGenerated extends AbstractResolvedCallsTest {
public void testAllFilesPresentInResolvedCalls() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/resolvedCalls"), Pattern.compile("^(.+)\\.kt$"), true);
@@ -240,6 +240,29 @@ public class ResolvedCallsTestGenerated extends AbstractResolvedCallsTest {
}
}
@TestMetadata("compiler/testData/resolvedCalls/differentCallElements")
public static class DifferentCallElements extends AbstractResolvedCallsTest {
public void testAllFilesPresentInDifferentCallElements() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/resolvedCalls/differentCallElements"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("annotationCall.kt")
public void testAnnotationCall() throws Exception {
doTest("compiler/testData/resolvedCalls/differentCallElements/annotationCall.kt");
}
@TestMetadata("delegatorToSuperCall.kt")
public void testDelegatorToSuperCall() throws Exception {
doTest("compiler/testData/resolvedCalls/differentCallElements/delegatorToSuperCall.kt");
}
@TestMetadata("simpleArrayAccess.kt")
public void testSimpleArrayAccess() throws Exception {
doTest("compiler/testData/resolvedCalls/differentCallElements/simpleArrayAccess.kt");
}
}
@TestMetadata("compiler/testData/resolvedCalls/functionTypes")
public static class FunctionTypes extends AbstractResolvedCallsTest {
public void testAllFilesPresentInFunctionTypes() throws Exception {
@@ -356,6 +379,7 @@ public class ResolvedCallsTestGenerated extends AbstractResolvedCallsTest {
TestSuite suite = new TestSuite("ResolvedCallsTestGenerated");
suite.addTestSuite(ResolvedCallsTestGenerated.class);
suite.addTest(Arguments.innerSuite());
suite.addTestSuite(DifferentCallElements.class);
suite.addTestSuite(FunctionTypes.class);
suite.addTestSuite(Invoke.class);
suite.addTestSuite(RealExamples.class);