Sha256: b13d711930a55617fda88d42644e66d4e6038aa1e86f01ad1b0bb2a4e23e0296

Contents?: true

Size: 1.06 KB

Versions: 2

Compression:

Stored size: 1.06 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe Optimizer::Algebra::Extension::UnoptimizedOperand, '#optimizable?' do
  subject { object.optimizable? }

  let(:header)   { Relation::Header.coerce([[:id, Integer]])       }
  let(:base)     { Relation.new(header, LazyEnumerable.new([[1]])) }
  let(:relation) { operand.extend { |r| r.add(*extensions) }       }
  let(:object)   { described_class.new(relation)                   }

  before do
    expect(object.operation).to be_kind_of(Algebra::Extension)
  end

  context 'when the operand is optimizable' do
    let(:operand)    { base.rename({}) }
    let(:extensions) { [:text, 1]      }

    it { should be(true) }
  end

  context 'when the extensions are optimizable' do
    let(:operand)    { base                                        }
    let(:extensions) { [:text, Function::Numeric::Absolute.new(1)] }

    it { should be(true) }
  end

  context 'when the operand and extensions are not optimizable' do
    let(:operand)    { base       }
    let(:extensions) { [:text, 1] }

    it { should be(false) }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
axiom-optimizer-0.2.0 spec/unit/axiom/optimizer/algebra/extension/unoptimized_operand/optimizable_predicate_spec.rb
axiom-optimizer-0.1.1 spec/unit/axiom/optimizer/algebra/extension/unoptimized_operand/optimizable_predicate_spec.rb