Sha256: cc509c00ae0b8cb64285466a1bd1a45d29ae417a71c88a88d618fcf2ff29283a

Contents?: true

Size: 1.66 KB

Versions: 1

Compression:

Stored size: 1.66 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe Optimizer::Function::Connective::Conjunction::Contradiction, '#optimizable?' do
  subject { object.optimizable? }

  let(:attribute)  { Attribute::Integer.new(:id)                        }
  let(:connective) { Function::Connective::Conjunction.new(left, right) }
  let(:object)     { described_class.new(connective)                    }

  before do
    expect(object.operation).to be_kind_of(Function::Connective::Conjunction)
  end

  context 'when left is a contradiction' do
    let(:left)  { Function::Proposition::Contradiction.instance }
    let(:right) { attribute.eq(1)                               }

    it { should be(true) }
  end

  context 'when right is a contradiction' do
    let(:left)  { attribute.eq(1)                               }
    let(:right) { Function::Proposition::Contradiction.instance }

    it { should be(true) }
  end

  context 'when left and right are equality predicates with the same attribute and constant values' do
    let(:left)  { attribute.eq(1) }
    let(:right) { attribute.eq(2) }

    it { should be(true) }
  end

  context 'when left and right are inverses' do
    let(:left)  { attribute.eq(1) }
    let(:right) { attribute.ne(1) }

    it { should be(true) }
  end

  context 'when left and right are procs' do
    let(:left)  { proc {} }
    let(:right) { proc {} }

    it { should be(false) }
  end

  context 'when left is a proc' do
    let(:left)  { proc {}         }
    let(:right) { attribute.ne(1) }

    it { should be(false) }
  end

  context 'when right is a proc' do
    let(:left)  { attribute.eq(1) }
    let(:right) { proc {}         }

    it { should be(false) }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
axiom-optimizer-0.1.1 spec/unit/axiom/optimizer/function/connective/conjunction/contradiction/optimizable_predicate_spec.rb