Project structure fixed
This commit is contained in:
@@ -8,9 +8,10 @@
|
||||
<orderEntry type="jdk" jdkName="1.6" jdkType="JavaSDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="js.translator" />
|
||||
<orderEntry type="library" name="idea-full" level="application" />
|
||||
<orderEntry type="library" name="js_libs" level="project" />
|
||||
<orderEntry type="module" module-name="compiler-tests" />
|
||||
<orderEntry type="library" name="idea-full" level="project" />
|
||||
<orderEntry type="library" name="js-libs" level="project" />
|
||||
<orderEntry type="module" module-name="frontend" />
|
||||
<orderEntry type="module" module-name="cli" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
@@ -36,7 +36,7 @@ public abstract class BaseTest extends UsefulTestCase {
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
// createEnvironmentWithMockJdk();
|
||||
createEnvironmentWithMockJdk();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -46,9 +46,9 @@ public final class Suite extends TranslationTest {
|
||||
});
|
||||
}
|
||||
|
||||
//NOTE: just to avoid warning
|
||||
public void testNothing() {
|
||||
}
|
||||
// //NOTE: just to avoid warning
|
||||
// public void testNothing() {
|
||||
// }
|
||||
|
||||
@Override
|
||||
protected String mainDirectory() {
|
||||
|
||||
@@ -16,6 +16,10 @@
|
||||
|
||||
package org.jetbrains.k2js.test;
|
||||
|
||||
import com.google.dart.compiler.backend.js.ast.JsProgram;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.k2js.config.TestConfig;
|
||||
import org.jetbrains.k2js.facade.K2JSTranslator;
|
||||
import org.mozilla.javascript.Context;
|
||||
import org.mozilla.javascript.Scriptable;
|
||||
@@ -29,8 +33,11 @@ import java.nio.channels.FileChannel;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static org.jetbrains.k2js.utils.JetFileUtils.createPsiFileList;
|
||||
|
||||
//TODO: spread the test* methods amongst classes that actually use them
|
||||
|
||||
/**
|
||||
@@ -44,6 +51,19 @@ public abstract class TranslationTest extends BaseTest {
|
||||
private static final String KOTLIN_JS_LIB = TEST_FILES + "kotlin_lib.js";
|
||||
private static final String EXPECTED = "expected/";
|
||||
|
||||
public void testTranslateFile(@NotNull String inputFile,
|
||||
@NotNull String outputFile) throws Exception {
|
||||
testTranslateFiles(Collections.singletonList(inputFile), outputFile);
|
||||
}
|
||||
|
||||
public void testTranslateFiles(@NotNull List<String> inputFiles,
|
||||
@NotNull String outputFile) throws Exception {
|
||||
K2JSTranslator translator = new K2JSTranslator(new TestConfig(getProject()));
|
||||
List<JetFile> psiFiles = createPsiFileList(inputFiles, getProject());
|
||||
JsProgram program = translator.generateProgram(psiFiles);
|
||||
K2JSTranslator.saveProgramToFile(outputFile, program);
|
||||
}
|
||||
|
||||
protected String kotlinLibraryPath() {
|
||||
return KOTLIN_JS_LIB;
|
||||
}
|
||||
@@ -97,8 +117,8 @@ public abstract class TranslationTest extends BaseTest {
|
||||
}
|
||||
|
||||
protected void translateFile(String filename) throws Exception {
|
||||
K2JSTranslator.testTranslateFile(getInputFilePath(filename),
|
||||
getOutputFilePath(filename));
|
||||
testTranslateFile(getInputFilePath(filename),
|
||||
getOutputFilePath(filename));
|
||||
}
|
||||
|
||||
protected void translateFilesInDir(String dirName) throws Exception {
|
||||
@@ -109,8 +129,8 @@ public abstract class TranslationTest extends BaseTest {
|
||||
fullFilePaths.add(getInputFilePath(dirName) + "\\" + fileName);
|
||||
}
|
||||
assert dir.isDirectory();
|
||||
K2JSTranslator.testTranslateFiles(fullFilePaths,
|
||||
getOutputFilePath(dirName + ".kt"));
|
||||
testTranslateFiles(fullFilePaths,
|
||||
getOutputFilePath(dirName + ".kt"));
|
||||
}
|
||||
|
||||
protected List<String> generateFilenameList(String inputFile) {
|
||||
|
||||
Reference in New Issue
Block a user