* ext/readline/readline.c (readline_s_set_point, Init_readline):

add Readline.point=(pos). Patched by naruse.  [ruby-dev:47535]
  [Feature #8675]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42405 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
kouji 2013-08-06 12:52:22 +00:00
parent b4e9b0d19c
commit a78713ce45
3 changed files with 44 additions and 1 deletions

View file

@ -17,6 +17,11 @@ class TestReadline < Test::Unit::TestCase
def teardown
ENV[INPUTRC] = @inputrc
Readline.instance_variable_set("@completion_proc", nil)
begin
Readline.delete_text
Readline.point = 0
rescue NotImplementedError
end
end
if !/EditLine/n.match(Readline::VERSION)
@ -311,9 +316,22 @@ class TestReadline < Test::Unit::TestCase
end
end
def test_point
assert_equal(0, Readline.point)
Readline.insert_text('12345')
assert_equal(5, Readline.point)
assert_equal(4, Readline.point=(4))
Readline.insert_text('abc')
assert_equal(7, Readline.point)
assert_equal('1234abc5', Readline.line_buffer)
rescue NotImplementedError
end if !/EditLine/n.match(Readline::VERSION)
def test_insert_text
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)