re.c: match? should return nil if no match

* re.c (rb_reg_match_m_p): should return nil if no match, as the
  document says.  [Feature #8110]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55067 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2016-05-19 02:37:38 +00:00
parent c2dc696067
commit 780c056dad
3 changed files with 11 additions and 6 deletions

View file

@ -528,13 +528,13 @@ class TestRegexp < Test::Unit::TestCase
def test_match_p
/backref/ =~ 'backref'
assert_nil(//.match?(nil))
assert_equal(false, //.match?(nil))
assert_equal(true, /.../.match?(:abc))
assert_raise(TypeError) { /.../.match?(Object.new) }
assert_equal(true, /../.match?('abc', 1))
assert_equal(true, /../.match?('abc', -2))
assert_nil(/../.match?("abc", -4))
assert_nil(/../.match?("abc", 4))
assert_equal(false, /../.match?("abc", -4))
assert_equal(false, /../.match?("abc", 4))
assert_equal(true, /../n.match?("\u3042" + '\x', 1))
assert_equal('backref', $&)
end