-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
/
deprecation_exec.jl
84 lines (66 loc) · 2.34 KB
/
deprecation_exec.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
using Test
module DeprecationTests # to test @deprecate
f() = true
# test the Symbol path of @deprecate
@deprecate f1 f
@deprecate f2 f false # test that f2 is not exported
# test the Expr path of @deprecate
@deprecate f3() f()
@deprecate f4() f() false # test that f4 is not exported
@deprecate f5(x::T) where T f()
# test deprecation of a constructor
struct A{T} end
@deprecate A{T}(x::S) where {T, S} f()
# test that @deprecate_moved can be overridden by an import
Base.@deprecate_moved foo1234 "Foo"
Base.@deprecate_moved bar "Bar" false
end # module
module Foo1234
export foo1234
foo1234(x) = x+1
end
# issue #21972
struct T21972
@noinline function T21972()
Base.depwarn("something", :T21972)
new()
end
end
@testset "@deprecate" begin
using .DeprecationTests
using .Foo1234
@test foo1234(3) == 4
@test_throws ErrorException DeprecationTests.bar(3)
# 22845
ex = :(module M22845; import ..DeprecationTests: bar;
bar(x::Number) = x + 3; end)
@test_warn "importing deprecated binding" eval(ex)
@test @test_nowarn(DeprecationTests.bar(4)) == 7
# enable when issue #22043 is fixed
# @test @test_warn "f1 is deprecated, use f instead." f1()
# @test @test_nowarn f1()
# @test_throws UndefVarError f2() # not exported
# @test @test_warn "f2 is deprecated, use f instead." DeprecationTests.f2()
# @test @test_nowarn DeprecationTests.f2()
# @test @test_warn "f3() is deprecated, use f() instead." f3()
# @test @test_nowarn f3()
# @test_throws UndefVarError f4() # not exported
# @test @test_warn "f4() is deprecated, use f() instead." DeprecationTests.f4()
# @test @test_nowarn DeprecationTests.f4()
# @test @test_warn "f5(x::T) where T is deprecated, use f() instead." f5(1)
# @test @test_nowarn f5(1)
# @test @test_warn "A{T}(x::S) where {T, S} is deprecated, use f() instead." A{Int}(1.)
# @test @test_nowarn A{Int}(1.)
# issue #21972
@noinline function f21972()
T21972()
end
@test_warn "deprecated" f21972()
@test_nowarn f21972()
end
f24658() = depwarn24658()
depwarn24658() = Base.firstcaller(backtrace(), :_func_not_found_)
@testset "firstcaller" begin
# issue #24658
@test eval(:(if true; f24658(); end)) == StackTraces.UNKNOWN
end