diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_regexp.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/test/ruby/test_regexp.rb b/test/ruby/test_regexp.rb index 5cb6c810da..b415c03aa1 100644 --- a/test/ruby/test_regexp.rb +++ b/test/ruby/test_regexp.rb @@ -95,6 +95,13 @@ class TestRegexp < Test::Unit::TestCase assert_equal({}, /(.)(.)/.named_captures) end + def test_assign_named_capture + assert_equal("a", eval('/(?<foo>.)/ =~ "a"; foo')) + assert_equal("a", eval('foo = 1; /(?<foo>.)/ =~ "a"; foo')) + assert_equal("a", eval('1.times {|foo| /(?<foo>.)/ =~ "a"; break foo }')) + assert_raise(SyntaxError) { eval('/(?<Foo>.)/ =~ "a"') } + end + def test_match_regexp r = /./ m = r.match("a") |