diff --git a/test/test_macros.jl b/test/test_macros.jl index 46cf93d8c03..ea2c31eb46e 100644 --- a/test/test_macros.jl +++ b/test/test_macros.jl @@ -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)