spec/calculator_spec.rb in dentaku-3.4.1 vs spec/calculator_spec.rb in dentaku-3.4.2

- old
+ new

@@ -500,10 +500,14 @@ ])).to eq(["Bob", "Jane"]) expect(calculator.evaluate!('map(users, u, u.name)', users: [ {"name" => "Bob", "age" => 44}, {"name" => "Jane", "age" => 27} ])).to eq(["Bob", "Jane"]) + expect(calculator.evaluate!('map(users, u, IF(u.age < 30, u, null))', users: [ + {"name" => "Bob", "age" => 44}, + {"name" => "Jane", "age" => 27} + ])).to eq([nil, { "name" => "Jane", "age" => 27 }]) end end describe "pluck" do it "plucks values from array of hashes" do @@ -694,12 +698,16 @@ describe 'math functions' do Math.methods(false).each do |method| it method do if Math.method(method).arity == 2 expect(calculator.evaluate("#{method}(x,y)", x: 1, y: '2')).to eq(Math.send(method, 1, 2)) + expect(calculator.evaluate("#{method}(x,y) + 1", x: 1, y: '2')).to be_within(0.00001).of(Math.send(method, 1, 2) + 1) expect { calculator.evaluate!("#{method}(x)", x: 1) }.to raise_error(Dentaku::ParseError) else expect(calculator.evaluate("#{method}(1)")).to eq(Math.send(method, 1)) + unless [:atanh, :frexp, :lgamma].include?(method) + expect(calculator.evaluate("#{method}(1) + 1")).to be_within(0.00001).of(Math.send(method, 1) + 1) + end end end end end