Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix zero() error in 'missing' test #24984

Merged
merged 1 commit into from
Dec 8, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions test/sparse/sparse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1135,14 +1135,19 @@ end
A = sparse(["a", "b"])
@test_throws MethodError findmin(A, 1)

# Support the case, when user defined `zero` and `isless` for non-numerical type
#
Base.zero(::Type{T}) where T<:AbstractString = ""
for (tup, rval, rind) in [((1,), ["a"], [1])]
# Support the case when user defined `zero` and `isless` for non-numerical type
struct CustomType
x::String
end
Base.zero(::Type{CustomType}) = CustomType("")
Base.isless(x::CustomType, y::CustomType) = isless(x.x, y.x)
A = sparse([CustomType("a"), CustomType("b")])

for (tup, rval, rind) in [((1,), [CustomType("a")], [1])]
@test isequal(findmin(A, tup), (rval, rind))
end

for (tup, rval, rind) in [((1,), ["b"], [2])]
for (tup, rval, rind) in [((1,), [CustomType("b")], [2])]
@test isequal(findmax(A, tup), (rval, rind))
end

Expand Down