From c83b83094e0369f2915d0d67ca8ff162ec1606fc Mon Sep 17 00:00:00 2001 From: Roman Korostinskiy <70313618+c71n93@users.noreply.github.com> Date: Tue, 24 Oct 2023 15:02:32 +0300 Subject: [PATCH 01/21] #2547 make int.eq an atom --- eo-runtime/src/main/eo/org/eolang/int.eo | 16 +---- .../main/java/EOorg/EOeolang/EOint$EOeq.java | 60 +++++++++++++++++++ 2 files changed, 61 insertions(+), 15 deletions(-) create mode 100644 eo-runtime/src/main/java/EOorg/EOeolang/EOint$EOeq.java diff --git a/eo-runtime/src/main/eo/org/eolang/int.eo b/eo-runtime/src/main/eo/org/eolang/int.eo index b6652178bc..615c0d3691 100644 --- a/eo-runtime/src/main/eo/org/eolang/int.eo +++ b/eo-runtime/src/main/eo/org/eolang/int.eo @@ -28,21 +28,7 @@ [] > 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 + [x] > eq /bool # Tests that $ < x [x] > lt diff --git a/eo-runtime/src/main/java/EOorg/EOeolang/EOint$EOeq.java b/eo-runtime/src/main/java/EOorg/EOeolang/EOint$EOeq.java new file mode 100644 index 0000000000..2d55e78d4d --- /dev/null +++ b/eo-runtime/src/main/java/EOorg/EOeolang/EOint$EOeq.java @@ -0,0 +1,60 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2016-2023 Objectionary.com + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/* + * @checkstyle PackageNameCheck (4 lines) + */ +package EOorg.EOeolang; + +import org.eolang.*; + +/** + * GT. + * + * @since 1.0 + * @checkstyle TypeNameCheck (5 lines) + */ +@Versionized +@XmirObject(oname = "int.eq") +public class EOint$EOeq extends PhDefault { + + /** + * Ctor. + * @param sigma Sigma + */ + public EOint$EOeq(final Phi sigma) { + super(sigma); + this.add("x", new AtFree()); + this.add( + "φ", + new AtComposite( + this, + rho -> new Data.ToPhi( + (long)(new Param(rho).strong(Long.class)) + == new Param(rho, "x").strong(Long.class) + ) + ) + ); + } +} From 01c7c88adf5a94ce1115944d2e54c60842dd0013 Mon Sep 17 00:00:00 2001 From: Roman Korostinskiy <70313618+c71n93@users.noreply.github.com> Date: Tue, 24 Oct 2023 16:37:45 +0300 Subject: [PATCH 02/21] #2547 turn off broken tests and add todo --- eo-runtime/src/test/eo/org/eolang/int-tests.eo | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/eo-runtime/src/test/eo/org/eolang/int-tests.eo b/eo-runtime/src/test/eo/org/eolang/int-tests.eo index 210159d0a8..1b048520ec 100644 --- a/eo-runtime/src/test/eo/org/eolang/int-tests.eo +++ b/eo-runtime/src/test/eo/org/eolang/int-tests.eo @@ -26,6 +26,10 @@ +package org.eolang +version 0.0.0 +# @todo #2547:30min After changing int.eq to atom some tests are broken due to types contradiction. +# Now int.eq can only compare an int object with another int object (to compare as bytes, use as-bytes attribute). +# Resolve and enable folowing tests: as-bytes-equals-to-int, int-equal-to-nan-and-infinites-is-false, +# int-zero-not-eq-to-float-zero [] > less-true eq. > @ lt. @@ -129,7 +133,7 @@ "check int.gte.not" [] > int-equal-to-nan-and-infinites-is-false - eq. > @ + eq. > res and. (0.eq nan).eq FALSE (0.eq positive-infinity).eq FALSE @@ -138,6 +142,7 @@ (42.eq positive-infinity).eq FALSE (42.eq negative-infinity).eq FALSE TRUE + nop > @ [] > zero-eq-to-zero eq. > @ @@ -147,11 +152,12 @@ TRUE [] > int-zero-not-eq-to-float-zero - eq. > @ + eq. > res eq. 0 0.0 FALSE + nop > @ [] > eq-true eq. > @ @@ -269,9 +275,10 @@ 42 [] > as-bytes-equals-to-int - eq. > @ + eq. > res 42 42.as-bytes + nop > @ [] > as-bytes-equals-to-int-backwards eq. > @ From 93e3352c7533ff3b550e66ca985a94885273bc45 Mon Sep 17 00:00:00 2001 From: Roman Korostinskiy <70313618+c71n93@users.noreply.github.com> Date: Tue, 24 Oct 2023 17:05:37 +0300 Subject: [PATCH 03/21] #2547 make float.eq an atom --- eo-runtime/src/main/eo/org/eolang/float.eo | 17 +---- .../java/EOorg/EOeolang/EOfloat$EOeq.java | 68 +++++++++++++++++++ 2 files changed, 69 insertions(+), 16 deletions(-) create mode 100644 eo-runtime/src/main/java/EOorg/EOeolang/EOfloat$EOeq.java diff --git a/eo-runtime/src/main/eo/org/eolang/float.eo b/eo-runtime/src/main/eo/org/eolang/float.eo index 74926c97a5..155cb5596b 100644 --- a/eo-runtime/src/main/eo/org/eolang/float.eo +++ b/eo-runtime/src/main/eo/org/eolang/float.eo @@ -28,22 +28,7 @@ [] > float # Tests that $ = x - [x] > eq - x > value! - if. > @ - and. - eq. - ^.as-bytes > self-as-bytes! - 00-00-00-00-00-00-00-00 > 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 + [x] > eq /bool # Tests that $ < x [x] > lt diff --git a/eo-runtime/src/main/java/EOorg/EOeolang/EOfloat$EOeq.java b/eo-runtime/src/main/java/EOorg/EOeolang/EOfloat$EOeq.java new file mode 100644 index 0000000000..5a928d71e9 --- /dev/null +++ b/eo-runtime/src/main/java/EOorg/EOeolang/EOfloat$EOeq.java @@ -0,0 +1,68 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2016-2023 Objectionary.com + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/* + * @checkstyle PackageNameCheck (4 lines) + */ +package EOorg.EOeolang; + +import org.eolang.AtComposite; +import org.eolang.AtFree; +import org.eolang.Data; +import org.eolang.Param; +import org.eolang.PhDefault; +import org.eolang.Phi; +import org.eolang.Versionized; +import org.eolang.XmirObject; + +/** + * GT. + * + * @since 1.0 + * @checkstyle TypeNameCheck (5 lines) + */ +@Versionized +@XmirObject(oname = "float.eq") +public class EOfloat$EOeq extends PhDefault { + + /** + * Ctor. + * @param sigma Sigma + */ + public EOfloat$EOeq(final Phi sigma) { + super(sigma); + this.add("x", new AtFree()); + this.add( + "φ", + new AtComposite( + this, + rho -> new Data.ToPhi( + (double)(new Param(rho).strong(Double.class)) + == new Param(rho, "x").strong(Double.class) + ) + ) + ); + } + +} From 80a0dc9a08fe8420d76016dd57fc9770e5ae6f11 Mon Sep 17 00:00:00 2001 From: Roman Korostinskiy <70313618+c71n93@users.noreply.github.com> Date: Tue, 24 Oct 2023 18:15:51 +0300 Subject: [PATCH 04/21] #2547 turn off broken float tests and add todo --- .../src/test/eo/org/eolang/float-tests.eo | 33 +++++++++++-------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/eo-runtime/src/test/eo/org/eolang/float-tests.eo b/eo-runtime/src/test/eo/org/eolang/float-tests.eo index 26905fde41..5f7a89fc8b 100644 --- a/eo-runtime/src/test/eo/org/eolang/float-tests.eo +++ b/eo-runtime/src/test/eo/org/eolang/float-tests.eo @@ -26,6 +26,9 @@ +tests +version 0.0.0 +# @todo #2547:30min After changing float.eq to atom some tests are broken due to types contradiction. +# Now float.eq can only compare an float object with another float object (to compare as bytes, use as-bytes attribute). +# Resolve and enable folowing tests: compares-two-different-types, float-zero-not-eq-to-int-zero [] > less-true eq. > @ -10.5.lt 50.3 @@ -125,15 +128,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. > @ @@ -155,32 +158,33 @@ -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 - eq. > @ + eq. > res eq. 0.0 0 FALSE + nop > @ [] > eq-true eq. > @ @@ -193,9 +197,10 @@ FALSE [] > compares-two-different-types - eq. > @ + eq. > res 3.14.eq "Hello" FALSE + nop > @ [] > times-by-zero eq. > @ From c1d254a675513ea2c216705c3131c739e4c0d239 Mon Sep 17 00:00:00 2001 From: Roman Korostinskiy <70313618+c71n93@users.noreply.github.com> Date: Tue, 24 Oct 2023 18:34:27 +0300 Subject: [PATCH 05/21] #2547 turn off some infinity tests --- .../src/test/eo/org/eolang/float-tests.eo | 18 +++++++++++++----- eo-runtime/src/test/eo/org/eolang/int-tests.eo | 2 +- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/eo-runtime/src/test/eo/org/eolang/float-tests.eo b/eo-runtime/src/test/eo/org/eolang/float-tests.eo index 5f7a89fc8b..aa331b13d4 100644 --- a/eo-runtime/src/test/eo/org/eolang/float-tests.eo +++ b/eo-runtime/src/test/eo/org/eolang/float-tests.eo @@ -26,7 +26,7 @@ +tests +version 0.0.0 -# @todo #2547:30min After changing float.eq to atom some tests are broken due to types contradiction. +# @todo #2547:30min After changing float.eq to atom some tests have broken due to types contradiction. # Now float.eq can only compare an float object with another float object (to compare as bytes, use as-bytes attribute). # Resolve and enable folowing tests: compares-two-different-types, float-zero-not-eq-to-int-zero [] > less-true @@ -382,9 +382,10 @@ pos-inf [] > positive-float-minus-positive-infinity - eq. > @ + eq. > res 42.5.minus positive-infinity negative-infinity + nop > @ [] > positive-float-times-positive-infinity positive-infinity > pos-inf @@ -403,10 +404,15 @@ -42.5.plus pos-inf pos-inf +# @todo #2547:30min After changing float.eq to atom some tests that used positve-infinity and negative-infinity +# have broken due to types contradiction. Resolve and enable folowing tests: negative-float-minus-negative-infinity, +# negative-float-minus-positive-infinity, positive-float-minus-negative-infinity, +# positive-float-minus-positive-infinity [] > negative-float-minus-positive-infinity - eq. > @ + eq. > res -42.5.minus positive-infinity negative-infinity + nop > @ [] > negative-float-times-positive-infinity eq. > @ @@ -425,9 +431,10 @@ neg-inf [] > positive-float-minus-negative-infinity - eq. > @ + eq. > res 42.5.minus negative-infinity positive-infinity + nop > @ [] > positive-float-times-negative-infinity negative-infinity > neg-inf @@ -447,9 +454,10 @@ neg-inf [] > negative-float-minus-negative-infinity - eq. > @ + eq. > res -42.5.minus negative-infinity positive-infinity + nop > @ [] > negative-float-times-negative-infinity eq. > @ diff --git a/eo-runtime/src/test/eo/org/eolang/int-tests.eo b/eo-runtime/src/test/eo/org/eolang/int-tests.eo index 1b048520ec..744fdfe786 100644 --- a/eo-runtime/src/test/eo/org/eolang/int-tests.eo +++ b/eo-runtime/src/test/eo/org/eolang/int-tests.eo @@ -26,7 +26,7 @@ +package org.eolang +version 0.0.0 -# @todo #2547:30min After changing int.eq to atom some tests are broken due to types contradiction. +# @todo #2547:30min After changing int.eq to atom some tests have broken due to types contradiction. # Now int.eq can only compare an int object with another int object (to compare as bytes, use as-bytes attribute). # Resolve and enable folowing tests: as-bytes-equals-to-int, int-equal-to-nan-and-infinites-is-false, # int-zero-not-eq-to-float-zero From d583bbbd6bcd56b2d253dc8db550b64b5d76668b Mon Sep 17 00:00:00 2001 From: Roman Korostinskiy <70313618+c71n93@users.noreply.github.com> Date: Tue, 24 Oct 2023 19:15:53 +0300 Subject: [PATCH 06/21] #2547 fix qulice --- .../java/EOorg/EOeolang/EOfloat$EOeq.java | 16 ++++++------- .../main/java/EOorg/EOeolang/EOint$EOeq.java | 24 ++++++++++++------- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/eo-runtime/src/main/java/EOorg/EOeolang/EOfloat$EOeq.java b/eo-runtime/src/main/java/EOorg/EOeolang/EOfloat$EOeq.java index 5a928d71e9..929e63ec59 100644 --- a/eo-runtime/src/main/java/EOorg/EOeolang/EOfloat$EOeq.java +++ b/eo-runtime/src/main/java/EOorg/EOeolang/EOfloat$EOeq.java @@ -54,15 +54,15 @@ public class EOfloat$EOeq extends PhDefault { super(sigma); this.add("x", new AtFree()); this.add( - "φ", - new AtComposite( - this, - rho -> new Data.ToPhi( - (double)(new Param(rho).strong(Double.class)) - == new Param(rho, "x").strong(Double.class) - ) + "φ", + new AtComposite( + this, + rho -> new Data.ToPhi( + (double) (new Param(rho).strong(Double.class)) == new Param( + rho, "x" + ).strong(Double.class) ) + ) ); } - } diff --git a/eo-runtime/src/main/java/EOorg/EOeolang/EOint$EOeq.java b/eo-runtime/src/main/java/EOorg/EOeolang/EOint$EOeq.java index 2d55e78d4d..ca2188efd4 100644 --- a/eo-runtime/src/main/java/EOorg/EOeolang/EOint$EOeq.java +++ b/eo-runtime/src/main/java/EOorg/EOeolang/EOint$EOeq.java @@ -27,7 +27,14 @@ */ package EOorg.EOeolang; -import org.eolang.*; +import org.eolang.AtComposite; +import org.eolang.AtFree; +import org.eolang.Data; +import org.eolang.Param; +import org.eolang.PhDefault; +import org.eolang.Phi; +import org.eolang.Versionized; +import org.eolang.XmirObject; /** * GT. @@ -47,14 +54,15 @@ public class EOint$EOeq extends PhDefault { super(sigma); this.add("x", new AtFree()); this.add( - "φ", - new AtComposite( - this, - rho -> new Data.ToPhi( - (long)(new Param(rho).strong(Long.class)) - == new Param(rho, "x").strong(Long.class) - ) + "φ", + new AtComposite( + this, + rho -> new Data.ToPhi( + (long) (new Param(rho).strong(Long.class)) == new Param( + rho, "x" + ).strong(Long.class) ) + ) ); } } From 67eb95b5b8d002bfb09c9f9bba06bccfd862d8ac Mon Sep 17 00:00:00 2001 From: Roman Korostinskiy <70313618+c71n93@users.noreply.github.com> Date: Wed, 25 Oct 2023 11:40:12 +0300 Subject: [PATCH 07/21] #2547 fix codacy --- .codacy.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.codacy.yml b/.codacy.yml index cfc888a748..6f56d3f74c 100644 --- a/.codacy.yml +++ b/.codacy.yml @@ -2,7 +2,5 @@ # 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" \ No newline at end of file + - "eo-runtime/src/main/java/EOorg/EOeolang/EOfloat$EOeq.java" + - "eo-runtime/src/main/java/EOorg/EOeolang/EOint$EOeq.java" \ No newline at end of file From c22035be763e76fc6e070d056ae312087059b0a9 Mon Sep 17 00:00:00 2001 From: Roman Korostinskiy <70313618+c71n93@users.noreply.github.com> Date: Wed, 25 Oct 2023 12:37:44 +0300 Subject: [PATCH 08/21] #2547 fix description --- eo-runtime/src/main/java/EOorg/EOeolang/EOfloat$EOeq.java | 4 ++-- eo-runtime/src/main/java/EOorg/EOeolang/EOint$EOeq.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/eo-runtime/src/main/java/EOorg/EOeolang/EOfloat$EOeq.java b/eo-runtime/src/main/java/EOorg/EOeolang/EOfloat$EOeq.java index 929e63ec59..06b7d5768b 100644 --- a/eo-runtime/src/main/java/EOorg/EOeolang/EOfloat$EOeq.java +++ b/eo-runtime/src/main/java/EOorg/EOeolang/EOfloat$EOeq.java @@ -37,9 +37,9 @@ import org.eolang.XmirObject; /** - * GT. + * EQ. * - * @since 1.0 + * @since 0.33 * @checkstyle TypeNameCheck (5 lines) */ @Versionized diff --git a/eo-runtime/src/main/java/EOorg/EOeolang/EOint$EOeq.java b/eo-runtime/src/main/java/EOorg/EOeolang/EOint$EOeq.java index ca2188efd4..ba8c5f2776 100644 --- a/eo-runtime/src/main/java/EOorg/EOeolang/EOint$EOeq.java +++ b/eo-runtime/src/main/java/EOorg/EOeolang/EOint$EOeq.java @@ -37,9 +37,9 @@ import org.eolang.XmirObject; /** - * GT. + * EQ. * - * @since 1.0 + * @since 0.33 * @checkstyle TypeNameCheck (5 lines) */ @Versionized From aa85dc0ea2ab97a58324638b922b9bbf5db61ee7 Mon Sep 17 00:00:00 2001 From: Roman Korostinskiy <70313618+c71n93@users.noreply.github.com> Date: Thu, 26 Oct 2023 18:01:44 +0300 Subject: [PATCH 09/21] #2547 make reinterpret type conversion for int.eq --- .../main/java/EOorg/EOeolang/EOint$EOeq.java | 5 ++--- .../src/main/java/org/eolang/Param.java | 21 +++++++++++++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/eo-runtime/src/main/java/EOorg/EOeolang/EOint$EOeq.java b/eo-runtime/src/main/java/EOorg/EOeolang/EOint$EOeq.java index ba8c5f2776..a686a4217c 100644 --- a/eo-runtime/src/main/java/EOorg/EOeolang/EOint$EOeq.java +++ b/eo-runtime/src/main/java/EOorg/EOeolang/EOint$EOeq.java @@ -58,9 +58,8 @@ public class EOint$EOeq extends PhDefault { new AtComposite( this, rho -> new Data.ToPhi( - (long) (new Param(rho).strong(Long.class)) == new Param( - rho, "x" - ).strong(Long.class) + new Param(rho).asBytesAppropriate(Long.BYTES).asNumber(Long.class) == (long) + new Param(rho, "x").asBytesAppropriate(Long.BYTES).asNumber(Long.class) ) ) ); diff --git a/eo-runtime/src/main/java/org/eolang/Param.java b/eo-runtime/src/main/java/org/eolang/Param.java index b5f2f85037..7c0b88b91a 100644 --- a/eo-runtime/src/main/java/org/eolang/Param.java +++ b/eo-runtime/src/main/java/org/eolang/Param.java @@ -134,4 +134,25 @@ public Bytes asBytes() { } return res; } + + /** + * Extracts BYTES of any type and checks if they have the appropriate size. + * @param appropriate The appropriate size. + * @return Bytes. + */ + public Bytes asBytesAppropriate(final int appropriate) { + final Bytes bytes = this.asBytes(); + final int size = bytes.take().length; + if (size != appropriate) { + throw new ExFailure( + String.format( + "The size of argument '.%s' is %d bytes, not '%d' as expected", + this.attr, + size, + appropriate + ) + ); + } + return bytes; + } } From e9aac1e497111db2545e78df945f14fd284c5c70 Mon Sep 17 00:00:00 2001 From: Roman Korostinskiy <70313618+c71n93@users.noreply.github.com> Date: Thu, 26 Oct 2023 18:06:05 +0300 Subject: [PATCH 10/21] #2547 resolve int tests --- eo-runtime/src/test/eo/org/eolang/int-tests.eo | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/eo-runtime/src/test/eo/org/eolang/int-tests.eo b/eo-runtime/src/test/eo/org/eolang/int-tests.eo index 744fdfe786..7c5bf0e8b3 100644 --- a/eo-runtime/src/test/eo/org/eolang/int-tests.eo +++ b/eo-runtime/src/test/eo/org/eolang/int-tests.eo @@ -26,10 +26,6 @@ +package org.eolang +version 0.0.0 -# @todo #2547:30min After changing int.eq to atom some tests have broken due to types contradiction. -# Now int.eq can only compare an int object with another int object (to compare as bytes, use as-bytes attribute). -# Resolve and enable folowing tests: as-bytes-equals-to-int, int-equal-to-nan-and-infinites-is-false, -# int-zero-not-eq-to-float-zero [] > less-true eq. > @ lt. @@ -133,7 +129,7 @@ "check int.gte.not" [] > int-equal-to-nan-and-infinites-is-false - eq. > res + eq. > @ and. (0.eq nan).eq FALSE (0.eq positive-infinity).eq FALSE @@ -142,7 +138,6 @@ (42.eq positive-infinity).eq FALSE (42.eq negative-infinity).eq FALSE TRUE - nop > @ [] > zero-eq-to-zero eq. > @ @@ -151,13 +146,12 @@ 0 TRUE -[] > int-zero-not-eq-to-float-zero - eq. > res +[] > int-zero-eq-to-float-zero + eq. > @ eq. 0 0.0 - FALSE - nop > @ + TRUE [] > eq-true eq. > @ @@ -275,10 +269,9 @@ 42 [] > as-bytes-equals-to-int - eq. > res + eq. > @ 42 42.as-bytes - nop > @ [] > as-bytes-equals-to-int-backwards eq. > @ From b26849cbe407c425fad483813a73663ce6ee8718 Mon Sep 17 00:00:00 2001 From: Roman Korostinskiy <70313618+c71n93@users.noreply.github.com> Date: Thu, 26 Oct 2023 18:14:08 +0300 Subject: [PATCH 11/21] #2547 make reinterpret type conversion for float.eq --- eo-runtime/src/main/java/EOorg/EOeolang/EOfloat$EOeq.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/eo-runtime/src/main/java/EOorg/EOeolang/EOfloat$EOeq.java b/eo-runtime/src/main/java/EOorg/EOeolang/EOfloat$EOeq.java index 06b7d5768b..3a8275b202 100644 --- a/eo-runtime/src/main/java/EOorg/EOeolang/EOfloat$EOeq.java +++ b/eo-runtime/src/main/java/EOorg/EOeolang/EOfloat$EOeq.java @@ -58,9 +58,8 @@ public class EOfloat$EOeq extends PhDefault { new AtComposite( this, rho -> new Data.ToPhi( - (double) (new Param(rho).strong(Double.class)) == new Param( - rho, "x" - ).strong(Double.class) + new Param(rho).asBytesAppropriate(Double.BYTES).asNumber(Double.class) == (double) + new Param(rho, "x").asBytesAppropriate(Double.BYTES).asNumber(Double.class) ) ) ); From 836218afd24cb21b78a0c28dd8d3d786260c007a Mon Sep 17 00:00:00 2001 From: Roman Korostinskiy <70313618+c71n93@users.noreply.github.com> Date: Thu, 26 Oct 2023 18:25:19 +0300 Subject: [PATCH 12/21] #2547 resolve float tests --- .../src/test/eo/org/eolang/float-tests.eo | 29 +++++++++---------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/eo-runtime/src/test/eo/org/eolang/float-tests.eo b/eo-runtime/src/test/eo/org/eolang/float-tests.eo index aa331b13d4..4093698c83 100644 --- a/eo-runtime/src/test/eo/org/eolang/float-tests.eo +++ b/eo-runtime/src/test/eo/org/eolang/float-tests.eo @@ -26,9 +26,6 @@ +tests +version 0.0.0 -# @todo #2547:30min After changing float.eq to atom some tests have broken due to types contradiction. -# Now float.eq can only compare an float object with another float object (to compare as bytes, use as-bytes attribute). -# Resolve and enable folowing tests: compares-two-different-types, float-zero-not-eq-to-int-zero [] > less-true eq. > @ -10.5.lt 50.3 @@ -178,13 +175,10 @@ -0.0.lte 0.0 TRUE -[] > float-zero-not-eq-to-int-zero - eq. > res - eq. - 0.0 - 0 - FALSE - nop > @ +[] > float-zero-eq-to-int-zero + eq. > @ + 0.0 + 0 [] > eq-true eq. > @ @@ -197,10 +191,14 @@ FALSE [] > compares-two-different-types - eq. > res - 3.14.eq "Hello" - FALSE - nop > @ + eq. > @ + try + [] + 3.14.eq "Hello" > @ + [e] + e > @ + nop + "The size of argument '.x' is 5 bytes, not '8' as expected" [] > times-by-zero eq. > @ @@ -454,10 +452,9 @@ neg-inf [] > negative-float-minus-negative-infinity - eq. > res + eq. > @ -42.5.minus negative-infinity positive-infinity - nop > @ [] > negative-float-times-negative-infinity eq. > @ From 4afea182a4525a76b4f747838927b2c0b44e580f Mon Sep 17 00:00:00 2001 From: Roman Korostinskiy <70313618+c71n93@users.noreply.github.com> Date: Thu, 26 Oct 2023 18:30:48 +0300 Subject: [PATCH 13/21] #2547 resolve infinite tests --- eo-runtime/src/test/eo/org/eolang/float-tests.eo | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/eo-runtime/src/test/eo/org/eolang/float-tests.eo b/eo-runtime/src/test/eo/org/eolang/float-tests.eo index 4093698c83..824ffb7de7 100644 --- a/eo-runtime/src/test/eo/org/eolang/float-tests.eo +++ b/eo-runtime/src/test/eo/org/eolang/float-tests.eo @@ -380,10 +380,9 @@ pos-inf [] > positive-float-minus-positive-infinity - eq. > res + eq. > @ 42.5.minus positive-infinity negative-infinity - nop > @ [] > positive-float-times-positive-infinity positive-infinity > pos-inf @@ -402,15 +401,10 @@ -42.5.plus pos-inf pos-inf -# @todo #2547:30min After changing float.eq to atom some tests that used positve-infinity and negative-infinity -# have broken due to types contradiction. Resolve and enable folowing tests: negative-float-minus-negative-infinity, -# negative-float-minus-positive-infinity, positive-float-minus-negative-infinity, -# positive-float-minus-positive-infinity [] > negative-float-minus-positive-infinity - eq. > res + eq. > @ -42.5.minus positive-infinity negative-infinity - nop > @ [] > negative-float-times-positive-infinity eq. > @ @@ -429,10 +423,9 @@ neg-inf [] > positive-float-minus-negative-infinity - eq. > res + eq. > @ 42.5.minus negative-infinity positive-infinity - nop > @ [] > positive-float-times-negative-infinity negative-infinity > neg-inf From a88f3b1d4999c65fe109ec38c4b5e90d7fcf4a42 Mon Sep 17 00:00:00 2001 From: Roman Korostinskiy <70313618+c71n93@users.noreply.github.com> Date: Thu, 26 Oct 2023 18:51:04 +0300 Subject: [PATCH 14/21] #2547 add additional tests --- .../main/java/EOorg/EOeolang/EOint$EOeq.java | 4 +-- .../src/test/eo/org/eolang/float-tests.eo | 17 ++++++++++- .../src/test/eo/org/eolang/int-tests.eo | 30 ++++++++++++++----- 3 files changed, 41 insertions(+), 10 deletions(-) diff --git a/eo-runtime/src/main/java/EOorg/EOeolang/EOint$EOeq.java b/eo-runtime/src/main/java/EOorg/EOeolang/EOint$EOeq.java index a686a4217c..b1ef7a036a 100644 --- a/eo-runtime/src/main/java/EOorg/EOeolang/EOint$EOeq.java +++ b/eo-runtime/src/main/java/EOorg/EOeolang/EOint$EOeq.java @@ -58,8 +58,8 @@ public class EOint$EOeq extends PhDefault { new AtComposite( this, rho -> new Data.ToPhi( - new Param(rho).asBytesAppropriate(Long.BYTES).asNumber(Long.class) == (long) - new Param(rho, "x").asBytesAppropriate(Long.BYTES).asNumber(Long.class) + new Param(rho).asBytesAppropriate(Long.BYTES).asNumber(Long.class) == (long) + new Param(rho, "x").asBytesAppropriate(Long.BYTES).asNumber(Long.class) ) ) ); diff --git a/eo-runtime/src/test/eo/org/eolang/float-tests.eo b/eo-runtime/src/test/eo/org/eolang/float-tests.eo index 824ffb7de7..fee9d1f543 100644 --- a/eo-runtime/src/test/eo/org/eolang/float-tests.eo +++ b/eo-runtime/src/test/eo/org/eolang/float-tests.eo @@ -190,7 +190,7 @@ 123.5.eq 42.4 FALSE -[] > compares-two-different-types +[] > compares-two-different-types-wrong-size-less eq. > @ try [] @@ -200,6 +200,21 @@ nop "The size of argument '.x' is 5 bytes, not '8' as expected" +[] > compares-two-different-types-wrong-bigger + eq. > @ + try + [] + 2.71.eq "123456789" > @ + [e] + e > @ + nop + "The size of argument '.x' is 9 bytes, not '8' as expected" + +[] > compares-two-different-types-right-size + eq. > @ + 2.71.eq "12345678" + FALSE + [] > times-by-zero eq. > @ times. diff --git a/eo-runtime/src/test/eo/org/eolang/int-tests.eo b/eo-runtime/src/test/eo/org/eolang/int-tests.eo index 7c5bf0e8b3..e1dc0281c4 100644 --- a/eo-runtime/src/test/eo/org/eolang/int-tests.eo +++ b/eo-runtime/src/test/eo/org/eolang/int-tests.eo @@ -170,14 +170,30 @@ TRUE "check int.eq.not" -[] > compares-two-different-types +[] > compares-two-different-types-wrong-size-less eq. > @ - not. - eq. - 42 - "Hello!" - TRUE - "check int.eq.not string" + try + [] + 42.eq "Hello" > @ + [e] + e > @ + nop + "The size of argument '.x' is 5 bytes, not '8' as expected" + +[] > compares-two-different-types-wrong-size-bigger + eq. > @ + try + [] + 414.eq "123456789" > @ + [e] + e > @ + nop + "The size of argument '.x' is 9 bytes, not '8' as expected" + +[] > compares-two-different-types-right-size + eq. > @ + 68.eq "12345678" + FALSE [] > calculates-fibonacci-number-with-recursion [n] > fibo From 0f749feb66d171319f818a68fd65251597681986 Mon Sep 17 00:00:00 2001 From: Roman Korostinskiy <70313618+c71n93@users.noreply.github.com> Date: Fri, 27 Oct 2023 14:20:17 +0300 Subject: [PATCH 15/21] #2547 fix naming --- .../src/main/java/EOorg/EOeolang/EOfloat$EOeq.java | 4 ++-- .../src/main/java/EOorg/EOeolang/EOint$EOeq.java | 4 ++-- eo-runtime/src/main/java/org/eolang/Param.java | 12 ++++++------ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/eo-runtime/src/main/java/EOorg/EOeolang/EOfloat$EOeq.java b/eo-runtime/src/main/java/EOorg/EOeolang/EOfloat$EOeq.java index 3a8275b202..16e3783539 100644 --- a/eo-runtime/src/main/java/EOorg/EOeolang/EOfloat$EOeq.java +++ b/eo-runtime/src/main/java/EOorg/EOeolang/EOfloat$EOeq.java @@ -58,8 +58,8 @@ public class EOfloat$EOeq extends PhDefault { new AtComposite( this, rho -> new Data.ToPhi( - new Param(rho).asBytesAppropriate(Double.BYTES).asNumber(Double.class) == (double) - new Param(rho, "x").asBytesAppropriate(Double.BYTES).asNumber(Double.class) + new Param(rho).asStrictBytes(Double.BYTES).asNumber(Double.class) == (double) + new Param(rho, "x").asStrictBytes(Double.BYTES).asNumber(Double.class) ) ) ); diff --git a/eo-runtime/src/main/java/EOorg/EOeolang/EOint$EOeq.java b/eo-runtime/src/main/java/EOorg/EOeolang/EOint$EOeq.java index b1ef7a036a..98634be7a5 100644 --- a/eo-runtime/src/main/java/EOorg/EOeolang/EOint$EOeq.java +++ b/eo-runtime/src/main/java/EOorg/EOeolang/EOint$EOeq.java @@ -58,8 +58,8 @@ public class EOint$EOeq extends PhDefault { new AtComposite( this, rho -> new Data.ToPhi( - new Param(rho).asBytesAppropriate(Long.BYTES).asNumber(Long.class) == (long) - new Param(rho, "x").asBytesAppropriate(Long.BYTES).asNumber(Long.class) + new Param(rho).asStrictBytes(Long.BYTES).asNumber(Long.class) == (long) + new Param(rho, "x").asStrictBytes(Long.BYTES).asNumber(Long.class) ) ) ); diff --git a/eo-runtime/src/main/java/org/eolang/Param.java b/eo-runtime/src/main/java/org/eolang/Param.java index 7c0b88b91a..4422c47906 100644 --- a/eo-runtime/src/main/java/org/eolang/Param.java +++ b/eo-runtime/src/main/java/org/eolang/Param.java @@ -137,19 +137,19 @@ public Bytes asBytes() { /** * Extracts BYTES of any type and checks if they have the appropriate size. - * @param appropriate The appropriate size. + * @param size The appropriate size. * @return Bytes. */ - public Bytes asBytesAppropriate(final int appropriate) { + public Bytes asStrictBytes(final int size) { final Bytes bytes = this.asBytes(); - final int size = bytes.take().length; - if (size != appropriate) { + final int length = bytes.take().length; + if (length != size) { throw new ExFailure( String.format( "The size of argument '.%s' is %d bytes, not '%d' as expected", this.attr, - size, - appropriate + length, + size ) ); } From 7d85d315db2f09fb5e4bce54271095fb99edace5 Mon Sep 17 00:00:00 2001 From: Roman Korostinskiy <70313618+c71n93@users.noreply.github.com> Date: Mon, 30 Oct 2023 12:46:20 +0300 Subject: [PATCH 16/21] #2547 implement int.eq in EO --- eo-runtime/src/main/eo/org/eolang/int.eo | 5 +- .../main/java/EOorg/EOeolang/EOint$EOeq.java | 67 ------------------- .../src/test/eo/org/eolang/int-tests.eo | 22 +----- 3 files changed, 5 insertions(+), 89 deletions(-) delete mode 100644 eo-runtime/src/main/java/EOorg/EOeolang/EOint$EOeq.java diff --git a/eo-runtime/src/main/eo/org/eolang/int.eo b/eo-runtime/src/main/eo/org/eolang/int.eo index 615c0d3691..401c613f3f 100644 --- a/eo-runtime/src/main/eo/org/eolang/int.eo +++ b/eo-runtime/src/main/eo/org/eolang/int.eo @@ -28,7 +28,10 @@ [] > int # Tests that $ = x - [x] > eq /bool + [x] > eq + eq. > @ + ^.as-bytes + x.as-bytes # Tests that $ < x [x] > lt diff --git a/eo-runtime/src/main/java/EOorg/EOeolang/EOint$EOeq.java b/eo-runtime/src/main/java/EOorg/EOeolang/EOint$EOeq.java deleted file mode 100644 index 98634be7a5..0000000000 --- a/eo-runtime/src/main/java/EOorg/EOeolang/EOint$EOeq.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2016-2023 Objectionary.com - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* - * @checkstyle PackageNameCheck (4 lines) - */ -package EOorg.EOeolang; - -import org.eolang.AtComposite; -import org.eolang.AtFree; -import org.eolang.Data; -import org.eolang.Param; -import org.eolang.PhDefault; -import org.eolang.Phi; -import org.eolang.Versionized; -import org.eolang.XmirObject; - -/** - * EQ. - * - * @since 0.33 - * @checkstyle TypeNameCheck (5 lines) - */ -@Versionized -@XmirObject(oname = "int.eq") -public class EOint$EOeq extends PhDefault { - - /** - * Ctor. - * @param sigma Sigma - */ - public EOint$EOeq(final Phi sigma) { - super(sigma); - this.add("x", new AtFree()); - this.add( - "φ", - new AtComposite( - this, - rho -> new Data.ToPhi( - new Param(rho).asStrictBytes(Long.BYTES).asNumber(Long.class) == (long) - new Param(rho, "x").asStrictBytes(Long.BYTES).asNumber(Long.class) - ) - ) - ); - } -} diff --git a/eo-runtime/src/test/eo/org/eolang/int-tests.eo b/eo-runtime/src/test/eo/org/eolang/int-tests.eo index e1dc0281c4..1af3e82c70 100644 --- a/eo-runtime/src/test/eo/org/eolang/int-tests.eo +++ b/eo-runtime/src/test/eo/org/eolang/int-tests.eo @@ -170,27 +170,7 @@ TRUE "check int.eq.not" -[] > compares-two-different-types-wrong-size-less - eq. > @ - try - [] - 42.eq "Hello" > @ - [e] - e > @ - nop - "The size of argument '.x' is 5 bytes, not '8' as expected" - -[] > compares-two-different-types-wrong-size-bigger - eq. > @ - try - [] - 414.eq "123456789" > @ - [e] - e > @ - nop - "The size of argument '.x' is 9 bytes, not '8' as expected" - -[] > compares-two-different-types-right-size +[] > compares-two-different-types-size eq. > @ 68.eq "12345678" FALSE From 5805dc7d5422c6a2f69ba4bc84c98bb1bada027a Mon Sep 17 00:00:00 2001 From: Roman Korostinskiy <70313618+c71n93@users.noreply.github.com> Date: Mon, 30 Oct 2023 13:37:51 +0300 Subject: [PATCH 17/21] #2547 implement float.eq in EO --- eo-runtime/src/main/eo/org/eolang/float.eo | 36 +++++++++- .../java/EOorg/EOeolang/EOfloat$EOeq.java | 67 ------------------- .../src/test/eo/org/eolang/float-tests.eo | 20 ------ 3 files changed, 35 insertions(+), 88 deletions(-) delete mode 100644 eo-runtime/src/main/java/EOorg/EOeolang/EOfloat$EOeq.java diff --git a/eo-runtime/src/main/eo/org/eolang/float.eo b/eo-runtime/src/main/eo/org/eolang/float.eo index 155cb5596b..11fbdc140d 100644 --- a/eo-runtime/src/main/eo/org/eolang/float.eo +++ b/eo-runtime/src/main/eo/org/eolang/float.eo @@ -28,7 +28,41 @@ [] > float # Tests that $ = x - [x] > eq /bool + [x] > eq + 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. > @ + or. + eq. + x-as-bytes + nan-as-bytes + eq. + self-as-bytes + nan-as-bytes + FALSE + if. + or. + or. + eq. + x-as-bytes + pos-zero-as-bytes + eq. + self-as-bytes + neg-zero-as-bytes + or. + eq. + x-as-bytes + neg-zero-as-bytes + eq. + self-as-bytes + pos-zero-as-bytes + TRUE + eq. + self-as-bytes + x-as-bytes # Tests that $ < x [x] > lt diff --git a/eo-runtime/src/main/java/EOorg/EOeolang/EOfloat$EOeq.java b/eo-runtime/src/main/java/EOorg/EOeolang/EOfloat$EOeq.java deleted file mode 100644 index 16e3783539..0000000000 --- a/eo-runtime/src/main/java/EOorg/EOeolang/EOfloat$EOeq.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2016-2023 Objectionary.com - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* - * @checkstyle PackageNameCheck (4 lines) - */ -package EOorg.EOeolang; - -import org.eolang.AtComposite; -import org.eolang.AtFree; -import org.eolang.Data; -import org.eolang.Param; -import org.eolang.PhDefault; -import org.eolang.Phi; -import org.eolang.Versionized; -import org.eolang.XmirObject; - -/** - * EQ. - * - * @since 0.33 - * @checkstyle TypeNameCheck (5 lines) - */ -@Versionized -@XmirObject(oname = "float.eq") -public class EOfloat$EOeq extends PhDefault { - - /** - * Ctor. - * @param sigma Sigma - */ - public EOfloat$EOeq(final Phi sigma) { - super(sigma); - this.add("x", new AtFree()); - this.add( - "φ", - new AtComposite( - this, - rho -> new Data.ToPhi( - new Param(rho).asStrictBytes(Double.BYTES).asNumber(Double.class) == (double) - new Param(rho, "x").asStrictBytes(Double.BYTES).asNumber(Double.class) - ) - ) - ); - } -} diff --git a/eo-runtime/src/test/eo/org/eolang/float-tests.eo b/eo-runtime/src/test/eo/org/eolang/float-tests.eo index fee9d1f543..9e4b01d469 100644 --- a/eo-runtime/src/test/eo/org/eolang/float-tests.eo +++ b/eo-runtime/src/test/eo/org/eolang/float-tests.eo @@ -190,26 +190,6 @@ 123.5.eq 42.4 FALSE -[] > compares-two-different-types-wrong-size-less - eq. > @ - try - [] - 3.14.eq "Hello" > @ - [e] - e > @ - nop - "The size of argument '.x' is 5 bytes, not '8' as expected" - -[] > compares-two-different-types-wrong-bigger - eq. > @ - try - [] - 2.71.eq "123456789" > @ - [e] - e > @ - nop - "The size of argument '.x' is 9 bytes, not '8' as expected" - [] > compares-two-different-types-right-size eq. > @ 2.71.eq "12345678" From 6d432f6931684acdda631db9a3cf0d989a4a0057 Mon Sep 17 00:00:00 2001 From: Roman Korostinskiy <70313618+c71n93@users.noreply.github.com> Date: Mon, 30 Oct 2023 14:14:17 +0300 Subject: [PATCH 18/21] #2547 add tests for float.eq --- eo-runtime/src/main/eo/org/eolang/float.eo | 10 +++++----- eo-runtime/src/test/eo/org/eolang/float-tests.eo | 5 +++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/eo-runtime/src/main/eo/org/eolang/float.eo b/eo-runtime/src/main/eo/org/eolang/float.eo index 11fbdc140d..acf786bee2 100644 --- a/eo-runtime/src/main/eo/org/eolang/float.eo +++ b/eo-runtime/src/main/eo/org/eolang/float.eo @@ -44,21 +44,21 @@ nan-as-bytes FALSE if. - or. + and. or. eq. x-as-bytes pos-zero-as-bytes - eq. - self-as-bytes - neg-zero-as-bytes - or. 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 TRUE eq. self-as-bytes diff --git a/eo-runtime/src/test/eo/org/eolang/float-tests.eo b/eo-runtime/src/test/eo/org/eolang/float-tests.eo index 9e4b01d469..99d8e718eb 100644 --- a/eo-runtime/src/test/eo/org/eolang/float-tests.eo +++ b/eo-runtime/src/test/eo/org/eolang/float-tests.eo @@ -180,6 +180,11 @@ 0.0 0 +[] > float-neg-zero-eq-to-int-zero + eq. > @ + -0.0 + 0 + [] > eq-true eq. > @ 123.5 From 45873bcbaaa0d884283bf05b09dd6bd4ccdbb7d2 Mon Sep 17 00:00:00 2001 From: Roman Korostinskiy <70313618+c71n93@users.noreply.github.com> Date: Mon, 30 Oct 2023 14:17:47 +0300 Subject: [PATCH 19/21] #2547 fix tests --- .../src/main/java/org/eolang/Param.java | 21 ------------------- .../src/test/eo/org/eolang/float-tests.eo | 4 ++-- .../src/test/eo/org/eolang/int-tests.eo | 2 +- 3 files changed, 3 insertions(+), 24 deletions(-) diff --git a/eo-runtime/src/main/java/org/eolang/Param.java b/eo-runtime/src/main/java/org/eolang/Param.java index 4422c47906..b5f2f85037 100644 --- a/eo-runtime/src/main/java/org/eolang/Param.java +++ b/eo-runtime/src/main/java/org/eolang/Param.java @@ -134,25 +134,4 @@ public Bytes asBytes() { } return res; } - - /** - * Extracts BYTES of any type and checks if they have the appropriate size. - * @param size The appropriate size. - * @return Bytes. - */ - public Bytes asStrictBytes(final int size) { - final Bytes bytes = this.asBytes(); - final int length = bytes.take().length; - if (length != size) { - throw new ExFailure( - String.format( - "The size of argument '.%s' is %d bytes, not '%d' as expected", - this.attr, - length, - size - ) - ); - } - return bytes; - } } diff --git a/eo-runtime/src/test/eo/org/eolang/float-tests.eo b/eo-runtime/src/test/eo/org/eolang/float-tests.eo index 99d8e718eb..c6f68b82e2 100644 --- a/eo-runtime/src/test/eo/org/eolang/float-tests.eo +++ b/eo-runtime/src/test/eo/org/eolang/float-tests.eo @@ -195,9 +195,9 @@ 123.5.eq 42.4 FALSE -[] > compares-two-different-types-right-size +[] > compares-two-different-types eq. > @ - 2.71.eq "12345678" + 3.14.eq "Hello" FALSE [] > times-by-zero diff --git a/eo-runtime/src/test/eo/org/eolang/int-tests.eo b/eo-runtime/src/test/eo/org/eolang/int-tests.eo index 1af3e82c70..bf3cb50a49 100644 --- a/eo-runtime/src/test/eo/org/eolang/int-tests.eo +++ b/eo-runtime/src/test/eo/org/eolang/int-tests.eo @@ -170,7 +170,7 @@ TRUE "check int.eq.not" -[] > compares-two-different-types-size +[] > compares-two-different-types eq. > @ 68.eq "12345678" FALSE From 2d3298859bb266093bf32f1952f4a3c564ee1356 Mon Sep 17 00:00:00 2001 From: Roman Korostinskiy <70313618+c71n93@users.noreply.github.com> Date: Mon, 30 Oct 2023 15:50:02 +0300 Subject: [PATCH 20/21] #2547 fix codacy --- .codacy.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.codacy.yml b/.codacy.yml index 6f56d3f74c..5ea7326c6b 100644 --- a/.codacy.yml +++ b/.codacy.yml @@ -1,6 +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/EOfloat$EOeq.java" - - "eo-runtime/src/main/java/EOorg/EOeolang/EOint$EOeq.java" \ No newline at end of file +exclude_paths: \ No newline at end of file From a7e7c71a0d88629fb38faf302816ee0f444cc141 Mon Sep 17 00:00:00 2001 From: Roman Korostinskiy <70313618+c71n93@users.noreply.github.com> Date: Mon, 30 Oct 2023 15:53:20 +0300 Subject: [PATCH 21/21] #2547 optimize float.eq --- eo-runtime/src/main/eo/org/eolang/float.eo | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/eo-runtime/src/main/eo/org/eolang/float.eo b/eo-runtime/src/main/eo/org/eolang/float.eo index acf786bee2..b8fe8f5074 100644 --- a/eo-runtime/src/main/eo/org/eolang/float.eo +++ b/eo-runtime/src/main/eo/org/eolang/float.eo @@ -43,7 +43,7 @@ self-as-bytes nan-as-bytes FALSE - if. + or. and. or. eq. @@ -59,7 +59,6 @@ eq. self-as-bytes neg-zero-as-bytes - TRUE eq. self-as-bytes x-as-bytes