mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
5c3be90ae0
commit
483c7290f2
2 changed files with 7 additions and 1 deletions
|
@ -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];
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in a new issue