Sha256: 8d2fefcdea797e3f62437d0dc5970f2b22e144e0302796046e362dfdd2308c08

Contents?: true

Size: 729 Bytes

Versions: 3

Compression:

Stored size: 729 Bytes

Contents

require 'spec_helper'
require 'dentaku/ast/functions/any'
require 'dentaku'

describe Dentaku::AST::Any do
  let(:calculator) { Dentaku::Calculator.new }
  it 'performs ANY operation' do
    result = Dentaku('ANY(vals, val, val > 1)', vals: [1, 2, 3])
    expect(result).to eq(true)
  end

  it 'works with a single value if needed for some reason' do
    result = Dentaku('ANY(vals, val, val > 1)', vals: 1)
    expect(result).to eq(false)

    result = Dentaku('ANY(vals, val, val > 1)', vals: 2)
    expect(result).to eq(true)
  end

  it 'raises argument error if a string is passed as identifier' do
    expect { calculator.evaluate!('ANY({1, 2, 3}, "val", val % 2 == 0)') }.to raise_error(Dentaku::ArgumentError)
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
dentaku_zevo-3.5.2 spec/ast/any_spec.rb
dentaku-3.5.1 spec/ast/any_spec.rb
dentaku-3.5.0 spec/ast/any_spec.rb