Skip to content

Commit c89992a

Browse files
committed
=fix mistake in non-tuple output message
1 parent e21bf34 commit c89992a

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "ChainRulesTestUtils"
22
uuid = "cdddcdb0-9152-4a09-a978-84456f9df70a"
3-
version = "0.7.11"
3+
version = "0.7.12"
44

55
[deps]
66
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"

src/testers.jl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,14 @@ function test_rrule(
244244

245245
check_inferred && _test_inferred(pullback, ȳ)
246246
ad_cotangents = pullback(ȳ)
247-
ad_cotangents isa Tuple || error("The pullback must return (∂self, ∂args...), not $∂s.")
248-
msg = "The pullback should return 1 cotangent for the primal and each primal input."
249-
@test_msg msg length(ad_cotangents) == 1 + length(args)
247+
@test_msg(
248+
"The pullback must return a Tuple (∂self, ∂args...)",
249+
ad_cotangents isa Tuple
250+
)
251+
@test_msg(
252+
"The pullback should return 1 cotangent for the primal and each primal input.",
253+
(ad_cotangents) == 1 + length(args)
254+
)
250255

251256
# Correctness testing via finite differencing.
252257
# TODO: remove Nothing when https://github.com/JuliaDiff/ChainRulesTestUtils.jl/issues/113

test/testers.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,15 @@ struct MySpecialConfig <: RuleConfig{Union{MySpecialTrait}} end
548548
@test fails(() -> test_frule(foo, 2.1, 2.1))
549549
@test fails(() -> test_rrule(foo, 21.0, 32.0))
550550
end
551+
552+
@testset "rrule not returning a tuple" begin
553+
bar(x, y) = x + 3y
554+
function ChainRulesCore.rrule(::typeof(bar), x, y)
555+
bar_pullback(dy) = dy
556+
return bar(x,y), bar_pullback
557+
end
558+
@test fails(() -> test_rrule(bar, 21.0, 32.0))
559+
end
551560
end
552561

553562
@testset "structs" begin

0 commit comments

Comments
 (0)