Tests for callable references and inline classes
This commit is contained in:
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
// !LANGUAGE: +InlineClasses
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// WITH_RUNTIME
|
||||
|
||||
inline class Z(val x: Int)
|
||||
inline class L(val x: Long)
|
||||
inline class S(val x: String)
|
||||
|
||||
fun Z.test() = x
|
||||
fun L.test() = x
|
||||
fun S.test() = x
|
||||
|
||||
fun box(): String {
|
||||
if (Z(42)::test.invoke() != 42) throw AssertionError()
|
||||
if (L(1234L)::test.invoke() != 1234L) throw AssertionError()
|
||||
if (S("abcdef")::test.invoke() != "abcdef") throw AssertionError()
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
// !LANGUAGE: +InlineClasses
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// WITH_RUNTIME
|
||||
|
||||
inline class Z(val x: Int)
|
||||
inline class L(val x: Long)
|
||||
inline class S(val x: String)
|
||||
|
||||
val Z.xx get() = x
|
||||
val L.xx get() = x
|
||||
val S.xx get() = x
|
||||
|
||||
fun box(): String {
|
||||
if (Z(42)::xx.get() != 42) throw AssertionError()
|
||||
if (L(1234L)::xx.get() != 1234L) throw AssertionError()
|
||||
if (S("abcdef")::xx.get() != "abcdef") throw AssertionError()
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Vendored
+23
@@ -0,0 +1,23 @@
|
||||
// !LANGUAGE: +InlineClasses
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// WITH_RUNTIME
|
||||
|
||||
inline class Z(val x: Int) {
|
||||
fun test() = x
|
||||
}
|
||||
|
||||
inline class L(val x: Long) {
|
||||
fun test() = x
|
||||
}
|
||||
|
||||
inline class S(val x: String) {
|
||||
fun test() = x
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
if (Z(42)::test.invoke() != 42) throw AssertionError()
|
||||
if (L(1234L)::test.invoke() != 1234L) throw AssertionError()
|
||||
if (S("abcdef")::test.invoke() != "abcdef") throw AssertionError()
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Vendored
+23
@@ -0,0 +1,23 @@
|
||||
// !LANGUAGE: +InlineClasses
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// WITH_RUNTIME
|
||||
|
||||
inline class Z(val x: Int) {
|
||||
val xx get() = x
|
||||
}
|
||||
|
||||
inline class L(val x: Long) {
|
||||
val xx get() = x
|
||||
}
|
||||
|
||||
inline class S(val x: String) {
|
||||
val xx get() = x
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
if (Z(42)::xx.get() != 42) throw AssertionError()
|
||||
if (L(1234L)::xx.get() != 1234L) throw AssertionError()
|
||||
if (S("abcdef")::xx.get() != "abcdef") throw AssertionError()
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
// !LANGUAGE: +InlineClasses
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// WITH_RUNTIME
|
||||
|
||||
inline class Z(val x: Int)
|
||||
inline class L(val x: Long)
|
||||
inline class S(val x: String)
|
||||
|
||||
fun box(): String {
|
||||
if (Z(42)::x.get() != 42) throw AssertionError()
|
||||
if (L(1234L)::x.get() != 1234L) throw AssertionError()
|
||||
if (S("abcdef")::x.get() != "abcdef") throw AssertionError()
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
// !LANGUAGE: +InlineClasses
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// WITH_RUNTIME
|
||||
|
||||
inline class Z(val x: Int)
|
||||
inline class L(val x: Long)
|
||||
inline class S(val x: String)
|
||||
|
||||
fun test(aZ: Z, aL: L, aS: S) = "${aZ.x} ${aL.x} ${aS.x}"
|
||||
|
||||
fun box(): String {
|
||||
if (::test.invoke(Z(1), L(1L), S("abc")) != "1 1 abc") throw AssertionError()
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
// !LANGUAGE: +InlineClasses
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// WITH_RUNTIME
|
||||
|
||||
inline class Z(val x: Int)
|
||||
inline class L(val x: Long)
|
||||
inline class S(val x: String)
|
||||
|
||||
fun Z.test() = x
|
||||
fun L.test() = x
|
||||
fun S.test() = x
|
||||
|
||||
fun box(): String {
|
||||
if (Z::test.invoke(Z(42)) != 42) throw AssertionError()
|
||||
if (L::test.invoke(L(1234L)) != 1234L) throw AssertionError()
|
||||
if (S::test.invoke(S("abcdef")) != "abcdef") throw AssertionError()
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
// !LANGUAGE: +InlineClasses
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// WITH_RUNTIME
|
||||
|
||||
inline class Z(val x: Int)
|
||||
inline class L(val x: Long)
|
||||
inline class S(val x: String)
|
||||
|
||||
val Z.xx get() = x
|
||||
val L.xx get() = x
|
||||
val S.xx get() = x
|
||||
|
||||
fun box(): String {
|
||||
if ((Z::xx).get(Z(42)) != 42) throw AssertionError()
|
||||
if ((L::xx).get(L(1234L)) != 1234L) throw AssertionError()
|
||||
if ((S::xx).get(S("abcdef")) != "abcdef") throw AssertionError()
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
// !LANGUAGE: +InlineClasses
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// WITH_RUNTIME
|
||||
|
||||
inline class Z(val x: Int) {
|
||||
fun test() = x
|
||||
}
|
||||
|
||||
inline class L(val x: Long) {
|
||||
fun test() = x
|
||||
}
|
||||
|
||||
inline class S(val x: String) {
|
||||
fun test() = x
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
if (Z::test.invoke(Z(42)) != 42) throw AssertionError()
|
||||
if (L::test.invoke(L(1234L)) != 1234L) throw AssertionError()
|
||||
if (S::test.invoke(S("abcdef")) != "abcdef") throw AssertionError()
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
// !LANGUAGE: +InlineClasses
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// WITH_RUNTIME
|
||||
|
||||
inline class Z(val x: Int) {
|
||||
val xx get() = x
|
||||
}
|
||||
|
||||
inline class L(val x: Long) {
|
||||
val xx get() = x
|
||||
}
|
||||
|
||||
inline class S(val x: String) {
|
||||
val xx get() = x
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
if ((Z::xx).get(Z(42)) != 42) throw AssertionError()
|
||||
if ((L::xx).get(L(1234L)) != 1234L) throw AssertionError()
|
||||
if ((S::xx).get(S("abcdef")) != "abcdef") throw AssertionError()
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
// !LANGUAGE: +InlineClasses
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// WITH_RUNTIME
|
||||
|
||||
inline class Z(val x: Int)
|
||||
inline class L(val x: Long)
|
||||
inline class S(val x: String)
|
||||
|
||||
fun box(): String {
|
||||
if (42.let(::Z).x != 42) throw AssertionError()
|
||||
if (1234L.let(::L).x != 1234L) throw AssertionError()
|
||||
if ("abcdef".let(::S).x != "abcdef") throw AssertionError()
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// !LANGUAGE: +InlineClasses
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// WITH_RUNTIME
|
||||
|
||||
inline class Z(val x: Int)
|
||||
inline class L(val x: Long)
|
||||
inline class S(val x: String)
|
||||
|
||||
fun box(): String {
|
||||
if ((Z::x).get(Z(42)) != 42) throw AssertionError()
|
||||
if ((L::x).get(L(1234L)) != 1234L) throw AssertionError()
|
||||
if ((S::x).get(S("abcdef")) != "abcdef") throw AssertionError()
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
// !LANGUAGE: +InlineClasses
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// WITH_RUNTIME
|
||||
inline class Z(val x: Int)
|
||||
|
||||
class C(var z: Z)
|
||||
|
||||
fun box(): String {
|
||||
val x = C(Z(42))
|
||||
|
||||
val ref = x::z
|
||||
|
||||
if (ref.get().x != 42) throw AssertionError()
|
||||
|
||||
ref.set(Z(1234))
|
||||
if (ref.get().x != 1234) throw AssertionError()
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
// !LANGUAGE: +InlineClasses
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// WITH_RUNTIME
|
||||
inline class Z(val x: Int)
|
||||
|
||||
class C(var z: Z)
|
||||
|
||||
fun box(): String {
|
||||
val ref = C::z
|
||||
|
||||
val x = C(Z(42))
|
||||
|
||||
if (ref.get(x).x != 42) throw AssertionError()
|
||||
|
||||
ref.set(x, Z(1234))
|
||||
if (ref.get(x).x != 1234) throw AssertionError()
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
// !LANGUAGE: +InlineClasses
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// WITH_RUNTIME
|
||||
inline class Z(val x: Int)
|
||||
|
||||
var topLevel = Z(42)
|
||||
|
||||
fun box(): String {
|
||||
val ref = ::topLevel
|
||||
|
||||
if (ref.get().x != 42) throw AssertionError()
|
||||
|
||||
ref.set(Z(1234))
|
||||
if (ref.get().x != 1234) throw AssertionError()
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user