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

test/ruby/test_enum.rb: Avoid "warning: assigned but unused variable"

This commit is contained in:
Yusuke Endoh 2020-12-16 16:17:54 +09:00
parent 19157a3c00
commit c668772b14

View file

@ -66,22 +66,22 @@ class TestEnumerable < Test::Unit::TestCase
def test_grep_optimization def test_grep_optimization
bug17030 = '[ruby-core:99156]' bug17030 = '[ruby-core:99156]'
'set last match' =~ /set last (.*)/ 'set last match' =~ /set last (.*)/
assert_equal([:a, 'b', :c], [:a, 'b', 'z', :c, 42, nil].grep(/[a-d]/)) assert_equal([:a, 'b', :c], [:a, 'b', 'z', :c, 42, nil].grep(/[a-d]/), bug17030)
assert_equal(['z', 42, nil], [:a, 'b', 'z', :c, 42, nil].grep_v(/[a-d]/)) assert_equal(['z', 42, nil], [:a, 'b', 'z', :c, 42, nil].grep_v(/[a-d]/), bug17030)
assert_equal('match', $1) assert_equal('match', $1, bug17030)
regexp = Regexp.new('x') regexp = Regexp.new('x')
assert_equal([], @obj.grep(regexp)) # sanity check assert_equal([], @obj.grep(regexp), bug17030) # sanity check
def regexp.===(other) def regexp.===(other)
true true
end end
assert_equal([1, 2, 3, 1, 2], @obj.grep(regexp)) assert_equal([1, 2, 3, 1, 2], @obj.grep(regexp), bug17030)
o = Object.new o = Object.new
def o.to_str def o.to_str
'hello' 'hello'
end end
assert_same(o, [o].grep(/ll/).first) assert_same(o, [o].grep(/ll/).first, bug17030)
end end
def test_count def test_count