Re-using test data from readKotlinBinaryClass
This commit is contained in:
+34
-2
@@ -20,14 +20,17 @@ import com.google.common.base.Predicates;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.util.Function;
|
||||
import org.jetbrains.jet.CompileCompilerDependenciesTest;
|
||||
import org.jetbrains.jet.JetTestUtils;
|
||||
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment;
|
||||
import org.jetbrains.jet.cli.jvm.compiler.NamespaceComparator;
|
||||
import org.jetbrains.jet.di.InjectorForTopDownAnalyzerForJvm;
|
||||
import org.jetbrains.jet.lang.descriptors.ModuleDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.psi.JetPsiFactory;
|
||||
import org.jetbrains.jet.lang.resolve.AnalyzerScriptParameter;
|
||||
@@ -69,7 +72,7 @@ public abstract class AbstractLazyResolveComparingTest {
|
||||
Disposer.dispose(rootDisposable);
|
||||
}
|
||||
|
||||
protected void doTest(String testFileName) throws IOException {
|
||||
protected void doTest(String testFileName, Function<Pair<ModuleDescriptor, ModuleDescriptor>, Pair<NamespaceDescriptor, NamespaceDescriptor>> transform) throws IOException {
|
||||
TopDownAnalysisParameters params = new TopDownAnalysisParameters(
|
||||
Predicates.<PsiFile>alwaysTrue(), false, false, Collections.<AnalyzerScriptParameter>emptyList());
|
||||
ModuleDescriptor module = new ModuleDescriptor(Name.special("<test module>"));
|
||||
@@ -91,7 +94,36 @@ public abstract class AbstractLazyResolveComparingTest {
|
||||
|
||||
ResolveSession session = new ResolveSession(project, lazyModule, new FileBasedDeclarationProviderFactory(files));
|
||||
|
||||
NamespaceComparator.compareNamespaces(module.getRootNamespace(), lazyModule.getRootNamespace(), true,
|
||||
Pair<NamespaceDescriptor, NamespaceDescriptor> namespacesToCompare = transform.fun(Pair.create(module, lazyModule));
|
||||
|
||||
NamespaceComparator.compareNamespaces(namespacesToCompare.first, namespacesToCompare.second,
|
||||
true,
|
||||
new File(FileUtil.getNameWithoutExtension(testFileName) + ".txt"));
|
||||
}
|
||||
|
||||
protected void doTest(String testFileName) throws Exception {
|
||||
doTest(testFileName, new Function<Pair<ModuleDescriptor, ModuleDescriptor>, Pair<NamespaceDescriptor, NamespaceDescriptor>>() {
|
||||
@Override
|
||||
public Pair<NamespaceDescriptor, NamespaceDescriptor> fun(Pair<ModuleDescriptor, ModuleDescriptor> pair) {
|
||||
return Pair.create(pair.first.getRootNamespace(), pair.second.getRootNamespace());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected void doTestSinglePackage(String testFileName) throws Exception {
|
||||
doTest(testFileName, new Function<Pair<ModuleDescriptor, ModuleDescriptor>, Pair<NamespaceDescriptor, NamespaceDescriptor>>() {
|
||||
@Override
|
||||
public Pair<NamespaceDescriptor, NamespaceDescriptor> fun(Pair<ModuleDescriptor, ModuleDescriptor> pair) {
|
||||
ModuleDescriptor expectedModule = pair.first;
|
||||
ModuleDescriptor actualModule = pair.second;
|
||||
NamespaceDescriptor actual = theOnlySubPackage(actualModule.getRootNamespace());
|
||||
NamespaceDescriptor expected = expectedModule.getRootNamespace().getMemberScope().getNamespace(actual.getName());
|
||||
return Pair.create(expected, actual);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private NamespaceDescriptor theOnlySubPackage(NamespaceDescriptor namespace) {
|
||||
return (NamespaceDescriptor) namespace.getMemberScope().getAllDescriptors().iterator().next();
|
||||
}
|
||||
}
|
||||
|
||||
+627
-3
@@ -26,6 +26,631 @@ import java.util.Set;
|
||||
|
||||
/* This class is generated by LazyResolveComparingTestGenerator. DO NOT MODIFY MANUALLY */
|
||||
public class LazyResolveComparingTestGenerated extends AbstractLazyResolveComparingTest {
|
||||
@Test
|
||||
public void testClass() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/class/Class.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClassInnerClass() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/class/ClassInnerClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClassInParam() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/class/ClassInParam.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClassOutParam() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/class/ClassOutParam.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClassParam() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/class/ClassParam.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClassParamReferencesParam() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/class/ClassParamReferencesParam.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClassParamReferencesParam2() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/class/ClassParamReferencesParam2.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClassParamReferencesSelf() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/class/ClassParamReferencesSelf.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClassParamUpperClassBound() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/class/ClassParamUpperClassBound.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClassParamUpperClassInterfaceBound() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/class/ClassParamUpperClassInterfaceBound.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClassParamUpperInterfaceBound() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/class/ClassParamUpperInterfaceBound.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClassParamUpperInterfaceClassBound() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/class/ClassParamUpperInterfaceClassBound.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClassTwoParams() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/class/ClassTwoParams.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClassTwoParams2() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/class/ClassTwoParams2.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInheritClassSimple() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/class/InheritClassSimple.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInheritClassWithParam() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/class/InheritClassWithParam.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInheritTraitWithParam() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/class/InheritTraitWithParam.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInnerClass() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/class/InnerClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInnerClassExtendInnerClass() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/class/InnerClassExtendInnerClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTrait() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/class/Trait.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClassInParamUsedInFun() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/classFun/ClassInParamUsedInFun.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClassParamUsedInFun() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/classFun/ClassParamUsedInFun.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFunInParamSuper() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/classFun/FunInParamSuper.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClassObjectDeclaresVal() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/classObject/ClassObjectDeclaresVal.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClassObjectDeclaresVar() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/classObject/ClassObjectDeclaresVar.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClassObjectExtendsTrait() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/classObject/ClassObjectExtendsTrait.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClassObjectExtendsTraitWithTP() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/classObject/ClassObjectExtendsTraitWithTP.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSimpleClassObject() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/classObject/SimpleClassObject.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConstructor0() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/constructor/Constructor0.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConstructor1() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/constructor/Constructor1.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConstructor1WithParamDefaultValue() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/constructor/Constructor1WithParamDefaultValue.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConstructorCollectionParameter() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/constructor/ConstructorCollectionParameter.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConstructorWithTwoTypeParameters() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/constructor/ConstructorWithTwoTypeParameters.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConstructorWithTwoTypeParametersAndOneIntValueParameter() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/constructor/ConstructorWithTwoTypeParametersAndOneIntValueParameter.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConstructorWithTwoTypeParametersAndOnePValueParameter() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/constructor/ConstructorWithTwoTypeParametersAndOnePValueParameter.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConstructorWithTypeParameter() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/constructor/ConstructorWithTypeParameter.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConstructorWithTypeParametersEAndOnePValueParameter() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/constructor/ConstructorWithTypeParametersEAndOnePValueParameter.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFunClassParamNotNull() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/fun/genericWithoutTypeVariables/FunClassParamNotNull.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFunClassParamNullable() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/fun/genericWithoutTypeVariables/FunClassParamNullable.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFunParamNullable() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/fun/genericWithoutTypeVariables/FunParamNullable.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReturnTypeClassParamNotNull() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/fun/genericWithoutTypeVariables/ReturnTypeClassParamNotNull.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReturnTypeClassParamNullable() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/fun/genericWithoutTypeVariables/ReturnTypeClassParamNullable.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFunGenericParam() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/fun/genericWithTypeVariables/FunGenericParam.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFunInParam() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/fun/genericWithTypeVariables/FunInParam.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFunOutParam() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/fun/genericWithTypeVariables/FunOutParam.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFunParamParam() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/fun/genericWithTypeVariables/FunParamParam.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFunParamParamErased() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/fun/genericWithTypeVariables/FunParamParamErased.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFunParamReferencesParam() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/fun/genericWithTypeVariables/FunParamReferencesParam.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFunParamReferencesParam2() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/fun/genericWithTypeVariables/FunParamReferencesParam2.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFunParamTwoUpperBounds() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/fun/genericWithTypeVariables/FunParamTwoUpperBounds.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFunParamUpperClassBound() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/fun/genericWithTypeVariables/FunParamUpperClassBound.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFunParamUpperClassInterfaceBound() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/fun/genericWithTypeVariables/FunParamUpperClassInterfaceBound.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFunParamUpperInterfaceBound() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/fun/genericWithTypeVariables/FunParamUpperInterfaceBound.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFunParamUpperInterfaceClassBound() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/fun/genericWithTypeVariables/FunParamUpperInterfaceClassBound.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFunParamVaragParam() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/fun/genericWithTypeVariables/FunParamVaragParam.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFunTwoTypeParams() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/fun/genericWithTypeVariables/FunTwoTypeParams.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFunTwoTypeParams2() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/fun/genericWithTypeVariables/FunTwoTypeParams2.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClassFun() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/fun/nonGeneric/ClassFun.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClassFunGetFoo() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/fun/nonGeneric/ClassFunGetFoo.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClassFunGetFooSetFoo() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/fun/nonGeneric/ClassFunGetFooSetFoo.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClassFunSetFoo() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/fun/nonGeneric/ClassFunSetFoo.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExtFun() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/fun/nonGeneric/ExtFun.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExtFunInClass() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/fun/nonGeneric/ExtFunInClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFunDefaultArg() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/fun/nonGeneric/FunDefaultArg.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFunParamNotNull() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/fun/nonGeneric/FunParamNotNull.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFunVarargInt() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/fun/nonGeneric/FunVarargInt.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFunVarargInteger() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/fun/nonGeneric/FunVarargInteger.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testModifierAbstract() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/fun/nonGeneric/ModifierAbstract.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testModifierOpen() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/fun/nonGeneric/ModifierOpen.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNsFun() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/fun/nonGeneric/NsFun.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNsFunGetFoo() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/fun/nonGeneric/NsFunGetFoo.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReturnTypeNotNull() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/fun/nonGeneric/ReturnTypeNotNull.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReturnTypeNullable() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/fun/nonGeneric/ReturnTypeNullable.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClassVal() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/prop/ClassVal.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClassValAbstract() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/prop/ClassValAbstract.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClassVar() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/prop/ClassVar.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCollectionSize() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/prop/CollectionSize.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExtValClass() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/prop/ExtValClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExtValInClass() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/prop/ExtValInClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExtValInt() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/prop/ExtValInt.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExtValIntCharSequence() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/prop/ExtValIntCharSequence.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExtValIntCharSequenceQ() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/prop/ExtValIntCharSequenceQ.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExtValIntListQOfIntInClass() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/prop/ExtValIntListQOfIntInClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExtValIntTInClass() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/prop/ExtValIntTInClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExtValIntTQInClass() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/prop/ExtValIntTQInClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExtValTIntInClass() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/prop/ExtValTIntInClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExtVarClass() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/prop/ExtVarClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExtVarInClass() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/prop/ExtVarInClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExtVarInt() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/prop/ExtVarInt.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExtVarIntTInClass() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/prop/ExtVarIntTInClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExtVarIntTQInClass() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/prop/ExtVarIntTQInClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExtVarl() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/prop/ExtVarl.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExtVarMapPQInt() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/prop/ExtVarMapPQInt.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExtVarTIntInClass() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/prop/ExtVarTIntInClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExtVarTQIntInClass() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/prop/ExtVarTQIntInClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNsVal() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/prop/NsVal.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNsVar() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/prop/NsVar.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOverrideClassVal() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/prop/OverrideClassVal.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOverrideTraitVal() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/prop/OverrideTraitVal.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPropFromSuperclass() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/prop/PropFromSuperclass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAny() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/type/Any.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAnyQ() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/type/AnyQ.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testArrayOfInt() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/type/ArrayOfInt.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testArrayOfInteger() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/type/ArrayOfInteger.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testArrayOfString() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/type/ArrayOfString.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFunction1IntString() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/type/Function1IntString.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInt() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/type/Int.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIntArray() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/type/IntArray.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIntQ() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/type/IntQ.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJlInteger() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/type/jlInteger.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJlIntegerQ() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/type/jlIntegerQ.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJlObject() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/type/jlObject.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJlObjectQ() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/type/jlObjectQ.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJlString() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/type/jlString.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJlStringQ() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/type/jlStringQ.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListOfAny() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/type/ListOfAny.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListOfAnyQ() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/type/ListOfAnyQ.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListOfjlString() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/type/ListOfjlString.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListOfStar() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/type/ListOfStar.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListOfString() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/type/ListOfString.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNothing() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/type/Nothing.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNothingQ() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/type/NothingQ.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testString() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/type/String.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStringQ() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/type/StringQ.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTuple0() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/readKotlinBinaryClass/type/Tuple0.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenericFunction() throws Exception {
|
||||
doTest("compiler/testData/lazyResolve/genericFunction.kt");
|
||||
@@ -36,15 +661,14 @@ public class LazyResolveComparingTestGenerated extends AbstractLazyResolveCompar
|
||||
doTest("compiler/testData/lazyResolve/simpleClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void allTestsPresent() {
|
||||
public void allTestsPresent(String testDataDir) {
|
||||
Set<String> methodNames = new HashSet<String>();
|
||||
for (Method method : LazyResolveComparingTestGenerated.class.getDeclaredMethods()) {
|
||||
if (method.isAnnotationPresent(Test.class)) {
|
||||
methodNames.add(method.getName().toLowerCase() + ".kt");
|
||||
}
|
||||
}
|
||||
File[] testDataFiles = new File("compiler/testData/lazyResolve").listFiles(new FileFilter() {
|
||||
File[] testDataFiles = new File("testDataDi").listFiles(new FileFilter() {
|
||||
@Override
|
||||
public boolean accept(File pathname) {
|
||||
return pathname.getName().endsWith(".kt");
|
||||
|
||||
+91
-14
@@ -16,6 +16,9 @@
|
||||
|
||||
package org.jetbrains.jet.lang.resolve.lazy;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.Collections2;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -23,6 +26,10 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author abreslav
|
||||
@@ -32,13 +39,80 @@ public class LazyResolveComparingTestGenerator {
|
||||
new LazyResolveComparingTestGenerator().generateAndSave();
|
||||
}
|
||||
|
||||
private static class TestDataSource {
|
||||
private final File rootFile;
|
||||
private final boolean recursive;
|
||||
private final FileFilter filter;
|
||||
private final String doTestMethodName;
|
||||
|
||||
public TestDataSource(@NotNull File rootFile, boolean recursive, @NotNull FileFilter filter, String doTestMethodName) {
|
||||
this.rootFile = rootFile;
|
||||
this.recursive = recursive;
|
||||
this.filter = filter;
|
||||
this.doTestMethodName = doTestMethodName;
|
||||
}
|
||||
|
||||
public Collection<TestDataFile> getFiles() {
|
||||
if (!rootFile.isDirectory()) {
|
||||
return Collections.singletonList(new TestDataFile(rootFile, doTestMethodName));
|
||||
}
|
||||
List<File> files = Lists.newArrayList();
|
||||
collectFiles(rootFile, files, recursive);
|
||||
return Collections2.transform(files, new Function<File, TestDataFile>() {
|
||||
@Override
|
||||
public TestDataFile apply(File file) {
|
||||
return new TestDataFile(file, doTestMethodName);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void collectFiles(File current, List<File> result, boolean recursive) {
|
||||
for (File file : current.listFiles(filter)) {
|
||||
if (file.isDirectory() && recursive) {
|
||||
collectFiles(file, result, recursive);
|
||||
}
|
||||
else {
|
||||
result.add(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class TestDataFile {
|
||||
private final File file;
|
||||
private final String doTestMethodName;
|
||||
|
||||
public TestDataFile(File file, String doTestMethodName) {
|
||||
this.file = file;
|
||||
this.doTestMethodName = doTestMethodName;
|
||||
}
|
||||
|
||||
public String getTestCall() {
|
||||
return doTestMethodName + "(\"" + file + "\");";
|
||||
}
|
||||
|
||||
public String getTestMethodName() {
|
||||
return "test" + FileUtil.getNameWithoutExtension(StringUtil.capitalize(file.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static FileFilter filterFilesByExtension(@NotNull final String extension) {
|
||||
return new FileFilter() {
|
||||
@Override
|
||||
public boolean accept(File file) {
|
||||
return file.isDirectory() || file.getName().endsWith("." + extension);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private final String baseDir;
|
||||
private final String testDataFileExtension;
|
||||
private final String testClassPackage;
|
||||
private final String testClassName;
|
||||
private final String baseTestClassPackage;
|
||||
private final String baseTestClassName;
|
||||
private final File testDataDir;
|
||||
private final Collection<TestDataSource> testDataSources;
|
||||
private final String generatorName;
|
||||
|
||||
public LazyResolveComparingTestGenerator() {
|
||||
@@ -48,7 +122,11 @@ public class LazyResolveComparingTestGenerator {
|
||||
testClassName = "LazyResolveComparingTestGenerated";
|
||||
baseTestClassPackage = "org.jetbrains.jet.lang.resolve.lazy";
|
||||
baseTestClassName = "AbstractLazyResolveComparingTest";
|
||||
testDataDir = new File("compiler/testData/lazyResolve");
|
||||
//testDataDir = new File("compiler/testData/lazyResolve");
|
||||
testDataSources = Arrays.asList(
|
||||
new TestDataSource(new File("compiler/testData/readKotlinBinaryClass"), true, filterFilesByExtension(testDataFileExtension), "doTestSinglePackage"),
|
||||
new TestDataSource(new File("compiler/testData/lazyResolve"), true, filterFilesByExtension(testDataFileExtension), "doTest")
|
||||
);
|
||||
generatorName = "LazyResolveComparingTestGenerator";
|
||||
}
|
||||
|
||||
@@ -77,18 +155,17 @@ public class LazyResolveComparingTestGenerator {
|
||||
p.println("public class ", testClassName, " extends ", baseTestClassName, " {");
|
||||
p.pushIndent();
|
||||
|
||||
File[] ktFiles = testDataDir.listFiles(new FileFilter() {
|
||||
@Override
|
||||
public boolean accept(File pathname) {
|
||||
return pathname.getName().endsWith("." + testDataFileExtension);
|
||||
}
|
||||
});
|
||||
for (File file : ktFiles) {
|
||||
Collection<TestDataFile> files = Lists.newArrayList();
|
||||
for (TestDataSource testDataSource : testDataSources) {
|
||||
files.addAll(testDataSource.getFiles());
|
||||
}
|
||||
|
||||
for (TestDataFile file : files) {
|
||||
p.println("@Test");
|
||||
p.println("public void test", FileUtil.getNameWithoutExtension(StringUtil.capitalize(file.getName())), "() throws Exception {");
|
||||
p.println("public void ", file.getTestMethodName(), "() throws Exception {");
|
||||
p.pushIndent();
|
||||
|
||||
p.println("doTest(\"", file.getPath(), "\");");
|
||||
p.println(file.getTestCall());
|
||||
|
||||
p.popIndent();
|
||||
p.println("}");
|
||||
@@ -106,15 +183,15 @@ public class LazyResolveComparingTestGenerator {
|
||||
|
||||
private void generateAllTestsPresent(Printer p) {
|
||||
String methodText =
|
||||
"@Test\n" +
|
||||
" public void allTestsPresent() {\n" +
|
||||
//"@Test\n" +
|
||||
" public void allTestsPresent(String testDataDir) {\n" +
|
||||
" Set<String> methodNames = new HashSet<String>();\n" +
|
||||
" for (Method method : " + testClassName + ".class.getDeclaredMethods()) {\n" +
|
||||
" if (method.isAnnotationPresent(Test.class)) {\n" +
|
||||
" methodNames.add(method.getName().toLowerCase() + \"." + testDataFileExtension + "\");\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
" File[] testDataFiles = new File(\"" + testDataDir + "\").listFiles(new FileFilter() {\n" +
|
||||
" File[] testDataFiles = new File(\"testDataDi\").listFiles(new FileFilter() {\n" +
|
||||
" @Override\n" +
|
||||
" public boolean accept(File pathname) {\n" +
|
||||
" return pathname.getName().endsWith(\"." + testDataFileExtension + "\");\n" +
|
||||
|
||||
Reference in New Issue
Block a user