Tests for private members and accessors for them
This commit is contained in:
committed by
Max Kammerer
parent
8641dbf42a
commit
3b02498ca8
@@ -0,0 +1,5 @@
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
return call()
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package test
|
||||
|
||||
fun call() = inlineFun2 { stub()}
|
||||
|
||||
internal inline fun inlineFun2(p: () -> Unit): String {
|
||||
p()
|
||||
|
||||
return inlineFun {
|
||||
test()
|
||||
}
|
||||
}
|
||||
|
||||
private fun stub() = "fail"
|
||||
|
||||
private fun test() = "OK"
|
||||
|
||||
inline internal fun inlineFun(p: () -> String): String {
|
||||
return p()
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
return A().call()
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package test
|
||||
|
||||
class A {
|
||||
fun call() = inlineFun2 { stub() }
|
||||
|
||||
internal inline fun inlineFun2(p: () -> Unit): String {
|
||||
p()
|
||||
|
||||
return inlineFun {
|
||||
test()
|
||||
}
|
||||
}
|
||||
|
||||
private fun stub() = "fail"
|
||||
|
||||
private fun test() = "OK"
|
||||
|
||||
|
||||
inline internal fun inlineFun(p: () -> String): String {
|
||||
return p()
|
||||
}
|
||||
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
return A().call();
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
@file:kotlin.jvm.JvmMultifileClass
|
||||
@file:kotlin.jvm.JvmName("TestKt")
|
||||
package test
|
||||
|
||||
private val prop = "O"
|
||||
|
||||
private fun test() = "K"
|
||||
|
||||
inline internal fun inlineFun(): String {
|
||||
return prop + test()
|
||||
}
|
||||
|
||||
class A () {
|
||||
fun call() = inlineFun()
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
import test.*
|
||||
fun box(): String {
|
||||
return A().call();
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package test
|
||||
|
||||
private val prop = "O"
|
||||
|
||||
private fun test() = "K"
|
||||
|
||||
inline internal fun inlineFun(): String {
|
||||
return prop + test()
|
||||
}
|
||||
|
||||
class A () {
|
||||
fun call() = inlineFun()
|
||||
}
|
||||
|
||||
Vendored
+20
@@ -0,0 +1,20 @@
|
||||
@file:kotlin.jvm.JvmMultifileClass
|
||||
@file:kotlin.jvm.JvmName("TestKt")
|
||||
package test
|
||||
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
private var prop = "O"
|
||||
|
||||
private fun test() = "K"
|
||||
|
||||
fun box(): String {
|
||||
|
||||
val clazz = Class.forName("test.TestKt")
|
||||
assertEquals(1, clazz.declaredMethods.size(), "Facade should have only box and getProp methods")
|
||||
assertEquals("box", clazz.declaredMethods.first().name, "Facade should have only box method")
|
||||
|
||||
return {
|
||||
prop + test()
|
||||
}()
|
||||
}
|
||||
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
@file:kotlin.jvm.JvmMultifileClass
|
||||
@file:kotlin.jvm.JvmName("TestKt")
|
||||
package test
|
||||
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
public var prop = "fail"
|
||||
private set
|
||||
|
||||
private fun test() = "K"
|
||||
|
||||
fun box(): String {
|
||||
|
||||
val clazz = Class.forName("test.TestKt")
|
||||
assertEquals(2, clazz.declaredMethods.size(), "Facade should have only box method")
|
||||
val methods = clazz.declaredMethods.map { it.name }
|
||||
assertTrue(methods.contains("box"), "Facade should have box method")
|
||||
assertTrue(methods.contains("getProp"), "Facade should have box method")
|
||||
|
||||
return {
|
||||
prop = "O"
|
||||
prop + test()
|
||||
}()
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package test
|
||||
|
||||
private val prop = "O"
|
||||
|
||||
private fun test() = "K"
|
||||
|
||||
inline internal fun call(p: () -> String): String = p()
|
||||
|
||||
inline internal fun inlineFun(): String {
|
||||
return call {
|
||||
object {
|
||||
fun run() = prop + test()
|
||||
}.run()
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return inlineFun();
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package test
|
||||
|
||||
private val prop = "O"
|
||||
|
||||
private fun test() = "K"
|
||||
|
||||
fun box(): String {
|
||||
return {
|
||||
prop + test()
|
||||
}()
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
@file:kotlin.jvm.JvmMultifileClass
|
||||
@file:kotlin.jvm.JvmName("TestKt")
|
||||
package test
|
||||
|
||||
private val prop = "O"
|
||||
|
||||
private fun test() = "K"
|
||||
|
||||
fun box(): String {
|
||||
return {
|
||||
prop + test()
|
||||
}()
|
||||
}
|
||||
+33
@@ -983,6 +983,39 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/boxInline/private")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Private extends AbstractBlackBoxInlineCodegenTest {
|
||||
@TestMetadata("accessorStability.1.kt")
|
||||
public void testAccessorStability() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/private/accessorStability.1.kt");
|
||||
doTestMultiFileWithInlineCheck(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("accessorStabilityInClass.1.kt")
|
||||
public void testAccessorStabilityInClass() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/private/accessorStabilityInClass.1.kt");
|
||||
doTestMultiFileWithInlineCheck(fileName);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInPrivate() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxInline/private"), Pattern.compile("^(.+)\\.1.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("privateInInlineInMultiFileFacade.1.kt")
|
||||
public void testPrivateInInlineInMultiFileFacade() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/private/privateInInlineInMultiFileFacade.1.kt");
|
||||
doTestMultiFileWithInlineCheck(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("privateInline.1.kt")
|
||||
public void testPrivateInline() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/private/privateInline.1.kt");
|
||||
doTestMultiFileWithInlineCheck(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/boxInline/reified")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
+39
@@ -4664,6 +4664,45 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/boxWithStdlib/topLevelPrivate")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class TopLevelPrivate extends AbstractBlackBoxCodegenTest {
|
||||
public void testAllFilesPresentInTopLevelPrivate() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxWithStdlib/topLevelPrivate"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("noPrivateNoAccessorsInMultiFileFacade.kt")
|
||||
public void testNoPrivateNoAccessorsInMultiFileFacade() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/topLevelPrivate/noPrivateNoAccessorsInMultiFileFacade.kt");
|
||||
doTestWithStdlib(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("noPrivateNoAccessorsInMultiFileFacade2.kt")
|
||||
public void testNoPrivateNoAccessorsInMultiFileFacade2() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/topLevelPrivate/noPrivateNoAccessorsInMultiFileFacade2.kt");
|
||||
doTestWithStdlib(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("privateInInlineNested.kt")
|
||||
public void testPrivateInInlineNested() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/topLevelPrivate/privateInInlineNested.kt");
|
||||
doTestWithStdlib(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("syntheticAccessor.kt")
|
||||
public void testSyntheticAccessor() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/topLevelPrivate/syntheticAccessor.kt");
|
||||
doTestWithStdlib(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("syntheticAccessorInMultiFile.kt")
|
||||
public void testSyntheticAccessorInMultiFile() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/topLevelPrivate/syntheticAccessorInMultiFile.kt");
|
||||
doTestWithStdlib(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/boxWithStdlib/typeMapping")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
+33
@@ -983,6 +983,39 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/boxInline/private")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Private extends AbstractCompileKotlinAgainstInlineKotlinTest {
|
||||
@TestMetadata("accessorStability.1.kt")
|
||||
public void testAccessorStability() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/private/accessorStability.1.kt");
|
||||
doBoxTestWithInlineCheck(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("accessorStabilityInClass.1.kt")
|
||||
public void testAccessorStabilityInClass() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/private/accessorStabilityInClass.1.kt");
|
||||
doBoxTestWithInlineCheck(fileName);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInPrivate() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxInline/private"), Pattern.compile("^(.+)\\.1.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("privateInInlineInMultiFileFacade.1.kt")
|
||||
public void testPrivateInInlineInMultiFileFacade() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/private/privateInInlineInMultiFileFacade.1.kt");
|
||||
doBoxTestWithInlineCheck(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("privateInline.1.kt")
|
||||
public void testPrivateInline() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/private/privateInline.1.kt");
|
||||
doBoxTestWithInlineCheck(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/boxInline/reified")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
Reference in New Issue
Block a user