parsecs 0.8.0 → 0.9.3
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 +34 -1
- metadata +6 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 66e5451ec9d950983f9e0900e1913e2619e7d88f2fee21eec4972c9311b7d74f
|
4
|
+
data.tar.gz: 161e65bff7e6d2b281e18ad0fa3ba4815f34ee81484329cbd2724f2eaeffaf9a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cab3eb621af78fa5a565adc603096f35850aa112778a5d55261f57bdd2042633c09821411e7e0083c9b2e2641382e7e0a030cf459a31552ae29ca3dc267444ec
|
7
|
+
data.tar.gz: 25d5f3bc6ffb401ef09320d75ebaaa989527c7720064adc9d4839ac75e17f63feb946a3530a24d8d8f9dd67104cc6115d7ea009d58933c7171ab27b8d7f1c832
|
@@ -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 = 'd35b30205dd08f80ceb01df003a376c95a715bb6'.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
@@ -60,6 +60,12 @@ class TestParsec < Minitest::Test
|
|
60
60
|
assert_equal(5, parser.eval_equation('number("5")'))
|
61
61
|
assert_equal('Hello', parser.eval_equation('left("Hello World", 5)'))
|
62
62
|
assert_equal('World', parser.eval_equation('right("Hello World", 5)'))
|
63
|
+
assert_equal('<a href="http://foo.bar">Title</a>', parser.eval_equation('link("Title", "http://foo.bar")'))
|
64
|
+
assert_equal('<a href="#">Title</a>', parser.eval_equation('link("Title", "#")'))
|
65
|
+
assert_equal('<a href="/test">Test title</a>', parser.eval_equation('link("Test title", "/test")'))
|
66
|
+
assert_raises(SyntaxError) { parser.eval_equation_with_type('link()') }
|
67
|
+
assert_raises(SyntaxError) { parser.eval_equation_with_type('link(1, 2, 3)') }
|
68
|
+
assert_raises(SyntaxError) { parser.eval_equation_with_type('link(1, "2")') }
|
63
69
|
end
|
64
70
|
|
65
71
|
def test_complex_string_manipulation
|
@@ -189,6 +195,24 @@ class TestParsec < Minitest::Test
|
|
189
195
|
assert_equal('1-1234-1234-1234-1234', parsec.eval_equation('mask("0-0000-0000-0000-0000", 11234123412341234)'))
|
190
196
|
end
|
191
197
|
|
198
|
+
def test_string_cast
|
199
|
+
parsec = Parsec::Parsec
|
200
|
+
assert_equal('4', parsec.eval_equation('string(4)'))
|
201
|
+
assert_equal('4.5', parsec.eval_equation('string(4.5)'))
|
202
|
+
assert_equal('true', parsec.eval_equation('string(true)'))
|
203
|
+
assert_equal('false', parsec.eval_equation('string(false)'))
|
204
|
+
assert_equal('4', parsec.eval_equation('string("4")'))
|
205
|
+
end
|
206
|
+
|
207
|
+
def test_number_cast
|
208
|
+
parsec = Parsec::Parsec
|
209
|
+
assert_equal(4, parsec.eval_equation('number(4)'))
|
210
|
+
assert_equal(4.5, parsec.eval_equation('number(4.5)'))
|
211
|
+
assert_equal(1, parsec.eval_equation('number(true)'))
|
212
|
+
assert_equal(0, parsec.eval_equation('number(false)'))
|
213
|
+
assert_equal(4, parsec.eval_equation('number("4")'))
|
214
|
+
end
|
215
|
+
|
192
216
|
def test_default_value
|
193
217
|
parsec = Parsec::Parsec
|
194
218
|
|
@@ -202,8 +226,17 @@ class TestParsec < Minitest::Test
|
|
202
226
|
assert_equal(false, parsec.eval_equation('default_value(false, true)'))
|
203
227
|
assert_equal(true, parsec.eval_equation('default_value(NULL, true)'))
|
204
228
|
|
229
|
+
# Mixing number types
|
230
|
+
assert_equal(1, parsec.eval_equation('default_value(1, 4.5)'))
|
231
|
+
assert_equal(1, parsec.eval_equation('default_value(1, 10)'))
|
232
|
+
assert_equal(1, parsec.eval_equation('default_value(1, 10.0)'))
|
233
|
+
assert_equal(1, parsec.eval_equation('default_value(1.0, 10)'))
|
234
|
+
assert_equal(1, parsec.eval_equation('default_value(1.0, 10.0)'))
|
235
|
+
assert_equal(1.5, parsec.eval_equation('default_value(1.5, 10)'))
|
236
|
+
assert_equal(1.5, parsec.eval_equation('default_value(1.5, 10.0)'))
|
237
|
+
assert_equal(1.5, parsec.eval_equation('default_value(1.5, 10.5)'))
|
238
|
+
|
205
239
|
# Error Scenarios
|
206
|
-
assert_raises(SyntaxError) { parsec.eval_equation('default_value(1, 4.5)') }
|
207
240
|
assert_raises(SyntaxError) { parsec.eval_equation('default_value(4.5, "string")') }
|
208
241
|
assert_raises(SyntaxError) { parsec.eval_equation('default_value("string", true)') }
|
209
242
|
assert_raises(SyntaxError) { parsec.eval_equation('default_value(true, 1)') }
|
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: parsecs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nilton Vasques
|
8
8
|
- Victor Cordeiro
|
9
9
|
- Beatriz Fagundes
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2021-04-09 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: minitest
|
@@ -62,7 +62,7 @@ homepage: https://github.com/niltonvasques/parsec
|
|
62
62
|
licenses:
|
63
63
|
- MIT
|
64
64
|
metadata: {}
|
65
|
-
post_install_message:
|
65
|
+
post_install_message:
|
66
66
|
rdoc_options: []
|
67
67
|
require_paths:
|
68
68
|
- lib
|
@@ -81,9 +81,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
81
81
|
requirements:
|
82
82
|
- swig
|
83
83
|
- cmake
|
84
|
-
|
85
|
-
|
86
|
-
signing_key:
|
84
|
+
rubygems_version: 3.0.9
|
85
|
+
signing_key:
|
87
86
|
specification_version: 4
|
88
87
|
summary: A gem to evaluate equations using muparserx C++ library
|
89
88
|
test_files:
|