Sha256: 7deda93c944c20cbadfc8068132bd86b0f03c9f4cf995127161f4a961166098f

Contents?: true

Size: 1.32 KB

Versions: 2

Compression:

Stored size: 1.32 KB

Contents

require 'spec_helper'
module Alf
  describe Relation, "equality" do

    let(:rel)   { Relation[id: Integer].coerce(id: 12) }
    let(:subrel){ Relation[id:  Fixnum].coerce(id: 12) }
    let(:suprel){ Relation[id: Numeric].coerce(id: 12) }

    context '==' do

      it 'returns true for all pairs above' do
        rel.should eq(subrel)
        subrel.should eq(rel)
        rel.should eq(suprel)
        suprel.should eq(rel)
        subrel.should eq(suprel)
        suprel.should eq(subrel)
      end

      it 'returns true on empty relations' do
        Relation([]).should eq(Relation([]))
      end

      it 'returns true on empty factored relations' do
        type = Relation[id: Integer]
        type.new(Set.new).should eq(type.new(Set.new))
      end

      it 'returns true on empty recursively defined relations' do
        type = Relation.type(id: Integer){|r| {children: r} }

        type.new(Set.new).should eq(type.new(Set.new))

        tuple = {id: 1, children: []}
        type.coerce(tuple).should eq(type.coerce(tuple))
      end
    end

    context 'eql?' do

      it 'returns true for all pairs' do
        rel.should eql(subrel)
        subrel.should eql(rel)
        rel.should eql(suprel)
        suprel.should eql(rel)
        subrel.should eql(suprel)
        suprel.should eql(subrel)
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
alf-core-0.15.0 spec/unit/alf-relation/relation/test_equality.rb
alf-core-0.14.0 spec/unit/alf-relation/relation/test_equality.rb