Skip to content

Commit cf2bc6e

Browse files
committed
Add tests
1 parent 9abe813 commit cf2bc6e

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

test/rules.jl

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ cool(x, y) = x + y + 1
88
dummy_identity(x) = x
99
@scalar_rule(dummy_identity(x), One())
1010

11+
nice(x) = 1
12+
@scalar_rule(nice(x), Zero())
13+
1114
#######
1215

1316
_second(t) = Base.tuple_type_head(Base.tuple_type_tail(t))
@@ -31,11 +34,16 @@ _second(t) = Base.tuple_type_head(Base.tuple_type_tail(t))
3134
@test cool_methods == only_methods
3235

3336
frx, cool_pushforward = frule(cool, 1, dself, 1)
34-
@test frx == 2
35-
@test cool_pushforward == 1
37+
@test frx === 2
38+
@test cool_pushforward === 1
3639
rrx, cool_pullback = rrule(cool, 1)
3740
self, rr1 = cool_pullback(1)
38-
@test self == NO_FIELDS
39-
@test rrx == 2
40-
@test rr1 == 1
41+
@test self === NO_FIELDS
42+
@test rrx === 2
43+
@test rr1 === 1
44+
45+
frx, nice_pushforward = frule(nice, 1, dself, 1)
46+
@test nice_pushforward === 0
47+
rrx, nice_pullback = rrule(nice, 1)
48+
@test (NO_FIELDS, 0) === nice_pullback(1)
4149
end

0 commit comments

Comments
 (0)