aboutsummaryrefslogtreecommitdiffstats
path: root/test/ruby/test_string.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-03-28 02:27:14 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-03-28 02:27:14 +0000
commit2d82342cf299220e0e7f84d464b205231fd41e8f (patch)
tree17ecfd3cb9eaade2d48507ac28bc8777e3c12a4f /test/ruby/test_string.rb
parent209a310c47a6e1f68f209bbf7038b12096d86b46 (diff)
downloadruby-2d82342cf299220e0e7f84d464b205231fd41e8f.tar.gz
string.c: unset $~ if unmatch
* string.c (rb_pat_search): unset $~ if the last match failed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45458 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_string.rb')
-rw-r--r--test/ruby/test_string.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb
index 5c8c4184a0..62402353a7 100644
--- a/test/ruby/test_string.rb
+++ b/test/ruby/test_string.rb
@@ -1147,6 +1147,14 @@ class TestString < Test::Unit::TestCase
res = []
a.scan(/./) { |w| res << w }
assert_predicate(res[0], :tainted?, '[ruby-core:33338] #4087')
+
+ /h/ =~ a
+ a.scan(/x/)
+ assert_nil($~)
+
+ /h/ =~ a
+ a.scan('x')
+ assert_nil($~)
end
def test_size