Sha256: 247f0f06e308cc09a92f5c05f010175b89942e914998fa2919d1a97102603eca

Contents?: true

Size: 1.08 KB

Versions: 2

Compression:

Stored size: 1.08 KB

Contents

require 'spec_helper'

describe 'Veritas::Logic::Connective::Negation#optimize' do
  subject { object.optimize }

  let(:klass)     { Logic::Connective::Negation }
  let(:attribute) { Attribute::Integer.new(:id) }
  let(:object)    { klass.new(operand)          }

  context 'operand is a predicate' do
    let(:operand) { attribute.gt(1) }

    it { should eql(attribute.lte(1)) }

    it_should_behave_like 'an optimize method'
  end

  context 'operand is a objected predicate' do
    let(:predicate) { attribute.gt(1)      }
    let(:operand)   { klass.new(predicate) }

    it { should eql(predicate) }

    it_should_behave_like 'an optimize method'
  end

  context 'operand is a true proposition' do
    let(:operand) { Logic::Proposition::True.instance }

    it { should equal(Logic::Proposition::False.instance) }

    it_should_behave_like 'an optimize method'
  end

  context 'operand is a false proposition' do
    let(:operand) { Logic::Proposition::False.instance }

    it { should equal(Logic::Proposition::True.instance) }

    it_should_behave_like 'an optimize method'
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
veritas-0.0.2 spec/integration/veritas/logic/connective/negation/optimize_spec.rb
veritas-0.0.1 spec/integration/veritas/logic/connective/negation/optimize_spec.rb