|
module Container
|
|
end
|
|
|
|
class Example
|
|
def initialize(strategy)
|
|
@strategy = strategy
|
|
end
|
|
|
|
def define_method_wrapper
|
|
define_method_somewhere_else(@strategy) do |name, &block|
|
|
missing_method_to_get_exception
|
|
end
|
|
end
|
|
|
|
def define_method_somewhere_else(name, &block)
|
|
Container.module_exec do
|
|
define_singleton_method(name, &block)
|
|
end
|
|
end
|
|
end
|
|
|
|
require 'minitest/autorun'
|
|
|
|
class TestTracePointStacks < Minitest::Test
|
|
def test_extra_b_call_and_b_return_events_bug
|
|
Example.new(:create).define_method_wrapper
|
|
events = []
|
|
TracePoint.new(:call, :return, :b_call, :b_return, :c_call, :c_return, :raise) do |tp|
|
|
events << [tp.event, tp.method_id]
|
|
end.enable do
|
|
Container.create(:thing) rescue nil
|
|
end
|
|
|
|
[[:b_call, :test_extra_b_call_and_b_return_events_bug],
|
|
[:call, :create],
|
|
[:c_call, :method_missing],
|
|
[:c_call, :initialize],
|
|
[:c_call, :initialize],
|
|
[:c_return, :initialize],
|
|
[:c_return, :initialize],
|
|
[:c_return, :method_missing],
|
|
[:c_call, :exception],
|
|
[:c_return, :exception],
|
|
[:c_call, :backtrace],
|
|
[:c_return, :backtrace],
|
|
[:raise, :create],
|
|
[:return, :create],
|
|
[:c_call, :===],
|
|
[:c_return, :===],
|
|
[:b_return, :test_extra_b_call_and_b_return_events_bug]].zip(events) do |expected, actual|
|
|
assert_equal(expected, actual)
|
|
end
|
|
end
|
|
end
|