Tests for annotation deserialization when platform names are used

This commit is contained in:
Andrey Breslav
2014-06-10 18:15:46 +04:00
parent 705a081919
commit fe09bd4fd8
5 changed files with 71 additions and 3 deletions
@@ -0,0 +1,18 @@
package test
import kotlin.platform.*
annotation class A(val s: String)
[platformName("bar")]
A("1")
fun foo() = "foo"
A("2")
var v: Int = 1
[platformName("vget")]
[A("3")]
get
[platformName("vset")]
[A("4")]
set
@@ -0,0 +1,12 @@
package test
test.A(s = "2": kotlin.String) internal var v: kotlin.Int
kotlin.platform.platformName(name = "vget": kotlin.String) test.A(s = "3": kotlin.String) internal fun <get-v>(): kotlin.Int
kotlin.platform.platformName(name = "vset": kotlin.String) test.A(s = "4": kotlin.String) internal fun <set-v>(/*0*/ <set-?>: kotlin.Int): kotlin.Unit
test.A(s = "1": kotlin.String) kotlin.platform.platformName(name = "bar": kotlin.String) internal fun foo(): kotlin.String
internal final annotation class A : kotlin.Annotation {
/*primary*/ public constructor A(/*0*/ s: kotlin.String)
internal final val s: kotlin.String
internal final fun <get-s>(): kotlin.String
}
@@ -101,17 +101,25 @@ public abstract class AbstractLoadJavaTest extends TestCaseWithTmpdir {
}
protected void doTestCompiledKotlin(@NotNull String ktFileName) throws Exception {
doTestCompiledKotlin(ktFileName, ConfigurationKind.JDK_ONLY);
}
protected void doTestCompiledKotlinWithStdlib(@NotNull String ktFileName) throws Exception {
doTestCompiledKotlin(ktFileName, ConfigurationKind.ALL);
}
protected void doTestCompiledKotlin(@NotNull String ktFileName, @NotNull ConfigurationKind configurationKind) throws Exception {
File ktFile = new File(ktFileName);
File txtFile = new File(ktFileName.replaceFirst("\\.kt$", ".txt"));
AnalyzeExhaust exhaust = compileKotlinToDirAndGetAnalyzeExhaust(Collections.singletonList(ktFile), tmpdir, getTestRootDisposable(),
ConfigurationKind.JDK_ONLY);
configurationKind);
PackageViewDescriptor packageFromSource = exhaust.getModuleDescriptor().getPackage(TEST_PACKAGE_FQNAME);
assert packageFromSource != null;
junit.framework.Assert.assertEquals("test", packageFromSource.getName().asString());
PackageViewDescriptor packageFromBinary = LoadDescriptorUtil.loadTestPackageAndBindingContextFromJavaRoot(
tmpdir, getTestRootDisposable(), ConfigurationKind.JDK_ONLY).first;
tmpdir, getTestRootDisposable(), configurationKind).first;
for (DeclarationDescriptor descriptor : packageFromBinary.getMemberScope().getAllDescriptors()) {
if (descriptor instanceof ClassDescriptor) {
@@ -30,7 +30,7 @@ import org.jetbrains.jet.jvm.compiler.AbstractLoadJavaTest;
/** This class is generated by {@link org.jetbrains.jet.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@InnerTestClasses({LoadJavaTestGenerated.CompiledJava.class, LoadJavaTestGenerated.CompiledJavaAndKotlin.class, LoadJavaTestGenerated.CompiledJavaCompareWithKotlin.class, LoadJavaTestGenerated.CompiledJavaIncludeObjectMethods.class, LoadJavaTestGenerated.CompiledKotlin.class, LoadJavaTestGenerated.JavaAgainstKotlin.class, LoadJavaTestGenerated.KotlinAgainstCompiledJavaWithKotlin.class, LoadJavaTestGenerated.SourceJava.class})
@InnerTestClasses({LoadJavaTestGenerated.CompiledJava.class, LoadJavaTestGenerated.CompiledJavaAndKotlin.class, LoadJavaTestGenerated.CompiledJavaCompareWithKotlin.class, LoadJavaTestGenerated.CompiledJavaIncludeObjectMethods.class, LoadJavaTestGenerated.CompiledKotlin.class, LoadJavaTestGenerated.CompiledKotlinWithStdlib.class, LoadJavaTestGenerated.JavaAgainstKotlin.class, LoadJavaTestGenerated.KotlinAgainstCompiledJavaWithKotlin.class, LoadJavaTestGenerated.SourceJava.class})
public class LoadJavaTestGenerated extends AbstractLoadJavaTest {
@TestMetadata("compiler/testData/loadJava/compiledJava")
@InnerTestClasses({CompiledJava.Annotations.class, CompiledJava.ProtectedPackage.class, CompiledJava.ProtectedStatic.class, CompiledJava.Sam.class, CompiledJava.SignaturePropagation.class, CompiledJava.Static.class})
@@ -3014,6 +3014,34 @@ public class LoadJavaTestGenerated extends AbstractLoadJavaTest {
}
}
@TestMetadata("compiler/testData/loadJava/compiledKotlinWithStdlib")
@InnerTestClasses({CompiledKotlinWithStdlib.PlatformNames.class})
public static class CompiledKotlinWithStdlib extends AbstractLoadJavaTest {
public void testAllFilesPresentInCompiledKotlinWithStdlib() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/loadJava/compiledKotlinWithStdlib"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("compiler/testData/loadJava/compiledKotlinWithStdlib/platformNames")
public static class PlatformNames extends AbstractLoadJavaTest {
public void testAllFilesPresentInPlatformNames() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/loadJava/compiledKotlinWithStdlib/platformNames"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("functionName.kt")
public void testFunctionName() throws Exception {
doTestCompiledKotlinWithStdlib("compiler/testData/loadJava/compiledKotlinWithStdlib/platformNames/functionName.kt");
}
}
public static Test innerSuite() {
TestSuite suite = new TestSuite("CompiledKotlinWithStdlib");
suite.addTestSuite(CompiledKotlinWithStdlib.class);
suite.addTestSuite(PlatformNames.class);
return suite;
}
}
@TestMetadata("compiler/testData/loadJava/javaAgainstKotlin")
@InnerTestClasses({JavaAgainstKotlin.SamAdapters.class, JavaAgainstKotlin.SignaturePropagation.class, JavaAgainstKotlin.Visibility.class})
public static class JavaAgainstKotlin extends AbstractLoadJavaTest {
@@ -3201,6 +3229,7 @@ public class LoadJavaTestGenerated extends AbstractLoadJavaTest {
suite.addTest(CompiledJavaCompareWithKotlin.innerSuite());
suite.addTestSuite(CompiledJavaIncludeObjectMethods.class);
suite.addTest(CompiledKotlin.innerSuite());
suite.addTest(CompiledKotlinWithStdlib.innerSuite());
suite.addTest(JavaAgainstKotlin.innerSuite());
suite.addTestSuite(KotlinAgainstCompiledJavaWithKotlin.class);
suite.addTestSuite(SourceJava.class);
@@ -199,6 +199,7 @@ fun main(args: Array<String>) {
model("loadJava/compiledJavaCompareWithKotlin", extension = "java", testMethod = "doTestCompiledJavaCompareWithKotlin")
model("loadJava/compiledJavaIncludeObjectMethods", extension = "java", testMethod = "doTestCompiledJavaIncludeObjectMethods")
model("loadJava/compiledKotlin", testMethod = "doTestCompiledKotlin")
model("loadJava/compiledKotlinWithStdlib", testMethod = "doTestCompiledKotlinWithStdlib")
model("loadJava/javaAgainstKotlin", extension = "txt", testMethod = "doTestJavaAgainstKotlin")
model("loadJava/kotlinAgainstCompiledJavaWithKotlin", extension = "kt", testMethod = "doTestKotlinAgainstCompiledJavaWithKotlin", recursive = false)
model("loadJava/sourceJava", extension = "java", testMethod = "doTestSourceJava")