aboutsummaryrefslogtreecommitdiffstats
path: root/test/ruby/test_m17n.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-09-16 05:50:00 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-09-16 05:50:00 +0000
commit4eb7dbc53cb22a529319d907da69d511ef3440fc (patch)
tree0cd1be11831d65517b08c912815a33d230f2948e /test/ruby/test_m17n.rb
parent9195e5ba6e0d272148ba36680c0823ed16f8fa90 (diff)
downloadruby-4eb7dbc53cb22a529319d907da69d511ef3440fc.tar.gz
string.c: keep coderange
* string.c (rb_str_setbyte): keep the code range as possible. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51873 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_m17n.rb')
-rw-r--r--test/ruby/test_m17n.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/ruby/test_m17n.rb b/test/ruby/test_m17n.rb
index 6b89ad572d..ca25f8502d 100644
--- a/test/ruby/test_m17n.rb
+++ b/test/ruby/test_m17n.rb
@@ -1488,6 +1488,31 @@ class TestM17N < Test::Unit::TestCase
s = u("\xE3\x81\x82\xE3\x81\x84")
s.setbyte(-4, 0x84)
assert_equal(u("\xE3\x81\x84\xE3\x81\x84"), s)
+
+ x = "x" * 100
+ t = nil
+ failure = proc {"#{i}: #{encdump(t)}"}
+
+ s = "\u{3042 3044}"
+ s.bytesize.times {|i|
+ t = s + x
+ t.setbyte(i, t.getbyte(i)+1)
+ assert_predicate(t, :valid_encoding?, failure)
+ assert_not_predicate(t, :ascii_only?, failure)
+ t = s + x
+ t.setbyte(i, 0x20)
+ assert_not_predicate(t, :valid_encoding?, failure)
+ }
+
+ s = "\u{41 42 43}"
+ s.bytesize.times {|i|
+ t = s + x
+ t.setbyte(i, 0x20)
+ assert_predicate(t, :valid_encoding?, failure)
+ assert_predicate(t, :ascii_only?, failure)
+ t.setbyte(i, 0xe3)
+ assert_not_predicate(t, :valid_encoding?, failure)
+ }
end
def test_compatible