diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-03-28 02:28:16 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-03-28 02:28:16 +0000 |
commit | 2f14bde88fc25fd49c5d72bac71e1f0381df944a (patch) | |
tree | 79c21674b0f5b7f98b6ff1023524dc3686251c6e /test | |
parent | 2d82342cf299220e0e7f84d464b205231fd41e8f (diff) | |
download | ruby-2f14bde88fc25fd49c5d72bac71e1f0381df944a.tar.gz |
string.c: backref substitution
* re.c (rb_reg_regsub): allow nil regexp for string matching.
* string.c (rb_str_sub_bang, str_gsub): make substitution if
replacement string has backref escapes.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45459 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_string.rb | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb index 62402353a7..5ee026c327 100644 --- a/test/ruby/test_string.rb +++ b/test/ruby/test_string.rb @@ -808,6 +808,7 @@ class TestString < Test::Unit::TestCase S("hello").gsub(/./) { |s| s[0].to_s + S(' ')}) assert_equal(S("HELL-o"), S("hello").gsub(/(hell)(.)/) { |s| $1.upcase + S('-') + $2 }) + assert_equal(S("<>h<>e<>l<>l<>o<>"), S("hello").gsub(S(''), S('<\0>'))) a = S("hello") a.taint @@ -1415,6 +1416,7 @@ class TestString < Test::Unit::TestCase assert_equal(S("HELL-o"), S("hello").sub(/(hell)(.)/) { |s| $1.upcase + S('-') + $2 }) + assert_equal(S("h<e>llo"), S("hello").sub('e', S('<\0>'))) assert_equal(S("a\\aba"), S("ababa").sub(/b/, '\\')) assert_equal(S("ab\\aba"), S("ababa").sub(/(b)/, '\1\\')) |