Sha256: 13d6791f29d862b083b927610802c1fa0507188ab98b7c421a314bde02659690

Contents?: true

Size: 962 Bytes

Versions: 2

Compression:

Stored size: 962 Bytes

Contents

require 'spec_helper'
module Finitio
  describe RelationType, "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)  { RelationType.new(h1) }
    let(:type2)  { RelationType.new(h2) }
    let(:type3)  { RelationType.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

2 entries across 2 versions & 1 rubygems

Version Path
finitio-0.4.1 spec/unit/type/relation_type/test_equality.rb
finitio-0.4.0 spec/unit/type/relation_type/test_equality.rb