Synchronize the test thread sleep
This commit is contained in:
parent
b30b727c24
commit
307835fe31
Notes:
git
2022-07-25 15:03:37 +09:00
@ -30,16 +30,23 @@ class TestThread < Test::Unit::TestCase
|
|||||||
|
|
||||||
def test_inspect
|
def test_inspect
|
||||||
m = Thread::Mutex.new
|
m = Thread::Mutex.new
|
||||||
|
cv1 = Thread::ConditionVariable.new
|
||||||
|
cv2 = Thread::ConditionVariable.new
|
||||||
m.lock
|
m.lock
|
||||||
line = __LINE__+1
|
line = __LINE__+1
|
||||||
th = Module.new {break module_eval("class C\u{30b9 30ec 30c3 30c9} < Thread; self; end")}.start do
|
th = Module.new {break module_eval("class C\u{30b9 30ec 30c3 30c9} < Thread; self; end")}.start do
|
||||||
m.synchronize {}
|
m.synchronize do
|
||||||
|
cv2.signal
|
||||||
|
cv1.wait(m)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
cv2.wait(m)
|
||||||
s = th.inspect
|
s = th.inspect
|
||||||
assert_include(s, "::C\u{30b9 30ec 30c3 30c9}:")
|
assert_include(s, "::C\u{30b9 30ec 30c3 30c9}:")
|
||||||
assert_include(s, " #{__FILE__}:#{line} ")
|
assert_include(s, " #{__FILE__}:#{line} ")
|
||||||
assert_equal(s, th.to_s)
|
assert_equal(s, th.to_s)
|
||||||
ensure
|
ensure
|
||||||
|
cv1.signal
|
||||||
m.unlock
|
m.unlock
|
||||||
th.join
|
th.join
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user