Merge boxWithStdlib testData into box, delete BoxWithStdlib test

This commit is contained in:
Alexander Udalov
2016-03-07 13:36:14 +03:00
committed by Alexander Udalov
parent 22bfc9786a
commit 06a67e6602
535 changed files with 3520 additions and 3871 deletions
@@ -0,0 +1,17 @@
// WITH_RUNTIME
import java.util.ArrayList
import java.util.Arrays
fun box(): String {
val list = ArrayList<Pair<String,String>>()
list.add(Pair("Sample", "http://cyber.law.harvard.edu/rss/examples/rss2sample.xml"))
list.add(Pair("Scripting", "http://static.scripting.com/rss.xml"))
val keys = list.map { it.first }.toTypedArray<String>()
val keysToString = Arrays.toString(keys)
if (keysToString != "[Sample, Scripting]") return keysToString
return "OK"
}
@@ -0,0 +1,12 @@
// WITH_RUNTIME
import java.util.Arrays
fun getCopyToArray(): Array<Int> = Arrays.asList(2, 3, 9).toTypedArray()
fun box(): String {
val str = Arrays.toString(getCopyToArray())
if (str != "[2, 3, 9]") return str
return "OK"
}
+23
View File
@@ -0,0 +1,23 @@
// WITH_RUNTIME
import java.util.Arrays
class MyCollection<T>(val delegate: Collection<T>): Collection<T> by delegate
fun box(): String {
val collection = MyCollection(Arrays.asList(2, 3, 9)) as java.util.Collection<*>
val array1 = collection.toArray()
val array2 = collection.toArray(arrayOfNulls<Int>(3) as Array<Int>)
if (!array1.isArrayOf<Any>()) return (array1 as Object).getClass().toString()
if (!array2.isArrayOf<Int>()) return (array2 as Object).getClass().toString()
val s1 = Arrays.toString(array1)
val s2 = Arrays.toString(array2)
if (s1 != "[2, 3, 9]") return "s1 = $s1"
if (s2 != "[2, 3, 9]") return "s2 = $s2"
return "OK"
}
@@ -0,0 +1,38 @@
// WITH_RUNTIME
import java.util.Arrays
class MyCollection<T>(val delegate: Collection<T>): Collection<T> by delegate {
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
asIntArray[1] = 1
asIntArray[2] = 2
return array
}
}
fun box(): String {
val collection = MyCollection(Arrays.asList(2, 3, 9)) as java.util.Collection<*>
val array1 = collection.toArray()
val array2 = collection.toArray(arrayOfNulls<Int>(3) as Array<Int>)
if (!array1.isArrayOf<Any>()) return (array1 as Object).getClass().toString()
if (!array2.isArrayOf<Int>()) return (array2 as Object).getClass().toString()
val s1 = Arrays.toString(array1)
val s2 = Arrays.toString(array2)
if (s1 != "[0, 1, 2]") return "s1 = $s1"
if (s2 != "[0, 1, 2]") return "s2 = $s2"
return "OK"
}
+13
View File
@@ -0,0 +1,13 @@
// WITH_RUNTIME
import java.util.Arrays
fun box(): String {
val array = Arrays.asList(2, 3, 9).toTypedArray()
if (!array.isArrayOf<Int>()) return array.javaClass.toString()
val str = Arrays.toString(array)
if (str != "[2, 3, 9]") return str
return "OK"
}