Sha256: c34fda49f58ac6028bc7c55c70075adfe12bdfcf12240378883de27fa414acba

Contents?: true

Size: 1.38 KB

Versions: 4

Compression:

Stored size: 1.38 KB

Contents

# encoding: utf-8

require 'spec_helper'

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

  let(:header)   { Relation::Header.new([ [ :id, Integer ] ]) }
  let(:base)     { Relation.new(header, [ [ 1 ] ].each)       }
  let(:relation) { operand.restrict { predicate }             }
  let(:object)   { described_class.new(relation)              }

  before do
    object.operation.should be_kind_of(Algebra::Restriction)
  end

  context 'when the operand and predicate is optimizable' do
    let(:predicate) { Function::Connective::Negation.new(header[:id].eq(1)) }
    let(:operand)   { base.rename({})                                       }

    it { should be(true) }
  end

  context 'when the operand is optimizable, but the predicate is not optimizable' do
    let(:predicate) { header[:id].eq(1) }
    let(:operand)   { base.rename({})   }

    it { should be(true) }
  end

  context 'when the operand is not optimizable, but the predicate is optimizable' do
    let(:predicate) { Function::Connective::Negation.new(header[:id].eq(1)) }
    let(:operand)   { base                                                  }

    it { should be(true) }
  end

  context 'when the operand and predicate are not optimizable' do
    let(:predicate) { header[:id].eq(1) }
    let(:operand)   { base              }

    it { should be(false) }
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
veritas-optimizer-0.0.7 spec/unit/veritas/optimizer/algebra/restriction/unoptimized_operand/optimizable_spec.rb
veritas-optimizer-0.0.6 spec/unit/veritas/optimizer/algebra/restriction/unoptimized_operand/optimizable_spec.rb
veritas-optimizer-0.0.5 spec/unit/veritas/optimizer/algebra/restriction/unoptimized_operand/optimizable_spec.rb
veritas-optimizer-0.0.4 spec/unit/veritas/optimizer/algebra/restriction/unoptimized_operand/optimizable_spec.rb