StdLib deprecations cleanup: *array -> *arrayOf, copyToArray -> toTypedArray.
This commit is contained in:
@@ -18,14 +18,14 @@ class JdbcTemplateTest {
|
|||||||
|
|
||||||
// TODO will use a tuple soon
|
// TODO will use a tuple soon
|
||||||
dataSource.update(
|
dataSource.update(
|
||||||
StringTemplate(array("insert into foo (id, name) values (", id, ", ", name, ")"))
|
StringTemplate(arrayOf("insert into foo (id, name) values (", id, ", ", name, ")"))
|
||||||
)
|
)
|
||||||
|
|
||||||
// Mimicks
|
// Mimicks
|
||||||
// datasource.query("select * from foo where id = $id") { it.map{ it["name"] } }
|
// datasource.query("select * from foo where id = $id") { it.map{ it["name"] } }
|
||||||
|
|
||||||
val names = dataSource.query(
|
val names = dataSource.query(
|
||||||
StringTemplate(array("select * from foo where id = ", id))
|
StringTemplate(arrayOf("select * from foo where id = ", id))
|
||||||
) {
|
) {
|
||||||
it.map{ it["name"] }.toList()
|
it.map{ it["name"] }.toList()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ class JdbcTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
test fun stringFormat() {
|
test fun stringFormat() {
|
||||||
dataSource.query(kotlin.template.StringTemplate(array("select * from foo where id = ", 1))) {
|
dataSource.query(kotlin.template.StringTemplate(arrayOf("select * from foo where id = ", 1))) {
|
||||||
for (row in it) {
|
for (row in it) {
|
||||||
println(row.getValuesAsMap())
|
println(row.getValuesAsMap())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -732,7 +732,7 @@ public fun String.lastIndexOfAny(strings: Collection<String>, startIndex: Int =
|
|||||||
*/
|
*/
|
||||||
public fun String.indexOf(char: Char, startIndex: Int = 0, ignoreCase: Boolean = false): Int {
|
public fun String.indexOf(char: Char, startIndex: Int = 0, ignoreCase: Boolean = false): Int {
|
||||||
return if (ignoreCase)
|
return if (ignoreCase)
|
||||||
indexOfAny(charArray(char), startIndex, ignoreCase)
|
indexOfAny(charArrayOf(char), startIndex, ignoreCase)
|
||||||
else
|
else
|
||||||
nativeIndexOf(char, startIndex)
|
nativeIndexOf(char, startIndex)
|
||||||
}
|
}
|
||||||
@@ -760,7 +760,7 @@ public fun String.indexOf(string: String, startIndex: Int = 0, ignoreCase: Boole
|
|||||||
*/
|
*/
|
||||||
public fun String.lastIndexOf(char: Char, startIndex: Int = lastIndex, ignoreCase: Boolean = false): Int {
|
public fun String.lastIndexOf(char: Char, startIndex: Int = lastIndex, ignoreCase: Boolean = false): Int {
|
||||||
return if (ignoreCase)
|
return if (ignoreCase)
|
||||||
lastIndexOfAny(charArray(char), startIndex, ignoreCase)
|
lastIndexOfAny(charArrayOf(char), startIndex, ignoreCase)
|
||||||
else
|
else
|
||||||
nativeLastIndexOf(char, startIndex)
|
nativeLastIndexOf(char, startIndex)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -161,11 +161,11 @@ class ArraysTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
test fun average() {
|
test fun average() {
|
||||||
expect(0.0) { array<Int>().average() }
|
expect(0.0) { arrayOf<Int>().average() }
|
||||||
expect(3.8) { array(1, 2, 5, 8, 3).average() }
|
expect(3.8) { arrayOf(1, 2, 5, 8, 3).average() }
|
||||||
expect(2.1) { array(1.6, 2.6, 3.6, 0.6).average() }
|
expect(2.1) { arrayOf(1.6, 2.6, 3.6, 0.6).average() }
|
||||||
expect(100.0) { array<Byte>(100, 100, 100, 100, 100, 100).average() }
|
expect(100.0) { arrayOf<Byte>(100, 100, 100, 100, 100, 100).average() }
|
||||||
expect(0) { array<Short>(1, -1, 2, -2, 3, -3).average().toShort() }
|
expect(0) { arrayOf<Short>(1, -1, 2, -2, 3, -3).average().toShort() }
|
||||||
// TODO: Property based tests
|
// TODO: Property based tests
|
||||||
// for each arr with size 1 arr.average() == arr[0]
|
// for each arr with size 1 arr.average() == arr[0]
|
||||||
// for each arr with size > 0 arr.average() = arr.sum().toDouble() / arr.size()
|
// for each arr with size > 0 arr.average() = arr.sum().toDouble() / arr.size()
|
||||||
@@ -296,7 +296,7 @@ class ArraysTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
test fun toPrimitiveArray() {
|
test fun toPrimitiveArray() {
|
||||||
val genericArray: Array<Int> = array(1, 2, 3)
|
val genericArray: Array<Int> = arrayOf(1, 2, 3)
|
||||||
val primitiveArray: IntArray = genericArray.toIntArray()
|
val primitiveArray: IntArray = genericArray.toIntArray()
|
||||||
expect(3) { primitiveArray.size() }
|
expect(3) { primitiveArray.size() }
|
||||||
assertEquals(genericArray.asList(), primitiveArray.asList())
|
assertEquals(genericArray.asList(), primitiveArray.asList())
|
||||||
|
|||||||
@@ -348,10 +348,10 @@ class FilesTest {
|
|||||||
fail(::visitDirectoryFailed).forEach { it -> if (!it.isDirectory()) visitFile(it) }
|
fail(::visitDirectoryFailed).forEach { it -> if (!it.isDirectory()) visitFile(it) }
|
||||||
assert(stack.isEmpty())
|
assert(stack.isEmpty())
|
||||||
val sep = File.separator
|
val sep = File.separator
|
||||||
for (fileName in array("", "1", "1${sep}2", "1${sep}3", "6", "8")) {
|
for (fileName in arrayOf("", "1", "1${sep}2", "1${sep}3", "6", "8")) {
|
||||||
assert(dirs.contains(fileName), fileName)
|
assert(dirs.contains(fileName), fileName)
|
||||||
}
|
}
|
||||||
for (fileName in array("1${sep}3${sep}4.txt", "1${sep}3${sep}4.txt", "7.txt", "8${sep}9.txt")) {
|
for (fileName in arrayOf("1${sep}3${sep}4.txt", "1${sep}3${sep}4.txt", "7.txt", "8${sep}9.txt")) {
|
||||||
assert(files.contains(fileName), fileName)
|
assert(files.contains(fileName), fileName)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -362,7 +362,7 @@ class FilesTest {
|
|||||||
forEach { it -> if (it != basedir) visitFile(it) }
|
forEach { it -> if (it != basedir) visitFile(it) }
|
||||||
assert(stack.isEmpty())
|
assert(stack.isEmpty())
|
||||||
assert(dirs.size() == 1 && dirs.contains(""), dirs.size())
|
assert(dirs.size() == 1 && dirs.contains(""), dirs.size())
|
||||||
for (file in array("1", "6", "7.txt", "8")) {
|
for (file in arrayOf("1", "6", "7.txt", "8")) {
|
||||||
assert(files.contains(file), file)
|
assert(files.contains(file), file)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -376,11 +376,11 @@ class FilesTest {
|
|||||||
assert(stack.isEmpty())
|
assert(stack.isEmpty())
|
||||||
assert(failed.size() == 1 && failed.contains("1"), failed.size())
|
assert(failed.size() == 1 && failed.contains("1"), failed.size())
|
||||||
assert(dirs.size() == 4, dirs.size())
|
assert(dirs.size() == 4, dirs.size())
|
||||||
for (dir in array("", "1", "6", "8")) {
|
for (dir in arrayOf("", "1", "6", "8")) {
|
||||||
assert(dirs.contains(dir), dir)
|
assert(dirs.contains(dir), dir)
|
||||||
}
|
}
|
||||||
assert(files.size() == 2, files.size())
|
assert(files.size() == 2, files.size())
|
||||||
for (file in array("7.txt", "8${sep}9.txt")) {
|
for (file in arrayOf("7.txt", "8${sep}9.txt")) {
|
||||||
assert(files.contains(file), file)
|
assert(files.contains(file), file)
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@@ -73,9 +73,9 @@ class LinkedHashMapTest : MapJsTest() {
|
|||||||
|
|
||||||
abstract class MapJsTest {
|
abstract class MapJsTest {
|
||||||
val KEYS = listOf("zero", "one", "two", "three")
|
val KEYS = listOf("zero", "one", "two", "three")
|
||||||
val VALUES = array(0, 1, 2, 3).toList()
|
val VALUES = arrayOf(0, 1, 2, 3).toList()
|
||||||
|
|
||||||
val SPECIAL_NAMES = array("__proto__", "constructor", "toString", "toLocaleString", "valueOf", "hasOwnProperty", "isPrototypeOf", "propertyIsEnumerable")
|
val SPECIAL_NAMES = arrayOf("__proto__", "constructor", "toString", "toLocaleString", "valueOf", "hasOwnProperty", "isPrototypeOf", "propertyIsEnumerable")
|
||||||
|
|
||||||
test fun getOrElse() {
|
test fun getOrElse() {
|
||||||
val data = emptyMap()
|
val data = emptyMap()
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ class HtmlTemplateTest : TestCase() {
|
|||||||
|
|
||||||
// TODO will use a tuple soon
|
// TODO will use a tuple soon
|
||||||
//val actual = StringTemplate(Tuple3<String,String,String>("<h1>", foo, "</h1> <p>hey ", bar, "</p>")).toHtml()
|
//val actual = StringTemplate(Tuple3<String,String,String>("<h1>", foo, "</h1> <p>hey ", bar, "</p>")).toHtml()
|
||||||
val actual = StringTemplate(array("<h1>", foo, "</h1> <p>hey ", bar, "</p>")).toHtml()
|
val actual = StringTemplate(arrayOf("<h1>", foo, "</h1> <p>hey ", bar, "</p>")).toHtml()
|
||||||
|
|
||||||
assertEquals("<h1>James</h1> <p>hey x > 1</p>", actual)
|
assertEquals("<h1>James</h1> <p>hey x > 1</p>", actual)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,9 +32,9 @@ class LocaleTemplateTest : TestCase() {
|
|||||||
|
|
||||||
// TODO will use a tuple soon
|
// TODO will use a tuple soon
|
||||||
//val actual = formatter.format(StringTemplate(Tuple2<String,String>("hello ", name))
|
//val actual = formatter.format(StringTemplate(Tuple2<String,String>("hello ", name))
|
||||||
val actual = StringTemplate(array("hello ", name,
|
val actual = StringTemplate(arrayOf("hello ", name,
|
||||||
" price ", price,
|
" price ", price,
|
||||||
" data ", now)).toString(formatter)
|
" data ", now)).toString(formatter)
|
||||||
|
|
||||||
println("Got text: $actual")
|
println("Got text: $actual")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ class StringTemplateTest : TestCase() {
|
|||||||
|
|
||||||
// TODO will use a tuple soon
|
// TODO will use a tuple soon
|
||||||
//val actual = StringTemplate(Tuple3<String,String,String>("hello ", name, "!"))).toString()
|
//val actual = StringTemplate(Tuple3<String,String,String>("hello ", name, "!"))).toString()
|
||||||
val actual = StringTemplate(array("hello ", name, "!")).toString()
|
val actual = StringTemplate(arrayOf("hello ", name, "!")).toString()
|
||||||
|
|
||||||
assertEquals("hello James!", actual)
|
assertEquals("hello James!", actual)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -262,8 +262,7 @@ class StringTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
test fun trimStartAndEnd() {
|
test fun trimStartAndEnd() {
|
||||||
val examples = array(
|
val examples = arrayOf("a",
|
||||||
"a",
|
|
||||||
" a ",
|
" a ",
|
||||||
" a ",
|
" a ",
|
||||||
" a b ",
|
" a b ",
|
||||||
@@ -279,12 +278,11 @@ class StringTest {
|
|||||||
assertEquals(example.trim(), example.trimStart().trimEnd())
|
assertEquals(example.trim(), example.trimStart().trimEnd())
|
||||||
}
|
}
|
||||||
|
|
||||||
val examplesForPredicate = array(
|
val examplesForPredicate = arrayOf("123",
|
||||||
"123",
|
|
||||||
"-=123=-"
|
"-=123=-"
|
||||||
)
|
)
|
||||||
|
|
||||||
val trimChars = charArray('-','=')
|
val trimChars = charArrayOf('-', '=')
|
||||||
val trimPredicate = { it: Char -> it < '0' || it > '9' } // TODO: Use !it.isDigit when available in JS
|
val trimPredicate = { it: Char -> it < '0' || it > '9' } // TODO: Use !it.isDigit when available in JS
|
||||||
for (example in examplesForPredicate) {
|
for (example in examplesForPredicate) {
|
||||||
assertEquals(example.trimStart(*trimChars).trimEnd(*trimChars), example.trim(*trimChars))
|
assertEquals(example.trimStart(*trimChars).trimEnd(*trimChars), example.trim(*trimChars))
|
||||||
@@ -354,8 +352,8 @@ class StringTest {
|
|||||||
|
|
||||||
test fun split() {
|
test fun split() {
|
||||||
assertEquals(listOf(""), "".split(";"))
|
assertEquals(listOf(""), "".split(";"))
|
||||||
assertEquals(listOf("test"), "test".split(*charArray()), "empty list of delimiters, none matched -> entire string returned")
|
assertEquals(listOf("test"), "test".split(*charArrayOf()), "empty list of delimiters, none matched -> entire string returned")
|
||||||
assertEquals(listOf("test"), "test".split(*array<String>()), "empty list of delimiters, none matched -> entire string returned")
|
assertEquals(listOf("test"), "test".split(*arrayOf<String>()), "empty list of delimiters, none matched -> entire string returned")
|
||||||
|
|
||||||
assertEquals(listOf("abc", "def", "123;456"), "abc;def,123;456".split(';', ',', limit = 3))
|
assertEquals(listOf("abc", "def", "123;456"), "abc;def,123;456".split(';', ',', limit = 3))
|
||||||
assertEquals(listOf("abc", "def", "123", "456"), "abc<BR>def<br>123<bR>456".split("<BR>", ignoreCase = true))
|
assertEquals(listOf("abc", "def", "123", "456"), "abc<BR>def<br>123<bR>456".split("<BR>", ignoreCase = true))
|
||||||
@@ -379,7 +377,7 @@ class StringTest {
|
|||||||
|
|
||||||
test fun indexOfAnyChar() {
|
test fun indexOfAnyChar() {
|
||||||
val string = "abracadabra"
|
val string = "abracadabra"
|
||||||
val chars = charArray('d','b')
|
val chars = charArrayOf('d', 'b')
|
||||||
assertEquals(1, string.indexOfAny(chars))
|
assertEquals(1, string.indexOfAny(chars))
|
||||||
assertEquals(6, string.indexOfAny(chars, startIndex = 2))
|
assertEquals(6, string.indexOfAny(chars, startIndex = 2))
|
||||||
assertEquals(-1, string.indexOfAny(chars, startIndex = 9))
|
assertEquals(-1, string.indexOfAny(chars, startIndex = 9))
|
||||||
@@ -388,12 +386,12 @@ class StringTest {
|
|||||||
assertEquals(6, string.lastIndexOfAny(chars, startIndex = 7))
|
assertEquals(6, string.lastIndexOfAny(chars, startIndex = 7))
|
||||||
assertEquals(-1, string.lastIndexOfAny(chars, startIndex = 0))
|
assertEquals(-1, string.lastIndexOfAny(chars, startIndex = 0))
|
||||||
|
|
||||||
assertEquals(-1, string.indexOfAny(charArray()))
|
assertEquals(-1, string.indexOfAny(charArrayOf()))
|
||||||
}
|
}
|
||||||
|
|
||||||
test fun indexOfAnyCharIgnoreCase() {
|
test fun indexOfAnyCharIgnoreCase() {
|
||||||
val string = "abraCadabra"
|
val string = "abraCadabra"
|
||||||
val chars = charArray('B','c')
|
val chars = charArrayOf('B', 'c')
|
||||||
assertEquals(1, string.indexOfAny(chars, ignoreCase = true))
|
assertEquals(1, string.indexOfAny(chars, ignoreCase = true))
|
||||||
assertEquals(4, string.indexOfAny(chars, startIndex = 2, ignoreCase = true))
|
assertEquals(4, string.indexOfAny(chars, startIndex = 2, ignoreCase = true))
|
||||||
assertEquals(-1, string.indexOfAny(chars, startIndex = 9, ignoreCase = true))
|
assertEquals(-1, string.indexOfAny(chars, startIndex = 9, ignoreCase = true))
|
||||||
@@ -473,8 +471,8 @@ class StringTest {
|
|||||||
assertEquals(2, string.lastIndexOf('e', 3))
|
assertEquals(2, string.lastIndexOf('e', 3))
|
||||||
|
|
||||||
for (startIndex in -1..string.length()+1) {
|
for (startIndex in -1..string.length()+1) {
|
||||||
assertEquals(string.indexOfAny(charArray('e'), startIndex), string.indexOf('e', startIndex))
|
assertEquals(string.indexOfAny(charArrayOf('e'), startIndex), string.indexOf('e', startIndex))
|
||||||
assertEquals(string.lastIndexOfAny(charArray('e'), startIndex), string.lastIndexOf('e', startIndex))
|
assertEquals(string.lastIndexOfAny(charArrayOf('e'), startIndex), string.lastIndexOf('e', startIndex))
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -490,8 +488,8 @@ class StringTest {
|
|||||||
|
|
||||||
|
|
||||||
for (startIndex in -1..string.length()+1){
|
for (startIndex in -1..string.length()+1){
|
||||||
assertEquals(string.indexOfAny(charArray('e'), startIndex, ignoreCase = true), string.indexOf('E', startIndex, ignoreCase = true))
|
assertEquals(string.indexOfAny(charArrayOf('e'), startIndex, ignoreCase = true), string.indexOf('E', startIndex, ignoreCase = true))
|
||||||
assertEquals(string.lastIndexOfAny(charArray('E'), startIndex, ignoreCase = true), string.lastIndexOf('e', startIndex, ignoreCase = true))
|
assertEquals(string.lastIndexOfAny(charArrayOf('E'), startIndex, ignoreCase = true), string.lastIndexOf('e', startIndex, ignoreCase = true))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -20,7 +20,7 @@ class JavadocStyleHtmlDoclet() : Doclet {
|
|||||||
fun generateExtensionFunctions(p: KPackage): Unit {
|
fun generateExtensionFunctions(p: KPackage): Unit {
|
||||||
val map = inheritedExtensionFunctions(p.functions)
|
val map = inheritedExtensionFunctions(p.functions)
|
||||||
val pmap = inheritedExtensionProperties(p.properties)
|
val pmap = inheritedExtensionProperties(p.properties)
|
||||||
val classes = hashSet<KClass>()
|
val classes = hashSetOf<KClass>()
|
||||||
classes.addAll(map.keySet())
|
classes.addAll(map.keySet())
|
||||||
classes.addAll(pmap.keySet())
|
classes.addAll(pmap.keySet())
|
||||||
for (c in classes) {
|
for (c in classes) {
|
||||||
|
|||||||
+1
-1
@@ -217,7 +217,7 @@ public open class Kotlin2JsCompile() : AbstractKotlinCompile<K2JSCompilerArgumen
|
|||||||
|
|
||||||
override fun createBlankArgs(): K2JSCompilerArguments {
|
override fun createBlankArgs(): K2JSCompilerArguments {
|
||||||
val args = K2JSCompilerArguments()
|
val args = K2JSCompilerArguments()
|
||||||
args.libraryFiles = array<String>() // defaults to null
|
args.libraryFiles = arrayOf<String>() // defaults to null
|
||||||
return args
|
return args
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user