Migrate boxMultiFile and boxMultifileClass tests to new multi-file tests
AbstractCompileKotlinAgainstMultifileKotlinTest is broken in this commit; will be fixed later
This commit is contained in:
@@ -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()
|
||||
}
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
import b.B
|
||||
import a.BSamePackage
|
||||
|
||||
fun box() = if (B().test() == BSamePackage().test()) "OK" else "fail"
|
||||
@@ -1,14 +0,0 @@
|
||||
package a
|
||||
|
||||
open class A {
|
||||
protected fun protectedFun(): String = "OK"
|
||||
}
|
||||
|
||||
class BSamePackage: A() {
|
||||
fun test(): String {
|
||||
val a = {
|
||||
protectedFun()
|
||||
}
|
||||
return a()
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package b
|
||||
|
||||
import a.A
|
||||
|
||||
class B: A() {
|
||||
fun test(): String {
|
||||
val a = {
|
||||
protectedFun()
|
||||
}
|
||||
return a()
|
||||
}
|
||||
}
|
||||
+18
@@ -1,3 +1,5 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
import test.A
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
@@ -47,3 +49,19 @@ class C : B() {
|
||||
}
|
||||
|
||||
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;" }
|
||||
}
|
||||
-13
@@ -1,13 +0,0 @@
|
||||
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;" }
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
// 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"
|
||||
-5
@@ -1,5 +0,0 @@
|
||||
package test
|
||||
|
||||
import b.bar
|
||||
|
||||
fun box(): String = bar()
|
||||
-5
@@ -1,5 +0,0 @@
|
||||
package b
|
||||
|
||||
import a.foo
|
||||
|
||||
fun bar(): String = foo()
|
||||
Vendored
-4
@@ -1,4 +0,0 @@
|
||||
@file:[JvmName("MultifileClass") JvmMultifileClass]
|
||||
package a
|
||||
|
||||
fun foo(): String = "OK"
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
// 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
|
||||
-5
@@ -1,5 +0,0 @@
|
||||
package test
|
||||
|
||||
import a.foo
|
||||
|
||||
fun box(): String = foo { "OK" }
|
||||
-4
@@ -1,4 +0,0 @@
|
||||
@file:[JvmName("A") JvmMultifileClass]
|
||||
package a
|
||||
|
||||
inline fun foo(body: () -> String): String = zee(body())
|
||||
-4
@@ -1,4 +0,0 @@
|
||||
@file:[JvmName("A") JvmMultifileClass]
|
||||
package a
|
||||
|
||||
public fun zee(x: String): String = x
|
||||
@@ -0,0 +1,9 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
fun box() = a.x
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
package a
|
||||
|
||||
val x: String = "OK"
|
||||
@@ -1 +0,0 @@
|
||||
fun box() = a.x
|
||||
@@ -1,3 +0,0 @@
|
||||
package a
|
||||
|
||||
val x: String = "OK"
|
||||
+17
-1
@@ -1,3 +1,5 @@
|
||||
// FILE: a.kt
|
||||
|
||||
package test2
|
||||
|
||||
import test.Actor
|
||||
@@ -17,4 +19,18 @@ fun box(): String {
|
||||
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
|
||||
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package test
|
||||
|
||||
open class Actor
|
||||
|
||||
abstract public class O2dScriptAction<T : Actor> {
|
||||
protected var owner: T? = null
|
||||
private set
|
||||
|
||||
protected fun calc(): T? = null
|
||||
|
||||
}
|
||||
+12
-1
@@ -1,3 +1,5 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package thispackage
|
||||
|
||||
import otherpackage.*
|
||||
@@ -15,4 +17,13 @@ fun box(): String {
|
||||
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")
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
package otherpackage
|
||||
|
||||
fun fromOtherPackage(): Boolean {
|
||||
val c = Runnable::class.java
|
||||
return (c.getName()!! == "java.lang.Runnable")
|
||||
}
|
||||
+7
-1
@@ -1,4 +1,10 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
fun box() = foo()
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
private val a = "OK"
|
||||
fun foo() : String {
|
||||
return "${a}"
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
fun box() = foo()
|
||||
+6
@@ -1,6 +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"
|
||||
@@ -1 +0,0 @@
|
||||
public var v2: String = "V2"
|
||||
+17
@@ -1,3 +1,20 @@
|
||||
// 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 {
|
||||
@@ -1,12 +0,0 @@
|
||||
import testing.ClassWithInternals
|
||||
|
||||
public class HelloServer() : ClassWithInternals() {
|
||||
public override fun start() {
|
||||
val test = foo() + someGetter //+ some
|
||||
}
|
||||
}
|
||||
|
||||
fun box() : String {
|
||||
HelloServer().start()
|
||||
return "OK"
|
||||
}
|
||||
+11
-1
@@ -1,3 +1,5 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test2
|
||||
|
||||
import test.A
|
||||
@@ -13,4 +15,12 @@ public class B : A() {
|
||||
}
|
||||
return "fail"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
package test
|
||||
|
||||
open class A {
|
||||
@JvmField protected val s = 2;
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package test
|
||||
|
||||
open class A {
|
||||
@JvmField protected val s = 2;
|
||||
}
|
||||
+10
@@ -1,3 +1,5 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test2
|
||||
|
||||
import test.A
|
||||
@@ -11,3 +13,11 @@ class C : A() {
|
||||
public fun box(): String {
|
||||
return C().a()
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
package test
|
||||
|
||||
open class A {
|
||||
@JvmField protected val s = "OK";
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package test
|
||||
|
||||
open class A {
|
||||
@JvmField protected val s = "OK";
|
||||
}
|
||||
@@ -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
|
||||
@@ -1,2 +0,0 @@
|
||||
public var OK: String = "OK"
|
||||
private set
|
||||
@@ -1,5 +0,0 @@
|
||||
object Test {
|
||||
val test: String = OK
|
||||
}
|
||||
|
||||
fun box(): String = Test.test
|
||||
+14
-1
@@ -1,3 +1,16 @@
|
||||
// FILE: a.kt
|
||||
|
||||
package a
|
||||
|
||||
import b.*
|
||||
|
||||
fun box(): String {
|
||||
BB().ok()
|
||||
return BB().OK
|
||||
}
|
||||
|
||||
// FILE: b.kt
|
||||
|
||||
package b
|
||||
|
||||
public open class B {
|
||||
@@ -7,4 +20,4 @@ public open class B {
|
||||
|
||||
public class BB : B() {
|
||||
public fun ok(): String = OK
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package a
|
||||
|
||||
import b.*
|
||||
|
||||
fun box(): String {
|
||||
BB().ok()
|
||||
return BB().OK
|
||||
}
|
||||
+15
-1
@@ -1,3 +1,5 @@
|
||||
// FILE: a.kt
|
||||
|
||||
package a
|
||||
|
||||
import b.*
|
||||
@@ -13,4 +15,16 @@ class B {
|
||||
fun box(): String {
|
||||
B()
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: b.kt
|
||||
|
||||
package b
|
||||
|
||||
var result = "fail"
|
||||
|
||||
abstract class A {
|
||||
protected fun foo() {
|
||||
result = "OK"
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package b
|
||||
|
||||
var result = "fail"
|
||||
|
||||
abstract class A {
|
||||
protected fun foo() {
|
||||
result = "OK"
|
||||
}
|
||||
}
|
||||
+15
-1
@@ -1,3 +1,5 @@
|
||||
// FILE: a.kt
|
||||
|
||||
package a
|
||||
|
||||
import b.*
|
||||
@@ -15,4 +17,16 @@ 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"
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package b
|
||||
|
||||
var result = "fail"
|
||||
|
||||
abstract class A {
|
||||
protected fun foo() {
|
||||
result = "OK"
|
||||
}
|
||||
}
|
||||
+19
@@ -1,3 +1,5 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
class A {}
|
||||
@@ -19,3 +21,20 @@ fun box(): String {
|
||||
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"
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package pkg
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
args[0] += "O"
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package pkg
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
args[0] += "K"
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
// 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
|
||||
-3
@@ -1,3 +0,0 @@
|
||||
import a.*
|
||||
|
||||
fun box(): String = OK
|
||||
-4
@@ -1,4 +0,0 @@
|
||||
@file:[JvmName("MultifileClass") JvmMultifileClass]
|
||||
package a
|
||||
|
||||
val O: String = "O"
|
||||
-4
@@ -1,4 +0,0 @@
|
||||
@file:[JvmName("MultifileClass") JvmMultifileClass]
|
||||
package a
|
||||
|
||||
val K: String = "K"
|
||||
-4
@@ -1,4 +0,0 @@
|
||||
@file:[JvmName("MultifileClass") JvmMultifileClass]
|
||||
package a
|
||||
|
||||
val OK: String = O + 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
|
||||
Vendored
-10
@@ -1,10 +0,0 @@
|
||||
package a
|
||||
|
||||
import pack.*
|
||||
|
||||
class X : SomeClass()
|
||||
|
||||
fun box(): String {
|
||||
X()
|
||||
return "OK"
|
||||
}
|
||||
Vendored
-3
@@ -1,3 +0,0 @@
|
||||
package kotlin.jvm
|
||||
|
||||
private class SomeClass
|
||||
Vendored
-3
@@ -1,3 +0,0 @@
|
||||
package pack
|
||||
|
||||
public open class SomeClass
|
||||
+12
-2
@@ -1,4 +1,15 @@
|
||||
// B.kt
|
||||
// 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
|
||||
@@ -14,4 +25,3 @@ public abstract class B(): A() {
|
||||
class C: B() {
|
||||
override fun test() = "OK"
|
||||
}
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
// A.kt
|
||||
package first
|
||||
|
||||
open class A {
|
||||
protected open fun test(): String = "FAIL (A)"
|
||||
}
|
||||
|
||||
fun box() = second.C().value()
|
||||
@@ -0,0 +1,22 @@
|
||||
// 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"
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
fun getWrapped1(): Runnable {
|
||||
val f = { }
|
||||
return Runnable(f)
|
||||
}
|
||||
-4
@@ -1,4 +0,0 @@
|
||||
fun getWrapped2(): Runnable {
|
||||
val f = { }
|
||||
return Runnable(f)
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
fun box(): String {
|
||||
val class1 = getWrapped1().javaClass
|
||||
val class2 = getWrapped2().javaClass
|
||||
|
||||
return if (class1 != class2) "OK" else "Same class: $class1"
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// FILE: 1/box.kt
|
||||
|
||||
fun box() = box1() + "K"
|
||||
|
||||
// FILE: 2/box2.kt
|
||||
|
||||
fun box1() = "O"
|
||||
@@ -1 +0,0 @@
|
||||
fun box() = box1() + "K"
|
||||
@@ -1 +0,0 @@
|
||||
fun box1() = "O"
|
||||
@@ -0,0 +1,21 @@
|
||||
// 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()
|
||||
@@ -1,5 +0,0 @@
|
||||
@file:JvmName("Foo")
|
||||
@file:JvmMultifileClass
|
||||
package test
|
||||
|
||||
fun foo(): String = "O"
|
||||
@@ -1,5 +0,0 @@
|
||||
@file:JvmName("Bar")
|
||||
@file:JvmMultifileClass
|
||||
package test
|
||||
|
||||
fun bar(): String = "K"
|
||||
@@ -1,3 +0,0 @@
|
||||
package test
|
||||
|
||||
fun box(): String = foo() + bar()
|
||||
@@ -0,0 +1,7 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
fun box() = ok()
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
fun ok(res: String = "OK") = res
|
||||
@@ -1 +0,0 @@
|
||||
fun box() = ok()
|
||||
@@ -1 +0,0 @@
|
||||
fun ok(res: String = "OK") = res
|
||||
Reference in New Issue
Block a user