Ensure that BranchedValue for in/!in work well with boolean operations

This commit is contained in:
Dmitry Petrov
2017-06-30 15:58:34 +03:00
parent a3cd4f415a
commit 7175361c97
5 changed files with 51 additions and 0 deletions
@@ -0,0 +1,27 @@
// WITH_RUNTIME
val i1 = 1
val i2 = 2
val i3 = 3
fun box(): String {
if (!(i2 in i1 .. i3 && i1 !in i2 .. i3)) return "Fail 1 &&"
if (!(i2 in i1 .. i3 || i1 !in i2 .. i3)) return "Fail 1 ||"
// const-folded in JVM BE
if (!(2 in 1 .. 3 && 1 !in 2 .. 3)) return "Fail 2 &&"
if (!(2 in 1 .. 3 || 1 !in 2 .. 3)) return "Fail 2 ||"
val xs = listOf(1, 2, 3)
if (!(1 in xs && 10 !in xs)) return "Fail 3 &&"
if (!(1 in xs || 10 !in xs)) return "Fail 3 ||"
val iarr = intArrayOf(1, 2, 3)
if (!(1 in iarr && 10 !in iarr)) return "Fail 4 &&"
if (!(1 in iarr || 10 !in iarr)) return "Fail 4 ||"
if (!("b" in "a" .. "c" && "a" !in "b" .. "c")) return "Fail 5 &&"
if (!("b" in "a" .. "c" || "a" !in "b" .. "c")) return "Fail 5 ||"
return "OK"
}
@@ -13255,6 +13255,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
doTest(fileName);
}
@TestMetadata("inRangeLiteralComposition.kt")
public void testInRangeLiteralComposition() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/contains/inRangeLiteralComposition.kt");
doTest(fileName);
}
@TestMetadata("inRangeOfComparable.kt")
public void testInRangeOfComparable() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/contains/inRangeOfComparable.kt");
@@ -13255,6 +13255,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
doTest(fileName);
}
@TestMetadata("inRangeLiteralComposition.kt")
public void testInRangeLiteralComposition() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/contains/inRangeLiteralComposition.kt");
doTest(fileName);
}
@TestMetadata("inRangeOfComparable.kt")
public void testInRangeOfComparable() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/contains/inRangeOfComparable.kt");
@@ -13255,6 +13255,12 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
doTest(fileName);
}
@TestMetadata("inRangeLiteralComposition.kt")
public void testInRangeLiteralComposition() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/contains/inRangeLiteralComposition.kt");
doTest(fileName);
}
@TestMetadata("inRangeOfComparable.kt")
public void testInRangeOfComparable() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/contains/inRangeOfComparable.kt");
@@ -14911,6 +14911,12 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
doTest(fileName);
}
@TestMetadata("inRangeLiteralComposition.kt")
public void testInRangeLiteralComposition() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/contains/inRangeLiteralComposition.kt");
doTest(fileName);
}
@TestMetadata("inRangeOfComparable.kt")
public void testInRangeOfComparable() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/contains/inRangeOfComparable.kt");