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

feat(#3621): introduced malloc.empty #3622

Merged
merged 2 commits into from
Dec 8, 2024
Merged
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions eo-runtime/src/main/eo/org/eolang/malloc.eo
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@
# Here the void attribute in the scope object is memory-block object which provides API to write
# and read data to the memory.
[] > malloc
# Allocates empty block in memory.
[scope] > empty
malloc.of > @
0
scope

# Allocates block in memory for given `object`. After allocation the provided object is dataized
# and the data are written into memory.
[object scope] > for
Expand Down
14 changes: 8 additions & 6 deletions eo-runtime/src/test/eo/org/eolang/malloc-tests.eo
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@
[f]
malloc.of > second
1
[s] >>
f.put (f.as-number.plus 1) > @
f.put (f.as-number.plus 1) > [s] >>
seq > @
*
second
Expand Down Expand Up @@ -168,8 +167,7 @@
[b]
malloc.of > @
10
[m] >>
b.put (m.size.eq 10) > @
b.put (m.size.eq 10) > [m] >>

# This unit test is supposed to check the functionality of the corresponding object.
[] > malloc-writes-and-reads
Expand Down Expand Up @@ -229,8 +227,7 @@
0
malloc.of
0
[m]
m.size > @
m.size > [m]

# This unit test is supposed to check the functionality of the corresponding object.
[] > malloc-increases-block-size
Expand Down Expand Up @@ -263,3 +260,8 @@
malloc.of > @
1
m.resized -1 > [m]

# This unit test is supposed to check the functionality of the corresponding object.
[] > malloc-empty-is-empty
malloc.empty > @
m.size.eq 0 > [m]
Loading