mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
test/ruby/test_enumerator.rb: check the deprecation warning
by explicitly setting `Warning[:deprecated] = true`.
I removed "capture_io" at 79063d8cbf
, but
it printed the warning when `RUBYOPT=-w`.
This change makes the warnings enabled explicitly, capture and check the
warning.
This commit is contained in:
parent
0db5324e0d
commit
abdd3c5616
1 changed files with 9 additions and 1 deletions
|
@ -69,7 +69,15 @@ class TestEnumerator < Test::Unit::TestCase
|
|||
|
||||
def test_initialize
|
||||
assert_equal([1, 2, 3], @obj.to_enum(:foo, 1, 2, 3).to_a)
|
||||
assert_equal([1, 2, 3], Enumerator.new(@obj, :foo, 1, 2, 3).to_a)
|
||||
begin
|
||||
deprecated_bak, Warning[:deprecated] = Warning[:deprecated], true
|
||||
_, err = capture_io do
|
||||
assert_equal([1, 2, 3], Enumerator.new(@obj, :foo, 1, 2, 3).to_a)
|
||||
end
|
||||
assert_match 'Enumerator.new without a block is deprecated', err
|
||||
ensure
|
||||
Warning[:deprecated] = deprecated_bak
|
||||
end
|
||||
assert_equal([1, 2, 3], Enumerator.new { |y| i = 0; loop { y << (i += 1) } }.take(3))
|
||||
assert_raise(ArgumentError) { Enumerator.new }
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue