Search in sources :

Example 56 with ProcessResult

use of org.eclipse.n4js.cli.helper.ProcessResult in project n4js by eclipse.

the class IncompleteApiImplementationTest method testfield_vs_getset_D.

/**
 */
@Test
public void testfield_vs_getset_D() {
    String expectedString = "Loaded Implementation one.x.impl::fields.F.n4js";
    String fileToRunName = fileToExecute_fields("Exec_AT_IDEBUG-505_field_vs_getset_D.js");
    ProcessResult nodejsResult = nodejsRun(workspace.toPath(), Path.of(fileToRunName));
    assertEquals(nodejsResult.toString(), expectedString, nodejsResult.getStdOut());
}
Also used : ProcessResult(org.eclipse.n4js.cli.helper.ProcessResult) Test(org.junit.Test) AbstractCliCompileTest(org.eclipse.n4js.cli.helper.AbstractCliCompileTest)

Example 57 with ProcessResult

use of org.eclipse.n4js.cli.helper.ProcessResult in project n4js by eclipse.

the class IncompleteApiImplementationTest method testMissing_setter_in_class.

/**
 */
@Test
public void testMissing_setter_in_class() {
    String expectedString = "Loaded Implementation one.x.impl::p.A.n4js";
    String fileToRunName = fileToExecute_direct("Exec_missing_setter_in_class.js");
    ProcessResult nodejsResult = nodejsRun(workspace.toPath(), Path.of(fileToRunName));
    assertEquals(nodejsResult.toString(), expectedString, nodejsResult.getStdOut());
}
Also used : ProcessResult(org.eclipse.n4js.cli.helper.ProcessResult) Test(org.junit.Test) AbstractCliCompileTest(org.eclipse.n4js.cli.helper.AbstractCliCompileTest)

Example 58 with ProcessResult

use of org.eclipse.n4js.cli.helper.ProcessResult in project n4js by eclipse.

the class N4jscScopedProjectTest method testNpmScopes.

/**
 * Test npm scopes.
 */
@Test
public void testNpmScopes() {
    Path project = proot.toPath().resolve("XClient");
    Path srcFolder = project.resolve("src-gen");
    Path testFile1 = srcFolder.resolve("ClientModule1.js");
    Path testFile2 = srcFolder.resolve("ClientModule2.js");
    CliCompileResult cliResult = n4jsc(COMPILE(workspace), VALIDATION_ERRORS);
    assertEquals(cliResult.toString(), 2, cliResult.getTranspiledFilesCount(project));
    String expectedString = "";
    expectedString += "Hello from A in @myScope/Lib!\n";
    expectedString += "Hello from B in Lib!\n";
    expectedString += "Hello from C in @myScope/Lib!\n";
    expectedString += "Hello from C in Lib!\n";
    expectedString += "Hello from D in @myScope/Lib!\n";
    expectedString += "Hello from D in Lib!";
    ProcessResult nodejsResult1 = nodejsRun(workspace.toPath(), testFile1);
    assertEquals(nodejsResult1.toString(), expectedString, nodejsResult1.getStdOut());
    ProcessResult nodejsResult2 = nodejsRun(workspace.toPath(), testFile2);
    assertEquals(nodejsResult2.toString(), expectedString, nodejsResult2.getStdOut());
}
Also used : Path(java.nio.file.Path) CliCompileResult(org.eclipse.n4js.cli.helper.CliCompileResult) ProcessResult(org.eclipse.n4js.cli.helper.ProcessResult) Test(org.junit.Test) AbstractCliCompileTest(org.eclipse.n4js.cli.helper.AbstractCliCompileTest)

Example 59 with ProcessResult

use of org.eclipse.n4js.cli.helper.ProcessResult in project n4js by eclipse.

the class ExecutionModesTest method testExecuteWithNativeESM.

@Test
public void testExecuteWithNativeESM() throws IOException {
    // the proband is configured for native ESM, so all we have to do is copy the "n4js-runtime":
    N4CliHelper.copyN4jsLibsToLocation(project.resolve(N4JSGlobals.NODE_MODULES), N4JSGlobals.N4JS_RUNTIME);
    CliCompileResult cliResult = n4jsc(COMPILE(project.toFile()), SUCCESS);
    assertEquals(cliResult.toString(), 0, cliResult.getExitCode());
    assertEquals(cliResult.toString(), 2, cliResult.getTranspiledFilesCount());
    Path fileMain = project.resolve("src-gen/Main.js");
    ProcessResult nodejsResult = nodejsRun(project, fileMain);
    assertEquals(nodejsResult.toString(), EXPECTED_OUTPUT, nodejsResult.getStdOut());
}
Also used : Path(java.nio.file.Path) CliCompileResult(org.eclipse.n4js.cli.helper.CliCompileResult) ProcessResult(org.eclipse.n4js.cli.helper.ProcessResult) Test(org.junit.Test) AbstractCliCompileTest(org.eclipse.n4js.cli.helper.AbstractCliCompileTest)

Example 60 with ProcessResult

use of org.eclipse.n4js.cli.helper.ProcessResult in project n4js by eclipse.

the class ExecutionModesTest method testExecuteWithEsmLibrary.

@Test
public void testExecuteWithEsmLibrary() throws IOException {
    // the proband is configured for native ESM, so we have to ...
    // A) patch the package.json:
    replaceInFile(project.resolve(N4JSGlobals.PACKAGE_JSON), // 1) remove "type":"module" from package.json
    Pair.of("\"type\": \"module\",", ""), // 2) add "esm" to dependencies
    Pair.of("\"dependencies\": {", "\"dependencies\": {\n\t\t\"esm\": \"3.2.25\","));
    // B) install library "esm":
    npmInstall(project);
    CliCompileResult cliResult = n4jsc(COMPILE(project.toFile()), SUCCESS);
    assertEquals(cliResult.toString(), 0, cliResult.getExitCode());
    assertEquals(cliResult.toString(), 2, cliResult.getTranspiledFilesCount());
    Path fileMain = project.resolve("src-gen/Main.js");
    ProcessResult nodejsResult = nodejsRun(project, new String[] { "-r", "esm" }, fileMain);
    assertEquals(nodejsResult.toString(), EXPECTED_OUTPUT, nodejsResult.getStdOut());
}
Also used : Path(java.nio.file.Path) CliCompileResult(org.eclipse.n4js.cli.helper.CliCompileResult) ProcessResult(org.eclipse.n4js.cli.helper.ProcessResult) Test(org.junit.Test) AbstractCliCompileTest(org.eclipse.n4js.cli.helper.AbstractCliCompileTest)

Aggregations

ProcessResult (org.eclipse.n4js.cli.helper.ProcessResult)64 Test (org.junit.Test)59 AbstractCliCompileTest (org.eclipse.n4js.cli.helper.AbstractCliCompileTest)55 Path (java.nio.file.Path)13 CliCompileResult (org.eclipse.n4js.cli.helper.CliCompileResult)12 Ignore (org.junit.Ignore)9 CliTools (org.eclipse.n4js.cli.helper.CliTools)5 N4jscOptions (org.eclipse.n4js.cli.N4jscOptions)4 N4jscTestOptions (org.eclipse.n4js.cli.N4jscTestOptions)4 File (java.io.File)3 AbstractCliJarTest (org.eclipse.n4js.cli.helper.AbstractCliJarTest)2 ArrayList (java.util.ArrayList)1 CliException (org.eclipse.n4js.cli.helper.CliTools.CliException)1 Project (org.eclipse.n4js.tests.codegen.Project)1 FileURI (org.eclipse.n4js.workspace.locations.FileURI)1 Xpect (org.eclipse.xpect.runner.Xpect)1