JS backend: test for KT-4225: Compiler to JavaScript produces semantically wrong code

This issue was fixed in build 0.8.541
This commit is contained in:
Michael Nedzelsky
2014-08-27 13:34:34 +04:00
parent 0e41411c75
commit f5963ebfe9
2 changed files with 40 additions and 0 deletions
@@ -116,4 +116,9 @@ public class EvaluationOrderTest extends AbstractExpressionTest {
public void testWhenJsLiteralWithSideEffect() throws Exception {
checkFooBoxIsOk();
}
public void testLiteralFunctionAsArgumentWithSideEffect() throws Exception {
checkFooBoxIsOk();
}
}
@@ -0,0 +1,35 @@
// http://youtrack.jetbrains.com/issue/KT-4225
// Compiler to JavaScript produces semantically wrong code
package foo
var i = 0
var j = 0
var global: String = ""
fun incI(){
i++
}
fun incJ(a: Any){
j++
}
fun foo(f: () -> Unit) = f
fun box(): String {
val bar = 1
val f = foo {
incI()
incJ(if (bar == 2) "A" else "B")
}
global +="i = $i, j = $j"
f()
global +=" : i = $i, j = $j"
assertEquals("i = 0, j = 0 : i = 1, j = 1", global)
return "OK"
}