Add a test for svar #7225 (#7228)

This commit is contained in:
Takashi Kokubun 2023-02-01 21:47:45 -08:00 committed by GitHub
parent 4d82e94200
commit 1c5bd01363
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
Notes: git 2023-02-02 05:48:05 +00:00
Merged-By: k0kubun <takashikkbn@gmail.com>

View File

@ -1334,4 +1334,16 @@ class TestEnumerable < Test::Unit::TestCase
assert_equal([], @obj.filter_map { nil })
assert_instance_of(Enumerator, @obj.filter_map)
end
def test_ruby_svar
klass = Class.new do
include Enumerable
def each
%w(bar baz).each{|e| yield e}
end
end
svars = []
klass.new.grep(/(b.)/) { svars << $1 }
assert_equal(["ba", "ba"], svars)
end
end