Sha256: 68ec49fcdf195835ae7493c6409365367d73c709f8150fa8301ee74a2278c203

Contents?: true

Size: 413 Bytes

Versions: 29

Compression:

Stored size: 413 Bytes

Contents

describe "Hash#shift" do
  it "removes a pair from hash and return it" do
    h = {:a => 1, :b => 2, "c" => 3, nil => 4, [] => 5}
    h2 = h.dup

    h.size.times do |i|
      r = h.shift
      # r.should be_kind_of(Array)
      # h2[r.first].should == r.last
      # h.size.should == h2.size - i - 1
    end

    h.should == {}
  end

  it "removes nil from an empty hash" do
    {}.shift.should == nil
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
opal-0.4.4 spec/rubyspec/core/hash/shift_spec.rb
opal-0.4.3 spec/rubyspec/core/hash/shift_spec.rb
opal-0.4.2 spec/rubyspec/core/hash/shift_spec.rb
opal-0.4.1 spec/rubyspec/core/hash/shift_spec.rb
opal-0.4.0 spec/rubyspec/core/hash/shift_spec.rb
opal-0.3.44 spec/rubyspec/core/hash/shift_spec.rb
opal-0.3.43 spec/rubyspec/core/hash/shift_spec.rb
opal-0.3.42 spec/core/hash/shift_spec.rb
opal-0.3.41 spec/core/hash/shift_spec.rb
opal-0.3.40 spec/core/hash/shift_spec.rb
opal-0.3.39 spec/core/hash/shift_spec.rb
opal-0.3.38 spec/core/hash/shift_spec.rb
opal-0.3.37 spec/core/hash/shift_spec.rb
opal-0.3.36 spec/core/hash/shift_spec.rb
opal-0.3.35 spec/core/hash/shift_spec.rb
opal-0.3.34 spec/core/hash/shift_spec.rb
opal-0.3.33 spec/core/hash/shift_spec.rb
opal-0.3.32 spec/core/hash/shift_spec.rb
opal-0.3.31 spec/core/hash/shift_spec.rb
opal-0.3.30 spec/core/hash/shift_spec.rb