summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-02-05 04:27:57 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-02-05 04:27:57 +0000
commit490f1fc00979b6fb2cd45bf01544e79e9d9ea66c (patch)
treef55d37a2222c63a004f36aabc5d72ffad0cf9a63 /test
parente29e4b55ab79bd18550b11ce7d9cf94deca365be (diff)
console.c: default by stty raw
* ext/io/console/console.c (rawmode_opt): use default values by `stty raw`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39060 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/io/console/test_io_console.rb24
1 files changed, 17 insertions, 7 deletions
diff --git a/test/io/console/test_io_console.rb b/test/io/console/test_io_console.rb
index ceaf5b9d0f..65514f2b81 100644
--- a/test/io/console/test_io_console.rb
+++ b/test/io/console/test_io_console.rb
@@ -29,14 +29,21 @@ class TestIO_Console < Test::Unit::TestCase
len = 0
th = nil
helper {|m, s|
+ assert_equal([nil, 0], [s.getch(min: 0), len])
+ main = Thread.current
+ go = false
th = Thread.start {
- m.print("a")
len += 1
- sleep 2
- m.print("1234567890")
+ m.print("a")
+ m.flush
+ sleep 0.01 until go and main.stop?
len += 10
+ m.print("1234567890")
+ m.flush
}
assert_equal(["a", 1], [s.getch(min: 1), len])
+ go = true
+ assert_equal(["1", 11], [s.getch, len])
}
ensure
th.kill if th and th.alive?
@@ -46,12 +53,15 @@ class TestIO_Console < Test::Unit::TestCase
len = 0
th = nil
helper {|m, s|
+ assert_equal([nil, 0], [s.getch(min: 0, time: 0.1), len])
+ main = Thread.current
th = Thread.start {
- sleep 2
- m.print("a")
- len += 1
+ sleep 0.01 until main.stop?
+ len += 2
+ m.print("ab")
}
- assert_equal([nil, 0], [s.getch(time: 0.1), len])
+ assert_equal(["a", 2], [s.getch(min: 1, time: 1), len])
+ assert_equal(["b", 2], [s.getch(time: 1), len])
}
ensure
th.kill if th and th.alive?