diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2019-09-24 15:53:58 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2019-09-24 16:20:31 +0900 |
commit | 10e3267c31c4c976d79e00bca484094f1a87dc65 (patch) | |
tree | 6eea029e66d6dc5376927d30d29af2c20ce9d0a8 /test/io/console | |
parent | 244f7ec204e2b3fd54ca68740587b5be6d9defc4 (diff) | |
download | ruby-10e3267c31c4c976d79e00bca484094f1a87dc65.tar.gz |
[ruby/io-console] Made cursor position 0-origin
https://github.com/ruby/io-console/commit/9377e37295
Diffstat (limited to 'test/io/console')
-rw-r--r-- | test/io/console/test_io_console.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/io/console/test_io_console.rb b/test/io/console/test_io_console.rb index db3814d51c..c81d80fa08 100644 --- a/test/io/console/test_io_console.rb +++ b/test/io/console/test_io_console.rb @@ -281,6 +281,26 @@ defined?(PTY) and defined?(IO.console) and TestIO_Console.class_eval do set_winsize_teardown end + def test_cursor_position + run_pty("#{<<~"begin;"}\n#{<<~'end;'}") do |r, w, _| + begin; + con = IO.console + p con.cursor + con.cursor_down(3); con.puts + con.cursor_right(4); con.puts + con.cursor_left(2); con.puts + con.cursor_up(1); con.puts + end; + assert_equal("\e[6n", r.readpartial(5)) + w.print("\e[12;34R"); w.flush + assert_equal([11, 33], eval(r.gets)) + assert_equal("\e[3B", r.gets.chomp) + assert_equal("\e[4C", r.gets.chomp) + assert_equal("\e[2D", r.gets.chomp) + assert_equal("\e[1A", r.gets.chomp) + end + end + unless IO.console def test_close assert_equal(["true"], run_pty("IO.console.close; p IO.console.fileno >= 0")) |