[K/N][Tests] Move codegen test sources interfaceCallsNCasts..vector

^KT-61259
This commit is contained in:
Vladimir Sukharev
2023-12-15 00:13:04 +01:00
committed by Space Team
parent 56e1c5cbc6
commit 93642020ff
182 changed files with 2023 additions and 686 deletions
@@ -0,0 +1,27 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package codegen.localClass.innerTakesCapturedFromOuter
import kotlin.test.*
fun box() {
var previous: Any? = null
for (i in 0 .. 2) {
class Outer {
inner class Inner {
override fun toString() = i.toString()
}
override fun toString() = Inner().toString()
}
if (previous != null) println(previous.toString())
previous = Outer()
}
}
@Test fun runTest() {
box()
}
@@ -0,0 +1,2 @@
0
1
@@ -0,0 +1,22 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package codegen.localClass.innerWithCapture
import kotlin.test.*
fun box(s: String): String {
class Local {
open inner class Inner() {
open fun result() = s
}
}
return Local().Inner().result()
}
@Test fun runTest() {
println(box("OK"))
}
@@ -0,0 +1 @@
OK
@@ -0,0 +1,23 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package codegen.localClass.localFunctionCallFromLocalClass
import kotlin.test.*
@Test fun runTest() {
var x = 1
fun local1() {
x++
}
class A {
fun bar() {
local1()
}
}
A().bar()
println("OK")
}
@@ -0,0 +1,30 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package codegen.localClass.localFunctionInLocalClass
import kotlin.test.*
@Test fun runTest() {
var x = 0
class A {
fun bar() {
fun local() {
class B {
fun baz() {
fun local2() {
x++
}
local2()
}
}
B().baz()
}
local()
}
}
A().bar()
println("OK")
}
@@ -0,0 +1 @@
OK
@@ -0,0 +1,24 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package codegen.localClass.localHierarchy
import kotlin.test.*
fun foo(s: String): String {
open class Local {
fun f() = s
}
open class Derived: Local() {
fun g() = f()
}
return Derived().g()
}
@Test fun runTest() {
println(foo("OK"))
}
@@ -0,0 +1 @@
OK
@@ -0,0 +1,30 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package codegen.localClass.noPrimaryConstructor
import kotlin.test.*
fun box(s: String): String {
class Local {
constructor(x: Int) {
this.x = x
}
constructor(z: String) {
x = z.length
}
val x: Int
fun result() = s
}
return Local(42).result() + Local("zzz").result()
}
@Test fun runTest() {
println(box("OK"))
}
@@ -0,0 +1 @@
OKOK
@@ -0,0 +1,34 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package codegen.localClass.objectExpressionInInitializer
import kotlin.test.*
abstract class Father {
abstract inner class InClass {
abstract fun work(): String
}
}
class Child : Father() {
val ChildInClass : InClass
init {
ChildInClass = object : Father.InClass() {
override fun work(): String {
return "OK"
}
}
}
}
fun box(): String {
return Child().ChildInClass.work()
}
@Test fun runTest() {
println(box())
}
@@ -0,0 +1,30 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package codegen.localClass.objectExpressionInProperty
import kotlin.test.*
abstract class Father {
abstract inner class InClass {
abstract fun work(): String
}
}
class Child : Father() {
val ChildInClass = object : Father.InClass() {
override fun work(): String {
return "OK"
}
}
}
fun box(): String {
return Child().ChildInClass.work()
}
@Test fun runTest() {
println(box())
}
@@ -0,0 +1 @@
OK
@@ -0,0 +1,25 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package codegen.localClass.tryCatch
import kotlin.test.*
private fun foo() {
val local =
object {
fun bar() {
try {
} catch (t: Throwable) {
println(t)
}
}
}
local.bar()
}
@Test fun runTest() {
foo()
}
@@ -0,0 +1,34 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package codegen.localClass.virtualCallFromConstructor
import kotlin.test.*
abstract class WaitFor {
init {
condition()
}
abstract fun condition(): Boolean;
}
fun box(): String {
val local = ""
var result = "fail"
val s = object : WaitFor() {
override fun condition(): Boolean {
result = "OK"
return result.length == 2
}
}
return result;
}
@Test fun runTest() {
println(box())
}
@@ -0,0 +1 @@
OK