Skip to content
Permalink
Browse files
protect NoMethodError from calling to_hash in replace
  • Loading branch information
visualsayed committed Jan 27, 2016
1 parent 2723b10 commit f5f48d9400420617fa8bee3b53075894b3a53c1c
Showing 2 changed files with 5 additions and 0 deletions.
@@ -154,6 +154,7 @@ def each_value(&block)
#
# ISO 15.2.13.4.23
def replace(hash)
raise TypeError, "can't convert argument into Hash" unless hash.respond_to?(:to_hash)
self.clear
hash = hash.to_hash
hash.each_key{|k|
@@ -239,6 +239,10 @@
a = Hash.new{|h,x| x}
b.replace(a)
assert_equal(127, b[127])

assert_raise(TypeError) do
{ 'abc_key' => 'abc_value' }.replace "a"
end
end

assert('Hash#shift', '15.2.13.4.24') do

0 comments on commit f5f48d9

Please sign in to comment.