Sha256: 97ce3a4385e33c24d2621c78d7b6c5c7d4e269ee5f29acd1377aff6c89e30e96

Contents?: true

Size: 873 Bytes

Versions: 2

Compression:

Stored size: 873 Bytes

Contents

require File.dirname(__FILE__) + '/../spec_helper'
require File.dirname(__FILE__) + '/constraint_helper'

describe Gecode::Constraints::IntEnum::Equality do
  before do
    @model = Gecode::Model.new
    @vars = @model.int_var_array(4, -2..2)
    @invoke_options = lambda do |hash| 
      @vars.must_be.equal(hash)
      @model.solve!
    end
    @expect_options = lambda do |strength, reif_var|
      Gecode::Raw.should_receive(:eq).once.with(@model.active_space, 
        anything, strength)
    end
  end
  
  it 'should translate equality constraints' do
    @expect_options.call(Gecode::Raw::ICL_DEF, nil)
    @invoke_options.call({})
    @vars.must_be.equal
  end

  it 'should not allow negation' do
    lambda{ @vars.must_not_be.equal }.should raise_error(
      Gecode::MissingConstraintError)
  end
  
  it_should_behave_like 'constraint with strength option'
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gecoder-0.4.0 specs/constraints/equality.rb
gecoder-0.5.0 specs/constraints/equality.rb