diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-05-19 03:10:12 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-05-19 03:10:12 +0000 |
commit | 9e36a8421df139cb264a4f621180122879398c9d (patch) | |
tree | 77998ac89b0fad3626652a2bd77dd0ca2be06cf4 /test | |
parent | 55f87e75866b6e5c1daf7c7624ccb633784243f0 (diff) | |
download | ruby-9e36a8421df139cb264a4f621180122879398c9d.tar.gz |
re.c: fix match?
* re.c (rb_reg_match_m_p): fix match against empty string.
rb_str_offset returns the end when the position exceeds the
length. fix the range parameter of onig_search.
[ruby-core:75604] [Bug #12394]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55069 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_regexp.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/test/ruby/test_regexp.rb b/test/ruby/test_regexp.rb index 8f5c9ceaa2..c25433b1ff 100644 --- a/test/ruby/test_regexp.rb +++ b/test/ruby/test_regexp.rb @@ -528,14 +528,21 @@ class TestRegexp < Test::Unit::TestCase def test_match_p /backref/ =~ 'backref' + # must match here, but not in a separate method, e.g., assert_send, + # to check if $~ is affected or not. assert_equal(false, //.match?(nil)) + assert_equal(true, //.match?("")) assert_equal(true, /.../.match?(:abc)) assert_raise(TypeError) { /.../.match?(Object.new) } + assert_equal(true, /b/.match?('abc')) + assert_equal(true, /b/.match?('abc', 1)) assert_equal(true, /../.match?('abc', 1)) assert_equal(true, /../.match?('abc', -2)) assert_equal(false, /../.match?("abc", -4)) assert_equal(false, /../.match?("abc", 4)) assert_equal(true, /../n.match?("\u3042" + '\x', 1)) + assert_equal(true, /\z/.match?("")) + assert_equal(true, /\z/.match?("abc")) assert_equal('backref', $&) end |