Skip to content

Commit

Permalink
Add a few more weird code patterns to the interesting backtrace helper
Browse files Browse the repository at this point in the history
  • Loading branch information
ivoanjo committed May 20, 2022
1 parent 7d1d002 commit 20c1c4b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,27 @@ def hello
end
end

def ibh_subclass_of_anonymous_class
c1 = Class.new(Array)
c2 = Class.new(c1) do
def hello
[nil].map { IbhClassN.new.hello }.first
end
end

c2.new.hello
end

module IbhModuleO
module_function

def hello
ibh_subclass_of_anonymous_class
end
end

def ibh_top_level_hello
IbhClassN.new.hello
IbhModuleO.hello
end

1.times {
Expand Down
6 changes: 2 additions & 4 deletions spec/datadog/profiling/collectors/stack_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,9 @@ def call_sleep
end
# rubocop:enable Style/GlobalVars

it 'matches the Ruby backtrace API' do
# I opted to join these two expects to avoid running the `load` above more than once
it 'matches the Ruby backtrace API has has a sleeping frame at the top of the stack' do
expect(gathered_stack).to eq reference_stack
end

it 'has a sleeping frame at the top of the stack' do
expect(reference_stack.first).to match(hash_including(base_label: 'sleep'))
end
end
Expand Down

0 comments on commit 20c1c4b

Please sign in to comment.