specs/constraints/cardinality.rb in gecoder-0.7.1 vs specs/constraints/cardinality.rb in gecoder-0.8.0

- old
+ new

@@ -47,15 +47,17 @@ end it 'should not shadow the integer variable domain constrain' do Gecode::Raw.should_receive(:dom).with( an_instance_of(Gecode::Raw::Space), - an_instance_of(Gecode::Raw::IntVar), 0, 11, Gecode::Raw::ICL_DEF) + an_instance_of(Gecode::Raw::IntVar), 0, 11, Gecode::Raw::ICL_DEF, + Gecode::Raw::PK_DEF) Gecode::Raw.should_receive(:dom).with( an_instance_of(Gecode::Raw::Space), an_instance_of(Gecode::Raw::IntVar), an_instance_of(Gecode::Raw::IntSet), - an_instance_of(Gecode::Raw::BoolVar), Gecode::Raw::ICL_DEF) + an_instance_of(Gecode::Raw::BoolVar), Gecode::Raw::ICL_DEF, + Gecode::Raw::PK_DEF) @set.size.must_not_be.in [1,3] @model.solve! end it_should_behave_like 'non-reifiable set constraint' @@ -71,11 +73,11 @@ @invoke = lambda do |rhs| @set.size.must == rhs @model.solve! end - @expect = lambda do |relation, rhs, strength, reif_var, negated| + @expect = lambda do |relation, rhs, strength, kind, reif_var, negated| @model.allow_space_access do rhs = an_instance_of(Gecode::Raw::IntVar) if rhs.respond_to? :bind if reif_var.nil? if !negated and relation == Gecode::Raw::IRT_EQ and !rhs.kind_of? Fixnum @@ -89,22 +91,22 @@ an_instance_of(Gecode::Raw::SetVar), an_instance_of(Gecode::Raw::IntVar)) Gecode::Raw.should_receive(:rel).once.with( an_instance_of(Gecode::Raw::Space), an_instance_of(Gecode::Raw::IntVar), relation, rhs, - strength) + strength, kind) end else Gecode::Raw.should_receive(:cardinality).once.with( an_instance_of(Gecode::Raw::Space), an_instance_of(Gecode::Raw::SetVar), an_instance_of(Gecode::Raw::IntVar)) Gecode::Raw.should_receive(:rel).once.with( an_instance_of(Gecode::Raw::Space), an_instance_of(Gecode::Raw::IntVar), relation, rhs, an_instance_of(Gecode::Raw::BoolVar), - strength) + strength, kind) end end end # For composite spec. @@ -115,20 +117,21 @@ @set.size.must.send(relation, target) end @model.solve! end @expect_relation = lambda do |relation, target, negated| - @expect.call(relation, target, Gecode::Raw::ICL_DEF, nil, negated) + @expect.call(relation, target, Gecode::Raw::ICL_DEF, Gecode::Raw::PK_DEF, + nil, negated) end # For options spec. @invoke_options = lambda do |hash| @set.size.must_be.less_than_or_equal_to(17, hash) @model.solve! end - @expect_options = lambda do |strength, reif_var| - @expect.call(Gecode::Raw::IRT_LQ, 17, strength, reif_var, false) + @expect_options = option_expectation do |strength, kind, reif_var| + @expect.call(Gecode::Raw::IRT_LQ, 17, strength, kind, reif_var, false) end end it 'should constrain the cardinality of a set' do @set.size.must == @var @@ -147,8 +150,8 @@ @var.must == 2 @model.solve! @set.value.size.should == 2 end - it_should_behave_like 'constraint with options' + it_should_behave_like 'reifiable constraint' it_should_behave_like 'composite constraint' end