Files
kotlin/compiler/testData/codegen/box/reflection/call/equalsHashCodeToString.kt
2016-11-09 21:41:12 +03:00

31 lines
841 B
Kotlin
Vendored

// TODO: muted automatically, investigate should it be ran for JS or not
// IGNORE_BACKEND: JS
// WITH_REFLECT
class A
data class D(val s: String)
fun box(): String {
val a = A()
assert(A::equals.call(a, a))
assert(!A::equals.call(a, 0))
assert(A::hashCode.call(a) == A::hashCode.call(a))
assert(A::toString.call(a).startsWith("A@"))
assert(D::equals.call(D("foo"), D("foo")))
assert(!D::equals.call(D("foo"), D("bar")))
assert(D::hashCode.call(D("foo")) == D::hashCode.call(D("foo")))
assert(D::toString.call(D("foo")) == "D(s=foo)")
assert(Int::equals.call(-1, -1))
assert(Int::hashCode.call(0) != Int::hashCode.call(1))
assert(Int::toString.call(42) == "42")
assert(String::equals.call("beer", "beer"))
String::hashCode.call("beer")
return String::toString.call("OK")
}