Merge boxMultiFile testData into box, delete BoxMultiFile test

This commit is contained in:
Alexander Udalov
2016-03-07 14:14:27 +03:00
committed by Alexander Udalov
parent e115f80d6c
commit 16a0ddd2fb
41 changed files with 234 additions and 269 deletions
@@ -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()
}
}
@@ -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"
}