Fix tests for j2converter
This commit is contained in:
@@ -46,6 +46,9 @@ public class Converter {
|
||||
"javax.annotation.Nonnull"
|
||||
);
|
||||
|
||||
@NotNull
|
||||
private final Project project;
|
||||
|
||||
@NotNull
|
||||
private Set<String> classIdentifiers = Sets.newHashSet();
|
||||
|
||||
@@ -59,9 +62,15 @@ public class Converter {
|
||||
private final Set<J2KConverterFlags> flags = Sets.newHashSet();
|
||||
|
||||
public Converter(@NotNull Project project) {
|
||||
this.project = project;
|
||||
KotlinBuiltIns.initialize(project, KotlinBuiltIns.InitializationMode.MULTI_THREADED);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Project getProject() {
|
||||
return project;
|
||||
}
|
||||
|
||||
public boolean addFlag(@NotNull J2KConverterFlags flag) {
|
||||
return flags.add(flag);
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
<orderEntry type="module" module-name="cli" scope="TEST" />
|
||||
<orderEntry type="module" module-name="frontend" scope="TEST" />
|
||||
<orderEntry type="module" module-name="util" />
|
||||
<orderEntry type="module" module-name="compiler-tests" scope="TEST" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
|
||||
@@ -16,44 +16,24 @@
|
||||
|
||||
package org.jetbrains.jet.j2k;
|
||||
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiJavaFile;
|
||||
import com.intellij.testFramework.UsefulTestCase;
|
||||
import junit.framework.Assert;
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.cli.jvm.JVMConfigurationKeys;
|
||||
import org.jetbrains.jet.ConfigurationKind;
|
||||
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment;
|
||||
import org.jetbrains.jet.config.CompilerConfiguration;
|
||||
import org.jetbrains.jet.utils.PathUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public class StandaloneJavaToKotlinConverterTest extends TestCase {
|
||||
private static final JetCoreEnvironment jetCoreEnvironment;
|
||||
|
||||
static {
|
||||
CompilerConfiguration config = new CompilerConfiguration();
|
||||
|
||||
config.add(JVMConfigurationKeys.CLASSPATH_KEY, PathUtil.findRtJar());
|
||||
File annotations = JavaToKotlinTranslator.findAnnotations();
|
||||
if (annotations != null && annotations.exists()) {
|
||||
config.add(JVMConfigurationKeys.CLASSPATH_KEY, annotations);
|
||||
}
|
||||
|
||||
Disposable disposable = new Disposable() {
|
||||
@Override
|
||||
public void dispose() {
|
||||
}
|
||||
};
|
||||
jetCoreEnvironment = new JetCoreEnvironment(disposable, config);
|
||||
}
|
||||
import static org.jetbrains.jet.JetTestUtils.createEnvironmentWithMockJdkAndIdeaAnnotations;
|
||||
|
||||
public class StandaloneJavaToKotlinConverterTest extends UsefulTestCase {
|
||||
private final String myDataPath;
|
||||
private final String myName;
|
||||
|
||||
@@ -64,7 +44,9 @@ public class StandaloneJavaToKotlinConverterTest extends TestCase {
|
||||
|
||||
@Override
|
||||
protected void runTest() throws Throwable {
|
||||
JetCoreEnvironment jetCoreEnvironment = createEnvironmentWithMockJdkAndIdeaAnnotations(getTestRootDisposable(), ConfigurationKind.JDK_ONLY);
|
||||
Converter converter = new Converter(jetCoreEnvironment.getProject());
|
||||
|
||||
String javaPath = "j2k/tests/testData/" + getTestFilePath();
|
||||
String kotlinPath = javaPath.replace(".jav", ".kt");
|
||||
|
||||
@@ -140,7 +122,7 @@ public class StandaloneJavaToKotlinConverterTest extends TestCase {
|
||||
|
||||
@NotNull
|
||||
private String fileToKotlin(Converter converter, @NotNull String text) {
|
||||
return generateKotlinCode(converter, JavaToKotlinTranslator.createFile(jetCoreEnvironment.getProject(), text));
|
||||
return generateKotlinCode(converter, JavaToKotlinTranslator.createFile(converter.getProject(), text));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
Reference in New Issue
Block a user