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:
@@ -116,4 +116,9 @@ public class EvaluationOrderTest extends AbstractExpressionTest {
|
|||||||
public void testWhenJsLiteralWithSideEffect() throws Exception {
|
public void testWhenJsLiteralWithSideEffect() throws Exception {
|
||||||
checkFooBoxIsOk();
|
checkFooBoxIsOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testLiteralFunctionAsArgumentWithSideEffect() throws Exception {
|
||||||
|
checkFooBoxIsOk();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+35
@@ -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"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user