mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* test/readline/test_readline.rb (test_completion_encoding): test on more locales.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34398 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
bfaba73ebb
commit
cba57022b0
1 changed files with 27 additions and 11 deletions
|
@ -283,27 +283,43 @@ class TestReadline < Test::Unit::TestCase
|
||||||
|
|
||||||
def test_completion_encoding
|
def test_completion_encoding
|
||||||
bug5941 = '[Bug #5941]'
|
bug5941 = '[Bug #5941]'
|
||||||
|
append_character = Readline.completion_append_character
|
||||||
|
Readline.completion_append_character = ""
|
||||||
completion_case_fold = Readline.completion_case_fold
|
completion_case_fold = Readline.completion_case_fold
|
||||||
Readline.completion_case_fold = false
|
locale = Encoding.find("locale")
|
||||||
case locale = Encoding.find("locale")
|
if locale == Encoding::UTF_8
|
||||||
when Encoding::UTF_8
|
|
||||||
enc1 = Encoding::EUC_JP
|
enc1 = Encoding::EUC_JP
|
||||||
when Encoding::EUC_JP, Encoding::Windows_31J
|
|
||||||
enc1 = Encoding::UTF_8
|
|
||||||
else
|
else
|
||||||
skip
|
enc1 = Encoding::UTF_8
|
||||||
end
|
end
|
||||||
results = nil
|
results = nil
|
||||||
Readline.completion_proc = ->(text) {results}
|
Readline.completion_proc = ->(text) {results}
|
||||||
|
|
||||||
results = ["\u{3042 3042}", "\u{3042 3044}"].map {|s| s.encode(locale)}
|
[%W"\u{3042 3042} \u{3042 3044}", %W"\u{fe5b fe5b} \u{fe5b fe5c}"].any? do |w|
|
||||||
assert_equal("\u{3042}", with_pipe {|r, w| w << "\t"}, bug5941)
|
begin
|
||||||
|
results = w.map {|s| s.encode(locale)}
|
||||||
|
rescue Encoding::UndefinedConversionError
|
||||||
|
end
|
||||||
|
end or
|
||||||
|
begin
|
||||||
|
"\xa1\xa2".encode(Encoding::UTF_8, locale)
|
||||||
|
rescue
|
||||||
|
else
|
||||||
|
results = %W"\xa1\xa1 \xa1\xa2".map {|s| s.force_encoding(locale)}
|
||||||
|
end or
|
||||||
|
skip("missing test for locale #{locale.name}")
|
||||||
|
expected = results[0][0...1]
|
||||||
Readline.completion_case_fold = false
|
Readline.completion_case_fold = false
|
||||||
assert_equal("\u{3042}", with_pipe {|r, w| w << "\t"}, bug5941)
|
assert_equal(expected, with_pipe {|r, w| w << "\t"}, bug5941)
|
||||||
results = ["\u{3042 3042}", "\u{3042 3044}"].map {|s| s.encode(enc1)}
|
Readline.completion_case_fold = true
|
||||||
assert_raise(Encoding::CompatibilityError, bug5941) {with_pipe {|r, w| w << "\t"}}
|
assert_equal(expected, with_pipe {|r, w| w << "\t"}, bug5941)
|
||||||
|
results.map! {|s| s.encode(enc1)}
|
||||||
|
assert_raise(Encoding::CompatibilityError, bug5941) do
|
||||||
|
with_pipe {|r, w| w << "\t"}
|
||||||
|
end
|
||||||
ensure
|
ensure
|
||||||
Readline.completion_case_fold = completion_case_fold
|
Readline.completion_case_fold = completion_case_fold
|
||||||
|
Readline.completion_append_character = append_character
|
||||||
end
|
end
|
||||||
|
|
||||||
# basic_word_break_characters
|
# basic_word_break_characters
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue