Skip to content

Commit

Permalink
fix(#2557): tests + infinites
Browse files Browse the repository at this point in the history
  • Loading branch information
maxonfjvipon committed Oct 26, 2023
1 parent 7ac6393 commit 494869e
Show file tree
Hide file tree
Showing 12 changed files with 124 additions and 253 deletions.
32 changes: 17 additions & 15 deletions eo-runtime/src/main/eo/org/eolang/negative-infinity.eo
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,19 @@

[num] > is-nan-or-zero
or. > @
is-nan num
num.eq -0.0
num.eq 0.0
or.
or.
is-nan num
num.eq -0.0
num.eq 0.0
num.eq 0
if. > @
is-nan-or-zero value
nan
if.
is-num-gt-zero value
negative-infinity
positive-infinity
if.
is-num-gt-zero value
negative-infinity
positive-infinity

# Sum of $ and x
[x] > plus
Expand Down Expand Up @@ -116,12 +118,11 @@
not. > @
num.eq num
if. > @
if.
or.
is-nan value
value.as-bytes.eq neg-inf-as-bytes
nan
negative-infinity
or.
is-nan value
value.as-bytes.eq neg-inf-as-bytes
nan
negative-infinity

# Quotient of the division of $ by x
[x] > div
Expand All @@ -133,8 +134,9 @@

[num] > is-nan-or-infinite
or. > @
is-nan num
num.eq positive-infinity
or.
is-nan num
num.eq positive-infinity
num.eq negative-infinity

[num] > is-num-gte-zero
Expand Down
13 changes: 8 additions & 5 deletions eo-runtime/src/main/eo/org/eolang/positive-infinity.eo
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,11 @@

[num] > is-nan-or-zero
or. > @
is-nan num
num.eq -0.0
num.eq 0.0
or.
or.
is-nan num
num.eq -0.0
num.eq 0.0
num.eq 0

[num] > is-num-gt-zero
Expand Down Expand Up @@ -132,8 +134,9 @@

[num] > is-nan-or-infinite
or. > @
is-nan num
num.eq positive-infinity
or.
is-nan num
num.eq positive-infinity
num.eq negative-infinity

[num] > is-num-gte-zero
Expand Down
6 changes: 4 additions & 2 deletions eo-runtime/src/main/java/EOorg/EOeolang/EOfloat$EOplus.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@ public class EOfloat$EOplus extends PhDefault {
new AtComposite(
this,
rho -> new Data.ToPhi(
new Param(rho).strong(Double.class)
+ new Param(rho, "x").strong(Double.class)
Double.sum(
new Param(rho).strong(Double.class),
new Param(rho, "x").strong(Double.class)
)
)
)
);
Expand Down
6 changes: 4 additions & 2 deletions eo-runtime/src/main/java/EOorg/EOeolang/EOint$EOplus.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@ public class EOint$EOplus extends PhDefault {
new AtComposite(
this,
rho -> new Data.ToPhi(
new Param(rho).strong(Long.class)
+ new Param(rho, "x").strong(Long.class)
Long.sum(
new Param(rho).strong(Long.class),
new Param(rho, "x").strong(Long.class)
)
)
)
);
Expand Down
47 changes: 0 additions & 47 deletions eo-runtime/src/test/eo/org/eolang/bool-tests.eo
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,6 @@
TRUE
42

[] > joins-many-ands
and. > @
TRUE
5.lt 10
4.gt -6
TRUE
0.eq 0

[] > forks-on-condition
eq. > @
if.
Expand All @@ -67,45 +59,6 @@
x.as-int.plus 1
11

# tests that bool.and stops calculations if its i'th
# object is false (including the base object)
[] > and-short-circuiting
memory 0 > mFirst
memory 0 > mThird
and. > res
not.
and.
(mFirst.write 1).eq 100
(mFirst.write 2).eq 2
(mFirst.write 3).eq 3
not.
and.
(mThird.write 1).eq 1
(mThird.write 2).eq 2
(mThird.write 3).eq 300
(mThird.write 4).eq 4
mFirst.eq 1
mThird.eq 3
nop > @

# tests that bool.or stops calculations if its i'th
# object is true (including the base object)
[] > or-short-circuiting
memory 0 > mFirst
memory 0 > mThird
and. > @
or.
(mFirst.write 1).eq 1
mFirst.write 2
mFirst.write 3
or.
(mThird.write 1).eq 100
(mThird.write 2).eq 200
(mThird.write 3).eq 3
mThird.write 4
mFirst.eq 1
mThird.eq 3

[] > compares-bool-to-bytes
and. > @
TRUE.eq 01-
Expand Down
29 changes: 0 additions & 29 deletions eo-runtime/src/test/eo/org/eolang/bytes-tests.eo
Original file line number Diff line number Diff line change
Expand Up @@ -162,15 +162,6 @@
-7.as-bytes.and (7.as-bytes)
-2.as-bytes

[] > and-with-vararg
eq. > @
as-int.
and.
0.as-bytes
5.as-bytes
10.as-bytes
0

[] > or-with-zero
not. > @
eq.
Expand All @@ -195,16 +186,6 @@
-7.as-bytes.or (23.as-bytes)
0.as-bytes

[] > or-with-vararg
not. > @
eq.
as-int.
or.
256.as-bytes
5.as-bytes
10.as-bytes
-1

[] > xor-with-zero
not. > @
eq.
Expand All @@ -229,16 +210,6 @@
-36.as-bytes.xor (43.as-bytes)
8.as-bytes

[] > xor-with-vararg
not. > @
eq.
as-int.
xor.
256.as-bytes
5.as-bytes
10.as-bytes
-1

[] > not-with-zero
not. > @
eq.
Expand Down
58 changes: 11 additions & 47 deletions eo-runtime/src/test/eo/org/eolang/float-tests.eo
Original file line number Diff line number Diff line change
Expand Up @@ -232,44 +232,25 @@
0.311985
-0.1792353825

[] > times-multiple
eq. > @
times.
-0.5745
0.311985
3.232
-2.532
1.4667591307996803

[] > add-test
eq. > @
plus.
574.5
311.985
886.485

[] > add-multiple-test
eq. > @
plus.
574.5
311.985
-101.1
1.001
786.386

[] > add-wrong-args
eq. > @
try
[]
plus. > @
574.5
311
-101.1
1.001
[e]
e > @
nop
"The 1th argument of 'float.plus' is not a(n) Double: 311"
not. > @
eq.
try
[]
plus. > @
42.5
24
[e]
e > @
nop
66.5

[] > neg-test
eq. > @
Expand All @@ -283,30 +264,13 @@
311.985
262.515

[] > sub-multiple-test
eq. > @
minus.
574.5
311.985
-24.347
3542.2238
-3255.3618

[] > div-test
eq. > @
div.
15.5
0.5
31.0

[] > div-multiple
eq. > @
div.
15.5
0.5
0.2
155.0

[] > zero-div-zero-as-bytes-is-equal-to-nan-as-bytes
eq. > @
(0.0.div 0.0).as-bytes
Expand Down
13 changes: 7 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 @@ -89,12 +89,13 @@
p2.sub 1 > p3
eq. > @
and.
(p1.block 6).write ("HELLO!".as-bytes)
eq.
p2.block
2
[b] (b.as-string > @)
"O!"
and.
(p1.block 6).write ("HELLO!".as-bytes)
eq.
p2.block
2
[b] (b.as-string > @)
"O!"
eq.
p3.block
2
Expand Down
Loading

0 comments on commit 494869e

Please sign in to comment.