summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-02-21 10:51:52 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-02-21 10:51:52 +0000
commit2d12151a686ccc71f62ae53f025605191342417c (patch)
treec30e4b74f2eff530ef1dcf61e3bbfe3fc0eb2459 /test
parent516e463aaf0850b21630e094e42ad0bb543c8c81 (diff)
re.c: RMatch::regexp can be nil
* 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/trunk@49675 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_regexp.rb13
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))