ReadJavaBinaryClassTest migrated to the generated form
This commit is contained in:
+11
-44
@@ -21,7 +21,6 @@ import com.intellij.openapi.vfs.CharsetToolkit;
|
|||||||
import com.intellij.psi.PsiFileFactory;
|
import com.intellij.psi.PsiFileFactory;
|
||||||
import com.intellij.psi.impl.PsiFileFactoryImpl;
|
import com.intellij.psi.impl.PsiFileFactoryImpl;
|
||||||
import com.intellij.testFramework.LightVirtualFile;
|
import com.intellij.testFramework.LightVirtualFile;
|
||||||
import junit.framework.Test;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.jet.ConfigurationKind;
|
import org.jetbrains.jet.ConfigurationKind;
|
||||||
import org.jetbrains.jet.JetTestCaseBuilder;
|
import org.jetbrains.jet.JetTestCaseBuilder;
|
||||||
@@ -33,21 +32,17 @@ import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
|
|||||||
import org.jetbrains.jet.lang.psi.JetFile;
|
import org.jetbrains.jet.lang.psi.JetFile;
|
||||||
import org.jetbrains.jet.lang.resolve.AnalyzerScriptParameter;
|
import org.jetbrains.jet.lang.resolve.AnalyzerScriptParameter;
|
||||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
|
||||||
import org.jetbrains.jet.lang.resolve.java.AnalyzerFacadeForJVM;
|
import org.jetbrains.jet.lang.resolve.java.AnalyzerFacadeForJVM;
|
||||||
import org.jetbrains.jet.lang.resolve.java.DescriptorSearchRule;
|
import org.jetbrains.jet.lang.resolve.java.DescriptorSearchRule;
|
||||||
import org.jetbrains.jet.lang.resolve.java.JavaDescriptorResolver;
|
import org.jetbrains.jet.lang.resolve.java.JavaDescriptorResolver;
|
||||||
|
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||||
import org.jetbrains.jet.plugin.JetLanguage;
|
import org.jetbrains.jet.plugin.JetLanguage;
|
||||||
import org.jetbrains.jet.test.TestCaseWithTmpdir;
|
import org.jetbrains.jet.test.TestCaseWithTmpdir;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
|
|
||||||
import javax.tools.JavaCompiler;
|
import javax.tools.*;
|
||||||
import javax.tools.JavaFileObject;
|
|
||||||
import javax.tools.StandardJavaFileManager;
|
|
||||||
import javax.tools.ToolProvider;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FilenameFilter;
|
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@@ -57,25 +52,15 @@ import java.util.Locale;
|
|||||||
/**
|
/**
|
||||||
* @author Stepan Koltsov
|
* @author Stepan Koltsov
|
||||||
*/
|
*/
|
||||||
public class ReadJavaBinaryClassTest extends TestCaseWithTmpdir {
|
public abstract class AbstractReadJavaBinaryClassTest extends TestCaseWithTmpdir {
|
||||||
|
|
||||||
private final File ktFile;
|
|
||||||
private final File javaFile;
|
|
||||||
private final File txtFile;
|
|
||||||
|
|
||||||
public ReadJavaBinaryClassTest(@NotNull File javaFile) {
|
public void doTest(String javaFileName) throws Exception {
|
||||||
this.javaFile = javaFile;
|
Assert.assertTrue("A java file expected: " + javaFileName, javaFileName.endsWith(".java"));
|
||||||
Assert.assertTrue(javaFile.getName().endsWith(".java"));
|
File javaFile = new File(javaFileName);
|
||||||
this.ktFile = new File(javaFile.getPath().replaceFirst("\\.java$", ".kt"));
|
File ktFile = new File(javaFile.getPath().replaceFirst("\\.java$", ".kt"));
|
||||||
this.txtFile = new File(javaFile.getPath().replaceFirst("\\.java$", ".txt"));
|
File txtFile = new File(javaFile.getPath().replaceFirst("\\.java$", ".txt"));
|
||||||
setName(javaFile.getName());
|
NamespaceDescriptor nsa = compileKotlin(ktFile);
|
||||||
}
|
NamespaceDescriptor nsb = compileJava(javaFile);
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void runTest() throws Exception {
|
|
||||||
NamespaceDescriptor nsa = compileKotlin();
|
|
||||||
NamespaceDescriptor nsb = compileJava();
|
|
||||||
NamespaceComparator.compareNamespaces(nsa, nsb, false, txtFile);
|
NamespaceComparator.compareNamespaces(nsa, nsb, false, txtFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,7 +79,7 @@ public class ReadJavaBinaryClassTest extends TestCaseWithTmpdir {
|
|||||||
return bindingContext.get(BindingContext.FQNAME_TO_NAMESPACE_DESCRIPTOR, FqName.topLevel(Name.identifier("test")));
|
return bindingContext.get(BindingContext.FQNAME_TO_NAMESPACE_DESCRIPTOR, FqName.topLevel(Name.identifier("test")));
|
||||||
}
|
}
|
||||||
|
|
||||||
private NamespaceDescriptor compileJava() throws Exception {
|
private NamespaceDescriptor compileJava(File javaFile) throws Exception {
|
||||||
JavaCompiler javaCompiler = ToolProvider.getSystemJavaCompiler();
|
JavaCompiler javaCompiler = ToolProvider.getSystemJavaCompiler();
|
||||||
|
|
||||||
StandardJavaFileManager fileManager = javaCompiler.getStandardFileManager(null, Locale.ENGLISH, Charset.forName("utf-8"));
|
StandardJavaFileManager fileManager = javaCompiler.getStandardFileManager(null, Locale.ENGLISH, Charset.forName("utf-8"));
|
||||||
@@ -121,22 +106,4 @@ public class ReadJavaBinaryClassTest extends TestCaseWithTmpdir {
|
|||||||
JavaDescriptorResolver javaDescriptorResolver = injector.getJavaDescriptorResolver();
|
JavaDescriptorResolver javaDescriptorResolver = injector.getJavaDescriptorResolver();
|
||||||
return javaDescriptorResolver.resolveNamespace(FqName.topLevel(Name.identifier("test")), DescriptorSearchRule.ERROR_IF_FOUND_IN_KOTLIN);
|
return javaDescriptorResolver.resolveNamespace(FqName.topLevel(Name.identifier("test")), DescriptorSearchRule.ERROR_IF_FOUND_IN_KOTLIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Test suite() {
|
|
||||||
class JavaFilter implements FilenameFilter {
|
|
||||||
@Override
|
|
||||||
public boolean accept(File dir, String name) {
|
|
||||||
return name.endsWith(".java");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return JetTestCaseBuilder.suiteForDirectory(JetTestCaseBuilder.getTestDataPathBase(), "/readJavaBinaryClass", true, new JavaFilter(), new JetTestCaseBuilder.NamedTestFactory() {
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
public Test createTest(@NotNull String dataPath, @NotNull String name, @NotNull File file) {
|
|
||||||
return new ReadJavaBinaryClassTest(file);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -38,7 +38,7 @@ import java.util.Collection;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Stepan Koltsov
|
* @author Stepan Koltsov
|
||||||
* @see ReadJavaBinaryClassTest
|
* @see AbstractReadJavaBinaryClassTest
|
||||||
*/
|
*/
|
||||||
public class JavaDescriptorResolverTest extends TestCaseWithTmpdir {
|
public class JavaDescriptorResolverTest extends TestCaseWithTmpdir {
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,378 @@
|
|||||||
|
/*
|
||||||
|
* 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.junit.Assert;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.junit.runners.Suite;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/* This class is generated by org.jetbrains.jet.jvm.compiler.ReadJavaBinaryClassTestGenerator. DO NOT MODIFY MANUALLY */
|
||||||
|
@RunWith(Suite.class)
|
||||||
|
@Suite.SuiteClasses({
|
||||||
|
ReadJavaBinaryClassTestGenerated.ReadJavaBinaryClass.class
|
||||||
|
})
|
||||||
|
public class ReadJavaBinaryClassTestGenerated {
|
||||||
|
public static class ReadJavaBinaryClass extends AbstractReadJavaBinaryClassTest {
|
||||||
|
@Test
|
||||||
|
public void allTestsPresentInReadJavaBinaryClass() throws Exception {
|
||||||
|
allTestsPresent(ReadJavaBinaryClass.class, new File("compiler/testData/readJavaBinaryClass"), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAnnotatedAnnotation() throws Exception {
|
||||||
|
doTest("compiler/testData/readJavaBinaryClass/annotation/AnnotatedAnnotation.java");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAnnotatedMethod() throws Exception {
|
||||||
|
doTest("compiler/testData/readJavaBinaryClass/annotation/AnnotatedMethod.java");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSimpleAnnotation() throws Exception {
|
||||||
|
doTest("compiler/testData/readJavaBinaryClass/annotation/SimpleAnnotation.java");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testClassDoesNotOverrideMethod() throws Exception {
|
||||||
|
doTest("compiler/testData/readJavaBinaryClass/ClassDoesNotOverrideMethod.java");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testClassWithTypeP() throws Exception {
|
||||||
|
doTest("compiler/testData/readJavaBinaryClass/ClassWithTypeP.java");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testClassWithTypePExtendsIterableP() throws Exception {
|
||||||
|
doTest("compiler/testData/readJavaBinaryClass/ClassWithTypePExtendsIterableP.java");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testClassWithTypePP() throws Exception {
|
||||||
|
doTest("compiler/testData/readJavaBinaryClass/ClassWithTypePP.java");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testClassWithTypePRefNext() throws Exception {
|
||||||
|
doTest("compiler/testData/readJavaBinaryClass/ClassWithTypePRefNext.java");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testClassWithTypePRefSelf() throws Exception {
|
||||||
|
doTest("compiler/testData/readJavaBinaryClass/ClassWithTypePRefSelf.java");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testConstructorGenericDeep() throws Exception {
|
||||||
|
doTest("compiler/testData/readJavaBinaryClass/constructor/ConstructorGenericDeep.java");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testConstructorGenericSimple() throws Exception {
|
||||||
|
doTest("compiler/testData/readJavaBinaryClass/constructor/ConstructorGenericSimple.java");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testConstructorGenericUpperBound() throws Exception {
|
||||||
|
doTest("compiler/testData/readJavaBinaryClass/constructor/ConstructorGenericUpperBound.java");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFieldAsVar() throws Exception {
|
||||||
|
doTest("compiler/testData/readJavaBinaryClass/FieldAsVar.java");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFieldOfArrayType() throws Exception {
|
||||||
|
doTest("compiler/testData/readJavaBinaryClass/FieldOfArrayType.java");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFinalFieldAsVal() throws Exception {
|
||||||
|
doTest("compiler/testData/readJavaBinaryClass/FinalFieldAsVal.java");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testInnerClass() throws Exception {
|
||||||
|
doTest("compiler/testData/readJavaBinaryClass/InnerClass.java");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testInnerClassesInGeneric() throws Exception {
|
||||||
|
doTest("compiler/testData/readJavaBinaryClass/InnerClassesInGeneric.java");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testInnerClassReferencesOuterTP() throws Exception {
|
||||||
|
doTest("compiler/testData/readJavaBinaryClass/InnerClassReferencesOuterTP.java");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDifferentGetterAndSetter() throws Exception {
|
||||||
|
doTest("compiler/testData/readJavaBinaryClass/javaBean/DifferentGetterAndSetter.java");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testJavaBeanAbstractGetter() throws Exception {
|
||||||
|
doTest("compiler/testData/readJavaBinaryClass/javaBean/JavaBeanAbstractGetter.java");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testJavaBeanVal() throws Exception {
|
||||||
|
doTest("compiler/testData/readJavaBinaryClass/javaBean/JavaBeanVal.java");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testJavaBeanVar() throws Exception {
|
||||||
|
doTest("compiler/testData/readJavaBinaryClass/javaBean/JavaBeanVar.java");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testJavaBeanVarOfGenericType() throws Exception {
|
||||||
|
doTest("compiler/testData/readJavaBinaryClass/javaBean/JavaBeanVarOfGenericType.java");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTwoSetters() throws Exception {
|
||||||
|
doTest("compiler/testData/readJavaBinaryClass/javaBean/TwoSetters.java");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAddingNullability() throws Exception {
|
||||||
|
doTest("compiler/testData/readJavaBinaryClass/kotlinSignature/error/AddingNullability.java");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testExtraUpperBound() throws Exception {
|
||||||
|
doTest("compiler/testData/readJavaBinaryClass/kotlinSignature/error/ExtraUpperBound.java");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMissingUpperBound() throws Exception {
|
||||||
|
doTest("compiler/testData/readJavaBinaryClass/kotlinSignature/error/MissingUpperBound.java");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testNotVarargReplacedWithVararg() throws Exception {
|
||||||
|
doTest("compiler/testData/readJavaBinaryClass/kotlinSignature/error/NotVarargReplacedWithVararg.java");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testReturnTypeMissing() throws Exception {
|
||||||
|
doTest("compiler/testData/readJavaBinaryClass/kotlinSignature/error/ReturnTypeMissing.java");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSyntaxError() throws Exception {
|
||||||
|
doTest("compiler/testData/readJavaBinaryClass/kotlinSignature/error/SyntaxError.java");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testVarargReplacedWithNotVararg() throws Exception {
|
||||||
|
doTest("compiler/testData/readJavaBinaryClass/kotlinSignature/error/VarargReplacedWithNotVararg.java");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testWrongMethodName() throws Exception {
|
||||||
|
doTest("compiler/testData/readJavaBinaryClass/kotlinSignature/error/WrongMethodName.java");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testWrongReturnTypeStructure() throws Exception {
|
||||||
|
doTest("compiler/testData/readJavaBinaryClass/kotlinSignature/error/WrongReturnTypeStructure.java");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testWrongTypeName1() throws Exception {
|
||||||
|
doTest("compiler/testData/readJavaBinaryClass/kotlinSignature/error/WrongTypeName1.java");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testWrongTypeName2() throws Exception {
|
||||||
|
doTest("compiler/testData/readJavaBinaryClass/kotlinSignature/error/WrongTypeName2.java");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testWrongTypeName3() throws Exception {
|
||||||
|
doTest("compiler/testData/readJavaBinaryClass/kotlinSignature/error/WrongTypeName3.java");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testWrongTypeParameterBoundStructure1() throws Exception {
|
||||||
|
doTest("compiler/testData/readJavaBinaryClass/kotlinSignature/error/WrongTypeParameterBoundStructure1.java");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testWrongTypeParameterBoundStructure2() throws Exception {
|
||||||
|
doTest("compiler/testData/readJavaBinaryClass/kotlinSignature/error/WrongTypeParameterBoundStructure2.java");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testWrongTypeParametersCount() throws Exception {
|
||||||
|
doTest("compiler/testData/readJavaBinaryClass/kotlinSignature/error/WrongTypeParametersCount.java");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testWrongTypeVariance() throws Exception {
|
||||||
|
doTest("compiler/testData/readJavaBinaryClass/kotlinSignature/error/WrongTypeVariance.java");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testWrongValueParametersCount() throws Exception {
|
||||||
|
doTest("compiler/testData/readJavaBinaryClass/kotlinSignature/error/WrongValueParametersCount.java");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testWrongValueParameterStructure1() throws Exception {
|
||||||
|
doTest("compiler/testData/readJavaBinaryClass/kotlinSignature/error/WrongValueParameterStructure1.java");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testWrongValueParameterStructure2() throws Exception {
|
||||||
|
doTest("compiler/testData/readJavaBinaryClass/kotlinSignature/error/WrongValueParameterStructure2.java");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMethodWithFunctionTypes() throws Exception {
|
||||||
|
doTest("compiler/testData/readJavaBinaryClass/kotlinSignature/MethodWithFunctionTypes.java");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMethodWithGenerics() throws Exception {
|
||||||
|
doTest("compiler/testData/readJavaBinaryClass/kotlinSignature/MethodWithGenerics.java");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMethodWithTupleType() throws Exception {
|
||||||
|
doTest("compiler/testData/readJavaBinaryClass/kotlinSignature/MethodWithTupleType.java");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMethodWithTypeParameters() throws Exception {
|
||||||
|
doTest("compiler/testData/readJavaBinaryClass/kotlinSignature/MethodWithTypeParameters.java");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMethodWithVararg() throws Exception {
|
||||||
|
doTest("compiler/testData/readJavaBinaryClass/kotlinSignature/MethodWithVararg.java");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMethodReferencesOuterClassTP() throws Exception {
|
||||||
|
doTest("compiler/testData/readJavaBinaryClass/MethodReferencesOuterClassTP.java");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMethodTypePOneUpperBound() throws Exception {
|
||||||
|
doTest("compiler/testData/readJavaBinaryClass/MethodTypePOneUpperBound.java");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMethodTypePTwoUpperBounds() throws Exception {
|
||||||
|
doTest("compiler/testData/readJavaBinaryClass/MethodTypePTwoUpperBounds.java");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMethodWithTypeP() throws Exception {
|
||||||
|
doTest("compiler/testData/readJavaBinaryClass/MethodWithTypeP.java");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMethodWithTypePP() throws Exception {
|
||||||
|
doTest("compiler/testData/readJavaBinaryClass/MethodWithTypePP.java");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMethodWithTypePRefClassP() throws Exception {
|
||||||
|
doTest("compiler/testData/readJavaBinaryClass/MethodWithTypePRefClassP.java");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMethosWithPRefTP() throws Exception {
|
||||||
|
doTest("compiler/testData/readJavaBinaryClass/MethosWithPRefTP.java");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMyException() throws Exception {
|
||||||
|
doTest("compiler/testData/readJavaBinaryClass/MyException.java");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testNotNullField() throws Exception {
|
||||||
|
doTest("compiler/testData/readJavaBinaryClass/notNull/NotNullField.java");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testNotNullMethod() throws Exception {
|
||||||
|
doTest("compiler/testData/readJavaBinaryClass/notNull/NotNullMethod.java");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testNotNullParameter() throws Exception {
|
||||||
|
doTest("compiler/testData/readJavaBinaryClass/notNull/NotNullParameter.java");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSimple() throws Exception {
|
||||||
|
doTest("compiler/testData/readJavaBinaryClass/Simple.java");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTwoFields() throws Exception {
|
||||||
|
doTest("compiler/testData/readJavaBinaryClass/TwoFields.java");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testVarargInt() throws Exception {
|
||||||
|
doTest("compiler/testData/readJavaBinaryClass/vararg/VarargInt.java");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testVarargString() throws Exception {
|
||||||
|
doTest("compiler/testData/readJavaBinaryClass/vararg/VarargString.java");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void allTestsPresent(Class<?> clazz, File testDataDir, boolean recursive) {
|
||||||
|
Set<String> methodNames = new HashSet<String>();
|
||||||
|
for (Method method : clazz.getDeclaredMethods()) {
|
||||||
|
if (method.isAnnotationPresent(Test.class)) {
|
||||||
|
methodNames.add(method.getName().toLowerCase() + ".java");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (File file : testDataDir.listFiles()) {
|
||||||
|
if (file.isDirectory()) {
|
||||||
|
if (recursive) {
|
||||||
|
allTestsPresent(clazz, file, recursive);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
String name = file.getName();
|
||||||
|
if (name.endsWith(".java") && !methodNames.contains("test" + name.toLowerCase())) {
|
||||||
|
Assert.fail("Test data file missing from the generated test class: " + file + "\nPlease re-run the generator: org.jetbrains.jet.jvm.compiler.ReadJavaBinaryClassTestGenerator");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* 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.jet.test.generator.TestDataSource;
|
||||||
|
import org.jetbrains.jet.test.generator.TestGenerator;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author abreslav
|
||||||
|
*/
|
||||||
|
public class ReadJavaBinaryClassTestGenerator {
|
||||||
|
public static void main(String[] args) throws IOException {
|
||||||
|
String aPackage = "org.jetbrains.jet.jvm.compiler";
|
||||||
|
String extension = "java";
|
||||||
|
new TestGenerator(
|
||||||
|
"compiler/tests/",
|
||||||
|
extension,
|
||||||
|
aPackage,
|
||||||
|
"ReadJavaBinaryClassTestGenerated",
|
||||||
|
aPackage,
|
||||||
|
"AbstractReadJavaBinaryClassTest",
|
||||||
|
Arrays.asList(
|
||||||
|
new TestDataSource(new File("compiler/testData/readJavaBinaryClass"), true, TestGenerator.filterFilesByExtension(extension), "doTest")
|
||||||
|
),
|
||||||
|
ReadJavaBinaryClassTestGenerator.class.getName()
|
||||||
|
).generateAndSave();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user