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 10, 2023
2 parents f02535d + 78c7db8 commit 287925b
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 121 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ private Optimization optimization(final ForeignTojo tojo, final Optimization com
}

/**
* Make path with optimized XML file after parsing.
* Make a path with optimized XML file after parsing.
*
* @param xml Optimized xml
* @param file EO file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public TjSmart foreign() {
* @param mojo Mojo to execute.
* @param <T> Template for descendants of Mojo.
* @return Workspace after executing Mojo.
* @throws java.io.IOException If some problem with filesystem have happened.
* @throws java.io.IOException If some problem with filesystem has happened.
*/
public <T extends AbstractMojo> FakeMaven execute(final Class<T> mojo) throws IOException {
if (this.defaults) {
Expand Down
175 changes: 74 additions & 101 deletions eo-runtime/src/test/eo/org/eolang/cage-tests.eo
Original file line number Diff line number Diff line change
Expand Up @@ -29,120 +29,89 @@

[] > writes-into-cage
[z] > a
cage 0 > x
nop > @
assert-that
seq
x.write
a 7
x.z
$.equal-to 7
cage a > x
assert-that > @
seq
x.write
a 7
x.z
$.equal-to 7

[] > avoid-infinite-loop
cage 0 > x
cage > x
TRUE.if
x' > copy
nop > @
assert-that
seq
x.write 42
copy.<
x.write (7.plus copy)
x
$.equal-to 49

[] > avoid-infinite-loop-second-case
[first second] > pair
[head tail] > add
pair head tail > @
cage 0 > list
list' > copy
nop > @
assert-that
seq
list.write (pair 1 0)
copy.<
list.write (add 2 copy)
list.second.second
$.equal-to 0
assert-that > @
seq
x.write
TRUE.if 1 0
copy.<
x.write
TRUE.if copy 0
x
$.equal-to 1

[] > cage-nested-objects
cage 0 > c
c' > copy
[x] > dummy
x > @
nop > @
assert-that
seq
c.write (dummy 42)
copy.<
c.write (dummy copy)
c.x.x
$.equal-to 42

[] > overwrites-caged-object-with-integer
cage 0 > c
[] > t
42 > attr
nop > @
assert-that
seq
c.write t
c.attr
c.write 66
c
$.equal-to 66
cage dummy > c
c' > copy
assert-that > @
seq
c.write (dummy 42)
copy.<
c.write (dummy copy)
c.x.x
$.equal-to 42

[] > dataizes-encaged-object-lazily-first
cage 0 > x
cage 0 > sum
nop > @
assert-that
seq
x.write 42
sum.write (x.plus 1)
x.write 7
sum
$.equal-to 8
cage 0.plus > sum
assert-that > @
seq
x.write 42
sum.write
x.plus 1
x.write 7
sum
$.equal-to 8

[] > dataizes-encaged-object-lazily-second
cage 0 > x
cage 0 > sum
nop > @
assert-that
seq
x.write 42
sum.write (1.plus x)
x.write 7
sum
$.equal-to 8
cage 0.plus > sum
assert-that > @
seq
x.write 42
sum.write
1.plus x
x.write 7
sum
$.equal-to 8

[] > dataizes-encaged-object-lazily-third
cage 0 > x
cage 0 > y
cage 0 > sum
nop > @
assert-that
seq
x.write 42
y.write 7
sum.write (x.plus y)
y.write 13
x.write 4
sum
$.equal-to 17
cage 0.plus > sum
assert-that > @
seq
x.write 42
y.write 7
sum.write
x.plus y
y.write 13
x.write 4
sum
$.equal-to 17

[] > stores-abstract-object-into-cage
cage 0 > c
nop > @
assert-that
seq
write.
c
[x]
112 > @
c.@
42
$.equal-to 112
assert-that > @
seq
cage > c
[x]
112 > @
c.@
42
$.equal-to 112

[] > multi-layer-volatility
memory 0 > ma
Expand Down Expand Up @@ -173,16 +142,20 @@
cb.z.plus 40

[] > infinite-loop-check
cage 0 > x
cage 0 > tmp
[value] > pyint
[y] > add
pyint (value.plus (y.value)) > @
nop > @
cage pyint > x
cage > tmp
x.add
assert-that > @
seq
x.write (pyint 0)
tmp.write (x.add (pyint 1))
tmp.value.eq 1
x.write
pyint 0
tmp.write
x.add (pyint 1)
tmp.value
$.equal-to 1

[] > catches-writing-objects-of-different-types
cage 5 > cge
Expand Down
33 changes: 15 additions & 18 deletions eo-runtime/src/test/java/EOorg/EOeolang/EOcageTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,12 @@
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

/**
* Test case for {@link EOcage}.
*
* @since 0.19
* @todo #1307:30min Refactor and enable cage tests. Since object {@link EOcage}
* prohibit writing objects of different types to itself (for more information
* see <a href="https://github.com/objectionary/eo/issues/1307">the ticket</a>)
* some of its tests were disabled because they fail. Need to resolve them and
* enable. List of disabled tests: EOcageTest.overwritesCagedObject,
* EOcageTest.writesItselfToItself, avoid-infinite-loop, cage-nested-objects,
* avoid-infinite-loop-second-case, dataizes-encaged-object-lazily-first,
* calling-caged-function, dataizes-encaged-object-lazily-second,
* dataizes-encaged-object-lazily-third. infinite-loop-checkt,
* overwrites-caged-object-with-integer, rho-of-add-should-not-change,
* stores-abstract-object-into-cage, writes-into-cage.
*/
final class EOcageTest {

Expand All @@ -79,10 +67,14 @@ void checksThatEmptyCageHasIdentity() {
}

@Test
@Disabled
void writesItselfToItself() {
final Phi cage = new EOcage(Phi.Φ);
EOcageTest.writeTo(cage, new Data.ToPhi(1L));
EOcageTest.writeTo(
cage,
new PhWith(
new EOcage(Phi.Φ), 0, new Data.ToPhi(1L)
)
);
final Phi first = cage.copy();
EOcageTest.writeTo(cage, first);
final Phi second = cage.copy();
Expand Down Expand Up @@ -139,7 +131,6 @@ void writesDummyToItself() {
}

@Test
@Disabled
void overwritesCagedObject() {
final Phi cage = new EOcage(Phi.Φ);
EOcageTest.writeTo(
Expand All @@ -153,10 +144,16 @@ void overwritesCagedObject() {
new Dataized(new PhMethod(cage, "x")).take(Long.class),
Matchers.equalTo(1L)
);
EOcageTest.writeTo(cage, new Data.ToPhi(0L));
EOcageTest.writeTo(
cage,
new PhWith(
new EOcageTest.Dummy(Phi.Φ),
0, new Data.ToPhi(2L)
)
);
MatcherAssert.assertThat(
new Dataized(cage).take(Long.class),
Matchers.equalTo(0L)
new Dataized(new PhMethod(cage, "x")).take(Long.class),
Matchers.equalTo(2L)
);
}

Expand Down

1 comment on commit 287925b

@0pdd
Copy link

@0pdd 0pdd commented on 287925b Aug 10, 2023

Choose a reason for hiding this comment

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

Puzzle 1307-4a15f9bc disappeared from eo-runtime/src/test/java/EOorg/EOeolang/EOcageTest.java), that's why I closed #2335. 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.