[K/N] Add tests for static initialisation of ConstantValues

This commit is contained in:
Pavel Kunyavskiy
2021-08-05 15:36:42 +03:00
committed by Space
parent 89414eb214
commit 533eb589cb
28 changed files with 269 additions and 0 deletions
@@ -14,5 +14,8 @@ class Box<T>(t: T) {
@Test fun runTest() {
val box: Box<Int> = Box<Int>(17)
println(box.value)
val nonConst = 17
val box2: Box<Int> = Box<Int>(nonConst)
println(box2.value)
}
@@ -1 +1,2 @@
17
17
@@ -13,6 +13,15 @@ fun foo(arg: Any) {
@Test fun runTest() {
foo(1)
foo(2u)
foo(false)
foo("Hello")
val nonConstInt = 1
val nonConstUInt = 2u
val nonConstBool = false
val nonConstString = "Hello"
foo(nonConstInt)
foo(nonConstUInt)
foo(nonConstBool)
foo(nonConstString)
}
@@ -1,3 +1,8 @@
1
2
false
Hello
1
2
false
Hello
@@ -13,4 +13,6 @@ fun foo(x: Number) {
@Test fun runTest() {
foo(18)
val nonConst = 18
foo(nonConst)
}
@@ -1 +1,2 @@
18
18
@@ -16,4 +16,10 @@ fun is42(x: Any?) {
is42(16)
is42(42)
is42("42")
val nonConst16 = 16
val nonConst42 = 42
val nonConst42String = "42"
is42(nonConst16)
is42(nonConst42)
is42(nonConst42String)
}
@@ -4,3 +4,9 @@ true
true
false
false
false
false
true
true
false
false
@@ -9,6 +9,8 @@ import kotlin.test.*
@Test fun runTest() {
42.println()
val nonConst = 42
nonConst.println()
}
fun <T> T.println() = println(this.toString())
@@ -1 +1,2 @@
42
42
@@ -9,6 +9,8 @@ import kotlin.test.*
@Test fun runTest() {
println(foo(17))
val nonConst = 17
println(foo(nonConst))
}
fun <T : Int> foo(x: T): Int = x
@@ -1 +1,2 @@
17
17
@@ -9,18 +9,30 @@ import kotlin.test.*
fun printInt(x: Int) = println(x)
fun printBoolean(x: Boolean) = println(x)
fun printUInt(x: UInt) = println(x)
fun foo(arg: Any) {
if (arg is Int)
printInt(arg)
else if (arg is Boolean)
printBoolean(arg)
else if (arg is UInt)
printUInt(arg)
else
println("other")
}
@Test fun runTest() {
foo(1)
foo(2u)
foo(true)
foo("Hello")
val nonConstInt = 1
val nonConstUInt = 2u
val nonConstBool = true
val nonConstString = "Hello"
foo(nonConstInt)
foo(nonConstUInt)
foo(nonConstBool)
foo(nonConstString)
}
@@ -1,3 +1,8 @@
1
2
true
other
1
2
true
other
@@ -16,4 +16,6 @@ fun foo(arg: Int?) {
@Test fun runTest() {
foo(42)
val nonConst = 42
foo(nonConst)
}
@@ -1 +1,2 @@
42
42
@@ -16,4 +16,6 @@ fun foo(arg: Any?) {
@Test fun runTest() {
foo(16)
val nonConst = 16
foo(nonConst)
}
@@ -1 +1,2 @@
16
16
@@ -16,4 +16,8 @@ fun foo(arg: Int?) {
@Test fun runTest() {
foo(null)
foo(42)
val nonConstNull = null
val nonConstInt = 42
foo(nonConstNull)
foo(nonConstInt)
}
@@ -1,2 +1,4 @@
16
42
16
42
@@ -16,4 +16,8 @@ fun foo(arg: Any) {
@Test fun runTest() {
foo(42)
foo("Hello")
val nonConstInt = 42
val nonConstString = "Hello"
foo(nonConstInt)
foo(nonConstString)
}
@@ -1,2 +1,4 @@
42
16
42
16
@@ -21,4 +21,8 @@ fun foo(arg: Any) {
@Test fun runTest() {
foo(1)
foo("Hello")
val nonConstInt = 1
val nonConstString = "Hello"
foo(nonConstInt)
foo(nonConstString)
}
@@ -1,2 +1,4 @@
1
0
1
0
@@ -15,4 +15,9 @@ fun foo(vararg args: Any?) {
@Test fun runTest() {
foo(1, null, true, "Hello")
val nonConstInt = 1
val nonConstNull = null
val nonConstBool = true
val nonConstString = "Hello"
foo(nonConstInt, nonConstNull, nonConstBool, nonConstString)
}
@@ -2,3 +2,7 @@
null
true
Hello
1
null
true
Hello