Added corner case test for int range iteration.
This commit is contained in:
+21
@@ -0,0 +1,21 @@
|
||||
fun Int.component1(): String {
|
||||
return arrayListOf("zero", "one", "two", "three")[this]
|
||||
}
|
||||
|
||||
fun Int.component2(): Int {
|
||||
return arrayListOf(0, 1, 4, 9)[this]
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val strings = arrayListOf<String>()
|
||||
val squares = arrayListOf<Int>()
|
||||
|
||||
for ((str, sq) in 1..3) {
|
||||
strings.add(str)
|
||||
squares.add(sq)
|
||||
}
|
||||
|
||||
if (strings != arrayListOf("one", "two", "three")) return "FAIL: $strings"
|
||||
if (squares != arrayListOf(1, 4, 9)) return "FAIL: $squares"
|
||||
return "OK"
|
||||
}
|
||||
+5
@@ -390,6 +390,11 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/codegen/boxWithStdlib/ranges"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("multiAssignmentIterationOverIntRange.kt")
|
||||
public void testMultiAssignmentIterationOverIntRange() throws Exception {
|
||||
doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/ranges/multiAssignmentIterationOverIntRange.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/boxWithStdlib/ranges/expression")
|
||||
public static class Expression extends AbstractBlackBoxCodegenTest {
|
||||
public void testAllFilesPresentInExpression() throws Exception {
|
||||
|
||||
@@ -111,7 +111,8 @@ public class GenerateRangesCodegenTestData {
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
FileUtil.delete(TEST_DATA_DIR);
|
||||
FileUtil.delete(AS_LITERAL_DIR);
|
||||
FileUtil.delete(AS_EXPRESSION_DIR);
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
AS_LITERAL_DIR.mkdirs();
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
|
||||
Reference in New Issue
Block a user