JS backend: simplify and rename tests for closure in nested functions.

This commit is contained in:
Zalim Bashorov
2013-07-22 18:58:08 +04:00
parent 462e1bdc98
commit e8b95ca074
5 changed files with 68 additions and 58 deletions
@@ -0,0 +1,50 @@
package foo
fun run<T>(f: ()->T) = f()
fun funfun(): Boolean {
val result = true
fun foo(): Boolean {
fun bar() = result
return bar()
}
return foo()
}
fun litlit(): Boolean {
val result = true
return run {
run { result }
}
}
fun funlit(): Boolean {
val result = true
fun foo(): Boolean {
return run { result }
}
return foo()
}
fun litfun(): Boolean {
val result = true
return run {
fun bar() = result
bar()
}
}
fun box(): String {
if (!funfun()) "funfun failed"
if (!litlit()) "litlit failed"
if (!funlit()) "funlit failed"
if (!litfun()) "litfun failed"
return "OK"
}