aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-01-30 04:03:19 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-01-30 04:03:19 +0000
commit46142e472fd713023766aa2943158d7fd50011ae (patch)
tree9547d0ea035ed0b71c6b5e3a1705ffb5cca91c63 /test
parentf989f7c7ea89bb0b4a120666f5e85c0a81c9b44c (diff)
downloadruby-46142e472fd713023766aa2943158d7fd50011ae.tar.gz
* hash.c (rb_hash_fetch_m): use useful message for longer key, not a
nonsense id value. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30730 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_hash.rb10
1 files changed, 8 insertions, 2 deletions
diff --git a/test/ruby/test_hash.rb b/test/ruby/test_hash.rb
index 4c0d556896..82aba92529 100644
--- a/test/ruby/test_hash.rb
+++ b/test/ruby/test_hash.rb
@@ -373,8 +373,6 @@ class TestHash < Test::Unit::TestCase
end
def test_fetch
- assert_raise(KeyError) { @cls[].fetch(1) }
- assert_raise(KeyError) { @h.fetch('gumby') }
assert_equal('gumbygumby', @h.fetch('gumby') {|k| k * 2 })
assert_equal('pokey', @h.fetch('gumby', 'pokey'))
@@ -383,6 +381,14 @@ class TestHash < Test::Unit::TestCase
assert_equal('nil', @h.fetch(nil))
end
+ def test_fetch_error
+ assert_raise(KeyError) { @cls[].fetch(1) }
+ assert_raise(KeyError) { @h.fetch('gumby') }
+ e = assert_raise(KeyError) { @h.fetch('gumby'*20) }
+ assert_match(/key not found: "gumbygumby/, e.message)
+ assert_match(/\.\.\.\z/, e.message)
+ end
+
def test_key2?
assert(!@cls[].key?(1))
assert(!@cls[].key?(nil))