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.
1096
1097
1098
1099
1100
1101
|
# File 'lib/roby/test/execution_expectations.rb', line 1096
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
1129
1130
1131
1132
1133
1134
1135
1136
|
# File 'lib/roby/test/execution_expectations.rb', line 1129
def relates_to_error?(error)
case error
when ExecutionException
@matched_execution_exceptions.include?(error)
else
@matched_exceptions.include?(error)
end
end
|
#return_object ⇒ Object
1138
1139
1140
1141
|
# File 'lib/roby/test/execution_expectations.rb', line 1138
def return_object
@matched_execution_exceptions.first ||
@matched_exceptions.first
end
|
#update_match(exceptions, emitted_events) ⇒ Object
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
|
# File 'lib/roby/test/execution_expectations.rb', line 1103
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
|