From e81f0f0f1e506a2fa5c5fb05abea3c272af850a2 Mon Sep 17 00:00:00 2001 From: odow Date: Mon, 18 Dec 2023 12:40:24 +1300 Subject: [PATCH 1/3] Improve test coverage in src/macros/@variable.jl --- test/test_macros.jl | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/test_macros.jl b/test/test_macros.jl index 46cf93d8c03..874f75d28ca 100644 --- a/test/test_macros.jl +++ b/test/test_macros.jl @@ -2167,6 +2167,17 @@ 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_base_name_escape() model = Model() x = @variable(model) From fce85169fa9ba2dc10aa924812ec80736df333b4 Mon Sep 17 00:00:00 2001 From: odow Date: Mon, 18 Dec 2023 12:45:11 +1300 Subject: [PATCH 2/3] Update --- test/test_macros.jl | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/test_macros.jl b/test/test_macros.jl index 874f75d28ca..11e3bda0798 100644 --- a/test/test_macros.jl +++ b/test/test_macros.jl @@ -2178,6 +2178,20 @@ function test_variable_not_a_variable_name() 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) From 47e1aa307979f20f2b25e33158d517e250bc8192 Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Mon, 18 Dec 2023 13:04:58 +1300 Subject: [PATCH 3/3] Update test/test_macros.jl --- test/test_macros.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_macros.jl b/test/test_macros.jl index 11e3bda0798..ea2c31eb46e 100644 --- a/test/test_macros.jl +++ b/test/test_macros.jl @@ -2185,7 +2185,7 @@ function test_variable_set_and_hermitian_matrix_space() 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 is already constrained to `$set`.", ), @variable(model, x[1:3, 1:3] in HermitianMatrixSpace(), Hermitian), )