Files
kotlin-fork/js/js.translator/testData/box/multideclaration/multiValForMap.kt
T
2019-12-06 05:37:09 +03:00

43 lines
829 B
Kotlin
Vendored

// KJS_WITH_FULL_RUNTIME
// EXPECTED_REACHABLE_NODES: 1368
package foo
operator fun <K, V> Map<K, V>.iterator(): Iterator<Map.Entry<K, V>> {
val entrySet = this.entries
return entrySet.iterator()
}
/** Returns the key of the entry */
operator fun <K, V> Map.Entry<K, V>.component1(): K {
return key
}
/** Returns the value of the entry */
operator fun <K, V> Map.Entry<K, V>.component2(): V {
return value
}
fun box(): String {
val map = HashMap<Int, String>()
map.put(1, "s1")
map.put(2, "s2")
var s1 = ""
var s2 = ""
for ((k, v) in map) {
when (k) {
2 -> s2 = v
1 -> s1 = v
else -> {
}
}
}
if (s1 != "s1") return "s1 != 's1', it: ${s1}"
if (s2 != "s2") return "s2 != 's2', it: ${s2}"
return "OK"
}