Fix deprecations in testData

This commit is contained in:
Ilya Gorbunov
2016-01-27 16:03:27 +03:00
parent eabac9dcf6
commit d49f5b95b0
15 changed files with 26 additions and 21 deletions
+1 -1
View File
@@ -13,7 +13,7 @@ public inline fun massert(value: Boolean, lazyMessage: () -> String) {
public inline fun massert(value: Boolean, message: Any = "Assertion failed") {
if (ASSERTIONS_ENABLED) {
if (MASSERTIONS_ENABLED) {
if (!value) {
throw AssertionError(message)
}
@@ -5,7 +5,7 @@ import kotlin.test.*
fun box(): String {
val c = J::class.constructors.single()
assertFalse(c.isAccessible)
assertFailsWith(IllegalCallableAccessException::class.java) { c.call("") }
assertFailsWith(IllegalCallableAccessException::class) { c.call("") }
c.isAccessible = true
assertTrue(c.isAccessible)
@@ -13,7 +13,7 @@ fun box(): String {
val m = J::class.members.single { it.name == "getResult" }
assertFalse(m.isAccessible)
assertFailsWith(IllegalCallableAccessException::class.java) { m.call(j)!! }
assertFailsWith(IllegalCallableAccessException::class) { m.call(j)!! }
m.isAccessible = true
return m.call(j) as String
+1 -1
View File
@@ -32,7 +32,7 @@ val fns = arrayOf<Any>(::fn0, ::fn1, ::fn2, ::fn3, ::fn4, ::fn5, ::fn6, ::fn7, :
::fn20, ::fn21, ::fn22)
inline fun asFailsWithCCE(operation: String, crossinline block: () -> Unit) {
assertFailsWith(ClassCastException::class.java, "$operation should throw an exception") {
assertFailsWith(ClassCastException::class, "$operation should throw an exception") {
block()
}
}
@@ -36,7 +36,7 @@ inline fun <reified T> reifiedAsSucceeds(x: Any, operation: String) {
}
inline fun <reified T> reifiedAsFailsWithCCE(x: Any, operation: String) {
assertFailsWith(ClassCastException::class.java, "$operation should throw an exception") {
assertFailsWith(ClassCastException::class, "$operation should throw an exception") {
x as T
}
}
+5 -3
View File
@@ -1,5 +1,7 @@
import java.util.LinkedList
fun ok1(): Boolean {
val queue = linkedListOf(1, 2, 3)
val queue = LinkedList(listOf(1, 2, 3))
while (!queue.isEmpty()) {
queue.poll()
for (y in 1..3) {
@@ -12,7 +14,7 @@ fun ok1(): Boolean {
}
fun ok2(): Boolean {
val queue = linkedListOf(1, 2, 3)
val queue = LinkedList(listOf(1, 2, 3))
val array = arrayOf(1, 2, 3)
while (!queue.isEmpty()) {
queue.poll()
@@ -26,7 +28,7 @@ fun ok2(): Boolean {
}
fun ok3(): Boolean {
val queue = linkedListOf(1, 2, 3)
val queue = LinkedList(listOf(1, 2, 3))
while (!queue.isEmpty()) {
queue.poll()
var x = 0
@@ -7,10 +7,12 @@ World""");
}
fun box() : String {
// NOTE: Also tested in stdlib: LineIteratorTest.useLines
// TODO compiler error
// both these expressions causes java.lang.NoClassDefFoundError: collections/CollectionPackage
val list1 = sample().useLines{it.toArrayList()}
val list2 = sample().useLines<ArrayList<String>>{it.toArrayList()}
val list1 = sample().useLines { it.toList() }
val list2 = sample().useLines<ArrayList<String>>{ it.toCollection(arrayListOf()) }
if(arrayListOf("Hello", "World") != list1) return "fail"
if(arrayListOf("Hello", "World") != list2) return "fail"
@@ -24,7 +24,7 @@ fun box(): String {
return "Fail: no Kotlin function found for static bridge for @JvmStatic method in companion object C::foo"
assertEquals(3, k2.call(C, "ghi"))
assertFailsWith(NullPointerException::class.java) { k2.call(null, "")!! }
assertFailsWith(NullPointerException::class) { k2.call(null, "")!! }
val j2 = k2.javaMethod
assertEquals(j, j2)
+1 -1
View File
@@ -3,5 +3,5 @@
fun foo() {
kotlin.test.<caret>assertFailsWith<Exception>("", {})
kotlin.test.assertFailsWith(RuntimeException::class.java, "", {})
kotlin.test.assertFailsWith(RuntimeException::class, "", {})
}
+1 -1
View File
@@ -5,5 +5,5 @@ import kotlin.test.assertFailsWith
fun foo() {
<caret>assertFailsWith<Exception>("", {})
assertFailsWith(RuntimeException::class.java, "", {})
assertFailsWith(RuntimeException::class, "", {})
}
@@ -1,7 +1,6 @@
// WITH_RUNTIME
// IS_APPLICABLE: FALSE
fun Int.withIndex(): List<Pair<Int, Int>> = linkedListOf<Pair<Int, Int>>()
fun Int.withIndex(): List<Pair<Int, Int>> = listOf<Pair<Int, Int>>()
fun foo(s: Int) {
for ((index<caret>, a) in s.withIndex()) {
@@ -2,5 +2,5 @@
package some
fun testFun() {
<caret>measureTimeNano({})
<caret>measureNanoTime({})
}
@@ -1,8 +1,8 @@
// "Import" "true"
package some
import kotlin.system.measureTimeNano
import kotlin.system.measureNanoTime
fun testFun() {
measureTimeNano({})
measureNanoTime({})
}
@@ -1,7 +1,7 @@
package foo
fun sequenceFromFunctionWithInitialValue() {
val values = sequence(3) { n -> if (n > 0) n - 1 else null }
val values = generateSequence(3) { n -> if (n > 0) n - 1 else null }
assertEquals(arrayListOf(3, 2, 1, 0), values.toList())
}
@@ -1,10 +1,12 @@
package foo
import kotlin.comparisons.*
val Int.abs: Int
get() = if (this >= 0) this else -this
fun test(xs: List<Int>): List<Int> =
xs.sortedWith(comparator { a, b -> a.abs.compareTo(b.abs) })
xs.sortedWith(compareBy { it.abs })
fun box(): String {
assertEquals(listOf(1, -2, 3, -4), test(listOf(-2, 1, -4, 3)))
+1 -1
View File
@@ -123,7 +123,7 @@ fun printField(s: String, steps: Int) {
fun makeField(s: String): Field {
val lines: List<String> = s.split("\n")
val w = Collections.max<String>(lines.toList(), comparator<String> { o1, o2 ->
val w = Collections.max<String>(lines.toList(), Comparator<String> { o1, o2 ->
val l1: Int = o1.length
val l2 = o2.length
l1 - l2