Gecoder C0 Coverage Information - RCov

lib/gecoder/interface/constraints/set/cardinality.rb

Name Total Lines Lines of Code Total Coverage Code Coverage
lib/gecoder/interface/constraints/set/cardinality.rb 65 49
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::Set
2   module SetOperand
3     # Produces an IntOperand representing the size of the set.
4     #
5     # ==== Examples 
6     #
7     #   # The size of +set+.
8     #   set.size
9     def size
10       Cardinality::SetSizeOperand.new(@model, self)
11     end
12   end
13 
14   # A module that gathers the classes and modules used in cardinality 
15   # constraints.
16   module Cardinality #:nodoc:
17     # Describes a cardinality constraint specifically for ranges. This is just
18     # a special case which is used instead of the more general composite 
19     # constraint when the target cardinality is a range. 
20     class CardinalityConstraint < Gecode::Constraint #:nodoc:
21       def post
22         var, range = @params.values_at(:lhs, :range)
23         Gecode::Raw::cardinality(@model.active_space, var.to_set_var.bind, 
24           range.first, range.last)
25       end
26     end
27     
28     class SetSizeOperand < Gecode::Int::ShortCircuitEqualityOperand #:nodoc:
29       def initialize(model, set_op)
30         super model
31         @set = set_op
32       end
33 
34       def constrain_equal(int_operand, constrain, propagation_options)
35         set = @set.to_set_var
36         if constrain
37           int_operand.must_be.in set.lower_bound.size..set.upper_bound.size
38         end
39         
40         Gecode::Raw::cardinality(@model.active_space, set.bind, 
41           int_operand.to_int_var.bind)
42       end
43 
44       alias_method :pre_cardinality_construct_receiver, :construct_receiver
45       def construct_receiver(params)
46         receiver = pre_cardinality_construct_receiver(params)
47         set = @set
48         receiver.instance_eval{ @set = set }
49         class <<receiver 
50           alias_method :in_without_short_circuit, :in
51           def in(range, options = {})
52             if range.kind_of?(Range) and !@params[:negate] and 
53                 !options.has_key?(:reify)
54               @params.update(:lhs => @set, :range => range)
55               @model.add_constraint CardinalityConstraint.new(@model, @params)
56             else
57               in_without_short_circuit(range, options)
58             end
59           end
60         end
61         return receiver
62       end
63     end
64   end
65 end

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