Skip to content

Commit

Permalink
Fix some deprecation warnings on 0.7 (#108)
Browse files Browse the repository at this point in the history
  • Loading branch information
ararslan authored May 25, 2018
1 parent 00cc39e commit 3096fdb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
8 changes: 4 additions & 4 deletions src/execution.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ elseif VERSION < v"0.7.0-DEV.484"
# to the `current_module` approach if we're on a Julia version where that's
# still possible.
function run_result(b::Benchmark, p::Parameters = b.params; kwargs...)
return eval(current_module(), :(BenchmarkTools._run($(b), $(p); $(kwargs...))))
return Core.eval(@__MODULE__, :(BenchmarkTools._run($(b), $(p); $(kwargs...))))
end
function lineartrial(b::Benchmark, p::Parameters = b.params; kwargs...)
return eval(@__MODULE__, :(BenchmarkTools._lineartrial($(b), $(p); $(kwargs...))))
return Core.eval(@__MODULE__, :(BenchmarkTools._lineartrial($(b), $(p); $(kwargs...))))
end
else
# There's a commit gap between `current_module` deprecation and `invokelatest` keyword
Expand Down Expand Up @@ -135,7 +135,7 @@ logistic(u, l, k, t, t0) = round(Int, ((u - l) / (1 + exp(-k * (t - t0)))) + l)
const EVALS = Vector{Int}(undef, 9000) # any `t > length(EVALS)` should get an `evals` of 1
for t in 1:400 (EVALS[t] = logistic(1006, 195, -0.025, t, 200)) end # EVALS[1] == 1000, EVALS[400] == 200
for t in 401:1000 (EVALS[t] = logistic(204, -16, -0.01, t, 800)) end # EVALS[401] == 200, EVALS[1000] == 10
for i in 1:8 (EVALS[((i*1000)+1):((i+1)*1000)] = 11 - i) end # linearly decrease from EVALS[1000]
for i in 1:8 (EVALS[((i*1000)+1):((i+1)*1000)] .= 11 - i) end # linearly decrease from EVALS[1000]

guessevals(t) = t <= length(EVALS) ? EVALS[t] : 1

Expand Down Expand Up @@ -312,7 +312,7 @@ function generate_benchmark_definition(eval_module, out_vars, setup_vars, core,
invocation = :($(Expr(:tuple, out_vars...)) = $(signature))
core_body = :($(core); $(returns))
end
return eval(eval_module, quote
return Core.eval(eval_module, quote
@noinline $(signature) = begin $(core_body) end
@noinline function $(samplefunc)(__params::$BenchmarkTools.Parameters)
$(setup)
Expand Down
8 changes: 4 additions & 4 deletions src/serialization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function recover(x::Vector)
length(x) == 2 || throw(ArgumentError("Expecting a vector of length 2"))
typename = x[1]::String
fields = x[2]::Dict
T = eval(parse(typename))::Type
T = Core.eval(@__MODULE__, parse(typename))::Type
fc = fieldcount(T)
xs = Vector{Any}(undef, fc)
for i = 1:fc
Expand Down Expand Up @@ -71,9 +71,9 @@ function save(io::IO, args...)
goodargs = Any[]
for arg in args
if arg isa String
warn("Naming variables in serialization is no longer supported.\nThe name " *
"will be ignored and the object will be serialized in the order it appears " *
"in the input.")
Compat.@warn("Naming variables in serialization is no longer supported.\n" *
"The name will be ignored and the object will be serialized " *
"in the order it appears in the input.")
continue
elseif !any(T->arg isa T, SUPPORTED_TYPES)
throw(ArgumentError("Only BenchmarkTools types can be serialized."))
Expand Down
6 changes: 5 additions & 1 deletion test/SerializationTests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ end

withtempdir() do
tmp = joinpath(pwd(), "tmp.json")
@test_warn "Naming variables" BenchmarkTools.save(tmp, "b", b)
@static if VERSION >= v"0.7.0-DEV.2988"
@test_logs (:warn, r"Naming variables") BenchmarkTools.save(tmp, "b", b)
else
@test_warn "Naming variables" BenchmarkTools.save(tmp, "b", b)
end
@test isfile(tmp)
results = BenchmarkTools.load(tmp)
@test length(results) == 1
Expand Down

0 comments on commit 3096fdb

Please sign in to comment.