Skip to content

Commit 3096fdb

Browse files
authored
Fix some deprecation warnings on 0.7 (#108)
1 parent 00cc39e commit 3096fdb

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

src/execution.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ elseif VERSION < v"0.7.0-DEV.484"
4141
# to the `current_module` approach if we're on a Julia version where that's
4242
# still possible.
4343
function run_result(b::Benchmark, p::Parameters = b.params; kwargs...)
44-
return eval(current_module(), :(BenchmarkTools._run($(b), $(p); $(kwargs...))))
44+
return Core.eval(@__MODULE__, :(BenchmarkTools._run($(b), $(p); $(kwargs...))))
4545
end
4646
function lineartrial(b::Benchmark, p::Parameters = b.params; kwargs...)
47-
return eval(@__MODULE__, :(BenchmarkTools._lineartrial($(b), $(p); $(kwargs...))))
47+
return Core.eval(@__MODULE__, :(BenchmarkTools._lineartrial($(b), $(p); $(kwargs...))))
4848
end
4949
else
5050
# There's a commit gap between `current_module` deprecation and `invokelatest` keyword
@@ -135,7 +135,7 @@ logistic(u, l, k, t, t0) = round(Int, ((u - l) / (1 + exp(-k * (t - t0)))) + l)
135135
const EVALS = Vector{Int}(undef, 9000) # any `t > length(EVALS)` should get an `evals` of 1
136136
for t in 1:400 (EVALS[t] = logistic(1006, 195, -0.025, t, 200)) end # EVALS[1] == 1000, EVALS[400] == 200
137137
for t in 401:1000 (EVALS[t] = logistic(204, -16, -0.01, t, 800)) end # EVALS[401] == 200, EVALS[1000] == 10
138-
for i in 1:8 (EVALS[((i*1000)+1):((i+1)*1000)] = 11 - i) end # linearly decrease from EVALS[1000]
138+
for i in 1:8 (EVALS[((i*1000)+1):((i+1)*1000)] .= 11 - i) end # linearly decrease from EVALS[1000]
139139

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

@@ -312,7 +312,7 @@ function generate_benchmark_definition(eval_module, out_vars, setup_vars, core,
312312
invocation = :($(Expr(:tuple, out_vars...)) = $(signature))
313313
core_body = :($(core); $(returns))
314314
end
315-
return eval(eval_module, quote
315+
return Core.eval(eval_module, quote
316316
@noinline $(signature) = begin $(core_body) end
317317
@noinline function $(samplefunc)(__params::$BenchmarkTools.Parameters)
318318
$(setup)

src/serialization.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function recover(x::Vector)
2424
length(x) == 2 || throw(ArgumentError("Expecting a vector of length 2"))
2525
typename = x[1]::String
2626
fields = x[2]::Dict
27-
T = eval(parse(typename))::Type
27+
T = Core.eval(@__MODULE__, parse(typename))::Type
2828
fc = fieldcount(T)
2929
xs = Vector{Any}(undef, fc)
3030
for i = 1:fc
@@ -71,9 +71,9 @@ function save(io::IO, args...)
7171
goodargs = Any[]
7272
for arg in args
7373
if arg isa String
74-
warn("Naming variables in serialization is no longer supported.\nThe name " *
75-
"will be ignored and the object will be serialized in the order it appears " *
76-
"in the input.")
74+
Compat.@warn("Naming variables in serialization is no longer supported.\n" *
75+
"The name will be ignored and the object will be serialized " *
76+
"in the order it appears in the input.")
7777
continue
7878
elseif !any(T->arg isa T, SUPPORTED_TYPES)
7979
throw(ArgumentError("Only BenchmarkTools types can be serialized."))

test/SerializationTests.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,11 @@ end
6464

6565
withtempdir() do
6666
tmp = joinpath(pwd(), "tmp.json")
67-
@test_warn "Naming variables" BenchmarkTools.save(tmp, "b", b)
67+
@static if VERSION >= v"0.7.0-DEV.2988"
68+
@test_logs (:warn, r"Naming variables") BenchmarkTools.save(tmp, "b", b)
69+
else
70+
@test_warn "Naming variables" BenchmarkTools.save(tmp, "b", b)
71+
end
6872
@test isfile(tmp)
6973
results = BenchmarkTools.load(tmp)
7074
@test length(results) == 1

0 commit comments

Comments
 (0)