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 9, 2023
2 parents 6309ea9 + 1dc20da commit 4717b03
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 18 deletions.
15 changes: 9 additions & 6 deletions eo-runtime/src/main/eo/org/eolang/float.eo
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
[] > float
# Tests that $ = x
[x] > eq
x > value!
if. > @
and.
eq.
Expand All @@ -39,7 +40,7 @@
zero-as-bytes
eq.
^.neg.as-bytes
x.neg.as-bytes
value.neg.as-bytes
eq.
self-as-bytes
x-as-bytes
Expand All @@ -48,25 +49,27 @@
[x] > lt
gt. > @
plus.
x
neg.
^
x
0.0

# Tests that $ ≤ x
[x] > lte
x > value!
or. > @
^.eq x
^.lt x
^.eq value
^.lt value

# Tests that $ > x
[x] > gt /bool

# Tests that $ ≥ x
[x] > gte
x > value!
or. > @
^.eq x
^.gt x
^.eq value
^.gt value

# Multiplication of $ and x
[x...] > times /float
Expand Down
9 changes: 1 addition & 8 deletions eo-runtime/src/main/java/EOorg/EOeolang/EOio/EOstdout.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
*/
package EOorg.EOeolang.EOio;

import java.io.PrintStream;
import org.eolang.AtComposite;
import org.eolang.AtFree;
import org.eolang.Data;
Expand All @@ -44,12 +43,6 @@
*/
@XmirObject(oname = "stdout")
public class EOstdout extends PhDefault {

/**
* Default out.
*/
private static final PrintStream OUT = System.out;

/**
* Ctor.
* @param sigma Sigma
Expand All @@ -62,7 +55,7 @@ public EOstdout(final Phi sigma) {
new AtComposite(
this,
rho -> {
EOstdout.OUT.print(
System.out.print(
new Param(rho, "text").strong(String.class)
);
return new Data.ToPhi(true);
Expand Down
4 changes: 0 additions & 4 deletions eo-runtime/src/test/eo/org/eolang/seq-tests.eo
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@
+package org.eolang
+version 0.0.0

# @todo #1299:60min Implement test that will
# check output of stdout. That should proven
# that there is no double printage, when
# methods lt., gt., lte., gte. are called.
[] > seq-single-dataization-float-less-than-test
memory 0.0 > counter
assert-that > @
Expand Down
72 changes: 72 additions & 0 deletions eo-runtime/src/test/java/EOorg/EOeolang/EOio/EOstdoutTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,20 @@
*/
package EOorg.EOeolang.EOio;

import EOorg.EOeolang.EOseq;
import org.eolang.Data;
import org.eolang.Dataized;
import org.eolang.PhCopy;
import org.eolang.PhMethod;
import org.eolang.PhWith;
import org.eolang.Phi;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
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}.
Expand All @@ -57,4 +63,70 @@ public void printsString() {
);
}

@StdIo
@ParameterizedTest
@CsvSource({"lt", "gt", "lte", "gte"})
public void doesNotPrintTwiceOnIntComparisonMethods(final String method, final StdOut out) {
final String str = "Hello world";
new Dataized(
new PhWith(
new PhMethod(
new Data.ToPhi(1L),
method
),
0,
new PhWith(
new PhWith(
new EOseq(Phi.Φ),
0,
new PhWith(
new EOstdout(Phi.Φ),
"text",
new Data.ToPhi(str)
)
),
0,
new Data.ToPhi(2L)
)
)
).take();
MatcherAssert.assertThat(
out.capturedLines()[0],
Matchers.equalTo(str)
);
out.capturedLines();
}

@StdIo
@ParameterizedTest
@CsvSource({"lt", "gt", "lte", "gte"})
public void doesNotPrintTwiceOnFloatComparisonMethods(final String method, final StdOut out) {
final String str = "Hello world";
new Dataized(
new PhWith(
new PhMethod(
new Data.ToPhi(1.0),
method
),
0,
new PhWith(
new PhWith(
new EOseq(Phi.Φ),
0,
new PhWith(
new EOstdout(Phi.Φ),
"text",
new Data.ToPhi(str)
)
),
0,
new Data.ToPhi(3.0)
)
)
).take();
MatcherAssert.assertThat(
out.capturedLines()[0],
Matchers.equalTo(str)
);
}
}

1 comment on commit 4717b03

@0pdd
Copy link

@0pdd 0pdd commented on 4717b03 Aug 9, 2023

Choose a reason for hiding this comment

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

Puzzle 1299-fdd4d593 disappeared from eo-runtime/src/test/eo/org/eolang/seq-tests.eo), that's why I closed #1953. 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.