Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In checking method table don't nest testsets #237

Merged
merged 1 commit into from
Jan 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "ChainRulesTestUtils"
uuid = "cdddcdb0-9152-4a09-a978-84456f9df70a"
version = "1.5.0"
version = "1.5.1"

[deps]
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
Expand Down
48 changes: 22 additions & 26 deletions src/global_checks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,37 +22,33 @@ was parametric, or `Union` if `Foo` was a type alias for a `Union`)
function test_method_signature end

function test_method_signature(::typeof(rrule), method::Method)
@testset "Sensible Constructors" begin
function_type = if method.sig <: Tuple{Any, RuleConfig, Type, Vararg}
_parameters(method.sig)[3]
elseif method.sig <: Tuple{Any, Type, Vararg}
_parameters(method.sig)[2]
else
nothing
end

@test_msg(
"Bad constructor rrule. `typeof(T)` used rather than `Type{T}`. $method",
function_type ∉ (DataType, UnionAll, Union)
)
function_type = if method.sig <: Tuple{Any, RuleConfig, Type, Vararg}
_parameters(method.sig)[3]
elseif method.sig <: Tuple{Any, Type, Vararg}
_parameters(method.sig)[2]
else
nothing
end

@test_msg(
"Bad constructor rrule. `typeof(T)` used rather than `Type{T}`. $method",
function_type ∉ (DataType, UnionAll, Union)
)
end

function test_method_signature(::typeof(frule), method::Method)
@testset "Sensible Constructors" begin
function_type = if method.sig <: Tuple{Any, RuleConfig, Any, Type, Vararg}
_parameters(method.sig)[4]
elseif method.sig <: Tuple{Any, Any, Type, Vararg}
_parameters(method.sig)[3]
else
nothing
end

@test_msg(
"Bad constructor frule. `typeof(T)` used rather than `Type{T}`. $method",
function_type ∉ (DataType, UnionAll, Union)
)
function_type = if method.sig <: Tuple{Any, RuleConfig, Any, Type, Vararg}
_parameters(method.sig)[4]
elseif method.sig <: Tuple{Any, Any, Type, Vararg}
_parameters(method.sig)[3]
else
nothing
end

@test_msg(
"Bad constructor frule. `typeof(T)` used rather than `Type{T}`. $method",
function_type ∉ (DataType, UnionAll, Union)
)
end

"""
Expand Down