Sha256: c76165e349ead36841d9dbf7398542a04a2f158c05a8706da16b2a56211a2e22

Contents?: true

Size: 642 Bytes

Versions: 75

Compression:

Stored size: 642 Bytes

Contents

require 'test_helper'

class HashTest < Test::Unit::TestCase  
  context "Hash" do
    should "should be constructible from key value pairs" do
      assert_equal({1 => 2, 3 => 4}, Hash[[[1,2],[3,4]]])
    end
    
    context "#default_proc=" do
      should "conform to doc" do
        h = { :foo => :bar }
        h.default = "Go fish"
        h.default_proc=lambda do |hash, key| 
          key + key 
        end 
        assert_equal :bar, h[:foo]
        assert_equal 4, h[2]
        assert_equal "catcat", h["cat"]
        h.default=nil
        assert_equal nil, h[2]
        assert_equal nil, h["cat"]
      end
    end
  end
  
end

Version data entries

75 entries across 75 versions & 2 rubygems

Version Path
backports-1.8.0 test/hash_test.rb
backports-1.8.2 test/hash_test.rb
backports-1.8.1 test/hash_test.rb
backports-1.7.1 test/hash_test.rb
backports-1.3.0 test/hash_test.rb
backports-1.6.3 test/hash_test.rb
backports-1.6.1 test/hash_test.rb
backports-1.6.0 test/hash_test.rb
backports-1.3.1 test/hash_test.rb
backports-1.5.0 test/hash_test.rb
backports-1.7.0 test/hash_test.rb
backports-1.6.6 test/hash_test.rb
backports-1.6.7 test/hash_test.rb
backports-1.6.8 test/hash_test.rb
backports-1.6.4 test/hash_test.rb