mirror of
https://github.com/ruby/ruby.git
synced 2025-08-24 21:44:30 +02:00
* re.c (rb_reg_match_m_p): Introduce Regexp#match?, which returns
bool and doesn't save backref. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55061 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
898aeb8779
commit
f09574c879
4 changed files with 98 additions and 0 deletions
|
@ -526,6 +526,19 @@ class TestRegexp < Test::Unit::TestCase
|
|||
$_ = nil; assert_nil(~/./)
|
||||
end
|
||||
|
||||
def test_match_p
|
||||
/backref/ =~ 'backref'
|
||||
assert_nil(//.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(true, /../n.match?("\u3042" + '\x', 1))
|
||||
assert_equal('backref', $&)
|
||||
end
|
||||
|
||||
def test_eqq
|
||||
assert_equal(false, /../ === nil)
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue