Use NoSuchElementException instead of KeyMissingException. Deprecate KeyMissingException.

This commit is contained in:
Ilya Gorbunov
2015-06-22 21:17:51 +03:00
parent 9c7992abbb
commit d04e94c826
6 changed files with 25 additions and 16 deletions
+2 -1
View File
@@ -1,5 +1,6 @@
package test.collections
import java.util.*
import kotlin.test.assertEquals
import kotlin.test.assertFalse
import kotlin.test.assertTrue
@@ -24,7 +25,7 @@ class MapTest {
test fun getOrImplicitDefault() {
val data: MutableMap<String, Int> = hashMapOf("bar" to 1)
assertTrue(fails { data.getOrImplicitDefault("foo") } is KeyMissingException)
assertTrue(fails { data.getOrImplicitDefault("foo") } is NoSuchElementException)
assertEquals(1, data.getOrImplicitDefault("bar"))
val mutableWithDefault = data.withDefault { 42 }
@@ -1,5 +1,6 @@
package test.properties.delegation
import java.util.*
import kotlin.properties.*
import kotlin.test.*
import org.junit.Test as test
@@ -24,7 +25,7 @@ class ValByMapExtensionsTest {
assertEquals("default", e)
assertEquals(1, i)
assertEquals(1.0, x)
fails { d }
assertTrue(fails { d } is NoSuchElementException)
}
}
@@ -59,7 +60,7 @@ class VarByMapExtensionsTest {
map["a"] = null
a // fails { a } // does not fail due to KT-8135
fails { d }
assertTrue(fails { d } is NoSuchElementException)
map["d"] = null
assertEquals(null, d)
}