summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-03-25 15:36:01 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-03-25 15:36:01 +0000
commit8dc3d3fd54982480b3bf8ce2e0112bded800b982 (patch)
tree09333c5268c7dec211e7dd5807d9b0ece92de58c /test
parenta0f4f4369b4d5a04f163bfaa20c4360aba3cee29 (diff)
merge revision(s) 57302,57303,57304: [Backport #13119]
string.c: block for scrub with ASCII-incompatible * string.c (rb_enc_str_scrub): honor the given block with ASCII-incompatible encoding. [ruby-core:79039] [Bug #13120] string.c: yield invalid part * string.c (rb_enc_str_scrub): yield the invalid part only with ASCII-incompatible. [ruby-core:79039] [Bug #13120] string.c: replacement and block * string.c (rb_enc_str_scrub): only one of replacement and block is allowed. [ruby-core:79038] [Bug #13119] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@58091 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_m17n.rb9
1 files changed, 8 insertions, 1 deletions
diff --git a/test/ruby/test_m17n.rb b/test/ruby/test_m17n.rb
index a4a2630edd..e78bfdb0cf 100644
--- a/test/ruby/test_m17n.rb
+++ b/test/ruby/test_m17n.rb
@@ -1592,8 +1592,9 @@ class TestM17N < Test::Unit::TestCase
assert_raise(ArgumentError){ u("\xE3\x81\x82\xE3\x81\x82\xE3\x81").scrub{u("\x81")} }
assert_equal(e("\xA4\xA2\xA2\xAE"), e("\xA4\xA2\xA4").scrub{e("\xA2\xAE")})
- assert_equal(u("\x81"), u("a\x81").scrub {|c| break c})
+ assert_equal(u("\x81"), u("a\x81c").scrub {|c| break c})
assert_raise(ArgumentError) {u("a\x81").scrub {|c| c}}
+ assert_raise(ArgumentError) {u("a").scrub("?") {|c| c}}
end
def test_scrub_widechar
@@ -1609,6 +1610,12 @@ class TestM17N < Test::Unit::TestCase
assert_equal("\uFFFD".encode("UTF-32LE"),
"\xff".force_encoding(Encoding::UTF_32LE).
scrub)
+ c = nil
+ assert_equal("?\u3042".encode(Encoding::UTF_16LE),
+ "\x00\xD8\x42\x30".force_encoding(Encoding::UTF_16LE).
+ scrub {|e| c = e; "?".encode(Encoding::UTF_16LE)})
+ assert_equal("\x00\xD8".force_encoding(Encoding::UTF_16LE), c)
+ assert_raise(ArgumentError) {"\uFFFD\u3042".encode("UTF-16BE").scrub("") {}}
end
def test_scrub_bang