Refactored tests using Array constructor:

Some moved to tests with stdlib
Some changed to use arrayOfNulls
This commit is contained in:
Denis Zharkov
2014-12-11 10:45:15 +03:00
committed by Alexander Udalov
parent abbcf61183
commit 654411a0b0
68 changed files with 266 additions and 253 deletions
@@ -1,7 +1,13 @@
import java.util.Arrays
class MyCollection<T>(val delegate: Collection<T>): Collection<T> by delegate {
public fun toArray(): Array<Any?> = Array<Any?>(3, { it })
public fun toArray(): Array<Any?> {
val a = arrayOfNulls<Any?>(3)
a[0] = 0
a[1] = 1
a[2] = 2
return a
}
public fun <E> toArray(array: Array<E>): Array<E> {
val asIntArray = array as Array<Int>
asIntArray[0] = 0
@@ -15,7 +21,7 @@ fun box(): String {
val collection = MyCollection(Arrays.asList(2, 3, 9)) as java.util.Collection<*>
val array1 = collection.toArray()
val array2 = collection.toArray(Array<Int>(3, { 0 }))
val array2 = collection.toArray(arrayOfNulls<Int>(3) as Array<Int>)
if (array1 !is Array<Any>) return (array1 as Object).getClass().toString()
if (array2 !is Array<Int>) return (array2 as Object).getClass().toString()