From 1c156a0d383e66a1905438344b0e9bf77229bd9a Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Tue, 13 Jun 2023 11:28:50 -0300 Subject: [PATCH 01/13] `==` add Unit support --- src/vm/values/comparison.nim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/vm/values/comparison.nim b/src/vm/values/comparison.nim index 0bf0956456..c24b73ab7c 100644 --- a/src/vm/values/comparison.nim +++ b/src/vm/values/comparison.nim @@ -185,7 +185,8 @@ proc `==`*(x: Value, y: Value): bool = if not (v==y.d[k]): return false return true - + of Unit: + return x.u == y.u of Object: if (let compareMethod = x.proto.methods.getOrDefault("compare", nil); not compareMethod.isNil): return x.proto.doCompare(x,y) == 0 From f4c88f9b94650bb7ecd3b9cce1d2bbe8f8a6f343 Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Tue, 13 Jun 2023 11:29:53 -0300 Subject: [PATCH 02/13] `<`/`>` add Unit support --- src/vm/values/comparison.nim | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/vm/values/comparison.nim b/src/vm/values/comparison.nim index c24b73ab7c..f96097238b 100644 --- a/src/vm/values/comparison.nim +++ b/src/vm/values/comparison.nim @@ -392,6 +392,8 @@ proc `<`*(x: Value, y: Value): bool {.inline.}= return x.a.len < y.a.len of Dictionary: return false + of Unit: + return false of Object: if (let compareMethod = x.proto.methods.getOrDefault("compare", nil); not compareMethod.isNil): return x.proto.doCompare(x, y) == -1 @@ -502,6 +504,8 @@ proc `>`*(x: Value, y: Value): bool {.inline.}= return x.a.len > y.a.len of Dictionary: return false + of Unit: + return false of Object: if (let compareMethod = x.proto.methods.getOrDefault("compare", nil); not compareMethod.isNil): return x.proto.doCompare(x,y) == 1 From 05d8dcb40ea0d4a3886fe8e7075a8944197d9948 Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Tue, 13 Jun 2023 12:00:24 -0300 Subject: [PATCH 03/13] [Comparison\between?]: add unit's unit-test --- tests/unittests/lib.comparison.art | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/unittests/lib.comparison.art b/tests/unittests/lib.comparison.art index d6db21507d..5a3e80f002 100644 --- a/tests/unittests/lib.comparison.art +++ b/tests/unittests/lib.comparison.art @@ -645,6 +645,10 @@ do [ to :date .format: "MMM dd" "Jan 16" passed + topic « between? - :unit + ensure -> between? `USD `USD + ensure -> not? between? `USD `EUR + passed ] From 20cc8b3b1c89b1fb8fdb850dd1056825d40cfe11 Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Tue, 13 Jun 2023 12:02:09 -0300 Subject: [PATCH 04/13] [Comparison\compare]: add unit's unit-test --- tests/unittests/lib.comparison.art | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/unittests/lib.comparison.art b/tests/unittests/lib.comparison.art index 5a3e80f002..a6e5a61b1a 100644 --- a/tests/unittests/lib.comparison.art +++ b/tests/unittests/lib.comparison.art @@ -1176,6 +1176,14 @@ do [ ensure -> 1 = compare e d passed + topic « compare - :unit + + ensure -> 0 = `USD `USD + ensure -> 1 = `USD `EUR + ensure -> 1 = `EUR `USD + passed + + ] topic « equal? From 73e6c4f070ad30ef2670f22f90e6d0fa8a2039ac Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Tue, 13 Jun 2023 12:08:39 -0300 Subject: [PATCH 05/13] [Comparison\equal?]: add unit's unit-test --- tests/unittests/lib.comparison.art | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/unittests/lib.comparison.art b/tests/unittests/lib.comparison.art index a6e5a61b1a..42c3fd6ed6 100644 --- a/tests/unittests/lib.comparison.art +++ b/tests/unittests/lib.comparison.art @@ -2278,6 +2278,20 @@ do [ -> equal? var 'regex? {/regex?/} ] => not? passed + + topic « equal? - :unit + + ensure -> equal? `USD `USD + ensure -> equal? `EUR `EUR + ensure -> `USD = `USD + ensure -> `EUR = `EUR + passed + + ensure -> not? equal? `USD `EUR + ensure -> not? equal? `EUR `USD + ensure -> not? `EUR = `USD + passed + ] topic « greater? From 0fdb93a867779f0383379ca3b0d125c6103c51bb Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Tue, 13 Jun 2023 12:10:28 -0300 Subject: [PATCH 06/13] [Comparison\greater?]: add unit's unit-test --- tests/unittests/lib.comparison.art | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/unittests/lib.comparison.art b/tests/unittests/lib.comparison.art index 42c3fd6ed6..ae7d792198 100644 --- a/tests/unittests/lib.comparison.art +++ b/tests/unittests/lib.comparison.art @@ -2993,6 +2993,18 @@ do [ passed + topic « greater? - :unit + + ensure -> not? greater? `USD `USD + ensure -> not? greater? `EUR `EUR + ensure -> not? greater? `USD `EUR + ensure -> not? greater? `EUR `USD + ensure -> not? `USD > `USD + ensure -> not? `EUR > `EUR + ensure -> not? `EUR > `USD + passed + + topic « greater? - incompatible types ; NOTES: From 38e0233d5a259d04804da14cc3690cdb14748ec2 Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Tue, 13 Jun 2023 12:19:37 -0300 Subject: [PATCH 07/13] [Comparison\between?]: fix unit's unit-test --- tests/unittests/lib.comparison.art | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/unittests/lib.comparison.art b/tests/unittests/lib.comparison.art index ae7d792198..37b234fe1e 100644 --- a/tests/unittests/lib.comparison.art +++ b/tests/unittests/lib.comparison.art @@ -646,9 +646,15 @@ do [ passed topic « between? - :unit - ensure -> between? `USD `USD - ensure -> not? between? `USD `EUR - passed + + ensure -> between? `USD `USD `USD + ensure -> between? `USD `USD `EUR + ensure -> between? `EUR `USD `EUR + passed + + ; TODO: fix me soon + ; ensure -> not? between? `BRL `USD `EUR + ; passed ] From 1433fd3d16d9b8e99767580c6ec2cbe84ce2cb19 Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Tue, 13 Jun 2023 12:20:40 -0300 Subject: [PATCH 08/13] [Comparison\compare]: fix unit's unit-test --- tests/unittests/lib.comparison.art | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/tests/unittests/lib.comparison.art b/tests/unittests/lib.comparison.art index 37b234fe1e..f006812559 100644 --- a/tests/unittests/lib.comparison.art +++ b/tests/unittests/lib.comparison.art @@ -1184,9 +1184,9 @@ do [ topic « compare - :unit - ensure -> 0 = `USD `USD - ensure -> 1 = `USD `EUR - ensure -> 1 = `EUR `USD + ensure -> 0 = compare `USD `USD + ensure -> 1 = compare `USD `EUR + ensure -> 1 = compare `EUR `USD passed @@ -4235,6 +4235,19 @@ do [ ensure -> not? greaterOrEqual? a d passed + topic « greaterOrEqual? - :unit + + ensure -> greaterOrEqual? `USD `USD + ensure -> greaterOrEqual? `EUR `EUR + ensure -> `USD >= `USD + ensure -> `EUR >= `EUR + passed + + ensure -> not? greaterOrEqual? `USD `EUR + ensure -> not? greaterOrEqual? `EUR `USD + ensure -> not? `EUR >= `USD + passed + topic « greaterOrEqual? - incompatible types From 51f2896feb4fe07d6aade37abec23245466a2bc9 Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Tue, 13 Jun 2023 12:28:14 -0300 Subject: [PATCH 09/13] [Comparison\less?]: add unit's unit-test --- tests/unittests/lib.comparison.art | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/unittests/lib.comparison.art b/tests/unittests/lib.comparison.art index f006812559..ba4082fb5a 100644 --- a/tests/unittests/lib.comparison.art +++ b/tests/unittests/lib.comparison.art @@ -5430,6 +5430,17 @@ do [ ensure -> not? less? a d passed + topic « less? - :unit + + ensure -> not? less? `USD `USD + ensure -> not? less? `EUR `EUR + ensure -> not? less? `USD `EUR + ensure -> not? less? `EUR `USD + ensure -> not? `USD < `USD + ensure -> not? `EUR < `EUR + ensure -> not? `EUR < `USD + passed + topic « less? - incompatible types From 7b325226da6c3b3157e439f6e0f2a002d5feff22 Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Tue, 13 Jun 2023 12:33:46 -0300 Subject: [PATCH 10/13] [Comparison\lessOrEqual?]: add unit's unit-test --- tests/unittests/lib.comparison.art | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/unittests/lib.comparison.art b/tests/unittests/lib.comparison.art index ba4082fb5a..6e1c000a4c 100644 --- a/tests/unittests/lib.comparison.art +++ b/tests/unittests/lib.comparison.art @@ -6667,6 +6667,19 @@ do [ ensure -> not? lessOrEqual? a d passed + topic « lessOrEqual? - :unit + + ensure -> lessOrEqual? `USD `USD + ensure -> lessOrEqual? `EUR `EUR + ensure -> `USD =< `USD + ensure -> `EUR =< `EUR + passed + + ensure -> not? lessOrEqual? `USD `EUR + ensure -> not? equal? `EUR `USD + ensure -> not? `EUR =< `USD + passed + topic « lessOrEqual? - incompatible types From bc449e842c28c692518fb7876efec2668dcfcb46 Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Tue, 13 Jun 2023 12:35:12 -0300 Subject: [PATCH 11/13] [Comparison\notEqual?]: add unit's unit-test --- tests/unittests/lib.comparison.art | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/unittests/lib.comparison.art b/tests/unittests/lib.comparison.art index 6e1c000a4c..2f748d8ffc 100644 --- a/tests/unittests/lib.comparison.art +++ b/tests/unittests/lib.comparison.art @@ -7771,6 +7771,19 @@ do [ ensure -> notEqual? a\year c\year passed + topic « notEqual? - :unit + + ensure -> not? notEqual? `USD `USD + ensure -> not? notEqual? `EUR `EUR + ensure -> not? `USD <> `USD + ensure -> not? `EUR <> `EUR + passed + + ensure -> notEqual? `USD `EUR + ensure -> notEqual? `EUR `USD + ensure -> `EUR <> `USD + passed + topic « notEqual? - incompatible types From c400f94eea6b46d2234c6cf177ac2df169c72595 Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Tue, 13 Jun 2023 12:36:24 -0300 Subject: [PATCH 12/13] [Comparison\same?]: add unit's unit-test --- tests/unittests/lib.comparison.art | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/unittests/lib.comparison.art b/tests/unittests/lib.comparison.art index 2f748d8ffc..d62ab1e0e7 100644 --- a/tests/unittests/lib.comparison.art +++ b/tests/unittests/lib.comparison.art @@ -8834,6 +8834,16 @@ do [ ensure -> not? same? a\year c\year passed + topic « same? - :unit + + ensure -> same? `USD `USD + ensure -> same? `EUR `EUR + passed + + ensure -> not? same? `USD `EUR + ensure -> not? same? `EUR `USD + passed + topic « same? - incompatible types From a3977697e6622ca1b2471b0183924ab9a295fe06 Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Tue, 13 Jun 2023 12:37:54 -0300 Subject: [PATCH 13/13] [Comparison\]: update unit-test's output --- tests/unittests/lib.comparison.res | 32 ++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/unittests/lib.comparison.res b/tests/unittests/lib.comparison.res index d4165fa84a..4a0afa451e 100644 --- a/tests/unittests/lib.comparison.res +++ b/tests/unittests/lib.comparison.res @@ -96,6 +96,9 @@ >> between? - :date [+] passed! +>> between? - :unit +[+] passed! + >> between? - test with reversed index [+] passed! [+] passed! @@ -208,6 +211,9 @@ [+] passed! [+] passed! +>> compare - :unit +[+] passed! + >> equal? >> equal? - :integer :floating :rational @@ -365,6 +371,10 @@ [+] passed! [+] passed! +>> equal? - :unit +[+] passed! +[+] passed! + >> greater? >> greater? - :integer :floating :rational @@ -496,6 +506,9 @@ [+] passed! [+] passed! +>> greater? - :unit +[+] passed! + >> greater? - incompatible types [+] passed! [+] passed! @@ -659,6 +672,10 @@ [+] passed! [+] passed! +>> greaterOrEqual? - :unit +[+] passed! +[+] passed! + >> greaterOrEqual? - incompatible types [+] passed! [+] passed! @@ -822,6 +839,9 @@ [+] passed! [+] passed! +>> less? - :unit +[+] passed! + >> less? - incompatible types [+] passed! [+] passed! @@ -984,6 +1004,10 @@ [+] passed! [+] passed! +>> lessOrEqual? - :unit +[+] passed! +[+] passed! + >> lessOrEqual? - incompatible types [+] passed! [+] passed! @@ -1139,6 +1163,10 @@ [+] passed! [+] passed! +>> notEqual? - :unit +[+] passed! +[+] passed! + >> notEqual? - incompatible types [+] passed! [+] passed! @@ -1299,6 +1327,10 @@ [+] passed! [+] passed! +>> same? - :unit +[+] passed! +[+] passed! + >> same? - incompatible types [+] passed! [+] passed!