Sha256: 17b8658aff252da67de8c36e86ded2176bbd4214b4bbd2462180a7c314a45d2e

Contents?: true

Size: 1.25 KB

Versions: 1

Compression:

Stored size: 1.25 KB

Contents

require 'spec_helper'
require File.expand_path('../fixtures/classes', __FILE__)

describe 'Veritas::Logic::Expression#==' do
  subject { object == other }

  let(:klass)  { Class.new(ExpressionSpecs::Object) }
  let(:object) { klass.new                          }

  before do
    klass.class_eval do
      def eql?(other)
        instance_of?(other.class)
      end
    end
  end

  context 'with the same object' do
    let(:other) { object }

    it { should be(true) }

    it 'is symmetric' do
      should == (other == object)
    end
  end

  context 'with an equivalent object' do
    let(:other) { object.dup }

    it { should be(true) }

    it 'is symmetric' do
      should == (other == object)
    end
  end

  context 'with two equivalent unoptimized object' do
    let(:object) { klass.new & klass.new }
    let(:other)  { klass.new & klass.new }

    it { should be(true) }

    it 'is symmetric' do
      should == (other == object)
    end
  end

  context 'with two different unoptimized object' do
    let(:object)   { klass.new & klass.new       }
    let(:subclass) { Class.new(klass)            }
    let(:other)    { subclass.new & subclass.new }

    it { should be(false) }

    it 'is symmetric' do
      should == (other == object)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
veritas-0.0.2 spec/unit/veritas/logic/expression/equal_value_spec.rb