Inline iterator test

This commit is contained in:
Michael Bogdanov
2015-03-13 14:39:35 +03:00
parent 596c5b8d41
commit 0999cd99e3
6 changed files with 105 additions and 0 deletions
@@ -0,0 +1,21 @@
import zzz.*
fun box(): String {
var (p, l) = A(1, 11)
return if (p == 1 && l == 11) "OK" else "fail: $p"
}
//SMAP
//inlineComponent.1.kt
//Kotlin
//*S Kotlin
//*F
//+ 1 inlineComponent.1.kt
//_DefaultPackage
//+ 2 inlineComponent.2.kt
//zzz/ZzzPackage
//*L
//1#1,21:1
//5#2,3:22
//*E
@@ -0,0 +1,9 @@
package zzz
public class A(val a: Int, val b: Int)
inline fun A.component1() = a
inline fun A.component2() = b
//SMAP ABSENT
@@ -0,0 +1,24 @@
import zzz.*
fun box(): String {
var p = 0
for (i in A(5)) {
p += i
}
return if (p == 15) "OK" else "fail: $p"
}
//SMAP
//inlineIterator.1.kt
//Kotlin
//*S Kotlin
//*F
//+ 1 inlineIterator.1.kt
//_DefaultPackage
//+ 2 inlineIterator.2.kt
//zzz/ZzzPackage
//*L
//1#1,24:1
//5#2:25
//*E
@@ -0,0 +1,7 @@
package zzz
public class A(val p: Int)
inline fun A.iterator() = (1..p).iterator()
//SMAP ABSENT
@@ -742,6 +742,7 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo
@TestDataPath("$PROJECT_ROOT")
@InnerTestClasses({
Smap.Anonymous.class,
Smap.Resolve.class,
})
@RunWith(JUnit3RunnerWithInners.class)
public static class Smap extends AbstractBlackBoxInlineCodegenTest {
@@ -823,6 +824,27 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo
doTestMultiFileWithInlineCheck(fileName);
}
}
@TestMetadata("compiler/testData/codegen/boxInline/smap/resolve")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Resolve extends AbstractBlackBoxInlineCodegenTest {
public void testAllFilesPresentInResolve() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxInline/smap/resolve"), Pattern.compile("^(.+)\\.1.kt$"), true);
}
@TestMetadata("inlineComponent.1.kt")
public void testInlineComponent() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/smap/resolve/inlineComponent.1.kt");
doTestMultiFileWithInlineCheck(fileName);
}
@TestMetadata("inlineIterator.1.kt")
public void testInlineIterator() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/smap/resolve/inlineIterator.1.kt");
doTestMultiFileWithInlineCheck(fileName);
}
}
}
@TestMetadata("compiler/testData/codegen/boxInline/special")
@@ -742,6 +742,7 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi
@TestDataPath("$PROJECT_ROOT")
@InnerTestClasses({
Smap.Anonymous.class,
Smap.Resolve.class,
})
@RunWith(JUnit3RunnerWithInners.class)
public static class Smap extends AbstractCompileKotlinAgainstInlineKotlinTest {
@@ -823,6 +824,27 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi
doBoxTestWithInlineCheck(fileName);
}
}
@TestMetadata("compiler/testData/codegen/boxInline/smap/resolve")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Resolve extends AbstractCompileKotlinAgainstInlineKotlinTest {
public void testAllFilesPresentInResolve() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxInline/smap/resolve"), Pattern.compile("^(.+)\\.1.kt$"), true);
}
@TestMetadata("inlineComponent.1.kt")
public void testInlineComponent() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/smap/resolve/inlineComponent.1.kt");
doBoxTestWithInlineCheck(fileName);
}
@TestMetadata("inlineIterator.1.kt")
public void testInlineIterator() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/smap/resolve/inlineIterator.1.kt");
doBoxTestWithInlineCheck(fileName);
}
}
}
@TestMetadata("compiler/testData/codegen/boxInline/special")