Skip to content

Commit 1761a6e

Browse files
nalimilanararslan
authored andcommitted
Fix zero() error in 'missing' test (#24984)
The 'sparse' test defined zero(::String), which triggered a failure when it was run on before the 'missing' test on the same worker.
1 parent 3719905 commit 1761a6e

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

test/sparse/sparse.jl

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,14 +1135,19 @@ end
11351135
A = sparse(["a", "b"])
11361136
@test_throws MethodError findmin(A, 1)
11371137

1138-
# Support the case, when user defined `zero` and `isless` for non-numerical type
1139-
#
1140-
Base.zero(::Type{T}) where T<:AbstractString = ""
1141-
for (tup, rval, rind) in [((1,), ["a"], [1])]
1138+
# Support the case when user defined `zero` and `isless` for non-numerical type
1139+
struct CustomType
1140+
x::String
1141+
end
1142+
Base.zero(::Type{CustomType}) = CustomType("")
1143+
Base.isless(x::CustomType, y::CustomType) = isless(x.x, y.x)
1144+
A = sparse([CustomType("a"), CustomType("b")])
1145+
1146+
for (tup, rval, rind) in [((1,), [CustomType("a")], [1])]
11421147
@test isequal(findmin(A, tup), (rval, rind))
11431148
end
11441149

1145-
for (tup, rval, rind) in [((1,), ["b"], [2])]
1150+
for (tup, rval, rind) in [((1,), [CustomType("b")], [2])]
11461151
@test isequal(findmax(A, tup), (rval, rind))
11471152
end
11481153

0 commit comments

Comments
 (0)