JS: add tests to check if super.equals/hashCode works properly
See KT-8226
This commit is contained in:
@@ -8105,6 +8105,12 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("intrinsic.kt")
|
||||||
|
public void testIntrinsic() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/superCall/intrinsic.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("nativeSuperClass.kt")
|
@TestMetadata("nativeSuperClass.kt")
|
||||||
public void testNativeSuperClass() throws Exception {
|
public void testNativeSuperClass() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/superCall/nativeSuperClass.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/superCall/nativeSuperClass.kt");
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
// EXPECTED_REACHABLE_NODES: 1141
|
||||||
|
class A(val x: Int) {
|
||||||
|
override fun equals(other: Any?): Boolean = other is A && other.x == x
|
||||||
|
|
||||||
|
override fun hashCode(): Int = x
|
||||||
|
|
||||||
|
fun identityEquals(other: Any?) = super.equals(other)
|
||||||
|
|
||||||
|
fun identityHashCode() = super.hashCode()
|
||||||
|
}
|
||||||
|
|
||||||
|
data class B(val y: Int) {
|
||||||
|
fun identityEquals(other: Any?) = super.equals(other)
|
||||||
|
|
||||||
|
fun identityHashCode() = super.hashCode()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
val a1 = A(23)
|
||||||
|
val a2 = A(23)
|
||||||
|
|
||||||
|
if (a1 != a2) return "fail1"
|
||||||
|
if (a1.identityEquals(a2)) return "fail2"
|
||||||
|
if (!a1.identityEquals(a1)) return "fail3"
|
||||||
|
val ah: Any = a1.identityHashCode()
|
||||||
|
if (ah !is Int) return "fail4"
|
||||||
|
if (a1.hashCode() != 23) return "fail5"
|
||||||
|
|
||||||
|
val b1 = B(23)
|
||||||
|
val b2 = B(23)
|
||||||
|
|
||||||
|
if (b1 != b2) return "fail6"
|
||||||
|
if (b1.identityEquals(b2)) return "fail7"
|
||||||
|
if (!b1.identityEquals(b1)) return "fail8"
|
||||||
|
val bh: Any = a1.identityHashCode()
|
||||||
|
if (bh !is Int) return "fail9"
|
||||||
|
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user