Sha256: 3ee013e2a86eb7c710e88c50d82e723ebe83401d61547edbf105ce69b1ea6e68
Contents?: true
Size: 817 Bytes
Versions: 3
Compression:
Stored size: 817 Bytes
Contents
require 'spec_helper' require 'dentaku/ast/functions/filter' require 'dentaku' describe Dentaku::AST::Filter do let(:calculator) { Dentaku::Calculator.new } it 'excludes unmatched values' do result = Dentaku('SUM(FILTER(vals, val, val > 1))', vals: [1, 2, 3]) expect(result).to eq(5) end it 'works with a single value if needed for some reason' do result = Dentaku('FILTER(vals, val, val > 1)', vals: 1) expect(result).to eq([]) result = Dentaku('FILTER(vals, val, val > 1)', vals: 2) expect(result).to eq([2]) end it 'raises argument error if a string is passed as identifier' do expect { calculator.evaluate!('FILTER({1, 2, 3}, "val", val % 2 == 0)') }.to raise_error( Dentaku::ArgumentError, 'FILTER() requires second argument to be an identifier' ) end end
Version data entries
3 entries across 3 versions & 2 rubygems
Version | Path |
---|---|
dentaku_zevo-3.5.2 | spec/ast/filter_spec.rb |
dentaku-3.5.1 | spec/ast/filter_spec.rb |
dentaku-3.5.0 | spec/ast/filter_spec.rb |