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

new memory behaviour #2189

Merged
merged 3 commits into from
Jul 5, 2023
Merged
Changes from all 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
79 changes: 79 additions & 0 deletions eo-runtime/src/test/eo/org/eolang/memory-tests.eo
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@
+package org.eolang
+version 0.0.0

# @todo #761:30min Let's make sure memory can only accept one "type" of data primitives.
# If we try to write a float into a memory that was initialized with an int, we should
# get an error. The same goes for strings and booleans. We should also make sure that
# we can't write a string that is longer than the memory size. We should also make sure
# that we can't write a number that is bigger than the memory size. And etc.
# We can also implement memory in EO instead of Java and let it use ram object.
# Let's not forget to update the "Origins of Objects" paper.
[] > writes-into-memory
memory 0 > x
assert-that > @
Expand Down Expand Up @@ -88,3 +95,75 @@
b.write 20
a
$.equal-to 10

[] > memory-is-strictly-typed-bool-error-overflow
memory FALSE > m
nop > @
assert-that
try
[]
m.write 86124867.88 > @
[e]
e > @
nop
$.equal-to "Not enough memory to write: expected <1> byte, got <2^61>"

[] > memory-is-strictly-typed-string-error-overflow
memory "Hello" > m
nop > @
assert-that
try
[]
m.write "Much longer string!" > @
[e]
e > @
nop
$.equal-to "Not enough memory to write: expected <5>, got <20>"

[] > memory-is-strictly-typed-int
memory 12248 > m
nop > @
assert-that
try
[]
m.write 2556 > @
[e]
e > @
nop
$.equal-to 2556

[] > memory-is-strictly-typed-float
memory 245.88 > m
nop > @
assert-that
try
[]
m.write 82.22 > @
[e]
e > @
nop
$.equal-to 82.22

[] > memory-is-strictly-typed-string
memory "Hello" > m
nop > @
assert-that
try
[]
m.write "Hell" > @
[e]
e > @
nop
$.equal-to "Hell"

[] > memory-is-strictly-typed-bool
memory FALSE > m
nop > @
assert-that
try
[]
m.write TRUE > @
[e]
e > @
nop
$.equal-to TRUE