diff options
Diffstat (limited to 'spec/ruby')
-rw-r--r-- | spec/ruby/core/tracepoint/enable_spec.rb | 55 | ||||
-rw-r--r-- | spec/ruby/core/tracepoint/inspect_spec.rb | 4 |
2 files changed, 42 insertions, 17 deletions
diff --git a/spec/ruby/core/tracepoint/enable_spec.rb b/spec/ruby/core/tracepoint/enable_spec.rb index ab392c7583..4d9cfa1448 100644 --- a/spec/ruby/core/tracepoint/enable_spec.rb +++ b/spec/ruby/core/tracepoint/enable_spec.rb @@ -57,25 +57,50 @@ describe 'TracePoint#enable' do end.enable { event_name.should equal(:line) } end - it 'enables the trace object for any thread' do - threads = [] - trace = TracePoint.new(:line) do |tp| - # Runs on purpose on any Thread - threads << Thread.current - end + ruby_version_is '3.2' do + it 'enables the trace object for any thread' do + threads = [] + trace = TracePoint.new(:line) do |tp| + # Runs on purpose on any Thread + threads << Thread.current + end - thread = nil - trace.enable do - line_event = true - thread = Thread.new do - event_in_other_thread = true + thread = nil + trace.enable do + line_event = true + thread = Thread.new do + event_in_other_thread = true + end + thread.join end - thread.join + + threads = threads.uniq + threads.should.include?(Thread.current) + threads.should_not.include?(thread) end + end - threads = threads.uniq - threads.should.include?(Thread.current) - threads.should.include?(thread) + ruby_version_is ''...'3.2' do + it 'enables the trace object for any thread' do + threads = [] + trace = TracePoint.new(:line) do |tp| + # Runs on purpose on any Thread + threads << Thread.current + end + + thread = nil + trace.enable do + line_event = true + thread = Thread.new do + event_in_other_thread = true + end + thread.join + end + + threads = threads.uniq + threads.should.include?(Thread.current) + threads.should.include?(thread) + end end it 'can accept arguments within a block but it should not yield arguments' do diff --git a/spec/ruby/core/tracepoint/inspect_spec.rb b/spec/ruby/core/tracepoint/inspect_spec.rb index b9d7f35c32..a07b626212 100644 --- a/spec/ruby/core/tracepoint/inspect_spec.rb +++ b/spec/ruby/core/tracepoint/inspect_spec.rb @@ -98,7 +98,7 @@ describe 'TracePoint#inspect' do TracePoint.new(:thread_begin) { |tp| next unless Thread.current == thread inspect ||= tp.inspect - }.enable do + }.enable(target_thread: nil) do thread = Thread.new {} thread_inspection = thread.inspect thread.join @@ -114,7 +114,7 @@ describe 'TracePoint#inspect' do TracePoint.new(:thread_end) { |tp| next unless Thread.current == thread inspect ||= tp.inspect - }.enable do + }.enable(target_thread: nil) do thread = Thread.new {} thread_inspection = thread.inspect thread.join |