mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* enumerator.c (inspect_enumerator): suppress uninitialized
instance variable warnings. [ruby-dev:45449][Bug #6214] patched by no6v (Nobuhiro IMAI). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35218 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
ecabd16923
commit
63e8110bfc
3 changed files with 16 additions and 3 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
Tue Apr 3 10:18:27 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* enumerator.c (inspect_enumerator): suppress uninitialized
|
||||||
|
instance variable warnings. [ruby-dev:45449][Bug #6214]
|
||||||
|
patched by no6v (Nobuhiro IMAI).
|
||||||
|
|
||||||
Mon Apr 2 13:25:08 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Mon Apr 2 13:25:08 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* lib/optparse/ac.rb: autoconf-like options.
|
* lib/optparse/ac.rb: autoconf-like options.
|
||||||
|
|
|
@ -875,7 +875,7 @@ inspect_enumerator(VALUE obj, VALUE dummy, int recur)
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
eobj = rb_iv_get(obj, "receiver");
|
eobj = rb_attr_get(obj, rb_intern("receiver"));
|
||||||
if (NIL_P(eobj)) {
|
if (NIL_P(eobj)) {
|
||||||
eobj = e->obj;
|
eobj = e->obj;
|
||||||
}
|
}
|
||||||
|
@ -886,7 +886,7 @@ inspect_enumerator(VALUE obj, VALUE dummy, int recur)
|
||||||
/* (1..100).each_cons(2) => "#<Enumerator: 1..100:each_cons(2)>" */
|
/* (1..100).each_cons(2) => "#<Enumerator: 1..100:each_cons(2)>" */
|
||||||
str = rb_sprintf("#<%s: ", cname);
|
str = rb_sprintf("#<%s: ", cname);
|
||||||
rb_str_concat(str, rb_inspect(eobj));
|
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)) {
|
if (NIL_P(method)) {
|
||||||
rb_str_buf_cat2(str, ":");
|
rb_str_buf_cat2(str, ":");
|
||||||
rb_str_buf_cat2(str, rb_id2name(e->meth));
|
rb_str_buf_cat2(str, rb_id2name(e->meth));
|
||||||
|
@ -897,7 +897,7 @@ inspect_enumerator(VALUE obj, VALUE dummy, int recur)
|
||||||
rb_str_buf_cat2(str, rb_id2name(SYM2ID(method)));
|
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)) {
|
if (NIL_P(eargs)) {
|
||||||
eargs = e->args;
|
eargs = e->args;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
require 'test/unit'
|
require 'test/unit'
|
||||||
|
require_relative 'envutil'
|
||||||
|
|
||||||
class TestEnumerator < Test::Unit::TestCase
|
class TestEnumerator < Test::Unit::TestCase
|
||||||
def setup
|
def setup
|
||||||
|
@ -358,6 +359,12 @@ class TestEnumerator < Test::Unit::TestCase
|
||||||
e.inspect)
|
e.inspect)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_inspect_verbose
|
||||||
|
bug6214 = '[ruby-dev:45449]'
|
||||||
|
assert_warn("", bug6214) { "".bytes.inspect }
|
||||||
|
assert_warn("", bug6214) { [].lazy.inspect }
|
||||||
|
end
|
||||||
|
|
||||||
def test_generator
|
def test_generator
|
||||||
# note: Enumerator::Generator is a class just for internal
|
# note: Enumerator::Generator is a class just for internal
|
||||||
g = Enumerator::Generator.new {|y| y << 1 << 2 << 3; :foo }
|
g = Enumerator::Generator.new {|y| y << 1 << 2 << 3; :foo }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue