[Tests] Migrate backend-independent tests from native to compiler/testData.

^KT-65979
This commit is contained in:
Vladimir Sukharev
2024-02-25 18:25:58 +01:00
committed by Space Team
parent dd9332d9e1
commit febac0dd5f
640 changed files with 68168 additions and 6313 deletions
@@ -1,18 +0,0 @@
/*
* 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.
*/
import kotlin.test.*
class A {
var field0:Int = 0;
constructor(arg0:Int) {
field0 = arg0
}
}
fun box(): String {
assertEquals(42, A(42).field0)
return "OK"
}
-25
View File
@@ -1,25 +0,0 @@
/*
* 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.
*/
import kotlin.test.*
private var globalValue = 1
var global:Int
get() = globalValue
set(value:Int) {globalValue = value}
fun globalTest(i:Int):Int {
global += i
return global
}
fun box(): String {
assertEquals(1, global)
assertEquals(42, globalTest(41))
assertEquals(42, global)
return "OK"
}
-23
View File
@@ -1,23 +0,0 @@
/*
* 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.
*/
import kotlin.test.*
class B(val a:Int, b:Int) {
constructor(pos:Int):this(1, pos) {}
val pos = b + 1
}
fun primaryConstructorCall(a:Int, b:Int) = B(a, b).pos
fun secondaryConstructorCall(a:Int) = B(a).pos
fun box(): String {
assertEquals(42, primaryConstructorCall(0xdeadbeef.toInt(), 41))
assertEquals(42, secondaryConstructorCall(41))
return "OK"
}
-51
View File
@@ -1,51 +0,0 @@
/*
* 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.
*/
import kotlin.test.*
val sb = StringBuilder()
var global: Int = 0
get() {
sb.appendLine("Get global = $field")
return field
}
set(value) {
sb.appendLine("Set global = $value")
field = value
}
class TestClass {
var member: Int = 0
get() {
sb.appendLine("Get member = $field")
return field
}
set(value) {
sb.appendLine("Set member = $value")
field = value
}
}
fun box(): String {
global = 1
val test = TestClass()
test.member = 42
global = test.member
test.member = global
assertEquals("""
Set global = 1
Set member = 42
Get member = 42
Set global = 42
Get global = 42
Set member = 42
""".trimIndent(), sb.toString())
return "OK"
}
@@ -1,17 +0,0 @@
/*
* 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.
*/
// Does not fail with TR.
public val z: Any = Z
private object Z
fun box(): String {
if (z is Z)
return "OK"
else
return "FAIL"
}
-20
View File
@@ -1,20 +0,0 @@
/*
* 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.
*/
import kotlin.test.*
class A(a:Int) {
var i:Int = 0
init {
if (a == 0) i = 1
}
}
fun box(): String {
assertEquals(1, A(0).i)
assertEquals(0, A(1).i)
return "OK"
}
@@ -1,32 +0,0 @@
/*
* 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.
*/
import kotlin.test.*
open class A(val a:Int, val b:Int)
open class B(val c:Int, d:Int):A(c, d)
open class C(i:Int, j:Int):B(i + j, 42)
class D (i: Int, j:Int) : C(i, j){
constructor(i: Int, j:Int, k:Int) : this(i, j) {
foo(i)
}
constructor():this(1, 2)
}
fun foo(i:Int) : Unit {}
fun foo(i:Int, j:Int):Int {
val c = D(i, j)
return c.c
}
fun box(): String {
assertEquals(5, foo(2, 3))
return "OK"
}
@@ -1,41 +0,0 @@
/*
* 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.
*/
import kotlin.test.*
val sb = StringBuilder()
class TestClass {
constructor() {
sb.appendLine("constructor1")
}
constructor(x: Int) : this() {
sb.appendLine("constructor2")
}
init {
sb.appendLine("init")
}
val f = sb.appendLine("field")
}
fun box(): String {
TestClass()
TestClass(1)
assertEquals("""
init
field
constructor1
init
field
constructor1
constructor2
""".trimIndent(), sb.toString())
return "OK"
}
@@ -1,17 +0,0 @@
/*
* 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.
*/
import kotlin.test.*
class A(val a:Int) {
fun foo(i:Int) = a + i
}
fun fortyTwo() = A(41).foo(1)
fun box(): String {
assertEquals(42, fortyTwo())
return "OK"
}