Skip to content

Commit

Permalink
Merge branch '__rultor'
Browse files Browse the repository at this point in the history
  • Loading branch information
rultor committed Aug 11, 2023
2 parents b64b485 + 34679a3 commit d95d171
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 24 deletions.
19 changes: 17 additions & 2 deletions eo-runtime/src/main/java/EOorg/EOeolang/EOio/EOstdout.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
*/
package EOorg.EOeolang.EOio;

import java.io.PrintStream;
import org.eolang.AtComposite;
import org.eolang.AtFree;
import org.eolang.Data;
Expand All @@ -44,18 +45,32 @@
@XmirObject(oname = "stdout")
public class EOstdout extends PhDefault {
/**
* Ctor.
* Default out print stream.
*/
private static final PrintStream OUT = System.out;

/**
* Default ctor.
* @param sigma Sigma
*/
public EOstdout(final Phi sigma) {
this(sigma, EOstdout.OUT);
}

/**
* Ctor for the tests.
* @param sigma Sigma
* @param out Stream to print
*/
EOstdout(final Phi sigma, final PrintStream out) {
super(sigma);
this.add("text", new AtFree());
this.add(
"φ",
new AtComposite(
this,
rho -> {
System.out.print(
out.print(
new Param(rho, "text").strong(String.class)
);
return new Data.ToPhi(true);
Expand Down
33 changes: 11 additions & 22 deletions eo-runtime/src/test/java/EOorg/EOeolang/EOio/EOstdoutTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
package EOorg.EOeolang.EOio;

import EOorg.EOeolang.EOseq;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import org.eolang.Data;
import org.eolang.Dataized;
import org.eolang.PhCopy;
Expand All @@ -36,28 +38,18 @@
import org.eolang.Phi;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import org.junitpioneer.jupiter.StdIo;
import org.junitpioneer.jupiter.StdOut;

/**
* Test case for {@link EOstdout}.
*
* @since 0.1
* @todo #2336:90min Enable all the tests in EOstdoutTest.
* The tests are disabled because they are flaky.
* The original issue is here:
* - https://github.com/objectionary/eo/issues/2371
* When the issue is fixed, enable the tests and remove the @Disabled annotation.
* Don't forget to remove the puzzle itself.
*/
public final class EOstdoutTest {

@Test
@Disabled("https://github.com/objectionary/eo/issues/2371")
public void printsString() {
final Phi format = new Data.ToPhi("Hello, world!\n");
final Phi phi = new PhWith(
Expand All @@ -71,11 +63,10 @@ public void printsString() {
);
}

@StdIo
@ParameterizedTest
@CsvSource({"lt", "gt", "lte", "gte"})
@Disabled("https://github.com/objectionary/eo/issues/2371")
public void doesNotPrintTwiceOnIntComparisonMethods(final String method, final StdOut out) {
public void doesNotPrintTwiceOnIntComparisonMethods(final String method) {
final ByteArrayOutputStream stream = new ByteArrayOutputStream();
final String str = "Hello world";
new Dataized(
new PhWith(
Expand All @@ -89,7 +80,7 @@ public void doesNotPrintTwiceOnIntComparisonMethods(final String method, final S
new EOseq(Phi.Φ),
0,
new PhWith(
new EOstdout(Phi.Φ),
new EOstdout(Phi.Φ, new PrintStream(stream)),
"text",
new Data.ToPhi(str)
)
Expand All @@ -100,17 +91,15 @@ public void doesNotPrintTwiceOnIntComparisonMethods(final String method, final S
)
).take();
MatcherAssert.assertThat(
out.capturedLines()[0],
stream.toString(),
Matchers.equalTo(str)
);
out.capturedLines();
}

@StdIo
@ParameterizedTest
@ParameterizedTest()
@CsvSource({"lt", "gt", "lte", "gte"})
@Disabled("https://github.com/objectionary/eo/issues/2371")
public void doesNotPrintTwiceOnFloatComparisonMethods(final String method, final StdOut out) {
public void doesNotPrintTwiceOnFloatComparisonMethods(final String method) {
final ByteArrayOutputStream stream = new ByteArrayOutputStream();
final String str = "Hello world";
new Dataized(
new PhWith(
Expand All @@ -124,7 +113,7 @@ public void doesNotPrintTwiceOnFloatComparisonMethods(final String method, final
new EOseq(Phi.Φ),
0,
new PhWith(
new EOstdout(Phi.Φ),
new EOstdout(Phi.Φ, new PrintStream(stream)),
"text",
new Data.ToPhi(str)
)
Expand All @@ -135,7 +124,7 @@ public void doesNotPrintTwiceOnFloatComparisonMethods(final String method, final
)
).take();
MatcherAssert.assertThat(
out.capturedLines()[0],
stream.toString(),
Matchers.equalTo(str)
);
}
Expand Down

1 comment on commit d95d171

@0pdd
Copy link

@0pdd 0pdd commented on d95d171 Aug 11, 2023

Choose a reason for hiding this comment

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

Puzzle 2336-caedc478 disappeared from eo-runtime/src/test/java/EOorg/EOeolang/EOio/EOstdoutTest.java), that's why I closed #2373. Please, remember that the puzzle was not necessarily removed in this particular commit. Maybe it happened earlier, but we discovered this fact only now.

Please sign in to comment.