diff options
Diffstat (limited to 'spec/ruby/core/tracepoint/inspect_spec.rb')
-rw-r--r-- | spec/ruby/core/tracepoint/inspect_spec.rb | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/spec/ruby/core/tracepoint/inspect_spec.rb b/spec/ruby/core/tracepoint/inspect_spec.rb index b9d7f35c32..cc6bf0f842 100644 --- a/spec/ruby/core/tracepoint/inspect_spec.rb +++ b/spec/ruby/core/tracepoint/inspect_spec.rb @@ -3,19 +3,22 @@ require_relative 'fixtures/classes' describe 'TracePoint#inspect' do before do - ruby_version_is ""..."3.0" do - @path_prefix = '@' - end - - ruby_version_is "3.0" do - @path_prefix = ' ' - end + @path_prefix = ' ' end it 'returns a string containing a human-readable TracePoint status' do TracePoint.new(:line) {}.inspect.should == '#<TracePoint:disabled>' end + it "shows only whether it's enabled when outside the TracePoint handler" do + trace = TracePoint.new(:line) {} + trace.enable + + trace.inspect.should == '#<TracePoint:enabled>' + + trace.disable + end + it 'returns a String showing the event, path and line' do inspect = nil line = nil @@ -41,7 +44,7 @@ describe 'TracePoint#inspect' do trace_point_spec_test_call end - inspect.should == "#<TracePoint:call `trace_point_spec_test_call'#{@path_prefix}#{__FILE__}:#{line}>" + inspect.should =~ /\A#<TracePoint:call [`']trace_point_spec_test_call'#{@path_prefix}#{__FILE__}:#{line}>\z/ end it 'returns a String showing the event, method, path and line for a :return event' do @@ -59,7 +62,7 @@ describe 'TracePoint#inspect' do trace_point_spec_test_return end - inspect.should == "#<TracePoint:return `trace_point_spec_test_return'#{@path_prefix}#{__FILE__}:#{line}>" + inspect.should =~ /\A#<TracePoint:return [`']trace_point_spec_test_return'#{@path_prefix}#{__FILE__}:#{line}>\z/ end it 'returns a String showing the event, method, path and line for a :c_call event' do @@ -73,7 +76,7 @@ describe 'TracePoint#inspect' do [0, 1].max end - inspect.should == "#<TracePoint:c_call `max'#{@path_prefix}#{__FILE__}:#{line}>" + inspect.should =~ /\A#<TracePoint:c_call [`']max'#{@path_prefix}#{__FILE__}:#{line}>\z/ end it 'returns a String showing the event, path and line for a :class event' do @@ -98,7 +101,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 +117,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 |