LoadCompiledKotlinCustomTest -> LoadKotlinCustomTest.
The test itself is enhanced so it loads descriptors from source and from binaries. Test data changed according to latest frontend changes.
This commit is contained in:
+6
-6
@@ -1,33 +1,33 @@
|
||||
namespace test
|
||||
|
||||
internal final enum class test.In : jet.Enum<test.In> {
|
||||
public final /*constructor*/ fun <init>(/*0*/ p0: jet.String?, /*1*/ p1: jet.Int): test.In
|
||||
protected final /*constructor*/ fun <init>(/*0*/ p0: jet.String?, /*1*/ p1: jet.Int): test.In
|
||||
public final override /*1*/ fun name(): jet.String
|
||||
public final override /*1*/ fun ordinal(): jet.Int
|
||||
internal final class object test.In.<class-object-for-In> {
|
||||
public final /*constructor*/ fun <init>(): test.In.<class-object-for-In>
|
||||
private final /*constructor*/ fun <init>(): test.In.<class-object-for-In>
|
||||
public final val A: test.In
|
||||
public final fun valueOf(/*0*/ value: jet.String): test.In
|
||||
public final fun values(): jet.Array<test.In>
|
||||
}
|
||||
}
|
||||
private final enum class test.Pr : jet.Enum<test.Pr> {
|
||||
public final /*constructor*/ fun <init>(/*0*/ p0: jet.String?, /*1*/ p1: jet.Int): test.Pr
|
||||
protected final /*constructor*/ fun <init>(/*0*/ p0: jet.String?, /*1*/ p1: jet.Int): test.Pr
|
||||
public final override /*1*/ fun name(): jet.String
|
||||
public final override /*1*/ fun ordinal(): jet.Int
|
||||
private final class object test.Pr.<class-object-for-Pr> {
|
||||
public final /*constructor*/ fun <init>(): test.Pr.<class-object-for-Pr>
|
||||
private final /*constructor*/ fun <init>(): test.Pr.<class-object-for-Pr>
|
||||
public final val A: test.Pr
|
||||
public final fun valueOf(/*0*/ value: jet.String): test.Pr
|
||||
public final fun values(): jet.Array<test.Pr>
|
||||
}
|
||||
}
|
||||
public final enum class test.Pu : jet.Enum<test.Pu> {
|
||||
public final /*constructor*/ fun <init>(/*0*/ p0: jet.String?, /*1*/ p1: jet.Int): test.Pu
|
||||
protected final /*constructor*/ fun <init>(/*0*/ p0: jet.String?, /*1*/ p1: jet.Int): test.Pu
|
||||
public final override /*1*/ fun name(): jet.String
|
||||
public final override /*1*/ fun ordinal(): jet.Int
|
||||
public final class object test.Pu.<class-object-for-Pu> {
|
||||
public final /*constructor*/ fun <init>(): test.Pu.<class-object-for-Pu>
|
||||
private final /*constructor*/ fun <init>(): test.Pu.<class-object-for-Pu>
|
||||
public final val A: test.Pu
|
||||
public final fun valueOf(/*0*/ value: jet.String): test.Pu
|
||||
public final fun values(): jet.Array<test.Pu>
|
||||
@@ -0,0 +1,50 @@
|
||||
namespace test
|
||||
|
||||
internal final enum class test.In : jet.Enum<test.In> {
|
||||
protected final /*constructor*/ fun <init>(): test.In
|
||||
public final override /*1*/ fun name(): jet.String
|
||||
public final override /*1*/ fun ordinal(): jet.Int
|
||||
internal final class object test.In.<class-object-for-In> {
|
||||
private final /*constructor*/ fun <init>(): test.In.<class-object-for-In>
|
||||
internal final val A: test.In.<class-object-for-In>.A
|
||||
internal final enum entry test.In.<class-object-for-In>.A : test.In {
|
||||
private final /*constructor*/ fun <init>(): test.In.<class-object-for-In>.A
|
||||
public final override /*1*/ fun name(): jet.String
|
||||
public final override /*1*/ fun ordinal(): jet.Int
|
||||
}
|
||||
public final fun valueOf(/*0*/ value: jet.String): test.In
|
||||
public final fun values(): jet.Array<test.In>
|
||||
}
|
||||
}
|
||||
private final enum class test.Pr : jet.Enum<test.Pr> {
|
||||
protected final /*constructor*/ fun <init>(): test.Pr
|
||||
public final override /*1*/ fun name(): jet.String
|
||||
public final override /*1*/ fun ordinal(): jet.Int
|
||||
private final class object test.Pr.<class-object-for-Pr> {
|
||||
private final /*constructor*/ fun <init>(): test.Pr.<class-object-for-Pr>
|
||||
internal final val A: test.Pr.<class-object-for-Pr>.A
|
||||
internal final enum entry test.Pr.<class-object-for-Pr>.A : test.Pr {
|
||||
private final /*constructor*/ fun <init>(): test.Pr.<class-object-for-Pr>.A
|
||||
public final override /*1*/ fun name(): jet.String
|
||||
public final override /*1*/ fun ordinal(): jet.Int
|
||||
}
|
||||
public final fun valueOf(/*0*/ value: jet.String): test.Pr
|
||||
public final fun values(): jet.Array<test.Pr>
|
||||
}
|
||||
}
|
||||
public final enum class test.Pu : jet.Enum<test.Pu> {
|
||||
protected final /*constructor*/ fun <init>(): test.Pu
|
||||
public final override /*1*/ fun name(): jet.String
|
||||
public final override /*1*/ fun ordinal(): jet.Int
|
||||
public final class object test.Pu.<class-object-for-Pu> {
|
||||
private final /*constructor*/ fun <init>(): test.Pu.<class-object-for-Pu>
|
||||
internal final val A: test.Pu.<class-object-for-Pu>.A
|
||||
internal final enum entry test.Pu.<class-object-for-Pu>.A : test.Pu {
|
||||
private final /*constructor*/ fun <init>(): test.Pu.<class-object-for-Pu>.A
|
||||
public final override /*1*/ fun name(): jet.String
|
||||
public final override /*1*/ fun ordinal(): jet.Int
|
||||
}
|
||||
public final fun valueOf(/*0*/ value: jet.String): test.Pu
|
||||
public final fun values(): jet.Array<test.Pu>
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,11 +1,11 @@
|
||||
namespace test
|
||||
|
||||
internal final enum class test.MyEnum : jet.Enum<test.MyEnum> {
|
||||
public final /*constructor*/ fun <init>(/*0*/ p0: jet.String?, /*1*/ p1: jet.Int): test.MyEnum
|
||||
protected final /*constructor*/ fun <init>(/*0*/ p0: jet.String?, /*1*/ p1: jet.Int): test.MyEnum
|
||||
public final override /*1*/ fun name(): jet.String
|
||||
public final override /*1*/ fun ordinal(): jet.Int
|
||||
internal final class object test.MyEnum.<class-object-for-MyEnum> {
|
||||
public final /*constructor*/ fun <init>(): test.MyEnum.<class-object-for-MyEnum>
|
||||
private final /*constructor*/ fun <init>(): test.MyEnum.<class-object-for-MyEnum>
|
||||
public final val ENTRY: test.MyEnum
|
||||
public final fun valueOf(/*0*/ value: jet.String): test.MyEnum
|
||||
public final fun values(): jet.Array<test.MyEnum>
|
||||
@@ -0,0 +1,18 @@
|
||||
namespace test
|
||||
|
||||
internal final enum class test.MyEnum : jet.Enum<test.MyEnum> {
|
||||
protected final /*constructor*/ fun <init>(): test.MyEnum
|
||||
public final override /*1*/ fun name(): jet.String
|
||||
public final override /*1*/ fun ordinal(): jet.Int
|
||||
internal final class object test.MyEnum.<class-object-for-MyEnum> {
|
||||
private final /*constructor*/ fun <init>(): test.MyEnum.<class-object-for-MyEnum>
|
||||
internal final val ENTRY: test.MyEnum.<class-object-for-MyEnum>.ENTRY
|
||||
internal final enum entry test.MyEnum.<class-object-for-MyEnum>.ENTRY : test.MyEnum {
|
||||
private final /*constructor*/ fun <init>(): test.MyEnum.<class-object-for-MyEnum>.ENTRY
|
||||
public final override /*1*/ fun name(): jet.String
|
||||
public final override /*1*/ fun ordinal(): jet.Int
|
||||
}
|
||||
public final fun valueOf(/*0*/ value: jet.String): test.MyEnum
|
||||
public final fun values(): jet.Array<test.MyEnum>
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.jvm.compiler;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
|
||||
import org.jetbrains.jet.test.TestCaseWithTmpdir;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import static org.jetbrains.jet.jvm.compiler.LoadDescriptorUtil.compileKotlinAndLoadTestNamespaceDescriptorFromBinary;
|
||||
import static org.jetbrains.jet.test.util.NamespaceComparator.DONT_INCLUDE_METHODS_OF_OBJECT;
|
||||
import static org.jetbrains.jet.test.util.NamespaceComparator.compareNamespaces;
|
||||
|
||||
/**
|
||||
* @author Pavel Talanov
|
||||
*/
|
||||
/*
|
||||
This test should be implemented via LoadCompiledKotlinTest.
|
||||
Atm it's not possible due to enums being loaded differently from binaries (in contrast to from sources).
|
||||
*/
|
||||
public final class LoadCompiledKotlinCustomTest extends TestCaseWithTmpdir {
|
||||
@NotNull
|
||||
private static final String PATH = "compiler/testData/loadKotlinCustom";
|
||||
|
||||
private void doTest(@NotNull String expectedFileName, @NotNull String kotlinFileName) throws Exception {
|
||||
NamespaceDescriptor namespaceFromClass =
|
||||
compileKotlinAndLoadTestNamespaceDescriptorFromBinary(new File(kotlinFileName), tmpdir, myTestRootDisposable);
|
||||
|
||||
compareNamespaces(namespaceFromClass, namespaceFromClass, DONT_INCLUDE_METHODS_OF_OBJECT, new File(expectedFileName));
|
||||
}
|
||||
|
||||
public void testSimpleEnum() throws Exception {
|
||||
String dir = PATH + "/enum";
|
||||
doTest(dir + "/simpleEnum.txt",
|
||||
dir + "/simpleEnum.kt");
|
||||
}
|
||||
|
||||
public void testEnumVisibility() throws Exception {
|
||||
String dir = PATH + "/enum";
|
||||
doTest(dir + "/enumVisibility.txt",
|
||||
dir + "/enumVisibility.kt");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright 2010-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.jvm.compiler;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.analyzer.AnalyzeExhaust;
|
||||
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.test.TestCaseWithTmpdir;
|
||||
import org.jetbrains.jet.test.util.NamespaceComparator;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import static org.jetbrains.jet.jvm.compiler.LoadDescriptorUtil.*;
|
||||
import static org.jetbrains.jet.test.util.NamespaceComparator.DONT_INCLUDE_METHODS_OF_OBJECT;
|
||||
import static org.jetbrains.jet.test.util.NamespaceComparator.compareNamespaces;
|
||||
|
||||
/**
|
||||
* @author Pavel Talanov
|
||||
*/
|
||||
/*
|
||||
* This test should be implemented via LoadCompiledKotlinTest.
|
||||
* Atm it's not possible due to enums being loaded differently from binaries (in contrast to from sources).
|
||||
*/
|
||||
public final class LoadKotlinCustomTest extends TestCaseWithTmpdir {
|
||||
@NotNull
|
||||
private static final String PATH = "compiler/testData/loadKotlinCustom";
|
||||
@NotNull
|
||||
private static final String ENUM_DIR = PATH + "/enum";
|
||||
|
||||
private void loadDescriptorsFromCompiledAndCompareWithTxt(@NotNull File expectedFile, @NotNull File kotlinFile)
|
||||
throws Exception {
|
||||
NamespaceDescriptor namespaceFromClass =
|
||||
compileKotlinAndLoadTestNamespaceDescriptorFromBinary(kotlinFile, tmpdir, myTestRootDisposable);
|
||||
|
||||
compareNamespaces(namespaceFromClass, namespaceFromClass, DONT_INCLUDE_METHODS_OF_OBJECT, expectedFile);
|
||||
}
|
||||
|
||||
private void loadDescriptorsFromSourceAndCompareWithTxt(@NotNull File expectedFile, @NotNull File kotlinFile)
|
||||
throws Exception {
|
||||
AnalyzeExhaust exhaust = compileKotlinToDirAndGetAnalyzeExhaust(kotlinFile, tmpdir, getTestRootDisposable());
|
||||
NamespaceDescriptor namespaceFromSource = exhaust.getBindingContext().get(BindingContext.FQNAME_TO_NAMESPACE_DESCRIPTOR,
|
||||
TEST_PACKAGE_FQNAME);
|
||||
assert namespaceFromSource != null;
|
||||
compareNamespaces(namespaceFromSource, namespaceFromSource, NamespaceComparator.DONT_INCLUDE_METHODS_OF_OBJECT,
|
||||
expectedFile);
|
||||
}
|
||||
|
||||
private void doTest(
|
||||
@NotNull String expectedSourceDescriptors,
|
||||
@NotNull String expectedBinaryDescriptors,
|
||||
@NotNull String kotlinFileName
|
||||
) throws Exception {
|
||||
loadDescriptorsFromSourceAndCompareWithTxt(new File(expectedSourceDescriptors), new File(kotlinFileName));
|
||||
loadDescriptorsFromCompiledAndCompareWithTxt(new File(expectedBinaryDescriptors), new File(kotlinFileName));
|
||||
}
|
||||
|
||||
private void doTest(@NotNull String dir) throws Exception {
|
||||
String name = getTestName(true);
|
||||
doTest(dir + "/" + name + "Source.txt",
|
||||
dir + "/" + name + "Binary.txt",
|
||||
dir + "/" + name + ".kt");
|
||||
}
|
||||
|
||||
public void testSimpleEnum() throws Exception {
|
||||
doTest(ENUM_DIR);
|
||||
}
|
||||
|
||||
public void testEnumVisibility() throws Exception {
|
||||
doTest(PATH + "/enum");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user