Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/FileFormats/MOF/read.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 23 additions & 0 deletions test/FileFormats/MOF/test_MOF.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Loading