Skip to content

Commit

Permalink
Fix @test_throws on Julia v0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
blegat committed Nov 16, 2018
1 parent 87c558b commit 7af300d
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions test/model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,24 @@ function test_model()
@test JuMP.backend(model) isa MOIU.CachingOptimizer
@test !(JuMP.backend(model).optimizer isa MOI.Bridges.LazyBridgeOptimizer)
@variable model x
err = ErrorException("Constraints of type MathOptInterface.ScalarAffineFunction{Float64}-in-MathOptInterface.Interval{Float64} are not supported by the solver, try using `bridge_constraints=true` in the `JuMP.Model` constructor if you believe the constraint can be reformulated to constraints supported by the solver.")
@test_throws err @constraint model 0 <= x + 1 <= 1
if VERSION < v"0.7-"
@test_throws ErrorException @constraint model 0 <= x + 1 <= 1
else
err = ErrorException("Constraints of type MathOptInterface.ScalarAffineFunction{Float64}-in-MathOptInterface.Interval{Float64} are not supported by the solver, try using `bridge_constraints=true` in the `JuMP.Model` constructor if you believe the constraint can be reformulated to constraints supported by the solver.")
@test_throws err @constraint model 0 <= x + 1 <= 1
end
end
@testset "No bridge automatically added in Direct mode" begin
optimizer = MOIU.MockOptimizer(SimpleLPModel{Float64}())
model = JuMP.direct_model(optimizer)
@test !JuMP.bridge_constraints(model)
@variable model x
err = ErrorException("Constraints of type MathOptInterface.ScalarAffineFunction{Float64}-in-MathOptInterface.Interval{Float64} are not supported by the solver.")
@test_throws err @constraint model 0 <= x + 1 <= 1
if VERSION < v"0.7-"
@test_throws ErrorException @constraint model 0 <= x + 1 <= 1
else
err = ErrorException("Constraints of type MathOptInterface.ScalarAffineFunction{Float64}-in-MathOptInterface.Interval{Float64} are not supported by the solver.")
@test_throws err @constraint model 0 <= x + 1 <= 1
end
end
end

Expand Down

0 comments on commit 7af300d

Please sign in to comment.