Sha256: f5e7d51dbc882e04e5f01e6040618b86bb3e3800c62fee94842dc657d600c633

Contents?: true

Size: 1.47 KB

Versions: 1

Compression:

Stored size: 1.47 KB

Contents

require 'spec_helper'

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

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

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

  context 'when the operand and predicate is optimizable' do
    let(:predicate) { Logic::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) { Logic::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

1 entries across 1 versions & 1 rubygems

Version Path
veritas-0.0.2 spec/unit/veritas/optimizer/algebra/restriction/unoptimized_operand/optimizable_spec.rb