summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-08-03 16:20:58 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-08-03 16:20:58 +0000
commit3aefb61f15ca7d09f8465b7cc8036eec81d0830d (patch)
tree010109df292b3d2a84715282883604879ebf92b9 /test
parent84091a71e50ebe37f2261762fcef97cefe4c93ab (diff)
merge revision(s) r46345,r46346: [Backport #9903]
re.c: reduce new strings * re.c (match_aref, rb_reg_regsub): reduce new strings creation for exceptions. * re.c (match_aref, rb_reg_regsub): consider encoding of captured names, encoding-incompatible should not match. [ruby-dev:48278] [Bug #9903] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47052 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_regexp.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/ruby/test_regexp.rb b/test/ruby/test_regexp.rb
index b4b29a6368..bef770b923 100644
--- a/test/ruby/test_regexp.rb
+++ b/test/ruby/test_regexp.rb
@@ -158,6 +158,15 @@ class TestRegexp < Test::Unit::TestCase
}
end
+ def test_named_capture_nonascii
+ bug9903 = '[ruby-dev:48278] [Bug #9903]'
+
+ key = "\xb1\xb2".force_encoding(Encoding::EUC_JP)
+ m = /(?<#{key}>.*)/.match("xxx")
+ assert_equal("xxx", m[key])
+ assert_raise(IndexError, bug9903) {m[key.dup.force_encoding(Encoding::Shift_JIS)]}
+ end
+
def test_assign_named_capture
assert_equal("a", eval('/(?<foo>.)/ =~ "a"; foo'))
assert_equal("a", eval('foo = 1; /(?<foo>.)/ =~ "a"; foo'))