parsecs 0.14.2 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/libnativemath/extconf.rb +1 -1
- data/lib/parsec.rb +1 -1
- data/test/test_parsec.rb +47 -0
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 708c8a4ef36a74b4387eaae39b32ba1521fcbf0c4eb9745afee00f0f47772e54
|
|
4
|
+
data.tar.gz: 8299e287f8d18fd2683f44b8001150dc3040c511a44f0ef5a57f1eb6e7649a29
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c4c931d2f8af9511b066e208cf3ed901b20e392bc30cfc083a1dfdd544e9c9df106a0dff8b1504ceadbf8c113679e7dc934867f19b41a01edad286c06f7563e5
|
|
7
|
+
data.tar.gz: e605c53da99a29147b6d5ca609179612a40d5b7cb99789efff0b83482a21581ad379fc9309a659211378c7883b87296646580d659104da287c279031a4c3c90b
|
|
@@ -38,7 +38,7 @@ libs.each do |lib|
|
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
GIT_REPOSITORY = 'https://github.com/oxeanbits/equations-parser.git'.freeze
|
|
41
|
-
COMMIT = '
|
|
41
|
+
COMMIT = 'ec64e60b8cd11299c2237b13630801f79a1954c1'.freeze
|
|
42
42
|
|
|
43
43
|
Dir.chdir(BASEDIR) do
|
|
44
44
|
system('git init')
|
data/lib/parsec.rb
CHANGED
data/test/test_parsec.rb
CHANGED
|
@@ -38,6 +38,22 @@ class TestParsec < Minitest::Test
|
|
|
38
38
|
assert_equal(4.56, parser.eval_equation('round_decimal(4.559, 2)'))
|
|
39
39
|
end
|
|
40
40
|
|
|
41
|
+
def test_round_with_optional_direction
|
|
42
|
+
parser = Parsec::Parsec
|
|
43
|
+
|
|
44
|
+
assert_equal(10, parser.eval_equation('round(10.1)'))
|
|
45
|
+
assert_equal(11, parser.eval_equation('round(10.1, "up")'))
|
|
46
|
+
assert_equal(10, parser.eval_equation('round(10.9, "down")'))
|
|
47
|
+
assert_equal(-10, parser.eval_equation('round(-10.9, "up")'))
|
|
48
|
+
assert_equal(-11, parser.eval_equation('round(-10.1, "down")'))
|
|
49
|
+
|
|
50
|
+
assert_equal(4.63, parser.eval_equation('round_decimal(4.621, 2, "up")'))
|
|
51
|
+
assert_equal(4.62, parser.eval_equation('round_decimal(4.629, 2, "down")'))
|
|
52
|
+
|
|
53
|
+
assert_raises(SyntaxError) { parser.eval_equation('round(10.5, "invalid")') }
|
|
54
|
+
assert_raises(SyntaxError) { parser.eval_equation('round(10.5, "up", "extra")') }
|
|
55
|
+
end
|
|
56
|
+
|
|
41
57
|
def test_if_then_else_equations
|
|
42
58
|
parser = Parsec::Parsec
|
|
43
59
|
assert_equal('bigger', parser.eval_equation('4 > 2 ? "bigger" : "smaller"'))
|
|
@@ -391,4 +407,35 @@ class TestParsec < Minitest::Test
|
|
|
391
407
|
assert_equal('One Two Three', parsec.eval_equation('calculate("\"One\" // \" \" // \"Two\" // \" \" // \"Three\"")'))
|
|
392
408
|
assert_equal('3', parsec.eval_equation('calculate("number(calculate(\"1 + 1\")) + 1")'))
|
|
393
409
|
end
|
|
410
|
+
|
|
411
|
+
def test_weekday
|
|
412
|
+
parsec = Parsec::Parsec
|
|
413
|
+
assert_equal(0, parsec.eval_equation('weekday("2021-03-21")'))
|
|
414
|
+
assert_equal(1, parsec.eval_equation('weekday("2016-03-21")'))
|
|
415
|
+
assert_equal(2, parsec.eval_equation('weekday("2017-03-21")'))
|
|
416
|
+
assert_equal(3, parsec.eval_equation('weekday("2018-03-21")'))
|
|
417
|
+
assert_equal(4, parsec.eval_equation('weekday("2019-03-21")'))
|
|
418
|
+
|
|
419
|
+
assert_equal(5, parsec.eval_equation('weekday("2014-03-21T21:03")'))
|
|
420
|
+
assert_equal(6, parsec.eval_equation('weekday("2015-03-21T21:03")'))
|
|
421
|
+
|
|
422
|
+
assert_equal('Søndag', parsec.eval_equation('weekday("2021-03-21", "nb")'))
|
|
423
|
+
assert_equal('星期一', parsec.eval_equation('weekday("2016-03-21", "zh-CN")'))
|
|
424
|
+
assert_equal('Mardi', parsec.eval_equation('weekday("2017-03-21", "fr-FR")'))
|
|
425
|
+
assert_equal('วันพุธ', parsec.eval_equation('weekday("2018-03-21", "th-TH")'))
|
|
426
|
+
assert_equal('Quinta-feira', parsec.eval_equation('weekday("2019-03-21", "pt-BR")'))
|
|
427
|
+
|
|
428
|
+
assert_raises(SyntaxError) { parsec.eval_equation('weekday("2019-03-21", "invalidlocale")') }
|
|
429
|
+
assert_raises(SyntaxError) { parsec.eval_equation('weekday("2024-32-21")') }
|
|
430
|
+
assert_raises(SyntaxError) { parsec.eval_equation('weekday("2024-09-17", "en", "one too many params")') }
|
|
431
|
+
end
|
|
432
|
+
|
|
433
|
+
def test_current_time
|
|
434
|
+
parsec = Parsec::Parsec
|
|
435
|
+
assert_raises(SyntaxError) { parsec.eval_equation('current_time("1"))') }
|
|
436
|
+
assert_match(/^([01]?[0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]$/, parsec.eval_equation('current_time(5)'))
|
|
437
|
+
assert_match(/^([01]?[0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]$/, parsec.eval_equation('current_time()'))
|
|
438
|
+
assert_match(/^([01]?[0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]$/, parsec.eval_equation('current_time(-3)'))
|
|
439
|
+
assert_match(/^([01]?[0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]$/, parsec.eval_equation('current_time(-200)'))
|
|
440
|
+
end
|
|
394
441
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: parsecs
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.15.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Nilton Vasques
|
|
@@ -10,7 +10,7 @@ authors:
|
|
|
10
10
|
autorequire:
|
|
11
11
|
bindir: bin
|
|
12
12
|
cert_chain: []
|
|
13
|
-
date:
|
|
13
|
+
date: 2026-09-14 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: minitest
|
|
@@ -81,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
81
81
|
requirements:
|
|
82
82
|
- swig
|
|
83
83
|
- cmake
|
|
84
|
-
rubygems_version: 3.
|
|
84
|
+
rubygems_version: 3.5.22
|
|
85
85
|
signing_key:
|
|
86
86
|
specification_version: 4
|
|
87
87
|
summary: A gem to evaluate equations using muparserx C++ library
|