summaryrefslogtreecommitdiff
path: root/spec/ruby/core/tracepoint/raised_exception_spec.rb
blob: ca2f50abb36f205d5331406ec5bd6905f0b82db1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
require_relative '../../spec_helper'
require_relative 'fixtures/classes'

describe 'TracePoint#raised_exception' do
  it 'returns value from exception raised on the :raise event' do
    raised_exception, error_result = nil
    trace = TracePoint.new(:raise) { |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