JS backend: added jsCode test cases

This commit is contained in:
Alexey Tsvetkov
2014-12-09 13:46:01 +03:00
parent 97bbcab77d
commit c3f67c54bd
32 changed files with 657 additions and 0 deletions
@@ -0,0 +1,59 @@
package foo
fun testLabelledBlock() {
var c: Int = 0
js("""
block: {
c = 1;
break block;
c = 2;
}
""")
assertEquals(1, c, "testLabelledBlock")
}
fun testBreakInFor() {
var c: Int = 0
js("""
outer: for (var i = 0; i < 10; i++) {
for (var j = 0; j < 10; j++) {
if (i === 1) {
break outer;
}
c += 1;
}
}
""")
assertEquals(10, c, "testBreakInFor")
}
fun testContinueInFor() {
var c: Int = 0
js("""
outer: for (var i = 0; i < 10; i++) {
for (var j = 0; j < 10; j++) {
if (i >= 1) {
continue outer;
}
c += 1;
}
}
""")
assertEquals(10, c, "testContinueInFor")
}
fun box(): String {
testLabelledBlock()
testBreakInFor()
testContinueInFor()
return "OK"
}