Sha256: e1b8c561c0e647781c867b5b90a51ccdf866b07481a279f61f6603a42784f39c

Contents?: true

Size: 1.18 KB

Versions: 40

Compression:

Stored size: 1.18 KB

Contents

require 'lib/ramaze/spec/helper/snippets'

describe 'OrderedSet' do
  os = OrderedSet.new(1,2,3,1)

  it 'should create sets' do
    OrderedSet.new.should == []
    OrderedSet.new(1).should == [1]
    OrderedSet.new(1,2).should == [1,2]
    OrderedSet.new([1,2,3]).should == [1,2,3]
  end

  it 'should compare sets' do
    os.should == OrderedSet.new(1,2,3,1)
    os.should == OrderedSet.new([1,2,3,1])
  end

  it 'should not contain duplicates' do
    os.should == [1,2,3]
  end

  it 'should not duplicate entries' do
    os << 4
    os.should == [1,2,3,4]

    os << 4
    os.should == [1,2,3,4]
  end

  it 'should append with push and prepend with unshift' do
    os.push 1
    os.should == [2,3,4,1]

    os.unshift 1
    os.should == [1,2,3,4]

    os.push [1,2]
    os.should == [1,2,3,4,[1,2]]

    os.unshift [1,2]
    os.should == [[1,2],1,2,3,4]
  end

  it 'should support Array#[]=' do
    os = OrderedSet.new(1)
    os.should == [1]

    os[0] = 1
    os.should == [1]

    os[1,0] = [3,4,5,1]
    os.should == [3,4,5,1]

    os[0,0] = [1,2]
    os.should == [1,2,3,4,5]

    os[5..5] = [7,8,1,2]
    os.should == [3,4,5,7,8,1,2]

    os[1..2] = 3
    os.should == [3,7,8,1,2]
  end
end

Version data entries

40 entries across 40 versions & 6 rubygems

Version Path
Pistos-ramaze-2008.09 spec/snippets/ordered_set.rb
Pistos-ramaze-2008.12 spec/snippets/ordered_set.rb
Pistos-ramaze-2009.01 spec/snippets/ordered_set.rb
Pistos-ramaze-2009.02 spec/snippets/ordered_set.rb
Pistos-ramaze-2009.04.08 spec/snippets/ordered_set.rb
clivecrous-ramaze-0.3.9.5 spec/snippets/ordered_set.rb
manveru-ramaze-2008.07 spec/snippets/ordered_set.rb
manveru-ramaze-2008.08 spec/snippets/ordered_set.rb
manveru-ramaze-2008.09 spec/snippets/ordered_set.rb
manveru-ramaze-2008.10 spec/snippets/ordered_set.rb
manveru-ramaze-2008.12 spec/snippets/ordered_set.rb
manveru-ramaze-2009.01 spec/snippets/ordered_set.rb
manveru-ramaze-2009.04.01 spec/snippets/ordered_set.rb
manveru-ramaze-2009.04.08 spec/snippets/ordered_set.rb
manveru-ramaze-2009.04.18 spec/snippets/ordered_set.rb
manveru-ramaze-2009.04.22 spec/snippets/ordered_set.rb
manveru-ramaze-2009.04 spec/snippets/ordered_set.rb
manveru-ramaze-2009.05.08 spec/snippets/ordered_set.rb
manveru-ramaze-2009.05 spec/snippets/ordered_set.rb
manveru-ramaze-2009.06.04 spec/snippets/ordered_set.rb