Add hashCode() for primitives. (#104)

This commit is contained in:
Nikolay Igotti
2016-12-01 16:07:06 +03:00
committed by GitHub
parent 28918f92f7
commit 85aca55ee5
6 changed files with 90 additions and 6 deletions
+5
View File
@@ -443,6 +443,11 @@ task interface0(type: RunKonanTest) {
source = "runtime/basic/interface0.kt"
}
task hash0(type: RunKonanTest) {
goldValue = "239\n0\n97\n1065353216\n1072693248\n1\n0\ntrue\ntrue\n"
source = "runtime/basic/hash0.kt"
}
task array_list1(type: RunKonanTest) {
goldValue = "OK\n"
source = "runtime/collections/array_list1.kt"
@@ -0,0 +1,18 @@
fun main(args : Array<String>) {
println(239.hashCode())
println((-1L).hashCode())
println('a'.hashCode())
println(1.0f.hashCode())
println(1.0.hashCode())
println(true.hashCode())
println(false.hashCode())
println(Any().hashCode() != Any().hashCode())
val a = CharArray(5)
a[0] = 'H'
a[1] = 'e'
a[2] = 'l'
a[3] = 'l'
a[4] = 'o'
// Note that it uses private Konan API.
println("Hello".hashCode() == fromCharArray(a, 0, 5).hashCode())
}