Name | Total Lines | Lines of Code | Total Coverage | Code Coverage |
---|---|---|---|---|
lib/gecoder/interface/constraints/set/channel.rb | 51 | 30 | 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::Set |
2 class SetConstraintReceiver |
3 # Constrains this set to channel +bool_enum+. The set is constrained |
4 # to include value i exactly when the operand at index i in the |
5 # boolean enumeration is true. |
6 # |
7 # Neither reification nor negation is supported. The boolean enum and set |
8 # can be interchanged. |
9 # |
10 # ==== Examples |
11 # |
12 # # Constrains the enumeration of boolean operands called +bools+ to at |
13 # # least have the first and third operands set to true |
14 # set.must_be.superset_of [0, 2] |
15 # set.must.channel bools |
16 # |
17 # # An alternative way of writing the above. |
18 # set.must_be.superset_of [0, 2] |
19 # bools.must.channel set |
20 def channel(bool_enum, options = {}) |
21 if @params[:negate] |
22 raise Gecode::MissingConstraintError, 'A negated channel constraint ' + |
23 'is not implemented.' |
24 end |
25 if options.has_key? :reify |
26 raise ArgumentError, 'The channel constraint does not support the ' + |
27 'reification option.' |
28 end |
29 unless bool_enum.respond_to? :to_bool_enum |
30 raise TypeError, 'Expected an enum of bool operands, ' + |
31 "got #{bool_enum.class}." |
32 end |
33 |
34 @params.update(:rhs => bool_enum) |
35 @params.update Gecode::Set::Util.decode_options(options) |
36 @model.add_constraint Channel::ChannelConstraint.new(@model, @params) |
37 end |
38 end |
39 |
40 # A module that gathers the classes and modules used in channel constraints |
41 # involving one set operand and a boolean enum. |
42 module Channel #:nodoc: |
43 class ChannelConstraint < Gecode::Constraint #:nodoc: |
44 def post |
45 lhs, rhs = @params.values_at(:lhs, :rhs) |
46 Gecode::Raw::channel(@model.active_space, rhs.to_bool_enum.bind_array, |
47 lhs.to_set_var.bind) |
48 end |
49 end |
50 end |
51 end |
Generated on Thu Jan 08 13:27:03 +0100 2015 with rcov 1.0.0