[K/N][Tests] Adjust moved codegen tests to new infra

^KT-61259
This commit is contained in:
Vladimir Sukharev
2023-12-12 17:06:31 +01:00
committed by Space Team
parent a5f3d5b737
commit e15068c62f
301 changed files with 2958 additions and 2382 deletions
@@ -3,13 +3,12 @@
* that can be found in the LICENSE file.
*/
package codegen.basics.array_to_any
import kotlin.test.*
@Test
fun runTest() {
fun box(): String {
foo().hashCode()
return "OK"
}
fun foo(): Any {
@@ -3,10 +3,10 @@
* that can be found in the LICENSE file.
*/
package codegen.basics.canonical_name
import kotlin.test.*
val sb = StringBuilder()
interface I<U, T> {
fun foo(a: U): T
fun qux(a: T): U
@@ -20,8 +20,8 @@ class A2
//-----------------------------------------------------------------------------//
class A : I<A1, A2> {
override fun foo(a: A1): A2 { println("A:foo"); return A2() }
override fun qux(a: A2): A1 { println("A:qux"); return A1() }
override fun foo(a: A1): A2 { sb.appendLine("A:foo"); return A2() }
override fun qux(a: A2): A1 { sb.appendLine("A:qux"); return A1() }
}
//-----------------------------------------------------------------------------//
@@ -33,7 +33,9 @@ fun <U, V> baz(i: I<U, V>, u: U, v:V) {
//-----------------------------------------------------------------------------//
@Test
fun runTest() {
fun box(): String {
baz<A1, A2>(A(), A1(), A2())
assertEquals("A:foo\nA:qux\n", sb.toString())
return "OK"
}
@@ -1,2 +0,0 @@
A:foo
A:qux
+3 -6
View File
@@ -3,12 +3,9 @@
* that can be found in the LICENSE file.
*/
package codegen.basics.cast_null
import kotlin.test.*
@Test
fun runTest() {
fun box(): String {
testCast(null, false)
testCastToNullable(null, true)
testCastToNullable(TestKlass(), true)
@@ -16,14 +13,14 @@ fun runTest() {
testCastNotNullableToNullable(TestKlass(), true)
testCastNotNullableToNullable("", false)
println("Ok")
return "OK"
}
class TestKlass
fun ensure(b: Boolean) {
if (!b) {
println("Error")
throw Error("Error")
}
}
@@ -1 +0,0 @@
Ok
+3 -4
View File
@@ -3,8 +3,6 @@
* that can be found in the LICENSE file.
*/
package codegen.basics.cast_simple
import kotlin.test.*
open class A() {}
@@ -18,7 +16,8 @@ fun castTest(): Boolean {
return true
}
@Test
fun runTest() {
fun box(): String {
if (!castTest()) throw Error()
return "OK"
}
+9 -11
View File
@@ -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 codegen.basics.check_type
import kotlin.test.*
interface I
@@ -37,12 +34,13 @@ fun isTypeOfInterface(a: Any) : Boolean {
//-----------------------------------------------------------------------------//
@Test
fun runTest() {
println(isTypeOf(A()))
println(isTypeOf(null))
println(isTypeNullableOf(A()))
println(isTypeNullableOf(null))
println(isNotTypeOf(B()))
println(isTypeOfInterface(A()))
fun box(): String {
if (!isTypeOf(A())) return "FAIL !isTypeOf(A())"
if (isTypeOf(null)) return "FAIL isTypeOf(null)"
if (!isTypeNullableOf(A())) return "FAIL !isTypeNullableOf(A())"
if (!isTypeNullableOf(null)) return "FAIL !isTypeNullableOf(null)"
if (!isNotTypeOf(B())) return "FAIL !isNotTypeOf(B())"
if (!isTypeOfInterface(A())) return "FAIL !isTypeOfInterface(A())"
return "OK"
}
@@ -1,6 +0,0 @@
true
false
true
true
true
true
+3 -1
View File
@@ -5,6 +5,8 @@
class A {
companion object {
fun foo() = "comp"
fun foo() = "OK"
}
}
fun box() = A.foo()
@@ -2,18 +2,19 @@
* 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.basics.concatenation
// OUTPUT_DATA_FILE: concatenation.out
import kotlin.test.*
@Test
fun runTest() {
fun box(): String {
val s = "world"
val i = 1
println("Hello $s $i ${2*i}")
val res1 = "Hello $s $i ${2 * i}"
if (res1 != "Hello world 1 2") return "FAIL 1: $res1"
for (item in listOf("a", "b")) {
println("Hello, $item")
}
val a = "a"
val res2 = "Hello, $a"
if (res2 != "Hello, a") return "FAIL 2: $res2"
return "OK"
}
@@ -1,3 +0,0 @@
Hello world 1 2
Hello, a
Hello, b
@@ -3,8 +3,6 @@
* that can be found in the LICENSE file.
*/
package codegen.basics.const_infinity
import kotlin.test.*
//Original issue here https://youtrack.jetbrains.com/issue/KT-37212
@@ -13,9 +11,10 @@ const val fpInfConst = 1.0F / 0.0F
@Suppress("DIVISION_BY_ZERO")
val fpInfVal = 1.0F / 0.0F
@Test
fun runTest() {
fun box(): String {
assertEquals(fpInfConst, Float.POSITIVE_INFINITY)
assertEquals(fpInfVal, Float.POSITIVE_INFINITY)
assertEquals(fpInfConst, fpInfVal)
}
return "OK"
}
@@ -3,22 +3,18 @@
* that can be found in the LICENSE file.
*/
package codegen.basics.expression_as_statement
import kotlin.test.*
fun foo() {
Any() as String
}
@Test
fun runTest() {
fun box(): String {
try {
foo()
} catch (e: Throwable) {
println("Ok")
return
return "OK"
}
println("Fail")
return "Fail"
}
@@ -1 +0,0 @@
Ok
+3 -4
View File
@@ -1,10 +1,9 @@
package codegen.basics.k42000_1
import kotlin.test.*
@Test
fun runTest() {
fun box(): String {
assertTrue(Reproducer().repro() > 0)
return "OK"
}
// Based on https://youtrack.jetbrains.com/issue/KT-42000#focus=Comments-27-4404934.0-0
+3 -4
View File
@@ -1,14 +1,13 @@
package codegen.basics.k42000_2
import kotlin.test.*
// https://youtrack.jetbrains.com/issue/KT-42000
@Test
fun runTest() {
fun box(): String {
assertFailsWith<Error> {
when (1) {
else -> throw Error()
} as String
}
return "OK"
}
@@ -3,8 +3,6 @@
* that can be found in the LICENSE file.
*/
package codegen.basics.local_variable
import kotlin.test.*
fun local_variable(a: Int) : Int {
@@ -13,7 +11,7 @@ fun local_variable(a: Int) : Int {
return b
}
@Test
fun runTest() {
fun box(): String {
if (local_variable(3) != 14) throw Error()
return "OK"
}
+7 -8
View File
@@ -3,8 +3,6 @@
* that can be found in the LICENSE file.
*/
package codegen.basics.null_check
import kotlin.test.*
//--- Test "eqeq" -------------------------------------------------------------//
@@ -31,10 +29,11 @@ fun null_check_eqeqeq2() : Boolean {
return check_eqeqeq(null)
}
@Test
fun runTest() {
if (null_check_eqeq1()) throw Error()
if (!null_check_eqeq2()) throw Error()
if (null_check_eqeqeq1()) throw Error()
if (!null_check_eqeqeq2()) throw Error()
fun box(): String {
if (null_check_eqeq1()) return "FAIL null_check_eqeq1()"
if (!null_check_eqeq2()) return "FAIL !null_check_eqeq2()"
if (null_check_eqeqeq1()) return "FAIL null_check_eqeqeq1()"
if (!null_check_eqeqeq2()) return "FAIL !null_check_eqeqeq2()"
return "OK"
}
+5 -6
View File
@@ -3,8 +3,6 @@
* that can be found in the LICENSE file.
*/
package codegen.basics.safe_cast
import kotlin.test.*
open class A
@@ -23,10 +21,11 @@ fun safe_cast_negative(): Boolean {
return foo(c) == null
}
@Test
fun runTest() {
fun box(): String {
val safeCastPositive = safe_cast_positive().toString()
val safeCastNegative = safe_cast_negative().toString()
println("safe_cast_positive: " + safeCastPositive)
println("safe_cast_negative: " + safeCastNegative)
if (safeCastPositive != "true") return "FAIL safeCastPositive"
if (safeCastNegative != "true") return "FAIL safeCastNegative"
return "OK"
}
@@ -1,2 +0,0 @@
safe_cast_positive: true
safe_cast_negative: true
@@ -3,16 +3,17 @@
* that can be found in the LICENSE file.
*/
package codegen.basics.spread_operator_0
import kotlin.test.*
@Test
fun runTest() {
fun box(): String {
val list0 = _arrayOf("K", "o", "t", "l", "i", "n")
val list1 = _arrayOf("l", "a","n", "g", "u", "a", "g", "e")
val list = foo(list0, list1)
println(list.toString())
val expected = listOf("K", "o", "t", "l", "i", "n", " ", "i", "s", " ", "c", "o", "o", "l", " ", "l", "a", "n", "g", "u", "a", "g", "e")
if (list != expected)
return "FAIL: $list"
return "OK"
}
@@ -1 +0,0 @@
[K, o, t, l, i, n, , i, s, , c, o, o, l, , l, a, n, g, u, a, g, e]
@@ -3,8 +3,6 @@
* that can be found in the LICENSE file.
*/
package codegen.basics.superFunCall
import kotlin.test.*
open class C {
@@ -22,8 +20,11 @@ class C3: C2() {
override fun f() = super<C2>.f() + "<fun:C3>"
}
@Test
fun runTest() {
println(C1().f())
println(C3().f())
fun box(): String {
val c1f = C1().f()
if (c1f != "<fun:C><fun:C1>") return "FAIL 1: $c1f"
val c3f = C3().f()
if (c3f != "<fun:C><fun:C3>") return "FAIL 2: $c3f"
return "OK"
}
@@ -1,2 +0,0 @@
<fun:C><fun:C1>
<fun:C><fun:C3>
@@ -3,8 +3,6 @@
* that can be found in the LICENSE file.
*/
package codegen.basics.superGetterCall
import kotlin.test.*
open class C {
@@ -22,8 +20,11 @@ class C3: C2() {
override val p1 = super<C2>.p1 + "<prop:C3>"
}
@Test
fun runTest() {
println(C1().p1)
println(C3().p1)
fun box(): String {
val c1p1 = C1().p1
if (c1p1 != "<prop:C><prop:C1>") return "FAIL 1: $c1p1"
val c3p1 = C3().p1
if (c3p1 != "<prop:C><prop:C3>") return "FAIl 2: $c3p1"
return "OK"
}
@@ -1,2 +0,0 @@
<prop:C><prop:C1>
<prop:C><prop:C3>
@@ -3,8 +3,6 @@
* that can be found in the LICENSE file.
*/
package codegen.basics.superSetterCall
import kotlin.test.*
open class C {
@@ -31,12 +29,15 @@ class C3: C2() {
}
}
@Test
fun runTest() {
fun box(): String {
val c1 = C1()
val c3 = C3()
c1.p2 = "zzz"
c3.p2 = "zzz"
println(c1.p2)
println(c3.p2)
val c1p2 = c1.p2
if (c1p2 != "<prop:C1><prop:C>zzz") return "FAIL 1: "
val c3p2 = c3.p2
if (c3p2 != "<prop:C3><prop:C>zzz") return "FAIL 2: "
return "OK"
}
@@ -1,2 +0,0 @@
<prop:C1><prop:C>zzz
<prop:C3><prop:C>zzz
+4 -5
View File
@@ -3,13 +3,12 @@
* that can be found in the LICENSE file.
*/
package codegen.basics.typealias1
import kotlin.test.*
@Test
fun runTest() {
println(Bar(42).x)
fun box(): String {
val x = Bar(42).x
if (x != 42 ) return "FAIL: $x"
return "OK"
}
class Foo(val x: Int)
@@ -1 +0,0 @@
42
@@ -3,24 +3,26 @@
* that can be found in the LICENSE file.
*/
package codegen.basics.unchecked_cast1
import kotlin.test.*
@Test
fun runTest() {
val sb = StringBuilder()
fun box(): String {
foo<String>("17")
bar<String>("17")
foo<String>(42)
bar<String>(42)
assertEquals("17\n17\n42\n42\n", sb.toString())
return "OK"
}
fun <T> foo(x: Any?) {
val y = x as T
println(y.toString())
sb.appendLine(y.toString())
}
fun <T> bar(x: Any?) {
val y = x as? T
println(y.toString())
sb.appendLine(y.toString())
}
@@ -1,4 +0,0 @@
17
17
42
42
@@ -2,18 +2,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 codegen.basics.unchecked_cast2
// IGNORE_BACKEND: NATIVE
import kotlin.test.*
@Test
fun runTest() {
fun box(): String {
try {
val x = cast<String>(Any())
println(x.length)
return "FAIL: ${x.length}"
} catch (e: Throwable) {
println("Ok")
return "OK"
}
}
@@ -1 +0,0 @@
Ok
@@ -3,17 +3,14 @@
* that can be found in the LICENSE file.
*/
package codegen.basics.unchecked_cast3
import kotlin.test.*
@Test
fun runTest() {
fun box(): String {
testCast<TestKlass>(TestKlass(), true)
testCast<TestKlass>(null, false)
testCastToNullable<TestKlass>(null, true)
println("Ok")
return "OK"
}
class TestKlass
@@ -1 +0,0 @@
Ok
@@ -3,12 +3,9 @@
* that can be found in the LICENSE file.
*/
package codegen.basics.unchecked_cast4
import kotlin.test.*
@Test
fun runTest() {
fun box(): String {
CI1I2().uncheckedCast<CI1I2>()
CI1I2().uncheckedCast<OtherCI1I2>()
@@ -16,7 +13,7 @@ fun runTest() {
Any().uncheckedCast<CI1I2>()
}
println("Ok")
return "OK"
}
fun <R : C> Any?.uncheckedCast() where R : I1, R : I2 {
@@ -1 +0,0 @@
Ok
+4 -7
View File
@@ -3,11 +3,8 @@
* that can be found in the LICENSE file.
*/
package codegen.basics.unit1
import kotlin.test.*
@Test
fun runTest() {
println(println("First").toString())
fun box(): String {
val unit = println("First")
if (unit.toString() != "kotlin.Unit") return "FAIL 1: $unit"
return "OK"
}
-2
View File
@@ -1,2 +0,0 @@
First
kotlin.Unit
+3 -7
View File
@@ -3,14 +3,10 @@
* that can be found in the LICENSE file.
*/
package codegen.basics.unit2
import kotlin.test.*
@Test
fun runTest() {
fun box(): String {
val x = foo()
println(x.toString())
if (x.toString() != "kotlin.Unit") return "FAIL: $x"
return "OK"
}
fun foo() {
-1
View File
@@ -1 +0,0 @@
kotlin.Unit
+6 -9
View File
@@ -3,15 +3,12 @@
* that can be found in the LICENSE file.
*/
package codegen.basics.unit3
import kotlin.test.*
@Test
fun runTest() {
foo(Unit)
fun box(): String {
val actual = foo(Unit)
if (actual != "kotlin.Unit") return "FAIL: $actual"
return "OK"
}
fun foo(x: Any) {
println(x.toString())
fun foo(x: Any): String {
return x.toString()
}
-1
View File
@@ -1 +0,0 @@
kotlin.Unit
+3 -8
View File
@@ -3,16 +3,11 @@
* that can be found in the LICENSE file.
*/
package codegen.basics.unit4
import kotlin.test.*
@Test
fun runTest() {
fun box(): String {
for (x in 0 .. 8) {
foo(x, Unit)
}
println("Done")
return "OK"
}
var global = 42
@@ -39,7 +34,7 @@ fun foo(x: Int, unit: Unit) {
}
if (y !== Unit) {
println("Fail at x = $x")
throw Error("Fail at x = $x")
}
}
-1
View File
@@ -1 +0,0 @@
Done