Sha256: caf512355e3b2257ea3278b015647771820bc4b692b102a418e206af78935537

Contents?: true

Size: 854 Bytes

Versions: 3

Compression:

Stored size: 854 Bytes

Contents

require 'spec_helper'
module Qrb
  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
      (uType  == uType2).should be_true
      (uType  == uType3).should be_true
      (uType2 == uType3).should be_true
    end

    it 'should apply distinguish different types' do
      (uType == uType4).should be_false
      (uType == intType).should be_false
    end

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

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