summaryrefslogtreecommitdiff
path: root/spec/ruby/core/tracepoint/inspect_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core/tracepoint/inspect_spec.rb')
-rw-r--r--spec/ruby/core/tracepoint/inspect_spec.rb35
1 files changed, 19 insertions, 16 deletions
diff --git a/spec/ruby/core/tracepoint/inspect_spec.rb b/spec/ruby/core/tracepoint/inspect_spec.rb
index 06bed9c99a..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,21 +62,21 @@ 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
inspect = nil
- line = nil
- TracePoint.new(:c_call) { |tp|
+ tracepoint = TracePoint.new(:c_call) { |tp|
next unless TracePointSpec.target_thread?
inspect ||= tp.inspect
- }.enable do
- line = __LINE__ + 1
+ }
+ line = __LINE__ + 2
+ tracepoint.enable 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