Sha256: 08015bdd6823fd98176387446bb74c6c6521194553582fc9aee1070c68bab21e

Contents?: true

Size: 880 Bytes

Versions: 19

Compression:

Stored size: 880 Bytes

Contents

require 'spec_helper'
module Finitio
  describe UnionType, "equality" do

    let(:uType)  { UnionType.new([intType, floatType]) }
    let(:uType2) { UnionType.new([floatType, intType]) }
    let(:uType3) { UnionType.new([floatType, intType]) }
    let(:uType4) { UnionType.new([intType])            }

    it 'should apply structural equality' do
      expect(uType  == uType2).to eq(true)
      expect(uType  == uType3).to eq(true)
      expect(uType2 == uType3).to eq(true)
    end

    it 'should apply distinguish different types' do
      expect(uType == uType4).to eq(false)
      expect(uType == intType).to eq(false)
    end

    it 'should be a total function, with nil for non types' do
      expect(uType == 12).to eq(false)
    end

    it 'should implement hash accordingly' do
      expect([uType, uType2, uType3].map(&:hash).uniq.size).to eq(1)
    end

  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
finitio-0.12.0 spec/type/union_type/test_equality.rb
finitio-0.11.4 spec/type/union_type/test_equality.rb
finitio-0.11.3 spec/type/union_type/test_equality.rb
finitio-0.11.2 spec/type/union_type/test_equality.rb
finitio-0.11.1 spec/type/union_type/test_equality.rb
finitio-0.10.0 spec/type/union_type/test_equality.rb
finitio-0.9.1 spec/type/union_type/test_equality.rb
finitio-0.9.0 spec/type/union_type/test_equality.rb
finitio-0.8.0 spec/type/union_type/test_equality.rb
finitio-0.7.0 spec/type/union_type/test_equality.rb
finitio-0.7.0.pre.rc4 spec/type/union_type/test_equality.rb
finitio-0.7.0.pre.rc3 spec/type/union_type/test_equality.rb
finitio-0.7.0.pre.rc2 spec/type/union_type/test_equality.rb
finitio-0.7.0.pre.rc1 spec/type/union_type/test_equality.rb
finitio-0.6.1 spec/type/union_type/test_equality.rb
finitio-0.6.0 spec/type/union_type/test_equality.rb
finitio-0.5.2 spec/type/union_type/test_equality.rb
finitio-0.5.1 spec/type/union_type/test_equality.rb
finitio-0.5.0 spec/type/union_type/test_equality.rb