Sha256: 7b46d1a691de088bbc0dca67b970af266349399065a5a8996e677b2ba155bbd2

Contents?: true

Size: 1.04 KB

Versions: 5

Compression:

Stored size: 1.04 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe Optimizer::Function::Predicate::Comparable::NormalizableOperands, '#optimizable?' do
  subject { object.optimizable? }

  let(:attribute) { Attribute::Integer.new(:id)                    }
  let(:predicate) { Function::Predicate::Equality.new(left, right) }
  let(:object)    { described_class.new(predicate)                 }

  before do
    predicate.should be_kind_of(Function::Predicate::Comparable)
  end

  context 'when left and right is a constant' do
    let(:left)  { 1 }
    let(:right) { 1 }

    it { should be(false) }
  end

  context 'when left and right is an attribute' do
    let(:left)  { attribute }
    let(:right) { attribute }

    it { should be(false) }
  end

  context 'when left is a constant and right is an attribute' do
    let(:left)  { 1         }
    let(:right) { attribute }

    it { should be(true) }
  end

  context 'when left is an attribute and right is a constant' do
    let(:left)  { attribute }
    let(:right) { 1         }

    it { should be(false) }
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
axiom-optimizer-0.1.0 spec/unit/axiom/optimizer/function/predicate/comparable/normalizable_operands/optimizable_predicate_spec.rb
veritas-optimizer-0.0.7 spec/unit/veritas/optimizer/function/predicate/comparable/normalizable_operands/optimizable_spec.rb
veritas-optimizer-0.0.6 spec/unit/veritas/optimizer/function/predicate/comparable/normalizable_operands/optimizable_spec.rb
veritas-optimizer-0.0.5 spec/unit/veritas/optimizer/function/predicate/comparable/normalizable_operands/optimizable_spec.rb
veritas-optimizer-0.0.4 spec/unit/veritas/optimizer/function/predicate/comparable/normalizable_operands/optimizable_spec.rb