Skip to content

Commit

Permalink
objectionary#2834 add broken tests for seq
Browse files Browse the repository at this point in the history
  • Loading branch information
c71n93 committed Feb 2, 2024
1 parent bfd4e77 commit 6a7f0b3
Show file tree
Hide file tree
Showing 2 changed files with 121 additions and 0 deletions.
25 changes: 25 additions & 0 deletions eo-runtime/src/test/eo/org/eolang/seq-tests.eo
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,28 @@
counter.as-int.plus 1
counter.as-int
1

# Test.
[] > seq-single-dataization-int-equal-than-test
memory 0 > x
eq. > @
seq
*
x.write 0
x.write (x.as-int.plus 1)
x.as-int
1

# Test.
[] > seq-single-dataization-int-equal-to-test-bug
memory 0 > x
eq. > nop
seq
*
at.
* 0 1
x.as-int
x.write (x.as-int.plus 1)
x.as-int
1
TRUE > @
96 changes: 96 additions & 0 deletions eo-runtime/src/test/java/EOorg/EOeolang/EOseqTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@
*/
package EOorg.EOeolang;

import org.eolang.AtComposite;
import org.eolang.Data;
import org.eolang.Dataized;
import org.eolang.PhCopy;
import org.eolang.PhDefault;
import org.eolang.PhMethod;
import org.eolang.PhWith;
import org.eolang.Phi;
import org.hamcrest.MatcherAssert;
Expand Down Expand Up @@ -81,4 +85,96 @@ public void calculatesAndReturnsObject() {
Matchers.startsWith("Hello")
);
}

/**
* Test
*
* [] > parent
* memory 0 > counter
* seq > @
* *
* at.
* * 0 1
* counter.as-int
* counter.write (counter.as-int.plus 1)
* counter.as-int
*
* @since 1.0
*/
@Test
public void calculatesWithTupleAndReturnsObject() {
final Phi counter = new PhMethod(new Parent(Phi.Φ), "counter");
new Dataized(
new PhWith(
new PhCopy(
new PhMethod(counter, "write")
),
0, new Data.ToPhi(0L)
)
).take();
final Phi get = new PhWith(
new PhWith(
new EOtuple$EOempty(Phi.Φ).attr("with").get().copy(),
0, new Data.ToPhi(0L)
).attr("with").get().copy(),
0, new Data.ToPhi(1L)
).attr("at").get().copy();
get.attr(0).put(counter.attr("as-int").get());
final Phi increment = new PhWith(
new PhCopy(
new PhMethod(counter, "write")
),
0,
new PhWith(
counter.attr("as-int").get().attr("plus").get(),
0,
new Data.ToPhi(1L)
)
);
MatcherAssert.assertThat(
new Dataized(
new PhWith(
new EOseq(Phi.Φ),
0,
new PhWith(
new PhWith(
new PhWith(
new EOtuple$EOempty(Phi.Φ).attr("with").get().copy(),
0,
get
).attr("with").get().copy(),
0,
increment
).attr("with").get().copy(),
0,
counter.attr("as-int").get()
)
)
).take(Long.class),
Matchers.equalTo(1L)
);
}

/**
* Parent Phi.
*
* @since 1.0
*/
private static final class Parent extends PhDefault {
/**
* Ctor.
* @param sigma Sigma
*/
Parent(final Phi sigma) {
super(sigma);
this.add(
"counter",
new AtComposite(
this,
EOmemory::new
)
);
}
}

}

0 comments on commit 6a7f0b3

Please sign in to comment.