parsecs 0.13.1 → 0.14.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/libnativemath/extconf.rb +1 -1
- data/lib/parsec.rb +1 -1
- data/test/test_parsec.rb +19 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 905bbac64279b895e489f739d6fc5171445d9a809306641a541688b525466cde
|
4
|
+
data.tar.gz: 25572af9b533b844d1f7563ee2f245fde5deab62983e1bb3625609b73654db90
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e401c2f0242f26cb46a97041a172b2ea9e3b7632b68c1c642c8a92750d16d7f2741f9aa080fce180623eee8118c229168fef1a8d0c49115d25a3c6cad76dca3
|
7
|
+
data.tar.gz: 6c1d9c4651f4af290337952bc05c7e0625c611a44d965adcffb4c631f4d7fbb7cc85479b939d214843836d4a4b304587180d3ce07a6a6665e29a66f6e7a064ab
|
@@ -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 = '39d949b5f53d1650eb8f166db3883900f5ce55d4'.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
@@ -372,4 +372,23 @@ class TestParsec < Minitest::Test
|
|
372
372
|
assert_equal(52, parsec.eval_equation('weekyear("2027-12-31")'))
|
373
373
|
assert_equal(53, parsec.eval_equation('weekyear("2028-01-01")'))
|
374
374
|
end
|
375
|
+
|
376
|
+
def test_calculate
|
377
|
+
parsec = Parsec::Parsec
|
378
|
+
assert_equal('World', parsec.eval_equation('regex("Hello World", "Hello (.*)")'))
|
379
|
+
assert_equal('12', parsec.eval_equation('calculate("2+2+2*4")'))
|
380
|
+
assert_equal('16', parsec.eval_equation('calculate("(2+2)*4")'))
|
381
|
+
assert_equal('16', parsec.eval_equation('calculate("2^4")'))
|
382
|
+
assert_equal('3', parsec.eval_equation('calculate("sqrt(9)")'))
|
383
|
+
assert_equal('50', parsec.eval_equation('calculate("abs(-50)")'))
|
384
|
+
assert_equal('1', parsec.eval_equation('calculate("round(1.123)")'))
|
385
|
+
assert_equal('2019-01-04', parsec.eval_equation('calculate("add_days(\"2019-01-01\", 3)")'))
|
386
|
+
assert_equal('1', parsec.eval_equation('calculate("daysdiff(\"2019-01-01\", \"2019-01-02\")")'))
|
387
|
+
assert_equal('24', parsec.eval_equation('calculate("hoursdiff(\"2019-01-01\", \"2019-01-02\")")'))
|
388
|
+
assert_equal('higher', parsec.eval_equation('calculate("3 > 2 ? \"higher\" : \"lower\"")'))
|
389
|
+
assert_equal('lower', parsec.eval_equation('calculate("3 < 2 ? \"higher\" : \"lower\"")'))
|
390
|
+
assert_equal('One Two Three', parsec.eval_equation('calculate("concat(\"One \", concat(\"Two\", \" Three\"))")'))
|
391
|
+
assert_equal('One Two Three', parsec.eval_equation('calculate("\"One\" // \" \" // \"Two\" // \" \" // \"Three\"")'))
|
392
|
+
assert_equal('3', parsec.eval_equation('calculate("number(calculate(\"1 + 1\")) + 1")'))
|
393
|
+
end
|
375
394
|
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.14.1
|
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: 2023-
|
13
|
+
date: 2023-12-04 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: minitest
|