From f050b2232711c162ee380ba61ddb8554cb4f7719 Mon Sep 17 00:00:00 2001 From: nobu Date: Sun, 3 Feb 2013 07:54:18 +0000 Subject: console.c: fix unit of min * ext/io/console/console.c (rawmode_opt): min is minimum characters, not tenths. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39029 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/io/console/test_io_console.rb | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'test/io') diff --git a/test/io/console/test_io_console.rb b/test/io/console/test_io_console.rb index 3acc4de5d5..2de15f1f24 100644 --- a/test/io/console/test_io_console.rb +++ b/test/io/console/test_io_console.rb @@ -25,6 +25,38 @@ class TestIO_Console < Test::Unit::TestCase } end + def test_raw_minchar + len = 0 + th = nil + helper {|m, s| + th = Thread.start { + m.print("a") + len += 1 + sleep 2 + m.print("1234567890") + len += 10 + } + assert_equal(["a", 1], [s.getch(min: 1), len]) + } + ensure + th.kill if th and th.alive? + end + + def test_raw_timeout + len = 0 + th = nil + helper {|m, s| + th = Thread.start { + sleep 2 + m.print("a") + len += 1 + } + assert_equal([nil, 0], [s.getch(time: 0.1), len]) + } + ensure + th.kill if th and th.alive? + end + def test_cooked helper {|m, s| assert_send([s, :echo?]) -- cgit v1.2.3