[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
@@ -5,23 +5,18 @@
// FILE: 1.kt // FILE: 1.kt
package codegen.annotations.annotations0
import kotlin.test.* import kotlin.test.*
import kotlinx.serialization.*
@SerialInfo @SerialInfo
annotation class Foo(val x: Int, val y: String) annotation class Foo(val x: Int, val y: String)
@Test fun runTest() { fun box(): String {
val foo = @Suppress("ANNOTATION_CLASS_CONSTRUCTOR_CALL") Foo(42, "17") val foo = @Suppress("ANNOTATION_CLASS_CONSTRUCTOR_CALL") Foo(42, "OK")
assertEquals(foo.x, 42) assertEquals(foo.x, 42)
assertEquals(foo.y, "17") return foo.y
} }
// FILE: 2.kt // FILE: 2.kt
package kotlinx.serialization
@Target(AnnotationTarget.ANNOTATION_CLASS) @Target(AnnotationTarget.ANNOTATION_CLASS)
annotation class SerialInfo annotation class SerialInfo
@@ -1,96 +0,0 @@
package codegen.arithmetic.basic
import kotlin.test.*
// Check that compiler doesn't optimize it to `true`
fun selfCmp1(x: Int) = x + 1 > x
fun selfCmp2(x: Int) = x - 1 < x
@Test
fun selfComparison() {
assertFalse(selfCmp1(Int.MAX_VALUE))
assertFalse(selfCmp2(Int.MIN_VALUE))
}
private fun charCornersMinus(): Int {
val a: Char = 0xFFFF.toChar()
val b: Char = 0.toChar()
return a - b
}
private fun charCornersComparison(): Boolean {
val a = 0xFFFF.toChar()
val b = 0.toChar()
return a < b
}
@Test
fun charCornerCases() {
assertEquals(65535, charCornersMinus())
assertFalse(charCornersComparison())
}
@Test
fun shifts() {
assertEquals(-2147483648, 1 shl -1)
assertEquals(0, 1 shr -1)
assertEquals(1, 1 shl 32)
assertEquals(1073741823, -1 ushr 2)
assertEquals(-1, -1 shr 2)
}
@Test
@kotlin.ExperimentalUnsignedTypes
fun uintTests() {
assertEquals(UInt.MAX_VALUE, UInt.MIN_VALUE - 1u)
}
@Test
fun charConversions() {
assertEquals(97.0, 'a'.toDouble())
assertEquals(-1, Char.MAX_VALUE.toShort())
assertEquals(32768, Short.MIN_VALUE.toChar().toInt())
assertEquals(-1, Char.MAX_VALUE.toByte())
assertEquals(65408, Byte.MIN_VALUE.toChar().toInt())
assertEquals(0, Float.MIN_VALUE.toChar().toInt())
}
@Test
fun doubleBasic() {
assertEquals(1, 0f.compareTo(-0f))
assertEquals(1, 0.0.compareTo(-0.0))
assertEquals(1.0, Double.fromBits(1.0.toBits()))
assertEquals(1.0f, Float.fromBits(1.0f.toBits()))
assertEquals(Double.NaN, Double.fromBits((0 / 0.0).toBits()))
assertEquals(Float.NaN, Float.fromBits((0 / 0f).toBits()))
}
@Test
fun integralToFloat() {
assertEquals(9.223372E18f, Long.MAX_VALUE.toFloat())
assertEquals(-9.223372E18f, Long.MIN_VALUE.toFloat())
assertEquals(-2.147483648E9, Int.MIN_VALUE.toDouble())
assertEquals(2.147483647E9, Int.MAX_VALUE.toDouble())
assertEquals(2147483647, Double.MAX_VALUE.toInt())
assertEquals(0, Float.MIN_VALUE.toLong())
assertEquals(9223372036854775807, Float.MAX_VALUE.toLong())
assertEquals(0, Double.MIN_VALUE.toInt())
}
@Test
fun compareIntToFloat() {
assertEquals(1, 0.compareTo(-0.0f))
assertEquals(0, 0.compareTo(+0.0f))
}
@Test
fun testKt37412() {
val two = 2.0
assertEquals(2, two.toInt())
}
@@ -0,0 +1,12 @@
import kotlin.test.*
fun box(): String {
assertEquals(97.0, 'a'.toDouble())
assertEquals(-1, Char.MAX_VALUE.toShort())
assertEquals(32768, Short.MIN_VALUE.toChar().toInt())
assertEquals(-1, Char.MAX_VALUE.toByte())
assertEquals(65408, Byte.MIN_VALUE.toChar().toInt())
assertEquals(0, Float.MIN_VALUE.toChar().toInt())
return "OK"
}
@@ -0,0 +1,20 @@
import kotlin.test.*
private fun charCornersMinus(): Int {
val a: Char = 0xFFFF.toChar()
val b: Char = 0.toChar()
return a - b
}
private fun charCornersComparison(): Boolean {
val a = 0xFFFF.toChar()
val b = 0.toChar()
return a < b
}
fun box(): String {
assertEquals(65535, charCornersMinus())
assertFalse(charCornersComparison())
return "OK"
}
@@ -0,0 +1,8 @@
import kotlin.test.*
fun box(): String {
assertEquals(1, 0.compareTo(-0.0f))
assertEquals(0, 0.compareTo(+0.0f))
return "OK"
}
@@ -0,0 +1,14 @@
import kotlin.test.*
fun box(): String {
assertEquals(1, 0f.compareTo(-0f))
assertEquals(1, 0.0.compareTo(-0.0))
assertEquals(1.0, Double.fromBits(1.0.toBits()))
assertEquals(1.0f, Float.fromBits(1.0f.toBits()))
assertEquals(Double.NaN, Double.fromBits((0 / 0.0).toBits()))
assertEquals(Float.NaN, Float.fromBits((0 / 0f).toBits()))
return "OK"
}
@@ -0,0 +1,17 @@
import kotlin.test.*
fun box(): String {
assertEquals(9.223372E18f, Long.MAX_VALUE.toFloat())
assertEquals(-9.223372E18f, Long.MIN_VALUE.toFloat())
assertEquals(-2.147483648E9, Int.MIN_VALUE.toDouble())
assertEquals(2.147483647E9, Int.MAX_VALUE.toDouble())
assertEquals(2147483647, Double.MAX_VALUE.toInt())
assertEquals(0, Float.MIN_VALUE.toLong())
assertEquals(9223372036854775807, Float.MAX_VALUE.toLong())
assertEquals(0, Double.MIN_VALUE.toInt())
return "OK"
}
@@ -0,0 +1,8 @@
import kotlin.test.*
fun box(): String {
val two = 2.0
assertEquals(2, two.toInt())
return "OK"
}
@@ -0,0 +1,13 @@
import kotlin.test.*
// Check that compiler doesn't optimize it to `true`
fun selfCmp1(x: Int) = x + 1 > x
fun selfCmp2(x: Int) = x - 1 < x
fun box(): String {
assertFalse(selfCmp1(Int.MAX_VALUE))
assertFalse(selfCmp2(Int.MIN_VALUE))
return "OK"
}
@@ -0,0 +1,11 @@
import kotlin.test.*
fun box(): String {
assertEquals(-2147483648, 1 shl -1)
assertEquals(0, 1 shr -1)
assertEquals(1, 1 shl 32)
assertEquals(1073741823, -1 ushr 2)
assertEquals(-1, -1 shr 2)
return "OK"
}
@@ -0,0 +1,8 @@
import kotlin.test.*
@kotlin.ExperimentalUnsignedTypes
fun box(): String {
assertEquals(UInt.MAX_VALUE, UInt.MIN_VALUE - 1u)
return "OK"
}
@@ -1,11 +1,10 @@
package codegen.arithmetic.division
import kotlin.test.* import kotlin.test.*
@Test fun box(): String {
fun divisionByZero() {
assertFailsWith(ArithmeticException::class, { 5 / 0 }) assertFailsWith(ArithmeticException::class, { 5 / 0 })
assertFailsWith(ArithmeticException::class, { 5 % 0 }) assertFailsWith(ArithmeticException::class, { 5 % 0 })
assertEquals(1, 5 / try { 0 / 0; 1 } catch (e: ArithmeticException) { 5 }) assertEquals(1, 5 / try { 0 / 0; 1 } catch (e: ArithmeticException) { 5 })
assertEquals(Double.NaN, 0.0 / 0.0) assertEquals(Double.NaN, 0.0 / 0.0)
return "OK"
} }
@@ -1,5 +1,3 @@
package codegen.arithmetic.github1856
import kotlin.test.* import kotlin.test.*
object RGBA { object RGBA {
@@ -18,9 +16,10 @@ object RGBA {
} }
} }
@Test fun box(): String {
fun main() {
val source = listOf(0xFFFFFFFF.toInt(), 0xFFFFFF77.toInt(), 0x777777FF.toInt(), 0x77777777.toInt()) val source = listOf(0xFFFFFFFF.toInt(), 0xFFFFFF77.toInt(), 0x777777FF.toInt(), 0x77777777.toInt())
val expect = listOf(-1, -137, 2000107383, 2000107319) val expect = listOf(-1, -137, 2000107383, 2000107319)
assertEquals(expect, source.map { RGBA.premultiplyFastInt(it) }) assertEquals(expect, source.map { RGBA.premultiplyFastInt(it) })
return "OK"
} }
@@ -0,0 +1,41 @@
/*
* Copyright 2010-2019 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.*
import kotlin.reflect.*
@OptIn(ExperimentalAssociatedObjects::class)
fun box(): String {
assertSame(Bar, Foo::class.findAssociatedObject<Associated1>())
assertSame(Baz, Foo::class.findAssociatedObject<Associated2>())
assertSame(null, Foo::class.findAssociatedObject<Associated3>())
assertSame(null, Bar::class.findAssociatedObject<Associated1>())
return "OK"
}
@OptIn(ExperimentalAssociatedObjects::class)
@AssociatedObjectKey
@Retention(AnnotationRetention.BINARY)
annotation class Associated1(val kClass: KClass<*>)
@OptIn(ExperimentalAssociatedObjects::class)
@AssociatedObjectKey
@Retention(AnnotationRetention.BINARY)
annotation class Associated2(val kClass: KClass<*>)
@OptIn(ExperimentalAssociatedObjects::class)
@AssociatedObjectKey
@Retention(AnnotationRetention.BINARY)
annotation class Associated3(val kClass: KClass<*>)
@Associated1(Bar::class)
@Associated2(Baz::class)
class Foo
object Bar
object Baz
@@ -3,21 +3,9 @@
* that can be found in the LICENSE file. * that can be found in the LICENSE file.
*/ */
package codegen.associatedObjects.associatedObjects1
import kotlin.test.* import kotlin.test.*
import kotlin.reflect.* import kotlin.reflect.*
@Test
@OptIn(ExperimentalAssociatedObjects::class)
fun testBasics1() {
assertSame(Bar, Foo::class.findAssociatedObject<Associated1>())
assertSame(Baz, Foo::class.findAssociatedObject<Associated2>())
assertSame(null, Foo::class.findAssociatedObject<Associated3>())
assertSame(null, Bar::class.findAssociatedObject<Associated1>())
}
@OptIn(ExperimentalAssociatedObjects::class) @OptIn(ExperimentalAssociatedObjects::class)
@AssociatedObjectKey @AssociatedObjectKey
@Retention(AnnotationRetention.BINARY) @Retention(AnnotationRetention.BINARY)
@@ -33,21 +21,15 @@ annotation class Associated2(val kClass: KClass<*>)
@Retention(AnnotationRetention.BINARY) @Retention(AnnotationRetention.BINARY)
annotation class Associated3(val kClass: KClass<*>) annotation class Associated3(val kClass: KClass<*>)
@Associated1(Bar::class)
@Associated2(Baz::class)
class Foo
object Bar
object Baz
@Test
@OptIn(ExperimentalAssociatedObjects::class) @OptIn(ExperimentalAssociatedObjects::class)
fun testGlobalOptimizations1() { fun box(): String {
val i1 = I1ImplHolder::class.findAssociatedObject<Associated1>()!! as I1 val i1 = I1ImplHolder::class.findAssociatedObject<Associated1>()!! as I1
assertEquals(42, i1.foo()) assertEquals(42, i1.foo())
val c = C(null) val c = C(null)
i1.bar(c) i1.bar(c)
assertEquals("zzz", c.list!![0]) assertEquals("zzz", c.list!![0])
return "OK"
} }
private class C(var list: List<String>?) private class C(var list: List<String>?)
@@ -66,21 +48,3 @@ private object I1Impl : I1 {
@Associated1(I1Impl::class) @Associated1(I1Impl::class)
private class I1ImplHolder private class I1ImplHolder
@Test
@OptIn(ExperimentalAssociatedObjects::class)
fun testGlobalOptimizations2() {
val i2 = I2ImplHolder()::class.findAssociatedObject<Associated1>()!! as I2
assertEquals(17, i2.foo())
}
private interface I2 {
fun foo(): Int
}
private object I2Impl : I2 {
override fun foo() = 17
}
@Associated1(I2Impl::class)
private class I2ImplHolder
@@ -0,0 +1,41 @@
/*
* Copyright 2010-2019 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.*
import kotlin.reflect.*
@OptIn(ExperimentalAssociatedObjects::class)
@AssociatedObjectKey
@Retention(AnnotationRetention.BINARY)
annotation class Associated1(val kClass: KClass<*>)
@OptIn(ExperimentalAssociatedObjects::class)
@AssociatedObjectKey
@Retention(AnnotationRetention.BINARY)
annotation class Associated2(val kClass: KClass<*>)
@OptIn(ExperimentalAssociatedObjects::class)
@AssociatedObjectKey
@Retention(AnnotationRetention.BINARY)
annotation class Associated3(val kClass: KClass<*>)
@OptIn(ExperimentalAssociatedObjects::class)
fun box(): String {
val i2 = I2ImplHolder()::class.findAssociatedObject<Associated1>()!! as I2
assertEquals(17, i2.foo())
return "OK"
}
private interface I2 {
fun foo(): Int
}
private object I2Impl : I2 {
override fun foo() = 17
}
@Associated1(I2Impl::class)
private class I2ImplHolder
@@ -3,13 +3,12 @@
* that can be found in the LICENSE file. * that can be found in the LICENSE file.
*/ */
package codegen.basics.array_to_any
import kotlin.test.* import kotlin.test.*
@Test fun box(): String {
fun runTest() {
foo().hashCode() foo().hashCode()
return "OK"
} }
fun foo(): Any { fun foo(): Any {
@@ -3,10 +3,10 @@
* that can be found in the LICENSE file. * that can be found in the LICENSE file.
*/ */
package codegen.basics.canonical_name
import kotlin.test.* import kotlin.test.*
val sb = StringBuilder()
interface I<U, T> { interface I<U, T> {
fun foo(a: U): T fun foo(a: U): T
fun qux(a: T): U fun qux(a: T): U
@@ -20,8 +20,8 @@ class A2
//-----------------------------------------------------------------------------// //-----------------------------------------------------------------------------//
class A : I<A1, A2> { class A : I<A1, A2> {
override fun foo(a: A1): A2 { println("A:foo"); return A2() } override fun foo(a: A1): A2 { sb.appendLine("A:foo"); return A2() }
override fun qux(a: A2): A1 { println("A:qux"); return A1() } 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 box(): String {
fun runTest() {
baz<A1, A2>(A(), A1(), A2()) 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. * that can be found in the LICENSE file.
*/ */
package codegen.basics.cast_null
import kotlin.test.* import kotlin.test.*
@Test fun box(): String {
fun runTest() {
testCast(null, false) testCast(null, false)
testCastToNullable(null, true) testCastToNullable(null, true)
testCastToNullable(TestKlass(), true) testCastToNullable(TestKlass(), true)
@@ -16,14 +13,14 @@ fun runTest() {
testCastNotNullableToNullable(TestKlass(), true) testCastNotNullableToNullable(TestKlass(), true)
testCastNotNullableToNullable("", false) testCastNotNullableToNullable("", false)
println("Ok") return "OK"
} }
class TestKlass class TestKlass
fun ensure(b: Boolean) { fun ensure(b: Boolean) {
if (!b) { 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. * that can be found in the LICENSE file.
*/ */
package codegen.basics.cast_simple
import kotlin.test.* import kotlin.test.*
open class A() {} open class A() {}
@@ -18,7 +16,8 @@ fun castTest(): Boolean {
return true return true
} }
@Test fun box(): String {
fun runTest() {
if (!castTest()) throw Error() 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 * 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. * that can be found in the LICENSE file.
*/ */
package codegen.basics.check_type
import kotlin.test.* import kotlin.test.*
interface I interface I
@@ -37,12 +34,13 @@ fun isTypeOfInterface(a: Any) : Boolean {
//-----------------------------------------------------------------------------// //-----------------------------------------------------------------------------//
@Test fun box(): String {
fun runTest() { if (!isTypeOf(A())) return "FAIL !isTypeOf(A())"
println(isTypeOf(A())) if (isTypeOf(null)) return "FAIL isTypeOf(null)"
println(isTypeOf(null)) if (!isTypeNullableOf(A())) return "FAIL !isTypeNullableOf(A())"
println(isTypeNullableOf(A())) if (!isTypeNullableOf(null)) return "FAIL !isTypeNullableOf(null)"
println(isTypeNullableOf(null)) if (!isNotTypeOf(B())) return "FAIL !isNotTypeOf(B())"
println(isNotTypeOf(B())) if (!isTypeOfInterface(A())) return "FAIL !isTypeOfInterface(A())"
println(isTypeOfInterface(A()))
return "OK"
} }
@@ -1,6 +0,0 @@
true
false
true
true
true
true
+3 -1
View File
@@ -5,6 +5,8 @@
class A { class A {
companion object { 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 * 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. * that can be found in the LICENSE file.
*/ */
// OUTPUT_DATA_FILE: concatenation.out
package codegen.basics.concatenation
import kotlin.test.* import kotlin.test.*
@Test fun box(): String {
fun runTest() {
val s = "world" val s = "world"
val i = 1 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")) { val a = "a"
println("Hello, $item") 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. * that can be found in the LICENSE file.
*/ */
package codegen.basics.const_infinity
import kotlin.test.* import kotlin.test.*
//Original issue here https://youtrack.jetbrains.com/issue/KT-37212 //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") @Suppress("DIVISION_BY_ZERO")
val fpInfVal = 1.0F / 0.0F val fpInfVal = 1.0F / 0.0F
@Test fun box(): String {
fun runTest() {
assertEquals(fpInfConst, Float.POSITIVE_INFINITY) assertEquals(fpInfConst, Float.POSITIVE_INFINITY)
assertEquals(fpInfVal, Float.POSITIVE_INFINITY) assertEquals(fpInfVal, Float.POSITIVE_INFINITY)
assertEquals(fpInfConst, fpInfVal) assertEquals(fpInfConst, fpInfVal)
return "OK"
} }
@@ -3,22 +3,18 @@
* that can be found in the LICENSE file. * that can be found in the LICENSE file.
*/ */
package codegen.basics.expression_as_statement
import kotlin.test.* import kotlin.test.*
fun foo() { fun foo() {
Any() as String Any() as String
} }
@Test fun box(): String {
fun runTest() {
try { try {
foo() foo()
} catch (e: Throwable) { } catch (e: Throwable) {
println("Ok") return "OK"
return
} }
println("Fail") return "Fail"
} }
@@ -1 +0,0 @@
Ok
+3 -4
View File
@@ -1,10 +1,9 @@
package codegen.basics.k42000_1
import kotlin.test.* import kotlin.test.*
@Test fun box(): String {
fun runTest() {
assertTrue(Reproducer().repro() > 0) assertTrue(Reproducer().repro() > 0)
return "OK"
} }
// Based on https://youtrack.jetbrains.com/issue/KT-42000#focus=Comments-27-4404934.0-0 // 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.* import kotlin.test.*
// https://youtrack.jetbrains.com/issue/KT-42000 // https://youtrack.jetbrains.com/issue/KT-42000
@Test fun box(): String {
fun runTest() {
assertFailsWith<Error> { assertFailsWith<Error> {
when (1) { when (1) {
else -> throw Error() else -> throw Error()
} as String } as String
} }
return "OK"
} }
@@ -3,8 +3,6 @@
* that can be found in the LICENSE file. * that can be found in the LICENSE file.
*/ */
package codegen.basics.local_variable
import kotlin.test.* import kotlin.test.*
fun local_variable(a: Int) : Int { fun local_variable(a: Int) : Int {
@@ -13,7 +11,7 @@ fun local_variable(a: Int) : Int {
return b return b
} }
@Test fun box(): String {
fun runTest() {
if (local_variable(3) != 14) throw Error() 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. * that can be found in the LICENSE file.
*/ */
package codegen.basics.null_check
import kotlin.test.* import kotlin.test.*
//--- Test "eqeq" -------------------------------------------------------------// //--- Test "eqeq" -------------------------------------------------------------//
@@ -31,10 +29,11 @@ fun null_check_eqeqeq2() : Boolean {
return check_eqeqeq(null) return check_eqeqeq(null)
} }
@Test fun box(): String {
fun runTest() { if (null_check_eqeq1()) return "FAIL null_check_eqeq1()"
if (null_check_eqeq1()) throw Error() if (!null_check_eqeq2()) return "FAIL !null_check_eqeq2()"
if (!null_check_eqeq2()) throw Error() if (null_check_eqeqeq1()) return "FAIL null_check_eqeqeq1()"
if (null_check_eqeqeq1()) throw Error() if (!null_check_eqeqeq2()) return "FAIL !null_check_eqeqeq2()"
if (!null_check_eqeqeq2()) throw Error()
return "OK"
} }
+5 -6
View File
@@ -3,8 +3,6 @@
* that can be found in the LICENSE file. * that can be found in the LICENSE file.
*/ */
package codegen.basics.safe_cast
import kotlin.test.* import kotlin.test.*
open class A open class A
@@ -23,10 +21,11 @@ fun safe_cast_negative(): Boolean {
return foo(c) == null return foo(c) == null
} }
@Test fun box(): String {
fun runTest() {
val safeCastPositive = safe_cast_positive().toString() val safeCastPositive = safe_cast_positive().toString()
val safeCastNegative = safe_cast_negative().toString() val safeCastNegative = safe_cast_negative().toString()
println("safe_cast_positive: " + safeCastPositive) if (safeCastPositive != "true") return "FAIL safeCastPositive"
println("safe_cast_negative: " + safeCastNegative) 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. * that can be found in the LICENSE file.
*/ */
package codegen.basics.spread_operator_0
import kotlin.test.* import kotlin.test.*
@Test fun box(): String {
fun runTest() {
val list0 = _arrayOf("K", "o", "t", "l", "i", "n") val list0 = _arrayOf("K", "o", "t", "l", "i", "n")
val list1 = _arrayOf("l", "a","n", "g", "u", "a", "g", "e") val list1 = _arrayOf("l", "a","n", "g", "u", "a", "g", "e")
val list = foo(list0, list1) 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. * that can be found in the LICENSE file.
*/ */
package codegen.basics.superFunCall
import kotlin.test.* import kotlin.test.*
open class C { open class C {
@@ -22,8 +20,11 @@ class C3: C2() {
override fun f() = super<C2>.f() + "<fun:C3>" override fun f() = super<C2>.f() + "<fun:C3>"
} }
@Test fun box(): String {
fun runTest() { val c1f = C1().f()
println(C1().f()) if (c1f != "<fun:C><fun:C1>") return "FAIL 1: $c1f"
println(C3().f()) 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. * that can be found in the LICENSE file.
*/ */
package codegen.basics.superGetterCall
import kotlin.test.* import kotlin.test.*
open class C { open class C {
@@ -22,8 +20,11 @@ class C3: C2() {
override val p1 = super<C2>.p1 + "<prop:C3>" override val p1 = super<C2>.p1 + "<prop:C3>"
} }
@Test fun box(): String {
fun runTest() { val c1p1 = C1().p1
println(C1().p1) if (c1p1 != "<prop:C><prop:C1>") return "FAIL 1: $c1p1"
println(C3().p1) 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. * that can be found in the LICENSE file.
*/ */
package codegen.basics.superSetterCall
import kotlin.test.* import kotlin.test.*
open class C { open class C {
@@ -31,12 +29,15 @@ class C3: C2() {
} }
} }
@Test fun box(): String {
fun runTest() {
val c1 = C1() val c1 = C1()
val c3 = C3() val c3 = C3()
c1.p2 = "zzz" c1.p2 = "zzz"
c3.p2 = "zzz" c3.p2 = "zzz"
println(c1.p2) val c1p2 = c1.p2
println(c3.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. * that can be found in the LICENSE file.
*/ */
package codegen.basics.typealias1
import kotlin.test.* import kotlin.test.*
@Test fun box(): String {
fun runTest() { val x = Bar(42).x
println(Bar(42).x) if (x != 42 ) return "FAIL: $x"
return "OK"
} }
class Foo(val x: Int) class Foo(val x: Int)
@@ -1 +0,0 @@
42
@@ -3,24 +3,26 @@
* that can be found in the LICENSE file. * that can be found in the LICENSE file.
*/ */
package codegen.basics.unchecked_cast1
import kotlin.test.* import kotlin.test.*
@Test val sb = StringBuilder()
fun runTest() {
fun box(): String {
foo<String>("17") foo<String>("17")
bar<String>("17") bar<String>("17")
foo<String>(42) foo<String>(42)
bar<String>(42) bar<String>(42)
assertEquals("17\n17\n42\n42\n", sb.toString())
return "OK"
} }
fun <T> foo(x: Any?) { fun <T> foo(x: Any?) {
val y = x as T val y = x as T
println(y.toString()) sb.appendLine(y.toString())
} }
fun <T> bar(x: Any?) { fun <T> bar(x: Any?) {
val y = x as? T 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 * 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. * that can be found in the LICENSE file.
*/ */
// IGNORE_BACKEND: NATIVE
package codegen.basics.unchecked_cast2
import kotlin.test.* import kotlin.test.*
@Test fun box(): String {
fun runTest() {
try { try {
val x = cast<String>(Any()) val x = cast<String>(Any())
println(x.length) return "FAIL: ${x.length}"
} catch (e: Throwable) { } catch (e: Throwable) {
println("Ok") return "OK"
} }
} }
@@ -1 +0,0 @@
Ok
@@ -3,17 +3,14 @@
* that can be found in the LICENSE file. * that can be found in the LICENSE file.
*/ */
package codegen.basics.unchecked_cast3
import kotlin.test.* import kotlin.test.*
@Test fun box(): String {
fun runTest() {
testCast<TestKlass>(TestKlass(), true) testCast<TestKlass>(TestKlass(), true)
testCast<TestKlass>(null, false) testCast<TestKlass>(null, false)
testCastToNullable<TestKlass>(null, true) testCastToNullable<TestKlass>(null, true)
println("Ok") return "OK"
} }
class TestKlass class TestKlass
@@ -1 +0,0 @@
Ok
@@ -3,12 +3,9 @@
* that can be found in the LICENSE file. * that can be found in the LICENSE file.
*/ */
package codegen.basics.unchecked_cast4
import kotlin.test.* import kotlin.test.*
@Test fun box(): String {
fun runTest() {
CI1I2().uncheckedCast<CI1I2>() CI1I2().uncheckedCast<CI1I2>()
CI1I2().uncheckedCast<OtherCI1I2>() CI1I2().uncheckedCast<OtherCI1I2>()
@@ -16,7 +13,7 @@ fun runTest() {
Any().uncheckedCast<CI1I2>() Any().uncheckedCast<CI1I2>()
} }
println("Ok") return "OK"
} }
fun <R : C> Any?.uncheckedCast() where R : I1, R : I2 { 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. * that can be found in the LICENSE file.
*/ */
package codegen.basics.unit1 fun box(): String {
val unit = println("First")
import kotlin.test.* if (unit.toString() != "kotlin.Unit") return "FAIL 1: $unit"
return "OK"
@Test
fun runTest() {
println(println("First").toString())
} }
-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. * that can be found in the LICENSE file.
*/ */
package codegen.basics.unit2 fun box(): String {
import kotlin.test.*
@Test
fun runTest() {
val x = foo() val x = foo()
println(x.toString()) if (x.toString() != "kotlin.Unit") return "FAIL: $x"
return "OK"
} }
fun foo() { 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. * that can be found in the LICENSE file.
*/ */
package codegen.basics.unit3 fun box(): String {
val actual = foo(Unit)
import kotlin.test.* if (actual != "kotlin.Unit") return "FAIL: $actual"
return "OK"
@Test
fun runTest() {
foo(Unit)
} }
fun foo(x: Any) { fun foo(x: Any): String {
println(x.toString()) 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. * that can be found in the LICENSE file.
*/ */
package codegen.basics.unit4 fun box(): String {
import kotlin.test.*
@Test
fun runTest() {
for (x in 0 .. 8) { for (x in 0 .. 8) {
foo(x, Unit) foo(x, Unit)
} }
println("Done") return "OK"
} }
var global = 42 var global = 42
@@ -39,7 +34,7 @@ fun foo(x: Int, unit: Unit) {
} }
if (y !== Unit) { if (y !== Unit) {
println("Fail at x = $x") throw Error("Fail at x = $x")
} }
} }
-1
View File
@@ -1 +0,0 @@
Done
@@ -1,622 +0,0 @@
/*
* 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 codegen.bce.arraysForLoops
import kotlin.test.*
import kotlin.reflect.KProperty
@Test fun forEachIndexedTest() {
val array = Array(10) { 0 }
assertFailsWith<IndexOutOfBoundsException> {
array.forEachIndexed { index, _ ->
array[index + 1] = 1
}
}
}
@Test fun forEachIndicies() {
val array = Array(10) { 0 }
val array1 = Array(3) { 0 }
var j = 4
assertFailsWith<IndexOutOfBoundsException> {
for (i in array.indices) {
array[j] = 6
j++
}
}
assertFailsWith<IndexOutOfBoundsException> {
for (i in array.indices) {
array[i + 1] = 6
}
}
assertFailsWith<IndexOutOfBoundsException> {
for (i in array.indices) {
array1[i] = 6
}
}
}
@Test fun forUntilSize() {
val array = Array(10) { 0L }
val array1 = Array(3) { 0L }
var j = 4
assertFailsWith<IndexOutOfBoundsException> {
for (i in 0 until array.size) {
array[j] = 6
j++
}
}
assertFailsWith<IndexOutOfBoundsException> {
for (i in 0 until array.size) {
array[i - 1] = 6
}
}
assertFailsWith<IndexOutOfBoundsException> {
for (i in 0 until array.size) {
array1[i] = 6
}
}
assertFailsWith<IndexOutOfBoundsException> {
for (i in 0 until array.size + 10) {
array[i] = 6
}
}
}
@Test fun forDownToSize() {
val array = Array(10) { 0L }
val array1 = Array(3) { 0L }
var j = 4
assertFailsWith<IndexOutOfBoundsException> {
for (i in array.size - 1 downTo 0) {
array[j] = 6
j++
}
}
assertFailsWith<IndexOutOfBoundsException> {
for (i in array.size - 1 downTo 0) {
array[i * 2] = 6
}
}
assertFailsWith<IndexOutOfBoundsException> {
for (i in array.size - 1 downTo 0) {
array1[i] = 6
}
}
var a = array.size - 1
val b = ++a
val c = b
assertFailsWith<IndexOutOfBoundsException> {
for (i in c downTo 0) {
array[i] = 6
}
}
assertFailsWith<IndexOutOfBoundsException> {
for (i in array.size + 1 downTo 0) {
array[i] = 6
}
}
assertFailsWith<IndexOutOfBoundsException> {
for (i in array.size - 1 downTo -1) {
array[i] = 6
}
}
assertFailsWith<IndexOutOfBoundsException> {
for (i in array.size downTo 0) {
array[i] = 6
}
}
}
@Test fun forRangeToSize() {
val array = Array(10) { 0L }
val array1 = Array(3) { 0L }
var j = 4
assertFailsWith<IndexOutOfBoundsException> {
for (i in 0..array.size - 1) {
array[j] = 6
j++
}
}
var length = array.size - 1
length = 2 * length
assertFailsWith<IndexOutOfBoundsException> {
for (i in 0..length) {
array[i] = 6
}
}
assertFailsWith<IndexOutOfBoundsException> {
for (i in 0..array.size - 1) {
array[i + 1] = 6
}
}
assertFailsWith<IndexOutOfBoundsException> {
for (i in 0..array.size - 1) {
array1[i] = 6
}
}
assertFailsWith<IndexOutOfBoundsException> {
for (i in 0..array.size + 1) {
array[i] = 6
}
}
assertFailsWith<IndexOutOfBoundsException> {
for (i in -1..array.size - 1) {
array[i] = 6
}
}
assertFailsWith<IndexOutOfBoundsException> {
for (i in 0..array.size) {
array[i] = 6
}
}
}
@Test fun forRangeToWithStep() {
val array = Array(10) { 0L }
val array1 = Array(3) { 0L }
var j = 8
assertFailsWith<IndexOutOfBoundsException> {
for (i in 0..array.size - 1 step 2) {
array[j] = 6
j++
}
}
assertFailsWith<IndexOutOfBoundsException> {
for (i in 0..array.size - 1 step 2) {
array[i - 1] = 6
}
}
assertFailsWith<IndexOutOfBoundsException> {
for (i in 0..array.size - 1 step 2) {
array1[i] = 6
}
}
assertFailsWith<IndexOutOfBoundsException> {
for (i in 0..array.size + 1 step 2) {
array[i] = 6
}
}
assertFailsWith<IndexOutOfBoundsException> {
for (i in -1..array.size - 1 step 2) {
array[i] = 6
}
}
assertFailsWith<IndexOutOfBoundsException> {
for (i in 0..array.size step 2) {
array[i] = 6
}
}
}
@Test fun forUntilWithStep() {
val array = CharArray(10) { '0' }
val array1 = CharArray(3) { '0' }
var j = 8
assertFailsWith<IndexOutOfBoundsException> {
for (i in 0 until array.size step 2) {
array[j] = '6'
j++
}
}
assertFailsWith<IndexOutOfBoundsException> {
for (i in 0 until array.size step 2) {
array[i + 3] = '6'
}
}
assertFailsWith<IndexOutOfBoundsException> {
for (i in 0 until array.size step 2) {
array1[i] = '6'
}
}
assertFailsWith<IndexOutOfBoundsException> {
for (i in 0 until (array.size/0.5).toInt() step 2) {
array[i] = '6'
}
}
assertFailsWith<IndexOutOfBoundsException> {
for (i in -array.size until array.size step 2) {
array[i] = '6'
}
}
}
@Test fun forDownToWithStep() {
val array = UIntArray(10) { 0U }
val array1 = UIntArray(3) { 0U }
var j = 8
assertFailsWith<IndexOutOfBoundsException> {
for (i in array.size - 1 downTo 0 step 2) {
array[j] = 6U
j++
}
}
assertFailsWith<IndexOutOfBoundsException> {
for (i in array.size - 1 downTo 1 step 2) {
array[i + 1] = 6U
}
}
assertFailsWith<IndexOutOfBoundsException> {
for (i in array.size - 1 downTo 1 step 2) {
array1[i] = 6U
}
}
assertFailsWith<IndexOutOfBoundsException> {
for (i in (array.size / 0.2).toInt() downTo 1 step 2) {
array[i] = 6U
}
}
assertFailsWith<IndexOutOfBoundsException> {
for (i in array.size - 1 downTo -3 step 2) {
array[i] = 6U
}
}
assertFailsWith<IndexOutOfBoundsException> {
for (i in array.size downTo 1 step 2) {
array[i] = 6U
}
}
}
@Test fun forIndiciesWithStep() {
val array = Array(10) { 0L }
val array1 = Array(3) { 0L }
var j = 8
assertFailsWith<IndexOutOfBoundsException> {
for (i in array.indices step 2) {
array[j] = 6
j++
}
}
assertFailsWith<IndexOutOfBoundsException> {
for (i in array.indices step 2) {
array[i - 1] = 6
}
}
assertFailsWith<IndexOutOfBoundsException> {
for (i in array.indices step 2) {
array1[i] = 6
}
}
}
@Test fun forWithIndex() {
val array = Array(10) { 100 }
val array1 = Array(3) { 0 }
var j = 8
assertFailsWith<IndexOutOfBoundsException> {
for ((index, value) in array.withIndex()) {
array[j] = 6
j++
}
}
assertFailsWith<IndexOutOfBoundsException> {
for ((index, value) in array.withIndex()) {
array[index + 1] = 6
}
}
assertFailsWith<IndexOutOfBoundsException> {
for ((index, value) in array.withIndex()) {
array[value] = 6
}
}
assertFailsWith<IndexOutOfBoundsException> {
for ((i, v) in (0..array.size + 30 step 2).withIndex()) {
array[i] = 6
}
}
assertFailsWith<IndexOutOfBoundsException> {
for ((i, v) in (0..array.size).withIndex()) {
array[v] = 8
}
}
}
@Test fun forReversed() {
val array = Array(10) { 100 }
val array1 = Array(3) { 0 }
var j = 8
assertFailsWith<IndexOutOfBoundsException> {
for (i in (0..array.size-1).reversed()) {
array[j] = 6
j++
}
}
assertFailsWith<IndexOutOfBoundsException> {
for (i in (0 until array.size).reversed()) {
array1[i] = 6
}
}
assertFailsWith<IndexOutOfBoundsException> {
for (i in (0..array.size).reversed()) {
array[i] = 6
}
}
assertFailsWith<IndexOutOfBoundsException> {
for (i in (array.size downTo 0).reversed()) {
array[i] = 6
}
}
}
fun foo(a: Int, b : Int): Int = a + b * 2
@Test fun bceCases() {
val array = Array(10) { 100 }
val array1 = Array(3) { 0 }
var length = array.size - 1
var sum = 0
array.forEach {
sum += it
}
for (i in array.indices) {
array[i] = 6
}
for (i in 0 until array.size) {
array[i] = 7
}
for (i in array.size - 1 downTo 1) {
array[i] = 7
}
for (it in array) {
sum += it
}
for (i in 0..array.size - 1 step 2) {
array[i] = 7
}
for (i in 0 until array.size step 2) {
array[i] = 7
}
for (i in array.indices step 2) {
array[i] = 6
}
for (i in array.size - 1 downTo 1 step 2) {
array[i] = 7
}
for ((index, value) in array.withIndex()) {
array[index] = 8
}
for ((i, v) in (0..array.size - 1 step 2).withIndex()) {
array[v] = 8
array[i] = 6
}
for (i in array.reversed()) {
sum += i
}
for (i in (0..array.size-1).reversed()) {
array [i] = 10
}
for (i in 0 until array.size) {
array[i] = 7
for (j in 0 until array1.size) {
array1[j] = array[i]
}
}
val size = array.size - 1
val size1 = size
for (i in 0..size1) {
foo(array[i], array[i])
}
for (i in 0..array.size - 2) {
array[i+1] = array[i]
}
}
var needSmallArray = true
class WithGetter() {
val array: Array<Int>
get() = if (needSmallArray)
Array(10) { 100 }
else
Array(100) { 100 }
}
class Delegate {
operator fun getValue(thisRef: Any?, property: KProperty<*>): Array<Int> {
return if (needSmallArray)
Array(10) { 100 }
else
Array(100) { 100 }
}
}
class WithDelegates {
val array by Delegate()
}
open class Base {
open val array = Array(10) { 100 }
val array1 by Delegate()
}
class Child : Base() {
override val array: Array<Int>
get() = if (needSmallArray)
Array(10) { 100 }
else
Array(100) { 100 }
}
@Test fun withGetter() {
val obj = WithGetter()
needSmallArray = false
assertFailsWith<IndexOutOfBoundsException> {
for (i in 0..obj.array.size-1) {
needSmallArray = true
obj.array[i] = 6
needSmallArray = false
}
}
}
@Test fun delegatedProperty() {
val obj = WithDelegates()
needSmallArray = false
assertFailsWith<IndexOutOfBoundsException> {
for (i in 0..obj.array.size-1) {
needSmallArray = true
obj.array[i] = 6
needSmallArray = false
}
}
}
@Test fun inheritance() {
val obj = Child()
val base = Base()
needSmallArray = false
assertFailsWith<IndexOutOfBoundsException> {
for (i in 0..obj.array.size-1) {
needSmallArray = true
obj.array[i] = 6
needSmallArray = false
}
}
needSmallArray = false
assertFailsWith<IndexOutOfBoundsException> {
for (i in 0..obj.array1.size-1) {
needSmallArray = true
obj.array1[i] = 6
needSmallArray = false
}
}
needSmallArray = false
assertFailsWith<IndexOutOfBoundsException> {
for (i in 0..obj.array.size-1) {
needSmallArray = true
base.array[i] = 6
needSmallArray = false
}
}
}
val array: Array<Int> = arrayOf(1)
get() = if (needSmallArray) field else arrayOf(1, 2, 3)
@Test fun customeGetter() {
val a = array
needSmallArray = false
assertFailsWith<IndexOutOfBoundsException> {
for (index in 0 until array.size) {
a[index] = 6
}
}
}
class First(initArray: Array<Int>) {
val array = initArray
}
class Second(initArray: Array<Int>){
val first = First(initArray)
}
class Third(initArray: Array<Int>) {
val second = Second(initArray)
}
@Test fun differentObjects() {
val a = Third(arrayOf(1, 2, 3, 4, 5))
val b = Third(arrayOf(1, 2))
assertFailsWith<IndexOutOfBoundsException> {
for (i in 0..a.second.first.array.size-1) {
b.second.first.array[i] = 6
}
}
}
class Foo(size: Int) {
val array = IntArray(size)
}
class Bar {
val smallFoo = Foo(1)
val largeFoo = Foo(10)
val smallArray = smallFoo.array
val largeArray = largeFoo.array
}
@Test fun differentArrays() {
val bar = Bar()
assertFailsWith<IndexOutOfBoundsException> {
for (index in 0 until bar.largeArray.size) {
bar.smallArray[index] = 6
}
}
}
+89
View File
@@ -0,0 +1,89 @@
/*
* 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.
*/
import kotlin.test.*
fun foo(a: Int, b : Int): Int = a + b * 2
fun box(): String {
val array = Array(10) { 100 }
val array1 = Array(3) { 0 }
var length = array.size - 1
var sum = 0
array.forEach {
sum += it
}
for (i in array.indices) {
array[i] = 6
}
for (i in 0 until array.size) {
array[i] = 7
}
for (i in array.size - 1 downTo 1) {
array[i] = 7
}
for (it in array) {
sum += it
}
for (i in 0..array.size - 1 step 2) {
array[i] = 7
}
for (i in 0 until array.size step 2) {
array[i] = 7
}
for (i in array.indices step 2) {
array[i] = 6
}
for (i in array.size - 1 downTo 1 step 2) {
array[i] = 7
}
for ((index, value) in array.withIndex()) {
array[index] = 8
}
for ((i, v) in (0..array.size - 1 step 2).withIndex()) {
array[v] = 8
array[i] = 6
}
for (i in array.reversed()) {
sum += i
}
for (i in (0..array.size-1).reversed()) {
array [i] = 10
}
for (i in 0 until array.size) {
array[i] = 7
for (j in 0 until array1.size) {
array1[j] = array[i]
}
}
val size = array.size - 1
val size1 = size
for (i in 0..size1) {
foo(array[i], array[i])
}
for (i in 0..array.size - 2) {
array[i+1] = array[i]
}
if (array.toList() != listOf(7, 7, 7, 7, 7, 7, 7, 7, 7, 7)) return "FAIL 1: ${array.toList()}"
if (array1.toList() != listOf(7, 7, 7)) return "FAIL 2: ${array1.toList()}"
return "OK"
}
@@ -0,0 +1,22 @@
/*
* 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.
*/
import kotlin.test.*
var needSmallArray = true
val array: Array<Int> = arrayOf(1)
get() = if (needSmallArray) field else arrayOf(1, 2, 3)
fun box(): String {
val a = array
needSmallArray = false
assertFailsWith<IndexOutOfBoundsException> {
for (index in 0 until array.size) {
a[index] = 6
}
}
return "OK"
}
@@ -0,0 +1,35 @@
/*
* 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.
*/
import kotlin.test.*
import kotlin.reflect.KProperty
var needSmallArray = true
class Delegate {
operator fun getValue(thisRef: Any?, property: KProperty<*>): Array<Int> {
return if (needSmallArray)
Array(10) { 100 }
else
Array(100) { 100 }
}
}
class WithDelegates {
val array by Delegate()
}
fun box(): String {
val obj = WithDelegates()
needSmallArray = false
assertFailsWith<IndexOutOfBoundsException> {
for (i in 0..obj.array.size-1) {
needSmallArray = true
obj.array[i] = 6
needSmallArray = false
}
}
return "OK"
}
@@ -0,0 +1,28 @@
/*
* 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.
*/
import kotlin.test.*
class Foo(size: Int) {
val array = IntArray(size)
}
class Bar {
val smallFoo = Foo(1)
val largeFoo = Foo(10)
val smallArray = smallFoo.array
val largeArray = largeFoo.array
}
fun box(): String {
val bar = Bar()
assertFailsWith<IndexOutOfBoundsException> {
for (index in 0 until bar.largeArray.size) {
bar.smallArray[index] = 6
}
}
return "OK"
}
@@ -0,0 +1,51 @@
/*
* 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.
*/
import kotlin.test.*
class First(initArray: Array<Int>) {
val array = initArray
}
class Second(initArray: Array<Int>){
val first = First(initArray)
}
class Third(initArray: Array<Int>) {
val second = Second(initArray)
}
fun box(): String {
val a = Third(arrayOf(1, 2, 3, 4, 5))
val b = Third(arrayOf(1, 2))
assertFailsWith<IndexOutOfBoundsException> {
for (i in 0..a.second.first.array.size-1) {
b.second.first.array[i] = 6
}
}
return "OK"
}
class Foo(size: Int) {
val array = IntArray(size)
}
class Bar {
val smallFoo = Foo(1)
val largeFoo = Foo(10)
val smallArray = smallFoo.array
val largeArray = largeFoo.array
}
@Test fun differentArrays() {
val bar = Bar()
assertFailsWith<IndexOutOfBoundsException> {
for (index in 0 until bar.largeArray.size) {
bar.smallArray[index] = 6
}
}
}
@@ -0,0 +1,59 @@
/*
* 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.
*/
import kotlin.test.*
fun box(): String {
val array = Array(10) { 0L }
val array1 = Array(3) { 0L }
var j = 4
assertFailsWith<IndexOutOfBoundsException> {
for (i in array.size - 1 downTo 0) {
array[j] = 6
j++
}
}
assertFailsWith<IndexOutOfBoundsException> {
for (i in array.size - 1 downTo 0) {
array[i * 2] = 6
}
}
assertFailsWith<IndexOutOfBoundsException> {
for (i in array.size - 1 downTo 0) {
array1[i] = 6
}
}
var a = array.size - 1
val b = ++a
val c = b
assertFailsWith<IndexOutOfBoundsException> {
for (i in c downTo 0) {
array[i] = 6
}
}
assertFailsWith<IndexOutOfBoundsException> {
for (i in array.size + 1 downTo 0) {
array[i] = 6
}
}
assertFailsWith<IndexOutOfBoundsException> {
for (i in array.size - 1 downTo -1) {
array[i] = 6
}
}
assertFailsWith<IndexOutOfBoundsException> {
for (i in array.size downTo 0) {
array[i] = 6
}
}
return "OK"
}
@@ -0,0 +1,49 @@
/*
* 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.
*/
import kotlin.test.*
fun box(): String {
val array = UIntArray(10) { 0U }
val array1 = UIntArray(3) { 0U }
var j = 8
assertFailsWith<IndexOutOfBoundsException> {
for (i in array.size - 1 downTo 0 step 2) {
array[j] = 6U
j++
}
}
assertFailsWith<IndexOutOfBoundsException> {
for (i in array.size - 1 downTo 1 step 2) {
array[i + 1] = 6U
}
}
assertFailsWith<IndexOutOfBoundsException> {
for (i in array.size - 1 downTo 1 step 2) {
array1[i] = 6U
}
}
assertFailsWith<IndexOutOfBoundsException> {
for (i in (array.size / 0.2).toInt() downTo 1 step 2) {
array[i] = 6U
}
}
assertFailsWith<IndexOutOfBoundsException> {
for (i in array.size - 1 downTo -3 step 2) {
array[i] = 6U
}
}
assertFailsWith<IndexOutOfBoundsException> {
for (i in array.size downTo 1 step 2) {
array[i] = 6U
}
}
return "OK"
}
@@ -0,0 +1,16 @@
/*
* 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.
*/
import kotlin.test.*
fun box(): String {
val array = Array(10) { 0 }
assertFailsWith<IndexOutOfBoundsException> {
array.forEachIndexed { index, _ ->
array[index + 1] = 1
}
}
return "OK"
}
@@ -0,0 +1,31 @@
/*
* 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.
*/
import kotlin.test.*
fun box(): String {
val array = Array(10) { 0 }
val array1 = Array(3) { 0 }
var j = 4
assertFailsWith<IndexOutOfBoundsException> {
for (i in array.indices) {
array[j] = 6
j++
}
}
assertFailsWith<IndexOutOfBoundsException> {
for (i in array.indices) {
array[i + 1] = 6
}
}
assertFailsWith<IndexOutOfBoundsException> {
for (i in array.indices) {
array1[i] = 6
}
}
return "OK"
}
@@ -0,0 +1,31 @@
/*
* 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.
*/
import kotlin.test.*
fun box(): String {
val array = Array(10) { 0L }
val array1 = Array(3) { 0L }
var j = 8
assertFailsWith<IndexOutOfBoundsException> {
for (i in array.indices step 2) {
array[j] = 6
j++
}
}
assertFailsWith<IndexOutOfBoundsException> {
for (i in array.indices step 2) {
array[i - 1] = 6
}
}
assertFailsWith<IndexOutOfBoundsException> {
for (i in array.indices step 2) {
array1[i] = 6
}
}
return "OK"
}
@@ -0,0 +1,57 @@
/*
* 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.
*/
import kotlin.test.*
fun box(): String {
val array = Array(10) { 0L }
val array1 = Array(3) { 0L }
var j = 4
assertFailsWith<IndexOutOfBoundsException> {
for (i in 0..array.size - 1) {
array[j] = 6
j++
}
}
var length = array.size - 1
length = 2 * length
assertFailsWith<IndexOutOfBoundsException> {
for (i in 0..length) {
array[i] = 6
}
}
assertFailsWith<IndexOutOfBoundsException> {
for (i in 0..array.size - 1) {
array[i + 1] = 6
}
}
assertFailsWith<IndexOutOfBoundsException> {
for (i in 0..array.size - 1) {
array1[i] = 6
}
}
assertFailsWith<IndexOutOfBoundsException> {
for (i in 0..array.size + 1) {
array[i] = 6
}
}
assertFailsWith<IndexOutOfBoundsException> {
for (i in -1..array.size - 1) {
array[i] = 6
}
}
assertFailsWith<IndexOutOfBoundsException> {
for (i in 0..array.size) {
array[i] = 6
}
}
return "OK"
}
@@ -0,0 +1,49 @@
/*
* 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.
*/
import kotlin.test.*
fun box(): String {
val array = Array(10) { 0L }
val array1 = Array(3) { 0L }
var j = 8
assertFailsWith<IndexOutOfBoundsException> {
for (i in 0..array.size - 1 step 2) {
array[j] = 6
j++
}
}
assertFailsWith<IndexOutOfBoundsException> {
for (i in 0..array.size - 1 step 2) {
array[i - 1] = 6
}
}
assertFailsWith<IndexOutOfBoundsException> {
for (i in 0..array.size - 1 step 2) {
array1[i] = 6
}
}
assertFailsWith<IndexOutOfBoundsException> {
for (i in 0..array.size + 1 step 2) {
array[i] = 6
}
}
assertFailsWith<IndexOutOfBoundsException> {
for (i in -1..array.size - 1 step 2) {
array[i] = 6
}
}
assertFailsWith<IndexOutOfBoundsException> {
for (i in 0..array.size step 2) {
array[i] = 6
}
}
return "OK"
}
+38
View File
@@ -0,0 +1,38 @@
/*
* 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.
*/
import kotlin.test.*
fun box(): String {
val array = Array(10) { 100 }
val array1 = Array(3) { 0 }
var j = 8
assertFailsWith<IndexOutOfBoundsException> {
for (i in (0..array.size-1).reversed()) {
array[j] = 6
j++
}
}
assertFailsWith<IndexOutOfBoundsException> {
for (i in (0 until array.size).reversed()) {
array1[i] = 6
}
}
assertFailsWith<IndexOutOfBoundsException> {
for (i in (0..array.size).reversed()) {
array[i] = 6
}
}
assertFailsWith<IndexOutOfBoundsException> {
for (i in (array.size downTo 0).reversed()) {
array[i] = 6
}
}
return "OK"
}
@@ -0,0 +1,37 @@
/*
* 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.
*/
import kotlin.test.*
fun box(): String {
val array = Array(10) { 0L }
val array1 = Array(3) { 0L }
var j = 4
assertFailsWith<IndexOutOfBoundsException> {
for (i in 0 until array.size) {
array[j] = 6
j++
}
}
assertFailsWith<IndexOutOfBoundsException> {
for (i in 0 until array.size) {
array[i - 1] = 6
}
}
assertFailsWith<IndexOutOfBoundsException> {
for (i in 0 until array.size) {
array1[i] = 6
}
}
assertFailsWith<IndexOutOfBoundsException> {
for (i in 0 until array.size + 10) {
array[i] = 6
}
}
return "OK"
}
@@ -0,0 +1,43 @@
/*
* 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.
*/
import kotlin.test.*
fun box(): String {
val array = Array(10) { 100 }
val array1 = Array(3) { 0 }
var j = 8
assertFailsWith<IndexOutOfBoundsException> {
for ((index, value) in array.withIndex()) {
array[j] = 6
j++
}
}
assertFailsWith<IndexOutOfBoundsException> {
for ((index, value) in array.withIndex()) {
array[index + 1] = 6
}
}
assertFailsWith<IndexOutOfBoundsException> {
for ((index, value) in array.withIndex()) {
array[value] = 6
}
}
assertFailsWith<IndexOutOfBoundsException> {
for ((i, v) in (0..array.size + 30 step 2).withIndex()) {
array[i] = 6
}
}
assertFailsWith<IndexOutOfBoundsException> {
for ((i, v) in (0..array.size).withIndex()) {
array[v] = 8
}
}
return "OK"
}
+62
View File
@@ -0,0 +1,62 @@
/*
* 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.
*/
import kotlin.reflect.KProperty
import kotlin.test.*
var needSmallArray = true
class Delegate {
operator fun getValue(thisRef: Any?, property: KProperty<*>): Array<Int> {
return if (needSmallArray)
Array(10) { 100 }
else
Array(100) { 100 }
}
}
open class Base {
open val array = Array(10) { 100 }
val array1 by Delegate()
}
class Child : Base() {
override val array: Array<Int>
get() = if (needSmallArray)
Array(10) { 100 }
else
Array(100) { 100 }
}
fun box(): String {
val obj = Child()
val base = Base()
needSmallArray = false
assertFailsWith<IndexOutOfBoundsException> {
for (i in 0..obj.array.size-1) {
needSmallArray = true
obj.array[i] = 6
needSmallArray = false
}
}
needSmallArray = false
assertFailsWith<IndexOutOfBoundsException> {
for (i in 0..obj.array1.size-1) {
needSmallArray = true
obj.array1[i] = 6
needSmallArray = false
}
}
needSmallArray = false
assertFailsWith<IndexOutOfBoundsException> {
for (i in 0..obj.array.size-1) {
needSmallArray = true
base.array[i] = 6
needSmallArray = false
}
}
return "OK"
}
+29
View File
@@ -0,0 +1,29 @@
/*
* 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.
*/
import kotlin.test.*
var needSmallArray = true
class WithGetter() {
val array: Array<Int>
get() = if (needSmallArray)
Array(10) { 100 }
else
Array(100) { 100 }
}
fun box(): String {
val obj = WithGetter()
needSmallArray = false
assertFailsWith<IndexOutOfBoundsException> {
for (i in 0..obj.array.size-1) {
needSmallArray = true
obj.array[i] = 6
needSmallArray = false
}
}
return "OK"
}
+9 -9
View File
@@ -3,8 +3,6 @@
* that can be found in the LICENSE file. * that can be found in the LICENSE file.
*/ */
package codegen.boxing.box_cache0
import kotlin.test.* import kotlin.test.*
fun <T> areSame(arg1: T, arg2: T): Boolean { fun <T> areSame(arg1: T, arg2: T): Boolean {
@@ -15,7 +13,7 @@ fun Boolean.oneIfTrueElseZero(): Int {
return if (this) 1 else 0 return if (this) 1 else 0
} }
@Test fun runTest() { fun box(): String {
var acc = 0 var acc = 0
val range = 1000 val range = 1000
@@ -24,35 +22,37 @@ fun Boolean.oneIfTrueElseZero(): Int {
acc += areSame(i, j).oneIfTrueElseZero() acc += areSame(i, j).oneIfTrueElseZero()
} }
} }
println(acc) if (acc != 2) "FAIL 1: $acc"
acc = 0 acc = 0
for (i in Byte.MIN_VALUE..Byte.MAX_VALUE) { for (i in Byte.MIN_VALUE..Byte.MAX_VALUE) {
acc += areSame(i, i).oneIfTrueElseZero() acc += areSame(i, i).oneIfTrueElseZero()
} }
println(acc) if (acc != 256) "FAIL 2: $acc"
acc = 0 acc = 0
for (i in Short.MIN_VALUE..Short.MAX_VALUE) { for (i in Short.MIN_VALUE..Short.MAX_VALUE) {
acc += areSame(i, i).oneIfTrueElseZero() acc += areSame(i, i).oneIfTrueElseZero()
} }
println(acc) if (acc != 256) "FAIL 3: $acc"
acc = 0 acc = 0
for (i in 0.toChar()..range.toChar()) { for (i in 0.toChar()..range.toChar()) {
acc += areSame(i, i).oneIfTrueElseZero() acc += areSame(i, i).oneIfTrueElseZero()
} }
println(acc) if (acc != 256) "FAIL 4: $acc"
acc = 0 acc = 0
for (i in -range..range) { for (i in -range..range) {
acc += areSame(i, i).oneIfTrueElseZero() acc += areSame(i, i).oneIfTrueElseZero()
} }
println(acc) if (acc != 256) "FAIL 5: $acc"
acc = 0 acc = 0
for (i in -range.toLong()..range.toLong()) { for (i in -range.toLong()..range.toLong()) {
acc += areSame(i, i).oneIfTrueElseZero() 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. * that can be found in the LICENSE file.
*/ */
package codegen.boxing.boxing0
import kotlin.test.* import kotlin.test.*
class Box<T>(t: T) { class Box<T>(t: T) {
var value = t var value = t
} }
@Test fun runTest() { fun box(): String {
val box: Box<Int> = Box<Int>(17) val box: Box<Int> = Box<Int>(17)
println(box.value) if (box.value != 17) return "FAIL 1: ${box.value}"
val nonConst = 17 val nonConst = 17
val box2: Box<Int> = Box<Int>(nonConst) 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. * that can be found in the LICENSE file.
*/ */
package codegen.boxing.boxing1
import kotlin.test.* import kotlin.test.*
val sb = StringBuilder()
fun foo(arg: Any) { fun foo(arg: Any) {
println(arg.toString()) sb.appendLine(arg.toString())
} }
@Test fun runTest() { fun box(): String {
foo(1) foo(1)
foo(2u) foo(2u)
foo(false) foo(false)
@@ -24,4 +24,17 @@ fun foo(arg: Any) {
foo(nonConstUInt) foo(nonConstUInt)
foo(nonConstBool) foo(nonConstBool)
foo(nonConstString) 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. * that can be found in the LICENSE file.
*/ */
package codegen.boxing.boxing10
import kotlin.test.* import kotlin.test.*
@Test fun runTest() { fun box(): String {
val FALSE: Boolean? = false val FALSE: Boolean? = false
if (FALSE != null) { if (FALSE != null) {
do { do {
println("Ok") return "OK"
} while (FALSE) } while (FALSE)
} }
return "FAIL"
} }
@@ -1 +0,0 @@
Ok
+7 -4
View File
@@ -3,11 +3,11 @@
* that can be found in the LICENSE file. * that can be found in the LICENSE file.
*/ */
package codegen.boxing.boxing11
import kotlin.test.* import kotlin.test.*
fun printInt(x: Int) = println(x) val sb = StringBuilder()
fun printInt(x: Int) = sb.appendLine(x)
class Foo(val value: Int?) { class Foo(val value: Int?) {
fun foo() { fun foo() {
@@ -15,7 +15,10 @@ class Foo(val value: Int?) {
} }
} }
@Test fun runTest() { fun box(): String {
Foo(17).foo() Foo(17).foo()
Foo(null).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. * that can be found in the LICENSE file.
*/ */
package codegen.boxing.boxing12
import kotlin.test.* import kotlin.test.*
val sb = StringBuilder()
fun foo(x: Number) { fun foo(x: Number) {
println(x.toByte()) sb.appendLine(x.toByte())
} }
@Test fun runTest() { fun box(): String {
foo(18) foo(18)
val nonConst = 18 val nonConst = 18
foo(nonConst) 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. * that can be found in the LICENSE file.
*/ */
package codegen.boxing.boxing13
import kotlin.test.* import kotlin.test.*
val sb = StringBuilder()
fun is42(x: Any?) { fun is42(x: Any?) {
println(x == 42) sb.appendLine(x == 42)
println(42 == x) sb.appendLine(42 == x)
} }
@Test fun runTest() { fun box(): String {
is42(16) is42(16)
is42(42) is42(42)
is42("42") is42("42")
@@ -22,4 +22,21 @@ fun is42(x: Any?) {
is42(nonConst16) is42(nonConst16)
is42(nonConst42) is42(nonConst42)
is42(nonConst42String) 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. * that can be found in the LICENSE file.
*/ */
package codegen.boxing.boxing14
import kotlin.test.* import kotlin.test.*
@Test fun runTest() { val sb = StringBuilder()
fun box(): String {
42.println() 42.println()
val nonConst = 42 val nonConst = 42
nonConst.println() 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. * that can be found in the LICENSE file.
*/ */
package codegen.boxing.boxing15
import kotlin.test.* import kotlin.test.*
@Test fun runTest() { fun box(): String {
println(foo(17)) val res1 = foo(17)
if (res1 != 17) return "FAIL 1: $res1"
val nonConst = 17 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 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. * that can be found in the LICENSE file.
*/ */
package codegen.boxing.boxing2
import kotlin.test.* import kotlin.test.*
fun printInt(x: Int) = println(x) val sb = StringBuilder()
fun printBoolean(x: Boolean) = println(x)
fun printUInt(x: UInt) = println(x) 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) { fun foo(arg: Any) {
if (arg is Int) if (arg is Int)
@@ -19,10 +19,10 @@ fun foo(arg: Any) {
else if (arg is UInt) else if (arg is UInt)
printUInt(arg) printUInt(arg)
else else
println("other") sb.appendLine("other")
} }
@Test fun runTest() { fun box(): String {
foo(1) foo(1)
foo(2u) foo(2u)
foo(true) foo(true)
@@ -35,4 +35,17 @@ fun foo(arg: Any) {
foo(nonConstUInt) foo(nonConstUInt)
foo(nonConstBool) foo(nonConstBool)
foo(nonConstString) 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

Some files were not shown because too many files have changed in this diff Show More