Gecoder C0 Coverage Information - RCov

lib/gecoder/interface/constraints/bool_enum/channel.rb

Name Total Lines Lines of Code Total Coverage Code Coverage
lib/gecoder/interface/constraints/bool_enum/channel.rb 68 33
100.00%
100.00%

Key

Code reported as executed by Ruby looks like this...and this: this line is also marked as covered.Lines considered as run by rcov, but not reported by Ruby, look like this,and this: these lines were inferred by rcov (using simple heuristics).Finally, here's a line marked as not executed.

Coverage Details

1 module Gecode::BoolEnum
2   class BoolEnumConstraintReceiver
3     # Constrains this enumeration to "channel" +integer_operand+. This 
4     # constrains the integer operand to take value i exactly when the 
5     # operand at index i in the boolean enumeration is true and the others 
6     # are false.
7     # 
8     # Beyond the common options the channel constraint can
9     # also take the following option:
10     #
11     # [:offset]  Specifies an offset for the integer operand. If the offset is
12     #            set to k then the integer operand takes value i+k exactly 
13     #            when the operand at index i in the boolean enumeration is 
14     #            true and the rest are false.
15     # 
16     # Neither reification nor negation is supported. The int operand
17     # and the enumeration can be interchanged.
18     #
19     # ==== Examples 
20     #
21     #   # Constrains the enumeration called +option_is_selected+ to be false 
22     #   # in the first four positions and have exactly one true operand in 
23     #   # the other. 
24     #   option_is_selected.must.channel selected_option_index 
25     #   selected_option_index.must_be > 3
26     #
27     #   # Constrains the enumeration called +option_is_selected+ to be false 
28     #   # in the first five positions and have exactly one true operand in 
29     #   # the other. 
30     #   selected_option_index.must.channel(option_is_selected, :offset => 1) 
31     #   selected_option_index.must_be > 3
32     def channel(integer_operand, options = {})
33       if @params[:negate]
34         raise Gecode::MissingConstraintError, 'A negated channel constraint ' + 
35           'is not implemented.'
36       end
37       if options.has_key? :reify
38         raise ArgumentError, 'The channel constraint does not support the ' + 
39           'reification option.'
40       end
41       unless integer_operand.respond_to? :to_int_var
42         raise TypeError, 'Expected an integer operand, got ' + 
43           "#{integer_operand.class}."
44       end
45       
46       @params.update(:rhs => integer_operand, 
47         :offset => options.delete(:offset) || 0)
48       @params.update(Gecode::Util.decode_options(options))
49       @model.add_constraint Channel::ChannelConstraint.new(@model, @params)
50     end
51 
52     # Provides commutativity with SetConstraintReceiver#channel
53     provide_commutativity(:channel){ |rhs, _| rhs.respond_to? :to_set_var }
54   end
55   
56   # A module that gathers the classes and modules used in channel constraints
57   # involving one boolean enum and one integer operand.
58   module Channel #:nodoc:
59     class ChannelConstraint < Gecode::Constraint #:nodoc:
60       def post
61         lhs, rhs, offset = @params.values_at(:lhs, :rhs, :offset)
62         Gecode::Raw::channel(@model.active_space, 
63           lhs.to_bool_enum.bind_array, rhs.to_int_var.bind, 
64           offset, *propagation_options)
65       end
66     end
67   end
68 end

Generated on Thu Jan 08 13:27:03 +0100 2015 with rcov 1.0.0