Minor, rename codegen tests on platformName and platformStatic
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
import kotlin.platform.platformStatic
|
||||
|
||||
object A {
|
||||
|
||||
val b: String = "OK"
|
||||
|
||||
@platformStatic val c: String = "OK"
|
||||
|
||||
@platformStatic fun test1() : String {
|
||||
return {b}()
|
||||
}
|
||||
|
||||
@platformStatic fun test2() : String {
|
||||
return {test1()}()
|
||||
}
|
||||
|
||||
fun test3(): String {
|
||||
return {"1".test5()}()
|
||||
}
|
||||
|
||||
@platformStatic fun test4(): String {
|
||||
return {"1".test5()}()
|
||||
}
|
||||
|
||||
@platformStatic fun String.test5() : String {
|
||||
return {this + b}()
|
||||
}
|
||||
|
||||
fun test6(): String {
|
||||
return {c}()
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
if (A.test1() != "OK") return "fail 1"
|
||||
|
||||
if (A.test2() != "OK") return "fail 2"
|
||||
|
||||
if (A.test3() != "1OK") return "fail 3"
|
||||
|
||||
if (A.test4() != "1OK") return "fail 4"
|
||||
|
||||
if (with(A) {"1".test5()} != "1OK") return "fail 5"
|
||||
|
||||
if (A.test6() != "OK") return "fail 6"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
import kotlin.platform.platformStatic
|
||||
|
||||
class B(var s: Int = 0) {
|
||||
|
||||
}
|
||||
|
||||
object A {
|
||||
|
||||
fun test1(v: B) {
|
||||
v += B(1000)
|
||||
}
|
||||
|
||||
@platformStatic fun B.plusAssign(b: B) {
|
||||
this.s += b.s
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
|
||||
val b1 = B(11)
|
||||
|
||||
with(A) {
|
||||
b1 += B(1000)
|
||||
}
|
||||
|
||||
if (b1.s != 1011) return "fail 1"
|
||||
|
||||
val b = B(11)
|
||||
A.test1(b)
|
||||
if (b.s != 1011) return "fail 2"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import kotlin.platform.platformStatic
|
||||
|
||||
object A {
|
||||
|
||||
@platformStatic fun test(b: String = "OK") : String {
|
||||
return b
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
|
||||
if (A.test() != "OK") return "fail 1"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
import kotlin.platform.platformStatic
|
||||
|
||||
object AX {
|
||||
|
||||
@platformStatic val c: String = "OK"
|
||||
|
||||
@platformStatic fun aStatic(): String {
|
||||
return AX.b()
|
||||
}
|
||||
|
||||
fun aNonStatic(): String {
|
||||
return AX.b()
|
||||
}
|
||||
|
||||
@platformStatic fun b(): String {
|
||||
return "OK"
|
||||
}
|
||||
|
||||
fun getProperty(): String {
|
||||
return AX.c
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun box() : String {
|
||||
|
||||
if (AX.aStatic() != "OK") return "fail 1"
|
||||
|
||||
if (AX.aNonStatic() != "OK") return "fail 2"
|
||||
|
||||
if (AX.getProperty() != "OK") return "fail 3"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import kotlin.platform.platformStatic
|
||||
|
||||
var holder = ""
|
||||
|
||||
fun getA(): A {
|
||||
holder += "OK"
|
||||
return A
|
||||
}
|
||||
|
||||
object A {
|
||||
@platformStatic fun a(): String {
|
||||
return holder
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return getA().a()
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
import O.p
|
||||
import O.f
|
||||
import C.Companion.p1
|
||||
import C.Companion.f1
|
||||
|
||||
object O {
|
||||
@JvmStatic
|
||||
fun f(): Int = 3
|
||||
|
||||
@JvmStatic
|
||||
val p: Int = 6
|
||||
}
|
||||
|
||||
class C {
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun f1(): Int = 3
|
||||
|
||||
@JvmStatic
|
||||
val p1: Int = 6
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
if (p + f() != 9) return "fail"
|
||||
if (p1 + f1() != 9) return "fail2"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import kotlin.platform.platformStatic
|
||||
|
||||
object A {
|
||||
|
||||
@platformStatic inline fun test(b: String = "OK") : String {
|
||||
return b
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
|
||||
if (A.test() != "OK") return "fail 1"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
import kotlin.platform.platformStatic
|
||||
|
||||
object A {
|
||||
|
||||
@platformStatic var a: Int = 1
|
||||
|
||||
var b: Int = 1
|
||||
@platformStatic get
|
||||
|
||||
var c: Int = 1
|
||||
@platformStatic set
|
||||
|
||||
}
|
||||
|
||||
var holder = ""
|
||||
fun getA(): A {
|
||||
holder += "getA()"
|
||||
return A
|
||||
}
|
||||
|
||||
|
||||
fun box(): String {
|
||||
|
||||
var p = A.a++
|
||||
if (p != 1 || A.a != 2) return "fail 1"
|
||||
|
||||
p = A.b++
|
||||
if (p != 1 || A.b != 2) return "fail 2"
|
||||
|
||||
p = A.c++
|
||||
if (p != 1 || A.c != 2) return "fail 3"
|
||||
|
||||
|
||||
p = getA().a++
|
||||
if (p != 2 || A.a != 3 || holder != "getA()") return "fail 4: $holder"
|
||||
holder = ""
|
||||
|
||||
p = getA().b++
|
||||
if (p != 2 || A.b != 3 || holder != "getA()") return "fail 5: $holder"
|
||||
holder = ""
|
||||
|
||||
p = getA().c++
|
||||
if (p != 2 || A.c != 3 || holder != "getA()") return "fail 6: $holder"
|
||||
holder = ""
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
import kotlin.platform.platformStatic
|
||||
|
||||
object A {
|
||||
|
||||
@platformStatic var a: Int = 1
|
||||
|
||||
var b: Int = 1
|
||||
@platformStatic get
|
||||
|
||||
var c: Int = 1
|
||||
@platformStatic set
|
||||
|
||||
}
|
||||
|
||||
var holder = ""
|
||||
fun getA(): A {
|
||||
holder += "getA()"
|
||||
return A
|
||||
}
|
||||
|
||||
|
||||
fun box(): String {
|
||||
|
||||
var p = ++A.a
|
||||
if (p != 2 || A.a != 2) return "fail 1"
|
||||
|
||||
p = ++A.b
|
||||
if (p != 2 || A.b != 2) return "fail 2"
|
||||
|
||||
p = ++A.c
|
||||
if (p != 2 || A.c != 2) return "fail 3"
|
||||
|
||||
|
||||
p = ++getA().a
|
||||
if (p != 3 || A.a != 3 || holder != "getA()") return "fail 4: $holder"
|
||||
holder = ""
|
||||
|
||||
p = ++getA().b
|
||||
if (p != 3 || A.b != 3 || holder != "getA()") return "fail 5: $holder"
|
||||
holder = ""
|
||||
|
||||
p = ++getA().c
|
||||
if (p != 3 || A.c != 3 || holder != "getA()") return "fail 6: $holder"
|
||||
holder = ""
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import kotlin.platform.platformStatic
|
||||
|
||||
object A {
|
||||
|
||||
private @platformStatic fun a(): String {
|
||||
return "OK"
|
||||
}
|
||||
|
||||
object Z {
|
||||
val p = a()
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return A.Z.p
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
import kotlin.platform.platformStatic
|
||||
|
||||
var holder = ""
|
||||
|
||||
fun getA(): A {
|
||||
holder += "getA()"
|
||||
return A
|
||||
}
|
||||
|
||||
object A {
|
||||
|
||||
@platformStatic var a: Int = 1
|
||||
|
||||
var b: Int = 1
|
||||
@platformStatic get
|
||||
|
||||
var c: Int = 1
|
||||
@platformStatic set
|
||||
|
||||
}
|
||||
|
||||
|
||||
fun box(): String {
|
||||
|
||||
if (getA().a != 1 || holder != "getA()") return "fail 1: $holder"
|
||||
holder = ""
|
||||
|
||||
if (getA().b != 1 || holder != "getA()") return "fail 2: $holder"
|
||||
holder = ""
|
||||
|
||||
if (getA().c != 1 || holder != "getA()") return "fail 3: $holder"
|
||||
holder = ""
|
||||
|
||||
getA().a = 2
|
||||
if (getA().a != 2 || holder != "getA()getA()") return "fail 1: $holder"
|
||||
holder = ""
|
||||
|
||||
getA().b = 2
|
||||
if (getA().b != 2 || holder != "getA()getA()") return "fail 2: $holder"
|
||||
holder = ""
|
||||
|
||||
getA().c = 2
|
||||
if (getA().c != 2 || holder != "getA()getA()") return "fail 3: $holder"
|
||||
holder = ""
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import kotlin.platform.platformStatic
|
||||
|
||||
object X {
|
||||
@platformStatic val x = "OK"
|
||||
|
||||
fun fn(value : String = x): String = value
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return X.fn()
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
import kotlin.platform.platformStatic
|
||||
|
||||
object A {
|
||||
|
||||
val b: String = "OK"
|
||||
|
||||
@platformStatic val c: String = "OK"
|
||||
|
||||
@platformStatic fun test1() : String {
|
||||
return b
|
||||
}
|
||||
|
||||
@platformStatic fun test2() : String {
|
||||
return test1()
|
||||
}
|
||||
|
||||
fun test3(): String {
|
||||
return "1".test5()
|
||||
}
|
||||
|
||||
@platformStatic fun test4(): String {
|
||||
return "1".test5()
|
||||
}
|
||||
|
||||
@platformStatic fun String.test5() : String {
|
||||
return this + b
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
if (A.test1() != "OK") return "fail 1"
|
||||
|
||||
if (A.test2() != "OK") return "fail 2"
|
||||
|
||||
if (A.test3() != "1OK") return "fail 3"
|
||||
|
||||
if (A.test4() != "1OK") return "fail 4"
|
||||
|
||||
if (with(A) {"1".test5()} != "1OK") return "fail 5"
|
||||
|
||||
if (A.c != "OK") return "fail 6"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import kotlin.platform.*
|
||||
|
||||
class C {
|
||||
companion object {
|
||||
private @platformStatic fun foo(): String {
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
fun bar(): String {
|
||||
return foo()
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return C().bar()
|
||||
}
|
||||
Reference in New Issue
Block a user