diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-12-24 00:48:15 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-12-24 00:48:15 +0000 |
commit | 483c7290f2509a9d5a3e193a66689971394d4de8 (patch) | |
tree | edb5f34e8752a4b5e7e69ad5b4f15dd9643fcc9b | |
parent | 5c3be90ae09f03f412cde51dc500da51827aafe7 (diff) | |
download | ruby-483c7290f2509a9d5a3e193a66689971394d4de8.tar.gz |
enumerator.c: fix inspect with the last empty hash
[ruby-core:90685] [Bug #15455]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66519 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | enumerator.c | 2 | ||||
-rw-r--r-- | test/ruby/test_enumerator.rb | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/enumerator.c b/enumerator.c index 021daeba59..609fc71015 100644 --- a/enumerator.c +++ b/enumerator.c @@ -1105,7 +1105,7 @@ append_method(VALUE obj, VALUE str, ID default_method, VALUE default_args) rb_str_buf_cat2(str, "("); - if (RB_TYPE_P(argv[argc-1], T_HASH)) { + if (RB_TYPE_P(argv[argc-1], T_HASH) && !RHASH_EMPTY_P(argv[argc-1])) { int all_key = TRUE; rb_hash_foreach(argv[argc-1], key_symbol_p, (VALUE)&all_key); if (all_key) kwds = argv[--argc]; diff --git a/test/ruby/test_enumerator.rb b/test/ruby/test_enumerator.rb index afd356105d..efcfef580f 100644 --- a/test/ruby/test_enumerator.rb +++ b/test/ruby/test_enumerator.rb @@ -407,6 +407,12 @@ class TestEnumerator < Test::Unit::TestCase e = (0..10).each_cons(2) assert_equal("#<Enumerator: 0..10:each_cons(2)>", e.inspect) + e = (0..10).each_with_object({}) + assert_equal("#<Enumerator: 0..10:each_with_object({})>", e.inspect) + + e = (0..10).each_with_object(a: 1) + assert_equal("#<Enumerator: 0..10:each_with_object(a: 1)>", e.inspect) + e = Enumerator.new {|y| y.yield; 10 } assert_match(/\A#<Enumerator: .*:each>/, e.inspect) |