Sha256: dc9f2b8cb935d6e3f16af4b3fd5fc4d0d4ebb9782d9d7867a3d5984c234add7e

Contents?: true

Size: 1.39 KB

Versions: 9

Compression:

Stored size: 1.39 KB

Contents

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

    subject{
      left.suppremum(right)
    }

    let(:left){
      Heading.new([Attribute.new(:a, intType),
                   Attribute.new(:b, stringType)])
    }

    context 'when both are equal' do
      let(:right){
        Heading.new([Attribute.new(:a, intType),
                     Attribute.new(:b, stringType)])
      }

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

    context 'when they are different' do
      let(:right){
        Heading.new([Attribute.new(:a, nilType),
                     Attribute.new(:b, stringType)])
      }

      it 'works' do
        expect(subject).to be_a(Heading)
        expect(subject[:a].type).to eql(UnionType.new [intType, nilType])
        expect(subject[:b].type).to eql(stringType)
      end
    end

    context 'when they are different II' do
      let(:right){
        Heading.new([Attribute.new(:c, nilType),
                     Attribute.new(:b, stringType)])
      }

      it 'works' do
        expect(subject).to be_a(Heading)
        expect(subject[:a].type).to eql(intType)
        expect(subject[:a].required).to eql(false)
        expect(subject[:b].type).to eql(stringType)
        expect(subject[:b].required).to eql(true)
        expect(subject[:c].type).to eql(nilType)
        expect(subject[:c].required).to eql(false)
      end
    end

  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

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