Skip to content

Commit

Permalink
Merge branch '__rultor'
Browse files Browse the repository at this point in the history
  • Loading branch information
rultor committed Apr 20, 2024
2 parents b2aed6a + 1e19306 commit 91f6cba
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 193 deletions.
15 changes: 12 additions & 3 deletions eo-runtime/src/main/eo/org/eolang/bytes.eo
Expand Up @@ -38,17 +38,26 @@
[start len] > slice /bytes

# Turn this chain of bytes into a string in UTF-8.
[] > as-string /string
[] > as-string
string ^ > @

# Turn this chain of eight bytes into an integer.
# If there are less or more than eight bytes, there will
# be an error returned.
[] > as-int /int
[] > as-int
if. > @
^.size.eq 8
int ^
error "Can't convert non 8 length bytes to int"

# Turn this chain of eight bytes into a float.
# If there are less or more than eight bytes, there will
# be an error returned.
[] > as-float /float
[] > as-float
if. > @
^.size.eq 8
float ^
error "Can't convert non 8 length bytes to float"

# Calculate bitwise and.
[b] > and /bytes
Expand Down
63 changes: 0 additions & 63 deletions eo-runtime/src/main/java/EOorg/EOeolang/EObytes$EOas_float.java

This file was deleted.

61 changes: 0 additions & 61 deletions eo-runtime/src/main/java/EOorg/EOeolang/EObytes$EOas_int.java

This file was deleted.

66 changes: 0 additions & 66 deletions eo-runtime/src/main/java/EOorg/EOeolang/EObytes$EOas_string.java

This file was deleted.

14 changes: 14 additions & 0 deletions eo-runtime/src/test/eo/org/eolang/bytes-tests.eo
Expand Up @@ -423,3 +423,17 @@
eq. > @
(-4294967296.as-bytes.or 1.as-bytes).as-int
-4294967295

# Test.
[] > bytes-of-wrong-size-as-int-of-returns-error
try > @
01-01-01-01.as-int
QQ.io.stdout e > [e]
false

# Test.
[] > bytes-of-wrong-size-as-float-returns-error
try > @
01-01-01-01.as-float
QQ.io.stdout e > [e]
false

0 comments on commit 91f6cba

Please sign in to comment.