Skip to content

Commit

Permalink
Add Expression testset
Browse files Browse the repository at this point in the history
  • Loading branch information
blegat committed May 11, 2018
1 parent 7420734 commit 9f1c96f
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions test/expr.jl
Expand Up @@ -6,20 +6,22 @@ Base.:^(x::PowVariable, i::Int) = PowVariable(x.pow*i)
Base.:*(x::PowVariable, y::PowVariable) = PowVariable(x.pow + y.pow)
Base.copy(x::PowVariable) = x

@testset "value for GenericAffExpr" begin
expr1 = JuMP.GenericAffExpr([3, 2], [-5., 4.], 3.)
@test @inferred(JuMP.value(expr1, -)) == 10.
expr2 = JuMP.GenericAffExpr(Int[], Int[], 2)
@test typeof(@inferred(JuMP.value(expr2, i -> 1.0))) == Float64
@test @inferred(JuMP.value(expr2, i -> 1.0)) == 2.0
end
@testset "Expression" begin
@testset "value for GenericAffExpr" begin
expr1 = JuMP.GenericAffExpr([3, 2], [-5., 4.], 3.)
@test @inferred(JuMP.value(expr1, -)) == 10.
expr2 = JuMP.GenericAffExpr(Int[], Int[], 2)
@test typeof(@inferred(JuMP.value(expr2, i -> 1.0))) == Float64
@test @inferred(JuMP.value(expr2, i -> 1.0)) == 2.0
end

@testset "expression^3 and unary*" begin
m = Model()
x = PowVariable(1)
# Calls (*)((x*x)^6)
y = @expression m (x*x)^3
@test y.pow == 6
z = @inferred (x*x)^3
@test z.pow == 6
@testset "expression^3 and unary*" begin
m = Model()
x = PowVariable(1)
# Calls (*)((x*x)^6)
y = @expression m (x*x)^3
@test y.pow == 6
z = @inferred (x*x)^3
@test z.pow == 6
end
end

0 comments on commit 9f1c96f

Please sign in to comment.