[K/N][tests] Adjust moved tests to new testing infra

^KT-61259
This commit is contained in:
Vladimir Sukharev
2024-01-03 22:37:53 +01:00
committed by Space Team
parent 0a0da76a56
commit e68bd1f04f
23 changed files with 183 additions and 123 deletions
+10 -7
View File
@@ -3,16 +3,16 @@
* that can be found in the LICENSE file.
*/
package runtime.basic.statements0
import kotlin.test.*
val sb = StringBuilder()
fun simple() {
var a = 238
a++
println(a)
sb.appendLine(a)
--a
println(a)
sb.appendLine(a)
}
class Foo() {
@@ -31,12 +31,15 @@ class Foo() {
fun fields() {
val foo = Foo()
foo.more()
println(foo.i)
sb.appendLine(foo.i)
foo.less()
println(foo.i)
sb.appendLine(foo.i)
}
@Test fun runTest() {
fun box(): String {
simple()
fields()
assertEquals("239\n238\n30\n29\n", sb.toString())
return "OK"
}
+11 -7
View File
@@ -2,8 +2,7 @@
* 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.enum_equals
// !LANGUAGE: -ProhibitComparisonOfIncompatibleEnums
import kotlin.test.*
@@ -15,8 +14,13 @@ enum class EnumB {
B
}
fun main() {
println(EnumA.A == EnumA.A)
println(EnumA.A == EnumA.B)
println(EnumA.A == EnumB.B)
}
fun box(): String {
if (!(EnumA.A == EnumA.A))
return "FAIL: A must equal A"
if (EnumA.A == EnumA.B)
return "FAIL: A.A must not equal A.B"
if (EnumA.A == EnumB.B)
return "FAIL: A.A must not equal B.B"
return "OK"
}
+16 -8
View File
@@ -3,23 +3,31 @@
* that can be found in the LICENSE file.
*/
package runtime.exceptions.catch1
import kotlin.test.*
@Test fun runTest() {
val sb = StringBuilder()
fun box(): String {
try {
println("Before")
sb.appendLine("Before")
foo()
println("After")
sb.appendLine("After")
} catch (e: Throwable) {
println("Caught Throwable")
sb.appendLine("Caught Throwable")
}
println("Done")
sb.appendLine("Done")
assertEquals("""
Before
Caught Throwable
Done
""".trimIndent(), sb.toString())
return "OK"
}
fun foo() {
throw Error("Error happens")
println("After in foo()")
sb.appendLine("After in foo()")
}
+18 -10
View File
@@ -3,27 +3,35 @@
* that can be found in the LICENSE file.
*/
package runtime.exceptions.catch2
import kotlin.test.*
@Test fun runTest() {
val sb = StringBuilder()
fun box(): String {
try {
println("Before")
sb.appendLine("Before")
foo()
println("After")
sb.appendLine("After")
} catch (e: Exception) {
println("Caught Exception")
sb.appendLine("Caught Exception")
} catch (e: Error) {
println("Caught Error")
sb.appendLine("Caught Error")
} catch (e: Throwable) {
println("Caught Throwable")
sb.appendLine("Caught Throwable")
}
println("Done")
sb.appendLine("Done")
assertEquals("""
Before
Caught Error
Done
""".trimIndent(), sb.toString())
return "OK"
}
fun foo() {
throw Error("Error happens")
println("After in foo()")
sb.appendLine("After in foo()")
}
+7 -5
View File
@@ -3,21 +3,23 @@
* that can be found in the LICENSE file.
*/
package runtime.exceptions.catch7
import kotlin.test.*
@Test fun runTest() {
val sb = StringBuilder()
fun box(): String {
try {
foo()
} catch (e: Throwable) {
val message = e.message
if (message != null) {
println(message)
sb.append(message)
}
}
return sb.toString()
}
fun foo() {
throw Error("Error happens")
throw Error("OK")
}
+3 -4
View File
@@ -3,16 +3,15 @@
* that can be found in the LICENSE file.
*/
package runtime.exceptions.extend0
import kotlin.test.*
class C : Exception("OK")
@Test fun runTest() {
fun box(): String {
try {
throw C()
} catch (e: Throwable) {
println(e.message!!)
return e.message!!
}
return "FAIL"
}
+2 -4
View File
@@ -3,12 +3,9 @@
* that can be found in the LICENSE file.
*/
package runtime.exceptions.rethtow
import kotlin.test.*
@Test
fun runTest() {
fun box(): String {
assertFailsWith<IllegalStateException>("My error") {
try {
error("My error")
@@ -16,4 +13,5 @@ fun runTest() {
throw e
}
}
return "OK"
}
+2 -4
View File
@@ -3,15 +3,13 @@
* that can be found in the LICENSE file.
*/
package runtime.basic.throw0
import kotlin.test.*
@Test fun runTest() {
fun box(): String {
val cond = 1
if (cond == 2) throw RuntimeException()
if (cond == 3) throw NoSuchElementException("no such element")
if (cond == 4) throw Error("error happens")
println("Done")
return "OK"
}
@@ -3,12 +3,9 @@
* that can be found in the LICENSE file.
*/
package runtime.exceptions.throw_from_catch
import kotlin.test.*
@Test
fun runTest() {
fun box(): String {
assertFailsWith<IllegalStateException>("My another error") {
try {
error("My error")
@@ -16,4 +13,5 @@ fun runTest() {
error("My another error")
}
}
return "OK"
}
@@ -3,51 +3,66 @@
* that can be found in the LICENSE file.
*/
package runtime.basic.initializers0
import kotlin.test.*
val sb = StringBuilder()
class A {
init{
println ("A::init")
sb.appendLine ("A::init")
}
val a = 1
companion object :B(1) {
init {
println ("A::companion")
sb.appendLine ("A::companion")
}
fun foo() {
println("A::companion::foo")
sb.appendLine("A::companion::foo")
}
}
object AObj : B(){
init {
println("A::Obj")
sb.appendLine("A::Obj")
}
fun foo() {
println("A::AObj::foo")
sb.appendLine("A::AObj::foo")
}
}
}
@Test fun runTest() {
println("main")
fun box(): String {
sb.appendLine("main")
A.foo()
A.foo()
A.AObj.foo()
A.AObj.foo()
assertEquals("""
main
B::constructor(1)
A::companion
A::companion::foo
A::companion::foo
B::constructor(0)
B::constructor()
A::Obj
A::AObj::foo
A::AObj::foo
""".trimIndent(), sb.toString())
return "OK"
}
open class B(val a:Int, val b:Int) {
constructor(a:Int):this (a, 0) {
println("B::constructor(" + a.toString()+ ")")
sb.appendLine("B::constructor(" + a.toString()+ ")")
}
constructor():this(0) {
println("B::constructor()")
sb.appendLine("B::constructor()")
}
}
@@ -2,21 +2,21 @@
* 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.*
val sb = StringBuilder()
class TestClass {
companion object {
init {
println("Init Test")
sb.append("OK")
}
}
}
@Test fun runTest() {
fun box(): String {
val t1 = TestClass()
val t2 = TestClass()
println("Done")
return sb.toString()
}
@@ -3,9 +3,13 @@
* that can be found in the LICENSE file.
*/
import kotlin.test.*
val sb = StringBuilder()
class A(val msg: String) {
init {
println("init $msg")
sb.appendLine("init $msg")
}
override fun toString(): String = msg
}
@@ -14,9 +18,19 @@ 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())
fun box(): String {
sb.appendLine(globalValue1.toString())
sb.appendLine(globalValue2.toString())
sb.appendLine(globalValue3.toString())
assertEquals("""
init globalValue2
init globalValue3
1
globalValue2
globalValue3
""".trimIndent(), sb.toString())
return "OK"
}
@@ -2,15 +2,13 @@
* 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)
fun box(): String {
assertEquals(42, x.bar)
return "OK"
}
@@ -2,15 +2,14 @@
* 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)
fun box(): String {
assertEquals(1073741824, INT_MAX_POWER_OF_TWO)
assertTrue(DOUBLE > 0.0)
return "OK"
}
@@ -2,9 +2,6 @@
* 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 {
@@ -12,6 +9,8 @@ object A {
val b = A.a
}
@Test fun runTest() {
println(A.b)
fun box(): String {
assertEquals(42, A.b)
return "OK"
}
@@ -2,9 +2,6 @@
* 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 {
@@ -53,8 +50,10 @@ fun assertCUninitialized() {
assertEquals(0, C.c4)
}
@Test fun runTest() {
fun box(): String {
assertEquals(A.a1, C.c2)
assertEquals(A.a2, C.c3)
assertEquals(C.c1, C.c4)
return "OK"
}
@@ -2,13 +2,10 @@
* 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"
var globalString = "OK"
@Test fun runTest() {
assertEquals("abc", globalString)
fun box(): String {
return globalString
}
@@ -2,9 +2,6 @@
* 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.interface0
import kotlin.test.*
interface A {
@@ -12,14 +9,17 @@ interface A {
fun c()
}
val sb = StringBuilder()
class B(): A {
override fun c() {
println("PASSED")
sb.append("OK")
}
}
@Test fun runTest() {
fun box(): String {
val a:A = B()
a.b()
}
return sb.toString()
}