summaryrefslogtreecommitdiffstats
path: root/test/ruby/test_m17n.rb
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-10-02 11:46:40 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-10-02 11:46:40 +0000
commit1d42215eb5c0a68c542f5855010bcc816c01fdb6 (patch)
treed4e528d553256bdef37711ce58dba2705ad3df80 /test/ruby/test_m17n.rb
parent902cee38df868e69dac52300251e4d40d394fb37 (diff)
downloadruby-1d42215eb5c0a68c542f5855010bcc816c01fdb6.tar.gz
ruby-1d42215eb5c0a68c542f5855010bcc816c01fdb6.tar.xz
ruby-1d42215eb5c0a68c542f5855010bcc816c01fdb6.zip
* string.c (rb_str_sub_bang): fix coderange.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@19662 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_m17n.rb')
-rw-r--r--test/ruby/test_m17n.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/ruby/test_m17n.rb b/test/ruby/test_m17n.rb
index a1772f640..416d8e190 100644
--- a/test/ruby/test_m17n.rb
+++ b/test/ruby/test_m17n.rb
@@ -959,6 +959,21 @@ class TestM17N < Test::Unit::TestCase
assert_equal(Encoding::EUC_JP, "\xa4\xa2".force_encoding("euc-jp").gsub(/./, '\&').encoding)
end
+ def test_sub2
+ s = "\x80".force_encoding("ASCII-8BIT")
+ r = Regexp.new("\x80".force_encoding("ASCII-8BIT"))
+ s2 = s.sub(r, "")
+ assert(s2.empty?)
+ assert(s2.ascii_only?)
+ end
+
+ def test_sub3
+ repl = "\x81".force_encoding("sjis")
+ assert_equal(false, repl.valid_encoding?)
+ s = "a@".sub(/a/, repl)
+ assert(s.valid_encoding?)
+ end
+
def test_insert
s = e("\xa3\xb0\xa3\xb1\xa3\xb2\xa3\xb3\xa3\xb4")
assert_equal(e("\xa3\xb0\xa3\xb1\xa3\xb2\xa3\xb3\xa3\xb4a"), s.insert(-1, "a"))