@@ -307,11 +307,12 @@ function _test_dual(
307307 Bridge:: Type{<:AbstractBridge} ,
308308 input_fn:: Function ;
309309 dual,
310+ eltype,
310311 model_eltype,
311312)
312313 inner = MOI. Utilities. UniversalFallback (MOI. Utilities. Model {model_eltype} ())
313314 mock = MOI. Utilities. MockOptimizer (inner)
314- model = _bridged_model (Bridge{model_eltype }, mock)
315+ model = _bridged_model (Bridge{eltype }, mock)
315316 input_fn (model)
316317 final_touch (model)
317318 # Should be able to call final_touch multiple times.
@@ -331,17 +332,21 @@ function _test_dual(
331332 MOI. set (model, MOI. ConstraintDual (), ci, _fake_start (dual, set))
332333 end
333334 end
334- model_dual = MOI. Utilities. get_fallback (
335- model,
336- MOI. DualObjectiveValue (),
337- model_eltype,
338- )
335+ model_dual =
336+ MOI. Utilities. get_fallback (model, MOI. DualObjectiveValue (), eltype)
339337 mock_dual =
340- MOI. Utilities. get_fallback (mock, MOI. DualObjectiveValue (), model_eltype )
338+ MOI. Utilities. get_fallback (mock, MOI. DualObjectiveValue (), eltype )
341339 # Need `atol` in case one of them is zero and the other one almost zero
342340 Test. @test model_dual ≈ mock_dual atol = 1e-6
343341end
344342
343+ function _check_bridged (model; no_bridge_used)
344+ unused = isempty (MOI. Bridges. Variable. bridges (model)) &&
345+ isempty (MOI. Bridges. Constraint. bridges (model)) &&
346+ isempty (MOI. Bridges. Objective. bridges (model))
347+ Test. @test unused == no_bridge_used
348+ end
349+
345350function _runtests (
346351 Bridge:: Type{<:AbstractBridge} ,
347352 input_fn:: Function ,
@@ -353,17 +358,22 @@ function _runtests(
353358 model_eltype = eltype,
354359 print_inner_model:: Bool = false ,
355360 cannot_unbridge:: Bool = false ,
361+ no_bridge_used:: Bool = false ,
356362)
357363 # Load model and bridge it
358364 inner = MOI. Utilities. UniversalFallback (MOI. Utilities. Model {model_eltype} ())
359365 model = _bridged_model (Bridge{eltype}, inner)
360366 input_fn (model)
367+ _check_bridged (model; no_bridge_used)
361368 final_touch (model)
362369 # Should be able to call final_touch multiple times.
363370 final_touch (model)
364371 if print_inner_model
365372 print (inner)
366373 end
374+ if no_bridge_used
375+ return
376+ end
367377 Test. @testset " Test outer bridged model appears like the input" begin # COV_EXCL_LINE
368378 test =
369379 MOI. Utilities. UniversalFallback (MOI. Utilities. Model {model_eltype} ())
@@ -455,7 +465,7 @@ function _runtests(
455465 end
456466 if ! isnothing (dual)
457467 Test. @testset " Test ConstraintDual" begin
458- _test_dual (Bridge, input_fn; dual, model_eltype)
468+ _test_dual (Bridge, input_fn; dual, eltype, model_eltype)
459469 end
460470 end
461471 return
0 commit comments