diff options
| author | yui-knk <[email protected]> | 2014-05-10 10:18:15 +0900 |
|---|---|---|
| committer | yui-knk <[email protected]> | 2014-05-10 10:18:15 +0900 |
| commit | 658a00ba4927b433420c9b26dcbc2365fb657f2b (patch) | |
| tree | a66c0c883da1e17ccddf28d8e2bdf93b2c210a0f /mrbgems/mruby-hash-ext | |
| parent | e07a3731d1c7198eb5b443818c0f6a0601ca790d (diff) | |
| download | mruby-658a00ba4927b433420c9b26dcbc2365fb657f2b.tar.gz mruby-658a00ba4927b433420c9b26dcbc2365fb657f2b.zip | |
Change to raise TypeError (Hash#merge, #merge!)
Diffstat (limited to 'mrbgems/mruby-hash-ext')
| -rw-r--r-- | mrbgems/mruby-hash-ext/mrblib/hash.rb | 2 | ||||
| -rw-r--r-- | mrbgems/mruby-hash-ext/test/hash.rb | 4 |
2 files changed, 5 insertions, 1 deletions
diff --git a/mrbgems/mruby-hash-ext/mrblib/hash.rb b/mrbgems/mruby-hash-ext/mrblib/hash.rb index 259b0fa12..71a518238 100644 --- a/mrbgems/mruby-hash-ext/mrblib/hash.rb +++ b/mrbgems/mruby-hash-ext/mrblib/hash.rb @@ -22,7 +22,7 @@ class Hash # def merge!(other, &block) - raise "can't convert argument into Hash" unless other.respond_to?(:to_hash) + raise TypeError, "can't convert argument into Hash" unless other.respond_to?(:to_hash) if block other.each_key{|k| self[k] = (self.has_key?(k))? block.call(k, self[k], other[k]): other[k] diff --git a/mrbgems/mruby-hash-ext/test/hash.rb b/mrbgems/mruby-hash-ext/test/hash.rb index b9992fa96..62cfc8856 100644 --- a/mrbgems/mruby-hash-ext/test/hash.rb +++ b/mrbgems/mruby-hash-ext/test/hash.rb @@ -16,6 +16,10 @@ assert('Hash#merge!') do 'xyz_key' => 'xyz_value' }, result_1) assert_equal({'abc_key' => 'abc_value', 'cba_key' => 'cba_value', 'xyz_key' => 'xyz_value' }, result_2) + + assert_raise(TypeError) do + { 'abc_key' => 'abc_value' }.merge! "a" + end end assert('Hash#values_at') do |
