From 782fd488d7abc7ccb0c8072349182ea8beb902f0 Mon Sep 17 00:00:00 2001 From: naruse Date: Thu, 21 Jan 2016 16:09:09 +0000 Subject: * regparse.c (fetch_name_with_level): allow non word characters at the first character. [Feature #11949] * regparse.c (fetch_name): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53610 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_regexp.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'test') diff --git a/test/ruby/test_regexp.rb b/test/ruby/test_regexp.rb index 96b0bfacb1..db83ee3ee7 100644 --- a/test/ruby/test_regexp.rb +++ b/test/ruby/test_regexp.rb @@ -142,6 +142,8 @@ class TestRegexp < Test::Unit::TestCase assert_equal("a[b]c", "abc".sub(/(?[bc])/, "[\\k]")) assert_equal("o", "foo"[/(?o)/, "bar"]) + assert_equal("o", "foo"[/(?<@bar>o)/, "@bar"]) + assert_equal("o", "foo"[/(?<@bar>.)\g<@bar>\k<@bar>/, "@bar"]) s = "foo" s[/(?o)/, "bar"] = "baz" @@ -175,6 +177,7 @@ class TestRegexp < Test::Unit::TestCase def test_assign_named_capture assert_equal("a", eval('/(?.)/ =~ "a"; foo')) + assert_equal(nil, eval('/(?<@foo>.)/ =~ "a"; defined?(@foo)')) assert_equal("a", eval('foo = 1; /(?.)/ =~ "a"; foo')) assert_equal("a", eval('1.times {|foo| /(?.)/ =~ "a"; break foo }')) assert_nothing_raised { eval('/(?.)/ =~ "a"') } @@ -939,6 +942,10 @@ class TestRegexp < Test::Unit::TestCase h = {a => 42} assert_equal(42, h[b], '[ruby-core:24748]') assert_match(/#\d+): (?.*)/.match("123456: hoge fuga") + assert_equal("123456", h["@time"]) + assert_equal("hoge fuga", h["body"]) end def test_regexp_poped -- cgit v1.2.3