Sha256: c3a541229f44adbdc4b69992c6600d7089d64056626eae54b122b47f95bf9dfa
Contents?: true
Size: 1.01 KB
Versions: 3
Compression:
Stored size: 1.01 KB
Contents
require 'spec_helper' require 'dentaku/ast/functions/mul' require 'dentaku' describe 'Dentaku::AST::Function::Mul' do it 'returns the product of an array of Numeric values' do result = Dentaku('MUL(1, x, 1.8)', x: 2.3) expect(result).to eq 4.14 end it 'returns the product of a single entry array of a Numeric value' do result = Dentaku('MUL(x)', x: 2.3) expect(result).to eq 2.3 end it 'coerces string inputs to numeric' do result = Dentaku('mul(1, x, 1.8)', x: '2.3') expect(result).to eq 4.14 end it 'returns the product even if an array is passed' do result = Dentaku('mul(1, x, 2.3)', x: [4, 5]) expect(result).to eq 46 end it 'handles nested calls' do result = Dentaku('mul(1, x, mul(4, 5))', x: '2.3') expect(result).to eq 46 end context 'checking errors' do let(:calculator) { Dentaku::Calculator.new } it 'raises an error if no arguments are passed' do expect { calculator.evaluate!('MUL()') }.to raise_error(ArgumentError) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
dentaku-3.3.0 | spec/ast/mul_spec.rb |
dentaku-3.2.1 | spec/ast/mul_spec.rb |
dentaku-3.2.0 | spec/ast/mul_spec.rb |