Sha256: b9a36096cc0cf718b9174c393d6e5aedaed94d47f97ba1170f8474530144f10c

Contents?: true

Size: 876 Bytes

Versions: 2

Compression:

Stored size: 876 Bytes

Contents

require 'facets/hash/rekey'
require 'test/unit'

class TC_Hash_Prime < Test::Unit::TestCase

  def test_rekey_01
    foo = { :a=>1, :b=>2 }
    assert_equal( { "a"=>1, "b"=>2 }, foo.rekey{|k|k.to_s} )
    assert_equal( { :a =>1, :b=>2 }, foo  )
  end

  def test_rekey_02
    foo = { :a=>1, :b=>2 }
    assert_equal( { "a"=>1, "b"=>2 }, foo.rekey!{|k|k.to_s}  )
    assert_equal( { "a"=>1, "b"=>2 }, foo )
  end

  def test_rekey_03
    foo = { :a=>1, :b=>2 }
    assert_equal( { "a"=>1, "b"=>2 }, foo.rekey(:to_s) )
    assert_equal( { :a =>1, :b=>2 }, foo  )
  end

  def test_rekey_04
    foo = { :a=>1, :b=>2 }
    assert_equal( { "a"=>1, "b"=>2 }, foo.rekey!(:to_s) )
    assert_equal( { "a"=>1, "b"=>2 }, foo )
  end

  def test_rekey_05
    foo = { "a"=>1, "b"=>2 }
    assert_equal( { :a=>1, :b=>2 }, foo.rekey! )
    assert_equal( { :a=>1, :b=>2 }, foo )
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
facets-2.4.0 test/hash/test_rekey2.rb
facets-2.4.1 test/hash/test_rekey2.rb