mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* added monitor.rb test. see #2240 the bug on ruby_1_8.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25418 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
9cf0cf92f2
commit
070cbd942e
1 changed files with 27 additions and 0 deletions
|
@ -54,6 +54,32 @@ class TestMonitor < Test::Unit::TestCase
|
|||
assert_equal((1..10).to_a, ary)
|
||||
end
|
||||
|
||||
def test_killed_thread_in_synchronize
|
||||
ary = []
|
||||
queue = Queue.new
|
||||
t1 = Thread.start {
|
||||
queue.pop
|
||||
@monitor.synchronize {
|
||||
ary << :t1
|
||||
}
|
||||
}
|
||||
t2 = Thread.start {
|
||||
queue.pop
|
||||
@monitor.synchronize {
|
||||
ary << :t2
|
||||
}
|
||||
}
|
||||
@monitor.synchronize do
|
||||
queue.enq(nil)
|
||||
queue.enq(nil)
|
||||
assert_equal([], ary)
|
||||
t1.kill
|
||||
t2.kill
|
||||
ary << :main
|
||||
end
|
||||
assert_equal([:main], ary)
|
||||
end
|
||||
|
||||
def test_try_enter
|
||||
queue1 = Queue.new
|
||||
queue2 = Queue.new
|
||||
|
@ -97,6 +123,7 @@ class TestMonitor < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def _test_timedwait
|
||||
cond = @monitor.new_cond
|
||||
b = "foo"
|
||||
queue2 = Queue.new
|
||||
Thread.start do
|
||||
|
|
Loading…
Reference in a new issue