diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-02-22 12:20:57 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-02-22 12:20:57 +0000 |
commit | 1750670084712e9b55aec73ed8c89a6ead773042 (patch) | |
tree | aef8e6ae13fc936f62a1ca9e98de04d9e3176651 /test | |
parent | 23cf2750d15f6a859d13d7110e5994b3575c6604 (diff) |
merge revision(s) 49675:
* re.c (match_aref): RMatch::regexp is Qnil after matching by a
string since r45451. [ruby-core:68209] [Bug #10877]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@49690 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_regexp.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/test/ruby/test_regexp.rb b/test/ruby/test_regexp.rb index e16075ad38..cef21b99aa 100644 --- a/test/ruby/test_regexp.rb +++ b/test/ruby/test_regexp.rb @@ -545,6 +545,19 @@ class TestRegexp < Test::Unit::TestCase assert_equal("foo", $&) end + def test_match_without_regexp + bug10877 = '[ruby-core:68209] [Bug #10877]' + "abc".sub("a", "") + assert_raise_with_message(IndexError, /foo/, bug10877) {$~["foo"]} + key = "\u{3042}" + [Encoding::UTF_8, Encoding::Shift_JIS, Encoding::EUC_JP].each do |enc| + idx = key.encode(enc) + EnvUtil.with_default_external(enc) do + assert_raise_with_message(IndexError, /#{idx}/, bug10877) {$~[idx]} + end + end + end + def test_last_match /(...)(...)(...)(...)?/.match("foobarbaz") assert_equal("foobarbaz", Regexp.last_match(0)) |