@@ -167,11 +167,12 @@ function test8(args...)
167167end
168168
169169function test9 (args... )
170- @testset " Test ErrorException(s) " begin
170+ @testset " Test bad model error " begin
171171 model_1 = Model (args... )
172172 @test_throws ErrorException x = Parameters (model_1, ones (5 ))
173173 @test_throws ErrorException y = Parameter (model_1, 1.0 )
174-
174+ end
175+ @testset " Test lazy duals errors" begin
175176 model_2 = ModelWithParams (args... )
176177 ParameterJuMP. set_lazy_duals (model_2)
177178 ParameterJuMP. set_lazy_duals (model_2) # warn
@@ -322,4 +323,24 @@ function test12(args...)
322323 @test JuMP. dual (cref) == 1.0
323324 @test JuMP. dual (α) == 0.0
324325 end
326+ end
327+
328+ function test13 (args... )
329+ @testset " Test no duals errors" begin
330+ model = ModelWithParams (args... )
331+ ParameterJuMP. set_no_duals (model)
332+ α = Parameter (model, 1.0 )
333+ ParameterJuMP. setvalue! (α, - 1.0 )
334+ @variable (model, x)
335+ cref = @constraint (model, x == α)
336+ @objective (model, Max, x)
337+ JuMP. optimize! (model)
338+ @test JuMP. value (x) == - 1.0
339+ @test JuMP. dual (cref) == - 1.0
340+ @test_throws ErrorException JuMP. dual (α)
341+
342+ model_2 = ModelWithParams (args... )
343+ y = Parameter (model_2, 1.0 )
344+ @test_throws ErrorException ParameterJuMP. set_no_duals (model_2)
345+ end
325346end
0 commit comments