mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* test/readline/test_readline_history.rb: check the encoding that
is in the Readline::HISTORY. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20974 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
60efdd5bbd
commit
823cfeed89
2 changed files with 29 additions and 21 deletions
|
@ -1,3 +1,8 @@
|
|||
Thu Dec 25 01:09:23 2008 TAKAO Kouji <kouji@takao7.net>
|
||||
|
||||
* test/readline/test_readline_history.rb: check the encoding that
|
||||
is in the Readline::HISTORY.
|
||||
|
||||
Thu Dec 25 00:59:06 2008 TAKAO Kouji <kouji@takao7.net>
|
||||
|
||||
* test/readline/test_readline_history.rb: did not check the
|
||||
|
|
|
@ -82,7 +82,7 @@ class Readline::TestHistory < Test::Unit::TestCase
|
|||
def test_get
|
||||
lines = push_history(5)
|
||||
lines.each_with_index do |s, i|
|
||||
assert_encoded_string_equal(s, HISTORY[i])
|
||||
assert_external_string_equal(s, HISTORY[i])
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -116,9 +116,8 @@ class Readline::TestHistory < Test::Unit::TestCase
|
|||
lines = push_history(5)
|
||||
5.times do |i|
|
||||
expected = "set: #{i}"
|
||||
s = (HISTORY[i] = expected)
|
||||
assert_encoded_string_equal(expected, HISTORY[i])
|
||||
assert_encoded_string_equal(expected, s)
|
||||
HISTORY[i] = expected
|
||||
assert_external_string_equal(expected, HISTORY[i])
|
||||
end
|
||||
rescue NotImplementedError
|
||||
end
|
||||
|
@ -150,7 +149,7 @@ class Readline::TestHistory < Test::Unit::TestCase
|
|||
5.times do |i|
|
||||
s = i.to_s
|
||||
assert_equal(HISTORY, HISTORY.push(s))
|
||||
assert_encoded_string_equal(s, HISTORY[i])
|
||||
assert_external_string_equal(s, HISTORY[i])
|
||||
end
|
||||
assert_equal(5, HISTORY.length)
|
||||
end
|
||||
|
@ -159,7 +158,7 @@ class Readline::TestHistory < Test::Unit::TestCase
|
|||
5.times do |i|
|
||||
s = i.to_s
|
||||
assert_equal(HISTORY, HISTORY << s)
|
||||
assert_encoded_string_equal(s, HISTORY[i])
|
||||
assert_external_string_equal(s, HISTORY[i])
|
||||
end
|
||||
assert_equal(5, HISTORY.length)
|
||||
end
|
||||
|
@ -167,13 +166,13 @@ class Readline::TestHistory < Test::Unit::TestCase
|
|||
def test_push__plural
|
||||
assert_equal(HISTORY, HISTORY.push("0", "1", "2", "3", "4"))
|
||||
(0..4).each do |i|
|
||||
assert_encoded_string_equal(i.to_s, HISTORY[i])
|
||||
assert_external_string_equal(i.to_s, HISTORY[i])
|
||||
end
|
||||
assert_equal(5, HISTORY.length)
|
||||
|
||||
assert_equal(HISTORY, HISTORY.push("5", "6", "7", "8", "9"))
|
||||
(5..9).each do |i|
|
||||
assert_encoded_string_equal(i.to_s, HISTORY[i])
|
||||
assert_external_string_equal(i.to_s, HISTORY[i])
|
||||
end
|
||||
assert_equal(10, HISTORY.length)
|
||||
end
|
||||
|
@ -184,7 +183,7 @@ class Readline::TestHistory < Test::Unit::TestCase
|
|||
|
||||
lines = push_history(5)
|
||||
(1..5).each do |i|
|
||||
assert_encoded_string_equal(lines[-i], HISTORY.pop)
|
||||
assert_external_string_equal(lines[-i], HISTORY.pop)
|
||||
assert_equal(lines.length - i, HISTORY.length)
|
||||
end
|
||||
|
||||
|
@ -199,7 +198,7 @@ class Readline::TestHistory < Test::Unit::TestCase
|
|||
|
||||
lines = push_history(5)
|
||||
(0..4).each do |i|
|
||||
assert_encoded_string_equal(lines[i], HISTORY.shift)
|
||||
assert_external_string_equal(lines[i], HISTORY.shift)
|
||||
assert_equal(lines.length - (i + 1), HISTORY.length)
|
||||
end
|
||||
|
||||
|
@ -216,8 +215,8 @@ class Readline::TestHistory < Test::Unit::TestCase
|
|||
lines = push_history(5)
|
||||
i = 0
|
||||
e = HISTORY.each do |s|
|
||||
assert_encoded_string_equal(HISTORY[i], s)
|
||||
assert_encoded_string_equal(lines[i], s)
|
||||
assert_external_string_equal(HISTORY[i], s)
|
||||
assert_external_string_equal(lines[i], s)
|
||||
i += 1
|
||||
end
|
||||
assert_equal(HISTORY, e)
|
||||
|
@ -252,22 +251,22 @@ class Readline::TestHistory < Test::Unit::TestCase
|
|||
begin
|
||||
lines = push_history(5)
|
||||
(0..4).each do |i|
|
||||
assert_encoded_string_equal(lines[i], HISTORY.delete_at(0))
|
||||
assert_external_string_equal(lines[i], HISTORY.delete_at(0))
|
||||
end
|
||||
assert(HISTORY.empty?)
|
||||
|
||||
lines = push_history(5)
|
||||
(1..5).each do |i|
|
||||
assert_encoded_string_equal(lines[lines.length - i], HISTORY.delete_at(-1))
|
||||
assert_external_string_equal(lines[lines.length - i], HISTORY.delete_at(-1))
|
||||
end
|
||||
assert(HISTORY.empty?)
|
||||
|
||||
lines = push_history(5)
|
||||
assert_encoded_string_equal(lines[0], HISTORY.delete_at(0))
|
||||
assert_encoded_string_equal(lines[4], HISTORY.delete_at(3))
|
||||
assert_encoded_string_equal(lines[1], HISTORY.delete_at(0))
|
||||
assert_encoded_string_equal(lines[3], HISTORY.delete_at(1))
|
||||
assert_encoded_string_equal(lines[2], HISTORY.delete_at(0))
|
||||
assert_external_string_equal(lines[0], HISTORY.delete_at(0))
|
||||
assert_external_string_equal(lines[4], HISTORY.delete_at(3))
|
||||
assert_external_string_equal(lines[1], HISTORY.delete_at(0))
|
||||
assert_external_string_equal(lines[3], HISTORY.delete_at(1))
|
||||
assert_external_string_equal(lines[2], HISTORY.delete_at(0))
|
||||
assert(HISTORY.empty?)
|
||||
rescue NotImplementedError
|
||||
end
|
||||
|
@ -310,9 +309,13 @@ class Readline::TestHistory < Test::Unit::TestCase
|
|||
return lines
|
||||
end
|
||||
|
||||
def assert_encoded_string_equal(expected, actual)
|
||||
def assert_external_string_equal(expected, actual)
|
||||
assert_equal(expected, actual)
|
||||
#assert_equal(expected.encoding, actual.encoding)
|
||||
assert_equal(get_default_internal_encoding, actual.encoding)
|
||||
end
|
||||
|
||||
def get_default_internal_encoding
|
||||
return Encoding.default_internal || Encoding.find("locale")
|
||||
end
|
||||
end if defined?(::Readline) && defined?(::Readline::HISTORY) &&
|
||||
(
|
||||
|
|
Loading…
Reference in a new issue