spec/calculator_spec.rb in dentaku-2.0.6 vs spec/calculator_spec.rb in dentaku-2.0.7

- old
+ new

@@ -258,9 +258,31 @@ expect(calculator.evaluate('rounddown(1.234, 2)')).to eq(1.23) end end end + describe 'explicit NULL' do + it 'can be used in IF statements' do + expect(calculator.evaluate('IF(null, 1, 2)')).to eq(2) + end + + it 'can be used in IF statements when passed in' do + expect(calculator.evaluate('IF(foo, 1, 2)', foo: nil)).to eq(2) + end + + it 'nil values are carried across middle terms' do + results = calculator.solve!( + choice: 'IF(bar, 1, 2)', + bar: 'foo', + foo: nil) + expect(results).to eq( + choice: 2, + bar: nil, + foo: nil + ) + end + end + describe 'case statements' do it 'handles complex then statements' do formula = <<-FORMULA CASE fruit WHEN 'apple'