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

Made eq attribute of standard objects int and float to meet the standards (IEEE 754) #2554

Merged
merged 21 commits into from
Oct 31, 2023
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: 1 addition & 5 deletions .codacy.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
# @todo #1326:30min Enable only necessary tests. Several checks
# are not available for the project. For example a lot of
# package name contains capital letter and such names are conventional.
exclude_paths:
- "eo-runtime/src/main/java/EOorg/EOeolang/EOrust.java"
- "eo-runtime/src/test/java/EOorg/EOeolang/EOintTest.java"
- "eo-maven-plugin/src/it/hash_package_layer/src/main/java/EOorg/EOeolang/Heaps.java"
- "eo-maven-plugin/src/it/hash_package_layer/src/main/java/EOorg/EOeolang/package-info.java"
exclude_paths:
42 changes: 30 additions & 12 deletions eo-runtime/src/main/eo/org/eolang/float.eo
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,39 @@
[] > float
# Tests that $ = x
[x] > eq
x > value!
x.as-bytes > x-as-bytes!
^.as-bytes > self-as-bytes!
nan.as-bytes > nan-as-bytes!
0.0.as-bytes > pos-zero-as-bytes!
-0.0.as-bytes > neg-zero-as-bytes!
if. > @
and.
or.
eq.
x-as-bytes
nan-as-bytes
eq.
^.as-bytes > self-as-bytes!
00-00-00-00-00-00-00-00 > zero-as-bytes!
self-as-bytes
nan-as-bytes
FALSE
or.
and.
or.
eq.
x-as-bytes
pos-zero-as-bytes
eq.
x-as-bytes
neg-zero-as-bytes
or.
eq.
self-as-bytes
pos-zero-as-bytes
eq.
self-as-bytes
neg-zero-as-bytes
eq.
value.as-bytes > x-as-bytes!
zero-as-bytes
eq.
^.neg.as-bytes
value.neg.as-bytes
eq.
self-as-bytes
x-as-bytes
self-as-bytes
x-as-bytes

# Tests that $ < x
[x] > lt
Expand Down
17 changes: 3 additions & 14 deletions eo-runtime/src/main/eo/org/eolang/int.eo
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,9 @@
[] > int
# Tests that $ = x
[x] > eq
if. > @
and.
eq.
^.as-bytes > self-as-bytes!
00-00-00-00-00-00-00-00 > zero-as-bytes!
eq.
x.as-bytes > x-as-bytes!
zero-as-bytes
eq.
^.neg.as-bytes
x.neg.as-bytes
eq.
self-as-bytes
x-as-bytes
eq. > @
^.as-bytes
x.as-bytes

# Tests that $ < x
[x] > lt
Expand Down
37 changes: 20 additions & 17 deletions eo-runtime/src/test/eo/org/eolang/float-tests.eo
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,15 @@
0.0
TRUE

[] > zero-not-equal-to-neg-zero
[] > zero-equal-to-neg-zero
eq. > @
0.0.eq -0.0
FALSE
TRUE

[] > neg-zero-not-equal-to-zero
[] > neg-zero-equal-to-zero
eq. > @
-0.0.eq 0.0
FALSE
TRUE

[] > zero-not-greater-that-neg-zero
eq. > @
Expand All @@ -155,32 +155,35 @@
-0.0.lt 0.0
FALSE

[] > zero-not-gte-neg-zero
[] > zero-gte-neg-zero
eq. > @
0.0.gte -0.0
FALSE
TRUE

[] > neg-zero-not-gte-zero
[] > neg-zero-gte-zero
eq. > @
-0.0.gte 0.0
FALSE
TRUE

[] > zero-not-lte-neg-zero
[] > zero-lte-neg-zero
eq. > @
0.0.lte -0.0
FALSE
TRUE

[] > neg-zero-not-lte-zero
[] > neg-zero-lte-zero
eq. > @
-0.0.lte 0.0
FALSE
TRUE

[] > float-zero-not-eq-to-int-zero
[] > float-zero-eq-to-int-zero
eq. > @
eq.
0.0
0
FALSE
0.0
0

[] > float-neg-zero-eq-to-int-zero
eq. > @
-0.0
0

[] > eq-true
eq. > @
Expand Down
12 changes: 4 additions & 8 deletions eo-runtime/src/test/eo/org/eolang/int-tests.eo
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,12 @@
0
TRUE

[] > int-zero-not-eq-to-float-zero
[] > int-zero-eq-to-float-zero
eq. > @
eq.
0
0.0
FALSE
TRUE

[] > eq-true
eq. > @
Expand All @@ -172,12 +172,8 @@

[] > compares-two-different-types
eq. > @
not.
eq.
42
"Hello!"
TRUE
"check int.eq.not string"
68.eq "12345678"
FALSE

[] > calculates-fibonacci-number-with-recursion
[n] > fibo
Expand Down
Loading