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());
}
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());
}
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());
}
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());
}
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());
}
Aggregations