From c6e3db0c66312af1e932c21006437419efa9ac75 Mon Sep 17 00:00:00 2001 From: Koichi Sasada Date: Wed, 4 Dec 2019 13:36:41 +0900 Subject: 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 --- test/monitor/test_monitor.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'test/monitor/test_monitor.rb') 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" -- cgit v1.2.3