[K/N][tests] Migrate various runtime/ tests ^KT-61259
This commit is contained in:
committed by
Space Team
parent
7ad4e58a7a
commit
d88092aa94
@@ -0,0 +1,28 @@
|
||||
import kotlin.test.*
|
||||
|
||||
private class Integer(val value: Int) {
|
||||
operator fun inc() = Integer(value + 1)
|
||||
}
|
||||
|
||||
private fun foo(x: Any, y: Any) {
|
||||
x.use()
|
||||
y.use()
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var x = Integer(0)
|
||||
|
||||
for (i in 0..1) {
|
||||
val c = Integer(0)
|
||||
if (i == 0) x = c
|
||||
}
|
||||
|
||||
// x refcount is 1.
|
||||
|
||||
foo(x, ++x)
|
||||
return "OK"
|
||||
}
|
||||
|
||||
private fun Any?.use() {
|
||||
var x = this
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
var x = Any()
|
||||
|
||||
for (i in 0..1) {
|
||||
val c = Any()
|
||||
if (i == 0) x = c
|
||||
}
|
||||
|
||||
// x refcount is 1.
|
||||
|
||||
val y = try {
|
||||
x
|
||||
} finally {
|
||||
x = Any()
|
||||
}
|
||||
|
||||
y.use()
|
||||
return "OK"
|
||||
}
|
||||
|
||||
private fun Any?.use() {
|
||||
var x = this
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
foo().use()
|
||||
return "OK"
|
||||
}
|
||||
|
||||
private fun foo(): Any {
|
||||
var x = Any()
|
||||
|
||||
for (i in 0..1) {
|
||||
val c = Any()
|
||||
if (i == 0) x = c
|
||||
}
|
||||
|
||||
// x refcount is 1.
|
||||
|
||||
try {
|
||||
return x
|
||||
} finally {
|
||||
x = Any()
|
||||
}
|
||||
}
|
||||
|
||||
private fun Any?.use() {
|
||||
var x = this
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
var x = Error()
|
||||
|
||||
for (i in 0..1) {
|
||||
val c = Error()
|
||||
if (i == 0) x = c
|
||||
}
|
||||
|
||||
// x refcount is 1.
|
||||
|
||||
try {
|
||||
try {
|
||||
throw x
|
||||
} finally {
|
||||
x = Error()
|
||||
}
|
||||
} catch (e: Error) {
|
||||
e.use()
|
||||
}
|
||||
return "OK"
|
||||
}
|
||||
|
||||
private fun Any?.use() {
|
||||
var x = this
|
||||
}
|
||||
Reference in New Issue
Block a user