Project

General

Profile

Bug #6214 ยป no-warn-enum-inspect.patch

no6v (Nobuhiro IMAI), 03/30/2012 10:50 PM

View differences:

enumerator.c
return str;
}
eobj = rb_iv_get(obj, "receiver");
eobj = rb_attr_get(obj, rb_intern("receiver"));
if (NIL_P(eobj)) {
eobj = e->obj;
}
......
/* (1..100).each_cons(2) => "#<Enumerator: 1..100:each_cons(2)>" */
str = rb_sprintf("#<%s: ", cname);
rb_str_concat(str, rb_inspect(eobj));
method = rb_iv_get(obj, "method");
method = rb_attr_get(obj, rb_intern("method"));
if (NIL_P(method)) {
rb_str_buf_cat2(str, ":");
rb_str_buf_cat2(str, rb_id2name(e->meth));
......
rb_str_buf_cat2(str, rb_id2name(SYM2ID(method)));
}
eargs = rb_iv_get(obj, "arguments");
eargs = rb_attr_get(obj, rb_intern("arguments"));
if (NIL_P(eargs)) {
eargs = e->args;
}
test/ruby/test_enumerator.rb
require 'test/unit'
require_relative 'envutil'
class TestEnumerator < Test::Unit::TestCase
def setup
......
e.inspect)
end
def test_inspect_verbose
bug6214 = '[ruby-dev:45449]'
assert_warn("", bug6214) { "".bytes.inspect }
assert_warn("", bug6214) { [].lazy.inspect }
end
def test_generator
# note: Enumerator::Generator is a class just for internal
g = Enumerator::Generator.new {|y| y << 1 << 2 << 3; :foo }
    (1-1/1)