[K/N][Tests] Adjust moved tests interfaceCallsNCasts..vector to new infra
^KT-61259
This commit is contained in:
committed by
Space Team
parent
93642020ff
commit
bb8a7b6795
@@ -6,7 +6,6 @@
|
|||||||
/**
|
/**
|
||||||
* Created by minamoto on 12/26/16.
|
* Created by minamoto on 12/26/16.
|
||||||
*/
|
*/
|
||||||
//package defaults
|
|
||||||
|
|
||||||
open class A(val a:Int) {
|
open class A(val a:Int) {
|
||||||
override fun equals(other: Any?): Boolean {
|
override fun equals(other: Any?): Boolean {
|
||||||
|
|||||||
+6
-6
@@ -3,8 +3,6 @@
|
|||||||
* that can be found in the LICENSE file.
|
* that can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package codegen.interfaceCallsNCasts.conservativeItable
|
|
||||||
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
interface I0 {
|
interface I0 {
|
||||||
@@ -559,9 +557,9 @@ fun foo(i42: I42, x: Int) = i42.foo42(x)
|
|||||||
|
|
||||||
fun bar(i_m1: I_M1, x: Int) = i_m1.bar(x)
|
fun bar(i_m1: I_M1, x: Int) = i_m1.bar(x)
|
||||||
|
|
||||||
@Test fun runTest() {
|
fun box(): String {
|
||||||
val y = Bar2()
|
val y = Bar2()
|
||||||
println(bar(y, 1))
|
assertEquals(539, bar(y, 1))
|
||||||
val x0 = Bar()
|
val x0 = Bar()
|
||||||
var t = 0
|
var t = 0
|
||||||
if (check_is_I0(x0)) t = t + 1
|
if (check_is_I0(x0)) t = t + 1
|
||||||
@@ -664,7 +662,7 @@ fun bar(i_m1: I_M1, x: Int) = i_m1.bar(x)
|
|||||||
if (check_is_I97(x0)) t = t + 98
|
if (check_is_I97(x0)) t = t + 98
|
||||||
if (check_is_I98(x0)) t = t + 99
|
if (check_is_I98(x0)) t = t + 99
|
||||||
if (check_is_I99(x0)) t = t + 100
|
if (check_is_I99(x0)) t = t + 100
|
||||||
println(t)
|
assertEquals(5050, t)
|
||||||
val x1 = I42_Impl1()
|
val x1 = I42_Impl1()
|
||||||
val x2 = I42_Impl2()
|
val x2 = I42_Impl2()
|
||||||
val x3 = I42_Impl3()
|
val x3 = I42_Impl3()
|
||||||
@@ -682,5 +680,7 @@ fun bar(i_m1: I_M1, x: Int) = i_m1.bar(x)
|
|||||||
t = foo(x6, t)
|
t = foo(x6, t)
|
||||||
t = foo(x7, t)
|
t = foo(x7, t)
|
||||||
t = foo(x8, t)
|
t = foo(x8, t)
|
||||||
println(t)
|
assertEquals(26551140, t)
|
||||||
|
|
||||||
|
return "OK"
|
||||||
}
|
}
|
||||||
|
|||||||
-3
@@ -1,3 +0,0 @@
|
|||||||
539
|
|
||||||
5050
|
|
||||||
26551140
|
|
||||||
@@ -3,8 +3,6 @@
|
|||||||
* that can be found in the LICENSE file.
|
* that can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package codegen.interfaceCallsNCasts.diamond
|
|
||||||
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
interface A<T, U> {
|
interface A<T, U> {
|
||||||
@@ -19,8 +17,7 @@ class Z : B<Int>, C<String> {
|
|||||||
override fun foo(t: String, u: Int) = "Z"
|
override fun foo(t: String, u: Int) = "Z"
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
fun box(): String {
|
||||||
fun runTest() {
|
|
||||||
val z = Z()
|
val z = Z()
|
||||||
val c: C<String> = z
|
val c: C<String> = z
|
||||||
val b: B<Int> = z
|
val b: B<Int> = z
|
||||||
@@ -30,4 +27,6 @@ fun runTest() {
|
|||||||
assertEquals("Z", c.foo("", 0))
|
assertEquals("Z", c.foo("", 0))
|
||||||
assertEquals("Z", b.foo("", 0))
|
assertEquals("Z", b.foo("", 0))
|
||||||
assertEquals("Z", a.foo("", 0))
|
assertEquals("Z", a.foo("", 0))
|
||||||
|
|
||||||
|
return "OK"
|
||||||
}
|
}
|
||||||
@@ -3,8 +3,6 @@
|
|||||||
* that can be found in the LICENSE file.
|
* that can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package codegen.interfaceCallsNCasts.finalMethod
|
|
||||||
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
interface I1<T> {
|
interface I1<T> {
|
||||||
@@ -21,8 +19,9 @@ class C : I2 {
|
|||||||
override fun foo(x: Int) = x
|
override fun foo(x: Int) = x
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
fun box(): String {
|
||||||
fun runTest() {
|
|
||||||
val c: I2 = C()
|
val c: I2 = C()
|
||||||
assertEquals(42, c.foo())
|
assertEquals(42, c.foo())
|
||||||
|
|
||||||
|
return "OK"
|
||||||
}
|
}
|
||||||
+3
-4
@@ -3,8 +3,6 @@
|
|||||||
* that can be found in the LICENSE file.
|
* that can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package codegen.interfaceCallsNCasts.functionNameClash
|
|
||||||
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
interface I1<T> {
|
interface I1<T> {
|
||||||
@@ -18,11 +16,12 @@ class C : I1<String>, I2<Int> {
|
|||||||
override fun foo(x: Int) = "I2.foo($x)"
|
override fun foo(x: Int) = "I2.foo($x)"
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
fun box(): String {
|
||||||
fun runTest() {
|
|
||||||
val c = C()
|
val c = C()
|
||||||
val i1: I1<String> = c
|
val i1: I1<String> = c
|
||||||
assertEquals("I1.foo(str)", i1.foo("str"))
|
assertEquals("I1.foo(str)", i1.foo("str"))
|
||||||
val i2: I2<Int> = c
|
val i2: I2<Int> = c
|
||||||
assertEquals("I2.foo(42)", i2.foo(42))
|
assertEquals("I2.foo(42)", i2.foo(42))
|
||||||
|
|
||||||
|
return "OK"
|
||||||
}
|
}
|
||||||
+11
-11
@@ -1,8 +1,6 @@
|
|||||||
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||||
@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class, kotlin.native.internal.InternalForKotlinNative::class)
|
@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class, kotlin.native.internal.InternalForKotlinNative::class)
|
||||||
|
|
||||||
package codegen.intrinsics.interop_sourceCodeStruct
|
|
||||||
|
|
||||||
import kotlinx.cinterop.*
|
import kotlinx.cinterop.*
|
||||||
import kotlinx.cinterop.internal.*
|
import kotlinx.cinterop.internal.*
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
@@ -29,15 +27,17 @@ class S(rawPtr: NativePtr) : CStructVar(rawPtr) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
fun box(): String {
|
||||||
fun test() = memScoped {
|
memScoped {
|
||||||
val s = alloc<S>()
|
val s = alloc<S>()
|
||||||
|
|
||||||
s.x = 123
|
s.x = 123
|
||||||
assertEquals(123, s.x)
|
assertEquals(123, s.x)
|
||||||
assertEquals(123, s.ptr.reinterpret<IntVar>()[0])
|
assertEquals(123, s.ptr.reinterpret<IntVar>()[0])
|
||||||
|
|
||||||
s.y = 321
|
s.y = 321
|
||||||
assertEquals(321, s.y)
|
assertEquals(321, s.y)
|
||||||
assertEquals(321, s.ptr.reinterpret<IntVar>()[1])
|
assertEquals(321, s.ptr.reinterpret<IntVar>()[1])
|
||||||
|
}
|
||||||
|
return "OK"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,12 +7,12 @@
|
|||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
import kotlin.native.Platform
|
import kotlin.native.Platform
|
||||||
|
|
||||||
@Test
|
|
||||||
@OptIn(kotlin.ExperimentalStdlibApi::class)
|
@OptIn(kotlin.ExperimentalStdlibApi::class)
|
||||||
fun testIsExperimentalMM() {
|
fun box(): String {
|
||||||
if (isExperimentalMM()) {
|
if (isExperimentalMM()) {
|
||||||
assertEquals(Platform.memoryModel, MemoryModel.EXPERIMENTAL)
|
assertEquals(Platform.memoryModel, MemoryModel.EXPERIMENTAL)
|
||||||
} else {
|
} else {
|
||||||
assertNotEquals(Platform.memoryModel, MemoryModel.EXPERIMENTAL)
|
assertNotEquals(Platform.memoryModel, MemoryModel.EXPERIMENTAL)
|
||||||
}
|
}
|
||||||
|
return "OK"
|
||||||
}
|
}
|
||||||
+46
@@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2023 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.
|
||||||
|
*/
|
||||||
|
// KT-64460: When producing cache, anonymous objects are not extracted from inline functions to module scope, so the following happens
|
||||||
|
// kotlin.AssertionError: Expected <class codegen.kclass.kclass0.MainKt$1>, actual <class codegen.kclass.kclass0.box$$inlined$getHasFoo$1>.
|
||||||
|
// IGNORE_NATIVE: cacheMode=STATIC_EVERYWHERE
|
||||||
|
// IGNORE_NATIVE: cacheMode=STATIC_PER_FILE_EVERYWHERE
|
||||||
|
|
||||||
|
package codegen.kclass.kclass0
|
||||||
|
import kotlin.test.*
|
||||||
|
import kotlin.reflect.KClass
|
||||||
|
|
||||||
|
interface HasFoo {
|
||||||
|
fun foo(): String
|
||||||
|
}
|
||||||
|
|
||||||
|
private inline fun getHasFoo(s: String) = object : HasFoo {
|
||||||
|
override fun foo(): String = s
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
val hasFoo = getHasFoo("zzz")
|
||||||
|
checkClass(
|
||||||
|
hasFoo::class,
|
||||||
|
expectedQualifiedName = null,
|
||||||
|
expectedSimpleName = null, // KT-64460: simpleName is explicitly prohibited in NATIVE backend
|
||||||
|
expectedToStringName = "class codegen.kclass.kclass0.MainKt\$1",
|
||||||
|
expectedInstance = hasFoo,
|
||||||
|
expectedNotInstance = Any()
|
||||||
|
)
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun checkClass(
|
||||||
|
clazz: KClass<*>,
|
||||||
|
expectedQualifiedName: String?, expectedSimpleName: String?, expectedToStringName: String,
|
||||||
|
expectedInstance: Any, expectedNotInstance: Any?
|
||||||
|
) {
|
||||||
|
assertEquals(expectedQualifiedName, clazz.qualifiedName)
|
||||||
|
assertEquals(expectedSimpleName, clazz.simpleName)
|
||||||
|
assertEquals(expectedToStringName, clazz.toString())
|
||||||
|
|
||||||
|
assertTrue(clazz.isInstance(expectedInstance))
|
||||||
|
if (expectedNotInstance != null) assertTrue(!clazz.isInstance(expectedNotInstance))
|
||||||
|
}
|
||||||
+46
@@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2023 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.
|
||||||
|
*/
|
||||||
|
// KT-64460: When not producing cache, anonymous objects are extracted from inline functions to module scope, so the following happens
|
||||||
|
// kotlin.AssertionError: Expected <class codegen.kclass.kclass0.checkAnonymousObjects$$inlined$getHasFoo$1>, actual <class codegen.kclass.kclass0.MainKt$1>.
|
||||||
|
// IGNORE_NATIVE: cacheMode=NO
|
||||||
|
// IGNORE_NATIVE: cacheMode=STATIC_ONLY_DIST
|
||||||
|
|
||||||
|
package codegen.kclass.kclass0
|
||||||
|
import kotlin.test.*
|
||||||
|
import kotlin.reflect.KClass
|
||||||
|
|
||||||
|
interface HasFoo {
|
||||||
|
fun foo(): String
|
||||||
|
}
|
||||||
|
|
||||||
|
private inline fun getHasFoo(s: String) = object : HasFoo {
|
||||||
|
override fun foo(): String = s
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
val hasFoo = getHasFoo("zzz")
|
||||||
|
checkClass(
|
||||||
|
hasFoo::class,
|
||||||
|
expectedQualifiedName = null,
|
||||||
|
expectedSimpleName = null, // KT-64460: simpleName is explicitly prohibited in NATIVE backend
|
||||||
|
expectedToStringName = "class codegen.kclass.kclass0.box\$\$inlined\$getHasFoo\$1",
|
||||||
|
expectedInstance = hasFoo,
|
||||||
|
expectedNotInstance = Any()
|
||||||
|
)
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun checkClass(
|
||||||
|
clazz: KClass<*>,
|
||||||
|
expectedQualifiedName: String?, expectedSimpleName: String?, expectedToStringName: String,
|
||||||
|
expectedInstance: Any, expectedNotInstance: Any?
|
||||||
|
) {
|
||||||
|
assertEquals(expectedQualifiedName, clazz.qualifiedName)
|
||||||
|
assertEquals(expectedSimpleName, clazz.simpleName)
|
||||||
|
assertEquals(expectedToStringName, clazz.toString())
|
||||||
|
|
||||||
|
assertTrue(clazz.isInstance(expectedInstance))
|
||||||
|
if (expectedNotInstance != null) assertTrue(!clazz.isInstance(expectedNotInstance))
|
||||||
|
}
|
||||||
@@ -3,8 +3,6 @@
|
|||||||
* that can be found in the LICENSE file.
|
* that can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package codegen.kclass.kClassEnumArgument
|
|
||||||
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
import kotlin.reflect.KClass
|
import kotlin.reflect.KClass
|
||||||
|
|
||||||
@@ -13,6 +11,8 @@ enum class E(val arg: KClass<*>?) {
|
|||||||
B(String::class);
|
B(String::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun runTest() {
|
fun box(): String {
|
||||||
println(E.B.arg?.simpleName)
|
assertEquals("String", E.B.arg?.simpleName)
|
||||||
|
|
||||||
|
return "OK"
|
||||||
}
|
}
|
||||||
@@ -1 +0,0 @@
|
|||||||
String
|
|
||||||
+2
-21
@@ -2,15 +2,14 @@
|
|||||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
* 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.
|
* that can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package codegen.kclass.kclass0
|
package codegen.kclass.kclass0
|
||||||
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
import kotlin.coroutines.*
|
import kotlin.coroutines.*
|
||||||
import kotlin.reflect.KClass
|
import kotlin.reflect.KClass
|
||||||
|
|
||||||
@Test fun runTest() {
|
fun box(): String {
|
||||||
main(emptyArray<String>())
|
main(emptyArray<String>())
|
||||||
|
return "OK"
|
||||||
}
|
}
|
||||||
|
|
||||||
fun main(args: Array<String>) {
|
fun main(args: Array<String>) {
|
||||||
@@ -211,14 +210,6 @@ private fun checkLocalClasses(args: Array<String>) {
|
|||||||
::suspendFunWithLocalClass.runCoroutine()
|
::suspendFunWithLocalClass.runCoroutine()
|
||||||
}
|
}
|
||||||
|
|
||||||
interface HasFoo {
|
|
||||||
fun foo(): String
|
|
||||||
}
|
|
||||||
|
|
||||||
private inline fun getHasFoo(s: String) = object : HasFoo {
|
|
||||||
override fun foo(): String = s
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun checkAnonymousObjects(args: Array<String>) {
|
private fun checkAnonymousObjects(args: Array<String>) {
|
||||||
// Anonymous object.
|
// Anonymous object.
|
||||||
with(object : Any() {
|
with(object : Any() {
|
||||||
@@ -378,16 +369,6 @@ private fun checkAnonymousObjects(args: Array<String>) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
::suspendFunWithAnonymousObject.runCoroutine()
|
::suspendFunWithAnonymousObject.runCoroutine()
|
||||||
|
|
||||||
val hasFoo = getHasFoo("zzz")
|
|
||||||
checkClass(
|
|
||||||
hasFoo::class,
|
|
||||||
expectedQualifiedName = null,
|
|
||||||
expectedSimpleName = null,
|
|
||||||
expectedToStringName = "class codegen.kclass.kclass0.Kclass0Kt$1",
|
|
||||||
expectedInstance = hasFoo,
|
|
||||||
expectedNotInstance = Any()
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun checkAnonymousObjectsAssignedToProperty(args: Array<String>) {
|
private fun checkAnonymousObjectsAssignedToProperty(args: Array<String>) {
|
||||||
|
|||||||
+6
-6
@@ -7,12 +7,12 @@ package codegen.kclass.kclass1
|
|||||||
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
// FILE: main.kt
|
val sb = StringBuilder()
|
||||||
@Test fun runTest() {
|
|
||||||
App(testQualified = true)
|
|
||||||
}
|
|
||||||
|
|
||||||
// FILE: app.kt
|
fun box(): String {
|
||||||
|
App(testQualified = true)
|
||||||
|
return sb.toString()
|
||||||
|
}
|
||||||
|
|
||||||
// Taken from:
|
// Taken from:
|
||||||
// https://github.com/SalomonBrys/kmffkn/blob/master/shared/main/kotlin/com/github/salomonbrys/kmffkn/app.kt
|
// https://github.com/SalomonBrys/kmffkn/blob/master/shared/main/kotlin/com/github/salomonbrys/kmffkn/app.kt
|
||||||
@@ -55,6 +55,6 @@ class App(testQualified: Boolean) {
|
|||||||
assert(TestClass()::class == TestClass()::class)
|
assert(TestClass()::class == TestClass()::class)
|
||||||
assert(TestClass()::class == TestClass::class)
|
assert(TestClass()::class == TestClass::class)
|
||||||
|
|
||||||
println("OK :D")
|
sb.append("OK")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
OK :D
|
|
||||||
+5
-4
@@ -3,14 +3,15 @@
|
|||||||
* that can be found in the LICENSE file.
|
* that can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package codegen.lambda.lambda1
|
|
||||||
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
@Test fun runTest() {
|
val sb = StringBuilder()
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
run {
|
run {
|
||||||
println("lambda")
|
sb.append("OK")
|
||||||
}
|
}
|
||||||
|
return sb.toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun run(f: () -> Unit) {
|
fun run(f: () -> Unit) {
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
lambda
|
|
||||||
+11
-4
@@ -3,19 +3,26 @@
|
|||||||
* that can be found in the LICENSE file.
|
* that can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package codegen.lambda.lambda10
|
|
||||||
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
@Test fun runTest() {
|
val sb = StringBuilder()
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
var str = "original"
|
var str = "original"
|
||||||
|
|
||||||
val lambda = {
|
val lambda = {
|
||||||
println(str)
|
sb.appendLine(str)
|
||||||
}
|
}
|
||||||
|
|
||||||
lambda()
|
lambda()
|
||||||
|
|
||||||
str = "changed"
|
str = "changed"
|
||||||
lambda()
|
lambda()
|
||||||
|
|
||||||
|
assertEquals("""
|
||||||
|
original
|
||||||
|
changed
|
||||||
|
|
||||||
|
""".trimIndent(), sb.toString())
|
||||||
|
return "OK"
|
||||||
}
|
}
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
original
|
|
||||||
changed
|
|
||||||
+12
-5
@@ -3,18 +3,25 @@
|
|||||||
* that can be found in the LICENSE file.
|
* that can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package codegen.lambda.lambda11
|
|
||||||
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
@Test fun runTest() {
|
val sb = StringBuilder()
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
val first = "first"
|
val first = "first"
|
||||||
val second = "second"
|
val second = "second"
|
||||||
|
|
||||||
run {
|
run {
|
||||||
println(first)
|
sb.appendLine(first)
|
||||||
println(second)
|
sb.appendLine(second)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assertEquals("""
|
||||||
|
first
|
||||||
|
second
|
||||||
|
|
||||||
|
""".trimIndent(), sb.toString())
|
||||||
|
return "OK"
|
||||||
}
|
}
|
||||||
|
|
||||||
fun run(f: () -> Unit) {
|
fun run(f: () -> Unit) {
|
||||||
|
|||||||
@@ -1,2 +0,0 @@
|
|||||||
first
|
|
||||||
second
|
|
||||||
+12
-5
@@ -3,15 +3,22 @@
|
|||||||
* that can be found in the LICENSE file.
|
* that can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package codegen.lambda.lambda12
|
|
||||||
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
@Test fun runTest() {
|
val sb = StringBuilder()
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
val lambda = { s1: String, s2: String ->
|
val lambda = { s1: String, s2: String ->
|
||||||
println(s1)
|
sb.appendLine(s1)
|
||||||
println(s2)
|
sb.appendLine(s2)
|
||||||
}
|
}
|
||||||
|
|
||||||
lambda("one", "two")
|
lambda("one", "two")
|
||||||
|
|
||||||
|
assertEquals("""
|
||||||
|
one
|
||||||
|
two
|
||||||
|
|
||||||
|
""".trimIndent(), sb.toString())
|
||||||
|
return "OK"
|
||||||
}
|
}
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
one
|
|
||||||
two
|
|
||||||
+6
-5
@@ -3,14 +3,15 @@
|
|||||||
* that can be found in the LICENSE file.
|
* that can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package codegen.lambda.lambda13
|
|
||||||
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
@Test fun runTest() {
|
val sb = StringBuilder()
|
||||||
apply("foo") {
|
|
||||||
println(this)
|
fun box(): String {
|
||||||
|
apply("OK") {
|
||||||
|
sb.append(this)
|
||||||
}
|
}
|
||||||
|
return sb.toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun apply(str: String, block: String.() -> Unit) {
|
fun apply(str: String, block: String.() -> Unit) {
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
foo
|
|
||||||
+3
-5
@@ -5,19 +5,17 @@
|
|||||||
|
|
||||||
// FILE: 1.kt
|
// FILE: 1.kt
|
||||||
|
|
||||||
package codegen.lambda.lambda14
|
|
||||||
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
@Test fun runTest() {
|
fun box(): String {
|
||||||
assertEquals(foo()(), "foo1")
|
assertEquals(foo()(), "foo1")
|
||||||
assertEquals(foo(0)(), "foo2")
|
assertEquals(foo(0)(), "foo2")
|
||||||
|
|
||||||
|
return "OK"
|
||||||
}
|
}
|
||||||
|
|
||||||
fun foo() = { "foo1" }
|
fun foo() = { "foo1" }
|
||||||
|
|
||||||
// FILE: 2.kt
|
// FILE: 2.kt
|
||||||
|
|
||||||
package codegen.lambda.lambda14
|
|
||||||
|
|
||||||
fun foo(ignored: Int) = { "foo2" }
|
fun foo(ignored: Int) = { "foo2" }
|
||||||
|
|||||||
+6
-5
@@ -3,17 +3,18 @@
|
|||||||
* that can be found in the LICENSE file.
|
* that can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package codegen.lambda.lambda2
|
|
||||||
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
@Test fun runTest() {
|
val sb = StringBuilder()
|
||||||
main(arrayOf("arg0"))
|
|
||||||
|
fun box(): String {
|
||||||
|
main(arrayOf("OK"))
|
||||||
|
return sb.toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun main(args : Array<String>) {
|
fun main(args : Array<String>) {
|
||||||
run {
|
run {
|
||||||
println(args[0])
|
sb.append(args[0])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
arg0
|
|
||||||
+6
-5
@@ -3,15 +3,16 @@
|
|||||||
* that can be found in the LICENSE file.
|
* that can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package codegen.lambda.lambda3
|
|
||||||
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
@Test fun runTest() {
|
val sb = StringBuilder()
|
||||||
var str = "lambda"
|
|
||||||
|
fun box(): String {
|
||||||
|
var str = "OK"
|
||||||
run {
|
run {
|
||||||
println(str)
|
sb.append(str)
|
||||||
}
|
}
|
||||||
|
return sb.toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun run(f: () -> Unit) {
|
fun run(f: () -> Unit) {
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
lambda
|
|
||||||
+15
-5
@@ -3,21 +3,31 @@
|
|||||||
* that can be found in the LICENSE file.
|
* that can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package codegen.lambda.lambda4
|
|
||||||
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
@Test fun runTest() {
|
val sb = StringBuilder()
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
val lambda = bar()
|
val lambda = bar()
|
||||||
lambda()
|
lambda()
|
||||||
lambda()
|
lambda()
|
||||||
|
|
||||||
|
assertEquals("""
|
||||||
|
1
|
||||||
|
2
|
||||||
|
3
|
||||||
|
3
|
||||||
|
4
|
||||||
|
|
||||||
|
""".trimIndent(), sb.toString())
|
||||||
|
return "OK"
|
||||||
}
|
}
|
||||||
|
|
||||||
fun bar(): () -> Unit {
|
fun bar(): () -> Unit {
|
||||||
var x = Integer(0)
|
var x = Integer(0)
|
||||||
|
|
||||||
val lambda = {
|
val lambda = {
|
||||||
println(x.toString())
|
sb.appendLine(x.toString())
|
||||||
x = x + 1
|
x = x + 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -26,7 +36,7 @@ fun bar(): () -> Unit {
|
|||||||
lambda()
|
lambda()
|
||||||
lambda()
|
lambda()
|
||||||
|
|
||||||
println(x.toString())
|
sb.appendLine(x.toString())
|
||||||
|
|
||||||
return lambda
|
return lambda
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
1
|
|
||||||
2
|
|
||||||
3
|
|
||||||
3
|
|
||||||
4
|
|
||||||
+7
-4
@@ -3,14 +3,17 @@
|
|||||||
* that can be found in the LICENSE file.
|
* that can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package codegen.lambda.lambda5
|
|
||||||
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
@Test fun runTest() {
|
val sb = StringBuilder()
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
foo {
|
foo {
|
||||||
println(it)
|
sb.append(it)
|
||||||
}
|
}
|
||||||
|
assertEquals("42", sb.toString())
|
||||||
|
return "OK"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun foo(f: (Int) -> Unit) {
|
fun foo(f: (Int) -> Unit) {
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
42
|
|
||||||
+12
-5
@@ -3,16 +3,23 @@
|
|||||||
* that can be found in the LICENSE file.
|
* that can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package codegen.lambda.lambda6
|
|
||||||
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
@Test fun runTest() {
|
val sb = StringBuilder()
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
val str = "captured"
|
val str = "captured"
|
||||||
foo {
|
foo {
|
||||||
println(it)
|
sb.appendLine(it)
|
||||||
println(str)
|
sb.appendLine(str)
|
||||||
}
|
}
|
||||||
|
assertEquals("""
|
||||||
|
42
|
||||||
|
captured
|
||||||
|
|
||||||
|
""".trimIndent(), sb.toString())
|
||||||
|
return "OK"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun foo(f: (Int) -> Unit) {
|
fun foo(f: (Int) -> Unit) {
|
||||||
|
|||||||
@@ -1,2 +0,0 @@
|
|||||||
42
|
|
||||||
captured
|
|
||||||
+3
-4
@@ -3,15 +3,14 @@
|
|||||||
* that can be found in the LICENSE file.
|
* that can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package codegen.lambda.lambda7
|
|
||||||
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
@Test fun runTest() {
|
fun box(): String {
|
||||||
val x = foo {
|
val x = foo {
|
||||||
it + 1
|
it + 1
|
||||||
}
|
}
|
||||||
println(x)
|
assertEquals(43, x)
|
||||||
|
return "OK"
|
||||||
}
|
}
|
||||||
|
|
||||||
fun foo(f: (Int) -> Int) = f(42)
|
fun foo(f: (Int) -> Int) = f(42)
|
||||||
@@ -1 +0,0 @@
|
|||||||
43
|
|
||||||
+18
-5
@@ -3,11 +3,11 @@
|
|||||||
* that can be found in the LICENSE file.
|
* that can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package codegen.lambda.lambda8
|
|
||||||
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
@Test fun runTest() {
|
val sb = StringBuilder()
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
val lambda1 = bar("first")
|
val lambda1 = bar("first")
|
||||||
val lambda2 = bar("second")
|
val lambda2 = bar("second")
|
||||||
|
|
||||||
@@ -15,14 +15,27 @@ import kotlin.test.*
|
|||||||
lambda2()
|
lambda2()
|
||||||
lambda1()
|
lambda1()
|
||||||
lambda2()
|
lambda2()
|
||||||
|
|
||||||
|
assertEquals("""
|
||||||
|
first
|
||||||
|
0
|
||||||
|
second
|
||||||
|
0
|
||||||
|
first
|
||||||
|
1
|
||||||
|
second
|
||||||
|
1
|
||||||
|
|
||||||
|
""".trimIndent(), sb.toString())
|
||||||
|
return "OK"
|
||||||
}
|
}
|
||||||
|
|
||||||
fun bar(str: String): () -> Unit {
|
fun bar(str: String): () -> Unit {
|
||||||
var x = Integer(0)
|
var x = Integer(0)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
println(str)
|
sb.appendLine(str)
|
||||||
println(x.toString())
|
sb.appendLine(x.toString())
|
||||||
x = x + 1
|
x = x + 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
first
|
|
||||||
0
|
|
||||||
second
|
|
||||||
0
|
|
||||||
first
|
|
||||||
1
|
|
||||||
second
|
|
||||||
1
|
|
||||||
+18
-5
@@ -3,11 +3,11 @@
|
|||||||
* that can be found in the LICENSE file.
|
* that can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package codegen.lambda.lambda9
|
|
||||||
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
@Test fun runTest() {
|
val sb = StringBuilder()
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
val lambdas = ArrayList<() -> Unit>()
|
val lambdas = ArrayList<() -> Unit>()
|
||||||
|
|
||||||
for (i in 0..1) {
|
for (i in 0..1) {
|
||||||
@@ -15,8 +15,8 @@ import kotlin.test.*
|
|||||||
val istr = i.toString()
|
val istr = i.toString()
|
||||||
|
|
||||||
lambdas.add {
|
lambdas.add {
|
||||||
println(istr)
|
sb.appendLine(istr)
|
||||||
println(x.toString())
|
sb.appendLine(x.toString())
|
||||||
x = x + 1
|
x = x + 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -28,6 +28,19 @@ import kotlin.test.*
|
|||||||
lambda2()
|
lambda2()
|
||||||
lambda1()
|
lambda1()
|
||||||
lambda2()
|
lambda2()
|
||||||
|
|
||||||
|
assertEquals("""
|
||||||
|
0
|
||||||
|
0
|
||||||
|
1
|
||||||
|
0
|
||||||
|
0
|
||||||
|
1
|
||||||
|
1
|
||||||
|
1
|
||||||
|
|
||||||
|
""".trimIndent(), sb.toString())
|
||||||
|
return "OK"
|
||||||
}
|
}
|
||||||
|
|
||||||
class Integer(val value: Int) {
|
class Integer(val value: Int) {
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
0
|
|
||||||
0
|
|
||||||
1
|
|
||||||
0
|
|
||||||
0
|
|
||||||
1
|
|
||||||
1
|
|
||||||
1
|
|
||||||
@@ -5,6 +5,8 @@ import kotlin.coroutines.*
|
|||||||
|
|
||||||
// https://youtrack.jetbrains.com/issue/KT-49360
|
// https://youtrack.jetbrains.com/issue/KT-49360
|
||||||
|
|
||||||
|
class Block(val block: () -> Int)
|
||||||
|
|
||||||
// The Flow code below is taken from kotlinx.coroutines (some unrelated details removed).
|
// The Flow code below is taken from kotlinx.coroutines (some unrelated details removed).
|
||||||
|
|
||||||
interface FlowCollector<in T> {
|
interface FlowCollector<in T> {
|
||||||
|
|||||||
@@ -3,18 +3,25 @@
|
|||||||
* that can be found in the LICENSE file.
|
* that can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package codegen.lateinit.globalIsInitialized
|
|
||||||
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
|
val sb = StringBuilder()
|
||||||
|
|
||||||
lateinit var s: String
|
lateinit var s: String
|
||||||
|
|
||||||
fun foo() {
|
fun foo() {
|
||||||
println(::s.isInitialized)
|
sb.appendLine(::s.isInitialized)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun runTest() {
|
fun box(): String {
|
||||||
foo()
|
foo()
|
||||||
s = "zzz"
|
s = "zzz"
|
||||||
foo()
|
foo()
|
||||||
|
|
||||||
|
assertEquals("""
|
||||||
|
false
|
||||||
|
true
|
||||||
|
|
||||||
|
""".trimIndent(), sb.toString())
|
||||||
|
return "OK"
|
||||||
}
|
}
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
false
|
|
||||||
true
|
|
||||||
@@ -3,8 +3,6 @@
|
|||||||
* that can be found in the LICENSE file.
|
* that can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package codegen.lateinit.inBaseClass
|
|
||||||
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
class A(val a: Int)
|
class A(val a: Int)
|
||||||
@@ -17,8 +15,10 @@ class C: B() {
|
|||||||
fun foo() { a = A(42) }
|
fun foo() { a = A(42) }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun runTest() {
|
fun box(): String {
|
||||||
val c = C()
|
val c = C()
|
||||||
c.foo()
|
c.foo()
|
||||||
println(c.a.a)
|
assertEquals(42, c.a.a)
|
||||||
|
|
||||||
|
return "OK"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
42
|
|
||||||
@@ -3,8 +3,6 @@
|
|||||||
* that can be found in the LICENSE file.
|
* that can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package codegen.lateinit.initialized
|
|
||||||
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
class A {
|
class A {
|
||||||
@@ -13,8 +11,8 @@ class A {
|
|||||||
fun foo() = s
|
fun foo() = s
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun runTest() {
|
fun box(): String {
|
||||||
val a = A()
|
val a = A()
|
||||||
a.s = "zzz"
|
a.s = "OK"
|
||||||
println(a.foo())
|
return a.foo()
|
||||||
}
|
}
|
||||||
@@ -1 +0,0 @@
|
|||||||
zzz
|
|
||||||
@@ -3,8 +3,6 @@
|
|||||||
* that can be found in the LICENSE file.
|
* that can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package codegen.lateinit.innerIsInitialized
|
|
||||||
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
open class Foo {
|
open class Foo {
|
||||||
@@ -23,6 +21,6 @@ open class Foo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun runTest() {
|
fun box(): String {
|
||||||
println(Foo().test())
|
return Foo().test()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
OK
|
|
||||||
@@ -3,21 +3,28 @@
|
|||||||
* that can be found in the LICENSE file.
|
* that can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package codegen.lateinit.isInitialized
|
|
||||||
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
|
val sb = StringBuilder()
|
||||||
|
|
||||||
class A {
|
class A {
|
||||||
lateinit var s: String
|
lateinit var s: String
|
||||||
|
|
||||||
fun foo() {
|
fun foo() {
|
||||||
println(::s.isInitialized)
|
sb.appendLine(::s.isInitialized)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun runTest() {
|
fun box(): String {
|
||||||
val a = A()
|
val a = A()
|
||||||
a.foo()
|
a.foo()
|
||||||
a.s = "zzz"
|
a.s = "zzz"
|
||||||
a.foo()
|
a.foo()
|
||||||
|
|
||||||
|
assertEquals("""
|
||||||
|
false
|
||||||
|
true
|
||||||
|
|
||||||
|
""".trimIndent(), sb.toString())
|
||||||
|
return "OK"
|
||||||
}
|
}
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
false
|
|
||||||
true
|
|
||||||
@@ -3,15 +3,13 @@
|
|||||||
* that can be found in the LICENSE file.
|
* that can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package codegen.lateinit.localCapturedInitialized
|
|
||||||
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
@Test fun runTest() {
|
fun box(): String {
|
||||||
lateinit var s: String
|
lateinit var s: String
|
||||||
|
|
||||||
fun foo() = s
|
fun foo() = s
|
||||||
|
|
||||||
s = "zzz"
|
s = "OK"
|
||||||
println(foo())
|
return foo()
|
||||||
}
|
}
|
||||||
@@ -1 +0,0 @@
|
|||||||
zzz
|
|
||||||
+7
-7
@@ -3,21 +3,21 @@
|
|||||||
* that can be found in the LICENSE file.
|
* that can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package codegen.lateinit.localCapturedNotInitialized
|
|
||||||
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
@Test fun runTest() {
|
val sb = StringBuilder()
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
lateinit var s: String
|
lateinit var s: String
|
||||||
|
|
||||||
fun foo() = s
|
fun foo() = s
|
||||||
|
|
||||||
try {
|
try {
|
||||||
println(foo())
|
sb.appendLine(foo())
|
||||||
}
|
}
|
||||||
catch (e: RuntimeException) {
|
catch (e: RuntimeException) {
|
||||||
println("OK")
|
sb.append("OK")
|
||||||
return
|
return sb.toString()
|
||||||
}
|
}
|
||||||
println("Fail")
|
return "Fail"
|
||||||
}
|
}
|
||||||
@@ -1 +0,0 @@
|
|||||||
OK
|
|
||||||
@@ -3,12 +3,10 @@
|
|||||||
* that can be found in the LICENSE file.
|
* that can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package codegen.lateinit.localInitialized
|
|
||||||
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
@Test fun runTest() {
|
fun box(): String {
|
||||||
lateinit var s: String
|
lateinit var s: String
|
||||||
s = "zzz"
|
s = "OK"
|
||||||
println(s)
|
return s
|
||||||
}
|
}
|
||||||
@@ -1 +0,0 @@
|
|||||||
zzz
|
|
||||||
@@ -3,19 +3,19 @@
|
|||||||
* that can be found in the LICENSE file.
|
* that can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package codegen.lateinit.localNotInitialized
|
|
||||||
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
@Test fun runTest() {
|
val sb = StringBuilder()
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
lateinit var s: String
|
lateinit var s: String
|
||||||
|
|
||||||
try {
|
try {
|
||||||
println(s)
|
sb.appendLine(s)
|
||||||
}
|
}
|
||||||
catch (e: RuntimeException) {
|
catch (e: RuntimeException) {
|
||||||
println("OK")
|
sb.append("OK")
|
||||||
return
|
return sb.toString()
|
||||||
}
|
}
|
||||||
println("Fail")
|
return "Fail"
|
||||||
}
|
}
|
||||||
@@ -1 +0,0 @@
|
|||||||
OK
|
|
||||||
@@ -3,8 +3,6 @@
|
|||||||
* that can be found in the LICENSE file.
|
* that can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package codegen.lateinit.notInitialized
|
|
||||||
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
class A {
|
class A {
|
||||||
@@ -13,14 +11,16 @@ class A {
|
|||||||
fun foo() = s
|
fun foo() = s
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun runTest() {
|
val sb = StringBuilder()
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
val a = A()
|
val a = A()
|
||||||
try {
|
try {
|
||||||
println(a.foo())
|
sb.appendLine(a.foo())
|
||||||
}
|
}
|
||||||
catch (e: RuntimeException) {
|
catch (e: RuntimeException) {
|
||||||
println("OK")
|
sb.append("OK")
|
||||||
return
|
return sb.toString()
|
||||||
}
|
}
|
||||||
println("Fail")
|
return "Fail"
|
||||||
}
|
}
|
||||||
@@ -1 +0,0 @@
|
|||||||
OK
|
|
||||||
+11
-8
@@ -3,11 +3,11 @@
|
|||||||
* that can be found in the LICENSE file.
|
* that can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package codegen.localClass.innerTakesCapturedFromOuter
|
|
||||||
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
fun box() {
|
val sb = StringBuilder()
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
var previous: Any? = null
|
var previous: Any? = null
|
||||||
for (i in 0 .. 2) {
|
for (i in 0 .. 2) {
|
||||||
class Outer {
|
class Outer {
|
||||||
@@ -17,11 +17,14 @@ fun box() {
|
|||||||
|
|
||||||
override fun toString() = Inner().toString()
|
override fun toString() = Inner().toString()
|
||||||
}
|
}
|
||||||
if (previous != null) println(previous.toString())
|
if (previous != null) sb.appendLine(previous.toString())
|
||||||
previous = Outer()
|
previous = Outer()
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Test fun runTest() {
|
assertEquals("""
|
||||||
box()
|
0
|
||||||
}
|
1
|
||||||
|
|
||||||
|
""".trimIndent(), sb.toString())
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
|
|||||||
-2
@@ -1,2 +0,0 @@
|
|||||||
0
|
|
||||||
1
|
|
||||||
@@ -3,8 +3,6 @@
|
|||||||
* that can be found in the LICENSE file.
|
* that can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package codegen.localClass.innerWithCapture
|
|
||||||
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
fun box(s: String): String {
|
fun box(s: String): String {
|
||||||
@@ -17,6 +15,6 @@ fun box(s: String): String {
|
|||||||
return Local().Inner().result()
|
return Local().Inner().result()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun runTest() {
|
fun box(): String {
|
||||||
println(box("OK"))
|
return box("OK")
|
||||||
}
|
}
|
||||||
@@ -1 +0,0 @@
|
|||||||
OK
|
|
||||||
+2
-4
@@ -3,11 +3,9 @@
|
|||||||
* that can be found in the LICENSE file.
|
* that can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package codegen.localClass.localFunctionCallFromLocalClass
|
|
||||||
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
@Test fun runTest() {
|
fun box(): String {
|
||||||
var x = 1
|
var x = 1
|
||||||
fun local1() {
|
fun local1() {
|
||||||
x++
|
x++
|
||||||
@@ -19,5 +17,5 @@ import kotlin.test.*
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
A().bar()
|
A().bar()
|
||||||
println("OK")
|
return "OK"
|
||||||
}
|
}
|
||||||
-1
@@ -1 +0,0 @@
|
|||||||
OK
|
|
||||||
+2
-4
@@ -3,11 +3,9 @@
|
|||||||
* that can be found in the LICENSE file.
|
* that can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package codegen.localClass.localFunctionInLocalClass
|
|
||||||
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
@Test fun runTest() {
|
fun box(): String {
|
||||||
var x = 0
|
var x = 0
|
||||||
class A {
|
class A {
|
||||||
fun bar() {
|
fun bar() {
|
||||||
@@ -26,5 +24,5 @@ import kotlin.test.*
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
A().bar()
|
A().bar()
|
||||||
println("OK")
|
return "OK"
|
||||||
}
|
}
|
||||||
@@ -1 +0,0 @@
|
|||||||
OK
|
|
||||||
@@ -3,8 +3,6 @@
|
|||||||
* that can be found in the LICENSE file.
|
* that can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package codegen.localClass.localHierarchy
|
|
||||||
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
fun foo(s: String): String {
|
fun foo(s: String): String {
|
||||||
@@ -19,6 +17,6 @@ fun foo(s: String): String {
|
|||||||
return Derived().g()
|
return Derived().g()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun runTest() {
|
fun box(): String {
|
||||||
println(foo("OK"))
|
return foo("OK")
|
||||||
}
|
}
|
||||||
@@ -1 +0,0 @@
|
|||||||
OK
|
|
||||||
@@ -3,8 +3,6 @@
|
|||||||
* that can be found in the LICENSE file.
|
* that can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package codegen.localClass.noPrimaryConstructor
|
|
||||||
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
fun box(s: String): String {
|
fun box(s: String): String {
|
||||||
@@ -25,6 +23,7 @@ fun box(s: String): String {
|
|||||||
return Local(42).result() + Local("zzz").result()
|
return Local(42).result() + Local("zzz").result()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun runTest() {
|
fun box(): String {
|
||||||
println(box("OK"))
|
assertEquals("OKOK", box("OK"))
|
||||||
|
return "OK"
|
||||||
}
|
}
|
||||||
@@ -1 +0,0 @@
|
|||||||
OKOK
|
|
||||||
-6
@@ -3,8 +3,6 @@
|
|||||||
* that can be found in the LICENSE file.
|
* that can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package codegen.localClass.objectExpressionInInitializer
|
|
||||||
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
abstract class Father {
|
abstract class Father {
|
||||||
@@ -28,7 +26,3 @@ class Child : Father() {
|
|||||||
fun box(): String {
|
fun box(): String {
|
||||||
return Child().ChildInClass.work()
|
return Child().ChildInClass.work()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun runTest() {
|
|
||||||
println(box())
|
|
||||||
}
|
|
||||||
-1
@@ -1 +0,0 @@
|
|||||||
OK
|
|
||||||
@@ -3,8 +3,6 @@
|
|||||||
* that can be found in the LICENSE file.
|
* that can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package codegen.localClass.objectExpressionInProperty
|
|
||||||
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
abstract class Father {
|
abstract class Father {
|
||||||
@@ -24,7 +22,3 @@ class Child : Father() {
|
|||||||
fun box(): String {
|
fun box(): String {
|
||||||
return Child().ChildInClass.work()
|
return Child().ChildInClass.work()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun runTest() {
|
|
||||||
println(box())
|
|
||||||
}
|
|
||||||
-1
@@ -1 +0,0 @@
|
|||||||
OK
|
|
||||||
@@ -3,23 +3,25 @@
|
|||||||
* that can be found in the LICENSE file.
|
* that can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package codegen.localClass.tryCatch
|
|
||||||
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
|
val sb = StringBuilder()
|
||||||
|
|
||||||
private fun foo() {
|
private fun foo() {
|
||||||
val local =
|
val local =
|
||||||
object {
|
object {
|
||||||
fun bar() {
|
fun bar() {
|
||||||
try {
|
try {
|
||||||
} catch (t: Throwable) {
|
} catch (t: Throwable) {
|
||||||
println(t)
|
sb.appendLine(t)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
local.bar()
|
local.bar()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun runTest() {
|
fun box(): String {
|
||||||
|
sb.append("OK")
|
||||||
foo()
|
foo()
|
||||||
|
return sb.toString()
|
||||||
}
|
}
|
||||||
@@ -3,8 +3,6 @@
|
|||||||
* that can be found in the LICENSE file.
|
* that can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package codegen.localClass.virtualCallFromConstructor
|
|
||||||
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
abstract class WaitFor {
|
abstract class WaitFor {
|
||||||
@@ -28,7 +26,3 @@ fun box(): String {
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun runTest() {
|
|
||||||
println(box())
|
|
||||||
}
|
|
||||||
-1
@@ -1 +0,0 @@
|
|||||||
OK
|
|
||||||
+36
-10
@@ -2,6 +2,9 @@
|
|||||||
* Copyright 2010-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
* Copyright 2010-2020 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.
|
* that can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
import kotlin.test.*
|
||||||
|
|
||||||
|
val sb = StringBuilder()
|
||||||
|
|
||||||
class ArraysConstructor {
|
class ArraysConstructor {
|
||||||
private val memberArray: IntArray
|
private val memberArray: IntArray
|
||||||
@@ -14,9 +17,9 @@ class ArraysConstructor {
|
|||||||
memberArray[1] = int2
|
memberArray[1] = int2
|
||||||
}
|
}
|
||||||
fun log() {
|
fun log() {
|
||||||
println("Array (constructor init):")
|
sb.appendLine("Array (constructor init):")
|
||||||
println("Size: ${memberArray.size}")
|
sb.appendLine("Size: ${memberArray.size}")
|
||||||
println("Contents: ${memberArray.contentToString()}")
|
sb.appendLine("Contents: ${memberArray.contentToString()}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,9 +33,9 @@ class ArraysDefault {
|
|||||||
memberArray[1] = int2
|
memberArray[1] = int2
|
||||||
}
|
}
|
||||||
fun log() {
|
fun log() {
|
||||||
println("Array (default value init):")
|
sb.appendLine("Array (default value init):")
|
||||||
println("Size: ${memberArray.size}")
|
sb.appendLine("Size: ${memberArray.size}")
|
||||||
println("Contents: ${memberArray.contentToString()}")
|
sb.appendLine("Contents: ${memberArray.contentToString()}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,13 +52,13 @@ class ArraysInitBlock {
|
|||||||
memberArray[1] = int2
|
memberArray[1] = int2
|
||||||
}
|
}
|
||||||
fun log() {
|
fun log() {
|
||||||
println("Array (init block):")
|
sb.appendLine("Array (init block):")
|
||||||
println("Size: ${memberArray.size}")
|
sb.appendLine("Size: ${memberArray.size}")
|
||||||
println("Contents: ${memberArray.contentToString()}")
|
sb.appendLine("Contents: ${memberArray.contentToString()}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun main() {
|
fun box(): String {
|
||||||
val array1 = (::ArraysConstructor)(1, 2)
|
val array1 = (::ArraysConstructor)(1, 2)
|
||||||
array1.log()
|
array1.log()
|
||||||
array1.set( 3, 4)
|
array1.set( 3, 4)
|
||||||
@@ -70,4 +73,27 @@ fun main() {
|
|||||||
array3.log()
|
array3.log()
|
||||||
array3.set( 3, 4)
|
array3.set( 3, 4)
|
||||||
array3.log()
|
array3.log()
|
||||||
|
|
||||||
|
assertEquals("""
|
||||||
|
Array (constructor init):
|
||||||
|
Size: 2
|
||||||
|
Contents: [1, 2]
|
||||||
|
Array (constructor init):
|
||||||
|
Size: 2
|
||||||
|
Contents: [3, 4]
|
||||||
|
Array (default value init):
|
||||||
|
Size: 2
|
||||||
|
Contents: [1, 2]
|
||||||
|
Array (default value init):
|
||||||
|
Size: 2
|
||||||
|
Contents: [3, 4]
|
||||||
|
Array (init block):
|
||||||
|
Size: 2
|
||||||
|
Contents: [1, 2]
|
||||||
|
Array (init block):
|
||||||
|
Size: 2
|
||||||
|
Contents: [3, 4]
|
||||||
|
|
||||||
|
""".trimIndent(), sb.toString())
|
||||||
|
return "OK"
|
||||||
}
|
}
|
||||||
-18
@@ -1,18 +0,0 @@
|
|||||||
Array (constructor init):
|
|
||||||
Size: 2
|
|
||||||
Contents: [1, 2]
|
|
||||||
Array (constructor init):
|
|
||||||
Size: 2
|
|
||||||
Contents: [3, 4]
|
|
||||||
Array (default value init):
|
|
||||||
Size: 2
|
|
||||||
Contents: [1, 2]
|
|
||||||
Array (default value init):
|
|
||||||
Size: 2
|
|
||||||
Contents: [3, 4]
|
|
||||||
Array (init block):
|
|
||||||
Size: 2
|
|
||||||
Contents: [1, 2]
|
|
||||||
Array (init block):
|
|
||||||
Size: 2
|
|
||||||
Contents: [3, 4]
|
|
||||||
@@ -3,8 +3,6 @@
|
|||||||
* that can be found in the LICENSE file.
|
* that can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package codegen.`object`.constructor0
|
|
||||||
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
class A {
|
class A {
|
||||||
@@ -13,3 +11,8 @@ class A {
|
|||||||
field0 = arg0
|
field0 = arg0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
assertEquals(42, A(42).field0)
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
|
|||||||
+6
-6
@@ -3,8 +3,6 @@
|
|||||||
* that can be found in the LICENSE file.
|
* that can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package codegen.`object`.fields
|
|
||||||
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
private var globalValue = 1
|
private var globalValue = 1
|
||||||
@@ -18,8 +16,10 @@ fun globalTest(i:Int):Int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test fun runTest() {
|
fun box(): String {
|
||||||
if (global != 1) throw Error()
|
assertEquals(1, global)
|
||||||
if (globalTest(41) != 42) throw Error()
|
assertEquals(42, globalTest(41))
|
||||||
if (global != 42) throw Error()
|
assertEquals(42, global)
|
||||||
|
|
||||||
|
return "OK"
|
||||||
}
|
}
|
||||||
+6
-5
@@ -3,8 +3,6 @@
|
|||||||
* that can be found in the LICENSE file.
|
* that can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package codegen.`object`.fields1
|
|
||||||
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
class B(val a:Int, b:Int) {
|
class B(val a:Int, b:Int) {
|
||||||
@@ -16,7 +14,10 @@ fun primaryConstructorCall(a:Int, b:Int) = B(a, b).pos
|
|||||||
|
|
||||||
fun secondaryConstructorCall(a:Int) = B(a).pos
|
fun secondaryConstructorCall(a:Int) = B(a).pos
|
||||||
|
|
||||||
@Test fun runTest() {
|
fun box(): String {
|
||||||
if (primaryConstructorCall(0xdeadbeef.toInt(), 41) != 42) throw Error()
|
assertEquals(42, primaryConstructorCall(0xdeadbeef.toInt(), 41))
|
||||||
if (secondaryConstructorCall(41) != 42) throw Error()
|
assertEquals(42, secondaryConstructorCall(41))
|
||||||
|
|
||||||
|
return "OK"
|
||||||
|
|
||||||
}
|
}
|
||||||
+18
-22
@@ -3,33 +3,33 @@
|
|||||||
* that can be found in the LICENSE file.
|
* that can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package codegen.`object`.fields2
|
|
||||||
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
|
val sb = StringBuilder()
|
||||||
|
|
||||||
var global: Int = 0
|
var global: Int = 0
|
||||||
get() {
|
get() {
|
||||||
println("Get global = $field")
|
sb.appendLine("Get global = $field")
|
||||||
return field
|
return field
|
||||||
}
|
}
|
||||||
set(value) {
|
set(value) {
|
||||||
println("Set global = $value")
|
sb.appendLine("Set global = $value")
|
||||||
field = value
|
field = value
|
||||||
}
|
}
|
||||||
|
|
||||||
class TestClass {
|
class TestClass {
|
||||||
var member: Int = 0
|
var member: Int = 0
|
||||||
get() {
|
get() {
|
||||||
println("Get member = $field")
|
sb.appendLine("Get member = $field")
|
||||||
return field
|
return field
|
||||||
}
|
}
|
||||||
set(value) {
|
set(value) {
|
||||||
println("Set member = $value")
|
sb.appendLine("Set member = $value")
|
||||||
field = value
|
field = value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun runTest1() {
|
fun box(): String {
|
||||||
global = 1
|
global = 1
|
||||||
|
|
||||||
val test = TestClass()
|
val test = TestClass()
|
||||||
@@ -37,19 +37,15 @@ class TestClass {
|
|||||||
|
|
||||||
global = test.member
|
global = test.member
|
||||||
test.member = global
|
test.member = global
|
||||||
}
|
|
||||||
|
assertEquals("""
|
||||||
@ThreadLocal
|
Set global = 1
|
||||||
val xInt = 42
|
Set member = 42
|
||||||
|
Get member = 42
|
||||||
@ThreadLocal
|
Set global = 42
|
||||||
val xString = "42"
|
Get global = 42
|
||||||
|
Set member = 42
|
||||||
@ThreadLocal
|
|
||||||
val xAny = Any()
|
""".trimIndent(), sb.toString())
|
||||||
|
return "OK"
|
||||||
@Test fun runTest2() {
|
|
||||||
assertEquals(42, xInt)
|
|
||||||
assertEquals("42", xString)
|
|
||||||
assertTrue(xAny is Any)
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
Set global = 1
|
|
||||||
Set member = 42
|
|
||||||
Get member = 42
|
|
||||||
Set global = 42
|
|
||||||
Get global = 42
|
|
||||||
Set member = 42
|
|
||||||
@@ -9,4 +9,9 @@ public val z: Any = Z
|
|||||||
|
|
||||||
private object Z
|
private object Z
|
||||||
|
|
||||||
fun main(args: Array<String>) { }
|
fun box(): String {
|
||||||
|
if (z is Z)
|
||||||
|
return "OK"
|
||||||
|
else
|
||||||
|
return "FAIL"
|
||||||
|
}
|
||||||
|
|||||||
+7
-2
@@ -3,8 +3,6 @@
|
|||||||
* that can be found in the LICENSE file.
|
* that can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package codegen.`object`.init0
|
|
||||||
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
class A(a:Int) {
|
class A(a:Int) {
|
||||||
@@ -12,4 +10,11 @@ class A(a:Int) {
|
|||||||
init {
|
init {
|
||||||
if (a == 0) i = 1
|
if (a == 0) i = 1
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
assertEquals(1, A(0).i)
|
||||||
|
assertEquals(0, A(1).i)
|
||||||
|
|
||||||
|
return "OK"
|
||||||
}
|
}
|
||||||
@@ -3,8 +3,6 @@
|
|||||||
* that can be found in the LICENSE file.
|
* that can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package codegen.`object`.initialization
|
|
||||||
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
open class A(val a:Int, val b:Int)
|
open class A(val a:Int, val b:Int)
|
||||||
@@ -28,6 +26,7 @@ fun foo(i:Int, j:Int):Int {
|
|||||||
return c.c
|
return c.c
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun runTest() {
|
fun box(): String {
|
||||||
if (foo(2, 3) != 5) throw Error()
|
assertEquals(5, foo(2, 3))
|
||||||
|
return "OK"
|
||||||
}
|
}
|
||||||
@@ -3,27 +3,39 @@
|
|||||||
* that can be found in the LICENSE file.
|
* that can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package codegen.`object`.initialization1
|
|
||||||
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
|
val sb = StringBuilder()
|
||||||
|
|
||||||
class TestClass {
|
class TestClass {
|
||||||
constructor() {
|
constructor() {
|
||||||
println("constructor1")
|
sb.appendLine("constructor1")
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(x: Int) : this() {
|
constructor(x: Int) : this() {
|
||||||
println("constructor2")
|
sb.appendLine("constructor2")
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
println("init")
|
sb.appendLine("init")
|
||||||
}
|
}
|
||||||
|
|
||||||
val f = println("field")
|
val f = sb.appendLine("field")
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun runTest() {
|
fun box(): String {
|
||||||
TestClass()
|
TestClass()
|
||||||
TestClass(1)
|
TestClass(1)
|
||||||
|
|
||||||
|
assertEquals("""
|
||||||
|
init
|
||||||
|
field
|
||||||
|
constructor1
|
||||||
|
init
|
||||||
|
field
|
||||||
|
constructor1
|
||||||
|
constructor2
|
||||||
|
|
||||||
|
""".trimIndent(), sb.toString())
|
||||||
|
return "OK"
|
||||||
}
|
}
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
init
|
|
||||||
field
|
|
||||||
constructor1
|
|
||||||
init
|
|
||||||
field
|
|
||||||
constructor1
|
|
||||||
constructor2
|
|
||||||
@@ -3,8 +3,6 @@
|
|||||||
* that can be found in the LICENSE file.
|
* that can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package codegen.`object`.method_call
|
|
||||||
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
class A(val a:Int) {
|
class A(val a:Int) {
|
||||||
@@ -13,6 +11,7 @@ class A(val a:Int) {
|
|||||||
|
|
||||||
fun fortyTwo() = A(41).foo(1)
|
fun fortyTwo() = A(41).foo(1)
|
||||||
|
|
||||||
@Test fun runTest() {
|
fun box(): String {
|
||||||
if (fortyTwo() != 42) throw Error()
|
assertEquals(42, fortyTwo())
|
||||||
|
return "OK"
|
||||||
}
|
}
|
||||||
@@ -3,8 +3,8 @@
|
|||||||
* that can be found in the LICENSE file.
|
* that can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@file:OptIn(FreezingIsDeprecated::class, kotlin.experimental.ExperimentalNativeApi::class)
|
//@file:OptIn(FreezingIsDeprecated::class, kotlin.experimental.ExperimentalNativeApi::class)
|
||||||
package codegen.objectDeclaration.isFrozen
|
@file:OptIn(kotlin.experimental.ExperimentalNativeApi::class)
|
||||||
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
import kotlin.native.concurrent.*
|
import kotlin.native.concurrent.*
|
||||||
@@ -13,7 +13,7 @@ object X {
|
|||||||
var value: Int = 0
|
var value: Int = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun runTest() {
|
fun box(): String {
|
||||||
if (Platform.memoryModel == MemoryModel.STRICT) {
|
if (Platform.memoryModel == MemoryModel.STRICT) {
|
||||||
assertTrue(X.isFrozen)
|
assertTrue(X.isFrozen)
|
||||||
assertFailsWith<InvalidMutabilityException> {
|
assertFailsWith<InvalidMutabilityException> {
|
||||||
@@ -25,4 +25,5 @@ object X {
|
|||||||
X.value = 42
|
X.value = 42
|
||||||
assertEquals(42, X.value)
|
assertEquals(42, X.value)
|
||||||
}
|
}
|
||||||
|
return "OK"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,11 +3,9 @@
|
|||||||
* that can be found in the LICENSE file.
|
* that can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package codegen.objectExpression.expr1
|
|
||||||
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
@Test fun runTest() {
|
fun box(): String {
|
||||||
val a = "a"
|
val a = "a"
|
||||||
|
|
||||||
val x = object {
|
val x = object {
|
||||||
@@ -18,5 +16,6 @@ import kotlin.test.*
|
|||||||
fun foo(s: String) = s + s
|
fun foo(s: String) = s + s
|
||||||
}
|
}
|
||||||
|
|
||||||
println(x.toString())
|
assertEquals("aabb", x.toString())
|
||||||
|
return "OK"
|
||||||
}
|
}
|
||||||
@@ -1 +0,0 @@
|
|||||||
aabb
|
|
||||||
@@ -3,11 +3,10 @@
|
|||||||
* that can be found in the LICENSE file.
|
* that can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package codegen.objectExpression.expr2
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
@Test fun runTest() {
|
fun box(): String {
|
||||||
val a = "a"
|
val a = "OK"
|
||||||
|
|
||||||
val x = object {
|
val x = object {
|
||||||
override fun toString(): String {
|
override fun toString(): String {
|
||||||
@@ -19,7 +18,5 @@ import kotlin.test.*
|
|||||||
fun foo(lambda: () -> String) = lambda()
|
fun foo(lambda: () -> String) = lambda()
|
||||||
}
|
}
|
||||||
|
|
||||||
print(x)
|
return x.toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun print(x: Any) = println(x.toString())
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user