From 12237c3cbaa633d21c1c4ebb024b9e7c5509333d Mon Sep 17 00:00:00 2001 From: Kirill Rakhman Date: Sat, 5 Mar 2016 00:49:26 +0100 Subject: [PATCH] test lambda parameter smart enter processor --- .../codeInsight/smartEnter/SmartEnterTest.kt | 122 ++++++++++++++++++ 1 file changed, 122 insertions(+) diff --git a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/smartEnter/SmartEnterTest.kt b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/smartEnter/SmartEnterTest.kt index 761f5193d04..9ed91ef1c09 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/smartEnter/SmartEnterTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/smartEnter/SmartEnterTest.kt @@ -1085,6 +1085,7 @@ class SmartEnterTest : KotlinLightCodeInsightFixtureTestCase() { } """ ) + fun testSetter6() = doFileTest( """ var a : Int = 0 @@ -1263,6 +1264,7 @@ class SmartEnterTest : KotlinLightCodeInsightFixtureTestCase() { } """ ) + fun testFinallyBody() = doFunTest( """ try { @@ -1279,6 +1281,126 @@ class SmartEnterTest : KotlinLightCodeInsightFixtureTestCase() { """ ) + fun testLambdaParamImplicit1() = doFileTest( + """ + fun foo(a: Any, block: () -> Unit) { + } + fun test() { + foo(Any()) + } + """ + , + """ + fun foo(a: Any, block: () -> Unit) { + } + fun test() { + foo(Any()) { + + } + } + """ + ) + + fun testLambdaParamImplicit2() = doFileTest( + """ + fun foo(a: Any, block: (Any) -> Unit) { + } + fun test() { + foo(Any() + } + """ + , + """ + fun foo(a: Any, block: (Any) -> Unit) { + } + fun test() { + foo(Any()) { + + } + } + """ + ) + + fun testLambdaParamExplicit1() = doFileTest( + """ + fun foo(a: Any, block: (Any, Any) -> Unit) { + } + fun test() { + foo(Any()) + } + """ + , + """ + fun foo(a: Any, block: (Any, Any) -> Unit) { + } + fun test() { + foo(Any()) { x1, x2 -> + + } + } + """ + ) + + fun testExtensionLambdaParamImplicit1() = doFileTest( + """ + fun foo(a: Any, block: Any.() -> Unit) { + } + fun test() { + foo(Any()) + } + """ + , + """ + fun foo(a: Any, block: Any.() -> Unit) { + } + fun test() { + foo(Any()) { + + } + } + """ + ) + + fun testExtensionLambdaParamImplicit2() = doFileTest( + """ + fun foo(a: Any, block: Any.(Any) -> Unit) { + } + fun test() { + foo(Any() + } + """ + , + """ + fun foo(a: Any, block: Any.(Any) -> Unit) { + } + fun test() { + foo(Any()) { + + } + } + """ + ) + + fun testExtensionLambdaParamExplicit1() = doFileTest( + """ + fun foo(a: Any, block: Any.(Any, Any) -> Unit) { + } + fun test() { + foo(Any()) + } + """ + , + """ + fun foo(a: Any, block: Any.(Any, Any) -> Unit) { + } + fun test() { + foo(Any()) { x1, x2 -> + + } + } + """ + ) + fun doFunTest(before: String, after: String) { fun String.withFunContext(): String { val bodyText = "//----\n${this.trimIndent()}\n//----"