Search in sources :

Example 1 with EcmaVersion

use of org.jetbrains.kotlin.js.config.EcmaVersion in project kotlin by JetBrains.

the class JsUnitTestBase method runTestFile.

public void runTestFile(@NotNull String pathToTestFile) throws Exception {
    Iterable<EcmaVersion> versions = DEFAULT_ECMA_VERSIONS;
    String testName = pathToTestFile.substring(pathToTestFile.lastIndexOf("/"));
    generateJavaScriptFiles(Collections.singletonList(pathToTestFile), testName, MainCallParameters.noCall(), versions);
    runRhinoTests(testName, versions, new RhinoSystemOutputChecker(""));
}
Also used : RhinoSystemOutputChecker(org.jetbrains.kotlin.js.test.rhino.RhinoSystemOutputChecker) EcmaVersion(org.jetbrains.kotlin.js.config.EcmaVersion)

Example 2 with EcmaVersion

use of org.jetbrains.kotlin.js.config.EcmaVersion in project kotlin by JetBrains.

the class CompileMavenGeneratedJSLibrary method generateJavaScriptFiles.

private void generateJavaScriptFiles(@NotNull Iterable<EcmaVersion> ecmaVersions, @NotNull String sourceDir, @NotNull String... stdLibFiles) throws Exception {
    List<String> files = Lists.newArrayList();
    // now lets add all the files from the definitions and library
    //addAllSourceFiles(files, generatedJsDefinitionsDir);
    addAllSourceFiles(files, generatedJsLibraryDir);
    File stdlibDir = new File(sourceDir);
    assertTrue("Cannot find stdlib test source: " + stdlibDir, stdlibDir.exists());
    for (String file : stdLibFiles) {
        files.add(new File(stdlibDir, file).getPath());
    }
    // now lets try invoke the compiler
    for (EcmaVersion version : ecmaVersions) {
        String outputFile = getOutputFilePath(getTestName(false) + ".compiler.kt", version);
        System.out.println("Compiling with version: " + version + " to: " + outputFile);
        List<String> args = new ArrayList<String>(Arrays.asList("-output", outputFile, "-libraries", generatedJsDefinitionsDir, "-verbose"));
        args.addAll(files);
        ExitCode answer = new K2JSCompiler().exec(System.out, ArrayUtil.toStringArray(args));
        assertEquals("Compile failed", ExitCode.OK, answer);
    }
}
Also used : K2JSCompiler(org.jetbrains.kotlin.cli.js.K2JSCompiler) ExitCode(org.jetbrains.kotlin.cli.common.ExitCode) ArrayList(java.util.ArrayList) EcmaVersion(org.jetbrains.kotlin.js.config.EcmaVersion) File(java.io.File)

Aggregations

EcmaVersion (org.jetbrains.kotlin.js.config.EcmaVersion)2 File (java.io.File)1 ArrayList (java.util.ArrayList)1 ExitCode (org.jetbrains.kotlin.cli.common.ExitCode)1 K2JSCompiler (org.jetbrains.kotlin.cli.js.K2JSCompiler)1 RhinoSystemOutputChecker (org.jetbrains.kotlin.js.test.rhino.RhinoSystemOutputChecker)1