parsecs 0.2.21 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 917b6ad3fd9e860c55b127ec85a37301398472d58dcd422d6ad7798355c7984a
4
- data.tar.gz: 7dba6d7168d479f8c47c67eb81f4d8febca6f6df64cf8dff7575a5d48a3ba02f
3
+ metadata.gz: 0c5932197c66e314ab693098dafac733c00e90a09ae6c66b3a7844442f44ac45
4
+ data.tar.gz: 0faf4c2409610597a83a926cec68368f136ffe5bba7e3e6ea77b37a77e8565bd
5
5
  SHA512:
6
- metadata.gz: e3485aa353d58f8c18f9f84e9661b35e9e7e512a00f0d9a71b0aa9226f68fec0f0d49559836efc544ac00f69fd7ceaa1f575394f9df07d1b59d0b8f291f4aac6
7
- data.tar.gz: 6efbf3526a66ee6f764a35b515591f22aa63f0bf1a7692d0fbac47f616e6a68a50e5b7da03fd6bc56d0a12b6fb408d64745a64a3146bdb1e98f2fa35ac3dc66c
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 = 'd53ae5eb308cb842351da7d1bb87c08e84c67d08'.freeze
41
+ COMMIT = 'e60587a4ae9136f6c70054f230b983225074ae31'.freeze
42
42
 
43
43
  Dir.chdir(BASEDIR) do
44
44
  system('git init')
@@ -30,6 +30,11 @@ Value Calc(string input) {
30
30
  return error;
31
31
  }
32
32
  }
33
+ catch(std::runtime_error &)
34
+ {
35
+ string_type error = "Error: Runtime error";
36
+ return error;
37
+ }
33
38
  return ans;
34
39
  }
35
40
 
data/lib/parsec.rb CHANGED
@@ -6,7 +6,7 @@ module Parsec
6
6
  class Parsec
7
7
  using StringToBooleanRefinements
8
8
 
9
- VERSION = '0.2.21'.freeze
9
+ VERSION = '0.3.0'.freeze
10
10
 
11
11
  # evaluates the equation
12
12
  def self.eval_equation(equation)
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
- assert_equal(true, parsec.validate_syntax('((0.09/1.0)+2.58)-1.6+'))
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
- assert_equal(true, parsec.validate_syntax!('((0.09/1.0)+2.58)-1.6+'))
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
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.2.21
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nilton Vasques