mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* test/readline/test_readline_history.rb: checked encoding.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20901 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
8cd6a45a2a
commit
1cf4744a83
2 changed files with 34 additions and 21 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
Sun Dec 21 14:48:51 2008 TAKAO Kouji <kouji@takao7.net>
|
||||||
|
|
||||||
|
* test/readline/test_readline_history.rb: checked encoding.
|
||||||
|
|
||||||
Sun Dec 21 14:45:58 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Sun Dec 21 14:45:58 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* lib/optparse.rb (parse_in_order): splat values to be passed.
|
* lib/optparse.rb (parse_in_order): splat values to be passed.
|
||||||
|
|
|
@ -75,13 +75,14 @@ class Readline::TestHistory < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_to_s
|
def test_to_s
|
||||||
assert_equal("HISTORY", HISTORY.to_s)
|
expected = "HISTORY"
|
||||||
|
assert_equal(expected, HISTORY.to_s)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_get
|
def test_get
|
||||||
lines = push_history(5)
|
lines = push_history(5)
|
||||||
lines.each_with_index do |s, i|
|
lines.each_with_index do |s, i|
|
||||||
assert_equal(s, HISTORY[i])
|
assert_encoded_string_equal(s, HISTORY[i])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -115,8 +116,9 @@ class Readline::TestHistory < Test::Unit::TestCase
|
||||||
lines = push_history(5)
|
lines = push_history(5)
|
||||||
5.times do |i|
|
5.times do |i|
|
||||||
expected = "set: #{i}"
|
expected = "set: #{i}"
|
||||||
HISTORY[i] = expected
|
s = (HISTORY[i] = expected)
|
||||||
assert_equal(expected, HISTORY[i])
|
assert_encoded_string_equal(expected, HISTORY[i])
|
||||||
|
assert_encoded_string_equal(expected, s)
|
||||||
end
|
end
|
||||||
rescue NotImplementedError
|
rescue NotImplementedError
|
||||||
end
|
end
|
||||||
|
@ -146,16 +148,18 @@ class Readline::TestHistory < Test::Unit::TestCase
|
||||||
|
|
||||||
def test_push
|
def test_push
|
||||||
5.times do |i|
|
5.times do |i|
|
||||||
assert_equal(HISTORY, HISTORY.push(i.to_s))
|
s = i.to_s
|
||||||
assert_equal(i.to_s, HISTORY[i])
|
assert_equal(HISTORY, HISTORY.push(s))
|
||||||
|
assert_encoded_string_equal(s, HISTORY[i])
|
||||||
end
|
end
|
||||||
assert_equal(5, HISTORY.length)
|
assert_equal(5, HISTORY.length)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_push__operator
|
def test_push__operator
|
||||||
5.times do |i|
|
5.times do |i|
|
||||||
assert_equal(HISTORY, HISTORY << i.to_s)
|
s = i.to_s
|
||||||
assert_equal(i.to_s, HISTORY[i])
|
assert_equal(HISTORY, HISTORY << s)
|
||||||
|
assert_encoded_string_equal(s, HISTORY[i])
|
||||||
end
|
end
|
||||||
assert_equal(5, HISTORY.length)
|
assert_equal(5, HISTORY.length)
|
||||||
end
|
end
|
||||||
|
@ -163,13 +167,13 @@ class Readline::TestHistory < Test::Unit::TestCase
|
||||||
def test_push__plural
|
def test_push__plural
|
||||||
assert_equal(HISTORY, HISTORY.push("0", "1", "2", "3", "4"))
|
assert_equal(HISTORY, HISTORY.push("0", "1", "2", "3", "4"))
|
||||||
(0..4).each do |i|
|
(0..4).each do |i|
|
||||||
assert_equal(i.to_s, HISTORY[i])
|
assert_encoded_string_equal(i.to_s, HISTORY[i])
|
||||||
end
|
end
|
||||||
assert_equal(5, HISTORY.length)
|
assert_equal(5, HISTORY.length)
|
||||||
|
|
||||||
assert_equal(HISTORY, HISTORY.push("5", "6", "7", "8", "9"))
|
assert_equal(HISTORY, HISTORY.push("5", "6", "7", "8", "9"))
|
||||||
(5..9).each do |i|
|
(5..9).each do |i|
|
||||||
assert_equal(i.to_s, HISTORY[i])
|
assert_encoded_string_equal(i.to_s, HISTORY[i])
|
||||||
end
|
end
|
||||||
assert_equal(10, HISTORY.length)
|
assert_equal(10, HISTORY.length)
|
||||||
end
|
end
|
||||||
|
@ -180,7 +184,7 @@ class Readline::TestHistory < Test::Unit::TestCase
|
||||||
|
|
||||||
lines = push_history(5)
|
lines = push_history(5)
|
||||||
(1..5).each do |i|
|
(1..5).each do |i|
|
||||||
assert_equal(lines[-i], HISTORY.pop)
|
assert_encoded_string_equal(lines[-i], HISTORY.pop)
|
||||||
assert_equal(lines.length - i, HISTORY.length)
|
assert_equal(lines.length - i, HISTORY.length)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -195,7 +199,7 @@ class Readline::TestHistory < Test::Unit::TestCase
|
||||||
|
|
||||||
lines = push_history(5)
|
lines = push_history(5)
|
||||||
(0..4).each do |i|
|
(0..4).each do |i|
|
||||||
assert_equal(lines[i], HISTORY.shift)
|
assert_encoded_string_equal(lines[i], HISTORY.shift)
|
||||||
assert_equal(lines.length - (i + 1), HISTORY.length)
|
assert_equal(lines.length - (i + 1), HISTORY.length)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -212,8 +216,8 @@ class Readline::TestHistory < Test::Unit::TestCase
|
||||||
lines = push_history(5)
|
lines = push_history(5)
|
||||||
i = 0
|
i = 0
|
||||||
e = HISTORY.each do |s|
|
e = HISTORY.each do |s|
|
||||||
assert_equal(HISTORY[i], s)
|
assert_encoded_string_equal(HISTORY[i], s)
|
||||||
assert_equal(lines[i], s)
|
assert_encoded_string_equal(lines[i], s)
|
||||||
i += 1
|
i += 1
|
||||||
end
|
end
|
||||||
assert_equal(HISTORY, e)
|
assert_equal(HISTORY, e)
|
||||||
|
@ -248,22 +252,22 @@ class Readline::TestHistory < Test::Unit::TestCase
|
||||||
begin
|
begin
|
||||||
lines = push_history(5)
|
lines = push_history(5)
|
||||||
(0..4).each do |i|
|
(0..4).each do |i|
|
||||||
assert_equal(lines[i], HISTORY.delete_at(0))
|
assert_encoded_string_equal(lines[i], HISTORY.delete_at(0))
|
||||||
end
|
end
|
||||||
assert(HISTORY.empty?)
|
assert(HISTORY.empty?)
|
||||||
|
|
||||||
lines = push_history(5)
|
lines = push_history(5)
|
||||||
(1..5).each do |i|
|
(1..5).each do |i|
|
||||||
assert_equal(lines[lines.length - i], HISTORY.delete_at(-1))
|
assert_encoded_string_equal(lines[lines.length - i], HISTORY.delete_at(-1))
|
||||||
end
|
end
|
||||||
assert(HISTORY.empty?)
|
assert(HISTORY.empty?)
|
||||||
|
|
||||||
lines = push_history(5)
|
lines = push_history(5)
|
||||||
assert_equal(lines[0], HISTORY.delete_at(0))
|
assert_encoded_string_equal(lines[0], HISTORY.delete_at(0))
|
||||||
assert_equal(lines[4], HISTORY.delete_at(3))
|
assert_encoded_string_equal(lines[4], HISTORY.delete_at(3))
|
||||||
assert_equal(lines[1], HISTORY.delete_at(0))
|
assert_encoded_string_equal(lines[1], HISTORY.delete_at(0))
|
||||||
assert_equal(lines[3], HISTORY.delete_at(1))
|
assert_encoded_string_equal(lines[3], HISTORY.delete_at(1))
|
||||||
assert_equal(lines[2], HISTORY.delete_at(0))
|
assert_encoded_string_equal(lines[2], HISTORY.delete_at(0))
|
||||||
assert(HISTORY.empty?)
|
assert(HISTORY.empty?)
|
||||||
rescue NotImplementedError
|
rescue NotImplementedError
|
||||||
end
|
end
|
||||||
|
@ -305,6 +309,11 @@ class Readline::TestHistory < Test::Unit::TestCase
|
||||||
HISTORY.push(*lines)
|
HISTORY.push(*lines)
|
||||||
return lines
|
return lines
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def assert_encoded_string_equal(expected, actual)
|
||||||
|
assert_equal(expected, actual)
|
||||||
|
assert_equal(expected.encoding, actual.encoding)
|
||||||
|
end
|
||||||
end if defined?(::Readline) && defined?(::Readline::HISTORY) &&
|
end if defined?(::Readline) && defined?(::Readline::HISTORY) &&
|
||||||
(
|
(
|
||||||
begin
|
begin
|
||||||
|
|
Loading…
Reference in a new issue