JS: Implement Long.hashCode function.

#KT-13756 Fixed
This commit is contained in:
Ilya Gorbunov
2016-08-25 04:13:21 +03:00
parent 813bee62e5
commit 25d8af3112
3 changed files with 25 additions and 0 deletions
@@ -81,6 +81,10 @@ public final class NumberTest extends SingleFileTranslationTest {
checkFooBoxIsOk();
}
public void testLongHashCode() throws Exception {
checkFooBoxIsOk();
}
public void testLongArray() throws Exception {
checkFooBoxIsOk();
}
+4
View File
@@ -279,6 +279,10 @@
this.getLowBitsUnsigned();
};
/** @return {number} The 32-bit hashCode of this value. */
Kotlin.Long.prototype.hashCode = function() {
return this.high_ ^ this.low_;
};
/**
* @param {number=} opt_radix The radix in which the text should be written.
+17
View File
@@ -0,0 +1,17 @@
package foo
fun box(): String {
var l1: Long = 0x12344478935690
var l2: Long = 0x12344478935698
var diff: Long = l2 - l1
l1 += (diff / 2)
l2 -= (diff / 2)
assertEquals(l1, l2, "When L1 == L2")
assertEquals(l1.hashCode(), l2.hashCode(), "L1.hashCode() == L2.hashCode()")
var l3: Any = l2
assertEquals(l1.hashCode(), l3.hashCode(), "Any(Long).hashCode()")
return "OK"
}