summaryrefslogtreecommitdiff
path: root/test/io/console/test_io_console.rb
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-05-30 13:28:39 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-05-30 13:28:39 +0000
commit5b75a0614f6469785bdf5f548fd3db2dae820ae2 (patch)
tree3baf3ad9f443e5d3eb70f737559f80bc783b5182 /test/io/console/test_io_console.rb
parente6da7c5ca9084a26bc1ce1828efe17f9eba4264d (diff)
Join threads, not kill.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46255 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/io/console/test_io_console.rb')
-rw-r--r--test/io/console/test_io_console.rb28
1 files changed, 15 insertions, 13 deletions
diff --git a/test/io/console/test_io_console.rb b/test/io/console/test_io_console.rb
index 3637546eb5..9cddd991a6 100644
--- a/test/io/console/test_io_console.rb
+++ b/test/io/console/test_io_console.rb
@@ -26,9 +26,8 @@ class TestIO_Console < Test::Unit::TestCase
end
def test_raw_minchar
- len = 0
- th = nil
helper {|m, s|
+ len = 0
assert_equal([nil, 0], [s.getch(min: 0), len])
main = Thread.current
go = false
@@ -41,18 +40,19 @@ class TestIO_Console < Test::Unit::TestCase
m.print("1234567890")
m.flush
}
- assert_equal(["a", 1], [s.getch(min: 1), len])
- go = true
- assert_equal(["1", 11], [s.getch, len])
+ begin
+ assert_equal(["a", 1], [s.getch(min: 1), len])
+ go = true
+ assert_equal(["1", 11], [s.getch, len])
+ ensure
+ th.join
+ end
}
- ensure
- th.kill if th and th.alive?
end
def test_raw_timeout
- len = 0
- th = nil
helper {|m, s|
+ len = 0
assert_equal([nil, 0], [s.getch(min: 0, time: 0.1), len])
main = Thread.current
th = Thread.start {
@@ -60,11 +60,13 @@ class TestIO_Console < Test::Unit::TestCase
len += 2
m.print("ab")
}
- assert_equal(["a", 2], [s.getch(min: 1, time: 1), len])
- assert_equal(["b", 2], [s.getch(time: 1), len])
+ begin
+ assert_equal(["a", 2], [s.getch(min: 1, time: 1), len])
+ assert_equal(["b", 2], [s.getch(time: 1), len])
+ ensure
+ th.join
+ end
}
- ensure
- th.kill if th and th.alive?
end
def test_cooked