parsecs 0.13.1 → 0.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- 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: dcff970a8a22bc17b6529f2f57f463615649317c0e19d31dcdbf1cff4d715c66
|
4
|
+
data.tar.gz: cc5851bd3fe8282a0abfea7243712fe5c10bceda40ea9c3ed9bd0860607b84ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f4bcf637585092a91fefc44d21b29b4172d353073b8df0887dfd8ca85f8e073b20d75461233ebf5fad2c76d3b036c9b564d43e6e75ea4e741f0a46ea7d9fe32
|
7
|
+
data.tar.gz: c2b62470fb930594281368d539cc8d8565b97194c3706c3f0cf4d28bf9f7da5b80b47ddbb0ae277cd9a996c669b53966e9d30f2675a945aa8398f62876634152
|
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.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: 2023-
|
13
|
+
date: 2023-11-30 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: minitest
|