From 8a24f22edd9c16d09d1ee5be944f638d6dd4427e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Legat?= Date: Wed, 28 Oct 2026 19:01:43 +0100 Subject: [PATCH 1/2] Add a test of sum with init --- test/Utilities/test_mutable_arithmetics.jl | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/Utilities/test_mutable_arithmetics.jl b/test/Utilities/test_mutable_arithmetics.jl index 33a30d72c5..25a1bd6038 100644 --- a/test/Utilities/test_mutable_arithmetics.jl +++ b/test/Utilities/test_mutable_arithmetics.jl @@ -190,6 +190,20 @@ function test_VariableIndex() MA.Test.@test_rewrite(x - a) end +function test_VariableIndex_sum_init() + x = MOI.VariableIndex.(1:3) + for T in (Int, Float32, Float64) + for init in (zero(T), T(2)) + f = sum(x; init) + expected = + MOI.ScalarAffineFunction(MOI.ScalarAffineTerm.(one(T), x), init) + @test f isa MOI.ScalarAffineFunction{T} + @test f ≈ expected + end + end + return +end + function test_ScalarAffineFunction() T = Int MA.Test.int_test( From a5011ac37ee9d24d2de84fdcf61ae2e4a6ada54b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Legat?= Date: Wed, 28 Oct 2026 19:21:19 +0100 Subject: [PATCH 2/2] Only test with zero --- test/Utilities/test_mutable_arithmetics.jl | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/test/Utilities/test_mutable_arithmetics.jl b/test/Utilities/test_mutable_arithmetics.jl index 25a1bd6038..041d0c15bc 100644 --- a/test/Utilities/test_mutable_arithmetics.jl +++ b/test/Utilities/test_mutable_arithmetics.jl @@ -193,13 +193,12 @@ end function test_VariableIndex_sum_init() x = MOI.VariableIndex.(1:3) for T in (Int, Float32, Float64) - for init in (zero(T), T(2)) - f = sum(x; init) - expected = - MOI.ScalarAffineFunction(MOI.ScalarAffineTerm.(one(T), x), init) - @test f isa MOI.ScalarAffineFunction{T} - @test f ≈ expected - end + init = zero(T) + f = sum(x; init) + expected = + MOI.ScalarAffineFunction(MOI.ScalarAffineTerm.(one(T), x), init) + @test f isa MOI.ScalarAffineFunction{T} + @test f ≈ expected end return end