mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-16 15:53:55 +00:00
Use `// !LANGUAGE: -ReleaseCoroutines` instead in tests which require old (1.2) coroutines, and nothing in tests which require new coroutines because master is already 1.3. Also remove superfluous API_VERSION and other directives which have no effect anymore. Do not include runtime automatically with `WITH_COROUTINES`/`COMMON_COROUTINES_TEST` in box tests; require `WITH_RUNTIME` for that (majority of tests already had it anyway), but remove it from bytecode text tests where runtime is always added automatically. Fix the coroutine package selection code in KotlinTestUtils and update the bunch files correspondingly. Disable tests in `box/coroutines/noStdLib` on JVM: despite the name, these tests were launched with stdlib because of the code in CodegenTestCase, and they do not work without it because at least CoroutineUtil.kt requires stdlib to compile correctly
122 lines
2.0 KiB
Kotlin
Vendored
122 lines
2.0 KiB
Kotlin
Vendored
// COMMON_COROUTINES_TEST
|
|
// WITH_RUNTIME
|
|
|
|
suspend fun empty() {}
|
|
suspend fun withoutReturn() {
|
|
empty()
|
|
}
|
|
|
|
suspend fun twoReturns() {
|
|
return empty()
|
|
return empty()
|
|
}
|
|
|
|
suspend fun notTailCall() {
|
|
empty()
|
|
return empty()
|
|
empty()
|
|
}
|
|
|
|
suspend fun lambdaAsParameter(c: suspend () -> Unit) {
|
|
c()
|
|
}
|
|
|
|
suspend fun lambdaAsParameterNotTailCall(c: suspend () -> Unit) {
|
|
c()
|
|
return c()
|
|
c()
|
|
}
|
|
|
|
suspend fun lambdaAsParameterReturn(c: suspend () -> Unit) {
|
|
return c()
|
|
c()
|
|
}
|
|
|
|
suspend fun returnsInt() = 42
|
|
suspend fun callsIntNotTailCall() {
|
|
returnsInt()
|
|
return
|
|
empty()
|
|
}
|
|
|
|
suspend fun multipleExitPoints(b: Boolean) {
|
|
if (b) empty() else withoutReturn()
|
|
return
|
|
empty()
|
|
}
|
|
|
|
suspend fun multipleExitPointsNotTailCall(b: Boolean) {
|
|
if (b) empty() else returnsInt()
|
|
return
|
|
empty()
|
|
}
|
|
|
|
fun ordinary() = 1
|
|
inline fun ordinaryInline() {
|
|
ordinary()
|
|
}
|
|
|
|
suspend fun multipleExitPointsWithOrdinaryInline(b: Boolean) {
|
|
if (b) empty() else ordinaryInline()
|
|
return
|
|
empty()
|
|
}
|
|
|
|
suspend fun multipleExitPointsWhen(i: Int) {
|
|
when (i) {
|
|
1 -> empty()
|
|
2 -> twoReturns()
|
|
3 -> withoutReturn()
|
|
else -> lambdaAsParameter {}
|
|
}
|
|
return
|
|
empty()
|
|
}
|
|
|
|
suspend fun <T> generic(): T = TODO()
|
|
suspend fun useGenericReturningUnit() {
|
|
generic<Unit>()
|
|
return
|
|
empty()
|
|
}
|
|
|
|
class Generic<T> {
|
|
suspend fun foo(): T = TODO()
|
|
}
|
|
|
|
suspend fun useGenericClass(g: Generic<Unit>) {
|
|
g.foo()
|
|
return
|
|
empty()
|
|
}
|
|
|
|
suspend fun <T> genericInferType(c: () -> T): T = TODO()
|
|
suspend fun useGenericInferType() {
|
|
genericInferType {}
|
|
return
|
|
empty()
|
|
}
|
|
|
|
suspend fun nullableUnit(): Unit? = null
|
|
suspend fun useNullableUnit() {
|
|
nullableUnit()
|
|
return
|
|
empty()
|
|
}
|
|
|
|
suspend fun useRunRunRunRunRun() {
|
|
run {
|
|
run {
|
|
run {
|
|
run {
|
|
run {
|
|
empty()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return
|
|
empty()
|
|
}
|