Sha256: 7413503928a8f96e0aa2cfcfeb0bb4ce3bcbf50dcc76305334aae6998c0b7521

Contents?: true

Size: 1.01 KB

Versions: 9

Compression:

Stored size: 1.01 KB

Contents

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

    subject{
      left.suppremum(right)
    }

    let(:left){
      UnionType.new([intType, nilType])
    }

    context 'when right is not a union type' do
      let(:right){
        stringType
      }

      it 'works' do
        expect(subject).to be_a(UnionType)
        expect(subject.candidates).to eql(left.candidates + [right])
      end
    end

    context 'when right is a union type' do
      let(:right){
        UnionType.new([stringType, nilType])
      }

      it 'works' do
        expect(subject).to be_a(UnionType)
        expect(subject.candidates).to eql([intType, nilType, stringType])
      end
    end

    context 'when union type is on the right' do
      let(:left){
        stringType
      }

      let(:right){
        UnionType.new([intType, nilType])
      }

      it 'works' do
        expect(subject).to be_a(UnionType)
        expect(subject.candidates).to eql([intType, nilType, stringType])
      end
    end

  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
finitio-0.12.0 spec/type/union_type/test_suppremum.rb
finitio-0.11.4 spec/type/union_type/test_suppremum.rb
finitio-0.11.3 spec/type/union_type/test_suppremum.rb
finitio-0.11.2 spec/type/union_type/test_suppremum.rb
finitio-0.11.1 spec/type/union_type/test_suppremum.rb
finitio-0.10.0 spec/type/union_type/test_suppremum.rb
finitio-0.9.1 spec/type/union_type/test_suppremum.rb
finitio-0.9.0 spec/type/union_type/test_suppremum.rb
finitio-0.8.0 spec/type/union_type/test_suppremum.rb