Sha256: 841fddce6fb2e4f48bc148dbef627f216e393a7c87da912a8aea32244af5640d

Contents?: true

Size: 791 Bytes

Versions: 3

Compression:

Stored size: 791 Bytes

Contents

require 'spec_helper'
module Qrb
  describe Heading, "equality" do

    let(:h1){ Heading.new([Attribute.new(:r, intType), Attribute.new(:b, intType)]) }
    let(:h2){ Heading.new([Attribute.new(:b, intType), Attribute.new(:r, intType)]) }
    let(:h3){ Heading.new([Attribute.new(:b, intType)])                             }

    it 'should apply structural equality' do
      (h1 == h2).should be_true
      (h2 == h1).should be_true
    end

    it 'should apply distinguish different types' do
      (h1 == h3).should be_false
      (h2 == h3).should be_false
    end

    it 'should be a total function, with nil for non types' do
      (h1 == 12).should be_nil
    end

    it 'should implement hash accordingly' do
      [h1, h2].map(&:hash).uniq.size.should eq(1)
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
qrb-0.3.0 spec/unit/heading/test_equality.rb
qrb-0.2.0 spec/unit/heading/test_equality.rb
qrb-0.1.0 spec/unit/heading/test_equality.rb