Skip to content

Commit 1a6d75f

Browse files
authored
Fix bug in test_model_ScalarFunctionConstantNotZero (#1762)
1 parent 03640ab commit 1a6d75f

2 files changed

Lines changed: 16 additions & 4 deletions

File tree

src/Test/test_model.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -748,16 +748,18 @@ function test_model_ScalarFunctionConstantNotZero(
748748
try
749749
f = MOI.ScalarAffineFunction(MOI.ScalarAffineTerm{T}[], T(1))
750750
c = MOI.add_constraint(model, f, MOI.EqualTo(T(2)))
751-
@requires _supports(config, MOI.ConstraintFunction)
752-
@test MOI.get(model, MOI.ConstraintFunction(), c) f
751+
if _supports(config, MOI.ConstraintFunction)
752+
@test MOI.get(model, MOI.ConstraintFunction(), c) f
753+
end
753754
catch err
754755
@test err == _error(MOI.EqualTo{T}, T(1))
755756
end
756757
try
757758
f = MOI.ScalarAffineFunction(MOI.ScalarAffineTerm{T}[], T(2))
758759
c = MOI.add_constraint(model, f, MOI.GreaterThan(T(1)))
759-
@requires _supports(config, MOI.ConstraintFunction)
760-
@test MOI.get(model, MOI.ConstraintFunction(), c) f
760+
if _supports(config, MOI.ConstraintFunction)
761+
@test MOI.get(model, MOI.ConstraintFunction(), c) f
762+
end
761763
catch err
762764
@test err == _error(MOI.GreaterThan{T}, T(2))
763765
end

test/Test/Test.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,16 @@ MOI.Test.runtests(
3838
],
3939
)
4040

41+
# Test for Issue #1757
42+
43+
MOI.Test.test_model_ScalarFunctionConstantNotZero(
44+
MOI.Utilities.MockOptimizer(
45+
MOI.Utilities.Model{Float64}(),
46+
scalar_function_constant_non_zero = false,
47+
),
48+
MOI.Test.Config(exclude = Any[MOI.ConstraintFunction]),
49+
)
50+
4151
# Test exclude_tests_after. This should work despite no methods being added for IncompleteOptimizer
4252
# because every test should get skipped.
4353

0 commit comments

Comments
 (0)