Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve test coverage in src/macros/@variable.jl #3633

Merged
merged 3 commits into from
Dec 18, 2023
Merged
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
25 changes: 25 additions & 0 deletions test/test_macros.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2167,6 +2167,31 @@ function test_expression_container_kwarg()
return
end

function test_variable_not_a_variable_name()
model = Model()
@test_throws_parsetime(
ErrorException(
"In `@variable(model, x)`: Expected x to be a variable name",
),
@variable(model, "x"),
)
return
end

function test_variable_set_and_hermitian_matrix_space()
model = Model()
set = esc(:(HermitianMatrixSpace()))
@test_throws_parsetime(
ErrorException(
"In `@variable(model, x[1:3, 1:3] in HermitianMatrixSpace(), Hermitian)`: " *
"Cannot pass `Hermitian` as a positional argument because the " *
"variable is already constrained to `$set`.",
),
@variable(model, x[1:3, 1:3] in HermitianMatrixSpace(), Hermitian),
)
return
end

function test_base_name_escape()
model = Model()
x = @variable(model)
Expand Down
Loading