diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-09-18 08:05:53 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-09-18 08:05:53 +0000 |
commit | 13f5dcb9f25cf07ef22baa5aded490395700b283 (patch) | |
tree | 5678b3e222c96077a2eb8e7a80e21dd5dbef1d3e /test/ruby/test_hash.rb | |
parent | 2627c19d82252f2bb571f6bcb44e359cacefa92b (diff) |
error.c: KeyError#receiver and KeyError#key
* error.c: new method KeyError#receiver and KeyError#key.
[Feature #12063]
* hash.c: make KeyError object with receiver and key.
* sprintf.c: ditto.
Author: ksss <co000ri@gmail.com>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59955 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_hash.rb')
-rw-r--r-- | test/ruby/test_hash.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/test/ruby/test_hash.rb b/test/ruby/test_hash.rb index 8fb1c17003..ebc622a827 100644 --- a/test/ruby/test_hash.rb +++ b/test/ruby/test_hash.rb @@ -531,6 +531,8 @@ class TestHash < Test::Unit::TestCase e = assert_raise(KeyError) { @h.fetch('gumby'*20) } assert_match(/key not found: "gumbygumby/, e.message) assert_match(/\.\.\.\z/, e.message) + assert_same(@h, e.receiver) + assert_equal('gumby'*20, e.key) end def test_key2? @@ -591,9 +593,11 @@ class TestHash < Test::Unit::TestCase assert_equal(4, res.length) assert_equal %w( three two one nil ), res - assert_raise KeyError do + e = assert_raise KeyError do @h.fetch_values(3, 'invalid') end + assert_same(@h, e.receiver) + assert_equal('invalid', e.key) res = @h.fetch_values(3, 'invalid') { |k| k.upcase } assert_equal %w( three INVALID ), res |