Gecoder C0 Coverage Information - RCov

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

Name Total Lines Lines of Code Total Coverage Code Coverage
lib/gecoder/interface/constraints/int_enum/element.rb 64 45
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     # This adds the adder for the methods in the modules including it. The 
4     # reason for doing it so indirect is that the first #[] won't be defined 
5     # before the module that this is mixed into is mixed into an enum.
6     def self.included(enum_mod) #:nodoc:
7       enum_mod.module_eval do
8         # Now we enter the module IntEnumOperands is mixed into.
9         class << self
10           alias_method :pre_element_included, :included
11           def included(mod) #:nodoc:
12             mod.module_eval do
13               if instance_methods.include? '[]'
14                 alias_method :pre_element_access, :[]
15               end
16           
17               # Produces an IntOperand representing the
18               # i:th integer operand in the enumeration, where i is the
19               # value of the integer operand used as index. Think of it
20               # as array access in the world of constraint programming.
21               # 
22               # ==== Examples 
23               # 
24               #   # The operand at the +x+:th position in +int_enum+,
25               #   # where +x+ is an integer operand.  
26               #   int_enum[x]
27               # 
28               def [](*vars)
29                 if vars.first.respond_to? :to_int_var
30                   return Element::ElementIntOperand.new(
31                     model, self, vars.first)
32                 else
33                   pre_element_access(*vars) if respond_to? :pre_element_access
34                 end
35               end
36             end
37             pre_element_included(mod)
38           end
39         end
40       end
41     end
42   end
43 
44   module Element #:nodoc:
45     class ElementIntOperand < Gecode::Int::ShortCircuitEqualityOperand #:nodoc:
46       def initialize(model, enum_op, position_int_var_op)
47         super model
48         @enum = enum_op
49         @position = position_int_var_op
50       end
51 
52       def constrain_equal(int_operand, constrain, propagation_options)
53         enum = @enum.to_int_enum
54         if constrain
55           int_operand.must_be.in enum.domain_range
56         end
57 
58         Gecode::Raw::element(model.active_space, enum.bind_array, 
59           @position.to_int_var.bind, int_operand.to_int_var.bind, 
60           *propagation_options)
61       end
62     end
63   end
64 end

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