Class ConstraintSolver::VariableTest
In: test/VariableTest.rb
Parent: Test::Unit::TestCase
Test::Unit::TestCase AllDifferentConstraintTest SolutionTest ConstraintSolverTest ConstraintListTest VariableTest DomainTest BinaryConstraintTest ProblemTest BinaryRelationTest Exception DomainWipeoutException UndoStackEmptyException AbstractConstraint BinaryConstraint AllDifferentConstraint Array ConstraintList BinaryRelation Variable Solution ConstraintSolver Problem Domain test/DomainTest.rb test/SolutionTest.rb lib/BinaryConstraint.rb lib/Variable.rb test/ConstraintListTest.rb lib/ConstraintList.rb test/ProblemTest.rb lib/Solution.rb test/BinaryConstraintTest.rb lib/ConstraintSolver.rb test/VariableTest.rb test/AllDifferentConstraintTest.rb lib/AllDifferentConstraint.rb lib/Problem.rb test/ConstraintSolverTest.rb lib/Domain.rb lib/AbstractConstraint.rb ConstraintSolver dot/m_19_0.png

Methods

Public Instance methods

[Source]

# File test/VariableTest.rb, line 11
        def setup
            @variable = Variable.new("test", Domain.new([ 3, 4, 5 ].to_set))
        end

[Source]

# File test/VariableTest.rb, line 28
        def testAssignment
            assert_raise(ArgumentError) { @variable.value = 2 }
            assert_nothing_raised { @variable.value = nil }
            assert_nothing_raised { @variable.value = 3 }
            assert(@variable.assigned?)
            assert_equal(3, @variable.value)
            @variable.reset
            assert_equal(false, @variable.assigned?)
            assert_equal(nil, @variable.value)
        end

[Source]

# File test/VariableTest.rb, line 15
        def testConstructor
            assert_raise(ArgumentError) { Variable.new }
            assert_raise(ArgumentError) { Variable.new(nil) }
            assert_raise(ArgumentError) { Variable.new(3) }
            assert_raise(ArgumentError) { Variable.new("name", Domain.new([ 3 ].to_set), 4) }
            assert_nothing_raised {
                var = Variable.new("name", nil, 3)
                assert_equal([ 3 ].to_set, var.domain.values)
            }
            assert_nothing_raised { Variable.new("name", Domain.new([ 3 ].to_set)) }
            assert_nothing_raised { Variable.new("name", Domain.new([ 3 ].to_set), 3) }
        end

[Source]

# File test/VariableTest.rb, line 39
        def testEquals
            assert_equal(@variable, Variable.new("test", Domain.new([ 3, 4, 5 ].to_set)))
            assert_not_equal(@variable, Variable.new("test", nil, 3))
            assert_not_equal(@variable, Variable.new("test", Domain.new([ 3, 4, 5 ].to_set), 3))
            assert_not_equal(@variable, Variable.new("tester", Domain.new([ 3, 4, 5 ].to_set)))
        end

[Validate]