Gecoder C0 Coverage Information - RCov

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

Name Total Lines Lines of Code Total Coverage Code Coverage
lib/gecoder/interface/constraints/set/relation.rb 155 91
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   class SetConstraintReceiver
3     alias_method :pre_relation_equality, :==
4     # Constrains the set operand to equal +set_operand+.
5     # 
6     # ==== Examples 
7     # 
8     #   # +set1+ must equal +set2+
9     #   set1.must == set2
10     #   
11     #   # +set1+ must equal +set2+. Reify the constraint with the
12     #   # boolean operand +bool+.
13     #   set1.must.equal(set2, :reify => bool)
14     def ==(set_operand, options = {})
15       if set_operand.respond_to? :to_set_var
16         add_relation_constraint(:==, set_operand, options)
17       else
18         pre_relation_equality(set_operand, options)
19       end
20     end
21 
22     alias_method :pre_relation_superset, :superset
23     # Constrains the set operand to be a superset of +set_operand+.
24     # 
25     # ==== Examples 
26     # 
27     #   # +set1+ must be a superset of +set2+
28     #   set1.must_be.superset_of set2
29     #   
30     #   # +set1+ must be a superset of +set2+. Reify the constraint 
31     #   # with the boolean operand +bool+.
32     #   set1.must_be.superset(set2, :reify => bool)
33     def superset(set_operand, options = {})
34       if set_operand.respond_to? :to_set_var
35         add_relation_constraint(:superset, set_operand, options)
36       else
37         pre_relation_superset(set_operand, options)
38       end
39     end
40 
41     alias_method :pre_relation_subset, :subset
42     # Constrains the set operand to be a subeset of +set_operand+.
43     # 
44     # ==== Examples 
45     # 
46     #   # +set1+ must be a subset of +set2+
47     #   set1.must_be.subset_of == set2
48     #   
49     #   # +set1+ must be a subset of +set2+. Reify the constraint 
50     #   # with the boolean operand +bool+.
51     #   set1.must_be.subset(set2, :reify => bool)
52     def subset(set_operand, options = {})
53       if set_operand.respond_to? :to_set_var
54         add_relation_constraint(:subset, set_operand, options)
55       else
56         pre_relation_subset(set_operand, options)
57       end
58     end
59 
60     alias_method :pre_relation_disjoint, :disjoint
61     # Constrains the set operand to be disjoint with +set_operand+.
62     # 
63     # ==== Examples 
64     # 
65     #   # +set1+ must be disjoint with +set2+
66     #   set1.must_be.disjoint_with set2
67     #   
68     #   # +set1+ must be disjoint with +set2+. Reify the constraint 
69     #   # with the boolean operand +bool+.
70     #   set1.must_be.disjoint(set2, :reify => bool)
71     def disjoint(set_operand, options = {})
72       if set_operand.respond_to? :to_set_var
73         add_relation_constraint(:disjoint, set_operand, options)
74       else
75         pre_relation_disjoint(set_operand, options)
76       end
77     end
78 
79     alias_method :pre_relation_complement, :complement
80     # Constrains the set operand to be the complement of +set_operand+.
81     # 
82     # ==== Examples 
83     # 
84     #   # +set1+ must be the complement of +set2+
85     #   set1.must_be.complement_of set2
86     #   
87     #   # +set1+ must be the complement of +set2+. Reify the constraint 
88     #   # with the boolean operand +bool+.
89     #   set1.must_be.complement(set2, :reify => bool)
90     def complement(set_operand, options = {})
91       if set_operand.respond_to? :to_set_var
92         add_relation_constraint(:complement, set_operand, options)
93       else
94         pre_relation_complement(set_operand, options)
95       end
96     end
97 
98     alias_set_methods
99     
100     private
101     
102     # Adds a relation constraint for the specified relation name, set
103     # operand and options.
104     def add_relation_constraint(relation_name, set, options)
105       @params[:rhs] = set
106       @params[:relation] = relation_name
107       @params.update Gecode::Set::Util.decode_options(options)
108       if relation_name == :==
109         @model.add_constraint Relation::EqualityRelationConstraint.new(@model, 
110           @params)
111       else
112         @model.add_constraint Relation::RelationConstraint.new(@model, @params)
113       end
114     end
115   end
116   
117   # A module that gathers the classes and modules used in relation constraints.
118   module Relation #:nodoc:
119     class EqualityRelationConstraint < Gecode::ReifiableConstraint #:nodoc:
120       def post
121         lhs, rhs, reif_var, negate = @params.values_at(:lhs, :rhs, :reif, 
122           :negate)
123         if negate
124           rel_type = Gecode::Util::NEGATED_SET_RELATION_TYPES[:==]
125         else
126           rel_type = Gecode::Util::SET_RELATION_TYPES[:==]
127         end
128         
129         (params = []) << lhs.to_set_var.bind
130         params << rel_type
131         params << rhs.to_set_var.bind
132         if reif_var.respond_to? :to_bool_var
133           params << reif_var.to_bool_var.bind 
134         end
135         Gecode::Raw::rel(@model.active_space, *params)
136       end
137     end
138   
139     class RelationConstraint < Gecode::ReifiableConstraint #:nodoc:
140       def post
141         lhs, rhs, reif_var, relation = @params.values_at(:lhs, :rhs, :reif, 
142           :relation)
143         
144         (params = []) << lhs.to_set_var.bind
145         params << Gecode::Util::SET_RELATION_TYPES[relation]
146         params << rhs.to_set_var.bind
147         if reif_var.respond_to? :to_bool_var
148           params << reif_var.to_bool_var.bind 
149         end
150         Gecode::Raw::rel(@model.active_space, *params)
151       end
152       negate_using_reification
153     end
154   end
155 end

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