Cleanup tests, specify type where it's ambiguous.

This commit is contained in:
Ilya Gorbunov
2015-10-22 16:44:12 +03:00
parent 0b74698c16
commit 579ce8091c
3 changed files with 12 additions and 11 deletions
@@ -433,7 +433,7 @@ class CollectionTest {
// lists throw an exception if out of range // lists throw an exception if out of range
assertFails { assertFails {
assertEquals(null, list[2]) val outOfBounds = list[2]
} }
// lets try update the list // lets try update the list
@@ -356,16 +356,16 @@ abstract class IterableTests<T : Iterable<String>>(val data: T, val empty: T) {
// lets use a mutable variable // lets use a mutable variable
var result: Iterable<String> = data var result: Iterable<String> = data
result -= "foo" result -= "foo"
assertEquals(listOf("bar"), result) assertEquals(listOf("bar"), result as? List)
result = data result = data
result -= listOf("beer", "bar") result -= listOf("beer", "bar")
assertEquals(listOf("foo"), result) assertEquals(listOf("foo"), result as? List)
result = data result = data
result -= arrayOf("bar", "foo") result -= arrayOf("bar", "foo")
assertEquals(emptyList<String>(), result) assertEquals(emptyList<String>(), result as? List)
result = data result = data
result -= sequenceOf("foo", "g") result -= sequenceOf("foo", "g")
assertEquals(listOf("bar"), result) assertEquals(listOf("bar"), result as? List)
} }
} }
+7 -6
View File
@@ -14,9 +14,10 @@ class ComplexMapJsTest : MapJsTest() {
HashMap<K, Int>(3, 0.5f) HashMap<K, Int>(3, 0.5f)
val map = HashMap<K, Int>(createTestMap() as HashMap<K, Int>) val map = HashMap<K, Int>(createTestMap() as HashMap<K, Int>)
assertEquals(KEYS.toNormalizedList(), map.keySet().toNormalizedList()) assertEquals(KEYS.toNormalizedList(), map.keys.toNormalizedList() as List<Any>)
assertEquals(VALUES.toNormalizedList(), map.values().toNormalizedList()) assertEquals(VALUES.toNormalizedList(), map.values.toNormalizedList())
} }
@test override fun constructors() { @test override fun constructors() {
doTest<String>() doTest<String>()
} }
@@ -35,8 +36,8 @@ class PrimitiveMapJsTest : MapJsTest() {
val map = HashMap<String, Int>(createTestMap()) val map = HashMap<String, Int>(createTestMap())
assertEquals(KEYS.toNormalizedList(), map.keySet().toNormalizedList()) assertEquals(KEYS.toNormalizedList(), map.keys.toNormalizedList())
assertEquals(VALUES.toNormalizedList(), map.values().toNormalizedList()) assertEquals(VALUES.toNormalizedList(), map.values.toNormalizedList())
} }
override fun <T : kotlin.Comparable<T>> Collection<T>.toNormalizedList(): List<T> = this.sorted() override fun <T : kotlin.Comparable<T>> Collection<T>.toNormalizedList(): List<T> = this.sorted()
@@ -62,8 +63,8 @@ class LinkedHashMapTest : MapJsTest() {
val map = LinkedHashMap<String, Int>(createTestMap()) val map = LinkedHashMap<String, Int>(createTestMap())
assertEquals(KEYS.toNormalizedList(), map.keySet().toNormalizedList()) assertEquals(KEYS.toNormalizedList(), map.keys.toNormalizedList())
assertEquals(VALUES.toNormalizedList(), map.values().toNormalizedList()) assertEquals(VALUES.toNormalizedList(), map.values.toNormalizedList())
} }
override fun <T : kotlin.Comparable<T>> Collection<T>.toNormalizedList(): List<T> = this.toList() override fun <T : kotlin.Comparable<T>> Collection<T>.toNormalizedList(): List<T> = this.toList()