JS: fix translation of augmented assignment when RHS changes value of LHS

This commit is contained in:
Alexey Andreev
2016-11-21 18:47:09 +03:00
parent be196789d2
commit 40e00a62f5
7 changed files with 77 additions and 13 deletions
@@ -1,9 +1,6 @@
// WITH_RUNTIME
// NO_INTERCEPT_RESUME_TESTS
// TODO: fix bug in JVM backend and remove this directive
// TARGET_BACKEND: JS
class Controller {
var result = ""
@@ -29,7 +26,7 @@ fun box(): String {
}
}
}
if (value != "A;[B][C]!") return "fail: suspend as if condition: $value"
if (value != "A;B]C]!") return "fail: suspend as if condition: $value"
return "OK"
}
@@ -0,0 +1,23 @@
// WITH_RUNTIME
import kotlin.test.*
var log = ""
var result = 20
fun <T> id(value: T) = value
fun box(): String {
result += if (id("true") == "true") {
result += 10
log += "true chosen"
3
}
else {
4
}
assertEquals(23, result)
assertEquals("true chosen", log)
return "OK"
}
@@ -4768,6 +4768,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
doTest(fileName);
}
@TestMetadata("switchLikeWhen.kt")
public void testSwitchLikeWhen() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/controlFlow/switchLikeWhen.kt");
doTest(fileName);
}
@TestMetadata("throwFromCatch.kt")
public void testThrowFromCatch() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/controlFlow/throwFromCatch.kt");
@@ -7679,6 +7685,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
doTest(fileName);
}
@TestMetadata("augmentedAssignmentWithComplexRhs.kt")
public void testAugmentedAssignmentWithComplexRhs() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/increment/augmentedAssignmentWithComplexRhs.kt");
doTest(fileName);
}
@TestMetadata("classNaryGetSet.kt")
public void testClassNaryGetSet() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/increment/classNaryGetSet.kt");
@@ -4768,6 +4768,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
doTest(fileName);
}
@TestMetadata("switchLikeWhen.kt")
public void testSwitchLikeWhen() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/controlFlow/switchLikeWhen.kt");
doTest(fileName);
}
@TestMetadata("throwFromCatch.kt")
public void testThrowFromCatch() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/controlFlow/throwFromCatch.kt");
@@ -7679,6 +7685,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
doTest(fileName);
}
@TestMetadata("augmentedAssignmentWithComplexRhs.kt")
public void testAugmentedAssignmentWithComplexRhs() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/increment/augmentedAssignmentWithComplexRhs.kt");
doTest(fileName);
}
@TestMetadata("classNaryGetSet.kt")
public void testClassNaryGetSet() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/increment/classNaryGetSet.kt");