Class: Roby::Test::ExecutionExpectations::Expectation Private

Inherits:
Object
  • Object
show all
Defined in:
lib/roby/test/execution_expectations.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Null implementation of an expectation

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(backtrace) ⇒ Expectation

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Expectation.



762
763
764
765
# File 'lib/roby/test/execution_expectations.rb', line 762

def initialize(backtrace)
    @backtrace = backtrace
    @result_filters = []
end

Instance Attribute Details

#backtraceObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



760
761
762
# File 'lib/roby/test/execution_expectations.rb', line 760

def backtrace
  @backtrace
end

Instance Method Details

#explain_unachievable(_propagation_info) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



778
779
780
# File 'lib/roby/test/execution_expectations.rb', line 778

def explain_unachievable(_propagation_info)
    nil
end

#filter_result(result) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Filter the result of this expectation before returning it to the user



825
826
827
# File 'lib/roby/test/execution_expectations.rb', line 825

def filter_result(result)
    @result_filters.inject(result) { |o, b| b.call(o) }
end

#filter_result_with(&block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Add a block that should be used to filter the result of this expectation before returning it to the caller

This is meant to be used to re-use general expectations in more specific ones



816
817
818
819
# File 'lib/roby/test/execution_expectations.rb', line 816

def filter_result_with(&block)
    @result_filters << block
    self
end

#format_unachievable_explanation(pp, explanation) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
# File 'lib/roby/test/execution_expectations.rb', line 786

def format_unachievable_explanation(pp, explanation)
    pp.text "but it did not because of "
    case explanation
    when Exception
        msg = Roby.format_exception(explanation, with_backtrace: true)
        msg.each do |line|
            pp.text line
            pp.breakable
        end
    when Event
        explanation.pretty_print(pp)
        if (e = explanation.context.first).kind_of?(Exception)
            msg = Roby.format_exception(e, with_backtrace: true)
            pp.nest(2) do
                msg.each do |line|
                    pp.breakable
                    pp.text line
                end
            end
        end
    else
        explanation.pretty_print(pp)
    end
end

#relates_to_error?(_error) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


782
783
784
# File 'lib/roby/test/execution_expectations.rb', line 782

def relates_to_error?(_error)
    false
end

#unachievable?(_propagation_info) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


774
775
776
# File 'lib/roby/test/execution_expectations.rb', line 774

def unachievable?(_propagation_info)
    false
end

#update_match(_propagation_info) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Verifies whether the expectation is met at this point

This method is meant to update



770
771
772
# File 'lib/roby/test/execution_expectations.rb', line 770

def update_match(_propagation_info)
    true
end