Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable the tests: deliversCleanOutput and executesJvmFullRun #2631

Merged
merged 12 commits into from
Nov 29, 2023
11 changes: 5 additions & 6 deletions eo-runtime/src/main/java/org/eolang/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

package org.eolang;

import EOorg.EOeolang.EOstring;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
Expand Down Expand Up @@ -172,6 +171,9 @@ private static boolean parse(final String opt) throws IOException {
* Run this opts.
* @param opts The opts left
* @throws Exception If fails
* @todo #2591:60min Make type casting when logging an app dataization result. The cast is
* necessary in this expression {@code new Data set(app).take()} in order to correctly
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@c71n93 I didn't really get what the expression in the {@code ...} means

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a code snippet.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@c71n93 I see but what new Data set(app) means?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maxonfjvipon It is an expression, that needs to be casted to an appropriate type.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@c71n93 is it a valid Java code?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@c71n93 maybe you meant Dataized instead of Data set?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maxonfjvipon Oh, yeah, didn't notice the mistake, thank you

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

* convert it to a string. This conversion it necessary for proper logging.
*/
private static void run(final List<String> opts) throws Exception {
final String path = new JavaPath(opts.get(0)).toString();
Expand All @@ -188,15 +190,12 @@ private static void run(final List<String> opts) throws Exception {
);
}
for (int idx = 1; idx < opts.size(); ++idx) {
final Phi phi = new EOstring(Phi.Φ);
final String arg = opts.get(idx);
phi.attr("Δ").put(new Data.Value<>(arg));
app.attr(0).put(phi);
app.attr(0).put(new Data.ToPhi(opts.get(idx)));
}
Main.LOGGER.info(
String.format(
"%n---%n%s",
new Dataized(app).take().toString()
Arrays.toString(new Dataized(app).take())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@c71n93 let's add a puzzle here so we won't forget to make up with some type casting here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maxonfjvipon done. Could you check, please?

)
);
}
Expand Down
10 changes: 2 additions & 8 deletions eo-runtime/src/test/java/org/eolang/MainTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,15 @@
import java.io.IOException;
import java.nio.channels.Channels;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

/**
* Test case for {@link Main}.
*
* @since 0.1
* @todo #2437:30min Enable the tests: {@link MainTest#deliversCleanOutput()} and
* {@link MainTest#executesJvmFullRun()}. These tests were disabled because we got rid of delta
* attribute in data primitives so code in the tests became invalid. Need to fix it and enable the
* tests. Don't forget to remove the puzzle.
*/
final class MainTest {

Expand All @@ -66,16 +62,14 @@ void printsHelp() throws Exception {
}

@Test
@Disabled
void deliversCleanOutput() {
MatcherAssert.assertThat(
MainTest.exec("org.eolang.io.stdout", "Hello!"),
Matchers.equalTo(String.format("Hello!%n---%ntrue%n"))
Matchers.equalTo(String.format("Hello!%n---%n%s%n", Arrays.toString(new byte[]{0x01})))
);
}

@Test
@Disabled
void executesJvmFullRun() throws Exception {
MatcherAssert.assertThat(
MainTest.exec("--verbose", "org.eolang.io.stdout", "Hello, dude!"),
Expand Down
Loading