aboutsummaryrefslogtreecommitdiffstats
path: root/test/monitor
diff options
context:
space:
mode:
authorKoichi Sasada <ko1@atdot.net>2019-12-04 13:36:41 +0900
committerKoichi Sasada <ko1@atdot.net>2019-12-04 13:36:41 +0900
commitc6e3db0c66312af1e932c21006437419efa9ac75 (patch)
treeb016c716a577fdd024a397a87e2eb715fb40586e /test/monitor
parentf9e5c74cd24025a5aa19e318e8fecabf207f1b7b (diff)
downloadruby-c6e3db0c66312af1e932c21006437419efa9ac75.tar.gz
new_cond before mon_initialize
MonitorMixin#new_cond can be called before mon_initialize, so we need to initialize `@monitor` before it. https://bugs.ruby-lang.org/issues/16255#note-4
Diffstat (limited to 'test/monitor')
-rw-r--r--test/monitor/test_monitor.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/test/monitor/test_monitor.rb b/test/monitor/test_monitor.rb
index 950db917e6..721c848d68 100644
--- a/test/monitor/test_monitor.rb
+++ b/test/monitor/test_monitor.rb
@@ -223,6 +223,19 @@ class TestMonitor < Test::Unit::TestCase
assert_join_threads([th, th2])
end
+ class NewCondTest
+ include MonitorMixin
+ attr_reader :cond
+ def initialize
+ @cond = new_cond
+ super # mon_initialize
+ end
+ end
+
+ def test_new_cond_before_initialize
+ assert NewCondTest.new.cond.instance_variable_get(:@monitor) != nil
+ end
+
def test_timedwait
cond = @monitor.new_cond
b = "foo"