From 5b63a0caa3b4c4d7ad10ed63bd44eeb84ff2a2a7 Mon Sep 17 00:00:00 2001 From: Herwin Date: Fri, 29 Nov 2024 11:14:39 +0100 Subject: [PATCH] Add specs for rescue even in TracePoint --- core/tracepoint/raised_exception_spec.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/core/tracepoint/raised_exception_spec.rb b/core/tracepoint/raised_exception_spec.rb index ca2f50abb3..5ac8531840 100644 --- a/core/tracepoint/raised_exception_spec.rb +++ b/core/tracepoint/raised_exception_spec.rb @@ -17,4 +17,22 @@ raised_exception.should equal(error_result) end end + + ruby_version_is "3.3" do + it 'returns value from exception rescued on the :rescue event' do + raised_exception, error_result = nil + trace = TracePoint.new(:rescue) { |tp| + next unless TracePointSpec.target_thread? + raised_exception = tp.raised_exception + } + trace.enable do + begin + raise StandardError + rescue => e + error_result = e + end + raised_exception.should equal(error_result) + end + end + end end