Skip to content

Commit f1998b8

Browse files
committed
fix deprecated tests
1 parent 7735e45 commit f1998b8

File tree

2 files changed

+21
-14
lines changed

2 files changed

+21
-14
lines changed

test/deprecated.jl

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,37 @@
11
@testset "NO_FIELDS" begin
2-
@test (@test_deprecated NO_FIELDS) isa NoTangent
2+
# Following doesn't work because of some deprecate_binding weirdness with not printing
3+
# @test (@test_deprecated NO_FIELDS) isa NoTangent
4+
# So just test it gives the old behavour
5+
@test NO_FIELDS isa NoTangent
36
end
47

58
@testset "extern" begin
6-
@test extern(@thunk(3)) == 3
7-
@test extern(@thunk(@thunk(3))) == 3
9+
@test (@test_deprecated extern(@thunk(3))) == 3
10+
@test (@test_deprecated extern(@thunk(@thunk(3)))) == 3
811

9-
@test extern(Tangent{Foo}(x=2.0)) == (;x=2.0)
10-
@test extern(Tangent{Tuple{Float64,}}(2.0)) == (2.0,)
11-
@test extern(Tangent{Dict}(Dict(4 => 3))) == Dict(4 => 3)
12+
@test (@test_deprecated extern(Tangent{Foo}(x=2.0))) == (;x=2.0)
13+
@test (@test_deprecated extern(Tangent{Tuple{Float64,}}(2.0))) == (2.0,)
14+
@test (@test_deprecated extern(Tangent{Dict}(Dict(4 => 3)))) == Dict(4 => 3)
1215

1316
# with differentials on the inside
14-
@test extern(Tangent{Foo}(x=@thunk(0+2.0))) == (;x=2.0)
15-
@test extern(Tangent{Tuple{Float64,}}(@thunk(0+2.0))) == (2.0,)
16-
@test extern(Tangent{Dict}(Dict(4 => @thunk(3)))) == Dict(4 => 3)
17+
@test (@test_deprecated extern(Tangent{Foo}(x=@thunk(0+2.0)))) == (;x=2.0)
18+
@test (@test_deprecated extern(Tangent{Tuple{Float64,}}(@thunk(0+2.0)))) == (2.0,)
19+
@test (@test_deprecated extern(Tangent{Dict}(Dict(4 => @thunk(3))))) == Dict(4 => 3)
1720

1821
z = ZeroTangent()
19-
@test extern(z) === false
22+
@test (@test_deprecated extern(z)) === false
23+
24+
# @test_throws doesn't play nice with `@test_deprecated` so have to be loud
2025
dne = NoTangent()
2126
@test_throws Exception extern(dne)
22-
E = ChainRulesCore.NotImplementedException
23-
@test_throws E extern(ni)
27+
ni = @not_implemented("no")
28+
@test_throws ChainRulesCore.NotImplementedException extern(ni)
2429
end
2530

2631

2732
@testset "Deprecated: calling thunks should call inner function" begin
28-
@test_deprecated (@thunk(3))() == 3
29-
@test_deprecated (@thunk(@thunk(3)))() isa Thunk
33+
@test (@test_deprecated (@thunk(3))()) == 3
34+
@test (@test_deprecated (@thunk(@thunk(3)))()) isa Thunk
3035
end
3136

3237
@testset "Deprecated: Inplacable Thunk argument order" begin

test/runtests.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,6 @@ using Test
2121
include("rules.jl")
2222
include("rule_definition_tools.jl")
2323
include("config.jl")
24+
25+
include("deprecated.jl")
2426
end

0 commit comments

Comments
 (0)