Skip to content

Commit 32d7f93

Browse files
committed
Use function noncallable end
1 parent ea2cc8b commit 32d7f93

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

test/reduce.jl

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -176,18 +176,17 @@ end
176176
@test typeof(sum(Int8[])) == typeof(sum(Int8[1])) == typeof(sum(Int8[1 7]))
177177

178178
@testset "`sum` of empty collections with `init`" begin
179+
function noncallable end # should not be called
179180
@testset for init in [0, 0.0]
180181
@test sum([]; init = init) === init
181182
@test sum((x for x in [123] if false); init = init) === init
182-
@test sum(nothing, []; init = init) === init
183-
@test sum(nothing, (x for x in [123] if false); init = init) === init
183+
@test sum(noncallable, []; init = init) === init
184+
@test sum(noncallable, (x for x in [123] if false); init = init) === init
184185
@test sum(Array{Any,3}(undef, 3, 2, 0); dims = 1, init = init) ==
185186
zeros(typeof(init), 1, 2, 0)
186-
@test sum(nothing, Array{Any,3}(undef, 3, 2, 0); dims = 1, init = init) ==
187+
@test sum(noncallable, Array{Any,3}(undef, 3, 2, 0); dims = 1, init = init) ==
187188
zeros(typeof(init), 1, 2, 0)
188189
end
189-
# Note: We are using `nothing` in place of the callable to make
190-
# sure that it's not actually called.
191190
end
192191

193192
# check sum(abs, ...) for support of empty collections
@@ -218,18 +217,17 @@ end
218217
@test typeof(prod(Array(trues(10)))) == Bool
219218

220219
@testset "`prod` of empty collections with `init`" begin
220+
function noncallable end # should not be called
221221
@testset for init in [1, 1.0, ""]
222222
@test prod([]; init = init) === init
223223
@test prod((x for x in [123] if false); init = init) === init
224-
@test prod(nothing, []; init = init) === init
225-
@test prod(nothing, (x for x in [123] if false); init = init) === init
224+
@test prod(noncallable, []; init = init) === init
225+
@test prod(noncallable, (x for x in [123] if false); init = init) === init
226226
@test prod(Array{Any,3}(undef, 3, 2, 0); dims = 1, init = init) ==
227227
ones(typeof(init), 1, 2, 0)
228-
@test prod(nothing, Array{Any,3}(undef, 3, 2, 0); dims = 1, init = init) ==
228+
@test prod(noncallable, Array{Any,3}(undef, 3, 2, 0); dims = 1, init = init) ==
229229
ones(typeof(init), 1, 2, 0)
230230
end
231-
# Note: We are using `nothing` in place of the callable to make
232-
# sure that it's not actually called.
233231
end
234232

235233
# check type-stability

0 commit comments

Comments
 (0)