class Roby::Test::ExecutionExpectations::ErrorExpectation

Public Class Methods

new(matcher, backtrace) click to toggle source
# File lib/roby/test/execution_expectations.rb, line 845
def initialize(matcher, backtrace)
    super(backtrace)
    @matcher = matcher.to_execution_exception_matcher
    @matched_execution_exceptions = Array.new
    @matched_exceptions = Array.new
end

Public Instance Methods

relates_to_error?(execution_exception) click to toggle source
# File lib/roby/test/execution_expectations.rb, line 874
def relates_to_error?(execution_exception)
    @matched_execution_exceptions.include?(execution_exception) ||
        @matched_exceptions.include?(execution_exception.exception) ||
        Roby.flatten_exception(execution_exception.exception).
            any? { |e| @matched_exceptions.include?(e) }
end
return_object() click to toggle source
# File lib/roby/test/execution_expectations.rb, line 881
def return_object
    @matched_execution_exceptions.first
end
update_match(exceptions, emitted_events) click to toggle source
# File lib/roby/test/execution_expectations.rb, line 852
def update_match(exceptions, emitted_events)
    @matched_execution_exceptions = exceptions.
        find_all { |error| @matcher === error }
    matched_exceptions = @matched_execution_exceptions.
        map(&:exception).to_set

    emitted_events.each do |ev|
        next if !ev.generator.respond_to?(:symbol) || ev.generator.symbol != :internal_error

        ev.context.each do |obj|
            if obj.kind_of?(Exception) && (@matcher === ExecutionException.new(obj))
                matched_exceptions << obj
            end
        end
    end

    @matched_exceptions = matched_exceptions.flat_map do |e|
        Roby.flatten_exception(e).to_a
    end.to_set
    !@matched_exceptions.empty?
end