Merge boxMultiFile testData into box, delete BoxMultiFile test
This commit is contained in:
committed by
Alexander Udalov
parent
e115f80d6c
commit
16a0ddd2fb
@@ -0,0 +1,7 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
fun box() = ok()
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
fun ok(res: String = "OK") = res
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
// WITH_RUNTIME
|
||||
// FILE: box.kt
|
||||
|
||||
package test
|
||||
|
||||
import b.bar
|
||||
|
||||
fun box(): String = bar()
|
||||
|
||||
// FILE: caller.kt
|
||||
|
||||
package b
|
||||
|
||||
import a.foo
|
||||
|
||||
fun bar(): String = foo()
|
||||
|
||||
// FILE: multifileClass.kt
|
||||
|
||||
@file:[JvmName("MultifileClass") JvmMultifileClass]
|
||||
package a
|
||||
|
||||
fun foo(): String = "OK"
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
// WITH_RUNTIME
|
||||
// FILE: 1.kt
|
||||
|
||||
import a.*
|
||||
|
||||
fun box(): String {
|
||||
if (foo() != "OK") return "Fail function"
|
||||
if (constOK != "OK") return "Fail const"
|
||||
if (valOK != "OK") return "Fail val"
|
||||
varOK = "OK"
|
||||
if (varOK != "OK") return "Fail var"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
@file:[JvmName("MultifileClass") JvmMultifileClass]
|
||||
package a
|
||||
|
||||
fun foo(): String = "OK"
|
||||
const val constOK: String = "OK"
|
||||
val valOK: String = "OK"
|
||||
var varOK: String = "Hmmm?"
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
// WITH_RUNTIME
|
||||
// FILE: 1.kt
|
||||
|
||||
import a.OK
|
||||
|
||||
fun box(): String {
|
||||
val okRef = ::OK
|
||||
|
||||
// TODO: see KT-10892
|
||||
// val annotations = okRef.annotations
|
||||
// val numAnnotations = annotations.size
|
||||
// if (numAnnotations != 1) {
|
||||
// return "Failed, annotations: $annotations"
|
||||
// }
|
||||
|
||||
return okRef.get()
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
@file:[JvmName("MultifileClass") JvmMultifileClass]
|
||||
package a
|
||||
|
||||
annotation class A
|
||||
|
||||
@A
|
||||
const val OK: String = "OK"
|
||||
Vendored
+22
@@ -0,0 +1,22 @@
|
||||
// WITH_RUNTIME
|
||||
// FILE: box.kt
|
||||
|
||||
package test
|
||||
|
||||
import a.foo
|
||||
|
||||
fun box(): String = foo { "OK" }
|
||||
|
||||
// FILE: foo.kt
|
||||
|
||||
@file:[JvmName("A") JvmMultifileClass]
|
||||
package a
|
||||
|
||||
inline fun foo(body: () -> String): String = zee(body())
|
||||
|
||||
// FILE: zee.kt
|
||||
|
||||
@file:[JvmName("A") JvmMultifileClass]
|
||||
package a
|
||||
|
||||
public fun zee(x: String): String = x
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
// WITH_RUNTIME
|
||||
// FILE: box.kt
|
||||
|
||||
import a.*
|
||||
|
||||
fun box(): String = OK
|
||||
|
||||
// FILE: part1.kt
|
||||
|
||||
@file:[JvmName("MultifileClass") JvmMultifileClass]
|
||||
package a
|
||||
|
||||
val O: String = "O"
|
||||
|
||||
// FILE: part2.kt
|
||||
|
||||
@file:[JvmName("MultifileClass") JvmMultifileClass]
|
||||
package a
|
||||
|
||||
val K: String = "K"
|
||||
|
||||
// FILE: part3.kt
|
||||
|
||||
@file:[JvmName("MultifileClass") JvmMultifileClass]
|
||||
package a
|
||||
|
||||
val OK: String = O + K
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
// WITH_RUNTIME
|
||||
// FILE: 1/part.kt
|
||||
|
||||
@file:JvmName("Foo")
|
||||
@file:JvmMultifileClass
|
||||
package test
|
||||
|
||||
fun foo(): String = "O"
|
||||
|
||||
// FILE: 2/part.kt
|
||||
|
||||
@file:JvmName("Bar")
|
||||
@file:JvmMultifileClass
|
||||
package test
|
||||
|
||||
fun bar(): String = "K"
|
||||
|
||||
// FILE: box.kt
|
||||
|
||||
package test
|
||||
|
||||
fun box(): String = foo() + bar()
|
||||
@@ -0,0 +1,41 @@
|
||||
// WITH_RUNTIME
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
class A {}
|
||||
|
||||
fun getMain(className: String): java.lang.reflect.Method {
|
||||
val classLoader = A().javaClass.classLoader
|
||||
return classLoader.loadClass(className).getDeclaredMethod("main", Array<String>::class.java)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val bMain = getMain("pkg.AKt")
|
||||
val cMain = getMain("pkg.BKt")
|
||||
|
||||
val args = Array(1, { "" })
|
||||
|
||||
bMain.invoke(null, args)
|
||||
cMain.invoke(null, args)
|
||||
|
||||
return args[0]
|
||||
}
|
||||
|
||||
|
||||
|
||||
// FILE: a.kt
|
||||
|
||||
package pkg
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
args[0] += "O"
|
||||
}
|
||||
|
||||
// FILE: b.kt
|
||||
|
||||
package pkg
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
args[0] += "K"
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
// FILE: box.kt
|
||||
|
||||
package a
|
||||
|
||||
import pack.*
|
||||
|
||||
class X : SomeClass()
|
||||
|
||||
fun box(): String {
|
||||
X()
|
||||
return "OK"
|
||||
}
|
||||
|
||||
// FILE: file1.kt
|
||||
|
||||
package kotlin.jvm
|
||||
|
||||
private class SomeClass
|
||||
|
||||
// FILE: file2.kt
|
||||
|
||||
package pack
|
||||
|
||||
public open class SomeClass
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// WITH_REFLECT
|
||||
// FILE: test.kt
|
||||
|
||||
fun test2() {
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
// See KT-10690 Exception in kotlin.reflect when trying to get kotlinFunction from javaMethod
|
||||
|
||||
import kotlin.reflect.jvm.javaMethod
|
||||
import kotlin.reflect.jvm.kotlinFunction
|
||||
|
||||
fun box(): String {
|
||||
if (::box.javaMethod?.kotlinFunction == null)
|
||||
return "Fail box"
|
||||
if (::test1.javaMethod?.kotlinFunction == null)
|
||||
return "Fail test1"
|
||||
if (::test2.javaMethod?.kotlinFunction == null)
|
||||
return "Fail test2"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
fun test1() {
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
fun box() = a.x
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
package a
|
||||
|
||||
internal val x: String = "OK"
|
||||
@@ -0,0 +1,30 @@
|
||||
// WITH_RUNTIME
|
||||
// FILE: 1.kt
|
||||
|
||||
package thispackage
|
||||
|
||||
import otherpackage.*
|
||||
|
||||
fun box(): String {
|
||||
if (!localUse()) {
|
||||
return "local use failed"
|
||||
}
|
||||
if (!fromOtherPackage()) {
|
||||
return "use from other package failed"
|
||||
}
|
||||
return "OK"
|
||||
}
|
||||
|
||||
fun localUse(): Boolean {
|
||||
val c = Runnable::class.java
|
||||
return (c.getName()!! == "java.lang.Runnable")
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
package otherpackage
|
||||
|
||||
fun fromOtherPackage(): Boolean {
|
||||
val c = Runnable::class.java
|
||||
return (c.getName()!! == "java.lang.Runnable")
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
fun box() = foo()
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
private val a = "OK"
|
||||
fun foo() : String {
|
||||
return "${a}"
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
public var v1: String = "V1"
|
||||
|
||||
fun box(): String {
|
||||
val s = "v1: $v1, v2: $v2"
|
||||
return "OK"
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
public var v2: String = "V2"
|
||||
@@ -0,0 +1,28 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
import testing.ClassWithInternals
|
||||
|
||||
public class HelloServer() : ClassWithInternals() {
|
||||
public override fun start() {
|
||||
val test = foo() + someGetter //+ some
|
||||
}
|
||||
}
|
||||
|
||||
fun box() : String {
|
||||
HelloServer().start()
|
||||
return "OK"
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
package testing; // There is no error if both files are in default package
|
||||
|
||||
public abstract class ClassWithInternals {
|
||||
protected var some: Int = 0;
|
||||
protected var someGetter: Int = 0
|
||||
get() = 5
|
||||
|
||||
protected fun foo() : Int = 0
|
||||
|
||||
public abstract fun start() : Unit;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// WITH_RUNTIME
|
||||
// FILE: 1.kt
|
||||
|
||||
package test2
|
||||
|
||||
import test.A
|
||||
|
||||
public fun box(): String {
|
||||
return B().test(B())
|
||||
}
|
||||
|
||||
public class B : A() {
|
||||
public fun test(other:Any): String {
|
||||
if (other is B && other.s == 2) {
|
||||
return "OK"
|
||||
}
|
||||
return "fail"
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
package test
|
||||
|
||||
open class A {
|
||||
@JvmField protected val s = 2;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
// WITH_RUNTIME
|
||||
// FILE: 1.kt
|
||||
|
||||
package test2
|
||||
|
||||
import test.A
|
||||
|
||||
class C : A() {
|
||||
fun a(): String {
|
||||
return this.s
|
||||
}
|
||||
}
|
||||
|
||||
public fun box(): String {
|
||||
return C().a()
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
package test
|
||||
|
||||
open class A {
|
||||
@JvmField protected val s = "OK";
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
// WITH_RUNTIME
|
||||
// FILE: 1/wrapped.kt
|
||||
|
||||
fun getWrapped1(): Runnable {
|
||||
val f = { }
|
||||
return Runnable(f)
|
||||
}
|
||||
|
||||
// FILE: 2/wrapped2.kt
|
||||
|
||||
fun getWrapped2(): Runnable {
|
||||
val f = { }
|
||||
return Runnable(f)
|
||||
}
|
||||
|
||||
// FILE: box.kt
|
||||
|
||||
fun box(): String {
|
||||
val class1 = getWrapped1().javaClass
|
||||
val class2 = getWrapped2().javaClass
|
||||
|
||||
return if (class1 != class2) "OK" else "Same class: $class1"
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
import b.B
|
||||
import a.BSamePackage
|
||||
|
||||
fun box() = if (B().test() == BSamePackage().test()) "OK" else "fail"
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
package a
|
||||
|
||||
open class A {
|
||||
protected fun protectedFun(): String = "OK"
|
||||
}
|
||||
|
||||
class BSamePackage: A() {
|
||||
fun test(): String {
|
||||
val a = {
|
||||
protectedFun()
|
||||
}
|
||||
return a()
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 3.kt
|
||||
|
||||
package b
|
||||
|
||||
import a.A
|
||||
|
||||
class B: A() {
|
||||
fun test(): String {
|
||||
val a = {
|
||||
protectedFun()
|
||||
}
|
||||
return a()
|
||||
}
|
||||
}
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
// WITH_RUNTIME
|
||||
// FILE: 1.kt
|
||||
|
||||
import test.A
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
open class B : A() {
|
||||
fun box(): String {
|
||||
val overriddenMethod: () -> String = {
|
||||
method()
|
||||
}
|
||||
assertEquals("C.method", overriddenMethod())
|
||||
|
||||
val superMethod: () -> String = {
|
||||
super.method()
|
||||
}
|
||||
assertEquals("A.method", superMethod())
|
||||
|
||||
val overriddenPropertyGetter: () -> String = {
|
||||
property
|
||||
}
|
||||
assertEquals("C.property", overriddenPropertyGetter())
|
||||
|
||||
val superPropertyGetter: () -> String = {
|
||||
super.property
|
||||
}
|
||||
assertEquals("A.property", superPropertyGetter())
|
||||
|
||||
val overriddenPropertySetter: () -> Unit = {
|
||||
property = ""
|
||||
}
|
||||
overriddenPropertySetter()
|
||||
|
||||
val superPropertySetter: () -> Unit = {
|
||||
super.property = ""
|
||||
}
|
||||
superPropertySetter()
|
||||
|
||||
assertEquals("C.property;A.property;", state)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
class C : B() {
|
||||
override fun method() = "C.method"
|
||||
override var property: String
|
||||
get() = "C.property"
|
||||
set(value) { state += "C.property;" }
|
||||
}
|
||||
|
||||
fun box() = C().box()
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
package test
|
||||
|
||||
abstract class A {
|
||||
public var state = ""
|
||||
|
||||
// These implementations should not be called, because they are overridden in C
|
||||
|
||||
protected open fun method(): String = "A.method"
|
||||
|
||||
protected open var property: String
|
||||
get() = "A.property"
|
||||
set(value) { state += "A.property;" }
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
// FILE: a.kt
|
||||
|
||||
package test2
|
||||
|
||||
import test.Actor
|
||||
import test.O2dScriptAction
|
||||
|
||||
class CompositeActor : Actor()
|
||||
|
||||
public open class O2dDialog : O2dScriptAction<CompositeActor>() {
|
||||
|
||||
fun test() = { owner }()
|
||||
|
||||
fun test2() = { calc() }()
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
if (O2dDialog().test() != null) return "fail 1"
|
||||
if (O2dDialog().test2() != null) return "fail 2"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
// FILE: b.kt
|
||||
|
||||
package test
|
||||
|
||||
open class Actor
|
||||
|
||||
abstract public class O2dScriptAction<T : Actor> {
|
||||
protected var owner: T? = null
|
||||
private set
|
||||
|
||||
protected fun calc(): T? = null
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// FILE: box.kt
|
||||
|
||||
object Test {
|
||||
val test: String = OK
|
||||
}
|
||||
|
||||
fun box(): String = Test.test
|
||||
|
||||
// FILE: Vars.kt
|
||||
|
||||
public var OK: String = "OK"
|
||||
private set
|
||||
@@ -0,0 +1,23 @@
|
||||
// FILE: a.kt
|
||||
|
||||
package a
|
||||
|
||||
import b.*
|
||||
|
||||
fun box(): String {
|
||||
BB().ok()
|
||||
return BB().OK
|
||||
}
|
||||
|
||||
// FILE: b.kt
|
||||
|
||||
package b
|
||||
|
||||
public open class B {
|
||||
public var OK: String = "OK"
|
||||
protected set
|
||||
}
|
||||
|
||||
public class BB : B() {
|
||||
public fun ok(): String = OK
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
// FILE: a.kt
|
||||
|
||||
package a
|
||||
|
||||
import b.*
|
||||
|
||||
class B {
|
||||
companion object : A() {}
|
||||
|
||||
init {
|
||||
foo()
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
B()
|
||||
return result
|
||||
}
|
||||
|
||||
// FILE: b.kt
|
||||
|
||||
package b
|
||||
|
||||
var result = "fail"
|
||||
|
||||
abstract class A {
|
||||
protected fun foo() {
|
||||
result = "OK"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
// FILE: a.kt
|
||||
|
||||
package a
|
||||
|
||||
import b.*
|
||||
|
||||
interface B {
|
||||
companion object : A() {}
|
||||
|
||||
fun test() {
|
||||
foo()
|
||||
}
|
||||
}
|
||||
|
||||
class C : B
|
||||
|
||||
fun box(): String {
|
||||
C().test()
|
||||
return result
|
||||
}
|
||||
|
||||
// FILE: b.kt
|
||||
|
||||
package b
|
||||
|
||||
var result = "fail"
|
||||
|
||||
abstract class A {
|
||||
protected fun foo() {
|
||||
result = "OK"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// FILE: A.kt
|
||||
|
||||
package first
|
||||
|
||||
open class A {
|
||||
protected open fun test(): String = "FAIL (A)"
|
||||
}
|
||||
|
||||
fun box() = second.C().value()
|
||||
|
||||
// FILE: B.kt
|
||||
|
||||
// See also KT-8344: INVOKESPECIAL instead of INVOKEVIRTUAL in accessor
|
||||
|
||||
package second
|
||||
|
||||
import first.A
|
||||
|
||||
public abstract class B(): A() {
|
||||
val value = {
|
||||
test()
|
||||
}
|
||||
}
|
||||
|
||||
class C: B() {
|
||||
override fun test() = "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user