Sha256: ecd673f284c7f3c8c0f3053b65f3c59f904f2a0cc17a7fdb2e74c8a1e0f2f006

Contents?: true

Size: 946 Bytes

Versions: 3

Compression:

Stored size: 946 Bytes

Contents

require 'spec_helper'
module Qrb
  describe TupleType, "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)])                             }

    let(:type1)  { TupleType.new(h1) }
    let(:type2)  { TupleType.new(h2) }
    let(:type3)  { TupleType.new(h3) }

    it 'should apply structural equality' do
      (type1 == type2).should be_true
      (type2 == type1).should be_true
    end

    it 'should apply distinguish different types' do
      (type1 == type3).should be_false
      (type2 == type3).should be_false
    end

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

    it 'should implement hash accordingly' do
      [type1, type2].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/type/tuple_type/test_equality.rb
qrb-0.2.0 spec/unit/type/tuple_type/test_equality.rb
qrb-0.1.0 spec/unit/type/tuple_type/test_equality.rb