Sha256: 21e55683bc5f65226beb771d7a4e30ad3c269fab177f581356f2345c2298460d

Contents?: true

Size: 1.45 KB

Versions: 11

Compression:

Stored size: 1.45 KB

Contents

require 'spec_helper'
require 'set'
describe Set do
  
  specify "empty sets should be equal" do
    Set.new([]).should eq(Set.new([]))
    Set.new([]).should eql(Set.new([]))
  end
  
  describe "on DEE-like sets" do
    let(:dee){ Set.new([{}]) }
      
    specify "DEE sets should be equal" do
      Set.new([{}]).should eq(dee)
      Set.new([{}]).should eql(dee)
    end
    
    specify "DEE-like sets should be equal (1)" do
      arr = [{}]
      Set.new(arr).should eq(dee)
      Set.new(arr).should eql(dee)
    end
    
    specify "DEE-like sets should be equal (2)" do
      arr = [{}]
      Set.new(arr.to_a).should eq(dee)
      Set.new(arr.to_a).should eql(dee)
    end
    
    specify "DEE-like sets should be equal (3)" do
      arr = [{}]
      arr.to_set.should eq(dee)
      arr.to_set.should eql(dee)
    end
    
    specify "DEE-like sets should be equal (4)" do
      arr = [{}]
      arr.to_set.should eq(dee)
      arr.to_set.should eql(dee)
    end
    
    specify "DEE-like sets should be equal (5)" do
      arr = Object.new.extend(Enumerable)
      def arr.each
        yield({})
      end
      arr.to_set.should eq(dee)
      arr.to_set.should eql(dee)
    end
    
    specify "DEE-like sets should be equal (5)" do
      arr = Object.new.extend(Enumerable)
      def arr.each
        tuple = {:sid => "1"} 
        tuple.delete(:sid)
        yield(tuple)
      end
      arr.to_set.should eq(dee)
      arr.to_set.should eql(dee)
    end

  end  

end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
alf-core-0.15.0 spec/unit/alf-core/assumptions/test_set.rb
alf-core-0.14.0 spec/unit/alf-core/assumptions/test_set.rb
alf-core-0.13.1 spec/unit/alf-core/assumptions/test_set.rb
alf-core-0.13.0 spec/unit/alf-core/assumptions/test_set.rb
alf-0.12.2 spec/unit/alf-core/assumptions/test_set.rb
alf-0.12.1 spec/unit/alf-core/assumptions/test_set.rb
alf-0.12.0 spec/unit/alf-core/assumptions/test_set.rb
alf-0.11.1 spec/unit/alf-core/assumptions/test_set.rb
alf-0.11.0 spec/unit/alf-core/assumptions/test_set.rb
alf-0.10.1 spec/unit/assumptions/test_set.rb
alf-0.10.0 spec/unit/assumptions/test_set.rb