Sha256: 2900f4ed503e6727679953ecd7a7fd14e93883ae1e2a5e43650cddd353c8d80b

Contents?: true

Size: 1.03 KB

Versions: 9

Compression:

Stored size: 1.03 KB

Contents

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

    subject{
      left.suppremum(right)
    }

    let(:left) {
      SetType.new(intType)
    }

    context 'when right is equal' do
      let(:right) {
        SetType.new(intType)
      }

      it 'keeps left' do
        expect(subject).to be(left)
      end
    end

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

      it 'builds a UnionType' do
        expect(subject).to eql(UnionType.new [left, right])
      end
    end

    context 'when right is a set type of same element type' do
      let(:right) {
        SeqType.new(intType)
      }

      it 'keeps right' do
        expect(subject).to eql(SetType.new intType)
      end
    end

    context 'when right is a seq type of a different element type' do
      let(:right) {
        SetType.new(floatType)
      }

      it 'builds a SetType[UnionType]' do
        expect(subject).to eql(SetType.new(UnionType.new [intType, floatType]))
      end
    end

  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

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