mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-04-04 15:51:54 +00:00
New test for jvm8 nondefaults target
This commit is contained in:
21
compiler/testData/codegen/java8/box/jvm8/bridgeInClass.kt
vendored
Normal file
21
compiler/testData/codegen/java8/box/jvm8/bridgeInClass.kt
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
// JVM_TARGET: 1.8
|
||||
|
||||
interface Test<T> {
|
||||
fun test(p: T): T {
|
||||
return p
|
||||
}
|
||||
}
|
||||
|
||||
class TestClass : Test<String> {
|
||||
override fun test(p: String): String {
|
||||
return p + "K"
|
||||
}
|
||||
}
|
||||
|
||||
fun <T> execute(t: Test<T>, p: T): T {
|
||||
return t.test(p)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return execute(TestClass(), "O")
|
||||
}
|
||||
24
compiler/testData/codegen/java8/box/jvm8/bridgeInInterface.kt
vendored
Normal file
24
compiler/testData/codegen/java8/box/jvm8/bridgeInInterface.kt
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
// JVM_TARGET: 1.8
|
||||
|
||||
interface Test<T> {
|
||||
fun test(p: T): T {
|
||||
return p
|
||||
}
|
||||
}
|
||||
|
||||
interface Test2: Test<String> {
|
||||
override fun test(p: String): String {
|
||||
return p + "K"
|
||||
}
|
||||
}
|
||||
|
||||
class TestClass : Test2 {
|
||||
}
|
||||
|
||||
fun <T> execute(t: Test<T>, p: T): T {
|
||||
return t.test(p)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return execute(TestClass(), "O")
|
||||
}
|
||||
13
compiler/testData/codegen/java8/box/jvm8/defaultArgs.kt
vendored
Normal file
13
compiler/testData/codegen/java8/box/jvm8/defaultArgs.kt
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
// JVM_TARGET: 1.8
|
||||
|
||||
interface Z {
|
||||
fun test(s: String = "OK"): String {
|
||||
return s
|
||||
}
|
||||
}
|
||||
|
||||
class Test: Z
|
||||
|
||||
fun box(): String {
|
||||
return Test().test()
|
||||
}
|
||||
54
compiler/testData/codegen/java8/box/jvm8/kt11969.kt
vendored
Normal file
54
compiler/testData/codegen/java8/box/jvm8/kt11969.kt
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_RUNTIME
|
||||
// IGNORE_BACKEND: JS
|
||||
|
||||
interface Z {
|
||||
private fun privateFun() = { "OK" }
|
||||
|
||||
fun callPrivateFun() = privateFun()
|
||||
|
||||
fun publicFun() = { "OK" }
|
||||
|
||||
fun funWithDefaultArgs(s: () -> Unit = {}): () -> Unit
|
||||
|
||||
val property: () -> Unit
|
||||
get() = {}
|
||||
|
||||
class Nested
|
||||
}
|
||||
|
||||
class Test : Z {
|
||||
override fun funWithDefaultArgs(s: () -> Unit): () -> Unit {
|
||||
return s
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
|
||||
val privateFun = Test().callPrivateFun()
|
||||
var enclosing = privateFun.javaClass.enclosingMethod!!
|
||||
if (enclosing.name != "privateFun") return "fail 1: ${enclosing.name}"
|
||||
if (enclosing.getDeclaringClass().simpleName != "DefaultImpls") return "fail 2: ${enclosing.getDeclaringClass().simpleName}"
|
||||
|
||||
val publicFun = Test().publicFun()
|
||||
enclosing = publicFun.javaClass.enclosingMethod!!
|
||||
if (enclosing.name != "publicFun") return "fail 3: ${enclosing.name}"
|
||||
if (enclosing.getDeclaringClass().simpleName != "DefaultImpls") return "fail 4: ${enclosing.getDeclaringClass().simpleName}"
|
||||
|
||||
val property = Test().property
|
||||
enclosing = property.javaClass.enclosingMethod!!
|
||||
if (enclosing.name != "getProperty") return "fail 4: ${enclosing.name}"
|
||||
if (enclosing.getDeclaringClass().simpleName != "DefaultImpls") return "fail 5: ${enclosing.getDeclaringClass().simpleName}"
|
||||
|
||||
val defaultArgs = Test().funWithDefaultArgs()
|
||||
enclosing = defaultArgs.javaClass.enclosingMethod!!
|
||||
if (enclosing.name != "funWithDefaultArgs\$default") return "fail 6: ${enclosing.name}"
|
||||
if (enclosing.parameterTypes.size != 4) return "fail 7: not default method ${enclosing.name}"
|
||||
if (enclosing.getDeclaringClass().simpleName != "DefaultImpls") return "fail 8: ${enclosing.getDeclaringClass().simpleName}"
|
||||
|
||||
val nested = Z.Nested::class.java
|
||||
val enclosingClass = nested.enclosingClass!!
|
||||
if (enclosingClass.name != "Z") return "fail 9: ${enclosingClass.name}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
20
compiler/testData/codegen/java8/box/jvm8/kt14243.kt
vendored
Normal file
20
compiler/testData/codegen/java8/box/jvm8/kt14243.kt
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
// JVM_TARGET: 1.8
|
||||
|
||||
interface Z<T> {
|
||||
fun test(p: T): T {
|
||||
return p
|
||||
}
|
||||
}
|
||||
|
||||
open class ZImpl : Z<String>
|
||||
|
||||
class ZImpl2 : ZImpl() {
|
||||
|
||||
override fun test(p: String): String {
|
||||
return super.test(p)
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return ZImpl2().test("OK")
|
||||
}
|
||||
22
compiler/testData/codegen/java8/box/jvm8/kt14243_2.kt
vendored
Normal file
22
compiler/testData/codegen/java8/box/jvm8/kt14243_2.kt
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
// JVM_TARGET: 1.8
|
||||
|
||||
interface Z<T> {
|
||||
fun test(p: T): T {
|
||||
return p
|
||||
}
|
||||
}
|
||||
|
||||
open class ZImpl : Z<String>
|
||||
|
||||
open class ZImpl2 : Z<String>, ZImpl()
|
||||
|
||||
class ZImpl3 : ZImpl2() {
|
||||
|
||||
override fun test(p: String): String {
|
||||
return super.test(p)
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return ZImpl3().test("OK")
|
||||
}
|
||||
23
compiler/testData/codegen/java8/box/jvm8/kt14243_prop.kt
vendored
Normal file
23
compiler/testData/codegen/java8/box/jvm8/kt14243_prop.kt
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
// JVM_TARGET: 1.8
|
||||
|
||||
interface Z<T> {
|
||||
val value: T
|
||||
|
||||
val z: T
|
||||
get() = value
|
||||
}
|
||||
|
||||
open class ZImpl : Z<String> {
|
||||
override val value: String
|
||||
get() = "OK"
|
||||
}
|
||||
|
||||
open class ZImpl2 : ZImpl() {
|
||||
override val z: String
|
||||
get() = super.z
|
||||
}
|
||||
|
||||
|
||||
fun box(): String {
|
||||
return ZImpl2().value
|
||||
}
|
||||
20
compiler/testData/codegen/java8/box/jvm8/oneImplementation.kt
vendored
Normal file
20
compiler/testData/codegen/java8/box/jvm8/oneImplementation.kt
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
// JVM_TARGET: 1.8
|
||||
// KOTLIN_CONFIGURATION_FLAGS: +JVM.JVM8_TARGET_WITH_DEFAULTS
|
||||
interface KCallable {
|
||||
val returnType: String
|
||||
}
|
||||
|
||||
interface KCallableImpl : KCallable {
|
||||
override val returnType: String
|
||||
get() = "OK"
|
||||
}
|
||||
|
||||
interface KCallableImpl2 : KCallableImpl
|
||||
|
||||
open class DescriptorBasedProperty : KCallableImpl
|
||||
open class KProperty1Impl : DescriptorBasedProperty(), KCallableImpl2
|
||||
open class KMutableProperty1Impl : KProperty1Impl(), KCallable
|
||||
|
||||
fun box(): String {
|
||||
return KMutableProperty1Impl().returnType
|
||||
}
|
||||
24
compiler/testData/codegen/java8/box/jvm8/oneImplementation2.kt
vendored
Normal file
24
compiler/testData/codegen/java8/box/jvm8/oneImplementation2.kt
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
// JVM_TARGET: 1.8
|
||||
interface KCallable {
|
||||
val returnType: String
|
||||
}
|
||||
|
||||
interface KCallableImpl : KCallable {
|
||||
override val returnType: String
|
||||
get() = "OK"
|
||||
}
|
||||
|
||||
interface KProperty : KCallable
|
||||
interface KPropertyImpl : KProperty, KCallableImpl
|
||||
interface KMutableProperty : KProperty
|
||||
interface KProperty1 : KProperty
|
||||
interface KMutableProperty1 : KProperty1, KMutableProperty
|
||||
interface KMutablePropertyImpl : KPropertyImpl
|
||||
|
||||
open class DescriptorBasedProperty : KCallableImpl
|
||||
open class KProperty1Impl : DescriptorBasedProperty(), KProperty1, KPropertyImpl
|
||||
open class KMutableProperty1Impl : KProperty1Impl(), KMutableProperty1, KMutablePropertyImpl
|
||||
|
||||
fun box(): String {
|
||||
return KMutableProperty1Impl().returnType
|
||||
}
|
||||
15
compiler/testData/codegen/java8/box/jvm8/simpleCall.kt
vendored
Normal file
15
compiler/testData/codegen/java8/box/jvm8/simpleCall.kt
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
// JVM_TARGET: 1.8
|
||||
|
||||
interface Test {
|
||||
fun test(): String {
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
class TestClass : Test {
|
||||
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return TestClass().test()
|
||||
}
|
||||
13
compiler/testData/codegen/java8/box/jvm8/simpleProperty.kt
vendored
Normal file
13
compiler/testData/codegen/java8/box/jvm8/simpleProperty.kt
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
// JVM_TARGET: 1.8
|
||||
|
||||
interface Z {
|
||||
val z: String;
|
||||
get() = "OK"
|
||||
}
|
||||
|
||||
|
||||
class Test : Z
|
||||
|
||||
fun box() : String {
|
||||
return Test().z
|
||||
}
|
||||
@@ -179,6 +179,72 @@ public class BlackBoxWithJava8CodegenTestGenerated extends AbstractBlackBoxCodeg
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/java8/box/jvm8"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("bridgeInClass.kt")
|
||||
public void testBridgeInClass() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/java8/box/jvm8/bridgeInClass.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("bridgeInInterface.kt")
|
||||
public void testBridgeInInterface() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/java8/box/jvm8/bridgeInInterface.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("defaultArgs.kt")
|
||||
public void testDefaultArgs() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/java8/box/jvm8/defaultArgs.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt11969.kt")
|
||||
public void testKt11969() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/java8/box/jvm8/kt11969.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt14243.kt")
|
||||
public void testKt14243() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/java8/box/jvm8/kt14243.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt14243_2.kt")
|
||||
public void testKt14243_2() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/java8/box/jvm8/kt14243_2.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt14243_prop.kt")
|
||||
public void testKt14243_prop() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/java8/box/jvm8/kt14243_prop.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("oneImplementation.kt")
|
||||
public void testOneImplementation() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/java8/box/jvm8/oneImplementation.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("oneImplementation2.kt")
|
||||
public void testOneImplementation2() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/java8/box/jvm8/oneImplementation2.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("simpleCall.kt")
|
||||
public void testSimpleCall() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/java8/box/jvm8/simpleCall.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("simpleProperty.kt")
|
||||
public void testSimpleProperty() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/java8/box/jvm8/simpleProperty.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/java8/box/jvm8/defaults")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
Reference in New Issue
Block a user