summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-05-18 10:37:13 (GMT)
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-05-18 10:37:13 (GMT)
commitf09574c879fe9a4488164a41b453617b4b1d56bb (patch)
tree4cde28960bec2ae35fa9a1c1c0d65900d940d8f3 /test
parent898aeb87792e952ba831931c2212baa50d81b62e (diff)
* 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
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 0562785..4d53411 100644
--- a/test/ruby/test_regexp.rb
+++ b/test/ruby/test_regexp.rb
@@ -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