parsecs 0.2.21 → 0.3.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/ext/libnativemath/libnativemath.cpp +5 -0
- data/lib/parsec.rb +1 -1
- data/test/test_parsec.rb +14 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c5932197c66e314ab693098dafac733c00e90a09ae6c66b3a7844442f44ac45
|
4
|
+
data.tar.gz: 0faf4c2409610597a83a926cec68368f136ffe5bba7e3e6ea77b37a77e8565bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84bd18f908d650b0ef144d5ecf1e8718ce427347fff25366362074c9f79bc9301e41c2875e00f8fd8a2d0779a0cfe89fa12f978c67f4d40000a2af03931a4f0c
|
7
|
+
data.tar.gz: 3b76fbb9f486ea46bdd803c49313355938c23f12e6775359a19ff21cbfe0e8e6652df68b042474c8d6e10ddc3b8a94bfe8842e7b8b8355367702966da9512d5c
|
@@ -38,7 +38,7 @@ libs.each do |lib|
|
|
38
38
|
end
|
39
39
|
|
40
40
|
GIT_REPOSITORY = 'https://github.com/niltonvasques/equations-parser.git'.freeze
|
41
|
-
COMMIT = '
|
41
|
+
COMMIT = 'e60587a4ae9136f6c70054f230b983225074ae31'.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
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'minitest/autorun'
|
2
2
|
require 'parsec'
|
3
|
+
require 'date'
|
3
4
|
|
4
5
|
# This class test all possible equations for this gem
|
5
6
|
class TestParsec < Minitest::Test
|
@@ -92,13 +93,23 @@ class TestParsec < Minitest::Test
|
|
92
93
|
|
93
94
|
def test_validate_syntax
|
94
95
|
parsec = Parsec::Parsec
|
95
|
-
|
96
|
+
refute_equal(true, parsec.validate_syntax('((0.09/1.0)+2.58)-1.6+'))
|
96
97
|
assert_equal('Missing parenthesis.', parsec.validate_syntax('(0.09/1.0'))
|
97
98
|
end
|
98
99
|
|
99
100
|
def test_validate_syntax!
|
100
101
|
parsec = Parsec::Parsec
|
101
|
-
|
102
|
-
assert_raises(parsec.validate_syntax!('(0.09/1.0')
|
102
|
+
assert_raises(SyntaxError) { parsec.validate_syntax!('((0.09/1.0)+2.58)-1.6+') }
|
103
|
+
assert_raises(SyntaxError) { parsec.validate_syntax!('(0.09/1.0') }
|
104
|
+
end
|
105
|
+
|
106
|
+
def test_date_functions
|
107
|
+
parsec = Parsec::Parsec
|
108
|
+
assert_equal(Date.today, Date.parse(parsec.eval_equation("current_date()")))
|
109
|
+
assert_equal(364, parsec.eval_equation('daysdiff("2018-01-01", "2018-12-31")'))
|
110
|
+
assert_equal(365, parsec.eval_equation('daysdiff("2016-01-01", "2016-12-31")'))
|
111
|
+
assert_equal(365, parsec.eval_equation('daysdiff("2000-01-01", "2000-12-31")'))
|
112
|
+
assert_equal(364, parsec.eval_equation('daysdiff("2100-01-01", "2100-12-31")'))
|
113
|
+
assert_equal(1, parsec.eval_equation('daysdiff("2018-01-01", "2017-12-31")'))
|
103
114
|
end
|
104
115
|
end
|