Skip to content

Commit 74cf90d

Browse files
vtjnashKristofferC
authored andcommitted
test: silence @time macro test
Also move to a more appropriate file and fix `s/@time/@test` typo. (cherry picked from commit ccbdb91)
1 parent 641db33 commit 74cf90d

File tree

2 files changed

+21
-13
lines changed

2 files changed

+21
-13
lines changed

test/core.jl

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5080,19 +5080,6 @@ end
50805080
@test f17255(10000)[1]
50815081
GC.enable(true)
50825082

5083-
# PR #39133, ensure that @time evaluates in the same scope
5084-
function time_macro_scope()
5085-
@time time_macro_local_var = 1
5086-
time_macro_local_var
5087-
end
5088-
@test time_macro_scope() == 1
5089-
5090-
function timev_macro_scope()
5091-
@timev timev_macro_local_var = 1
5092-
timev_macro_local_var
5093-
end
5094-
@time timev_macro_scope() == 1
5095-
50965083
# issue #18710
50975084
bad_tvars() where {T} = 1
50985085
@test isa(which(bad_tvars, ()), Method)

test/misc.jl

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,27 @@ v11801, t11801 = @timed sin(1)
231231

232232
@test names(@__MODULE__, all = true) == names_before_timing
233233

234+
# PR #39133, ensure that @time evaluates in the same scope
235+
function time_macro_scope()
236+
try # try/throw/catch bypasses printing
237+
@time (time_macro_local_var = 1; throw("expected"))
238+
return time_macro_local_var
239+
catch ex
240+
ex === "expected" || rethrow()
241+
end
242+
end
243+
@test time_macro_scope() == 1
244+
245+
function timev_macro_scope()
246+
try # try/throw/catch bypasses printing
247+
@timev (time_macro_local_var = 1; throw("expected"))
248+
return time_macro_local_var
249+
catch ex
250+
ex === "expected" || rethrow()
251+
end
252+
end
253+
@test timev_macro_scope() == 1
254+
234255
# interactive utilities
235256

236257
struct ambigconvert; end # inject a problematic `convert` method to ensure it still works

0 commit comments

Comments
 (0)