Sha256: b91e6f11282471a2013f33cafede2aafadb9a20ceb5d001235f1b9b4d7f1812c

Contents?: true

Size: 559 Bytes

Versions: 26

Compression:

Stored size: 559 Bytes

Contents

describe "Hash.new" do
  it "creates an empty Hash if passed no arguments" do
    Hash.new.should == {}
    Hash.new.size.should == 0
  end

  it "creates a new Hash with default object if passed a default argument" do
    Hash.new(5).default.should == 5
    Hash.new({}).default.should == {}
  end

  it "creates a Hash with a default_proc if passed a block" do
    Hash.new.default_proc.should == nil

    h = Hash.new { |x| "Answer to #{x}" }
    h.default_proc.call(5).should == "Answer to 5"
    h.default_proc.call("x").should == "Answer to x"
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

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