Sha256: 51f1a30dffd4adfce10aae12718abf520e3263d2a045540ce4a173810fedd3ff

Contents?: true

Size: 691 Bytes

Versions: 62

Compression:

Stored size: 691 Bytes

Contents

require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../fixtures/classes', __FILE__)

describe "Hash#to_a" do
  it "returns a list of [key, value] pairs with same order as each()" do
    h = new_hash(:a => 1, 1 => :a, 3 => :b, :b => 5)
    pairs = []

    h.each_pair do |key, value|
      pairs << [key, value]
    end

    h.to_a.should be_kind_of(Array)
    h.to_a.should == pairs
  end

  it "is called for Enumerable#entries" do
    h = new_hash(:a => 1, 1 => :a, 3 => :b, :b => 5)
    pairs = []

    h.each_pair do |key, value|
      pairs << [key, value]
    end

    ent = h.entries
    ent.should be_kind_of(Array)
    ent.should == pairs
  end
end

Version data entries

62 entries across 62 versions & 3 rubygems

Version Path
rhodes-7.6.0 spec/framework_spec/app/spec/core/hash/to_a_spec.rb
rhodes-7.5.1 spec/framework_spec/app/spec/core/hash/to_a_spec.rb
rhodes-7.4.1 spec/framework_spec/app/spec/core/hash/to_a_spec.rb
rhodes-7.1.17 spec/framework_spec/app/spec/core/hash/to_a_spec.rb
rhodes-6.2.0 spec/framework_spec/app/spec/core/hash/to_a_spec.rb
rhodes-6.0.11 spec/framework_spec/app/spec/core/hash/to_a_spec.rb
rhodes-5.5.18 spec/framework_spec/app/spec/core/hash/to_a_spec.rb
rhodes-5.5.17 spec/framework_spec/app/spec/core/hash/to_a_spec.rb
rhodes-5.5.15 spec/framework_spec/app/spec/core/hash/to_a_spec.rb
rhodes-5.5.0.22 spec/framework_spec/app/spec/core/hash/to_a_spec.rb
rhodes-5.5.2 spec/framework_spec/app/spec/core/hash/to_a_spec.rb
rhodes-5.5.0.7 spec/framework_spec/app/spec/core/hash/to_a_spec.rb
rhodes-5.5.0.3 spec/framework_spec/app/spec/core/hash/to_a_spec.rb
rhodes-5.5.0 spec/framework_spec/app/spec/core/hash/to_a_spec.rb
tauplatform-1.0.3 spec/framework_spec/app/spec/core/hash/to_a_spec.rb
tauplatform-1.0.2 spec/framework_spec/app/spec/core/hash/to_a_spec.rb
tauplatform-1.0.1 spec/framework_spec/app/spec/core/hash/to_a_spec.rb
jactive_support-2.1.2 spec/java_ext/map/to_a_spec.rb
jactive_support-3.0.0 spec/java_ext/map/to_a_spec.rb
jactive_support-3.0.0.pre2 spec/java_ext/map/to_a_spec.rb