From 072919b2e1fd93f0490ce9cc690fbdef11bb5eb4 Mon Sep 17 00:00:00 2001 From: RevolverOcelotIII Date: Wed, 9 Sep 2026 16:00:50 -0300 Subject: [PATCH 1/4] Adding tests for custom round --- test/test_parsec.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/test_parsec.rb b/test/test_parsec.rb index 3c337c5..f7b6623 100644 --- a/test/test_parsec.rb +++ b/test/test_parsec.rb @@ -38,6 +38,19 @@ def test_complex_math_equations assert_equal(4.56, parser.eval_equation('round_decimal(4.559, 2)')) end + def test_round_with_optional_direction + parser = Parsec::Parsec + + assert_equal(10, parser.eval_equation('round(10.1)')) + assert_equal(11, parser.eval_equation('round(10.1, "up")')) + assert_equal(10, parser.eval_equation('round(10.9, "down")')) + assert_equal(-10, parser.eval_equation('round(-10.9, "up")')) + assert_equal(-11, parser.eval_equation('round(-10.1, "down")')) + + assert_raises(SyntaxError) { parser.eval_equation('round(10.5, "invalid")') } + assert_raises(SyntaxError) { parser.eval_equation('round(10.5, "up", "extra")') } + end + def test_if_then_else_equations parser = Parsec::Parsec assert_equal('bigger', parser.eval_equation('4 > 2 ? "bigger" : "smaller"')) From f40d3ea1875238fc8ef232a5ab34609888e0b2ce Mon Sep 17 00:00:00 2001 From: RevolverOcelotIII Date: Thu, 10 Sep 2026 16:48:56 -0300 Subject: [PATCH 2/4] updating equations parser version and adding new tests --- ext/equations-parser | 2 +- test/test_parsec.rb | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ext/equations-parser b/ext/equations-parser index 7428a00..ec64e60 160000 --- a/ext/equations-parser +++ b/ext/equations-parser @@ -1 +1 @@ -Subproject commit 7428a00a7e56f14afc9178de599e331bae71d17b +Subproject commit ec64e60b8cd11299c2237b13630801f79a1954c1 diff --git a/test/test_parsec.rb b/test/test_parsec.rb index f7b6623..45bd6d7 100644 --- a/test/test_parsec.rb +++ b/test/test_parsec.rb @@ -46,6 +46,9 @@ def test_round_with_optional_direction assert_equal(10, parser.eval_equation('round(10.9, "down")')) assert_equal(-10, parser.eval_equation('round(-10.9, "up")')) assert_equal(-11, parser.eval_equation('round(-10.1, "down")')) + + assert_equal(10, assert_equal(4.63, parsec.eval_equation('round_decimal(4.621, 2, "up")'))) + assert_equal(11, assert_equal(4.62, parsec.eval_equation('round_decimal(4.629, 2, "down")'))) assert_raises(SyntaxError) { parser.eval_equation('round(10.5, "invalid")') } assert_raises(SyntaxError) { parser.eval_equation('round(10.5, "up", "extra")') } From c38d63a630d54d2efc20fd952e861d8ebde8bf42 Mon Sep 17 00:00:00 2001 From: RevolverOcelotIII Date: Thu, 10 Sep 2026 17:22:10 -0300 Subject: [PATCH 3/4] updating commit hash --- ext/libnativemath/extconf.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/libnativemath/extconf.rb b/ext/libnativemath/extconf.rb index b0973e1..e43b45c 100644 --- a/ext/libnativemath/extconf.rb +++ b/ext/libnativemath/extconf.rb @@ -38,7 +38,7 @@ end GIT_REPOSITORY = 'https://github.com/oxeanbits/equations-parser.git'.freeze -COMMIT = '7428a00a7e56f14afc9178de599e331bae71d17b'.freeze +COMMIT = 'ec64e60b8cd11299c2237b13630801f79a1954c1'.freeze Dir.chdir(BASEDIR) do system('git init') From 6efa1aafa102f7940f1f1963bd7d75aa7b875054 Mon Sep 17 00:00:00 2001 From: RevolverOcelotIII Date: Thu, 10 Sep 2026 17:30:21 -0300 Subject: [PATCH 4/4] fixing tests --- test/test_parsec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test_parsec.rb b/test/test_parsec.rb index 45bd6d7..a839351 100644 --- a/test/test_parsec.rb +++ b/test/test_parsec.rb @@ -47,8 +47,8 @@ def test_round_with_optional_direction assert_equal(-10, parser.eval_equation('round(-10.9, "up")')) assert_equal(-11, parser.eval_equation('round(-10.1, "down")')) - assert_equal(10, assert_equal(4.63, parsec.eval_equation('round_decimal(4.621, 2, "up")'))) - assert_equal(11, assert_equal(4.62, parsec.eval_equation('round_decimal(4.629, 2, "down")'))) + assert_equal(4.63, parser.eval_equation('round_decimal(4.621, 2, "up")')) + assert_equal(4.62, parser.eval_equation('round_decimal(4.629, 2, "down")')) assert_raises(SyntaxError) { parser.eval_equation('round(10.5, "invalid")') } assert_raises(SyntaxError) { parser.eval_equation('round(10.5, "up", "extra")') }