Sha256: ea0c91f20f8f86df4eff6676d8fcbda69b64f36f72f2c6cece1c6561798aaa16

Contents?: true

Size: 751 Bytes

Versions: 4

Compression:

Stored size: 751 Bytes

Contents

#!/usr/bin/env ruby
# $Id: test-hash.rb 159 2006-07-24 08:13:02Z larry $

$:.unshift File.join(File.dirname(__FILE__), "..", "lib")

require 'test/unit'
require 'core_ext/hash'
  
class TestHash < Test::Unit::TestCase
  def test_simple_merge
    h1 = {:x => 'a', :y => 'b'}
    h2 = {:x => 'p', :z => 'd'}
    
    hm1 = h1.merge(h2)
    hm2 = h1.deep_merge(h2)
    
    assert_equal hm1, hm2
  end
  
  def test_two_level
    h1 = {:x => {:a => 1, :b => 2}, :y => 3, :z => 4}
    h2 = {:x => {:a => 10, :c => 20}, :y =>30, :p => 40 }
    
    hm = h1.deep_merge(h2)
    assert_equal( {:x => {:a => 10, :b => 2, :c => 20}, 
                   :y => 30, :z => 4, :p => 40 },
                  hm )
    
    assert_not_equal(hm, h1.merge(h2))
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
tartan-0.2.1 test/test-hash.rb
tartan-0.1.1 test/test-hash.rb
tartan-0.1.0 test/test-hash.rb
tartan-0.2.0 test/test-hash.rb