diff --git a/src/FileFormats/MOF/read.jl b/src/FileFormats/MOF/read.jl index 963fc90215..a3ca5e7e27 100644 --- a/src/FileFormats/MOF/read.jl +++ b/src/FileFormats/MOF/read.jl @@ -189,7 +189,7 @@ macro head_to_val(f, arg1, args...) push!(leaf.args, new_expr) leaf = new_expr end - push!(leaf.args, Expr(:return, Val(head))) + push!(leaf.args, :(return Val(Symbol($head)))) quote function $(esc(f))($head::String) return $body diff --git a/test/FileFormats/MOF/test_MOF.jl b/test/FileFormats/MOF/test_MOF.jl index e274faabcc..3f6414995f 100644 --- a/test/FileFormats/MOF/test_MOF.jl +++ b/test/FileFormats/MOF/test_MOF.jl @@ -1681,6 +1681,29 @@ function test_unsupported_objectives() return end +struct CustomSet <: MOI.AbstractVectorSet + dimension::Int +end + +function MOF.set_to_moi(::Val{:CustomSet}, object::Dict) + return CustomSet(object["dimension"]) +end + +function test_custom_set_to_moi() + object = Dict{String,Any}("type" => "CustomSet", "dimension" => 3) + @test MOF.set_to_moi(Val(:CustomSet), Float64, object) == CustomSet(3) + @test MOF.set_to_moi(Float64, object) == CustomSet(3) + return +end + +function test_head_to_val() + @test MOF.head_to_set("Nonnegatives") === Val(:Nonnegatives) + @test MOF.head_to_set("CustomSet") === Val(:CustomSet) + @test MOF.head_to_function("VectorOfVariables") === Val(:VectorOfVariables) + @test MOF.head_to_function("CustomFunction") === Val(:CustomFunction) + return +end + function test_unsupported_kwarg() @test_throws( ErrorException(