Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(#2435): tests that uses memory #2450

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions eo-runtime/src/main/eo/org/eolang/heap.eo
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
memory 0 > next
plus. > new-next!
s
^.malloc.next
^.malloc.next.as-int
if. > @
gt.
new-next
Expand All @@ -47,7 +47,7 @@
^.malloc.next
new-next
0.plus
^.malloc.next
^.malloc.next.as-int

# Freed a block in memory, which is referred by the
# given pointer, which was earlier obtained with malloc().
Expand Down
1 change: 1 addition & 0 deletions eo-runtime/src/main/java/EOorg/EOeolang/AtMemoized.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public void put(final Phi phi) {
this.length
);
}
System.out.println(bytes);
maxonfjvipon marked this conversation as resolved.
Show resolved Hide resolved
this.object = new Data.ToPhi(bytes);
}

Expand Down
20 changes: 11 additions & 9 deletions eo-runtime/src/test/eo/org/eolang/bool-tests.eo
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,19 @@

[] > iterates-over-simple-counter
memory 0 > x
assert-that > res
assert-that > @
and.
eq.
x.write 5
5
eq.
11
while.
x.as-int.lt 10
[i]
^.^.^ > x
x.write (x.as-int.plus 1) > @
x.write > @
x.as-int.plus 1
11
$.equal-to TRUE
nop > @

[] > prints-nice-formulas
memory 0 > x
Expand Down Expand Up @@ -166,7 +165,7 @@

[] > complex-bool-expression-in-while
memory 0 > m
assert-that > res
assert-that > @
seq
m.write 5
while.
Expand All @@ -175,11 +174,14 @@
TRUE
[i]
seq > @
m.write (m.as-int.minus 1)
stdout (sprintf "%d\n" m.as-int)
m.write
m.as-int.minus 1
stdout
sprintf
"%d\n"
m.as-int
TRUE
$.equal-to TRUE
nop > @

[] > last-while-dataization-object
memory 0 > x
Expand Down
9 changes: 3 additions & 6 deletions eo-runtime/src/test/eo/org/eolang/heap-tests.eo
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
heap 1024 > h!
h.malloc 64 > p1!
h.malloc 32 > p2!
assert-that > res
assert-that > @
eq.
seq
QQ.io.stdout
Expand All @@ -57,24 +57,22 @@
p1
p2
$.equal-to FALSE
nop > @

[] > mallocs-do-not-overlap
heap 1024 > h!
h.malloc 64 > p1!
h.malloc 32 > p2!
assert-that > res
assert-that > @
or.
p2.gte
p1.plus 64
p2.lte
p1.minus 32
$.equal-to TRUE
nop > @

[] > malloc-return-error
heap 2 > h!
assert-that > res
assert-that > @
try
[]
h.malloc > @
Expand All @@ -84,7 +82,6 @@
nop
$.equal-to
"Allocation failed: bad alloc (not enough memory in the heap)"
nop > @

[] > write-and-read-without-error
heap 1024 > h
Expand Down
3 changes: 3 additions & 0 deletions eo-runtime/src/test/eo/org/eolang/tuple-tests.eo
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@
anArray.at 0
$.equal-to 100

# @todo #2435:30min Enable test with array-each. assert-that.array-each object
# uses memory. So after changing memory behaviour array-each started to work
# incorrectly. Need to fix the object and then enable the test
[] > tuple-as-a-bound-attribute-size-2
* > anArray
1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ void iteratesManyTimes() {
}

@Test
@Disabled
void loopsOverAbstractObjects() {
final Phi parent = new Parent(Phi.Φ);
final Phi toggle = new PhCopy(new PhMethod(parent, "toggle"));
Expand All @@ -123,7 +122,7 @@ void loopsOverAbstractObjects() {
MatcherAssert.assertThat(
new Dataized(
new PhWith(
new PhCopy(new PhMethod(toggle, "while")),
toggle.attr("as-bool").get().attr("while").get().copy(),
0, new Kid(Phi.Φ, toggle)
)
).take(),
Expand All @@ -132,10 +131,8 @@ void loopsOverAbstractObjects() {
}

@Test
@Disabled
void dataizesComplexBooleanToggle() {
final Phi parent = new Parent(Phi.Φ);
final Phi toggle = new PhMethod(parent, "toggle");
final Phi toggle = new PhMethod(new Parent(Phi.Φ), "toggle");
new Dataized(
new PhWith(
new PhMethod(toggle, "write"),
Expand Down
8 changes: 0 additions & 8 deletions eo-runtime/src/test/java/EOorg/EOeolang/EOmemoryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,6 @@
* Test case for {@link EOmemory}.
*
* @since 0.1
* @todo #2211:30min Enable tests that uses memory object.
* After memory started behave like bytes some tests had been stopped worked.
* Need to refactor and enable disabled tests that uses memory object:
* malloc-return-error, complex-bool-expression-in-while,
* EOboolEOwhileTest.dataizesComplexBooleanToggle,
* EOboolEOwhileTest.loopsOverAbstractObjects,
* malloc-returns-different-pointers, mallocs-do-not-overlap,
* tuple-as-a-bound-attribute-size-2, iterates-over-simple-counter
*/
public final class EOmemoryTest {

Expand Down
Loading