diff options
Diffstat (limited to 'test/monitor')
-rw-r--r-- | test/monitor/test_monitor.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/monitor/test_monitor.rb b/test/monitor/test_monitor.rb index 49c34e067e..950db917e6 100644 --- a/test/monitor/test_monitor.rb +++ b/test/monitor/test_monitor.rb @@ -35,6 +35,29 @@ class TestMonitor < Test::Unit::TestCase assert_equal((1..10).to_a, ary) end + def test_exit + m = Monitor.new + m.enter + assert_equal true, m.mon_owned? + m.exit + assert_equal false, m.mon_owned? + + assert_raise ThreadError do + m.exit + end + + assert_equal false, m.mon_owned? + + m.enter + Thread.new{ + assert_raise(ThreadError) do + m.exit + end + }.join + assert_equal true, m.mon_owned? + m.exit + end + def test_enter_second_after_killed_thread th = Thread.start { @monitor.enter |