Skip to content

Commit

Permalink
Synchronize the test thread not to die before assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu committed Jul 5, 2022
1 parent 3a9ff94 commit babdb15
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion test/ruby/test_thread.rb
Expand Up @@ -29,13 +29,18 @@ def teardown
end

def test_inspect
m = Thread::Mutex.new
m.lock
line = __LINE__+1
th = Module.new {break module_eval("class C\u{30b9 30ec 30c3 30c9} < Thread; self; end")}.start{}
th = Module.new {break module_eval("class C\u{30b9 30ec 30c3 30c9} < Thread; self; end")}.start do
m.synchronize {}
end
s = th.inspect
assert_include(s, "::C\u{30b9 30ec 30c3 30c9}:")
assert_include(s, " #{__FILE__}:#{line} ")
assert_equal(s, th.to_s)
ensure
m.unlock
th.join
end

Expand Down

0 comments on commit babdb15

Please sign in to comment.