Sha256: 4c105eeb84db694d5df26f9b5c18133505f145eca5948cfd98bed83d14f25503
Contents?: true
Size: 539 Bytes
Versions: 16
Compression:
Stored size: 539 Bytes
Contents
require 'facets/hash/keys' require 'test/unit' class TC_Hash_Keys < Test::Unit::TestCase def test_each_with_key h1 = { :a=>1, :b=>2 } h2 = {} h1.each_with_key { |v,k| h2[v] = k } assert_equal( {1=>:a, 2=>:b}, h2 ) end def test_has_keys? assert( { :a=>1,:b=>2,:c=>3 }.has_keys?(:a,:b) ) assert( ! { :a=>1,:b=>2,:c=>3 }.has_keys?(:a,:b,:d) ) end def test_has_only_keys? assert( { :a=>1,:b=>2,:c=>3 }.has_only_keys?(:a,:b,:c) ) assert( ! { :a=>1,:b=>2,:c=>3 }.has_only_keys?(:a,:b) ) end end
Version data entries
16 entries across 16 versions & 1 rubygems