Cleanup in libraries
This commit is contained in:
@@ -6,7 +6,6 @@ package kotlin.io
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
import java.util.Stack
|
||||
import kotlin.support.AbstractIterator
|
||||
|
||||
/**
|
||||
* An enumeration to describe possible walk directions.
|
||||
|
||||
@@ -438,7 +438,7 @@ public fun String.toPattern(flags: Int = 0): java.util.regex.Pattern {
|
||||
* @sample test.text.StringTest.capitalize
|
||||
*/
|
||||
public fun String.capitalize(): String {
|
||||
return if (isNotEmpty() && charAt(0).isLowerCase()) substring(0, 1).toUpperCase() + substring(1) else this
|
||||
return if (isNotEmpty() && this[0].isLowerCase()) substring(0, 1).toUpperCase() + substring(1) else this
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -448,7 +448,7 @@ public fun String.capitalize(): String {
|
||||
* @sample test.text.StringTest.decapitalize
|
||||
*/
|
||||
public fun String.decapitalize(): String {
|
||||
return if (isNotEmpty() && charAt(0).isUpperCase()) substring(0, 1).toLowerCase() + substring(1) else this
|
||||
return if (isNotEmpty() && this[0].isUpperCase()) substring(0, 1).toLowerCase() + substring(1) else this
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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)))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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])
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
@@ -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))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user