JS backend: added tests for labels

This commit is contained in:
Alexey Tsvetkov
2014-10-13 20:43:58 +04:00
parent 0bc05135d8
commit 09c98226c8
12 changed files with 378 additions and 4 deletions
@@ -0,0 +1,43 @@
package foo
// CHECK_CONTAINS_NO_CALLS: test
// CHECK_LABELS_COUNT: function=test name=loop$ count=1
// CHECK_LABELS_COUNT: function=test name=loop$_0 count=1
// CHECK_LABELS_COUNT: function=test name=loop$_1 count=1
class State() {
public var value: Int = 0
}
inline fun test1(state: State) {
@loop for (i in 1..10) {
state.value++
if (i == 2) break@loop
}
}
inline fun test2(state: State) {
@loop for (i in 1..10) {
test1(state)
if (i == 2) break@loop
}
}
inline fun test3(state: State) {
@loop for (i in 1..10) {
test2(state)
if (i == 2) break@loop
}
}
noinline fun test(state: State) {
test3(state)
}
fun box(): String {
val state = State()
test(state)
assertEquals(8, state.value)
return "OK"
}