From 87a6d3e08dd89648501e5babf1e4b1c6dfd6d733 Mon Sep 17 00:00:00 2001 From: Robin Deits Date: Wed, 16 Aug 2017 18:11:15 -0400 Subject: [PATCH] fix a missing esc() --- .travis.yml | 2 -- src/macros.jl | 2 +- test/runtests.jl | 17 +++++++++++++++++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 04dcd99..9be64a0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,7 +30,5 @@ branches: #script: # - julia -e 'Pkg.clone(pwd()); Pkg.build("ConditionalJuMP"); Pkg.test("ConditionalJuMP"; coverage=true)' after_success: - # push coverage results to Coveralls - - julia -e 'cd(Pkg.dir("ConditionalJuMP")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())' # push coverage results to Codecov - julia -e 'cd(Pkg.dir("ConditionalJuMP")); Pkg.add("Coverage"); using Coverage; Codecov.submit(Codecov.process_folder())' diff --git a/src/macros.jl b/src/macros.jl index 0eb80a0..1e7f4a3 100644 --- a/src/macros.jl +++ b/src/macros.jl @@ -6,7 +6,7 @@ function _conditionalize_recursive!(ex::Expr) ex.args[i] = _conditionalize_recursive!(ex.args[i]) end if !(ex.args[1] ∈ (:(=>),)) - Expr(:call, :_conditional, ex.args[1], ex.args[2:end]...) + Expr(:call, :_conditional, esc(ex.args[1]), ex.args[2:end]...) else Expr(:call, ex.args...) end diff --git a/test/runtests.jl b/test/runtests.jl index e80a044..37f9d8a 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -4,6 +4,23 @@ using JuMP using Cbc using Base.Test +# Macro hygiene +module MacroHygieneTest + +using Base.Test +using ConditionalJuMP + +function f(x) + x + 1 +end + +@testset "macro hygiene" begin + x = 5 + @test @?(f(x) <= 0) == false +end + +end + @testset "bounds" begin m = Model() @variable m 1 <= x <= 3