Gecoder C0 Coverage Information - RCov

lib/gecoder/interface/constraints/int_enum_constraints.rb

Name Total Lines Lines of Code Total Coverage Code Coverage
lib/gecoder/interface/constraints/int_enum_constraints.rb 95 32
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 # A module containing constraints that have enumerations of integer 
2 # operands as left hand side.
3 module Gecode::IntEnum #:nodoc:
4   # A IntEnumOperand is a enumeration of IntOperand on which the
5   # constraints defined in IntEnumConstraintReceiver can be placed.
6   #
7   # Enumerations of integer operands can be created either by using
8   # Gecode::Mixin#int_var_array and Gecode::Mixin#int_var_matrix, or
9   # by wrapping an existing enumeration containing IntOperand using
10   # Gecode::Mixin#wrap_enum. The enumerations, no matter how they were
11   # created, all respond to the properties defined by IntEnumOperand.
12   #
13   # ==== Examples 
14   #
15   # Produces an array of five int operands with domain 0..9 inside a 
16   # problem formulation using Gecode::Mixin#int_var_array:
17   #
18   #   int_enum = int_var_array(5, 0..9)
19   #
20   # Uses Gecode::Mixin#wrap_enum inside a problem formulation to create
21   # a IntEnumOperand from an existing enumeration containing the
22   # integer operands +int_operand1+ and +int_operand2+:
23   #
24   #   int_enum = wrap_enum([int_operand1, int_operand2])
25   #   
26   #--
27   # Classes that mix in IntEnumOperand must define #model and
28   # #to_int_enum .
29   module IntEnumOperand
30     include Gecode::Operand 
31 
32     def method_missing(method, *args) #:nodoc:
33       if Gecode::IntEnum::Dummy.instance_methods.include? method.to_s
34         # Delegate to the int enum.
35         to_int_enum.method(method).call(*args)
36       else
37         super
38       end
39     end
40 
41     private
42 
43     def construct_receiver(params)
44       IntEnumConstraintReceiver.new(@model, params)
45     end
46   end
47 
48   # IntEnumConstraintReceiver contains all constraints that can be
49   # placed on a IntEnumOperand.
50   #
51   # Constraints are placed by calling IntEnumOperand#must (or any other
52   # of the variations defined in Operand), which produces a 
53   # IntEnumConstraintReceiver from which the desired constraint can be used.
54   #
55   # Some constraint accepts a number of options. See ConstraintReceiver
56   # for more information.
57   #
58   # ==== Examples 
59   #
60   # Constrains the integer operands in +int_enum+ to take on different
61   # values by using IntEnumConstraintReceiver#distinct:
62   #
63   #   int_enum.must_be.distinct
64   #
65   # Constrains +int_enum2+ to have the same elements as +int_enum+, but
66   # sorted in ascending order. Uses IntEnumConstraintReceiver#sorted:
67   #
68   #   int_enum.must_be.sorted(:as => int_enum2)
69   #
70   # The same as above, but specifying that strength :domain should be 
71   # used and that the constraint should be reified with +bool_operand+:
72   #
73   #   int_enum.must_be.sorted(:as => int_enum2, :strength => :domain, :reify => bool_operand)
74   #
75   class IntEnumConstraintReceiver < Gecode::ConstraintReceiver
76     # Raises TypeError unless the left hand side is an int enum
77     # operand.
78     def initialize(model, params) #:nodoc:
79       super
80 
81       unless params[:lhs].respond_to? :to_int_enum
82         raise TypeError, 'Must have int enum operand as left hand side.'
83       end
84     end
85   end
86 end
87 
88 require 'gecoder/interface/constraints/int_enum/distinct'
89 require 'gecoder/interface/constraints/int_enum/equality'
90 require 'gecoder/interface/constraints/int_enum/channel'
91 require 'gecoder/interface/constraints/int_enum/element'
92 require 'gecoder/interface/constraints/int_enum/count'
93 require 'gecoder/interface/constraints/int_enum/sort'
94 require 'gecoder/interface/constraints/int_enum/arithmetic'
95 require 'gecoder/interface/constraints/int_enum/extensional'

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