Sha256: e19e4d549c031dec6f0aa71e675fee76a76d6b304d78a44b6565493661f21cd1

Contents?: true

Size: 360 Bytes

Versions: 29

Compression:

Stored size: 360 Bytes

Contents

describe "Hash#index" do
  it "returns the corresponding key for value" do
    {2 => 'a', 1 => 'b'}.index('b').should == 1
  end

  it "returns nil if the value is not found" do
    {:a => -1, :b => 3.14, :c => 2.718}.index(1).should be_nil
  end

  it "doesn't return default value if the value isn't found" do
    Hash.new(5).index(5).should be_nil
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

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