ruby-changes:30094
From: naruse <ko1@a...>
Date: Wed, 24 Jul 2013 03:00:38 +0900 (JST)
Subject: [ruby-changes:30094] naruse:r42146 (trunk): fix test of r42101 [Feature #6626]
naruse 2013-07-24 03:00:26 +0900 (Wed, 24 Jul 2013) New Revision: 42146 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=42146 Log: fix test of r42101 [Feature #6626] rl_delete_text removes characters in line_buffer, but it doesn't move rl_point. Therefore it may cause invalid rl_point. On following case, test_input_metachar causes test_insert_text failure. (test_input_metachar_multibyte) is skipped because of locale) http://c5664.rubyci.org/~chkbuild/ruby-trunk/log/20130723T133302Z.log.html.gz Modified files: trunk/test/readline/test_readline.rb Index: test/readline/test_readline.rb =================================================================== --- test/readline/test_readline.rb (revision 42145) +++ test/readline/test_readline.rb (revision 42146) @@ -312,33 +312,51 @@ class TestReadline < Test::Unit::TestCas https://github.com/ruby/ruby/blob/trunk/test/readline/test_readline.rb#L312 end def test_insert_text - begin + str = "test_insert_text" + with_pipe {|r, w| w.write("\C-a\n")} # reset rl_point + assert_equal(0, Readline.point) + assert_equal(Readline, Readline.insert_text(str)) + assert_equal(str, Readline.line_buffer) + assert_equal(16, Readline.point) + assert_equal(get_default_internal_encoding, + Readline.line_buffer.encoding) + + Readline.delete_text(1, 3) + assert_equal("t_insert_text", Readline.line_buffer) + Readline.delete_text(11) + assert_equal("t_insert_te", Readline.line_buffer) + Readline.delete_text(-3...-1) + assert_equal("t_inserte", Readline.line_buffer) + Readline.delete_text(-3..-1) + assert_equal("t_inse", Readline.line_buffer) + Readline.delete_text(3..-3) + assert_equal("t_ise", Readline.line_buffer) + Readline.delete_text(3, 1) + assert_equal("t_ie", Readline.line_buffer) + Readline.delete_text(1..1) + assert_equal("tie", Readline.line_buffer) + Readline.delete_text(1...2) + assert_equal("te", Readline.line_buffer) + Readline.delete_text + assert_equal("", Readline.line_buffer) + rescue NotImplementedError + end if !/EditLine/n.match(Readline::VERSION) + + def test_delete_text str = "test_insert_text" + assert_equal(0, Readline.point) assert_equal(Readline, Readline.insert_text(str)) + assert_equal(16, Readline.point) assert_equal(str, Readline.line_buffer) - assert_equal(get_default_internal_encoding, - Readline.line_buffer.encoding) - - Readline.delete_text(1, 3) - assert_equal("t_insert_text", Readline.line_buffer) - Readline.delete_text(11) - assert_equal("t_insert_te", Readline.line_buffer) - Readline.delete_text(-3...-1) - assert_equal("t_inserte", Readline.line_buffer) - Readline.delete_text(-3..-1) - assert_equal("t_inse", Readline.line_buffer) - Readline.delete_text(3..-3) - assert_equal("t_ise", Readline.line_buffer) - Readline.delete_text(3, 1) - assert_equal("t_ie", Readline.line_buffer) - Readline.delete_text(1..1) - assert_equal("tie", Readline.line_buffer) - Readline.delete_text(1...2) - assert_equal("te", Readline.line_buffer) Readline.delete_text + + # NOTE: unexpected but GNU Readline's spec + assert_equal(16, Readline.point) + assert_equal("", Readline.line_buffer) + assert_equal(Readline, Readline.insert_text(str)) + assert_equal(32, Readline.point) assert_equal("", Readline.line_buffer) - rescue NotImplementedError - end + rescue NotImplementedError end if !/EditLine/n.match(Readline::VERSION) def test_modify_text_in_pre_input_hook -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/