1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* enum.c (slice_before_i): use rb_attr_get to surpress wrong warning

for internal instance variable slicebefore_initial_state.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33324 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
naruse 2011-09-24 18:43:32 +00:00
parent 48ddab1e7d
commit 73220a234e
3 changed files with 22 additions and 1 deletions

View file

@ -1,3 +1,8 @@
Sun Sep 25 03:43:03 2011 NARUSE, Yui <naruse@ruby-lang.org>
* enum.c (slice_before_i): use rb_attr_get to surpress wrong warning
for internal instance variable slicebefore_initial_state.
Fri Sep 23 14:20:14 2011 Martin Bosslet <Martin.Bosslet@googlemail.com>
* ext/openssl/ossl_asn1.c: remove unused variable.

2
enum.c
View file

@ -2469,7 +2469,7 @@ slicebefore_i(VALUE yielder, VALUE enumerator, int argc, VALUE *argv)
enumerable = rb_ivar_get(enumerator, rb_intern("slicebefore_enumerable"));
arg.sep_pred = rb_attr_get(enumerator, rb_intern("slicebefore_sep_pred"));
arg.sep_pat = NIL_P(arg.sep_pred) ? rb_ivar_get(enumerator, rb_intern("slicebefore_sep_pat")) : Qnil;
arg.state = rb_ivar_get(enumerator, rb_intern("slicebefore_initial_state"));
arg.state = rb_attr_get(enumerator, rb_intern("slicebefore_initial_state"));
arg.prev_elts = Qnil;
arg.yielder = yielder;

View file

@ -1,5 +1,6 @@
require 'test/unit'
require 'continuation'
require 'stringio'
class TestEnumerable < Test::Unit::TestCase
def setup
@ -22,6 +23,20 @@ class TestEnumerable < Test::Unit::TestCase
$VERBOSE = @verbose
end
def assert_not_warn
begin
org_stderr = $stderr
v = $VERBOSE
$stderr = StringIO.new(warn = '')
$VERBOSE = true
yield
ensure
$stderr = org_stderr
$VERBOSE = v
end
assert_equal("", warn)
end
def test_grep
assert_equal([1, 2, 1, 2], @obj.grep(1..2))
a = []
@ -383,6 +398,7 @@ class TestEnumerable < Test::Unit::TestCase
ss = %w[abc defg h ijk l mno pqr st u vw xy z]
assert_equal([%w[abc defg h], %w[ijk l], %w[mno], %w[pqr st u vw xy z]],
ss.slice_before(/\A...\z/).to_a)
assert_not_warn{ss.slice_before(/\A...\z/).to_a}
end
end