From 73220a234e978fe92b20287a1d4cd1c540ffe103 Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 24 Sep 2011 18:43:32 +0000 Subject: * 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 --- test/ruby/test_enum.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'test/ruby/test_enum.rb') diff --git a/test/ruby/test_enum.rb b/test/ruby/test_enum.rb index d5353f680c..c8f2fad546 100644 --- a/test/ruby/test_enum.rb +++ b/test/ruby/test_enum.rb @@ -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 -- cgit v1.2.3