Skip to content

Commit

Permalink
misc tests for keytype, valtype and some find* functions (#32229)
Browse files Browse the repository at this point in the history
  • Loading branch information
kshyatt authored and fredrikekre committed Jun 5, 2019
1 parent 67f1a47 commit 6b45b6e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions test/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -865,8 +865,8 @@ for A in (rand(2), rand(2,3))
end
@test Array(values(A)) == A

@test keytype(A) == eltype(keys(A))
@test valtype(A) == eltype(values(A))
@test keytype(A) == keytype(typeof(A)) == eltype(keys(A))
@test valtype(A) == valtype(typeof(A)) == eltype(values(A))
end

# nextind and prevind
Expand Down
9 changes: 9 additions & 0 deletions test/arrayops.jl
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,14 @@ end

@test findall(in([1, 2]), 2) == [1]
@test findall(in([1, 2]), 3) == []

@test sort(findall(Dict(1=>false, 2=>true, 3=>true))) == [2, 3]

@test findall(true) == [1]
@test findall(false) == Int[]

@test findall(isodd, 1) == [1]
@test findall(isodd, 2) == Int[]
end
@testset "setindex! return type" begin
rt = Base.return_types(setindex!, Tuple{Array{Int32, 3}, Vector{UInt8}, Vector{Int}, Int16, UnitRange{Int}})
Expand Down Expand Up @@ -526,6 +534,7 @@ end
@test findfirst(!iszero, a) == 2
@test findfirst(a.==0) == 1
@test findfirst(a.==5) == nothing
@test findfirst(Dict(1=>false, 2=>true)) == 2
@test findfirst(isequal(3), [1,2,4,1,2,3,4]) == 6
@test findfirst(!isequal(1), [1,2,4,1,2,3,4]) == 2
@test findfirst(isodd, [2,4,6,3,9,2,0]) == 4
Expand Down

0 comments on commit 6b45b6e

Please sign in to comment.