diff --git a/test/test_constraint.jl b/test/test_constraint.jl index 3f800f419df..cb63bb99e29 100644 --- a/test/test_constraint.jl +++ b/test/test_constraint.jl @@ -2199,9 +2199,7 @@ function test_shadow_price_errors() @variable(model, x >= 0) set_optimizer( model, - () -> MOI.Utilities.MockOptimizer( - MOI.Utilities.Model{Float64}(), - ), + () -> MOI.Utilities.MockOptimizer(MOI.Utilities.Model{Float64}()), ) optimize!(model) mock = unsafe_backend(model) diff --git a/test/test_model.jl b/test/test_model.jl index d3926b20e8e..6db3a692ed0 100644 --- a/test/test_model.jl +++ b/test/test_model.jl @@ -1371,7 +1371,7 @@ function test_copy_nonlinear() @test_throws( ErrorException( "copy is not supported yet for models with nonlinear constraints" * - " and/or nonlinear objective function" + " and/or nonlinear objective function", ), copy_model(model), ) diff --git a/test/test_nlp.jl b/test/test_nlp.jl index fbbeea10edc..2dee2c61ca8 100644 --- a/test/test_nlp.jl +++ b/test/test_nlp.jl @@ -1683,4 +1683,46 @@ function test_get_node_type_comparison() return end +function test_NL_dot() + model = Model() + @variable(model, x) + y = (; abc = x) + @NLexpression(model, ref, y.abc) + nlp = nonlinear_model(model) + @test MOI.Nonlinear.parse_expression(nlp, x) == nlp[index(ref)] + return +end + +function test_NL_adjoint() + model = Model() + @variable(model, x) + @NLexpression(model, ref, x') + nlp = nonlinear_model(model) + @test MOI.Nonlinear.parse_expression(nlp, x) == nlp[index(ref)] + return +end + +function test_NL_too_many_arguments_errors() + model = Model() + @test_throws_parsetime( + ErrorException( + "At `@NLexpression()`: To few arguments (0); must pass the model and nonlinear expression as arguments.", + ), + @NLexpression(), + ) + @test_throws_parsetime( + ErrorException( + "At `@NLexpression(model, ex, 1, 2)`: To many arguments (4).", + ), + @NLexpression(model, ex, 1, 2), + ) + @test_throws_parsetime( + ErrorException( + "At `@NLconstraint(model, ex, 1, 2)`: too many arguments.", + ), + @NLconstraint(model, ex, 1, 2), + ) + return +end + end