Cleanup in libraries

This commit is contained in:
Ilya Gorbunov
2015-12-29 19:21:39 +03:00
parent 92c2d17910
commit 19a4f65fd1
15 changed files with 32 additions and 44 deletions
+6 -18
View File
@@ -1,7 +1,6 @@
package test.annotations
import kotlin.*
import kotlin.test.assertTrue
import kotlin.test.*
import org.junit.Test as test
@Retention(AnnotationRetention.RUNTIME)
@@ -14,21 +13,10 @@ class AnnotatedClass
class AnnotationTest {
@test fun annotationType() {
val annotations = javaClass<AnnotatedClass>().getAnnotations()!!
var foundMyAnno = false
var foundDeprecated = false
for (annotation in annotations) {
val clazz = annotation!!.annotationType()
when {
clazz == javaClass<MyAnno>() -> foundMyAnno = true
clazz == javaClass<java.lang.Deprecated>() -> foundDeprecated = true
else -> {}
}
}
assertTrue(foundMyAnno)
assertTrue(foundDeprecated)
val kAnnotations = AnnotatedClass::class.java.annotations.map { it!!.annotationClass }
val jAnnotations = AnnotatedClass::class.java.annotations.map { it!!.annotationClass.java }
assertTrue(kAnnotations.containsAll(listOf(MyAnno::class, java.lang.Deprecated::class)))
assertTrue(jAnnotations.containsAll(listOf(MyAnno::class.java, java.lang.Deprecated::class.java)))
}
}
+3 -2
View File
@@ -2,13 +2,14 @@ package testjc
import kotlin.test.*
import junit.framework.TestCase
import java.util.*
class C()
class JavaClassTest() : TestCase() {
fun testMe () {
assertEquals("java.util.ArrayList", java.util.ArrayList<Any>().javaClass.getName())
assertEquals("java.util.ArrayList", javaClass<java.util.ArrayList<Any>>().getName())
assertEquals("testjc.C", javaClass<C>().getName())
assertEquals("java.util.ArrayList", ArrayList::class.java.getName())
assertEquals("testjc.C", C::class.java.getName())
}
}
@@ -43,7 +43,7 @@ class MapJVMTest {
}
@test fun iterateAndRemove() {
val map = (1..5).toMap({ it }, { 'a' + it }).toLinkedMap()
val map = (1..5).toMapBy({ it }, { 'a' + it }).toLinkedMap()
val iterator = map.iterator()
while (iterator.hasNext()) {
if (iterator.next().key % 2 == 0)
+1 -1
View File
@@ -187,7 +187,7 @@ class MapTest {
}
@test fun createWithSelectorForKeyAndValue() {
val map = listOf("a", "bb", "ccc").toMap({ it.length }, { it.toUpperCase() })
val map = listOf("a", "bb", "ccc").toMapBy({ it.length }, { it.toUpperCase() })
assertEquals(3, map.size)
assertEquals("A", map[1])
assertEquals("BB", map[2])
+2 -2
View File
@@ -11,7 +11,7 @@ class IOStreamsTest {
var writer: Writer? = null
try {
writer = tmpFile.outputStream().writer()
writer!!.write("Hello, World!")
writer.write("Hello, World!")
} finally {
writer?.close()
}
@@ -19,7 +19,7 @@ class IOStreamsTest {
var reader: BufferedReader? = null
try {
reader = tmpFile.inputStream().reader().buffered()
act = reader!!.readLine()
act = reader.readLine()
} finally {
reader?.close()
}
+2 -2
View File
@@ -189,7 +189,7 @@ abstract class MapJsTest {
map.containsKey(KEYS[3]))
assertFalse(map.containsKey("foo") ||
map.containsKey(1))
map.containsKey(1 as Any))
}
@test fun mapContainsValue() {
@@ -200,7 +200,7 @@ abstract class MapJsTest {
map.containsValue(VALUES[2]) &&
map.containsValue(VALUES[3]))
assertFalse(map.containsValue("four") ||
assertFalse(map.containsValue("four" as Any) ||
map.containsValue(5))
}