[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
+9 -9
View File
@@ -3,8 +3,6 @@
* that can be found in the LICENSE file.
*/
package codegen.boxing.box_cache0
import kotlin.test.*
fun <T> areSame(arg1: T, arg2: T): Boolean {
@@ -15,7 +13,7 @@ fun Boolean.oneIfTrueElseZero(): Int {
return if (this) 1 else 0
}
@Test fun runTest() {
fun box(): String {
var acc = 0
val range = 1000
@@ -24,35 +22,37 @@ fun Boolean.oneIfTrueElseZero(): Int {
acc += areSame(i, j).oneIfTrueElseZero()
}
}
println(acc)
if (acc != 2) "FAIL 1: $acc"
acc = 0
for (i in Byte.MIN_VALUE..Byte.MAX_VALUE) {
acc += areSame(i, i).oneIfTrueElseZero()
}
println(acc)
if (acc != 256) "FAIL 2: $acc"
acc = 0
for (i in Short.MIN_VALUE..Short.MAX_VALUE) {
acc += areSame(i, i).oneIfTrueElseZero()
}
println(acc)
if (acc != 256) "FAIL 3: $acc"
acc = 0
for (i in 0.toChar()..range.toChar()) {
acc += areSame(i, i).oneIfTrueElseZero()
}
println(acc)
if (acc != 256) "FAIL 4: $acc"
acc = 0
for (i in -range..range) {
acc += areSame(i, i).oneIfTrueElseZero()
}
println(acc)
if (acc != 256) "FAIL 5: $acc"
acc = 0
for (i in -range.toLong()..range.toLong()) {
acc += areSame(i, i).oneIfTrueElseZero()
}
println(acc)
if (acc != 256) "FAIL 6: $acc"
return "OK"
}
@@ -1,6 +0,0 @@
2
256
256
256
256
256
+6 -5
View File
@@ -3,19 +3,20 @@
* that can be found in the LICENSE file.
*/
package codegen.boxing.boxing0
import kotlin.test.*
class Box<T>(t: T) {
var value = t
}
@Test fun runTest() {
fun box(): String {
val box: Box<Int> = Box<Int>(17)
println(box.value)
if (box.value != 17) return "FAIL 1: ${box.value}"
val nonConst = 17
val box2: Box<Int> = Box<Int>(nonConst)
println(box2.value)
if (box2.value != 17) return "FAIL 1: ${box2.value}"
return "OK"
}
@@ -1,2 +0,0 @@
17
17
+17 -4
View File
@@ -3,15 +3,15 @@
* that can be found in the LICENSE file.
*/
package codegen.boxing.boxing1
import kotlin.test.*
val sb = StringBuilder()
fun foo(arg: Any) {
println(arg.toString())
sb.appendLine(arg.toString())
}
@Test fun runTest() {
fun box(): String {
foo(1)
foo(2u)
foo(false)
@@ -24,4 +24,17 @@ fun foo(arg: Any) {
foo(nonConstUInt)
foo(nonConstBool)
foo(nonConstString)
assertEquals("""
1
2
false
Hello
1
2
false
Hello
""".trimIndent(), sb.toString())
return "OK"
}
@@ -1,8 +0,0 @@
1
2
false
Hello
1
2
false
Hello
+3 -4
View File
@@ -3,16 +3,15 @@
* that can be found in the LICENSE file.
*/
package codegen.boxing.boxing10
import kotlin.test.*
@Test fun runTest() {
fun box(): String {
val FALSE: Boolean? = false
if (FALSE != null) {
do {
println("Ok")
return "OK"
} while (FALSE)
}
return "FAIL"
}
@@ -1 +0,0 @@
Ok
+7 -4
View File
@@ -3,11 +3,11 @@
* that can be found in the LICENSE file.
*/
package codegen.boxing.boxing11
import kotlin.test.*
fun printInt(x: Int) = println(x)
val sb = StringBuilder()
fun printInt(x: Int) = sb.appendLine(x)
class Foo(val value: Int?) {
fun foo() {
@@ -15,7 +15,10 @@ class Foo(val value: Int?) {
}
}
@Test fun runTest() {
fun box(): String {
Foo(17).foo()
Foo(null).foo()
assertEquals("17\n42\n", sb.toString())
return "OK"
}
@@ -1,2 +0,0 @@
17
42
+7 -4
View File
@@ -3,16 +3,19 @@
* that can be found in the LICENSE file.
*/
package codegen.boxing.boxing12
import kotlin.test.*
val sb = StringBuilder()
fun foo(x: Number) {
println(x.toByte())
sb.appendLine(x.toByte())
}
@Test fun runTest() {
fun box(): String {
foo(18)
val nonConst = 18
foo(nonConst)
assertEquals("18\n18\n", sb.toString())
return "OK"
}
@@ -1,2 +0,0 @@
18
18
+22 -5
View File
@@ -3,16 +3,16 @@
* that can be found in the LICENSE file.
*/
package codegen.boxing.boxing13
import kotlin.test.*
val sb = StringBuilder()
fun is42(x: Any?) {
println(x == 42)
println(42 == x)
sb.appendLine(x == 42)
sb.appendLine(42 == x)
}
@Test fun runTest() {
fun box(): String {
is42(16)
is42(42)
is42("42")
@@ -22,4 +22,21 @@ fun is42(x: Any?) {
is42(nonConst16)
is42(nonConst42)
is42(nonConst42String)
assertEquals("""
false
false
true
true
false
false
false
false
true
true
false
false
""".trimIndent(), sb.toString())
return "OK"
}
@@ -1,12 +0,0 @@
false
false
true
true
false
false
false
false
true
true
false
false
+7 -4
View File
@@ -3,14 +3,17 @@
* that can be found in the LICENSE file.
*/
package codegen.boxing.boxing14
import kotlin.test.*
@Test fun runTest() {
val sb = StringBuilder()
fun box(): String {
42.println()
val nonConst = 42
nonConst.println()
assertEquals("42\n42\n", sb.toString())
return "OK"
}
fun <T> T.println() = println(this.toString())
fun <T> T.println() = sb.appendLine(this)
@@ -1,2 +0,0 @@
42
42
+8 -5
View File
@@ -3,14 +3,17 @@
* that can be found in the LICENSE file.
*/
package codegen.boxing.boxing15
import kotlin.test.*
@Test fun runTest() {
println(foo(17))
fun box(): String {
val res1 = foo(17)
if (res1 != 17) return "FAIL 1: $res1"
val nonConst = 17
println(foo(nonConst))
val res2 = foo(nonConst)
if (res2 != 17) return "FAIL 2: $res2"
return "OK"
}
fun <T : Int> foo(x: T): Int = x
@@ -1,2 +0,0 @@
17
17
+20 -7
View File
@@ -3,13 +3,13 @@
* that can be found in the LICENSE file.
*/
package codegen.boxing.boxing2
import kotlin.test.*
fun printInt(x: Int) = println(x)
fun printBoolean(x: Boolean) = println(x)
fun printUInt(x: UInt) = println(x)
val sb = StringBuilder()
fun printInt(x: Int) = sb.appendLine(x.toString())
fun printBoolean(x: Boolean) = sb.appendLine(x.toString())
fun printUInt(x: UInt) = sb.appendLine(x.toString())
fun foo(arg: Any) {
if (arg is Int)
@@ -19,10 +19,10 @@ fun foo(arg: Any) {
else if (arg is UInt)
printUInt(arg)
else
println("other")
sb.appendLine("other")
}
@Test fun runTest() {
fun box(): String {
foo(1)
foo(2u)
foo(true)
@@ -35,4 +35,17 @@ fun foo(arg: Any) {
foo(nonConstUInt)
foo(nonConstBool)
foo(nonConstString)
assertEquals("""
1
2
true
other
1
2
true
other
""".trimIndent(), sb.toString())
return "OK"
}
@@ -1,8 +0,0 @@
1
2
true
other
1
2
true
other
+7 -4
View File
@@ -3,19 +3,22 @@
* that can be found in the LICENSE file.
*/
package codegen.boxing.boxing3
import kotlin.test.*
fun printInt(x: Int) = println(x)
val sb = StringBuilder()
fun printInt(x: Int) = sb.appendLine(x)
fun foo(arg: Int?) {
if (arg != null)
printInt(arg)
}
@Test fun runTest() {
fun box(): String {
foo(42)
val nonConst = 42
foo(nonConst)
assertEquals("42\n42\n", sb.toString())
return "OK"
}
@@ -1,2 +0,0 @@
42
42
+7 -4
View File
@@ -3,19 +3,22 @@
* that can be found in the LICENSE file.
*/
package codegen.boxing.boxing4
import kotlin.test.*
fun printInt(x: Int) = println(x)
val sb = StringBuilder()
fun printInt(x: Int) = sb.appendLine(x)
fun foo(arg: Any?) {
if (arg is Int? && arg != null)
printInt(arg)
}
@Test fun runTest() {
fun box(): String {
foo(16)
val nonConst = 16
foo(nonConst)
assertEquals("16\n16\n", sb.toString())
return "OK"
}
@@ -1,2 +0,0 @@
16
16
+7 -4
View File
@@ -3,21 +3,24 @@
* that can be found in the LICENSE file.
*/
package codegen.boxing.boxing5
import kotlin.test.*
fun printInt(x: Int) = println(x)
val sb = StringBuilder()
fun printInt(x: Int) = sb.appendLine(x)
fun foo(arg: Int?) {
printInt(arg ?: 16)
}
@Test fun runTest() {
fun box(): String {
foo(null)
foo(42)
val nonConstNull = null
val nonConstInt = 42
foo(nonConstNull)
foo(nonConstInt)
assertEquals("16\n42\n16\n42\n", sb.toString())
return "OK"
}
@@ -1,4 +0,0 @@
16
42
16
42
+7 -4
View File
@@ -3,21 +3,24 @@
* that can be found in the LICENSE file.
*/
package codegen.boxing.boxing6
import kotlin.test.*
fun printInt(x: Int) = println(x)
val sb = StringBuilder()
fun printInt(x: Int) = sb.appendLine(x)
fun foo(arg: Any) {
printInt(arg as? Int ?: 16)
}
@Test fun runTest() {
fun box(): String {
foo(42)
foo("Hello")
val nonConstInt = 42
val nonConstString = "Hello"
foo(nonConstInt)
foo(nonConstString)
assertEquals("42\n16\n42\n16\n", sb.toString())
return "OK"
}
@@ -1,4 +0,0 @@
42
16
42
16
+7 -4
View File
@@ -3,11 +3,11 @@
* that can be found in the LICENSE file.
*/
package codegen.boxing.boxing7
import kotlin.test.*
fun printInt(x: Int) = println(x)
val sb = StringBuilder()
fun printInt(x: Int) = sb.appendLine(x)
fun foo(arg: Any) {
val argAsInt = try {
@@ -18,11 +18,14 @@ fun foo(arg: Any) {
printInt(argAsInt)
}
@Test fun runTest() {
fun box(): String {
foo(1)
foo("Hello")
val nonConstInt = 1
val nonConstString = "Hello"
foo(nonConstInt)
foo(nonConstString)
assertEquals("1\n0\n1\n0\n", sb.toString())
return "OK"
}
@@ -1,4 +0,0 @@
1
0
1
0
+17 -4
View File
@@ -3,21 +3,34 @@
* that can be found in the LICENSE file.
*/
package codegen.boxing.boxing8
import kotlin.test.*
val sb = StringBuilder()
fun foo(vararg args: Any?) {
for (arg in args) {
println(arg.toString())
sb.appendLine(arg.toString())
}
}
@Test fun runTest() {
fun box(): String {
foo(1, null, true, "Hello")
val nonConstInt = 1
val nonConstNull = null
val nonConstBool = true
val nonConstString = "Hello"
foo(nonConstInt, nonConstNull, nonConstBool, nonConstString)
assertEquals("""
1
null
true
Hello
1
null
true
Hello
""".trimIndent(), sb.toString())
return "OK"
}
@@ -1,8 +0,0 @@
1
null
true
Hello
1
null
true
Hello
+18 -4
View File
@@ -3,13 +3,13 @@
* that can be found in the LICENSE file.
*/
package codegen.boxing.boxing9
import kotlin.test.*
val sb = StringBuilder()
fun foo(vararg args: Any?) {
for (arg in args) {
println(arg.toString())
sb.appendLine(arg.toString())
}
}
@@ -17,6 +17,20 @@ fun bar(vararg args: Any?) {
foo(1, *args, 2, *args, 3)
}
@Test fun runTest() {
fun box(): String {
bar(null, true, "Hello")
assertEquals("""
1
null
true
Hello
2
null
true
Hello
3
""".trimIndent(), sb.toString())
return "OK"
}
@@ -1,9 +0,0 @@
1
null
true
Hello
2
null
true
Hello
3
@@ -3,8 +3,6 @@
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package codegen.boxing.kt53100_casts
import kotlin.test.*
// Reproducer is copied from FloatingPointParser.unaryMinus()
@@ -16,7 +14,12 @@ inline fun <reified T> unaryMinus(value: T): T {
}
}
@Test fun runTest(){
println(unaryMinus(0.0))
println(unaryMinus(0.0f))
fun box(): String {
val res1 = unaryMinus(0.0).toString()
if (res1 != "-0.0") return "FAIL 1: $res1"
val res2 = unaryMinus(0.0f).toString()
if (res2 != "-0.0") return "FAIL 2: $res2"
return "OK"
}
@@ -1,2 +0,0 @@
-0.0
-0.0