Class: Roby::Test::ExecutionExpectations::ErrorExpectation
Instance Attribute Summary
Attributes inherited from Expectation
#backtrace
Instance Method Summary
collapse
Methods inherited from Expectation
#explain_unachievable, #filter_result, #filter_result_with, #format_unachievable_explanation, #unachievable?
Constructor Details
#initialize(matcher, backtrace) ⇒ ErrorExpectation
Returns a new instance of ErrorExpectation.
1039
1040
1041
1042
1043
1044
|
# File 'lib/roby/test/execution_expectations.rb', line 1039
def initialize(matcher, backtrace)
super(backtrace)
@matcher = matcher.to_execution_exception_matcher
@matched_execution_exceptions = []
@matched_exceptions = []
end
|
Instance Method Details
#relates_to_error?(error) ⇒ Boolean
1072
1073
1074
1075
1076
1077
1078
1079
|
# File 'lib/roby/test/execution_expectations.rb', line 1072
def relates_to_error?(error)
case error
when ExecutionException
@matched_execution_exceptions.include?(error)
else
@matched_exceptions.include?(error)
end
end
|
#return_object ⇒ Object
1081
1082
1083
1084
|
# File 'lib/roby/test/execution_expectations.rb', line 1081
def return_object
@matched_execution_exceptions.first ||
@matched_exceptions.first
end
|
#update_match(exceptions, emitted_events) ⇒ Object
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
|
# File 'lib/roby/test/execution_expectations.rb', line 1046
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 unless ev.generator.respond_to?(:symbol) &&
ev.generator.symbol == :internal_error
ev.context.each do |obj|
next unless obj.kind_of?(Exception)
next unless @matcher === ExecutionException.new(obj)
matched_exceptions << obj
end
end
@matched_exceptions = matched_exceptions.flat_map do |e|
Roby.flatten_exception(e).to_a
end.to_set
!@matched_exceptions.empty?
end
|