Skip to content

Commit

Permalink
fix(#2969): enable cage tests
Browse files Browse the repository at this point in the history
  • Loading branch information
maxonfjvipon committed Mar 21, 2024
1 parent eb40a6d commit 3d335b7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 43 deletions.
3 changes: 1 addition & 2 deletions eo-runtime/src/main/java/org/eolang/PhOnce.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ class PhOnce implements Phi {
* @param blank The string value
* @param expr The expression
*/
PhOnce(final Data<Phi> data, final Supplier<String> blank,
final Supplier<String> expr) {
PhOnce(final Data<Phi> data, final Supplier<String> blank, final Supplier<String> expr) {
this.object = new Data.Once<>(data, blank);
this.exp = expr;
}
Expand Down
33 changes: 19 additions & 14 deletions eo-runtime/src/test/eo/org/eolang/cage-tests.eo
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@
+version 0.0.0

# Test.
# @todo #2931:30min Enable cage tests. The tests were disabled because they stopped working
# when \rho attribute became immutable. Need to find out what's going on and enable them.
# Tests: infinite-loop-check, dataizes-encaged-object-lazily-third,
# dataizes-encaged-object-lazily-first
[] > writes-into-cage
# Object with free attribute.
[z] > a
Expand Down Expand Up @@ -76,19 +72,26 @@
42

# Test.
[] > dataizes-encaged-object-lazily-first
# The test seems not obvious, but it illustrates `cage` side effects well.
# Here when `sum.write (x.plus 1)` is dataized `sum` needs to check if given
# object has the valid form - `int.plus`. But `x.plus` does not have form at
# the beginning because attribute `plus` in not taken from `x` yet.
# So to get forma this `plus` is taken from `x`. As the result we get object
# `42.plus` which means `42.plus.^` is `42` and it won't be changed.
# That's why `x.write 7` rewrites value of `x` but does not affect `42.plus` and
# does not affect `sum`.
[] > dataizes-encaged-object-not-lazily-first
cage 0 > x
cage 0.plus > sum
eq. > res
eq. > @
seq
*
x.write 42
sum.write
x.plus 1
x.write 7
sum
8
TRUE > @
43

# Test.
[] > dataizes-encaged-object-lazily-second
Expand All @@ -105,11 +108,13 @@
8

# Test.
# The test seems not obvious, but you may see detailed explanation in
# `dataizes-encaged-object-not-lazily-first` test.
[] > dataizes-encaged-object-lazily-third
cage 0 > x
cage 0 > y
cage 0.plus > sum
eq. > res
eq. > @
seq
*
x.write 42
Expand All @@ -119,8 +124,7 @@
y.write 13
x.write 4
sum
17
nop > @
55

# Test.
[] > stores-abstract-object-into-cage
Expand Down Expand Up @@ -179,20 +183,21 @@
[value] > pyint
# Add.
[y] > add
pyint (value.plus y.value) > @
pyint (^.value.plus y.value) > @
cage pyint > x
cage > tmp
x.add
eq. > res
eq. > @
seq
*
x.write
pyint 0
tmp.write
x.add (pyint 1)
QQ.io.stdout
tmp.value
tmp.value
1
nop > @

# Test.
[] > catches-writing-objects-of-different-types
Expand Down
27 changes: 0 additions & 27 deletions eo-runtime/src/test/java/EOorg/EOeolang/EOcageTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@
/**
* Test case for {@link EOcage}.
* @since 0.19
* @todo #2931:30min Resolve test {@link EOcageTest#evaluatesLazily}. This test stopped working
* after introducing new rho logic. Need to decide either we can remove the test or we can resolve
* it somehow.
*/
final class EOcageTest {

Expand Down Expand Up @@ -156,30 +153,6 @@ void overwritesCagedObject() {
);
}

@Test
@Disabled
void evaluatesLazily() {
final Phi cage = new EOcage(Phi.Φ);
final Phi first = cage.copy();
EOcageTest.writeTo(first, new Data.ToPhi(3L));
final Phi second = cage.copy();
EOcageTest.writeTo(second, new Data.ToPhi(5L));
final Phi sum = cage.copy();
EOcageTest.writeTo(
sum,
new PhWith(
new PhCopy(new PhMethod(first, "plus")),
0, second
)
);
EOcageTest.writeTo(first, new Data.ToPhi(1L));
EOcageTest.writeTo(second, new Data.ToPhi(9L));
MatcherAssert.assertThat(
new Dataized(sum).take(Long.class),
Matchers.equalTo(10L)
);
}

@Test
void makesTrueCopy() {
final Phi first = new EOcage(Phi.Φ).copy();
Expand Down

2 comments on commit 3d335b7

@0pdd
Copy link

@0pdd 0pdd commented on 3d335b7 Mar 21, 2024

Choose a reason for hiding this comment

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

Puzzle 2931-033a49dd disappeared from eo-runtime/src/test/eo/org/eolang/cage-tests.eo), that's why I closed #2969. Please, remember that the puzzle was not necessarily removed in this particular commit. Maybe it happened earlier, but we discovered this fact only now.

@0pdd
Copy link

@0pdd 0pdd commented on 3d335b7 Mar 21, 2024

Choose a reason for hiding this comment

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

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