Skip to content

Commit

Permalink
Add a test for svar #7225
Browse files Browse the repository at this point in the history
  • Loading branch information
k0kubun committed Feb 2, 2023
1 parent 0a82bfe commit 97426c1
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/ruby/test_enum.rb
Expand Up @@ -1334,4 +1334,16 @@ def test_filter_map
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

0 comments on commit 97426c1

Please sign in to comment.