1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

test_thread.rb: move thread switch test

* test/ruby/test_thread.rb (test_switch_while_busy_loop): move
  from test/test_timeout.rb.  [Bug #1402]

* test/test_timeout.rb (test_timeout): no longer related to
  [Bug #1402].  [Bug #8523]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46196 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2014-05-28 03:05:48 +00:00
parent 1142249713
commit bd77dbc37a
2 changed files with 20 additions and 8 deletions

View file

@ -369,6 +369,24 @@ class TestThread < Test::Unit::TestCase
c.kill if c
end
def test_switch_while_busy_loop
bug1402 = "[ruby-dev:38319] [Bug #1402]"
flag = true
th = Thread.current
waiter = Thread.start {
sleep 0.1
flag = false
sleep 1
th.raise(bug1402)
}
assert_nothing_raised(RuntimeError, bug1402) do
nil while flag
end
assert(!flag, bug1402)
ensure
waiter.kill.join
end
def test_safe_level
ok = false
t = Thread.new do

View file

@ -11,17 +11,11 @@ class TestTimeout < Test::Unit::TestCase
end
def test_timeout
flag = true
Thread.start {
sleep 1
flag = false
}
assert_raise(Timeout::Error, "[ruby-dev:38319]") do
assert_raise(Timeout::Error) do
Timeout.timeout(0.1) {
Thread.pass while flag
nil while true
}
end
assert flag, "[ruby-dev:38319]"
end
def test_cannot_convert_into_time_interval