From f17af09b264975fea3ce03210f740c17c96b62db Mon Sep 17 00:00:00 2001 From: akr Date: Sat, 14 Mar 2009 18:04:21 +0000 Subject: * string.c (rb_str_subpat): accept capture name. (rb_str_aref): follow above change. (rb_str_aref_m): pass the 2nd argument to rb_str_subpat. (rb_str_subpat_set): accept capture name. (rb_str_aset): follow above change. (rb_str_partition): ditto. (rb_str_aset_m): pass the 2nd argument to rb_str_subpat_set. * include/ruby/intern.h (rb_reg_backref_number): declared. * re.c (rb_reg_backref_number): defined. [ruby-core:21057] git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@22959 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_regexp.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_regexp.rb b/test/ruby/test_regexp.rb index d6441c957..8b7b6c053 100644 --- a/test/ruby/test_regexp.rb +++ b/test/ruby/test_regexp.rb @@ -104,6 +104,12 @@ class TestRegexp < Test::Unit::TestCase assert_equal({}, /(.)(.)/.named_captures) assert_equal("a[b]c", "abc".sub(/(?[bc])/, "[\\k]")) + + assert_equal("o", "foo"[/(?o)/, "bar"]) + + s = "foo" + s[/(?o)/, "bar"] = "baz" + assert_equal("fbazo", s) end def test_assign_named_capture -- cgit