[K/N][tests] Adjust moved tests to new testing infra
^KT-61259
This commit is contained in:
committed by
Space Team
parent
0a0da76a56
commit
e68bd1f04f
+16
-8
@@ -3,23 +3,31 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package runtime.exceptions.catch1
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
@Test fun runTest() {
|
||||
val sb = StringBuilder()
|
||||
|
||||
fun box(): String {
|
||||
try {
|
||||
println("Before")
|
||||
sb.appendLine("Before")
|
||||
foo()
|
||||
println("After")
|
||||
sb.appendLine("After")
|
||||
} catch (e: Throwable) {
|
||||
println("Caught Throwable")
|
||||
sb.appendLine("Caught Throwable")
|
||||
}
|
||||
|
||||
println("Done")
|
||||
sb.appendLine("Done")
|
||||
|
||||
assertEquals("""
|
||||
Before
|
||||
Caught Throwable
|
||||
Done
|
||||
|
||||
""".trimIndent(), sb.toString())
|
||||
return "OK"
|
||||
}
|
||||
|
||||
fun foo() {
|
||||
throw Error("Error happens")
|
||||
println("After in foo()")
|
||||
sb.appendLine("After in foo()")
|
||||
}
|
||||
+18
-10
@@ -3,27 +3,35 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package runtime.exceptions.catch2
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
@Test fun runTest() {
|
||||
val sb = StringBuilder()
|
||||
|
||||
fun box(): String {
|
||||
try {
|
||||
println("Before")
|
||||
sb.appendLine("Before")
|
||||
foo()
|
||||
println("After")
|
||||
sb.appendLine("After")
|
||||
} catch (e: Exception) {
|
||||
println("Caught Exception")
|
||||
sb.appendLine("Caught Exception")
|
||||
} catch (e: Error) {
|
||||
println("Caught Error")
|
||||
sb.appendLine("Caught Error")
|
||||
} catch (e: Throwable) {
|
||||
println("Caught Throwable")
|
||||
sb.appendLine("Caught Throwable")
|
||||
}
|
||||
|
||||
println("Done")
|
||||
sb.appendLine("Done")
|
||||
|
||||
assertEquals("""
|
||||
Before
|
||||
Caught Error
|
||||
Done
|
||||
|
||||
""".trimIndent(), sb.toString())
|
||||
return "OK"
|
||||
}
|
||||
|
||||
fun foo() {
|
||||
throw Error("Error happens")
|
||||
println("After in foo()")
|
||||
sb.appendLine("After in foo()")
|
||||
}
|
||||
@@ -3,21 +3,23 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package runtime.exceptions.catch7
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
@Test fun runTest() {
|
||||
val sb = StringBuilder()
|
||||
|
||||
fun box(): String {
|
||||
try {
|
||||
foo()
|
||||
} catch (e: Throwable) {
|
||||
val message = e.message
|
||||
if (message != null) {
|
||||
println(message)
|
||||
sb.append(message)
|
||||
}
|
||||
}
|
||||
|
||||
return sb.toString()
|
||||
}
|
||||
|
||||
fun foo() {
|
||||
throw Error("Error happens")
|
||||
throw Error("OK")
|
||||
}
|
||||
@@ -3,16 +3,15 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package runtime.exceptions.extend0
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
class C : Exception("OK")
|
||||
|
||||
@Test fun runTest() {
|
||||
fun box(): String {
|
||||
try {
|
||||
throw C()
|
||||
} catch (e: Throwable) {
|
||||
println(e.message!!)
|
||||
return e.message!!
|
||||
}
|
||||
return "FAIL"
|
||||
}
|
||||
@@ -3,12 +3,9 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package runtime.exceptions.rethtow
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
@Test
|
||||
fun runTest() {
|
||||
fun box(): String {
|
||||
assertFailsWith<IllegalStateException>("My error") {
|
||||
try {
|
||||
error("My error")
|
||||
@@ -16,4 +13,5 @@ fun runTest() {
|
||||
throw e
|
||||
}
|
||||
}
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -3,15 +3,13 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package runtime.basic.throw0
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
@Test fun runTest() {
|
||||
fun box(): String {
|
||||
val cond = 1
|
||||
if (cond == 2) throw RuntimeException()
|
||||
if (cond == 3) throw NoSuchElementException("no such element")
|
||||
if (cond == 4) throw Error("error happens")
|
||||
|
||||
println("Done")
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -3,12 +3,9 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package runtime.exceptions.throw_from_catch
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
@Test
|
||||
fun runTest() {
|
||||
fun box(): String {
|
||||
assertFailsWith<IllegalStateException>("My another error") {
|
||||
try {
|
||||
error("My error")
|
||||
@@ -16,4 +13,5 @@ fun runTest() {
|
||||
error("My another error")
|
||||
}
|
||||
}
|
||||
return "OK"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user