Fix deprecations in testData: BlackBoxWithStdLibCodegenTest

This commit is contained in:
Ilya Gorbunov
2015-09-15 18:28:32 +03:00
parent 74e1dbff76
commit 9c974b6c5c
36 changed files with 109 additions and 109 deletions
@@ -26,5 +26,5 @@ fun box(): String {
if (A(-2.72) !in s) return "Fail: -2.72 not found" if (A(-2.72) !in s) return "Fail: -2.72 not found"
if (A(NAN) !in s) return "Fail: NaN not found" if (A(NAN) !in s) return "Fail: NaN not found"
return if (s.size == 5) "OK" else "Fail $s" return if (s.size() == 5) "OK" else "Fail $s"
} }
@@ -1,6 +1,6 @@
data class A(val v: Array<Int>) data class A(val v: Array<Int>)
fun box() : String { fun box() : String {
if(A(array(0,1,2)) != A(array(0,1,2))) return "fail" if(A(arrayOf(0,1,2)) != A(arrayOf(0,1,2))) return "fail"
return "OK" return "OK"
} }
@@ -1,6 +1,6 @@
data class A(val v: IntArray) data class A(val v: IntArray)
fun box() : String { fun box() : String {
if(A(intArray(0,1,2)) != A(intArray(0,1,2))) return "fail" if(A(intArrayOf(0,1,2)) != A(intArrayOf(0,1,2))) return "fail"
return "OK" return "OK"
} }
@@ -26,5 +26,5 @@ fun box(): String {
if (A(-2.72f) !in s) return "Fail: -2.72 not found" if (A(-2.72f) !in s) return "Fail: -2.72 not found"
if (A(NAN) !in s) return "Fail: NaN not found" if (A(NAN) !in s) return "Fail: NaN not found"
return if (s.size == 5) "OK" else "Fail $s" return if (s.size() == 5) "OK" else "Fail $s"
} }
@@ -1,6 +1,6 @@
data class A(val a: IntArray, var b: Array<String>) data class A(val a: IntArray, var b: Array<String>)
fun box() : String { fun box() : String {
if( A(intArray(1,2,3),array("239")).hashCode() != 31*java.util.Arrays.hashCode(intArray(0,1,2)) + "239".hashCode()) "fail" if( A(intArrayOf(1,2,3),arrayOf("239")).hashCode() != 31*java.util.Arrays.hashCode(intArrayOf(0,1,2)) + "239".hashCode()) "fail"
return "OK" return "OK"
} }
@@ -9,7 +9,7 @@ enum class Game {
} }
fun box(): String { fun box(): String {
val a = array(LIZARD, SCISSORS, SPOCK, ROCK, PAPER) val a = arrayOf(LIZARD, SCISSORS, SPOCK, ROCK, PAPER)
a.sort() a.sort()
val str = a.joinToString(" ") val str = a.joinToString(" ")
return if (str == "ROCK PAPER SCISSORS LIZARD SPOCK") "OK" else "Fail: $str" return if (str == "ROCK PAPER SCISSORS LIZARD SPOCK") "OK" else "Fail: $str"
+4 -4
View File
@@ -1,5 +1,5 @@
fun ok1(): Boolean { fun ok1(): Boolean {
val queue = linkedList(1, 2, 3) val queue = linkedListOf(1, 2, 3)
while (!queue.isEmpty()) { while (!queue.isEmpty()) {
queue.poll() queue.poll()
for (y in 1..3) { for (y in 1..3) {
@@ -12,8 +12,8 @@ fun ok1(): Boolean {
} }
fun ok2(): Boolean { fun ok2(): Boolean {
val queue = linkedList(1, 2, 3) val queue = linkedListOf(1, 2, 3)
val array = array(1, 2, 3) val array = arrayOf(1, 2, 3)
while (!queue.isEmpty()) { while (!queue.isEmpty()) {
queue.poll() queue.poll()
for (y in array) { for (y in array) {
@@ -26,7 +26,7 @@ fun ok2(): Boolean {
} }
fun ok3(): Boolean { fun ok3(): Boolean {
val queue = linkedList(1, 2, 3) val queue = linkedListOf(1, 2, 3)
while (!queue.isEmpty()) { while (!queue.isEmpty()) {
queue.poll() queue.poll()
var x = 0 var x = 0
+1 -1
View File
@@ -4,7 +4,7 @@ fun box(): String {
} }
class A: B() { class A: B() {
override var foo = array<Int?>(12, 13) override var foo = arrayOf<Int?>(12, 13)
} }
abstract class B { abstract class B {
@@ -36,18 +36,18 @@ fun <T> testMutableCollectionIterator(c: MutableCollection<T>, t: T) {
assertEquals(0, c.size()) assertEquals(0, c.size())
} }
fun <T> testMutableCollectionAddAll(c: MutableCollection<T>, t1: T, t2: T) { fun <T> testMutableCollectionAddAll(c: MutableCollection<T>, t1: T, t2: T) {
c.addAll(arrayList(t1, t2)) c.addAll(arrayListOf(t1, t2))
assertEquals(arrayList(t1, t2), c) assertEquals(arrayListOf(t1, t2), c)
} }
fun <T> testMutableCollectionRemoveAll(c: MutableCollection<T>, t1: T, t2: T) { fun <T> testMutableCollectionRemoveAll(c: MutableCollection<T>, t1: T, t2: T) {
c.addAll(arrayList(t1, t2)) c.addAll(arrayListOf(t1, t2))
c.removeAll(arrayList(t1)) c.removeAll(arrayListOf(t1))
assertEquals(arrayList(t2), c) assertEquals(arrayListOf(t2), c)
} }
fun <T> testMutableCollectionRetainAll(c: MutableCollection<T>, t1: T, t2: T) { fun <T> testMutableCollectionRetainAll(c: MutableCollection<T>, t1: T, t2: T) {
c.addAll(arrayList(t1, t2)) c.addAll(arrayListOf(t1, t2))
c.retainAll(arrayList(t1)) c.retainAll(arrayListOf(t1))
assertEquals(arrayList(t1), c) assertEquals(arrayListOf(t1), c)
} }
fun <T> testMutableCollectionClear(c: MutableCollection<T>) { fun <T> testMutableCollectionClear(c: MutableCollection<T>) {
c.clear() c.clear()
@@ -55,27 +55,27 @@ fun <T> testMutableCollectionClear(c: MutableCollection<T>) {
} }
fun testCollection() { fun testCollection() {
testCollectionSize(arrayList<Int>()) testCollectionSize(arrayListOf<Int>())
testCollectionIsEmpty(arrayList<String>()) testCollectionIsEmpty(arrayListOf<String>())
testCollectionContains(arrayList(1)) testCollectionContains(arrayListOf(1))
testCollectionIterator(arrayList(1)) testCollectionIterator(arrayListOf(1))
testCollectionContainsAll(arrayList("a", "b")) testCollectionContainsAll(arrayListOf("a", "b"))
testMutableCollectionAdd(arrayList(), "") testMutableCollectionAdd(arrayListOf(), "")
testMutableCollectionRemove(arrayList("a"), "a") testMutableCollectionRemove(arrayListOf("a"), "a")
testMutableCollectionIterator(arrayList(), 1) testMutableCollectionIterator(arrayListOf(), 1)
testMutableCollectionAddAll(arrayList(), 1, 2) testMutableCollectionAddAll(arrayListOf(), 1, 2)
testMutableCollectionRemoveAll(arrayList(), 1, 2) testMutableCollectionRemoveAll(arrayListOf(), 1, 2)
testMutableCollectionRetainAll(arrayList(), 1, 2) testMutableCollectionRetainAll(arrayListOf(), 1, 2)
testMutableCollectionClear(arrayList(1, 2)) testMutableCollectionClear(arrayListOf(1, 2))
} }
fun <T> testListGet(l: List<T>, t: T) = assertEquals(t, l.get(0)) fun <T> testListGet(l: List<T>, t: T) = assertEquals(t, l.get(0))
fun <T> testListIndexOf(l: List<T>, t: T) = assertEquals(0, l.indexOf(t)) fun <T> testListIndexOf(l: List<T>, t: T) = assertEquals(0, l.indexOf(t))
fun <T> testListIterator(l: List<T>, t1 : T, t2 : T) { fun <T> testListIterator(l: List<T>, t1 : T, t2 : T) {
val indexes = arrayList<Int>() val indexes = arrayListOf<Int>()
val result = arrayList<T>() val result = arrayListOf<T>()
val it = l.listIterator() val it = l.listIterator()
while (it.hasNext()) { while (it.hasNext()) {
indexes.add(it.nextIndex()) indexes.add(it.nextIndex())
@@ -85,14 +85,14 @@ fun <T> testListIterator(l: List<T>, t1 : T, t2 : T) {
indexes.add(it.previousIndex()) indexes.add(it.previousIndex())
result.add(it.previous()) result.add(it.previous())
} }
assertEquals(arrayList(0, 1, 1, 0), indexes) assertEquals(arrayListOf(0, 1, 1, 0), indexes)
assertEquals(arrayList(t1, t2, t2, t1), result) assertEquals(arrayListOf(t1, t2, t2, t1), result)
} }
fun <T> testListSublist(l: List<T>, t: T) = assertEquals(arrayList(t), l.subList(0, 1)) fun <T> testListSublist(l: List<T>, t: T) = assertEquals(arrayListOf(t), l.subList(0, 1))
fun <T> testMutableListSet(l: MutableList<T>, t: T) { fun <T> testMutableListSet(l: MutableList<T>, t: T) {
l.set(0, t) l.set(0, t)
assertEquals(arrayList(t), l) assertEquals(arrayListOf(t), l)
} }
fun <T> testMutableListIterator(l: MutableList<T>, t1: T, t2: T, t3: T) { fun <T> testMutableListIterator(l: MutableList<T>, t1: T, t2: T, t3: T) {
val it = l.listIterator() val it = l.listIterator()
@@ -100,22 +100,22 @@ fun <T> testMutableListIterator(l: MutableList<T>, t1: T, t2: T, t3: T) {
it.next() it.next()
it.add(t3) it.add(t3)
} }
assertEquals(arrayList(t1, t3, t2, t3), l) assertEquals(arrayListOf(t1, t3, t2, t3), l)
} }
fun testList() { fun testList() {
testListGet(arrayList(1), 1) testListGet(arrayListOf(1), 1)
testListIndexOf(arrayList(1), 1) testListIndexOf(arrayListOf(1), 1)
testListIterator(arrayList("a", "b"), "a", "b") testListIterator(arrayListOf("a", "b"), "a", "b")
testListSublist(arrayList(1, 2), 1) testListSublist(arrayListOf(1, 2), 1)
testMutableListSet(arrayList(2), 4) testMutableListSet(arrayListOf(2), 4)
testMutableListIterator(arrayList(1, 2), 1, 2, 3) testMutableListIterator(arrayListOf(1, 2), 1, 2, 3)
} }
fun <K, V> testMapContainsKey(map: Map<K, V>, k: K) = assertTrue(map.containsKey(k)) fun <K, V> testMapContainsKey(map: Map<K, V>, k: K) = assertTrue(map.containsKey(k))
fun <K, V> testMapKeys(map: Map<K, V>, k1: K, k2: K) = assertEqualCollections(hashSet(k1, k2), map.keySet()) fun <K, V> testMapKeys(map: Map<K, V>, k1: K, k2: K) = assertEqualCollections(hashSetOf(k1, k2), map.keySet())
fun <K, V> testMapValues(map: Map<K, V>, v1: V, v2: V) = assertEqualCollections(hashSet(v1, v2), map.values()) fun <K, V> testMapValues(map: Map<K, V>, v1: V, v2: V) = assertEqualCollections(hashSetOf(v1, v2), map.values())
fun <K, V> testMapEntrySet(map: Map<K, V>, k : K, v: V) { fun <K, V> testMapEntrySet(map: Map<K, V>, k : K, v: V) {
for (entry in map.entrySet()) { for (entry in map.entrySet()) {
assertEquals(k, entry.key) assertEquals(k, entry.key)
@@ -126,16 +126,16 @@ fun <K, V> testMutableMapEntry(map: MutableMap<K, V>, k1 : K, v: V) {
for (entry in map.entrySet()) { for (entry in map.entrySet()) {
entry.setValue(v) entry.setValue(v)
} }
assertEquals(hashMap(k1 to v), map) assertEquals(hashMapOf(k1 to v), map)
} }
fun testMap() { fun testMap() {
testMapContainsKey(hashMap(1 to 'a', 2 to 'b'), 2) testMapContainsKey(hashMapOf(1 to 'a', 2 to 'b'), 2)
testMapKeys(hashMap(1 to 'a', 2 to 'b'), 1, 2) testMapKeys(hashMapOf(1 to 'a', 2 to 'b'), 1, 2)
testMapValues(hashMap(1 to 'a', 2 to 'b'), 'a', 'b') testMapValues(hashMapOf(1 to 'a', 2 to 'b'), 'a', 'b')
testMapEntrySet(hashMap(1 to 'a'), 1, 'a') testMapEntrySet(hashMapOf(1 to 'a'), 1, 'a')
testMutableMapEntry(hashMap(1 to 'a'), 1, 'b') testMutableMapEntry(hashMapOf(1 to 'a'), 1, 'b')
} }
fun box() : String { fun box() : String {
@@ -145,4 +145,4 @@ fun box() : String {
return "OK" return "OK"
} }
fun <T> assertEqualCollections(c1: Collection<T>, c2: Collection<T>) = assertEquals(c1.toCollection(hashSet<T>()), c2.toCollection(hashSet<T>())) fun <T> assertEqualCollections(c1: Collection<T>, c2: Collection<T>) = assertEquals(c1.toCollection(hashSetOf<T>()), c2.toCollection(hashSetOf<T>()))
@@ -13,7 +13,7 @@ World""");
val list1 = sample().useLines{it.toArrayList()} val list1 = sample().useLines{it.toArrayList()}
val list2 = sample().useLines<ArrayList<String>>{it.toArrayList()} val list2 = sample().useLines<ArrayList<String>>{it.toArrayList()}
if(arrayList("Hello", "World") != list1) return "fail" if(arrayListOf("Hello", "World") != list1) return "fail"
if(arrayList("Hello", "World") != list2) return "fail" if(arrayListOf("Hello", "World") != list2) return "fail"
return "OK" return "OK"
} }
@@ -6,6 +6,6 @@ class C {
fun box(): String? { fun box(): String? {
val c: C? = C() val c: C? = C()
val arrayList = array(c?.calc(), "") val arrayList = arrayOf(c?.calc(), "")
return arrayList[0] return arrayList[0]
} }
@@ -6,7 +6,7 @@ annotation class Ann(val args: Array<KClass<*>>)
class O class O
class K class K
@Ann(array(O::class, K::class)) class MyClass @Ann(arrayOf(O::class, K::class)) class MyClass
fun box(): String { fun box(): String {
val args = javaClass<MyClass>().getAnnotation(javaClass<Ann>()).args val args = javaClass<MyClass>().getAnnotation(javaClass<Ann>()).args
@@ -8,7 +8,7 @@ class A {
fun box(): String { fun box(): String {
val a = A() val a = A()
(A::q).set(a, array(array(A.B("array")))) (A::q).set(a, arrayOf(arrayOf(A.B("array"))))
if (a.q!![0][0].result != "array") return "Fail array" if (a.q!![0][0].result != "array") return "Fail array"
(A::p).set(a, A.B("OK")) (A::p).set(a, A.B("OK"))
@@ -9,7 +9,7 @@ fun f(xs: Iterator<Int>): Int {
} }
fun box(): String { fun box(): String {
val list = arrayList(1, 2, 3) val list = arrayListOf(1, 2, 3)
val result = f(list.iterator()) val result = f(list.iterator())
return if (6 == result) "OK" else "fail" return if (6 == result) "OK" else "fail"
} }
@@ -11,7 +11,7 @@ class ClassWithGenericSuperInterface: java.util.Comparator<String> {
fun check(klass: Class<*>) { fun check(klass: Class<*>) {
val interfaces = klass.getInterfaces().toList() val interfaces = klass.getInterfaces().toList()
val genericInterfaces = klass.getGenericInterfaces().toList() val genericInterfaces = klass.getGenericInterfaces().toList()
if (interfaces.size != genericInterfaces.size) { if (interfaces.size() != genericInterfaces.size()) {
throw AssertionError("interfaces=$interfaces, genericInterfaces=$genericInterfaces") throw AssertionError("interfaces=$interfaces, genericInterfaces=$genericInterfaces")
} }
} }
@@ -20,7 +20,7 @@ public fun <T: Comparable<T>> Collection<T>.testMin(): T? {
} }
fun box() : String { fun box() : String {
val users = arrayList( val users = arrayListOf(
User("John", "Doe", 30), User("John", "Doe", 30),
User("Jane", "Doe", 27)) User("Jane", "Doe", 27))
@@ -3,6 +3,6 @@ class A<T>(t: Array<Array<T>>) {
} }
fun box(): String { fun box(): String {
A<Int>(array()) // <- java.lang.VerifyError: (class: A, method: getA signature: ()[[Ljava/lang/Object;) Wrong return type in function A<Int>(arrayOf()) // <- java.lang.VerifyError: (class: A, method: getA signature: ()[[Ljava/lang/Object;) Wrong return type in function
return "OK" return "OK"
} }
@@ -1,4 +1,4 @@
fun box(): String { fun box(): String {
val list = array("a", "c", "b").toSortedList() val list = arrayOf("a", "c", "b").sorted()
return if (list.toString() == "[a, b, c]") "OK" else "Fail: $list" return if (list.toString() == "[a, b, c]") "OK" else "Fail: $list"
} }
@@ -8,5 +8,5 @@ fun box() : String {
val a = ArrayList<Int>(); val a = ArrayList<Int>();
a.add(1) a.add(1)
a.add(2) a.add(2)
return if((a.size == 2) && (a.get(1) == 2) && (a.get(0) == 1)) "OK" else "fail" return if((a.size() == 2) && (a.get(1) == 2) && (a.get(0) == 1)) "OK" else "fail"
} }
@@ -1,7 +1,7 @@
import kotlin.test.assertEquals import kotlin.test.assertEquals
inline fun <reified T> copy(c: Collection<T>): Array<T> { inline fun <reified T> copy(c: Collection<T>): Array<T> {
return c.copyToArray() return c.toTypedArray()
} }
fun box(): String { fun box(): String {
@@ -5,7 +5,7 @@ inline fun<reified T> Array<Any>.filterIsInstance(): List<T> {
} }
fun box(): String { fun box(): String {
val src: Array<Any> = array(1,2,3.toDouble(), "abc", "cde") val src: Array<Any> = arrayOf(1,2,3.toDouble(), "abc", "cde")
assertEquals(arrayListOf(1,2), src.filterIsInstance<Int>()) assertEquals(arrayListOf(1,2), src.filterIsInstance<Int>())
assertEquals(arrayListOf(3.0), src.filterIsInstance<Double>()) assertEquals(arrayListOf(3.0), src.filterIsInstance<Double>())
@@ -2,7 +2,7 @@ import kotlin.test.assertEquals
inline fun <reified T : Any, reified R : Any> foo(): Array<String> { inline fun <reified T : Any, reified R : Any> foo(): Array<String> {
val x = object { val x = object {
inline fun <reified T1 : Any, reified T : Any> bar(): Array<String> = array( inline fun <reified T1 : Any, reified T : Any> bar(): Array<String> = arrayOf(
javaClass<T1>().getName(), javaClass<T>().getName(), javaClass<R>().getName() javaClass<T1>().getName(), javaClass<T>().getName(), javaClass<R>().getName()
) )
fun f1() = bar<T, R>() fun f1() = bar<T, R>()
@@ -16,7 +16,7 @@ inline fun <reified T : Any, reified R : Any> foo(): Array<String> {
val x3 = x.f3() val x3 = x.f3()
val x4 = x.f4() val x4 = x.f4()
return array( return arrayOf(
x1[0], x1[1], x1[2], x1[0], x1[1], x1[2],
x2[0], x2[1], x2[2], x2[0], x2[1], x2[2],
x3[0], x3[1], x3[2], x3[0], x3[1], x3[2],
@@ -27,7 +27,7 @@ inline fun <reified T : Any, reified R : Any> foo(): Array<String> {
fun box(): String { fun box(): String {
val result = foo<Double, Int>() val result = foo<Double, Int>()
val expected = array( val expected = arrayOf(
"java.lang.Double", "java.lang.Integer", "java.lang.Integer", "java.lang.Double", "java.lang.Integer", "java.lang.Integer",
"java.lang.Integer", "java.lang.Double", "java.lang.Integer", "java.lang.Integer", "java.lang.Double", "java.lang.Integer",
"java.lang.Boolean", "java.lang.Double", "java.lang.Integer", "java.lang.Boolean", "java.lang.Double", "java.lang.Integer",
@@ -11,13 +11,13 @@ inline fun <reified T, reified R> foo(): Array<A<*,*,*>> {
fun f4() = bar<T, Boolean>() fun f4() = bar<T, Boolean>()
} }
return array(x.f1(), x.f2(), x.f3(), x.f4()) return arrayOf(x.f1(), x.f2(), x.f3(), x.f4())
} }
fun box(): String { fun box(): String {
val result = foo<Double, Int>() val result = foo<Double, Int>()
val expected = array( val expected = arrayOf(
Triple("java.lang.Double", "java.lang.Integer", "java.lang.Integer"), Triple("java.lang.Double", "java.lang.Integer", "java.lang.Integer"),
Triple("java.lang.Integer", "java.lang.Double", "java.lang.Integer"), Triple("java.lang.Integer", "java.lang.Double", "java.lang.Integer"),
Triple("java.lang.Boolean", "java.lang.Double", "java.lang.Integer"), Triple("java.lang.Boolean", "java.lang.Double", "java.lang.Integer"),
+4 -4
View File
@@ -5,19 +5,19 @@ fun <T> foo(vararg a: T) = a.size()
inline fun <reified T> bar(a: Array<T>, block: () -> T): Array<T> { inline fun <reified T> bar(a: Array<T>, block: () -> T): Array<T> {
assertEquals(4, foo(*a, block(), block())) assertEquals(4, foo(*a, block(), block()))
return array(*a, block(), block()) return arrayOf(*a, block(), block())
} }
inline fun <reified T> empty() = array<T>() inline fun <reified T> empty() = arrayOf<T>()
fun box(): String { fun box(): String {
var i = 0 var i = 0
val a: Array<String> = bar(array("1", "2")) { i++; i.toString() } val a: Array<String> = bar(arrayOf("1", "2")) { i++; i.toString() }
assertEquals("1234", a.join("")) assertEquals("1234", a.join(""))
i = 0 i = 0
val b: Array<Int> = bar(array(0, 1)) { i++ } val b: Array<Int> = bar(arrayOf(0, 1)) { i++ }
assertEquals("0123", b.map { it.toString() }.join("")) assertEquals("0123", b.map { it.toString() }.join(""))
return "OK" return "OK"
+2 -2
View File
@@ -5,10 +5,10 @@ fun <T> foo(vararg a: T) = a.size()
inline fun <reified T> bar(block: () -> T): Array<T> { inline fun <reified T> bar(block: () -> T): Array<T> {
assertEquals(2, foo(block(), block())) assertEquals(2, foo(block(), block()))
return array(block(), block(), block()) return arrayOf(block(), block(), block())
} }
inline fun <reified T> empty() = array<T>() inline fun <reified T> empty() = arrayOf<T>()
fun box(): String { fun box(): String {
var i = 0 var i = 0
@@ -9,7 +9,7 @@ inline fun foo() = "-"
fun box(): String { fun box(): String {
val result1 = foobar1(if (1 == 1) true else bar(), foo(), "OK") val result1 = foobar1(if (1 == 1) true else bar(), foo(), "OK")
val result2 = foobar2(if (1 == 1) "true" else array("false"), foo(), "OK") val result2 = foobar2(if (1 == 1) "true" else arrayOf("false"), foo(), "OK")
assertEquals("true-OK", result1) assertEquals("true-OK", result1)
assertEquals("true-OK", result2) assertEquals("true-OK", result2)
return "OK" return "OK"
@@ -1,7 +1,7 @@
import java.util.Arrays import java.util.Arrays
fun box(): String { fun box(): String {
val array = Arrays.asList(2, 3, 9).copyToArray() val array = Arrays.asList(2, 3, 9).toTypedArray()
if (array !is Array<Int>) return array.javaClass.toString() if (array !is Array<Int>) return array.javaClass.toString()
val str = Arrays.toString(array) val str = Arrays.toString(array)
@@ -6,7 +6,7 @@ fun box(): String {
list.add(Pair("Sample", "http://cyber.law.harvard.edu/rss/examples/rss2sample.xml")) list.add(Pair("Sample", "http://cyber.law.harvard.edu/rss/examples/rss2sample.xml"))
list.add(Pair("Scripting", "http://static.scripting.com/rss.xml")) list.add(Pair("Scripting", "http://static.scripting.com/rss.xml"))
val keys = list.map { it.first }.copyToArray<String>() val keys = list.map { it.first }.toTypedArray<String>()
val keysToString = Arrays.toString(keys) val keysToString = Arrays.toString(keys)
if (keysToString != "[Sample, Scripting]") return keysToString if (keysToString != "[Sample, Scripting]") return keysToString
@@ -1,6 +1,6 @@
import java.util.Arrays import java.util.Arrays
fun getCopyToArray(): Array<Int> = Arrays.asList(2, 3, 9).copyToArray() fun getCopyToArray(): Array<Int> = Arrays.asList(2, 3, 9).toTypedArray()
fun box(): String { fun box(): String {
val str = Arrays.toString(getCopyToArray()) val str = Arrays.toString(getCopyToArray())
@@ -3,43 +3,43 @@ fun box(): String {
if (test1(1) != "1") return "fail 2" if (test1(1) != "1") return "fail 2"
if (test1(1, 2) != "12") return "fail 3" if (test1(1, 2) != "12") return "fail 3"
if (test1(*intArray()) != "") return "fail 4" if (test1(*intArrayOf()) != "") return "fail 4"
if (test1(*intArray(1)) != "1") return "fail 5" if (test1(*intArrayOf(1)) != "1") return "fail 5"
if (test1(*intArray(1, 2)) != "12") return "fail 6" if (test1(*intArrayOf(1, 2)) != "12") return "fail 6"
if (test1(p = 1) != "1") return "fail 7" if (test1(p = 1) != "1") return "fail 7"
if (test1(p = *intArray()) != "") return "fail 8" if (test1(p = *intArrayOf()) != "") return "fail 8"
if (test1(p = *intArray(1)) != "1") return "fail 9" if (test1(p = *intArrayOf(1)) != "1") return "fail 9"
if (test1(p = *intArray(1, 2)) != "12") return "fail 10" if (test1(p = *intArrayOf(1, 2)) != "12") return "fail 10"
if (test2() != "") return "fail 11" if (test2() != "") return "fail 11"
if (test2("1") != "1") return "fail 12" if (test2("1") != "1") return "fail 12"
if (test2("1", "2") != "12") return "fail 13" if (test2("1", "2") != "12") return "fail 13"
if (test2(*array<String>()) != "") return "fail 14" if (test2(*arrayOf<String>()) != "") return "fail 14"
if (test2(*array<String>("1")) != "1") return "fail 15" if (test2(*arrayOf<String>("1")) != "1") return "fail 15"
if (test2(*array<String>("1", "2")) != "12") return "fail 16" if (test2(*arrayOf<String>("1", "2")) != "12") return "fail 16"
if (test2(p = "1") != "1") return "fail 17" if (test2(p = "1") != "1") return "fail 17"
if (test2(p = *array<String>()) != "") return "fail 18" if (test2(p = *arrayOf<String>()) != "") return "fail 18"
if (test2(p = *array<String>("1")) != "1") return "fail 19" if (test2(p = *arrayOf<String>("1")) != "1") return "fail 19"
if (test2(p = *array<String>("1", "2")) != "12") return "fail 20" if (test2(p = *arrayOf<String>("1", "2")) != "12") return "fail 20"
if (test3<String>() != "") return "fail 21" if (test3<String>() != "") return "fail 21"
if (test3("1") != "1") return "fail 22" if (test3("1") != "1") return "fail 22"
if (test3("1", "2") != "12") return "fail 23" if (test3("1", "2") != "12") return "fail 23"
if (test3(*array<String>()) != "") return "fail 24" if (test3(*arrayOf<String>()) != "") return "fail 24"
if (test3(*array<String>("1")) != "1") return "fail 25" if (test3(*arrayOf<String>("1")) != "1") return "fail 25"
if (test3(*array<String>("1", "2")) != "12") return "fail 26" if (test3(*arrayOf<String>("1", "2")) != "12") return "fail 26"
if (test3(p = "1") != "1") return "fail 27" if (test3(p = "1") != "1") return "fail 27"
if (test3(p = *array<String>()) != "") return "fail 28" if (test3(p = *arrayOf<String>()) != "") return "fail 28"
if (test3(p = *array<String>("1")) != "1") return "fail 29" if (test3(p = *arrayOf<String>("1")) != "1") return "fail 29"
if (test3(p = *array<String>("1", "2")) != "12") return "fail 30" if (test3(p = *arrayOf<String>("1", "2")) != "12") return "fail 30"
return "OK" return "OK"
} }
@@ -17,7 +17,7 @@ fun dense(x: Int): Int {
} }
fun box(): String { fun box(): String {
var result = (-5..10).map(::dense).makeString() var result = (-5..10).map(::dense).joinToString()
if (result != "19, 9, 19, 19, 10, 11, 12, 19, 19, 13, 14, 15, 16, 17, 18, 19") return "dense:" + result if (result != "19, 9, 19, 19, 10, 11, 12, 19, 19, 13, 14, 15, 16, 17, 18, 19") return "dense:" + result
return "OK" return "OK"
@@ -8,7 +8,7 @@ fun foo(x: Int): Int {
} }
fun box(): String { fun box(): String {
var result = (0..10).map(::foo).makeString() var result = (0..10).map(::foo).joinToString()
if (result != "4, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4") return result if (result != "4, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4") return result
return "OK" return "OK"
@@ -10,7 +10,7 @@ fun sparse(x: Int): Int {
} }
fun box(): String { fun box(): String {
var result = (0..3).map(::sparse).makeString() var result = (0..3).map(::sparse).joinToString()
if (result != "4, 1, 2, 3") return "sparse:" + result if (result != "4, 1, 2, 3") return "sparse:" + result
return "OK" return "OK"
@@ -22,11 +22,11 @@ fun nonExhaustive(x: Int): Int {
} }
fun box(): String { fun box(): String {
var result = (0..3).map(::exhaustive).makeString() var result = (0..3).map(::exhaustive).joinToString()
if (result != "4, 1, 2, 3") return "exhaustive:" + result if (result != "4, 1, 2, 3") return "exhaustive:" + result
result = (0..3).map(::nonExhaustive).makeString() result = (0..3).map(::nonExhaustive).joinToString()
if (result != "4, 1, 2, 3") return "non-exhaustive:" + result if (result != "4, 1, 2, 3") return "non-exhaustive:" + result
return "OK" return "OK"
@@ -35,19 +35,19 @@ fun charFoo(x: Char): Int {
} }
fun box(): String { fun box(): String {
var result = (1..4).map(::intFoo).makeString() var result = (1..4).map(::intFoo).joinToString()
if (result != "5, 6, 7, 8") return "int:" + result if (result != "5, 6, 7, 8") return "int:" + result
result = (1.toShort()..4.toShort()).map(::shortFoo).makeString() result = (1.toShort()..4.toShort()).map(::shortFoo).joinToString()
if (result != "5, 6, 7, 8") return "short:" + result if (result != "5, 6, 7, 8") return "short:" + result
result = (1.toByte()..4.toByte()).map(::byteFoo).makeString() result = (1.toByte()..4.toByte()).map(::byteFoo).joinToString()
if (result != "5, 6, 7, 8") return "byte:" + result if (result != "5, 6, 7, 8") return "byte:" + result
result = ('a'..'d').map(::charFoo).makeString() result = ('a'..'d').map(::charFoo).joinToString()
if (result != "5, 6, 7, 8") return "int:" + result if (result != "5, 6, 7, 8") return "int:" + result
return "OK" return "OK"
@@ -8,7 +8,7 @@ fun foo(x: Int): Int {
} }
fun box(): String { fun box(): String {
var result = (0..3).map(::foo).makeString() var result = (0..3).map(::foo).joinToString()
if (result != "8, 5, 6, 7") return "unordered:" + result if (result != "8, 5, 6, 7") return "unordered:" + result
return "OK" return "OK"