Files
kotlin-fork/kotlin-native/backend.native/tests/coverage/basic/jumps/main.kt
T
Stanislav Erokhin f624800b84 Move everything under kotlin-native folder
I was forced to manually do update the following files, because otherwise
they would be ignored according .gitignore settings. Probably they
should be deleted from repo.

Interop/.idea/compiler.xml
Interop/.idea/gradle.xml
Interop/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_runtime_1_0_3.xml
Interop/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_1_0_3.xml
Interop/.idea/modules.xml
Interop/.idea/modules/Indexer/Indexer.iml
Interop/.idea/modules/Runtime/Runtime.iml
Interop/.idea/modules/StubGenerator/StubGenerator.iml
backend.native/backend.native.iml
backend.native/bc.frontend/bc.frontend.iml
backend.native/cli.bc/cli.bc.iml
backend.native/cli.bc/src/org/jetbrains/kotlin/cli/bc/K2Native.kt
backend.native/cli.bc/src/org/jetbrains/kotlin/cli/bc/K2NativeCompilerArguments.kt
backend.native/tests/link/lib/foo.kt
backend.native/tests/link/lib/foo2.kt
backend.native/tests/teamcity-test.property
2020-10-27 21:00:28 +03:00

90 lines
1.4 KiB
Kotlin

package coverage.basic.jumps
fun simpleReturn(n: Int) {
if (n == 0) return
println(n)
}
fun returnFromIfBranch(n: Int) {
if (n > 0) {
if (n > 10) {
return
}
} else if (n < -10) {
return
} else if (n == 0) {
return
}
println(n)
}
fun returnFromWhenBranch(n: Int) {
when {
n == 0 -> return
n == 1 -> return
n == 2 -> {
println(n)
return
}
else -> println(n)
}
}
fun breakFromWhile() {
var a = 7
while (true) {
if (a < 4) break
println(a)
a--
}
}
fun continueFromDoWhile() {
var a = 0
do {
if (a % 3 == 0) {
a++
continue
}
println(a)
a++
} while (a < 10)
}
fun singleReturn() {
return
}
fun nestedReturn() {
while (true) {
while (true) {
while (true) {
if (1 < 2) {
return
}
println()
}
println()
}
}
println()
}
fun main() {
simpleReturn(0)
simpleReturn(1)
returnFromIfBranch(1)
returnFromIfBranch(11)
returnFromIfBranch(-11)
returnFromIfBranch(0)
returnFromWhenBranch(0)
returnFromWhenBranch(1)
returnFromWhenBranch(2)
breakFromWhile()
continueFromDoWhile()
singleReturn()
nestedReturn()
}