Skip to content

Commit

Permalink
Update test_macros.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
odow authored Nov 12, 2024
1 parent aea87c2 commit 5b7cc3a
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions test/test_macros.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2494,7 +2494,7 @@ function test_subexpression_kwarg()
@test ex isa VariableRef
@test model[:ex] isa VariableRef
@test model[:ex] === ex
@test occursin("ex - sin(x) = 0", sprint(print, model))
@test occursin(r"ex - sin\(x\) ==? 0", sprint(print, model))
@test num_variables(model) == 2
return
end
Expand All @@ -2505,8 +2505,8 @@ function test_subexpression_kwarg_array()
@expression(model, ex[i in 1:2], sin(x[i]), subexpression = true)
@test ex isa Vector{VariableRef}
@test model[:ex] === ex
@test occursin("ex[1] - sin(x[1]) = 0", sprint(print, model))
@test occursin("ex[2] - sin(x[2]) = 0", sprint(print, model))
@test occursin(r"ex\[1\] - sin\(x\[1\]\) ==? 0", sprint(print, model))
@test occursin(r"ex\[2\] - sin\(x\[2\]\) ==? 0", sprint(print, model))
@test num_variables(model) == 4
return
end
Expand All @@ -2517,8 +2517,8 @@ function test_subexpression_kwarg_dense_axis_array()
@expression(model, ex[i in 2:3], sin(x[i]), subexpression = true)
@test ex isa Containers.DenseAxisArray{VariableRef}
@test model[:ex] === ex
@test occursin("ex[2] - sin(x[2]) = 0", sprint(print, model))
@test occursin("ex[3] - sin(x[3]) = 0", sprint(print, model))
@test occursin(r"ex\[2\] - sin\(x\[2\]\) ==? 0", sprint(print, model))
@test occursin(r"ex\[3\] - sin\(x\[3\]\) ==? 0", sprint(print, model))
@test num_variables(model) == 4
return
end
Expand All @@ -2529,8 +2529,8 @@ function test_subexpression_kwarg_dense_axis_array()
@expression(model, ex[i in 1:3; isodd(i)], sin(x[i]), subexpression = true)
@test ex isa Containers.SparseAxisArray{VariableRef}
@test model[:ex] === ex
@test occursin("ex[1] - sin(x[1]) = 0", sprint(print, model))
@test occursin("ex[3] - sin(x[3]) = 0", sprint(print, model))
@test occursin(r"ex\[1\] - sin\(x\[1\]\) ==? 0", sprint(print, model))
@test occursin(r"ex\[3\] - sin\(x\[3\]\) ==? 0", sprint(print, model))
@test num_variables(model) == 4
return
end
Expand All @@ -2541,8 +2541,8 @@ function test_subexpression_kwarg_vector_element()
@expression(model, ex, sin.(x), subexpression = true)
@test ex isa Vector{VariableRef}
@test model[:ex] === ex
@test occursin("ex - sin(x[1]) = 0", sprint(print, model))
@test occursin("ex - sin(x[2]) = 0", sprint(print, model))
@test occursin(r"ex - sin\(x\[1\]\) ==? 0", sprint(print, model))
@test occursin(r"ex - sin\(x\[2\]\) ==? 0", sprint(print, model))
@test num_variables(model) == 4
return
end
Expand All @@ -2553,7 +2553,7 @@ function test_subexpression_kwarg_no_name()
ex = @expression(model, sin(x), subexpression = true)
@test ex isa VariableRef
@test !haskey(model, :ex)
@test occursin("_[2] - sin(x) = 0", sprint(print, model))
@test occursin(r"\_\[2\] - sin\(x\) ==? 0", sprint(print, model))
@test num_variables(model) == 2
return
end
Expand Down

0 comments on commit 5b7cc3a

Please sign in to comment.