When2Switch: tests for non-literal expression in when by integral
This commit is contained in:
committed by
Evgeny Gerashchenko
parent
8d8c3d2b9e
commit
18cb479ef3
@@ -0,0 +1,23 @@
|
||||
fun foo1(x: Int): Boolean {
|
||||
when(x) {
|
||||
2 + 2 -> return true
|
||||
else -> return false
|
||||
}
|
||||
}
|
||||
|
||||
fun foo2(x: Int): Boolean {
|
||||
when(x) {
|
||||
Integer.MAX_VALUE -> return true
|
||||
else -> return false
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
assert(foo1(4))
|
||||
assert(!foo1(1))
|
||||
|
||||
assert(foo2(Integer.MAX_VALUE))
|
||||
assert(!foo2(1))
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
fun foo1(x: Int): Boolean {
|
||||
when(x) {
|
||||
2 + 2 -> return true
|
||||
else -> return false
|
||||
}
|
||||
}
|
||||
|
||||
fun foo2(x: Int): Boolean {
|
||||
when(x) {
|
||||
Integer.MAX_VALUE -> return true
|
||||
else -> return false
|
||||
}
|
||||
}
|
||||
|
||||
// 0 TABLESWITCH
|
||||
// 2 LOOKUPSWITCH
|
||||
@@ -31,7 +31,7 @@ import org.jetbrains.jet.codegen.AbstractBytecodeTextTest;
|
||||
/** This class is generated by {@link org.jetbrains.jet.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
|
||||
@SuppressWarnings("all")
|
||||
@TestMetadata("compiler/testData/codegen/bytecodeText")
|
||||
@InnerTestClasses({BytecodeTextTestGenerated.BoxingOptimization.class, BytecodeTextTestGenerated.Constants.class, BytecodeTextTestGenerated.DirectInvoke.class, BytecodeTextTestGenerated.Statements.class, BytecodeTextTestGenerated.WhenEnumOptimization.class, BytecodeTextTestGenerated.WhenStringOptimization.class})
|
||||
@InnerTestClasses({BytecodeTextTestGenerated.BoxingOptimization.class, BytecodeTextTestGenerated.Constants.class, BytecodeTextTestGenerated.DirectInvoke.class, BytecodeTextTestGenerated.Statements.class, BytecodeTextTestGenerated.When.class, BytecodeTextTestGenerated.WhenEnumOptimization.class, BytecodeTextTestGenerated.WhenStringOptimization.class})
|
||||
public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest {
|
||||
@TestMetadata("accessorForProtected.kt")
|
||||
public void testAccessorForProtected() throws Exception {
|
||||
@@ -304,6 +304,19 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest {
|
||||
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/bytecodeText/when")
|
||||
public static class When extends AbstractBytecodeTextTest {
|
||||
public void testAllFilesPresentInWhen() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/codegen/bytecodeText/when"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("integralWhenWithNoInlinedConstants.kt")
|
||||
public void testIntegralWhenWithNoInlinedConstants() throws Exception {
|
||||
doTest("compiler/testData/codegen/bytecodeText/when/integralWhenWithNoInlinedConstants.kt");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/bytecodeText/whenEnumOptimization")
|
||||
public static class WhenEnumOptimization extends AbstractBytecodeTextTest {
|
||||
public void testAllFilesPresentInWhenEnumOptimization() throws Exception {
|
||||
@@ -412,6 +425,7 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest {
|
||||
suite.addTestSuite(Constants.class);
|
||||
suite.addTestSuite(DirectInvoke.class);
|
||||
suite.addTestSuite(Statements.class);
|
||||
suite.addTestSuite(When.class);
|
||||
suite.addTestSuite(WhenEnumOptimization.class);
|
||||
suite.addTestSuite(WhenStringOptimization.class);
|
||||
return suite;
|
||||
|
||||
+5
@@ -1920,6 +1920,11 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/codegen/boxWithStdlib/when"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("integralWhenWithNoInlinedConstants.kt")
|
||||
public void testIntegralWhenWithNoInlinedConstants() throws Exception {
|
||||
doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/when/integralWhenWithNoInlinedConstants.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("switchOptimizationDense.kt")
|
||||
public void testSwitchOptimizationDense() throws Exception {
|
||||
doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/when/switchOptimizationDense.kt");
|
||||
|
||||
Reference in New Issue
Block a user