[K/N][tests] Move some more native tests to new testing infra

^KT-61259
This commit is contained in:
Vladimir Sukharev
2024-01-03 22:35:22 +01:00
committed by Space Team
parent 4080776fe3
commit 0a0da76a56
43 changed files with 7475 additions and 7233 deletions
@@ -0,0 +1,53 @@
/*
* 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 runtime.basic.initializers0
import kotlin.test.*
class A {
init{
println ("A::init")
}
val a = 1
companion object :B(1) {
init {
println ("A::companion")
}
fun foo() {
println("A::companion::foo")
}
}
object AObj : B(){
init {
println("A::Obj")
}
fun foo() {
println("A::AObj::foo")
}
}
}
@Test fun runTest() {
println("main")
A.foo()
A.foo()
A.AObj.foo()
A.AObj.foo()
}
open class B(val a:Int, val b:Int) {
constructor(a:Int):this (a, 0) {
println("B::constructor(" + a.toString()+ ")")
}
constructor():this(0) {
println("B::constructor()")
}
}
@@ -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 runtime.basic.initializers1
import kotlin.test.*
class TestClass {
companion object {
init {
println("Init Test")
}
}
}
@Test fun runTest() {
val t1 = TestClass()
val t2 = TestClass()
println("Done")
}
@@ -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.
*/
class A(val msg: String) {
init {
println("init $msg")
}
override fun toString(): String = msg
}
val globalValue1 = 1
val globalValue2 = A("globalValue2")
val globalValue3 = A("globalValue3")
fun main(args: Array<String>) {
println(globalValue1.toString())
println(globalValue2.toString())
println(globalValue3.toString())
}
@@ -0,0 +1,16 @@
/*
* 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 runtime.basic.initializers3
import kotlin.test.*
class Foo(val bar: Int)
var x = Foo(42)
@Test fun runTest() {
println(x.bar)
}
@@ -0,0 +1,16 @@
/*
* 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 runtime.basic.initializers4
import kotlin.test.*
const val INT_MAX_POWER_OF_TWO: Int = Int.MAX_VALUE / 2 + 1
val DOUBLE = Double.MAX_VALUE - 1.0
@Test fun runTest() {
println(INT_MAX_POWER_OF_TWO)
println(DOUBLE > 0.0)
}
@@ -0,0 +1,17 @@
/*
* 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 runtime.basic.initializers5
import kotlin.test.*
object A {
val a = 42
val b = A.a
}
@Test fun runTest() {
println(A.b)
}
@@ -0,0 +1,60 @@
/*
* 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.
*/
package runtime.basic.initializers7
import kotlin.test.*
object A {
init {
assertAUninitialized()
}
val a1 = 7
val a2 = 12
}
// Check that A is initialized dynamically.
fun assertAUninitialized() {
assertEquals(0, A.a1)
assertEquals(0, A.a2)
}
object B {
init {
assertBUninitialized()
}
val b1 = A.a2
val b2 = C.c1
}
// Check that B is initialized dynamically.
fun assertBUninitialized() {
assertEquals(0, B.b1)
assertEquals(0, B.b2)
}
object C {
init {
assertCUninitialized()
}
val c1 = 42
val c2 = A.a1
val c3 = B.b1
val c4 = B.b2
}
// Check that C is initialized dynamically.
fun assertCUninitialized() {
assertEquals(0, C.c1)
assertEquals(0, C.c2)
assertEquals(0, C.c3)
assertEquals(0, C.c4)
}
@Test fun runTest() {
assertEquals(A.a1, C.c2)
assertEquals(A.a2, C.c3)
assertEquals(C.c1, C.c4)
}
@@ -0,0 +1,14 @@
/*
* Copyright 2010-2021 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 runtime.basic.initializers8
import kotlin.test.*
var globalString = "abc"
@Test fun runTest() {
assertEquals("abc", globalString)
}