Name | Total Lines | Lines of Code | Total Coverage | Code Coverage |
---|---|---|---|---|

lib/gecoder/interface/constraints/int/relation.rb | 141 |
53 |
100.00% |
100.00% |

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.

1 module Gecode::Int |

2 class IntConstraintReceiver |

3 # Constrains the integer operand to equal +int_operand_or_fixnum+. |

4 # #equal and #equal_to are aliases of this method. |

5 # |

6 # ==== Examples |

7 # |

8 # # +int1+ must equal +int2+ |

9 # int1.must == int2 |

10 # |

11 # # +int+ must equal 17 |

12 # int.must == 17 |

13 # |

14 # # +int1+ must equal +int2+. We reify the constraint with |

15 # # +bool+ and select +domain+ as strength. |

16 # int1.must.equal(int2, :reify => bool, :strength => :domain) |

17 def ==(int_operand_or_fixnum, options = {}) |

18 comparison(:==, int_operand_or_fixnum, options) |

19 end |

20 |

21 # Constrains the integer operand to be strictly greater than |

22 # +int_operand_or_fixnum+. #greater and #greater_than are |

23 # aliases of this method. |

24 # |

25 # ==== Examples |

26 # |

27 # # +int1+ must be strictly greater than +int2+ |

28 # int1.must > int2 |

29 # |

30 # # +int+ must be strictly greater than 17 |

31 # int.must > 17 |

32 # |

33 # # +int1+ must be strictly greater than +int2+. We reify the |

34 # # constraint with +bool+ and select +domain+ as strength. |

35 # int1.must_be.greater_than(int2, :reify => bool, :strength => :domain) |

36 def >(int_operand_or_fixnum, options = {}) |

37 comparison(:>, int_operand_or_fixnum, options) |

38 end |

39 |

40 # Constrains the integer operand to be greater than or equal to |

41 # +int_operand_or_fixnum+. #greater_or_equal and |

42 # #greater_than_or_equal_to are aliases of this method. |

43 # |

44 # ==== Examples |

45 # |

46 # # +int1+ must be greater than or equal to +int2+ |

47 # int1.must >= int2 |

48 # |

49 # # +int+ must be greater than or equal to 17 |

50 # int.must >= 17 |

51 # |

52 # # +int1+ must be greater than or equal to +int2+. We reify the |

53 # # constraint with +bool+ and select +domain+ as strength. |

54 # int1.must.greater_or_equal(int2, :reify => bool, :strength => :domain) |

55 def >=(int_operand_or_fixnum, options = {}) |

56 comparison(:>=, int_operand_or_fixnum, options) |

57 end |

58 |

59 # Constrains the integer operand to be strictly less than |

60 # +int_operand_or_fixnum+. #lesser and #lesser_than are |

61 # aliases of this method. |

62 # |

63 # ==== Examples |

64 # |

65 # # +int1+ must be strictly less than +int2+ |

66 # int1.must < int2 |

67 # |

68 # # +int+ must be strictly less than 17 |

69 # int.must < 17 |

70 # |

71 # # +int1+ must be strictly less than +int2+. We reify the |

72 # # constraint with +bool+ and select +domain+ as strength. |

73 # int1.must_be.less_than(int2, :reify => bool, :strength => :domain) |

74 def <(int_operand_or_fixnum, options = {}) |

75 comparison(:<, int_operand_or_fixnum, options) |

76 end |

77 |

78 # Constrains the integer operand to be less than or equal to |

79 # +int_operand_or_fixnum+. #less_or_equal and |

80 # #less_than_or_equal_to are aliases of this method. |

81 # |

82 # ==== Examples |

83 # |

84 # # +int1+ must be less than or equal to +int2+ |

85 # int1.must <= int2 |

86 # |

87 # # +int+ must be less than or equal to 17 |

88 # int.must <= 17 |

89 # |

90 # # +int1+ must be less than or equal to +int2+. We reify the |

91 # # constraint with +bool+ and select +domain+ as strength. |

92 # int1.must.less_or_equal(int2, :reify => bool, :strength => :domain) |

93 def <=(int_operand_or_fixnum, options = {}) |

94 comparison(:<=, int_operand_or_fixnum, options) |

95 end |

96 |

97 alias_comparison_methods |

98 |

99 private |

100 |

101 # Helper for the comparison methods. The reason that they are not |

102 # generated in a loop is that it would mess up the RDoc. |

103 def comparison(name, int_operand_or_fixnum, options) |

104 unless int_operand_or_fixnum.respond_to?(:to_int_var) or |

105 int_operand_or_fixnum.kind_of?(Fixnum) |

106 raise TypeError, "Expected int operand or integer, got " + |

107 "#{int_operand_or_fixnum.class}." |

108 end |

109 |

110 unless @params[:negate] |

111 relation_type = Gecode::Util::RELATION_TYPES[name] |

112 else |

113 relation_type = Gecode::Util::NEGATED_RELATION_TYPES[name] |

114 end |

115 @params.update Gecode::Util.decode_options(options) |

116 @model.add_constraint Relation::RelationConstraint.new(@model, |

117 @params.update(:relation_type => relation_type, |

118 :rhs => int_operand_or_fixnum)) |

119 end |

120 end |

121 |

122 # A module that gathers the classes and modules used in relation constraints. |

123 module Relation #:nodoc: |

124 class RelationConstraint < Gecode::ReifiableConstraint #:nodoc: |

125 def post |

126 # Fetch the parameters to Gecode. |

127 lhs, relation, rhs, reif_var = |

128 @params.values_at(:lhs, :relation_type, :rhs, :reif) |

129 |

130 rhs = rhs.to_int_var.bind if rhs.respond_to? :to_int_var |

131 if reif_var.nil? |

132 Gecode::Raw::rel(@model.active_space, lhs.to_int_var.bind, |

133 relation, rhs, *propagation_options) |

134 else |

135 Gecode::Raw::rel(@model.active_space, lhs.to_int_var.bind, |

136 relation, rhs, reif_var.to_bool_var.bind, *propagation_options) |

137 end |

138 end |

139 end |

140 end |

141 end |

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