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:
parent
1142249713
commit
bd77dbc37a
2 changed files with 20 additions and 8 deletions
|
@ -369,6 +369,24 @@ class TestThread < Test::Unit::TestCase
|
||||||
c.kill if c
|
c.kill if c
|
||||||
end
|
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
|
def test_safe_level
|
||||||
ok = false
|
ok = false
|
||||||
t = Thread.new do
|
t = Thread.new do
|
||||||
|
|
|
@ -11,17 +11,11 @@ class TestTimeout < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_timeout
|
def test_timeout
|
||||||
flag = true
|
assert_raise(Timeout::Error) do
|
||||||
Thread.start {
|
|
||||||
sleep 1
|
|
||||||
flag = false
|
|
||||||
}
|
|
||||||
assert_raise(Timeout::Error, "[ruby-dev:38319]") do
|
|
||||||
Timeout.timeout(0.1) {
|
Timeout.timeout(0.1) {
|
||||||
Thread.pass while flag
|
nil while true
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
assert flag, "[ruby-dev:38319]"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_cannot_convert_into_time_interval
|
def test_cannot_convert_into_time_interval
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue