* 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:
nahi 2009-10-20 15:57:39 +00:00
Родитель 9cf0cf92f2
Коммит 070cbd942e
1 изменённых файлов: 27 добавлений и 0 удалений

Просмотреть файл

@ -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