From 9d1e319f0febb4cf036d74fe2cd110450e0113a8 Mon Sep 17 00:00:00 2001 From: Zalim Bashorov Date: Fri, 21 Jun 2013 16:21:28 +0400 Subject: [PATCH] JS backend: implemented PrimitiveHashMap#putAll. --- js/js.translator/testFiles/maps.js | 8 +++++++- libraries/stdlib/test/js/MapJsTest.kt | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/js/js.translator/testFiles/maps.js b/js/js.translator/testFiles/maps.js index 75d078d4363..ffc18118fc2 100644 --- a/js/js.translator/testFiles/maps.js +++ b/js/js.translator/testFiles/maps.js @@ -472,7 +472,13 @@ Kotlin.ComplexHashMap = Kotlin.HashMap; this.map = {}; }, putAll: function (fromMap) { - throw Kotlin.$new(Kotlin.UnsupportedOperationException)(); + var map = fromMap.map; + for (var key in map) { + if (map.hasOwnProperty(key)) { + this.map[key] = map[key]; + this.$size++; + } + } }, keySet: function () { var result = Kotlin.$new(Kotlin.PrimitiveHashSet)(); diff --git a/libraries/stdlib/test/js/MapJsTest.kt b/libraries/stdlib/test/js/MapJsTest.kt index 3132b0878f3..5c564f92208 100644 --- a/libraries/stdlib/test/js/MapJsTest.kt +++ b/libraries/stdlib/test/js/MapJsTest.kt @@ -5,6 +5,7 @@ import kotlin.test.* import java.util.* import org.junit.Test as test +// TODO: Write test generator for testing `Map` implementations. class MapJsTest { //TODO: replace `array(...).toList()` to `listOf(...)` val KEYS = array("zero", "one", "two", "three").toList()