mirror of
https://github.com/ruby/ruby.git
synced 2025-08-24 21:44:30 +02:00
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
This commit is contained in:
parent
516e463aaf
commit
2d12151a68
3 changed files with 21 additions and 2 deletions
|
@ -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))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue