Gecoder C0 Coverage Information - RCov

lib/gecoder/interface/constraints/int_enum/count.rb

Name Total Lines Lines of Code Total Coverage Code Coverage
lib/gecoder/interface/constraints/int_enum/count.rb 66 47
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::IntEnum
2   module IntEnumOperand
3     # Produces a new IntOperand representing the number of times
4     # +int_operand_or_fixnum+ is present in this enumeration.
5     #
6     # ==== Examples 
7     #
8     #   # The number of times 17 occurs in +int_enum+.
9     #   int_enum.count(17)
10     #
11     #   # The number of times +int_operand+ occurs in +int_enum+.
12     #   int_enum.count(int_operand)
13     def count(int_operand_or_fixnum)
14       unless int_operand_or_fixnum.respond_to? :to_int_var or 
15           int_operand_or_fixnum.kind_of?(Fixnum)
16         raise TypeError, 'Expected integer operand of fixnum, got ' + 
17           "#{int_operand_or_fixnum.class}."
18       end
19       Count::IntEnumCountOperand.new(@model, self, int_operand_or_fixnum)
20     end
21   end
22 
23   # A module that gathers the classes and modules used in count constraints.
24   module Count #:nodoc:
25     class IntEnumCountOperand < Gecode::Int::ShortCircuitRelationsOperand #:nodoc:
26       def initialize(model, int_enum, element)
27         super model
28         @enum = int_enum
29         @element = element
30       end
31       
32       def relation_constraint(relation, int_operand_or_fix, params)
33         unless params[:negate]
34           relation_type = 
35             Gecode::Util::RELATION_TYPES[relation]
36         else
37           relation_type = 
38             Gecode::Util::NEGATED_RELATION_TYPES[relation]
39         end
40         
41         params.update(:enum => @enum, :element => @element, 
42           :rhs => int_operand_or_fix, :relation_type => relation_type)
43         CountConstraint.new(@model, params)
44       end
45     end
46     
47     class CountConstraint < Gecode::ReifiableConstraint #:nodoc:
48       def post
49         enum, element, relation_type, rhs = 
50           @params.values_at(:enum, :element, :relation_type, :rhs)
51         
52         # Bind variables if needed.
53         unless element.kind_of? Fixnum
54           element = element.to_int_var.bind
55         end
56         unless rhs.kind_of? Fixnum
57           rhs = rhs.to_int_var.bind
58         end
59         
60         # Post the constraint to gecode.
61         Gecode::Raw::count(@model.active_space, enum.to_int_enum.bind_array, 
62           element, relation_type, rhs, *propagation_options)
63       end
64     end
65   end
66 end

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