Skip to content

Commit f2e2c09

Browse files
authored
Switch constants over to use test_scalar (#96)
* Switch constants over to use test_scalar * more tests of constants * Update test/rulesets/Base/base.jl
1 parent 63fe051 commit f2e2c09

File tree

1 file changed

+3
-15
lines changed

1 file changed

+3
-15
lines changed

test/rulesets/Base/base.jl

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -152,20 +152,8 @@
152152
rrule_test(identity, randn(rng, 4), (randn(rng, 4), randn(rng, 4)))
153153
end
154154

155-
@testset "Constants" begin
156-
function test_constant(f, x, expected)
157-
y, rule = frule(f, x)
158-
@test y == expected
159-
@test extern(rule(1)) == 0.0
160-
161-
y, rule = rrule(f, x)
162-
@test y == expected
163-
@test extern(rule(1)) == 0.0
164-
end
165-
test_constant(one, 5, 1)
166-
test_constant(one, -4.1, 1)
167-
168-
test_constant(zero, 5, 0)
169-
test_constant(zero, -4.1, 0)
155+
@testset "Constants" for x in (-0.1, 6.4, 1.0+0.5im, -10.0+0im, 0+200im)
156+
test_scalar(one, x)
157+
test_scalar(zero, x)
170158
end
171159
end

0 commit comments

Comments
 (0)