Sha256: a1ffaca79f701b1f918f891465fe11c5e7e49ccb3570be8fa5c9c21782314764

Contents?: true

Size: 643 Bytes

Versions: 3

Compression:

Stored size: 643 Bytes

Contents

require 'dentaku'

describe Dentaku do
  it 'evaulates an expression' do
    expect(Dentaku('5+3')).to eql(8)
  end

  it 'binds values to variables' do
    expect(Dentaku('oranges > 7', {:oranges => 10})).to be_truthy
  end

  it 'evaulates a nested function' do
    expect(Dentaku('roundup(roundup(3 * cherries) + raspberries)', cherries: 1.5, raspberries: 0.9)).to eql(6)
  end

  it 'treats variables as case-insensitive' do
    expect(Dentaku('40 + N', 'n' => 2)).to eql(42)
    expect(Dentaku('40 + N', 'N' => 2)).to eql(42)
    expect(Dentaku('40 + n', 'N' => 2)).to eql(42)
    expect(Dentaku('40 + n', 'n' => 2)).to eql(42)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dentaku-1.2.4 spec/dentaku_spec.rb
dentaku-1.2.3 spec/dentaku_spec.rb
dentaku-1.2.2 spec/dentaku_spec.rb